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.

Remove category URL last segment

March 09, 2014 5:34pm

Subscribe [2]
  • #1 / Mar 09, 2014 5:34pm

    Wabi Sabi Press

    8 posts

    I am using the code below to display a list of items all with the same category, which works. However the URL is not want I would like displayed. The URL shows as DOMAIN/store/products/category/ceramics/264

    This code is on the site index page and points to the store page: site/store/products/

    I would like to remove the /264

    How would I do this? I have Low Seg2Cat installed, but I’m not sure how to use it in this case?

    The category group is 26 and is called ‘ceramics’, however the category added to the group is also called ‘ceramics’ and is 264!

    The channel “promotional” has the ceramics group added to it under the Categories tab and the category ‘ceramics’ (264) is selected.

    Could the issue be the the category group / category?

    {exp:channel:entries channel="promotional" status="open" category="{last_segment}" limit="4"}
    <div class="item {if count == 1}active{/if}"> <!-- Start .item -->
    {promo_product_image}
    {image:url}
    {/promo_product_image}
    <div class="container">
    <div class="carousel-caption">
    <h1>{promo_main_title}</h1>
    {promo_product_description}
    {categories show_group="26|25|28"}
    <a href="http://{path=%27store/products%27}/{category_id}%22class=%22btn" class="btn btn-outline-white">View Details</a>
    {/categories}
    </div>
    </div>
    </div> <!-- End .item -->
    {/exp:channel:entries}

    I have also tried this code, but it does not remove the /264.

    {exp:channel:entries channel="promotional" status="open" category="{last_segment_category_id}" limit="4"}

    I would be most grateful for anyone’s help.

  • #2 / Mar 09, 2014 7:45pm

    ahmad saad

    364 posts

    Hi,

    u just need to remove the {category_id} from ur url so ur code will be:

    {categories show_group="26|25|28"}
    <a href="http://{path=%27store/products%27}%22class=%22btn" class="btn btn-outline-white">View Details</a>
    {/categories}

    this will give u DOMAIN/store/products/category/ceramics/

    and here u can remove the category param from {channel:entries} loop , EE will automatically show the entries belong the ceramics category.

    when u use Category URL Indicator “category”  there is no need for category param in ur loop.

    we usually use Seg2Cat when we paln to remove the Category URL Indicator “category”  to get more friendly url like DOMAIN/store/products/ceramics/

    to make this url works we add category=”{last_segment_category_id}” to {channel:entries} loop.

    I hope this will help u,

    Regard’s.

  • #3 / Mar 10, 2014 5:51am

    Wabi Sabi Press

    8 posts

    Hi ahmad saad,

    Many thanks for your kind help, Yes it worked as you said. And removing the {category_id} makes sense, I should have tried that.

    Best wishes
    Graham

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

ExpressionEngine News!

#eecms, #events, #releases