We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Display entries for a specific category

How Do I?

kurtclare's avatar
kurtclare
1 posts
10 years ago
kurtclare's avatar kurtclare

Hi,

I am new to EE and working on a personal website to sell my products. I have somewhat of a 3 step flow for displaying my products on 3 separate pages.

  1. Home - displays my featured product group. Individual links will go to page 2 below.
{exp:channel:entries channel="products" disable="member_data|pagination" dynamic="no" sort="asc" }
{title}

<a href="http://{path=site_index}products/{url_title}">view products</a>
{/exp:channel:entries}
  1. Products - displays all products within a specific category from the link in 1 above. Individual links will go to page 3 below.
{exp:channel:entries channel="items" disable="member_data|pagination" dynamic="no" sort="asc" }
{title}
{cf_item_photos}<div  url('{cf_item_photo}')"></div>{/cf_item_photos}

<a href="http://{path=site_index}items/{url_title}">view product</a>
{/exp:channel:entries}
  1. Product Details - displays the product details for a specific product from the link in 2 above.
Have not really worked on this page code as yet.

Page 1 works fine but I cannot get the products to display on page 2 correctly. It is displaying all products within the system and not just those based on the link click from page 1.

Appreciate any help for this.

Thanks

       
deswork's avatar
deswork
122 posts
10 years ago
deswork's avatar deswork

Have you tried removing dynamic=”no” from the channel entries?

       
wbdzynr's avatar
wbdzynr
137 posts
10 years ago
wbdzynr's avatar wbdzynr

You’re not defining a category group in Step 2, so it’s pulling all of the entries. You said Step 1 is showing your “featured product group”? You need to tell Step 2 what the product group (category) is, then add that to the channel entries tag - ie {exp:channel:entries channel="items" category_group="2"}

       
Noor M's avatar
Noor M
99 posts
10 years ago
Noor M's avatar Noor M

Am guessing that you are having category group called “Products” (with category id say, 1) and have various product categories defined inside it. Example categories and corresponding category ids can probably be Category id 1 : Furniture Category id 2 : Electronics Category id 3 : Computers etc.

You need to have a channel to store all the products, which I see you already have.

As you are displaying featured product categories on homepage, you can use GWCode Categories plugin to do that.

Step 1: Homepage

{exp:gwcode_categories
 channel="products"
    group_id="1"
    style="linear"
    status="Open"
    show_empty="yes"
}
    {if no_results}
    {if:else}
        {cat_name}

        <a href="http://{path=products/listing/{cat_url_title}}">view products</a>
    {/if}
{/exp:gwcode_categories}

Note that the path is pointing to products/listing (template group/template)

Step 2: Entries listing from a specific category

I did this using NSM Categories addon

{exp:nsm_categories:archive
    channel="products"
    category_group="1"
    enable="entries"
    orderby="date"
}

    {if category_url_title == '{segment_3}'} <!--Assuming that your category/sub-category url title shows up in segment 3-->
    
        {category_channel_entries}
            <ul>
              <li><a href="http://{entry_id_path=products/details}">{title}</a></li>
            </ul>
        {/category_channel_entries}
    
    {/if}
    
    {if no_results}There are no products in this category!{/if}

{/exp:nsm_categories:archive}

Step 3: Product Details

This is simple, as you will be using {exp:channel:entries} tag

{exp:channel:entries
 channel="products"
    category_group="1" <!--Important-->
    status="open|all-your-other-statuses-seperated-by-pipe-character"
    disable="member_data|pagination"
    dynamic="no"
    sort="asc"
}

All your custom fields and markup goes in here.

{/exp:channel:entries}

Keep us posted

       
Noor M's avatar
Noor M
99 posts
10 years ago
Noor M's avatar Noor M

If product details page doesn’t show up correctly, you can get rid of dynamic=”no” parameter in the product details page.

       
Noor M's avatar
Noor M
99 posts
10 years ago
Noor M's avatar Noor M

Seems like channel categories archive tag is limited!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.