1

I would like to be able to link to all entries that have a specific file included using P&T Assets. I have a page that displays the large version of an image which is called via this code:

{exp:assets:files file_id="{segment_2}"}
<img src="{url}" />
{/exp:assets:files}

So I know the file_id (and any other info stored by Assets), is there a way I can search through the entries looking for that Assets file_id?

0

You would have to do a custom query against the exp_assets_selections table. Currently there's no other way.

1
  • I've not used a custom query before so wasn't sure of the syntax, so thought of another solution.
    – Paul Frost
    Feb 13 '14 at 21:10
0

I wasn't sure how to build the custom query, but I worked out this solution, but it's probably not the most efficient, but it works. I'm searching for the filename in the channel entries custom field instead of the file_id. The original code now has an embed call to another template.

{exp:assets:files file_id="{segment_2}"}
<img src="{url}" />
{embed="includes/_related_entries" file="{filename}"}
{/exp:assets:files}

Then this is the embedded template (cf_images is the Assets custom field):

{exp:channel:entries channel="yxz" disable="categories|member_data|pagination" search:cf_images="={embed:file}"}
<p><a href="{comment_url_title_auto_path}" title=""></a>{title}</p>
{/exp:channel:entries}

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.