This is my first PHP if statement so bear with me if I have made a silly mistake!
I am running pmWiki and have a two variables for the Group names. $Group is the group name without spaces (EasyCatalog for example) and $Groupspace is the group name with spaces (Easy Catalog for example).
I want to check if $Groupspaced == "Easy Catalog", if true then return the $Group variable, else return $Groupspaced
This is my code:
<p class="grouptitle">
<?php if ($Groupspaced == "Easy Catalog") : ?>
<a href='{$ScriptUrl}/{$Group}' class="pagegroup">{$Group}</a>
<?php else : ?>
<a href='{$ScriptUrl}/{$Group}' class="pagegroup">{$Groupspaced}</a>
<?php endif; ?>
</p>
The problem I am having is that it is returning both links not one.
It seems you are using Smarty: use its syntax for if else:
{if $Groupspaced eq 'Easy Catalog'}
<a href='{$ScriptUrl}/{$Group}' class="pagegroup">{$Group}</a>
{else}
<a href='{$ScriptUrl}/{$Group}' class="pagegroup">{$Groupspaced}</a>
{/if}
More you can read at http://www.smarty.net/docsv2/en/language.function.if.tpl
I see that this is not a smarty: Here is pmWiki if else syntax:
(:if cond param:) body (:else:) body (:ifend:)
In your case the code should be:
(:if equal "{$Groupspaced}" "Easy Catalog":)
<a href='{$ScriptUrl}/{$Group}' class="pagegroup">{$Group}</a>
(:else:)
<a href='{$ScriptUrl}/{$Group}' class="pagegroup">{$Group}</a>
(:ifend:)
I got this from here: http://www.pmwiki.org/wiki/Cookbook/ConditionalMarkupSamples