Extension

Archived
Forum
(read-only)

Lodewijk Schutte does not actively monitor this forum
(but you can still get help from other EE users).

EE 1
EE 2
Low Seg2Cat

Back to this add-on's main page
View Other Add-ons From Lodewijk Schutte

     

You must be logged in to post.

Problems trying to use seg2cat as a top level template conditional

General

Jonathan Schofield
Jonathan Schofield

I’m new to seg2cat and I’m trying to use it in an EE 2.x template like so…

{if segment_2 == ""
BRANCH 1
PRODUCT SECTION PAGE

{if
:elseif segment_2_category_id}
BRANCH 2
PRODUCT GROUP (CATEGORYPAGE

{if
:else} 
BRANCH 3
PRODUCT DETAIL PAGE for {segment_2}
{
/if} 

Output is as desired with the second and third code branches but the first branch (the products section page) with a url of the form example.com/template_group produces the following PHP error…

A PHP Error was encountered

Severity: User Warning

Message: Invalid EE Conditional Variable: {if segment_2_category_id}

Filename: libraries/Functions.php

Line Number: 2790
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /[server_system_path]/codeigniter/system/core/Exceptions.php:170)

Filename: core/Common.php

Line Number: 409


I know this extension is free but any help would be appreciated. I’ve made a modest donation towards its on-going development.

Jonathan Schofield
# 1
Jonathan Schofield

I’ve tried all sorts of different ways to execute the three branches in a single template using seg2cat (my preferred outcome) including nested conditionals and various wrappers to parse the tested segment strings, but to no avail :(

I must be doing something wrong.

To clarify a little further, what I want to be able to achieve with the 3 branches is:

example.com/template_group
example
.com/template_group/category_name
example
.com/template_group/url_title 

instead of…

example.com/template_group
example
.com/template_group/category/category_name
example
.com/template_group/url_title 
Jonathan Schofield
# 2
Jonathan Schofield

OK, through trial and error and reading between the lines of the old seg2cat thread on Low’s blog, I’ve discovered a fix…

Seems the answer is to go to the seg2cat Settings in Add-Ons and set Set all segments to Yes.

I’m not sure I follow why this works but it does.

A parting shot…

Seg2cat does indeed seem to be the wonderful add-on I have heard so many times from others but the docs could really do with examples. I guess that’s reasonably the hidden ‘price’ of the add-on being free.