There are two methods in Mage_Catalog_Model_Layer_Filter_Item. One retrieves the URL of for a filter:

public function getUrl()
    $query = array(
        Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null // exclude current page from urls
    return Mage::getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));

and another removes it:

public function getRemoveUrl()
    $query = array($this->getFilter()->getRequestVar()=>$this->getFilter()->getResetValue());
    $params['_current']     = true;
    $params['_use_rewrite'] = true;
    $params['_query']       = $query;
    $params['_escape']      = true;
    return Mage::getUrl('*/*/*', $params);

I'm wondering is there any reason why an URL for getRemoveUrl is escaped and getUrl is not?


The result of getUrl is escaped in the template.
Check app/design/frontend/base/default/template/catalog/layer/filter.phtml.
the filter URL is rendered like this:

<a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>

urlEscape is a wrapper for htmlspecialchars.

In state.phtml (same folder) the remove url is rendered like so href="<?php echo $_filter->getRemoveUrl() ?>".

I couldn't tell you the reason. All I know is that in both cases the url's get escaped. At least in the default theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.