devilsown Posted November 17, 2011 Share Posted November 17, 2011 I tired removing the _ in tools.php in the overides folder and copying this in but it did not work. Anyone have any ideas how i can set it up so i don't loose my custmation when newer updates come out.? /** * Get the user's journey * * @param integer $id_category Category ID * @param string $path Path end * @param boolean $linkOntheLastItem Put or not a link on the current category * @param string [optionnal] $categoryType defined what type of categories is used (products or cms) */ public static function getPath($id_category, $path = '', $linkOntheLastItem = false, $categoryType = 'products') { global $link, $cookie; if ($id_category == 1) return '<li>'.$path.'</li>'; $pipe = Configuration::get('PS_NAVIGATION_PIPE'); if (empty($pipe)) $pipe = '>'; $fullPath = ''; if ($categoryType === 'products') { $category = Db::getInstance()->getRow(' SELECT id_category, level_depth, nleft, nright FROM '._DB_PREFIX_.'category WHERE id_category = '.(int)$id_category); if (isset($category['id_category'])) { $categories = Db::getInstance()->ExecuteS(' 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) WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)($cookie->id_lang).' AND c.id_category != 1 ORDER BY c.level_depth ASC LIMIT '.(int)$category['level_depth']); $n = 1; $nCategories = (int)sizeof($categories); foreach ($categories AS $category) { $fullPath .= (($n < $nCategories OR $linkOntheLastItem) ? '<a href="'.self::safeOutput($link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'])).'" title="'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'">' : ''). htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8'). (($n < $nCategories OR $linkOntheLastItem) ? '</a>' : ''). (($n++ != $nCategories OR !empty($path)) ? ' <li>' : ''); } return $fullPath.$path; } } elseif ($categoryType === 'CMS') { $category = new CMSCategory((int)($id_category), (int)($cookie->id_lang)); if (!Validate::isLoadedObject($category)) die(self::displayError()); $categoryLink = $link->getCMSCategoryLink($category); if ($path != $category->name) $fullPath .= '<a href="'.self::safeOutput($categoryLink).'">'.htmlentities($category->name, ENT_NOQUOTES, 'UTF-8').'</a><span class="navigation-pipe">'.$pipe.'</span>'.$path; else $fullPath = ($linkOntheLastItem ? '<a href="'.self::safeOutput($categoryLink).'">' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($linkOntheLastItem ? '</a>' : ''); return self::getPath((int)($category->id_parent), $fullPath, $linkOntheLastItem, $categoryType); } } Link to comment Share on other sites More sharing options...
devilsown Posted November 17, 2011 Author Share Posted November 17, 2011 anyone have an idea how to set this up so i don't overite it when i upgrade my site. Link to comment Share on other sites More sharing options...
Dave L Posted November 17, 2011 Share Posted November 17, 2011 From what I understand you can only use overrides with .tpl .css and .js files. Link to comment Share on other sites More sharing options...
devilsown Posted November 17, 2011 Author Share Posted November 17, 2011 I think there is a way by using the overide folder. Just don't understand how to use it. Link to comment Share on other sites More sharing options...
Dave L Posted November 17, 2011 Share Posted November 17, 2011 Ah, OK, I didn't know that. I'll watch your thread with interest. Link to comment Share on other sites More sharing options...
devilsown Posted November 19, 2011 Author Share Posted November 19, 2011 I guess there is no way to do this. Link to comment Share on other sites More sharing options...
razaro Posted November 19, 2011 Share Posted November 19, 2011 Leave _Tools.php like it was and create new Tools.php with this code <?php class Tools extends ToolsCore { /** * Get the user's journey * * @param integer $id_category Category ID * @param string $path Path end * @param boolean $linkOntheLastItem Put or not a link on the current category * @param string [optionnal] $categoryType defined what type of categories is used (products or cms) */ public static function getPath($id_category, $path = '', $linkOntheLastItem = false, $categoryType = 'products') { global $link, $cookie; if ($id_category == 1) return '<li>'.$path.'</li>'; $pipe = Configuration::get('PS_NAVIGATION_PIPE'); if (empty($pipe)) $pipe = '>'; $fullPath = ''; if ($categoryType === 'products') { $category = Db::getInstance()->getRow(' SELECT id_category, level_depth, nleft, nright FROM '._DB_PREFIX_.'category WHERE id_category = '.(int)$id_category); if (isset($category['id_category'])) { $categories = Db::getInstance()->ExecuteS(' 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) WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)($cookie->id_lang).' AND c.id_category != 1 ORDER BY c.level_depth ASC LIMIT '.(int)$category['level_depth']); $n = 1; $nCategories = (int)sizeof($categories); foreach ($categories AS $category) { $fullPath .= (($n < $nCategories OR $linkOntheLastItem) ? '<a href="'.self::safeOutput($link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'])).'" title="'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'">' : ''). htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8'). (($n < $nCategories OR $linkOntheLastItem) ? '</a>' : ''). (($n++ != $nCategories OR !empty($path)) ? ' <li>' : ''); } return $fullPath.$path; } } elseif ($categoryType === 'CMS') { $category = new CMSCategory((int)($id_category), (int)($cookie->id_lang)); if (!Validate::isLoadedObject($category)) die(self::displayError()); $categoryLink = $link->getCMSCategoryLink($category); if ($path != $category->name) $fullPath .= '<a href="'.self::safeOutput($categoryLink).'">'.htmlentities($category->name, ENT_NOQUOTES, 'UTF-8').'</a><span class="navigation-pipe">'.$pipe.'</span>'.$path; else $fullPath = ($linkOntheLastItem ? '<a href="'.self::safeOutput($categoryLink).'">' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($linkOntheLastItem ? '</a>' : ''); return self::getPath((int)($category->id_parent), $fullPath, $linkOntheLastItem, $categoryType); } } } So what I think that you missed is class Tools extends ToolsCore { ... } Here are some link that maybe could explain more http://www.nethercot...rriding-classes http://doc.prestasho...roller+Override Link to comment Share on other sites More sharing options...
devilsown Posted November 19, 2011 Author Share Posted November 19, 2011 Thanks so much for your help, that is what i was leaving out of the of my tools.php 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