3
votes

In my site I need to display breadcrumbs like this.

Home / Search results for: 'laptop' / Lenova G50 Laptop

I am searching any products (like above 'laptop') in site.

After get result I click any products in search result page.

That clicked product view page I need above type of breadcrumbs.

When I click that " Search results for: 'laptop' ", go to that search result page.

How can i do this ? Any one help me.

2
I'm voting to close this question as off-topic because Stack Overflow is a programming-related Q&A site. Your question is not about programming. Perhaps you should post it on magento.stackexchange.com instead?Enigmativity
Many questions regarding Magento were asked the same site. @EnigmativityVijayS91
Yes, but unless they are about programming then they too are off topic. Just because one person got away with murder it doesn't make murder legal. Stack Overflow is exclusively about programming.Enigmativity

2 Answers

0
votes

try this and get search term and add to it's url and then again generate search url with query

<?php 
$urlRequest = Mage::app()->getFrontController()->getRequest();
$urlPart = $urlRequest->getServer('ORIG_PATH_INFO');

if(is_null($urlPart))
{
  $urlPart = $urlRequest->getServer('PATH_INFO');
}


$urlPart = substr($urlPart, 1 );
$currentUrl = $this->getUrl($urlPart);

 //$controllerName =  Mage::app()->getFrontController()->getRequest()->getControllerName();
 //$controllerName = ucfirst($controllerName);

$controllerName = str_replace("/", " ", $urlPart);
$controllerName = str_replace("_", " ", $controllerName);
$controllerName = str_replace("-", " ", $controllerName);
$controllerName = ucfirst($controllerName);

?>
<span class="breadcrumbs">
<strong class="float"><?php echo $this->__("You're currently on: ")   ?>
</strong>
<ul class="breadcrumbs">
<li class="home">
    <a title="<?php echo $this->__('Go to Home Page') ?>" href="<?php echo $this->getUrl() ?>"><?php echo $this->__('Home') ?></a>
</li>
<li> / </li>
    <li class="<?php echo strtolower($controllerName) ?>">
    <strong><?php echo $this->__($controllerName) ?></strong>
</li>
</ul>
</span>
0
votes

I have tried Below Code :

        <?php    
         $last_url = $_SERVER['HTTP_REFERER'];  
         if (strpos($last_url, 'catalogsearch') !== false && Mage::registry('current_product') && strpos($last_url, 'q=') !== false ) {
             $base_url = basename($last_url);
             $search = explode("&", $base_url);
             foreach($search as $value) {
                  if(strpos($value, 'q=')!== false) {
                       $search_text = trim(trim(trim($value), "?"), "q=");
                  }
             }
          ?>

       <div class="breadcrumbs">
            <ul>
                <li>
                    <?php echo $this->__("Home");?> &nbsp; / &nbsp;
                </li>
                <li>
                    <a href="<?php echo $last_url; ?>">
                        <?php echo $this->__("Search results for : '%s'", urldecode($search_text));?>
                    </a>
                    &nbsp; / &nbsp;
                </li>
                <li><?php echo $this->escapeHtml(Mage::registry('current_product')->getName()); ?></li>
            </ul>
        </div>
       <?php } ?>

Check this link.