We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Need auto_path to point to a file?

How Do I?

marlborough1's avatar
marlborough1
14 posts
10 years ago
marlborough1's avatar marlborough1

I have a channel set up to store policy PDF documents. So - I have an entry say for ‘health and safety policy’ and a couple of bits of info, then I have a File field where the PDF can be uploaded and stored to a /uploads/policies folder.

All works fine, but I’d like to add search. I struggling to point the path correctly to the uploaded file. If I use {auto_path} then I don’t get the path to the PDF.

{exp:search:search_results} 

 <a href="http://{auto_path}">{title}</a>

{/exp:search:search_results}

I have made it work for a single channel by hard coding the Search Results URL in the Channel settings to the upload folder, and then using the {policy_document} field name instead of auto_path, but I need this to work across a number of channels with a number of different document fieldnames so this isn’t a good fix.

How can I make the {auto_path} return the correct full link to the PDF document?

Cheers!

       
Boyink!'s avatar
Boyink!
5,011 posts
10 years ago
Boyink!'s avatar Boyink!

You can’t…;) Or at least not without hacking some core files. Auto path is intended to be just a path to an EE template, not a specific file.

You’re going to have to build your own links in the search results. I’d be looking at some channel/fieldname naming schema that you could then use to dynamically build the link on the results page.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.