2

I recently upgraded to Primary Category 2.2.1 The following code is returning the primary category id twice

Has anyone had a similar problem with duplication?

{exp:primary_category category_group="2"}
    {primary_category_id}
{/exp:primary_category} 

regards, Ciaran

1

Try adding an entry_id="" parameter to {exp:primary_category}. By providing an entry_id, you let Primary Category know which primary categories to display for that entry.

| improve this answer | |
  • Thanks for the reply. Unfortunately this has not solved the problem. I have found an article that references a possible bug relating to the $ character: expressionengine.stackexchange.com/questions/12740/… This could be relevant as the only entries I have that do not experience this duplication problem are included in a Primary Category with a $ character in the Category Name field – ciarj Mar 4 '14 at 14:47
  • Do you have more context for the {exp:primary_category} tag code you have above? Is it inside another tag, using other variables, 3rd-party tags, etc? If so, please provide this code context in your OP :) Also, if $ is relevant, please give an example of where $ is used. – Solspace Mar 5 '14 at 2:37
  • Hi, I've stripped it down to this: – ciarj Mar 5 '14 at 10:57
  • <html> <body> {exp:channel:entries channel="products"} <!-- BREADCRUMBS --> {exp:primary_category category_group="2" entry_id="{entry_id}"} {primary_category_id} {/exp:primary_category} {/exp:channel:entries} </body> </html> – ciarj Mar 5 '14 at 10:58
  • I've stripped the template down to the code above. Still returning primary_category_id twice – ciarj Mar 5 '14 at 11:03
1

This turned out to be a database issue. I had duplicate entries in my exp_primary_category table. I think this may have been due to problems I had while upgrading Primary Category.

Solution: Using 'Sequel Pro' I connected to DB, and ran the following query to create a new database table containing only unique rows from exp_primary_category: "create table exp_primary_category2 as select distinct * from exp_primary_category;"

I then renamed 'exp_primary_category' to 'exp_primary_category-old' (just in case anything went wrong with new table) and named my new table 'exp_primary_category'.

Everything back to normal now! Thanks for the help

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.