ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

index.php/channel/category/entry-url-title

February 14, 2011 4:39am

Subscribe [3]
  • #1 / Feb 14, 2011 4:39am

    maxi

    220 posts

    Hello,

    I don’t seem to be able to have entries on the index page have URI’s with a structure like: index.php/channel/category/entry-url-title which links to a single entry template to show all the details.

    I would then like to have a template for “index.php/channel/category” to dynamically show all the entries in that category.

    Sounds simple, but I guess I got a bit rusty eheh 😊

    Thanks

  • #2 / Feb 14, 2011 9:52am

    Sue Crocker

    26054 posts

    Do you mean something like this?

    http://eehowto.com/index.php/howto/archives/category/howto

    See the list of categories on the right?

  • #3 / Feb 14, 2011 9:58am

    maxi

    220 posts

    Yeh but the entries should then have a the category in their url. In that example they have articles, and I’d like them to have howto

  • #4 / Feb 14, 2011 10:36am

    Sue Crocker

    26054 posts

    archives is my template name.. are you going to only have one category per entry?

  • #5 / Feb 14, 2011 10:45am

    maxi

    220 posts

    Yes only 1 category per entry

  • #6 / Feb 14, 2011 10:49am

    Sue Crocker

    26054 posts

    Then I’d use the Pages module and build out the url you like for your individual entries. This won’t help with the urls for the individual archive pages themselves..

  • #7 / Feb 14, 2011 10:56am

    maxi

    220 posts

    For each entry every time?

  • #8 / Feb 14, 2011 12:59pm

    Sue Crocker

    26054 posts

    Is channel an actual name of the channel, or a template name?

  • #9 / Feb 14, 2011 1:29pm

    maxi

    220 posts

    Channel meaning name of the channel, in my case ‘orologi’. And category as name of the category the entry belongs to, for example ‘rolex’.

    So I’d like to have index.php/orologi/rolex/title-of-the-entry

    And if I stop at /rolex/ I see all the entries belonging to that rolex category.

    And if at /orologi/ I see all the entries of the channel

  • #10 / Feb 14, 2011 4:59pm

    Barry Cogan

    291 posts

    Hi Maxi!

    I get the example of how that should work to you in a jiffy.

  • #11 / Feb 14, 2011 5:33pm

    maxi

    220 posts

    Great, cannot wait 😊

  • #12 / Feb 14, 2011 7:19pm

    Barry Cogan

    291 posts

    Hi Maxi,

    I have this set up using the following settings:

    * {site_url} = http://www.example.com/index.php

    * I made the template_group the default for the site.

    * I put the following test code into the index of the template_group mentioned above:

    {!--
    This code just shows basic /channel/category_url_title/url_title processing
    Assumes  this code is placed in the default index. If not, the segments will need to be incremented  
    Segment 1 = desired channel
    Segment 2 = category url title
    segment 3 = channel entry url title
    --}
    {exp:channel:entries channel="{segment_1}" {if segment_3 != ""} url_title="{segment_3}"{/if} }
    {if segment_3 != ""}
      {!-- We have an entry --}
      <h1>{title}</h1>
      
    {if:else}
      {!-- No entry found --}
      {categories}
      {if segment_2 != ""}
        {!-- We have a category --)
        {if category_url_title == "{segment_2}"}
        <a href="http://{site_url}/{channel_short_name}/{segment_2}/{url_title}">{entry_id}: {title}</a>
    
        {picture_1}
    
        {/if}
      {if:else}
         {!-- No category --}
        <a href="http://{site_url}/{channel_short_name}/{category_url_title}/{url_title}">{entry_id}: {title}</a>
    
        {picture_1}
    
      {/if}
      {/categories}
    {/if}
    {/exp:channel:entries}

    You should note that this will need to 404 checking to make it more robust.

    Hope this helps you out!

    Sincerely,
    Barry

  • #13 / Feb 14, 2011 8:47pm

    maxi

    220 posts

    Ohhh it looks really good, let me try it out and see 😊

  • #14 / Feb 15, 2011 9:23am

    maxi

    220 posts

    It works great! 😊

    Being the same template there are then 2 details that need to change:

    – The number of entries shown (only 6 on main page and all entries on category page)
    – The page title (to include details of category and entry)

    How to tweak that?

  • #15 / Feb 15, 2011 1:35pm

    Barry Cogan

    291 posts

    HI maxi,

    I am moving this post to the codeshare corner. As this kind of help is outside of the regular tech support. I will still continue to help you! 😊

    Change

    {exp:channel:entries channel="{segment_1}" {if segment_3 != ""} url_title="{segment_3}"{/if} }

    into:

    {exp:channel:entries channel="{segment_1}" {if segment_3 != ""} url_title="{segment_3}"{/if} {if segment_2 == ""} limit="3"{/if} }

    and you will get 6 entries when there is nothing in segment 2.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases