Announcement

Collapse
No announcement yet.

PHP IF Statemnet not working in Mega Menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP IF Statemnet not working in Mega Menu

    I want to force my Section names onto two lines within the menu but do not want to add the necessary <br> to the section name itself
    So I created a new variable called MenuName and tried to apply it when it is present (Not Null) - the vale has html (specifically a <br> with it)

    i.e. Section anme = Skating Dresses
    MenuName = Skating<br>Dresses

    Code:
    			$sMenuName = ("<actinic:variable encoding="perl" name="MenuName" selectable="false" />");	
    			
    			$sSectionName = strip_tags("<actinic:variable encoding="actinic" name="SectionName" selectable="false" />");		  
    	  
    			if (sMenuName != NULL)
    			{
            		echo '>'.$sMenuName.'</a>';
    			}
    			else
    			{
    				echo '>'.$sSectionName.'</a>';
    			}
    I have set the value of a new php variable to MenuName and tehn try and do an IF statemnt on it
    If exists then use it
    Else
    Use the original Section Name

    When I set the
    If as above to == ALL returns are the original section value
    and to != All the returns are the new MenuName

    I have populated some but not all of the MenuName so OI should be getting a mix or values

    the MenuName is set to Quoted Perl otherwise I get the value but with the <br> showing.

    Must be something pretty simple I have missed Greatly appreciate any pointers or advice to get this working.

    Thanks
    David Cunningham

    www.truska.com
    -----------------------------
    ECommerce (SellerDeck) & Web Design, Hosting, Search Engine Optimisation, Social Media and Remote Backup (Truska Backup)

    #2
    Missing $ on one of the sMenuName instances.

    Also, use single quotes with encoding="perl" and try comparing with the empty string ''.
    Code:
    			$sMenuName = '<actinic:variable encoding="perl" name="MenuName" selectable="false" />';	
    			
    			$sSectionName = strip_tags("<actinic:variable encoding="actinic" name="SectionName" selectable="false" />");		  
    	  
    			if ($sMenuName != '')
    			{
            		echo '>'.$sMenuName.'</a>';
    			}
    			else
    			{
    			echo '>'.$sSectionName.'</a>';
    			}
    Or try the less wordy:
    Code:
    			$sSectionName = strip_tags("<actinic:variable encoding="actinic" name="SectionName" selectable="false" />");		  
    			$sMenuName = '<actinic:variable encoding="perl" name="MenuName" selectable="false" />';	
            		echo '>'. ($sMenuName != '' ? $sMenuName : $sSectionName) .'</a>';
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Norman

      Thank you - can't sometime see the wood for teh trees - thought i had ticked that "obvious" error off the list .

      Working fine now thanks again

      David
      David Cunningham

      www.truska.com
      -----------------------------
      ECommerce (SellerDeck) & Web Design, Hosting, Search Engine Optimisation, Social Media and Remote Backup (Truska Backup)

      Comment

      Working...
      X