Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

RE: How to display Channel entry page?

The accepted solution doesn't seem to work for me. My "products/index" template has something like this:

{exp:channel:entries channel="products" limit="10" orderby="date" sort="desc"}
   <a href=/products/detail/{url_title}">{name}</a>
{/exp:channel:entries}

Then in "products/detail" template, I have something like this:

{exp:channel:entries channel="products" limit="1"}
   <h2>{name}</h2>
   <p>{description}</p>
{/exp:channel:entries}

The "products/detail" page always shows the same record (and when you look at the tag pair, it make sense I think). How is this template supposed to know which record specifically to access? What is it about {url_title} that hints to which entry to retrieve? Is there something I need to put in the tag pair to tell it to use the {url_title} segment?

share|improve this question
    
When ExpressionEngine is set-up in dynamic mode, segment_3 triggers the look-up of the entry_id, title, and other parameters. If the title or entry_id is not provided in segment_3, then turn dynamic-off, and trigger the look-up based on either {url_title} or {entry_id} in the {exp:channel:entries} tag, such as {exp:channel:entries channel="products" url_title="{segment_4}" dynamic="off" limit="1"} where segment would be whichever segment you are using, 2, 4, etc. Also, test with the {title} field it will provide a better idea of what's being pulled, if anything. –  nonprofit_tech Dec 29 '12 at 18:13
    
Just wanted to clarify that the last {segment} will trigger the lookup (not just {segment_3}). If it's an integer, then EE looks up by entry_id. If it's a string, it looks up by entry_url. –  Ryan Wheale 2 days ago
add comment

3 Answers

up vote 4 down vote accepted

Your code is correct, and should work. EE will always look at the third segment for either an entry_id or url_title, unless you specifically add dynamic="no" to your Channel Entries tag. So although the suggestions that you specify entry_id="{segment_3}" or url_title="{segment_3}" will work, they should not be necessary.

Note that in your first code sample, you should use {permalink="products/detail"} or {title_permalink="products/detail"} - more future-proof.

share|improve this answer
    
dynamic="no" was not included, so I'm not sure why it wasn't looking at segment_3. Yes, I'm actually using {permalink="products/detail"}. –  ExpressionEngineNewbie Dec 29 '12 at 18:16
add comment

You could add url_title="{segment_3}" to the channel entries tag in the products/detail template.

share|improve this answer
    
And dynamic="no" ad I would normally use and as above points out. –  Mark Dec 29 '12 at 18:01
add comment

On your details template, you can add two parameters to the entries loop that should solve this - add dynamic="no" and url_title="{segment_3}".

share|improve this answer
    
There are other options than url_title. Say I use entry_id, do I then just add entry_id="{segment_3}"? I'm actually using permalink for testing. –  ExpressionEngineNewbie Dec 29 '12 at 17:51
    
Using permalink in the products/index template. products/details seems to work when I use entry_id="{segment_3}". permalink="{segment_3}" did not work. Are these correct? –  ExpressionEngineNewbie Dec 29 '12 at 18:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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