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.

Using headers inbetween categories in navigation

March 15, 2011 10:45pm

Subscribe [3]
  • #1 / Mar 15, 2011 10:45pm

    Nelson Randella

    6 posts

    Hi,

    I have a number of categories which all fall within one channel and I need to be able to seperate them with specific headers. I know that I can make parent categories and as such they can be manipulated within the css to look like headers. I don’t want them to be links however.

    See the code that I have at the moment which is how I want the page to appear:

    <ul id="inner_pg_ul">
            <h3>C3 | Integrity for…</h3>
    <p>        <li><a href="http://{path=product/page/category/finance}id=current">Finance Functions</a></li><br />
            <li><a href="http://{path=product/page/category/performance}id=current">Performance Management</a></li><br />
            <li><a href="http://{path=product/page/category/reference_data_applications}id=current">Reference Data Applications</a></li><br />
            <li><a href="http://{path=product/page/category/warehouse}id=current">Rapid Warehouse Development</a></li><br />
            <li><a href="http://{path=product/page/category/policy}id=current">Policy Decision Making</a></li><br />
            <li><a href="http://{path=product/page/category/carbon}id=current">Carbon Reporting</a></li><br />
        </p><h3>Product Info</h3>
    <p>        <li><a href="http://{path=product/page/category/features}id=current">Features</a></li><br />
            <li><a href="http://{path=product/page/category/business_analyst}id=current">For the business analyst</a></li>  <br />
              <li><a href="http://{path=product/page/category/file}id=current">File formats</a></li>  <br />
               <li><a href="http://{path=product/page/category/data}id=current">Data store</a></li>  <br />
               <li><a href="http://{path=product/page/category/security}id=current">Security & auditing</a></li><br />
            <li><a href="http://{path=product/page/category/support_plan}id=current">Support Plan Options</a></li><br />
            </p><h3>TECHNICAL INFO</h3>
    <p>           <li><a href="http://{path=product/page/category/robust_development}id=current">robust development</a></li><br />
               <li><a href="http://{path=product/page/category/tech_spec}id=current">technical specifications</a></li><br />
          </ul>

    This doesn’t give the end user (my client) very much control within Expression engine.

    The code that I have without headers is:

    <ul id="inner_pg_ul">
    {exp:channel:categories channel="product_pages" style="nested" id="category-nav"}
        <a href="http://{path=">{category_name}</a>
    {/exp:channel:categories}
          </ul>

    This allows the user to input categories and place them where they wish, but it doesn’t have the headers within the navigation sidebar.

    Is the answer to have three channels and move the categories into these channels? Is there a better way so that there is only one channel?

    The web page is: http://www.c3integrity.com/index.php/product

    Many thanks

  • #2 / Mar 15, 2011 10:59pm

    Cheif

    626 posts

    IF you do make parent categories you can use something like:

    {if parent_id=="0"}
        <span class="parent">{category_name}</span>
    {if:else}
        <a href="http://{path=templategroup/{category_url_title}}">{category_name}</a>
    {/if}
  • #3 / Mar 16, 2011 2:17am

    Nelson Randella

    6 posts

    Thanks,

    I think I will opt for the parent category option. One further question, if I do use this method, how do I get each individual link within the category navigation to appear in the ‘current’ style.

    The code I have is this:

    <a href="http://{path=trial/page/category/{category_url_title}}id=current">{category_name}</a>

    However, this will give all the headings within the navigation sidebar the ‘current’ style on the index page for that channel and does nothing to change the style for the template page within that channel (i.e the specific category page). Does that make sense!!

    What am I doing wrong?

    Many thanks again

  • #4 / Mar 16, 2011 1:48pm

    Brandon Jones

    5500 posts

    Hi Nelson Randella,

    I wouldn’t say you’re doing anything wrong (well, other than specifying the same id for multiple elements) but rather this is a limitation of using categories in this manner. There are definitely front-end workarounds though, so I’m moving this over to the CodeShare Corner to get you further input. Thanks.

  • #5 / Mar 17, 2011 1:12am

    Nelson Randella

    6 posts

    Thanks,

    I will await further input. I can’t see a way round this myself as I want to use categories to input further pages and for them to appear on the navigation sidebar and also for them to have a ‘current’ style.

  • #6 / Mar 20, 2011 7:10pm

    Nelson Randella

    6 posts

    Hi, I still haven’t had any feedback from CodeShare Corner. If there is a solution to my problem I’d love to hear it.

    Thanks

  • #7 / Mar 21, 2011 2:40am

    Cheif

    626 posts

    The code I have is this:

    <a href="http://{path=trial/page/category/{category_url_title}}id=current">{category_name}</a>

    However, this will give all the headings within the navigation sidebar the ‘current’ style on the index page for that channel and does nothing to change the style for the template page within that channel (i.e the specific category page). Does that make sense!!

    Using:
    a href=”#” (if segment = “category_url_title”) class=“active” (//endif) {category_name}{category_name}


    *Forums remove if statement - you’ll have to decipher

    Unsure of testing the IF in ur situation but I’ve used this approach numerous times with various items.

  • #8 / Mar 21, 2011 9:17pm

    Nelson Randella

    6 posts

    Hi,

    Thanks for that, I did try and implement that code and manipulated it so that it works with the site I’m working on. It failed to differentiate between the different categories however. Maybe I’m missing something (this is my first ‘ExpressionEngine’ build so it’s very plausible!)

    The url is: http://www.c3integrity.com/index.php/trial

    The code is:

    <ul id="inner_pg_ul">
    {exp:channel:categories channel="trial" style="nested"}
    {if parent_id=="0"}
        <h3>{category_name}</h3>
    <p>{if:else}<br />
    <a href="http://{path=trial/page/category/{category_url_title}}">{category_name}</a><br />
    {/if}<br />
    {/exp:channel:categories}<br />
          </ul>

    As always, any help would be gratefully appreciated. I can’t believe that there isn’t a way to display a ‘current’ page using ExpressionEngine’s category navigation method.

    Thanks

  • #9 / Mar 22, 2011 12:40am

    Cheif

    626 posts

    How have u got your categories setup ?

    I use this on a site - use a flat cat setup so they’re all parents

    <awrapper>{WIF segment_3==category_url_title}class="active"{/WIF}>Title </awrapper>
  • #10 / Mar 22, 2011 1:24am

    Nelson Randella

    6 posts

    I have my parent categories set as a header, I need to be able to differentiate between the parent and child categories.

  • #11 / Mar 22, 2011 4:00am

    Cheif

    626 posts

    Lets re:cap, what exactly isnt working, looking at your eg, you’ve got the parent/child styling done ? is it just the active class you’re seeking ?

  • #12 / Mar 22, 2011 4:16am

    Cheif

    626 posts

    Jebus… I just looked at your code and your conversion of my supplied code didn’t really work, getting all manner of borked code out put.

    I’ve left off the opening “<” before the a tag below and attached screenshot:

    a href=”{path=templategroup/{category_url_title}}” {if segment_4=="{category_url_title}” class=“active {/if} >{category_name}</a>

  • #13 / Mar 23, 2011 10:03pm

    Nelson Randella

    6 posts

    So I eventually managed to get this thing to work, so if anyone else runs into this problem, the solution I found is:

    <a href="http://{path=template_path/{category_url_title}}">{category_name}</a>
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases