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.

Category in Single Entry URL

December 08, 2008 8:16am

Subscribe [1]
  • #1 / Dec 08, 2008 8:16am

    Cam

    5 posts

    Each entry in my_weblog is assigned only to 1 category. Is it possible that the single entry urls have their assigned category in them.

    http://www.example.com/index.php/template_group/template/category/category_url_title/single_entry_url ??

    preferably:
    http://www.example.com/index.php/template_group/category_url_title/template/single_entry_url ??

  • #2 / Dec 08, 2008 9:16am

    Cam

    5 posts

    So I managed to achieve ‘something’.

    This page shows multiple entries but filtered by category:

    <a href="http://www.example.com/index.php/my_template_group/category/category_id/">http://www.example.com/index.php/my_template_group/category/category_id/</a>

    Now I want to take that category to the next template so that I know if the user has filtered by category or not:

    <a href="http://{path=my_template_group/template/{url_title}}/{segment_3}">Link Title</a>

    Can now use segment_3 in the next template as it will be segment_4 in the templates URL and can use Prev and Next entry within a category or not:

    {exp:weblog:entries}
    {if segment_4 != ''}
         {exp:weblog:prev_entry category="{categories}{category_id}|{/categories}"}<a href="http://{path="><span>Prev Entry</span></a>{/exp:weblog:prev_entry}
         {exp:weblog:next_entry category="{categories}{category_id}|{/categories}"}<a href="http://{path="><span>Next Entry</span></a>{/exp:weblog:next_entry}
    {if:else}
         {exp:weblog:prev_entry}<a href="http://{path="><span>Prev Entry</span></a>{/exp:weblog:prev_entry}
         {exp:weblog:next_entry}<a href="http://{path="><span>Next Entry</span></a>{/exp:weblog:next_entry}
    {/if}
    {/exp:weblog:entries}


    However the URL structure is not the nicest.

  • #3 / Dec 08, 2008 6:54pm

    Cam

    5 posts

    This work but the URL’s are not in the best order. Am I missing something with URL segments? Is there a better way to achieve what I am doing?

    I am going to try and make it all work with URLs like this:
    http://www.example.com/index.php/my_template_group/template/single_entry/#category as this is a little bit nicer

    URL segments don’t like the hash at the moment, it doesn’t pick up {segment_4} is “#category” but I’m going to try to get it to work

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

ExpressionEngine News!

#eecms, #events, #releases