EllisLab text mark
Advanced Search
     
Link to single entry
Posted: 04 July 2012 01:22 AM   [ Ignore ]
Joined: 2010-10-17
181 posts

Hi there,

it’s been a while since working with Expression Engine and I’m a little ashamed of asking such a simple question, but here we go…

I’m displaying entries from all channels on the frontpage and want to link from there to a single entry’s template page.

I’ve setup template groups as well as a single-entry template for each channel e.g. products_group/product_single and I can’t get the link to work dynamically.

Right now I’m using:

<a href="{url_title_path='products_group/product_single'}">my-entry</a

Using this method I have to assign products_group manually, but I need this to be assigned dynamically on a per entry basis.

How can I achieve this?

Preload_replacements are not an option because I’m displaying entries from all channels on my index page. :(

 
Posted: 04 July 2012 03:40 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2010-10-17
181 posts

OK, I got this to work:

<a href="{relative_url}/product_single/{url_title}" title="{title}">{title}</a

Is this acceptible practice or is there a better way?

 
Posted: 05 July 2012 10:42 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi Heiko!

Indeed, it’s not exactly a “better” way, but it is completely automatic. You want to make use of comment_url_title_auto_path.

Here’s how it works:
Novigate to Admin->Channel Administration->Channels: Edit Preferences for one of your channels.

Look for the Path Settings Heading and the preference for “Comment Page URL”

In that preference, you supply the URL to this channels “single entry page”, don’t let “comment” in the name throw you off. So:

http://domain.dev/products_group/product_single/ 

Then, using the comment_url_title_auto_path will automatically build a URL based on the entry’s URL title, and the auto path will be specific and unique to each channel based on the value in “Comment Page URL” for each channel.

<a href="{comment_url_title_auto_path}" title="{title}">{title}</a

Will generate:

<a href="http://domain.dev/products_group/product_single/my_awesome_product" title="My Awesome Product">My Awesome Product</a

What do you think?

Cheers,

 

 Signature 

How may I help you?

 
Posted: 05 July 2012 11:57 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2010-10-17
181 posts

Fantastic! I’d never looked for that. smile

Thank you!

 
Posted: 06 July 2012 10:28 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2011-11-25
7174 posts

Hey Heiko,

I am glad to see that Dan was able to help you out!

If you need anything else, please just let me know by opening a new thread.

Cheers,

 Signature 

Recent version: EE 2.5.4 | Forum Module 3.1.10 | MSM 2.1.4 | 2.x Bug Tracker | Version Upgrade