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 custom field name conflicts?

June 24, 2008 11:06am

Subscribe [1]
  • #1 / Jun 24, 2008 11:06am

    Brent Cartier

    87 posts

    I wondering if there’s an issue with having several category groups all containg a category custom fields that have the same name. I’m working on a bilingual (English/French) site, and for every category, I need to have the category name in French, so I use the custom field name “category_name_fr”. I do this in 4 separate category groups.

    The problem is that I can’t seem to display the french name using the weblog:categories tag, which according to the docs, I should be able to display custom fields:

    {exp:weblog:categories weblog="contacts" category_group="4"}
      <option value="{category_id}">{if lang=="en"}{category_name}{/if}{if lang=="fr"}{category_name_fr}{/if}</option>
    {/exp:weblog:categories}

    This code shows a list of provinces, but in French, it actaully creates the dropdown which I can select from, the text is blank. My hunch is that this is a naming conflict, but I’d really prefer to keep the variable names consistent so that I can loop through several category groups in my templates and always know that the field is going to be “category_name_fr”, regardless of the group or weblog. Does that make any sense?

    Thanks for your time!

  • #2 / Jun 24, 2008 11:28am

    Robin Sowell

    13255 posts

    Hm- do a quick test on a blank template

    {exp:weblog:categories weblog="contacts" category_group="4" style="linear"}
     {category_name} - french: {category_name_fr}
    
    {/exp:weblog:categories}

    Does it fail to show there as well?and- you’re using a custom category field in multiple groups with the name category_name_fr?

  • #3 / Jun 24, 2008 11:32am

    Brent Cartier

    87 posts

    Hi Robin,

    Thanks for the quick reply - the clean template with the code above outputs:

    Alberta - french:
    British Columbia - french:
    Manitoba - french:
    ...

    category_name_fr is still outputting nothing. I double checked for typos in the field name etc.

    Strange eh?

  • #4 / Jun 24, 2008 11:35am

    Brent Cartier

    87 posts

    Hi Robin - I think I found my error - one minute…

  • #5 / Jun 24, 2008 11:51am

    Brent Cartier

    87 posts

    Hi Robin,

    Sorry about the mix up, the weblog:categories tag seems to be working, it’s the {categories} pair that’s giving me grief:

    Here’s some sample code:

    <ul>
       {exp:weblog:entries weblog="meetings" limit="3"  }
        <li>{title}
    
           {categories}
                  {category_name} - {category_name_fr}
               {/categories}
           
    <em>{entry_date format="%l %F %j%S, %Y at %g:%i%a"}</em>
            </li>
            
       {/exp:weblog:entries}
    </ul>
    <hr>
    {exp:weblog:categories weblog="meetings"  }
      {category_name} - french: {category_name_fr}
    
    {/exp:weblog:categories}

    In the {categories} variable pair, category_name_fr is empty, but in the weblog:categories tag, it’s displayed… The meetings weblog has only one category group assigned (id:2)

  • #6 / Jun 24, 2008 12:04pm

    Robin Sowell

    13255 posts

    Hm- try clearing the cache- ‘admin-utilities’.  Might also try specifing the group id in the weblog’s category pair:

    {categories show_group="2"}

    And I don’t think this is it- because I’d expect the category tag to have issues as well- but might run this fix just to eliminate one possibility.

    If none of the above works, I’ll get you to walk me through duplicating the issue.

    Oh- what build/version are you running?

  • #7 / Jun 24, 2008 12:21pm

    Brent Cartier

    87 posts

    Hi Robin,

    I tried clearing the cache, and adding the show_group parameter - same result.

    I’m running the latest verion/build and haven’t updated since install:

    ExpressionEngine 1.6.3,  Build 20080421

    Should I still try that fix you mentioned?

  • #8 / Jun 24, 2008 12:29pm

    Brent Cartier

    87 posts

    I tried disabling all extensions - no luck.

    I did however rename the field in that one category group to category_name_fr2 and it displays perfectly. It must be a conflict of names across groups.

  • #9 / Jun 24, 2008 12:31pm

    Robin Sowell

    13255 posts

    Crud.  This rings a vague bell, but I can’t recall if it’s this exact issue.  Let me search around, see if I can find a related thread.

  • #10 / Jun 24, 2008 12:41pm

    Robin Sowell

    13255 posts

    OK- I had seen this before in this thread and the issue is under discussion with the crew regarding whether duplicate names across groups should be allowed.  I haven’t heard the final decision on that one yet.

    So for the short term- duplicate custom field groups across category groups (or w/in the same group) should be avoided as you’re likely to run into trouble with it.  Is that going to work ok for you?

  • #11 / Jun 24, 2008 12:50pm

    Brent Cartier

    87 posts

    Ok - I should be able to get that working using some logic in my templates. Maybe as a decision is being made, the docs could be updated to say that “category field names bust be unique within the group and across all category groups”. I’d add a note in the doc myself but I’m still only a “Grad Student” 😉

    Thanks for the help!

  • #12 / Jun 24, 2008 1:00pm

    Robin Sowell

    13255 posts

    Yep- I already bumped the crew on it to see which way to go.  Normally would have had a bug report in on it from the first occurrence- but it wasn’t clear if it’s a bug or a documentation issue.  Sorry you got caught up in the decision making process!

    And I shall go ahead and close this on out.

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

ExpressionEngine News!

#eecms, #events, #releases