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.

Question about categories.

November 07, 2012 12:58am

Subscribe [3]
  • #1 / Nov 07, 2012 12:58am

    manuqc

    115 posts

    Hello,

    I am starting to develop a new expression engine website for a chemical company and
    will like some advice on using categories, as to be honest I do not have much experience using.

    I’ll explain what I want to accomplish.

    The company have 5 divisions selling different products, but sometimes some of the products can be found in more than one division.

    Products belong to diferent categories, to give an example: cleaners, sanitizers, surface protection, etc.

    what I want is to do is a grid of categories, in which each one expands to show the products belonging to that category.

    Here is an image to help visualize what I mean. The css/javascript and html are working fine at this point, so I am in the part of translating this to EE code.

    https://dl.dropbox.com/u/4138955/drop3d/web/site_example_v001.JPG

    On that example I took one of the “categories” and circled it in red to show what I mean.

    ——-

    So this is what I did:

    a)Created a channel and called it “food_and_beverage_products_page” (this is meant to represent one of the five divisions).
    b)Created a Field group with custom fields for that channel (product name, description, image, etc)
    c)related the field groups with the channel
    d)Created a new category group called “Food and Beverage Products”
    e)created categories for that group, example: cleaners, sanitizers, surface protection, etc.


    So hoping I haven’t mixed you up until this point. What I ll like to do is to dynamically
    generate a category group (like the one circled in red in the image) and add products to that category (again like the image).

    things I am not sure how to do.

    1) How can I reuse a new product entry into a different category, lets say a product belongs to several categories.

    2) can I contain a category inside a channel tag? if so, how can I specify the exact category group, and the specific category inside this group I want to populate?

    3) can a div be dynamically generated on top of another such as an inline element would do, how can I wrap up the content, right now I have one chunk for the categories and one for the products channel, but both need to be generated at the same time.

    Currently my code looks like this:

    <div class="toggle">
    
    <h5 class="toggle_title">
    {exp:channel:categories channel="food_and_beverage_products_page" style="linear" show_empty="yes"}
    {category_name}
    {/exp:channel:categories}
    </h5>
    
    
    
                  <div class="toggle_content">
                    <ul class="productfeatures">
    
    {exp:channel:entries channel="food_and_beverage_products_page" disable="member_data" orderby="title" sort="asc"}
    <li><a href="http://{product_link}">{product_name}</a></li>
     {/exp:channel:entries}               
                    
                  </ul>
                  </div>
                </div>

    And here is another image showing it more graphically (sorry for the crappy drawing, but thought it might help to get it clear 😊

    https://dl.dropbox.com/u/4138955/drop3d/web/site_example_v002.JPG

    Thanks in advanced for your help

    I ll be looking forward your advice before proceeding.


    Regards,


    -Manuel

     

  • #2 / Nov 07, 2012 11:42am

    manuqc

    115 posts

    I’ve been trying to figure this out and I am wondering a couple things, that hope you can clarify to me.


    1) Is there a way to allow the client to chose which category to show dynamically, meaning
    to change the following values (in red) through a channel entry:

    {exp:channel:categories channel="food_and_beverage_products_page" style="linear" show_empty="yes" category_group=“1” show=“6”}
    {category_name}
    {/exp:channel:categories}

    2) How can I specify in the channel code, (like the following) to only display channel entries belonging to category group “1” - category “6” (as the example above)

    {exp:channel:entries channel="food_and_beverage_products_page" disable="member_data" orderby="title" sort="asc"}
    <li><a href="http://{product_link}">{product_name}</a></li>
    {/exp:channel:entries}


    Thank you very much for your time.

     

     

  • #3 / Nov 07, 2012 11:46am

    Rob Allen

    3114 posts

    You could use the category archive tag and embed channel entries inside that - see the wiki article for an example - http://expressionengine.com/wiki/Category_Archives_with_Custom_Fields

  • #4 / Nov 07, 2012 5:07pm

    Dan Decker

    7338 posts

    Check out Categories on Train:ee. Mike explains how to create a multifaceted navigation in ExpressionEngine using categories.

    And here is a tutorial on building a product comparison tool with ExpressionEngine.

    Cheers,

  • #5 / Nov 08, 2012 12:37pm

    manuqc

    115 posts

    Hey guys, thanks a lot for the help!

    sorry for the delay, I ve been testing stuff out..

    @bluedreamer, thanks that helped a lot, I went and purchased the module for “category-sorted-entries” good call.

    @Dan, Thank I watched those, and straightly bookmarked for reference! that surely helps.

    I actually starting doing some tests, and I am using a plugin I bought called MLS (multi language support) it does work nicely, although I am having some issues while trying to make it work with “category-sorted-entries” plugin.

    This is what I mean with quick example:

    I have the following working fine, although I will like to have this working on a multi lingual scenario

    {exp:category_sorted_entries channel="food_and_beverage_products_page"  show_empty="no" group_id="1" category="6"}
    
    {category}
    <h5>{category_name}</h5>
    <p>{/category}</p>
    
    <p><ul><br />
    {entries}<br />
    <li></p>
    
    <h5> {product_name_en}</h5>
    
    <p></li><br />
    {/entries}<br />
    </ul></p>
    
    <p>{/exp:category_sorted_entries}

    In the example above only the fields from category “6” are showing which is ok.
    live example here

    ——-

    I tried to set it up to work in a multi lingual setup and was suggested by the developer to use the following code:

    {exp:category_sorted_entries channel="food_and_beverage_products_page"  show_empty="no" group_id="1" category="6"}
    
    {category}
    <h5>{category_name}</h5>
    <p>{/category}</p>
    
    <p><br />
    <ul></p>
    
    <p><li><br />
    {embed="embeds/support_template_products" group="1" category="6"}<br />
    </li></p>
    
    <p></ul></p>
    
    <p><br />
    {/exp:category_sorted_entries}

    being the “support_template_products” the following:

    {exp:channel:entries channel="food_and_beverage_products_page" category_group="{embed:group}" show="{embed:category}"}
    
    <li>
    {bbr-mls:product_name}
    </li>
    
    {/exp:channel:entries}

    * As a note:

    {bbr-mls:product_name}

    does understand automatically in which language to show the content in regards to already declared custom fields for each language.

    And although the entry fields are showing, the problem I am having is that they are not only the ones belonging to the desired category (“6”) but rather from all categories combined.

    here is an example

    ———-


    Additional I ll have another question 😊

    is there a way in expression engine to share categories between category groups? Lets say

    product “xyz” belongs to category “1” from “category_group_1”. But it also belongs to category “1” from “category_group_2”. In which I’ll ideally like to have only one “category 1” but shared between two category groups.

    Reason being, because the company has many products that belong to a specific division, but that some times belong to another division as well, so I created a “category group” per division, containg categories like:  cleaners, sanitizers, disinfectant. but those categories will be likely to be used by another category group. Not wanting to creat similar categories twice.

    Hopefully all of this makes sense.

    Once again I really really appreciate your help 😊

    Regards

  • #6 / Nov 08, 2012 4:50pm

    Shane Eckert

    7174 posts

    Hey there manuqc,

    I am glad that Rob and Dan were able to help you.

    If I understand your question right, you would like a child category to have two parents? I do not think that is possible. I did some looking around for an Add-On that might allow something like that, but I am not seeing one.

    Is that what you are after?

    Thanks,

  • #7 / Nov 08, 2012 5:25pm

    manuqc

    115 posts

    Hello Shane,

    thanks for offering your help.  Yes I was looking for a way to have a category that can be shared across two category groups. If this is not possible like you say, might you propose me something else?

    and secondly, as the example I posted, I will simply like to be able to use the MLS extension inside the “category_sorted_entries” as I explained in the examples above. Its nothing fancy, just want some custom fields to output content from a specified category in a multilingual fashion using MLS extension.

    Hope I can get some help with this,

    thanks again

  • #8 / Nov 09, 2012 4:46pm

    Robin Sowell

    13255 posts

    As Shane notes, I don’t think there is a way to share a category across two groups in the way you mean.  But channels can have more than one category group assigned- would that work.  Or- do you need more than one category group for this?  There was a lot of overlap in the categories between divisions, so that may be a possibility. 

    And then I’d use either the archive tag or the addon- and not limit it by category.

    {exp:category_sorted_entries channel="food_and_beverage_products_page" show_empty="no"}

    That would make it dynamic- you wouldn’t need to put up one for every category.  You’ll need to tweak it to get the layout you want, but it is WAY less resource intensive plus it’s fully dynamic.  I would really reconsider setting it up that way.

    Looking at the addon- can you use some of the language variables to show the right content?  Preferably

    {product_name_{language_code}}

    If that won’t work inside the tag- perhaps use conditionals based on a language variable?  That should definitely work.

    And I hate to say it, but I would really try to avoid using an embed like that.  You’re looping it- which adds a lot of overhead.  An unacceptable amount IMO, given your example pages.

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

ExpressionEngine News!

#eecms, #events, #releases