Hi there
I am trying to solve a problem I am having in v224 with an if statement.
I want to run a script on all pages except the cart and checkout pages. So I tried an if statement like {if $content == “cart” || $content == “checkout”} in the main_content.post.tpl in the folder index but had no results.
I had that with an else statement again nothing. It s like it doesn't take in count the if statement at all.
Is it content or control ? Am I missing something? Should I try another hook instead of main_content?
Please any ideas?
Fotis
Well today out of the blue it works fine!
Although yesterday after countless cache cleans and trials with != (that's for not equal) and also && instead of || today I just loaded the page and it started working just fine…
Go figure.
Fotis
Change $content to $controller
$content is usually the actual html page content
Hi tbimseth
Yes I actually did that also but forgot to write it.
Good call.
Fotis
I also use very often $config.current_url smarty variable for the same purpose
```php
{if $config.current_url!='index.php'}
{else}
{/if}
```
Nice one Captain.
Never thought of that.
I ll say this post can be a nice sticky if we gather a few more ideas.
Fotis
Should use a class, not embedded style. Bad practice.
Also, you should probably use
{if $controller == 'index'}
instead of $config.current_url since that would also include any http_path that is defined in config.local.php resulting in your test failing.