Romain28 Posted February 20, 2013 Share Posted February 20, 2013 (edited) Bonjour, Je suis sur une version 1.5.3 de prestashop. J'aurais aimé faire l'intégration de rich snippets pour mon fil d'ariane. J'ai suivi les recommandations faites ici mais la modification du fichier Tools est toujours valable pour la version 1.5 ? J'ai pas essayé... Le tuto donne la marche à suivre pour les versions antérieures, pas de MAJ depuis. Merci d'avance Edited February 23, 2013 by Romain28 (see edit history) Link to comment Share on other sites More sharing options...
Romain28 Posted February 21, 2013 Author Share Posted February 21, 2013 up Link to comment Share on other sites More sharing options...
Romain28 Posted February 22, 2013 Author Share Posted February 22, 2013 UP Link to comment Share on other sites More sharing options...
Bondaty and Co Posted February 22, 2013 Share Posted February 22, 2013 J'ai testé ça l'fait pas, je suis sur une autre solution... Link to comment Share on other sites More sharing options...
Romain28 Posted February 23, 2013 Author Share Posted February 23, 2013 Je trouve pas up Link to comment Share on other sites More sharing options...
Bondaty and Co Posted February 23, 2013 Share Posted February 23, 2013 C'est un vrai casse tête le truc !! Link to comment Share on other sites More sharing options...
Romain28 Posted February 23, 2013 Author Share Posted February 23, 2013 Voila la modification à faire du fichier tools.php fonction getPath ligne 858 public static function getPath($id_category, $path = '', $link_on_the_item = false, $category_type = 'products', Context $context = null) { if (!$context) $context = Context::getContext(); $id_category = (int)$id_category; if ($id_category == 1) return '<span class="navigation_end">'.$path.'</span>'; $pipe = Configuration::get('PS_NAVIGATION_PIPE'); if (empty($pipe)) $pipe = '>'; $full_path = ''; if ($category_type === 'products') { $interval = Category::getInterval($id_category); $id_root_category = $context->shop->getCategory(); $interval_root = Category::getInterval($id_root_category); if ($interval) { $sql = 'SELECT c.id_category, cl.name, cl.link_rewrite FROM '._DB_PREFIX_.'category c LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.Shop::addSqlRestrictionOnLang('cl').') WHERE c.nleft <= '.$interval['nleft'].' AND c.nright >= '.$interval['nright'].' AND c.nleft >= '.$interval_root['nleft'].' AND c.nright <= '.$interval_root['nright'].' AND cl.id_lang = '.(int)$context->language->id.' AND c.active = 1 AND c.level_depth > '.(int)$interval_root['level_depth'].' ORDER BY c.level_depth ASC'; $categories = Db::getInstance()->executeS($sql); $n = 1; $n_categories = count($categories); foreach ($categories as $category) { $full_path .= (($n < $n_categories || $link_on_the_item) ? '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.Tools::safeOutput($context->link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'])).'" title="'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'" itemprop="url"><span itemprop="title">' : ''). htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8'). (($n < $n_categories || $link_on_the_item) ? '</span></a></div>' : ''). (($n++ != $n_categories || !empty($path)) ? '<span class="navigation-pipe">'.$pipe.'</span>' : ''); } return $full_path.$path; } } else if ($category_type === 'CMS') { $category = new CMSCategory($id_category, $context->language->id); if (!Validate::isLoadedObject($category)) die(Tools::displayError()); $category_link = $context->link->getCMSCategoryLink($category); if ($path != $category->name) $full_path .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.Tools::safeOutput($category_link).'" itemprop="url"><span itemprop="title">'.htmlentities($category->name, ENT_NOQUOTES, 'UTF-8').'</span></a></div><span class="navigation-pipe">'.$pipe.'</span>'.$path; else $full_path = ($link_on_the_item ? '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.Tools::safeOutput($category_link).'" itemprop="url"><span itemprop="title">' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($link_on_the_item ? '</span></a></div>' : ''); return Tools::getPath($category->id_parent, $full_path, $link_on_the_item, $category_type); } } Fichier breadcrumb.tpl : <!-- Breadcrumb --> {if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if} <div class="breadcrumb" style="display:inline"> <div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="{$base_dir}" title="{l s='return to Home'}" itemprop="url"><span itemprop="title">{l s='Home'}</a></div> {if isset($path) AND $path} <span class="navigation-pipe" {if isset($category) && isset($category->id_category) && $category->id_category == 1}style="display:none;"{/if}></span> {if !$path|strpos:'span'} <span class="navigation_page">{$path}</span> {else} {$path} {/if} {/if} </div> <!-- /Breadcrumb --> Voilà réussi finalement ^^ 3 Link to comment Share on other sites More sharing options...
Bondaty and Co Posted February 24, 2013 Share Posted February 24, 2013 Désolé Romain, les mêmes problèmes que j'avais apparaissent, ne fonctionne pas avec les CMS. je gratte un peu dans 1 semaine. Link to comment Share on other sites More sharing options...
radus Posted February 26, 2013 Share Posted February 26, 2013 (edited) Voila la modification à faire du fichier tools.php fonction getPath ligne 858 public static function getPath($id_category, $path = '', $link_on_the_item = false, $category_type = 'products', Context $context = null) { if (!$context) $context = Context::getContext(); $id_category = (int)$id_category; if ($id_category == 1) return '<span class="navigation_end">'.$path.'</span>'; $pipe = Configuration::get('PS_NAVIGATION_PIPE'); if (empty($pipe)) $pipe = '>'; $full_path = ''; if ($category_type === 'products') { $interval = Category::getInterval($id_category); $id_root_category = $context->shop->getCategory(); $interval_root = Category::getInterval($id_root_category); if ($interval) { $sql = 'SELECT c.id_category, cl.name, cl.link_rewrite FROM '._DB_PREFIX_.'category c LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.Shop::addSqlRestrictionOnLang('cl').') WHERE c.nleft <= '.$interval['nleft'].' AND c.nright >= '.$interval['nright'].' AND c.nleft >= '.$interval_root['nleft'].' AND c.nright <= '.$interval_root['nright'].' AND cl.id_lang = '.(int)$context->language->id.' AND c.active = 1 AND c.level_depth > '.(int)$interval_root['level_depth'].' ORDER BY c.level_depth ASC'; $categories = Db::getInstance()->executeS($sql); $n = 1; $n_categories = count($categories); foreach ($categories as $category) { $full_path .= (($n < $n_categories || $link_on_the_item) ? '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.Tools::safeOutput($context->link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'])).'" title="'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'" itemprop="url"><span itemprop="title">' : ''). htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8'). (($n < $n_categories || $link_on_the_item) ? '</span></a></div>' : ''). (($n++ != $n_categories || !empty($path)) ? '<span class="navigation-pipe">'.$pipe.'</span>' : ''); } return $full_path.$path; } } else if ($category_type === 'CMS') { $category = new CMSCategory($id_category, $context->language->id); if (!Validate::isLoadedObject($category)) die(Tools::displayError()); $category_link = $context->link->getCMSCategoryLink($category); if ($path != $category->name) $full_path .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.Tools::safeOutput($category_link).'" itemprop="url"><span itemprop="title">'.htmlentities($category->name, ENT_NOQUOTES, 'UTF-8').'</span></a></div><span class="navigation-pipe">'.$pipe.'</span>'.$path; else $full_path = ($link_on_the_item ? '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.Tools::safeOutput($category_link).'" itemprop="url"><span itemprop="title">' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($link_on_the_item ? '</span></a></div>' : ''); return Tools::getPath($category->id_parent, $full_path, $link_on_the_item, $category_type); } } Fichier breadcrumb.tpl : <!-- Breadcrumb --> {if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if} <div class="breadcrumb" style="display:inline"> <div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="{$base_dir}" title="{l s='return to Home'}" itemprop="url"><span itemprop="title">{l s='Home'}</a></div> {if isset($path) AND $path} <span class="navigation-pipe" {if isset($category) && isset($category->id_category) && $category->id_category == 1}style="display:none;"{/if}></span> {if !$path|strpos:'span'} <span class="navigation_page">{$path}</span> {else} {$path} {/if} {/if} </div> <!-- /Breadcrumb --> Voilà réussi finalement ^^ Romain, Do you happen to know how & where in these scripts to modify so that we get as active hyperlink the lowest level breadcrumb [ ex. Page Breadcrumb or SubCategory Beadcrumb ] ? It sems to be very important as of 2013, in AdWords Dynamic Ads , AdWords Quality score and Relevance score. thanks, r PS. I succeded to make Category link "active" in the breadcrumb. Works for Category and Subcategory when it is current page. I still have to discover for Product page. /classes/Tools.php look fo getPath public static function getPath($id_category, $path = '', $link_on_the_item = false true, $category_type = 'products', Context $context = null) Edited March 1, 2013 by radus (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now