ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

{file3_dir} appears on sql query

March 14, 2011 12:08am

Subscribe [3]
  • #1 / Mar 14, 2011 12:08am

    overtoner

    20 posts

    I came across a similar error on this thread:
    http://ellislab.com/forums/viewthread/163987/

    But the solution there was to change the field type to file - my field type is that already.

    Here’s the sql query:

    {exp:query sql="SELECT `exp_channel_titles`.*, `exp_channel_data`.*
    FROM (`exp_channel_titles`) LEFT JOIN `exp_channel_data` ON `exp_channel_titles`.`entry_id` = `exp_channel_data`.`entry_id`
    WHERE exp_channel_titles.channel_id like'4'
    AND exp_channel_data.field_id_19 not like'0'
    AND exp_channel_data.field_id_19 > '{current_date}’
    AND exp_channel_titles.status not like ‘closed’
    AND exp_channel_titles.site_id like ‘1’
    AND ((exp_channel_titles.status like ‘Top Story’) OR (exp_channel_titles.status like ‘Featured Top Story’))
    ORDER BY `exp_channel_data`.`field_id_19` asc LIMIT 6”
    }
    {field_id_16}


    {/exp:query}

    The result is showing up as
    {fieldir_3}image1.jpg
    {fieldir_3}image2.jpg

    Any ideas on how to properly parse the filedir_3 diretory would be great.

    Moved to CodeShare Corner by Moderator

  • #2 / Mar 14, 2011 10:44am

    Sue Crocker

    26054 posts

    Hi, overtoner. What I do is create a global variable for filedir_3 and point it to the path to your images. I’m assuming you mean filedir instead of fielddir.

  • #3 / Mar 14, 2011 12:04pm

    Mark Bowen

    12637 posts

    As Sue has mentioned that’s definitely one way to do it although if your file upload prefs change for any reason then you will need to update those variables. Not a major worry but if you are worried about it then you could try out this plugin I just very quickly created called Parse Filedirectories.

    Hopefully should work for you.

    Best wishes,

    Mark


    P.S. At some point in the near future I will delete the plugin from this post as I’ve just submitted it to devot:ee. Not too sure how long it takes for them to show up on there though so for now will leave it in this post. I will update the post with the link to the add-on at devot:ee as soon as it is on there though.

  • #4 / Mar 14, 2011 12:17pm

    overtoner

    20 posts

    Mark, I will give that a shot.

    Sue, your solution did not work.  If I refer to https://ellislab.com/asset/images/ent-partner-work/ directly - then the global variable shows.  Otherwise - the result is still the same.

  • #5 / Mar 14, 2011 2:49pm

    overtoner

    20 posts

    Mark - you solution worked, but how can I take that and apply it into another plugin:

    {exp:ce_img:make src="{field_id_16}” max_width=“110” max_height=“110” crop=“yes”}
    {made}
    {/exp:ce_img:make}

  • #6 / Mar 14, 2011 3:33pm

    Mark Bowen

    12637 posts

    Mark - you solution worked, but how can I take that and apply it into another plugin:

    {exp:ce_img:make src="{field_id_16}" max_width="110" max_height="110" crop="yes"}
    {made}
    {/exp:ce_img:make}

    Ah well you didn’t mention that at the beginning now did you? 😉

    Try downloading the file above again (I’ve just updated it) and change your code to the following :

    {exp:ce_img:make
            src="{exp:parse_filedirectories}{field_id_16}{/exp:parse_filedirectories}"
            max_width="110"
            max_height="110"
            crop="yes"
            parse="inward"}
    {made}
    {/exp:ce_img:make}

    Hopefully that should then work. Let me know how you get on with it.

    Best wishes,

    Mark

  • #7 / Mar 14, 2011 5:46pm

    overtoner

    20 posts

    hmm, nothing is appearing within the ce_img tags

    {made} does not show up.

  • #8 / Mar 14, 2011 6:36pm

    Mark Bowen

    12637 posts

    I just tried this using that same image plugin on my install and although admittedly I didn’t have access to the same SQL query as you it did parse the URL for me correctly.

    Did you make sure you added the parse=“inward” parameter to the ce_img plugin tag as it won’t work without that.

    Best wishes,

    Mark

  • #9 / Mar 14, 2011 9:44pm

    overtoner

    20 posts

    yes - the parse inward is there.

  • #10 / Mar 15, 2011 9:24am

    Mark Bowen

    12637 posts

    Hmm I’m a bit lost as to what to say then, sorry.

    If you try just this in a template then what do you get?

    {exp:parse_filedirectories}https://ellislab.com/asset/images/ent-partner-work/image1.jpg{/exp:parse_filedirectories}

    Just want to make sure the new version of the plugin is doing its job correctly. If it is then I’m really not too sure why it isn’t working in your case because as mentioned I’ve tried this with a SQL query in exactly the same way as you are doing (albeit with a different query although that really shouldn’t matter as we both come out with a URL at the end of it) and it works fine in my tests.

    Best wishes,

    Mark

  • #11 / Mar 15, 2011 9:26am

    Mark Bowen

    12637 posts

    Also one other thing. As Sue asked before what exactly are you getting brought back from your query? Are you getting {fieldir_3} or https://ellislab.com/asset/images/ent-partner-work/. Is the first one a typo or is that what you are getting back from the query?

    Best wishes,

    Mark

  • #12 / Mar 15, 2011 11:30am

    overtoner

    20 posts

    ok, below is the whole query and result.  (swapped out my actual domain with mydomain)

    If I hard code one of the parsed directory results in the ce_img tag - it does resize.


    {exp:query sql="SELECT `exp_channel_titles`.*, `exp_channel_data`.*
    FROM (`exp_channel_titles`) LEFT JOIN `exp_channel_data` ON `exp_channel_titles`.`entry_id` = `exp_channel_data`.`entry_id`
    WHERE exp_channel_titles.channel_id like'4'
    AND exp_channel_data.field_id_19 not like'0'
    AND exp_channel_data.field_id_19 > '{current_date}’
    AND exp_channel_titles.status not like ‘closed’
    AND exp_channel_titles.site_id like ‘1’
    AND ((exp_channel_titles.status like ‘Top Story’) OR (exp_channel_titles.status like ‘Featured Top Story’))
    ORDER BY `exp_channel_data`.`field_id_19` asc LIMIT 6”
    }

    {exp:parse_filedirectories}{field_id_16}{/exp:parse_filedirectories}

     

    {exp:ce_img:make
    src="{exp:parse_filedirectories}{field_id_16}{/exp:parse_filedirectories}”
          max_width=“110”
          max_height=“110”
          crop=“yes”
          parse=“inward”}
    {made}
    {/exp:ce_img:make} 
    hi2
    {/exp:query}

    http://www.MYDOMAIN.com/article_images/bandapps1.jpg

    hi2 http://www.MYDOMAIN.com/article_images/watoto.jpg

    hi2 http://www.MYDOMAIN.com/article_images/drowsy_logo.jpg

    hi2 http://www.MYDOMAIN.com/article_images/garbagecantata.jpg

    hi2 http://www.MYDOMAIN.com/article_images/Alan_athighland2.jpg

    hi2 http://www.MYDOMAIN.com/article_images/MWS_LOGO.jpg

    hi2

  • #13 / Mar 15, 2011 11:52am

    Mark Bowen

    12637 posts

    I’m a bit confused from the code above, not sure if it means you have it working or not?

    If not then can you place just a simple query like this in a template :

    {exp:query sql="
            SELECT field_id_16
            FROM exp_channel_data
            WHERE field_id_16 != ''
            "}
    {field_id_16}
    
    {/exp:query}

    What do you get when you do that?

    Also one other question. When you view the source output the results don’t have any formatting around them do they? They should just be literally links (albeit links that won’t work) but just links and shouldn’t have any formatting around them such as paragraph tags and the like. Can you confirm that is the case here.

    Best wishes,

    Mark

  • #14 / Mar 15, 2011 12:24pm

    overtoner

    20 posts

    ok, I simplified it to your code - I have a lot more in my query because I’m using more of the fields - I don’t only need the file field.

    Your results came out the same as my original issue:
    {fieldir_3}image1.jpg

    And if I add the parsed tag:
    {exp:parse_filedirectories}{field_id_16}{/exp:parse_filedirectories}
    The result is:
    http://www.mydomain.com/article_images/image1.jpg

    And the if I throw this in:

    {exp:ce_img:make
    src="{exp:parse_filedirectories}{field_id_16}{/exp:parse_filedirectories}”
          max_width=“110”
          max_height=“110”
          crop=“yes”
          parse=“inward”}
    {made}
    {/exp:ce_img:make} 

    The result to this section is blank.

  • #15 / Mar 15, 2011 12:36pm

    Mark Bowen

    12637 posts

    Aha!! 😉

    I didn’t see them before as you’re not surrounding your code blocks above with the [ code ] pair so more difficult to see but it looks like you are getting curly quotes introduced into your code.

    Try deleting all the quotes in all the parameters and type them back in again by hand. That should hopefully do it.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases