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.

problem with custom category fields

May 28, 2008 1:22pm

Subscribe [2]
  • #1 / May 28, 2008 1:22pm

    mArzsmAn

    45 posts

    I have a strange problem, I hope I’m just overlooking something stupid.
    This works, I get all the custom fields of category group 9

    {exp:weblog:categories weblog="recipes" category_group="9"}
        {category_name_fr}    
    {/exp:weblog:categories}

    And this is not working, I get all the category_name’s but not the custom fields

    {exp:weblog:entries weblog="recipes"}
        {title}
        <ul>
        {categories show_group="9"}
            <li>{category_name} - {category_name_fr}</li>
        {/categories}
        </ul>
    {/exp:weblog:entries}

    I’m using this in a completely different and more complex template, because it wasn’t working I created a test template with just this code to see what was happening.

    When I enable queries I see that the custom fields are collected, I just don’t understand why they aren’t showing up.

    SELECT c.cat_name, c.cat_url_title, c.cat_id, c.cat_image, c.cat_description, c.parent_id, p.cat_id, p.entry_id, c.group_id , cg.field_html_formatting, fd.* FROM (exp_categories AS c, exp_category_posts AS p) LEFT JOIN exp_category_field_data AS fd ON fd.cat_id = c.cat_id LEFT JOIN exp_category_groups AS cg ON cg.group_id = c.group_id WHERE c.cat_id = p.cat_id AND p.entry_id IN ('561','560','559','558','555','554','550','549','548','546','207','206','205','201','200','178','177','176','175','173','168','167') ORDER BY c.group_id, c.parent_id, c.cat_order

    Any ideas?

  • #2 / May 29, 2008 7:48am

    mArzsmAn

    45 posts

    OK, I finally solved my problem 😛
    and I think this is sort of a bug from expression engine(correct me if I’m wrong) or I missed something in the user guide.

    On the website I’m building I have lots of category groups, for all those groups I use the same naming conventions and every single category is in 4 languages.

    category group recipes:
    category_name (default)
    category_name_fr (default)
    category_name_de (default)
    category_name_es (default)

    category group blog:
    category_name (default)
    category_name_fr (default)
    category_name_de (default)
    category_name_es (default)


    After a lot of debugging, writing funky queries and banging my head I found out that custom category fields of different groups need different names.

    category group recipes:
    category_name
    recipe_category_name_fr
    recipe_category_name_de
    recipe_category_name_es

    category group blog:
    category_name
    blog_category_name_fr
    blog_category_name_de
    blog_category_name_es

    EE never complained about using the same custom field names for custom category fields in different groups so I never saw this as a problem. I think that in a situation like this EE need to give a warning(just like you can’t create same custom fields in weblogs)

  • #3 / May 29, 2008 10:57am

    Robin Sowell

    13255 posts

    Agreed- it’s not working like I’d expect.  Though for me, the field is parsed.  But- in the first field group, nothing is displayed.  Second group, it is.  Try it with no group specified- do you replicate?

    It’s definitely ‘off’ to me, and the docs say

    The field name must be unique within the category group,

    So it reads as if they need not be unique across groups.  And w/in group, you get an error if you duplicate shortnames.  So- something is off.  I’ll give the crew a heads up to confirm and enter a bug report.

    But do let me know what happens if you don’t specify a group in the cat tag pair.

  • #4 / May 29, 2008 11:06am

    mArzsmAn

    45 posts

    Sorry, all my category fields are already renamed, so I can’t retest it again. But I’m 100% sure I already tested it without the category_group. I completely stripped my tags to be sure I wasn’t doing something wrong.

    The only place where it did work is within a exp:weblog:categories tag

  • #5 / May 29, 2008 11:10am

    Robin Sowell

    13255 posts

    Got it- and no biggie if you can’t test.  Sounds like you already did a ton of it!  And nice job on the debug, as I didn’t say it before. 

    I’ve bumped it to the crew for confirmation and they are on it.  The behavior is definitely seeming buggy on my tests as well.

    I’ll close this out once it’s confirmed and reported.  For the moment, using the different field names is a good workaround.

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

ExpressionEngine News!

#eecms, #events, #releases