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.

Category display hosed after 1.6 update

June 24, 2007 4:48pm

Subscribe [1]
  • #1 / Jun 24, 2007 4:48pm

    g0t035

    45 posts

    Our site uses a template, “ctp” (category template page) which uses PHP and MySQL to display a list of subcategories of the current category.

    A typical URL that uses this template: http://www.omg.zzz/index.php/templategroup/ctp/C5/

    Clicking on a category name would take the user to another template (“inside”) which would then display the posts in that category.

    With the 1.6 update, this no longer displays anything but triangle images we used as bullets for each category.

    Help!

    Here is the code that displayed the subcats. It is the only practical way we could figure out at the time that would get us the subcategories of a category.

    
    									
  • #2 / Jun 24, 2007 4:58pm

    Robin Sowell

    13255 posts

    There was a bug that would affect new categories created post-1.6 update.  To see if it may be a factor- go to ‘admin- utilities- mysql manager’- browse the tables.  How many rows do you have for the exp_categories table?  How many do you have for the exp_category_field_data table?

    Also- what build are you running?  Should show in the footer- has been one 1.6 bug fix build out already.

  • #3 / Jun 24, 2007 5:08pm

    g0t035

    45 posts

    We have entered no new categories after the update.

    Build = 20070622

    Both of the tables you mentioned have 44 rows.

  • #4 / Jun 24, 2007 5:21pm

    Robin Sowell

    13255 posts

    Hm- there’s a fair bit going on in that template, so let’s do some reduction testing.  Might want to create a test template for it.  First- let’s make sure the category tag is working ok (is on mine- just tested)- try:

    {exp:weblog:categories weblog="blog" style="linear"}
    
    {if no_results}
    {redirect="templategroup/errortpl"}
    {/if}
    
    {category_name} - {category_id}
    
    
    {/exp:weblog:categories}

    NOTE- I added a weblog parameter in my test- it’s required unless you only have one weblog.  Now- no reason this shouldn’t work- but let’s make sure before proceeding.

  • #5 / Jun 24, 2007 5:29pm

    g0t035

    45 posts

    Thanks Robin.

    Your snippet appears to work in a test template.

    It produces results like these:

    About - 5
    Contact Information - 14
    Leadership & Management - 15
    Member List - 38
    Press Room - 16
    Web Site Information - 11

    ...and so on.

  • #6 / Jun 24, 2007 5:31pm

    Robin Sowell

    13255 posts

    Also- I’m not really understanding your code.  You’re limiting the category tag to only show the category currently indicated in the url- via the show parameter.  Then you’re nesting a query inside it- but the query doesn’t use any of the variables that would be produced via the cat tag- and instead uses the category indicated in the url.  As far as I can spot- there’s no reason for nesting it at all.  (And if you are going to nest it in order to achieve the effect, I’d probably use the category heading tag instead- as it would be less resource intensive.  But since there isn’t a reason to nest it in the first place, why not just use the query all by iteself?)

    ETA- oops, we cross posted.  I definitely want to spot it if there’s a bug, but I think for your particular needs, we should take a step back and figure out what your ultimate goal is- and how to best achieve it.  From here- it’s looking like the best way is to simply use the query module all by iteself.  Will that work for you?  Looks like it should.

  • #7 / Jun 24, 2007 5:57pm

    Derek Jones

    7561 posts

    Category related tags are being a bit variable-cannabalistic after the addition of category custom fields.  In other words, the tag is parsing your query module’s tags as its own variables, and since there is no information for them, removing them.  I have tweaked this internally so that it is more discrete about which variables it grabs (i.e. only existing category field variables, and not all template variables), and the fix will be released in the next few days in a Build update.  For a temporary solution you can put your query in an embedded template and pass the $seg variable to it by way of an embed variable.

  • #8 / Jun 24, 2007 6:05pm

    g0t035

    45 posts

    since there isn’t a reason to nest it in the first place, why not just use the query all by iteself?

    To start, I have to get the ID of the current category in order to find all the subcategories that have this ID as their parent.

    If I’m to use {category_id} in the query, wouldn’t it need to be nested within a category tag?

    The goal is to list the subcategories of the current category, with each listed item hyperlinked to another template that displays the posts in the clicked subcategory.

    It’s worked well until the update, although if there’s a less resource intensive way to do it, then let’s do it.

    So I scrapped the PHP block. Now I’m trying to figure out how to make this work:

    {exp:query sql="SELECT cat_name, cat_id, cat_description FROM exp_categories WHERE parent_id = '{category_id}' ORDER BY cat_name"}
  • #9 / Jun 24, 2007 7:36pm

    Robin Sowell

    13255 posts

    Looks like Derek has the 1.6 parse issue squared- but yep, I’d go a different route.  First/easy option- there’s a third party plugin - Subcategories plugin- I think it may do what you want.

    If not- you can opt to NOT ditch the php- use it to grab the current category from the url- then echo it in the query.  Note- that’s actually what you were doing in your first example:

    {exp:query sql="SELECT cat_name, cat_id, cat_description FROM exp_categories 
    WHERE parent_id = '<?php echo $seg; ?>' ORDER BY cat_name"}

    Which is what made it really obvious to me that the nesting was redundant.  You already had the current cat id via the php.  (Last option- using the category heading tag would also be a bit leaner and avoid php.  But- I think the plugin will work regardless.  If so, it’s the option I’d go with.)

  • #10 / Jun 24, 2007 7:58pm

    g0t035

    45 posts

    Looks like Derek has the 1.6 parse issue squared

    I have just got his workaround working. That is, the query is in a separate, embedded template.

    First/easy option- there’s a third party plugin

    My query actually came out of the subcategories plugin. I was the guy who prompted the author of that plugin to make it, if we’re talking about the same plugin. I used it for awhile, but took the relevant code out of it and put it right into my template.

    Here’s the deal with the nesting: I now see that it was redundant; what happened is that I had put the categories close-tag in the wrong place (after the query).

    Last option- using the category heading tag would also be a bit leaner and avoid php

    Hey, I did it with the category heading tag and seems to be working without the PHP! I am feeding category_id of category_heading to the embed template instead of my PHP variable. I must be dreaming…

    Thank you very very much.

  • #11 / Jun 24, 2007 8:11pm

    g0t035

    45 posts

    Looking at the subcategories thread, it looks like a different plugin. Another member created a subcategories plugin and sent it to me—I thought he posted it for all. I will study the thread you pointed to. Anyway—problem appears solved for now.

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

ExpressionEngine News!

#eecms, #events, #releases