In short: Low Seg2Cat gives you easy access to category ids so you can use them in your URIs and templates without the use of the Category URL Indicator or custom PHP.
Where in the parse order chain are the seg2cat global variables? http://expressionengine.com/wiki/Parse_Order/
I’ve been using this on a site in development and it was working great.
But the other day I started getting this error:
Warning: Invalid EE Conditional Variable: {if segment_3_category_id != ""} in path/to/admin/core/core.functions.php on line 2804
My template contains {if segment_3_category_id != ""}, but its inside an IF loop that shouldn’t be getting executed on the particular pages where the error is being thrown.
I can’t think of anything I changed that would have caused this.
Have you seen this error before?
Low, first off, great extension and thanks for sharing!
I got an oddity that is baffling me. I have the ext. looking at the segment_2, and on some pages it grabs the correct ID, and on others it doesnt. So I ran a little test to make sure EE was outputting the correct ID, and sure enough it does, but Seg2Cat doesn’t see the ID?
Double checking ID’s:
{categories}{category_id}{/categories} |
{segment_2_category_id}
And this is the template that works on most, but not all categories:
{exp:weblog:entries weblog="project" limit="1" status="Open|Featured" category="{segment_2_category_id}" dynamic="off" orderby="random" disable="category_fields|member_data|pagination|trackbacks"}
Hey Siebird,
Are you getting a wrong ID or none at all? If you’re getting a wrong ID, you might want to check the unique-ness of the categories, as explained on my site (Caveats).
Otherwise: - What version of Seg2Cat are you using? - What version of EE are you using? - What version of PHP are you using? - Is this happening to a single category or all? - Is this happening on a single template or all? - What is the full URI when this is happening?
After taking a quick look in your templates, here’s what’s happening: the url_title in segment_2 belongs to an entry, not a category. Some entry url_titles are identical to the categories they’re assigned to – that’s why sometimes you do get an id back. Solution: link to the category itself, not the entry belonging to that category.
In a MSM setup, does Seg2Cat allow the same category names across sites? I realize the caveat about not having the same category names in a single site, but didn’t know if this was also the case across sites in an MSM setup.
I’m using the same code on two sites in one MSM installation. On Site A the code is working perfectly. On Site B, the code doesn’t pull the entries from the correct segment variable. Instead, it’s displaying ALL entries.
Low Seg2Cat only looks for categories belonging to the current site. If no match was found, it will return an empty string. So, if you’re using code like this…
{exp:weblog:entries weblog="default_site" category="{segment_2_category_id}"}
…and no category is found in {segment_2}, the weblog entries won’t be filtered, thus showing all entries.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.