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.

I have a single entry url like site.com/forum/answers/12272 and would like to have the url_title appended like site.com/forum/answers/12272/how-big-is-a-carp. Anyone got an idea how to do this please? I'm stumped.

Thank you...

share|improve this question
    
ellislab.com/expressionengine/user-guide/modules/channel/… is that what you wanna do ? –  Simon Dec 27 '12 at 22:10
    
you should accept an answer so that people know a solution was found. –  nonprofit_tech Dec 29 '12 at 12:32

4 Answers 4

You can use the {url_title} variable. That is assuming that you are actually using ExpressionEngine channels and not forums.

You don't actually need the entry_id in the url, the url could just be

site.com/forum/answers/how-big-is-a-carp

But if you wanted to keep, the entry_id, you can build the url on the template like:

site.com/forum/answers/{entry_id}/{url_title}

The process should be similar for forums, but I'd assume the tags/variables maybe different.

share|improve this answer
    
Thanks for the reply, much appreciated. I should have been clearer, what I'm after is if someone goes to site.com/forum/answers/12272, that site.com/forum/answers/12272/how-big-is-a-carp is rendered. –  user1070143 Dec 27 '12 at 22:28
    
That's the response, I provided. You need to change the template code, for the link. As, I mentioned, it probably reads site.com/forum/answers/{entry_id} and you want it to read site.com/forum/answers/{entry_id}/{url_title} What I don't know is if you are actually using Channels or the Forums Module. The forums module would be different. You can add extra segments after the primary (which in this case is the {entry_id} and still have dynamic addressing. This means you can just place {url_title} after the code that renders the link. –  nonprofit_tech Dec 27 '12 at 22:44

I came up with:

{if segment_4 == ""} {exp:channel:entries limit="1" entry_id="{segment_3}" disable="categories|category_fields|custom_fields|member_data|pagination"} {redirect='forum/answers/{entry_id}/{url_title}'} {/exp:channel:entries} {/if}

share|improve this answer
    
Unless there are cases where {segment_4} isn't empty, this check wastes resources. On the template that renders the initial url, make the <a href=""> go to forum/answers/{entry_id}/{url_title} that will always place the {url_title} after the {entry_id}, not require an {if} statement and not force a redirect. –  nonprofit_tech Dec 27 '12 at 22:51

Are you saying that what you want is that if the user types one address into their browser bar, a different thing is displayed there after that request is sent to the server?

If you want to actually change the URL that the user sees, then one (not very good) option is to mess around with your .htaccess file to create a rewrite. Another, possibly better option is to use a redirect in your template code, which goes into effect if the extra section of the URI isn't there.

Check out http://ellislab.com/expressionengine/user-guide/development/reference/functions.html#redirect-location-string

I'm afraid that without a more in depth question or example of what you're trying to do it's difficult to understand what you want, exactly... :S

share|improve this answer
up vote 0 down vote accepted

Thanks for the help everyone @nonprofit_tech. I'm using the entries and comment module to build a forum and want the urls of single entry pages formated like site.com/forum/answers/{entry_id}/{url_title}.

I'm intending to use link rel="canonical" href="{path='{segment_1}/{segment_2}/{segment_3}/{segment_4}'}" so that the full url (site.com/forum/answers/{entry_id}/{url_title}) gets indexed by Google. As the entries module is looking at segment_3 to return the entry, it leaves me free to tweak segment_4 for better seo.

I came up with {if segment_4 == ""} {exp:channel:entries limit="1" entry_id="{segment_3}" disable="categories|category_fields|custom_fields|member_data|pagination"} {redirect='forum/answers/{entry_id}/{url_title}'} {/exp:channel:entries} {/if} to guard against segment_4 being missing.

I'm concerned that if Google bot traverses the url it would see the same content at site.com/forum/answers/{entry_id} and site.com/forum/answers/{entry_id}/{url_title}, hence the redirect and the canonical tag

share|improve this answer

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.