Wednesday 20 May 2015

how can add span in breadcrumbs in magneto?

Hello

I have Issue in My magento. i have add span beetween description.

Here Only I want to change in magento result page (search page).

THis In My Question


Here My breadcrumbs html

  • Home

i want span at 


between search and ring 

i like this 


result.php my breadcrumbs code 

$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
        if ($breadcrumbs) {
            $title = $this->__("Search > %s",$this->helper('catalogsearch')->getQueryText());

            $breadcrumbs->addCrumb('home', array(
                'label' => $this->__('Home'),
                'title' => $this->__('Go to Home Page'),
                'link'  => Mage::getBaseUrl()
            ))->addCrumb('search', array(
                'label' => $title,
                'title' => $title

            ));
        }

I Found Solution From magento.stackexchange site.


The text you put in the breadcrumbs is escaped before printing so you won't be a victim of XSS. So any tag you put in the breadcrumbs label will be shown as a tag in the frontend and won't be interpreted.
But you can achieve what you need like this
You need to add after this line:

$title = $this->__("Search > %s",$this->helper('catalogsearch')->getQueryText());

this
$label = $this->__('Search <span></span>');//span add here
$label .= Mage::helper('core')->escapeHtml($this->helper('catalogsearch')->getQueryText());

This will make your query string escaped before sending it to the breadcrumbs template.

You will also have 2 variables instead of one. $title will still have the original text so you can use it as title for the span element (this will be escaped) and $label that you can use as the span innerHTML.
Now you need to tell the template not to escape the $label again.

So replace this

 ->addCrumb('search', array(
     'label' => $title,
     'title' => $title
 ))

with 

->addCrumb('search', array(
     'label' => $label,
     'title' => $title,
     'no_escape' => true
 ))

Now you need to edit the breadcrumbs template an remove the htmlEscape when the no_escape element is true.



Replace this section

if($_crumbInfo['link']): 
    echo $this->htmlEscape($_crumbInfo['label']) 
elseif($_crumbInfo['last']): 
    echo $this->htmlEscape($_crumbInfo['label']) 
else: 
    echo $this->htmlEscape($_crumbInfo['label']) 
endif; 
with this


if (isset($_crumbInfo['no_escape']) && $_crumbInfo['no_escape']) : 
    $label = $_crumbInfo['label'];
else : 
    $label = $this->htmlEscape($_crumbInfo['label']) ;
endif;
if($_crumbInfo['link']): 
    echo $label 
elseif($_crumbInfo['last']): 
    echo $label 
else: 
    echo $label 
endif; 
    

    

No comments:

Post a Comment

Thank You For Comment