1

I've just updated my version of Primary Category from Solspace from version 2.0.2 to 2.2.1 in my EE 2.5.2 install and run into what I think is a bug. A BIG change in the update is that you now need to wrap your primary category variables inside a {primary_categories} tag pair inside the channel entries tag (in the past you could just use the primary category variables inside channel entries without the wrapper). So I updated my templates, but when I put in the wrapper tags I had some channel entries that suddenly were displaying duplicate and broken content. After investigating I found the common thread for the broken entries was that they had channel field content that contained the '$' symbol. So for example a reference to a price, like $1,099.00, in the title or body. This appears to be a bug in Primary Category.

Has anyone run across this same issue and if so do you have a fix or work around?

Thanks.

0

This obviously needs to be tested, but I was able to find this article and employing the solution it offered seems to work:

http://www.procata.com/blog/archives/2005/11/13/two-preg_replace-escaping-gotchas/

The issue is that the '$' has significance in the preg_replace replacement pattern so the $1 in the $1,099 becomes a back reference.

Just before line 1198 in the ext.primary_category.php file I added this line:

$tag_pair_data = preg_replace('/(\$|\\\\)(?=\d)/', '\\\\\1', $tag_pair_data);

This seems to have resolved the bug for me. I've forwarded my findings to Solspace and I am posting this here just for completeness. Personally I would wait for an official fix from Solspace, but if you're brave (or desperate) you might try this.

| improve this answer | |
0

This indeed appears to be an (odd) bug in Primary Category, which is reported. This seems to affect only dollar signs followed by numbers only (i.e. $hello gets parsed correctly, but not $123, which outputs 3).

One workaround I found was to avoid having the dollar sign followed immediately by a number. Adding a space between the $ and number seems to prevent the odd parsing.

Eg. Change $1,009.00 to $ 1,009.00 (please note the space).

| improve this answer | |
  • Hey I just upgraded to version 2.2.2 and looks like this issue still isn't fixed. A possible fix is in my post below if you want to take a look and see if that is worth rolling into the next update? – Adam Christianson May 24 '14 at 14:19
  • Just a note, that I changed my upvote and acceptance of this answer because in hindsight this is more of a workaround than a real fix. It's not really correct to have a space between the dollar sign and amount in your entry. The fix I mention below seems to work. We've had it deployed on our production site for over nine months without any noticeable issues. – Adam Christianson May 24 '14 at 14:44

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.