17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2378 Views |
-
InSection Questions

9 August 2008 at 7:47am
I'm guessing it is not possible to check multiple pages using InSection? e.g if InSection(page1,page2)
Is it then possible to use if/else if statements in my template with it? I tried with no luck.
<% if InSection(page) %>
Something
<% else_if InSection(page2) %>
Something else
<% end_if %> -
Re: InSection Questions

9 August 2008 at 8:34am
try this
<% if URLSegment== page title %>
content here
<% else_if URLSegment== page title 2 %>
more content
<% end_if %> -
Re: InSection Questions

9 August 2008 at 10:02pm
I would have thought your (Lee's) code would work. Does something like this work?
<% if InSection(a) %>
<% else %>
<% if InSection(b) %>
<% end_if %>
<% end_if %> -
Re: InSection Questions

11 August 2008 at 9:05am Last edited: 11 August 2008 4:59pm
I just had the same issue as LeeUmm while using SS v2.2.2. I found a possible bug in sapphire/core/SSViewer.php and a fix.
Around line 263 in SSViewer.php you'll find several ereg_replace() calls that appear to change the .ss template if/else syntax to php if/else syntax. There are a few lines that replace "else_if" wrong or not at all...
// line 278
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *&&? *([A-Za-z0-9_]+) +%' . '>', '<? else_if($item->hasValue("\\1") && $item->hasValue("\\2")) { ?>', $content);
//change to
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *&&? *([A-Za-z0-9_]+) +%' . '>', '<? } else if($item->hasValue("\\1") && $item->hasValue("\\2")) { ?>', $content);// line 274
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *\\|\\|? *([A-Za-z0-9_]+) +%' . '>', '<? else_if($item->hasValue("\\1") || $item->hasValue("\\2")) { ?>', $content);
// change to
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *\\|\\|? *([A-Za-z0-9_]+) +%' . '>', '<? } else if($item->hasValue("\\1") || $item->hasValue("\\2")) { ?>', $content);// line 266
$content = ereg_replace('<' . '% +if +([A-Za-z0-9_]+)\\(([A-Za-z0-9_-]+)\\) +%' . '>', '<? if($item->hasValue("\\1",array("\\2"))) { ?>', $content);
// ADD this line below it...
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+)\\(([A-Za-z0-9_-]+)\\) +%' . '>', '<? } else if($item->hasValue("\\1",array("\\2"))) { ?>', $content);// line 263
$content = ereg_replace('<' . '% +if +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+) +%' . '>', '<? if($item->obj("\\1",null,true)->hasValue("\\2")) { ?>', $content);
// ADD this line below it...
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+) +%' . '>', '<? } else if($item->obj("\\1",null,true)->hasValue("\\2")) { ?>', $content);Keep in mind this changes core code. Any upgrades to SS will erase these changes. By then this bug might be fixed anyway
. I will try to look in the bug reports to see if it's there already, and if not add it.
Oh, and Willr's suggestion works for me, I just wanted to have the ability to make my templates a bit more readable.
-Billy
-
Re: InSection Questions

12 August 2008 at 11:32am
Great find and fix. I haven't had time to apply changes, just viewing the topic for the first time since posting with the weekend and all.
Submitting the bug would be great, as I'm like you, I'd rather have cleaner more proper code in my templates, and having to update all my SS sites in the future would be a hassle.
| 2378 Views | ||
|
Page:
1
|
Go to Top |




