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.

Issue with child category descriptions

October 23, 2007 1:22pm

Subscribe [1]
  • #1 / Oct 23, 2007 1:22pm

    Michael Layne

    26 posts

    I have roughly 20 categories.  Some are parents, most are children:

    Architect
    | Architecture Students
    | Design

    Market Insights
    | Construction Forecasts
    | Economy and Finance
    | Housing

    etc…

    I have the following code on several templates (unique for each category):

    {exp:weblog:categories weblog="articles" show="{template_cat}" style="linear"}
    {category_description}
    {/exp:weblog:categories}

    On the ‘Market Insights’ template, the description displays as expected.  ANY children however are missing their descriptions.

    The following does display all descriptions:

    {exp:weblog:categories weblog="articles" show="not 19|20"}
    <a href="#{category_id}" rel="{category_id}" class="clist">{category_name}</a>
    {if category_description}
    <div id="com{category_id}" class="smdesc fragment">{category_description}  <a href="/{category_url_title}/class=nogo"><strong>GO »</strong></a></div>
    {/if}
    {/exp:weblog:categories}

    It’s as if the child needs its parent…  Thanks!

  • #2 / Oct 23, 2007 3:34pm

    Lisa Wess

    20502 posts

    You’re essentially correct, if you hide the parent, all the children will be hidden as well.  You could put in a feature request for this, or create a plugin to have the exact output you need.

  • #3 / Oct 23, 2007 4:29pm

    Michael Layne

    26 posts

    That seems a bit odd if you’re just requesting some information on a one specific category, but I sure appreciate the explanation.  It’s a bit of a negative against the advantages of parent/children paradigm for categories.  It might be a while before I whip out some plugins of my own… =) Thanks once again, Lisa.

  • #4 / Oct 23, 2007 4:31pm

    Lisa Wess

    20502 posts

    Depending on your need, you could use the Query module for a direct query as well, if you’re not ready to tackle a plugin. =)

    I haven’t played with this either, but you could potentially use some conditionals to hide categories based on ID, rather than the show= parameter.  Or rather, just use a conditional to show only certain categories; but that would be done per ID so isn’t all that scalable.

  • #5 / Oct 23, 2007 6:16pm

    Michael Layne

    26 posts

    The Query module was my solution here.  Perfect.  Thanks!

    I was about to roll my own… I forgot about that module (guess that means I really am a newbie…)

  • #6 / Oct 23, 2007 6:22pm

    Lisa Wess

    20502 posts

    Glad to see you got it resolved, Michael!  And hardly, I forget about features occasionally, too. Well, not entire modules… *grins*

  • #7 / Oct 23, 2007 6:29pm

    Lisa Wess

    20502 posts

    Michael, can we revisit this a little?  What is the purpose of the template? Is it to show only a single category? Perhaps a plain English explanation would be good, as you may not need a query.

    And why do you have a template per category?

  • #8 / Oct 23, 2007 7:09pm

    Michael Layne

    26 posts

    Yes.  A single category. Although you’ll see it displays related ones as well through

    {exp:categories}

    This site has “communities”, which is a unique repository of related: articles, companies, special reports, promotions, and partners, etc. (the list will grow after Phase I). “Market Insights” is a community with several “channels”(company slang, but in EE, sub-categories).  These channels need to live under their parent communities.

    The client wants ALL communities to be at the root level of the site.  They all have slightly different looks/color schemes, etc.  I actually think I’m doing a decent job with includes, variables, etc. but you can be the judge of that if we get to a point where I post some code.

    If you recall this:

    Market Insights
    | Construction Forecasts
    | Economy and Finance
    | Housing

    ... each one is a template. Only a couple of panels for now, but imagine several.  So, each panel is tagged to one or more communities. all the different weblogs are brought if they are tagged with the current category.  Making sense?  See attached screenshot

  • #9 / Oct 23, 2007 7:17pm

    Lisa Wess

    20502 posts

    What is the URL to the category page?  Just the part after index.php; I do not need an actual link. =)

  • #10 / Oct 23, 2007 8:41pm

    Michael Layne

    26 posts

    domain.com/market-insights/
    domain.com/construction-starts/
    domain.com/housing/
    ...etc.

    index.php is MIA due to our little friend .htaccess

  • #11 / Oct 23, 2007 8:48pm

    Lisa Wess

    20502 posts

    Ah, normally I would recommend this but you’re not using EE’s URLs at all; and so you’re losing about oh - well, a huge amount of the power and flexibility of ExpressionEngine.  I’m beginning to see why you need 100s of templates; and quite honestly, I would strongly recommend against your current route.  If you read through the Semantics series you’ll see just how much you’re giving up in terms of how ExpressionEngine works.

    Normally, for your situation, I’d recommend a single template with a weblog entries tag and the category heading tag; but given the kinds of URLs you are using, I’m not sure that would work for you.  You’ve really made quite a lot more work for yourself. =/

  • #12 / Oct 23, 2007 9:09pm

    Michael Layne

    26 posts

    Believe me, I hear you.  I’m new to EE but not new to web development.  This company has literally thousands of publications, products, services, etc. The rely on monetization for their site and have over 50 other sites just within this business unit.  One of their requirements is to follow the URL structure I referred to before.

    Did you see the screenshot?  I can’t take all the credit for the amount of work I’m doing… =/ I hope to prove to you that I AM using plenty of EE features that are making my life easier.

    Client is a large company. Many chiefs, lots of opinions about URLs, shades of green, font-size…you follow me.  Thanks again.

  • #13 / Oct 23, 2007 9:27pm

    Lisa Wess

    20502 posts

    Yes, I see the screenshot; and 90% of it could be done using the category heading tag and the weblog entries tag with related categories mode, but that would be in the normal URL structure. 

    I’m glad to hear that ExpressionEngine is making your work easier; that’s always a good thing, I’m just concerned about the scalability of the work that you’re doing. =)

  • #14 / Oct 23, 2007 10:39pm

    Michael Layne

    26 posts

    OK, you’re making me feel possibly pretty thick!  6 weeks ago, a company I contract with said, “you need to build a site for our client using this thing called ExpressionEngine”.  Not a ton of time to ramp up on it.  I got a thin requirements document and some PSDs.

    So, while I slowly climb out of the errors of my ways (and learn how EE should be used moving forward), lets say we have the following URL:

    http://example.com/index.php/site/index/category/work/

    Where is the physical template?  What’s it called? What is one (or two) piece(s) of EE code that would display entries from an ‘articles’ weblog and a ‘reports’ weblog tagged by ‘work’ category?

    I think the big crime here might have to do with their adherence to their old URL structure for SEO purposes.

    Again, my sincere thanks for pointing me i the right direction =)

  • #15 / Oct 24, 2007 12:18am

    Lisa Wess

    20502 posts

    Ok.  First, read Understanding EE URLs.

    Now, in your example - everything after index.php - there are several terms:

    site/index/category/work/

    site = {segment_1} = template group (not physical - in the database - Templates screen)
    index = {segment_2} = template name (not physical - in the database - Templates screen)
    category = {segment_3} = category URL indicator
    work = {segment_4} = category url title

    All of this is explained in the Semantics article on Displaying Categories, which I linked above.

    Now, by default, the Category Heading tag, and the Weblog Entries tag will show entries only from the category in the URL.  So you can use this one template to display *all of your categories* and the magic will restrict the entries shown by categories.  So, for your code, all you’d need at a minimum - to show titles from both weblogs, in any given category is this:

    {exp:weblog:entries weblog="articles|reports" limit="20" relaxed_categories="on"}
    {title}
    
    {/exp:weblog:entries}

    Then simply visit it with the URL you gave above, change out Segment 4 with various category URL titles, you’ll note the entries listed change according to the category in the URL.

    So go ahead, make a blank template, put the code here into it, and manually append the URLs.  Actually, let me make it easier on you.  Make a template in the site template group called learning_ee.

    {!-- Explaining how the Category Heading Tag works --}
    
    {exp:weblog:category_heading relaxed_categories="yes" weblog="articles|reports"}
    
    <h1>{category_name}</h1>
    
    {if category_description}
    {category_description}
    {/if}
    
    {/exp:weblog:category_heading}
    
    {!-- And the weblog entries tag --}
    
    {exp:weblog:entries weblog="articles|reports" limit="20" relaxed_categories="yes"}
    {title}: {categories}<a href="http://{path=">{category_name}</a>{/categories}
    
    {/exp:weblog:entries}
    
    {!-- And a path statement! --}
    <a href="http://{path=">View full list, without category restriction</a>

    Now, click “view rendered template”.  Click on some categories, you’ll see the list of entries change based on category - all that in one template.  =)

    Edited to add some EE comments and the category heading tag.

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

ExpressionEngine News!

#eecms, #events, #releases