Reputation: 105
i am working with magento and i want to show one div, depending if i am in a specific view. I use the following:
<?php
$url1 = (string)$this->getBaseUrl()."home_tienda";
$url2 = (string)$this->getUrl('*/*/*',array('_current'=>true, '_use_rewrite'=>true));
?>
If i type a "var_dump" of $url1 and $url2, i obtain the following:
string(28) "http://127.0.0.1/home_tienda"
string(37) "http://127.0.0.1/home_tienda"
Well, i have tried this:
<?php if (strcmp($url1,$url2)==0):?>
<div class="clsbanner"><?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_banner')->toHtml(); ?></div>
<?php endif?>
and i have tried this too:
<?php if ($url1==$url2):?>
<div class="clsbanner"><?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_banner')->toHtml(); ?></div>
<?php endif?>
in both i obtained false, so my div doesnt show, and i need it to be shown
Upvotes: 2
Views: 996
Reputation: 21851
Please retry strcmp()
and/or stricmp()
with the ===
operator. Another useful tool is stripos()
, which returns 0 from your URL comparison but will return FALSE if string isn't found.
0 == FALSE
tests the same...
However
0 === FALSE
will catch the condition you are looking for as ===
matches data type as well.
Upvotes: 2