Breadcrumbs Product hyperlink The Next CEO of Stack OverflowMy Breadcrumbs wont work when on a...
How can the PCs determine if an item is a phylactery?
Compensation for working overtime on Saturdays
How to show a landlord what we have in savings?
How can I separate the number from the unit in argument?
Man transported from Alternate World into ours by a Neutrino Detector
Simplify trigonometric expression using trigonometric identities
Is there a rule of thumb for determining the amount one should accept for a settlement offer?
logical reads on global temp table, but not on session-level temp table
Airship steam engine room - problems and conflict
Planeswalker Ability and Death Timing
Car headlights in a world without electricity
Incomplete cube
Which acid/base does a strong base/acid react when added to a buffer solution?
Can Sri Krishna be called 'a person'?
What did the word "leisure" mean in late 18th Century usage?
Another proof that dividing by 0 does not exist -- is it right?
Are British MPs missing the point, with these 'Indicative Votes'?
Upgrading From a 9 Speed Sora Derailleur?
How to find if SQL server backup is encrypted with TDE without restoring the backup
Find a path from s to t using as few red nodes as possible
Why can't we say "I have been having a dog"?
Direct Implications Between USA and UK in Event of No-Deal Brexit
Is a distribution that is normal, but highly skewed, considered Gaussian?
Why does freezing point matter when picking cooler ice packs?
Breadcrumbs Product hyperlink
The Next CEO of Stack OverflowMy Breadcrumbs wont work when on a product pageBreadcrumbs do not contain linksRemoving home and all Categories from breadcrumbsMagento(1.9) Breadcrumbs not showingMagento display multiple breadcrumbs in product view pageMagento 2 Breadcrumbs CopyChanging breadcrumbs product name to an attributeaccount information breadcrumbs in magento 1.9Orders showing on account overview but not on historyHow To Remove Product Title from Breadcrumbs
I need the breadcrumbs to hyperlink the current page i'm in..
For example
Home >> Category >> Product
usually, all parent categories hyperlinked. i wish to have product hyperlinked as well.
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Page
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Html page block
*
* @category Mage
* @package Mage_Page
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Page_Block_Html_Breadcrumbs extends Mage_Core_Block_Template
{
/**
* Array of breadcrumbs
*
* array(
* [$index] => array(
* ['label']
* ['title']
* ['link']
* ['first']
* ['last']
* )
* )
*
* @var array
*/
protected $_crumbs = null;
function __construct()
{
parent::__construct();
$this->setTemplate('page/html/breadcrumbs.phtml');
}
function addCrumb($crumbName, $crumbInfo, $after = false)
{
$this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly'));
if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
$this->_crumbs[$crumbName] = $crumbInfo;
}
return $this;
}
protected function _toHtml() {
$cat_id = "";
if (Mage::registry('current_product')) {
$product_id = Mage::registry('current_product')->getId();
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
if ($product_id) {
$categoryIds = $_product->getCategoryIds();
$cat_id = $categoryIds[0];
}
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_name = $category->getName();
$cat_url = $this->getBaseUrl().$category->getUrlPath();
}
if (is_array($this->_crumbs)) {
reset($this->_crumbs);
$this->_crumbs[key($this->_crumbs)]['first'] = true;
end($this->_crumbs);
$this->_crumbs[key($this->_crumbs)]['last'] = true;
}
if($cat_id) {
$this->_crumbs['category'.$cat_id] = array('label'=>$cat_name, 'title'=>'', 'link'=>$cat_url,'first'=>'','last'=>'','readonly'=>'');
ksort($this->_crumbs);
$home = $this->_crumbs['home'];
unset($this->_crumbs['home']);
array_unshift($this->_crumbs,$home);
}
$this->assign('crumbs', $this->_crumbs);
return parent::_toHtml();
}
}
Thanks
magento-1.9 php breadcrumbs
bumped to the homepage by Community♦ 13 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I need the breadcrumbs to hyperlink the current page i'm in..
For example
Home >> Category >> Product
usually, all parent categories hyperlinked. i wish to have product hyperlinked as well.
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Page
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Html page block
*
* @category Mage
* @package Mage_Page
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Page_Block_Html_Breadcrumbs extends Mage_Core_Block_Template
{
/**
* Array of breadcrumbs
*
* array(
* [$index] => array(
* ['label']
* ['title']
* ['link']
* ['first']
* ['last']
* )
* )
*
* @var array
*/
protected $_crumbs = null;
function __construct()
{
parent::__construct();
$this->setTemplate('page/html/breadcrumbs.phtml');
}
function addCrumb($crumbName, $crumbInfo, $after = false)
{
$this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly'));
if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
$this->_crumbs[$crumbName] = $crumbInfo;
}
return $this;
}
protected function _toHtml() {
$cat_id = "";
if (Mage::registry('current_product')) {
$product_id = Mage::registry('current_product')->getId();
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
if ($product_id) {
$categoryIds = $_product->getCategoryIds();
$cat_id = $categoryIds[0];
}
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_name = $category->getName();
$cat_url = $this->getBaseUrl().$category->getUrlPath();
}
if (is_array($this->_crumbs)) {
reset($this->_crumbs);
$this->_crumbs[key($this->_crumbs)]['first'] = true;
end($this->_crumbs);
$this->_crumbs[key($this->_crumbs)]['last'] = true;
}
if($cat_id) {
$this->_crumbs['category'.$cat_id] = array('label'=>$cat_name, 'title'=>'', 'link'=>$cat_url,'first'=>'','last'=>'','readonly'=>'');
ksort($this->_crumbs);
$home = $this->_crumbs['home'];
unset($this->_crumbs['home']);
array_unshift($this->_crumbs,$home);
}
$this->assign('crumbs', $this->_crumbs);
return parent::_toHtml();
}
}
Thanks
magento-1.9 php breadcrumbs
bumped to the homepage by Community♦ 13 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I need the breadcrumbs to hyperlink the current page i'm in..
For example
Home >> Category >> Product
usually, all parent categories hyperlinked. i wish to have product hyperlinked as well.
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Page
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Html page block
*
* @category Mage
* @package Mage_Page
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Page_Block_Html_Breadcrumbs extends Mage_Core_Block_Template
{
/**
* Array of breadcrumbs
*
* array(
* [$index] => array(
* ['label']
* ['title']
* ['link']
* ['first']
* ['last']
* )
* )
*
* @var array
*/
protected $_crumbs = null;
function __construct()
{
parent::__construct();
$this->setTemplate('page/html/breadcrumbs.phtml');
}
function addCrumb($crumbName, $crumbInfo, $after = false)
{
$this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly'));
if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
$this->_crumbs[$crumbName] = $crumbInfo;
}
return $this;
}
protected function _toHtml() {
$cat_id = "";
if (Mage::registry('current_product')) {
$product_id = Mage::registry('current_product')->getId();
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
if ($product_id) {
$categoryIds = $_product->getCategoryIds();
$cat_id = $categoryIds[0];
}
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_name = $category->getName();
$cat_url = $this->getBaseUrl().$category->getUrlPath();
}
if (is_array($this->_crumbs)) {
reset($this->_crumbs);
$this->_crumbs[key($this->_crumbs)]['first'] = true;
end($this->_crumbs);
$this->_crumbs[key($this->_crumbs)]['last'] = true;
}
if($cat_id) {
$this->_crumbs['category'.$cat_id] = array('label'=>$cat_name, 'title'=>'', 'link'=>$cat_url,'first'=>'','last'=>'','readonly'=>'');
ksort($this->_crumbs);
$home = $this->_crumbs['home'];
unset($this->_crumbs['home']);
array_unshift($this->_crumbs,$home);
}
$this->assign('crumbs', $this->_crumbs);
return parent::_toHtml();
}
}
Thanks
magento-1.9 php breadcrumbs
I need the breadcrumbs to hyperlink the current page i'm in..
For example
Home >> Category >> Product
usually, all parent categories hyperlinked. i wish to have product hyperlinked as well.
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Page
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Html page block
*
* @category Mage
* @package Mage_Page
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Page_Block_Html_Breadcrumbs extends Mage_Core_Block_Template
{
/**
* Array of breadcrumbs
*
* array(
* [$index] => array(
* ['label']
* ['title']
* ['link']
* ['first']
* ['last']
* )
* )
*
* @var array
*/
protected $_crumbs = null;
function __construct()
{
parent::__construct();
$this->setTemplate('page/html/breadcrumbs.phtml');
}
function addCrumb($crumbName, $crumbInfo, $after = false)
{
$this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly'));
if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
$this->_crumbs[$crumbName] = $crumbInfo;
}
return $this;
}
protected function _toHtml() {
$cat_id = "";
if (Mage::registry('current_product')) {
$product_id = Mage::registry('current_product')->getId();
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
if ($product_id) {
$categoryIds = $_product->getCategoryIds();
$cat_id = $categoryIds[0];
}
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_name = $category->getName();
$cat_url = $this->getBaseUrl().$category->getUrlPath();
}
if (is_array($this->_crumbs)) {
reset($this->_crumbs);
$this->_crumbs[key($this->_crumbs)]['first'] = true;
end($this->_crumbs);
$this->_crumbs[key($this->_crumbs)]['last'] = true;
}
if($cat_id) {
$this->_crumbs['category'.$cat_id] = array('label'=>$cat_name, 'title'=>'', 'link'=>$cat_url,'first'=>'','last'=>'','readonly'=>'');
ksort($this->_crumbs);
$home = $this->_crumbs['home'];
unset($this->_crumbs['home']);
array_unshift($this->_crumbs,$home);
}
$this->assign('crumbs', $this->_crumbs);
return parent::_toHtml();
}
}
Thanks
magento-1.9 php breadcrumbs
magento-1.9 php breadcrumbs
edited Aug 27 '18 at 5:30
Ansar Husain
1,715218
1,715218
asked Sep 8 '15 at 10:09
user30913user30913
62
62
bumped to the homepage by Community♦ 13 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 13 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You need to modify getBreadcrumbPath() in app/code/core/Mage/Catalog/Helper/Data as links are not added to the breadcrumb array by default.
Do this with a rewrite that would look like
...
<helpers>
<catalog>
<rewrite>
<data>[Vendor]_[ModuleName]_Helper_Catalog_Data</data>
</rewrite>
</catalog>
</helpers>
...
in your config.xml and the following would be the rewritten class
class [Vendor]_[ModuleName]_Helper_Catalog_Data extends Mage_Catalog_Helper_Data
{
public function getBreadcrumbPath()
{
parent::getBreadcrumbPath();
if (array_key_exists('product', $this->_categoryPath)) {
$this->_categoryPath['product']['link'] = $this->getProduct()->getProductUrl();
}
return $this->_categoryPath;
}
}
add a comment |
Observe the proper event, perhaps something similar to (just guessing the event) core_block_abstract_to_html_before
, (but perhaps something that would be less often observed) with a custom observer, similar to:
<core_block_abstract_to_html_before>
<observers>
<df2k2_update_breadcrumb>
<class>df2k2_page/observer</class>
<method>updateBreadcrumbLink</method>
</df2k2_update_breadcrumb>
</observers>
</core_block_abstract_to_html_before>
Observer Class
public function updateBreadcrumbLink(Varien_Event_Observer $observer)
{
$breadcrumbsBlock = $observer->getEvent()->getBlock();
if ($breadcrumbsBlock instanceof Mage_Page_Block_Html_Breadcrumbs) {
// Get the block, get the last breadcrumb item in the array
// and simply check for registry('current_product') or 'current_category',
// and set the last item's [`link`] element to either the product's url or the categories URL
// example,
if (is_array($breadcrumbsBlock->_crumbs)) {
end($breadcrumbsBlock->_crumbs);
$breadcrumbsBlock->_crumbs[key($breadcrumbsBlock->_crumbs)]['link']
= Mage::getRegistry('current_product')->getUrl();
// = Mage::helper('core')->getCurrentUrl();
}
$breadcrumbsBlock->assign('crumbs', $breadcrumbsBlock->_crumbs);
}
return $this;
}
Once you set the link
part for the last crumb item in the array of crumbs, then it will automatically render the item to include the linked URL.
There is a lot of detail missing with logic and object checking for current_product and category... Essentially, if there exists a registry for current_product, use that... if current_category, use that... otherwise, simply do whatever you want, or nothing at all.
If you don't wish to look up the details of the product/category.. just get the current URL and set the ['link'] element to the current URL.
add a comment |
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a>
<?php elseif($_crumbInfo['last']): ?>
<?php // i have add link code here as below ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><strong><?php echo $this->escapeHtml($_crumbInfo['label']) ?></strong></a>
<?php else: ?>
<?php echo $this->escapeHtml($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>/ </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
edit above code in
app/design/frontend/[Your-theme]/[Your-package]/template/page/html/breadcrumbs.phtml
typo: breadcrums.phtml -- breadcrumbs.phtml, yes?
– df2k2
Apr 15 '18 at 7:04
yes breadcrums.phtml
– Yogesh Trivedi
Apr 24 '18 at 9:35
add a comment |
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f82283%2fbreadcrumbs-product-hyperlink%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to modify getBreadcrumbPath() in app/code/core/Mage/Catalog/Helper/Data as links are not added to the breadcrumb array by default.
Do this with a rewrite that would look like
...
<helpers>
<catalog>
<rewrite>
<data>[Vendor]_[ModuleName]_Helper_Catalog_Data</data>
</rewrite>
</catalog>
</helpers>
...
in your config.xml and the following would be the rewritten class
class [Vendor]_[ModuleName]_Helper_Catalog_Data extends Mage_Catalog_Helper_Data
{
public function getBreadcrumbPath()
{
parent::getBreadcrumbPath();
if (array_key_exists('product', $this->_categoryPath)) {
$this->_categoryPath['product']['link'] = $this->getProduct()->getProductUrl();
}
return $this->_categoryPath;
}
}
add a comment |
You need to modify getBreadcrumbPath() in app/code/core/Mage/Catalog/Helper/Data as links are not added to the breadcrumb array by default.
Do this with a rewrite that would look like
...
<helpers>
<catalog>
<rewrite>
<data>[Vendor]_[ModuleName]_Helper_Catalog_Data</data>
</rewrite>
</catalog>
</helpers>
...
in your config.xml and the following would be the rewritten class
class [Vendor]_[ModuleName]_Helper_Catalog_Data extends Mage_Catalog_Helper_Data
{
public function getBreadcrumbPath()
{
parent::getBreadcrumbPath();
if (array_key_exists('product', $this->_categoryPath)) {
$this->_categoryPath['product']['link'] = $this->getProduct()->getProductUrl();
}
return $this->_categoryPath;
}
}
add a comment |
You need to modify getBreadcrumbPath() in app/code/core/Mage/Catalog/Helper/Data as links are not added to the breadcrumb array by default.
Do this with a rewrite that would look like
...
<helpers>
<catalog>
<rewrite>
<data>[Vendor]_[ModuleName]_Helper_Catalog_Data</data>
</rewrite>
</catalog>
</helpers>
...
in your config.xml and the following would be the rewritten class
class [Vendor]_[ModuleName]_Helper_Catalog_Data extends Mage_Catalog_Helper_Data
{
public function getBreadcrumbPath()
{
parent::getBreadcrumbPath();
if (array_key_exists('product', $this->_categoryPath)) {
$this->_categoryPath['product']['link'] = $this->getProduct()->getProductUrl();
}
return $this->_categoryPath;
}
}
You need to modify getBreadcrumbPath() in app/code/core/Mage/Catalog/Helper/Data as links are not added to the breadcrumb array by default.
Do this with a rewrite that would look like
...
<helpers>
<catalog>
<rewrite>
<data>[Vendor]_[ModuleName]_Helper_Catalog_Data</data>
</rewrite>
</catalog>
</helpers>
...
in your config.xml and the following would be the rewritten class
class [Vendor]_[ModuleName]_Helper_Catalog_Data extends Mage_Catalog_Helper_Data
{
public function getBreadcrumbPath()
{
parent::getBreadcrumbPath();
if (array_key_exists('product', $this->_categoryPath)) {
$this->_categoryPath['product']['link'] = $this->getProduct()->getProductUrl();
}
return $this->_categoryPath;
}
}
answered Sep 8 '15 at 10:53
SmartieSmartie
2,8001727
2,8001727
add a comment |
add a comment |
Observe the proper event, perhaps something similar to (just guessing the event) core_block_abstract_to_html_before
, (but perhaps something that would be less often observed) with a custom observer, similar to:
<core_block_abstract_to_html_before>
<observers>
<df2k2_update_breadcrumb>
<class>df2k2_page/observer</class>
<method>updateBreadcrumbLink</method>
</df2k2_update_breadcrumb>
</observers>
</core_block_abstract_to_html_before>
Observer Class
public function updateBreadcrumbLink(Varien_Event_Observer $observer)
{
$breadcrumbsBlock = $observer->getEvent()->getBlock();
if ($breadcrumbsBlock instanceof Mage_Page_Block_Html_Breadcrumbs) {
// Get the block, get the last breadcrumb item in the array
// and simply check for registry('current_product') or 'current_category',
// and set the last item's [`link`] element to either the product's url or the categories URL
// example,
if (is_array($breadcrumbsBlock->_crumbs)) {
end($breadcrumbsBlock->_crumbs);
$breadcrumbsBlock->_crumbs[key($breadcrumbsBlock->_crumbs)]['link']
= Mage::getRegistry('current_product')->getUrl();
// = Mage::helper('core')->getCurrentUrl();
}
$breadcrumbsBlock->assign('crumbs', $breadcrumbsBlock->_crumbs);
}
return $this;
}
Once you set the link
part for the last crumb item in the array of crumbs, then it will automatically render the item to include the linked URL.
There is a lot of detail missing with logic and object checking for current_product and category... Essentially, if there exists a registry for current_product, use that... if current_category, use that... otherwise, simply do whatever you want, or nothing at all.
If you don't wish to look up the details of the product/category.. just get the current URL and set the ['link'] element to the current URL.
add a comment |
Observe the proper event, perhaps something similar to (just guessing the event) core_block_abstract_to_html_before
, (but perhaps something that would be less often observed) with a custom observer, similar to:
<core_block_abstract_to_html_before>
<observers>
<df2k2_update_breadcrumb>
<class>df2k2_page/observer</class>
<method>updateBreadcrumbLink</method>
</df2k2_update_breadcrumb>
</observers>
</core_block_abstract_to_html_before>
Observer Class
public function updateBreadcrumbLink(Varien_Event_Observer $observer)
{
$breadcrumbsBlock = $observer->getEvent()->getBlock();
if ($breadcrumbsBlock instanceof Mage_Page_Block_Html_Breadcrumbs) {
// Get the block, get the last breadcrumb item in the array
// and simply check for registry('current_product') or 'current_category',
// and set the last item's [`link`] element to either the product's url or the categories URL
// example,
if (is_array($breadcrumbsBlock->_crumbs)) {
end($breadcrumbsBlock->_crumbs);
$breadcrumbsBlock->_crumbs[key($breadcrumbsBlock->_crumbs)]['link']
= Mage::getRegistry('current_product')->getUrl();
// = Mage::helper('core')->getCurrentUrl();
}
$breadcrumbsBlock->assign('crumbs', $breadcrumbsBlock->_crumbs);
}
return $this;
}
Once you set the link
part for the last crumb item in the array of crumbs, then it will automatically render the item to include the linked URL.
There is a lot of detail missing with logic and object checking for current_product and category... Essentially, if there exists a registry for current_product, use that... if current_category, use that... otherwise, simply do whatever you want, or nothing at all.
If you don't wish to look up the details of the product/category.. just get the current URL and set the ['link'] element to the current URL.
add a comment |
Observe the proper event, perhaps something similar to (just guessing the event) core_block_abstract_to_html_before
, (but perhaps something that would be less often observed) with a custom observer, similar to:
<core_block_abstract_to_html_before>
<observers>
<df2k2_update_breadcrumb>
<class>df2k2_page/observer</class>
<method>updateBreadcrumbLink</method>
</df2k2_update_breadcrumb>
</observers>
</core_block_abstract_to_html_before>
Observer Class
public function updateBreadcrumbLink(Varien_Event_Observer $observer)
{
$breadcrumbsBlock = $observer->getEvent()->getBlock();
if ($breadcrumbsBlock instanceof Mage_Page_Block_Html_Breadcrumbs) {
// Get the block, get the last breadcrumb item in the array
// and simply check for registry('current_product') or 'current_category',
// and set the last item's [`link`] element to either the product's url or the categories URL
// example,
if (is_array($breadcrumbsBlock->_crumbs)) {
end($breadcrumbsBlock->_crumbs);
$breadcrumbsBlock->_crumbs[key($breadcrumbsBlock->_crumbs)]['link']
= Mage::getRegistry('current_product')->getUrl();
// = Mage::helper('core')->getCurrentUrl();
}
$breadcrumbsBlock->assign('crumbs', $breadcrumbsBlock->_crumbs);
}
return $this;
}
Once you set the link
part for the last crumb item in the array of crumbs, then it will automatically render the item to include the linked URL.
There is a lot of detail missing with logic and object checking for current_product and category... Essentially, if there exists a registry for current_product, use that... if current_category, use that... otherwise, simply do whatever you want, or nothing at all.
If you don't wish to look up the details of the product/category.. just get the current URL and set the ['link'] element to the current URL.
Observe the proper event, perhaps something similar to (just guessing the event) core_block_abstract_to_html_before
, (but perhaps something that would be less often observed) with a custom observer, similar to:
<core_block_abstract_to_html_before>
<observers>
<df2k2_update_breadcrumb>
<class>df2k2_page/observer</class>
<method>updateBreadcrumbLink</method>
</df2k2_update_breadcrumb>
</observers>
</core_block_abstract_to_html_before>
Observer Class
public function updateBreadcrumbLink(Varien_Event_Observer $observer)
{
$breadcrumbsBlock = $observer->getEvent()->getBlock();
if ($breadcrumbsBlock instanceof Mage_Page_Block_Html_Breadcrumbs) {
// Get the block, get the last breadcrumb item in the array
// and simply check for registry('current_product') or 'current_category',
// and set the last item's [`link`] element to either the product's url or the categories URL
// example,
if (is_array($breadcrumbsBlock->_crumbs)) {
end($breadcrumbsBlock->_crumbs);
$breadcrumbsBlock->_crumbs[key($breadcrumbsBlock->_crumbs)]['link']
= Mage::getRegistry('current_product')->getUrl();
// = Mage::helper('core')->getCurrentUrl();
}
$breadcrumbsBlock->assign('crumbs', $breadcrumbsBlock->_crumbs);
}
return $this;
}
Once you set the link
part for the last crumb item in the array of crumbs, then it will automatically render the item to include the linked URL.
There is a lot of detail missing with logic and object checking for current_product and category... Essentially, if there exists a registry for current_product, use that... if current_category, use that... otherwise, simply do whatever you want, or nothing at all.
If you don't wish to look up the details of the product/category.. just get the current URL and set the ['link'] element to the current URL.
edited Apr 15 '18 at 8:22
answered Apr 15 '18 at 8:03
df2k2df2k2
734310
734310
add a comment |
add a comment |
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a>
<?php elseif($_crumbInfo['last']): ?>
<?php // i have add link code here as below ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><strong><?php echo $this->escapeHtml($_crumbInfo['label']) ?></strong></a>
<?php else: ?>
<?php echo $this->escapeHtml($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>/ </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
edit above code in
app/design/frontend/[Your-theme]/[Your-package]/template/page/html/breadcrumbs.phtml
typo: breadcrums.phtml -- breadcrumbs.phtml, yes?
– df2k2
Apr 15 '18 at 7:04
yes breadcrums.phtml
– Yogesh Trivedi
Apr 24 '18 at 9:35
add a comment |
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a>
<?php elseif($_crumbInfo['last']): ?>
<?php // i have add link code here as below ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><strong><?php echo $this->escapeHtml($_crumbInfo['label']) ?></strong></a>
<?php else: ?>
<?php echo $this->escapeHtml($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>/ </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
edit above code in
app/design/frontend/[Your-theme]/[Your-package]/template/page/html/breadcrumbs.phtml
typo: breadcrums.phtml -- breadcrumbs.phtml, yes?
– df2k2
Apr 15 '18 at 7:04
yes breadcrums.phtml
– Yogesh Trivedi
Apr 24 '18 at 9:35
add a comment |
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a>
<?php elseif($_crumbInfo['last']): ?>
<?php // i have add link code here as below ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><strong><?php echo $this->escapeHtml($_crumbInfo['label']) ?></strong></a>
<?php else: ?>
<?php echo $this->escapeHtml($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>/ </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
edit above code in
app/design/frontend/[Your-theme]/[Your-package]/template/page/html/breadcrumbs.phtml
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a>
<?php elseif($_crumbInfo['last']): ?>
<?php // i have add link code here as below ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><strong><?php echo $this->escapeHtml($_crumbInfo['label']) ?></strong></a>
<?php else: ?>
<?php echo $this->escapeHtml($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>/ </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
edit above code in
app/design/frontend/[Your-theme]/[Your-package]/template/page/html/breadcrumbs.phtml
edited May 7 '18 at 18:09
MagentoAaron
388115
388115
answered Sep 8 '15 at 10:27
Yogesh TrivediYogesh Trivedi
1,94711424
1,94711424
typo: breadcrums.phtml -- breadcrumbs.phtml, yes?
– df2k2
Apr 15 '18 at 7:04
yes breadcrums.phtml
– Yogesh Trivedi
Apr 24 '18 at 9:35
add a comment |
typo: breadcrums.phtml -- breadcrumbs.phtml, yes?
– df2k2
Apr 15 '18 at 7:04
yes breadcrums.phtml
– Yogesh Trivedi
Apr 24 '18 at 9:35
typo: breadcrums.phtml -- breadcrumbs.phtml, yes?
– df2k2
Apr 15 '18 at 7:04
typo: breadcrums.phtml -- breadcrumbs.phtml, yes?
– df2k2
Apr 15 '18 at 7:04
yes breadcrums.phtml
– Yogesh Trivedi
Apr 24 '18 at 9:35
yes breadcrums.phtml
– Yogesh Trivedi
Apr 24 '18 at 9:35
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f82283%2fbreadcrumbs-product-hyperlink%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown