1

First of all. Big thank you to Rob Sanchez. I'm using his plugin inside the query module to get a zoo-visitor member-picture and add it to a public profile page.

This is the query. field_id_37 contains something like {filedir_1}filename.jpg.

{exp:query limit="1" sql="
SELECT ct.author_id, ct.entry_id, ct.channel_id, cd.field_id_37
FROM exp_channel_titles ct
INNER JOIN exp_channel_data cd
USING(entry_id)
WHERE author_id = '{embed:lid}' AND ct.channel_id = '6' 
"}

{exp:parse_file_paths}
{field_id_37}
{/exp:parse_file_paths}

{/exp:query}

This works fine. The output is something like: http://mysite.com/picture/filename.jpg

I do need this information to create a link to the full picture. I'd like to show the thumb as well. And that is what this question is about. How do i change the path from http://mysite.com/picture/filename.jpg to http://mysite.com/picture/_thumb/filename.jpg?

If I didn't use the Query module, but simply the channel:entries tag the solution would be simple:

{field_id_37:thumb}

How can i rewrite the default path?

1

I ended up using the SQL REPLACE functionality:

{exp:query limit="1" sql="
SELECT ct.author_id, ct.entry_id, ct.channel_id,
REPLACE (cd.field_id_37, '\{filedir_1\}', '') AS myfile
FROM exp_channel_titles ct
INNER JOIN
exp_channel_data cd
USING(entry_id)
WHERE author_id = '{embed:lid}' AND ct.channel_id = '6' 
"}

{if myfile == ""}
    {site_url}/pic/nofile.gif
{if:else}
    {site_url}/picture/_thumb/{myfile}
{/if}

{/exp:query}

So, for future reference and for those interested. If you only want the full filename, without a path and you're using the query module... Use the REPLACE functionality.

If there is a better way to solve this, i'd love to hear it. I'll be keeping an eye out for other solutions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.