I would like to make a small change in a code for a table of contents.
I want to add a sign in front of each heading. The character should be recognized as text.
I've tried a few things, but unfortunately I have not found the right variable.
The code comes from a plugin for Wordpress
I have already tried the following variables:
$items
$tic
$find
$replace
$post
Here is the code that prints the list:
if ( $tic->is_eligible($custom_toc_position) ) {
extract( $args );
$items = $tic->extract_headings( $find, $replace,wptexturize($post->post_content) );
$title = ( array_key_exists('title', $instance) ) ? apply_filters('widget_title', $instance['title']) : '';
if ( strpos($title, '%PAGE_TITLE%') !== false ) $title = str_replace( '%PAGE_TITLE%', get_the_title(), $title );
if ( strpos($title, '%PAGE_NAME%') !== false ) $title = str_replace( '%PAGE_NAME%', get_the_title(), $title );
$hide_inline = $toc_options['show_toc_in_widget_only'];
$css_classes = '';
// bullets?
if ( $toc_options['bullet_spacing'] )
$css_classes .= ' have_bullets';
else
$css_classes .= ' no_bullets';
if ( $items ) {
// before widget (defined by themes)
echo $before_widget;
// display the widget title if one was input (before and after titles defined by themes)
if ( $title ) echo $before_title . $title . $after_title;
// display the list
echo '<ul class="toc_widget_list' . $css_classes . '">' . $items . '</ul>';
// after widget (defined by themes)
echo $after_widget;
}
This are the full code of function extract_headings:
public function extract_headings( &$find, &$replace, $content = '' )
{
$matches = array();
$anchor = '';
$items = false;
// reset the internal collision collection as the_content may have been triggered elsewhere
// eg by themes or other plugins that need to read in content such as metadata fields in
// the head html tag, or to provide descriptions to twitter/facebook
$this->collision_collector = array();
if ( is_array($find) && is_array($replace) && $content ) {
// get all headings
// the html spec allows for a maximum of 6 heading depths
if ( preg_match_all('/(<h([1-6]{1})[^>]*>).*<\/h\2>/msuU', $content, $matches, PREG_SET_ORDER) ) {
// remove undesired headings (if any) as defined by heading_levels
if ( count($this->options['heading_levels']) != 6 ) {
$new_matches = array();
for ($i = 0; $i < count($matches); $i++) {
if ( in_array($matches[$i][2], $this->options['heading_levels']) )
$new_matches[] = $matches[$i];
}
$matches = $new_matches;
}
// remove specific headings if provided via the 'exclude' property
if ( $this->options['exclude'] ) {
$excluded_headings = explode('|', $this->options['exclude']);
if ( count($excluded_headings) > 0 ) {
for ($j = 0; $j < count($excluded_headings); $j++) {
// escape some regular expression characters
// others: http://www.php.net/manual/en/regexp.reference.meta.php
$excluded_headings[$j] = str_replace(
array('*'),
array('.*'),
trim($excluded_headings[$j])
);
}
$new_matches = array();
for ($i = 0; $i < count($matches); $i++) {
$found = false;
for ($j = 0; $j < count($excluded_headings); $j++) {
if ( #preg_match('/^' . $excluded_headings[$j] . '$/imU', strip_tags($matches[$i][0])) ) {
$found = true;
break;
}
}
if (!$found) $new_matches[] = $matches[$i];
}
if ( count($matches) != count($new_matches) )
$matches = $new_matches;
}
}
// remove empty headings
$new_matches = array();
for ($i = 0; $i < count($matches); $i++) {
if ( trim( strip_tags($matches[$i][0]) ) != false )
$new_matches[] = $matches[$i];
}
if ( count($matches) != count($new_matches) )
$matches = $new_matches;
// check minimum number of headings
if ( count($matches) >= $this->options['start'] ) {
for ($i = 0; $i < count($matches); $i++) {
// get anchor and add to find and replace arrays
$anchor = $this->url_anchor_target( $matches[$i][0] );
$find[] = $matches[$i][0];
$replace[] = str_replace(
array(
$matches[$i][1], // start of heading
'</h' . $matches[$i][2] . '>' // end of heading
),
array(
$matches[$i][1] . '<span id="' . $anchor . '">',
'</span></h' . $matches[$i][2] . '>'
),
$matches[$i][0]
);
// assemble flat list
if ( !$this->options['show_heirarchy'] ) {
$items .= '<li><a href="#' . $anchor . '">';
if ( $this->options['ordered_list'] ) $items .= count($replace) . ' ';
$items .= strip_tags($matches[$i][0]) . '</a></li>';
}
}
// build a hierarchical toc?
// we could have tested for $items but that var can be quite large in some cases
if ( $this->options['show_heirarchy'] ) $items = $this->build_hierarchy( $matches );
}
}
}
return $items;
}
I tried it like this:
$items = '>'.$items
$tic = '>'.$tic
$find = '>'.$find
.
.
.
Unfortunately, nothing has hit the right place
$ items addressed only the entire list
The other Variables had no effect or led to errors
The extract_headings is creating the list items. This section of the function...
// assemble flat list
if ( !$this->options['show_heirarchy'] ) {
$items .= '<li><a href="#' . $anchor . '">';
if ( $this->options['ordered_list'] ) $items .= count($replace) . ' ';
$items .= strip_tags($matches[$i][0]) . '</a></li>';
}
Should look like this:
// assemble flat list
if ( !$this->options['show_heirarchy'] ) {
$items .= '<li><a href="#' . $anchor . '">>';
if ( $this->options['ordered_list'] ) $items .= count($replace) . ' ';
$items .= strip_tags($matches[$i][0]) . '</a></li>';
}
You can see I've added an extra > inside the hyperlink on the third line. If adding an extra > causes any issues, you can also use >.
Related
I'm trying to make my list of tags, organized with first letter heads, to show Alphabet (a, b, c, d, etc..) first then numbers and symbols (#,1,2,3 etc..)
here is my code:
<?php $list = '';
$tags = get_tags();
$groups = array();
if( $tags && is_array( $tags ) ) {
foreach ($tags as $tag) {
$first_letter = strtoupper( $firstLetter );
$groups[ $first_letter ][] = $tag;
}
if( !empty( $groups ) ) {
foreach( $groups as $letter => $tags ) {
usort($letter, 'myComparison');
$list .= "\n\t" . '</ul><h2>' . apply_filters( 'the_title', $letter ) .'</h2>';
$list .= "\n\t" . '</ul><ul id="archiveEach">';
foreach( $tags as $tag ) {
$lower = strtolower($tag->name);
$name = str_replace(' ', ' ', $tag->name);
$naam = str_replace(' ', '-', $lower);
$link = $tag->link;
$list .= "\n\t\t" . '<li>'.$name.'</li>';
}}}}else $list .= "\n\t" . '<p>Sorry, but no tags were found</p>';
print_r( $list);
?>
I've tried to sort using different functionalities, using this
function myComparison($a, $b){
if(is_numeric($a) && !is_numeric($b))
return 1;
else if(!is_numeric($a) && is_numeric($b))
return -1;
else
return ($a < $b) ? -1 : 1;
}
then calling the function using usort($differnentelements, 'myComparison')
I cannot get it to work -- any suggestions would be really greatly appreciated. thanks!
I'm trying to output order numbers to elements that are generated from gallery captions.
foreach ( $item['gallery'] as $image ) {
$lines = intval( apply_filters( 'caption_line', 1 ) );
for ( $line = 1; $line <= $lines; $line++ ) {
$attachment_post = get_post( $image['id'] );
$image_caption = $attachment_post->post_excerpt;
echo '<span class="dot1" onclick="currentSlide' . $item['unit_link'] . '(' . esc_attr( $line ) . ')">' . $image_caption . '</span>';
}
}
So I need 1,2,3,4...to be generated for $line, but for what I have tried it only output 1 for all elements, changing 1 $lines = intval( apply_filters( 'caption_line', 1 ) ); to higher number shows the number, but also duplicate them.
Just figured it out, this does exactly what I was looking for!
foreach ( $item['gallery'] as $key => $image ) {
$attachment_post = get_post( $image['id'] );
$image_caption = $attachment_post->post_excerpt;
$keyplus = $key+1;
echo '<span class="dot1" onclick="currentSlide' . $item['unit_link'] . '(' . $keyplus . ')">' . $image_caption . '</span>';
}
This one is boggling me, because I think the code is right but something just isn't clicking, this is a code I picked up from Yanick Rochon and it works when the array is hard coded (in the commented out area) but when I push together the array from all of the pa_mymelp terms it doesn't behave as expected, it uses the entire line as an item vs multiple items per line, and does not create children either, wonder why.. thank you!:
<?php
$thearray = array();
$terms = get_terms("pa_mymelp");
foreach ( $terms as $term ) {
$categories = $term->name;
array_push($thearray, $categories);
}
$categoryLines = $thearray;
/*$categoryLines = array(
"Dodge>2002>Ram 3500>5.9 359cid L6 DIESEL OHV>Engine>Engine Oil Cooler",
"Dodge>2001>Ram 2500>5.9 359cid L6 DIESEL OHV>Engine>Engine Oil Cooler"
);*/
function buildCategoryTree($categoryLines, $separator) {
$catTree = array();
foreach ($categoryLines as $catLine) {
$path = explode($separator, $catLine);
$node = & $catTree;
foreach ($path as $cat) {
$cat = trim($cat);
if (!isset($node[$cat])) {
$node[$cat] = array();
}
$node = & $node[$cat];
}
}
return $catTree;
}
function displayCategoryTree($categoryTree, $indent = '') {
foreach ($categoryTree as $node => $children) {
echo $indent . $node . "\n";
displayCategoryTree($children, $indent . '|- ');
}
}
$categoryTree = buildCategoryTree($categoryLines, '>');
function displayHtmlCategoryTree($categoryTree, $id = null, $pathSeparator = '>', $parents = '') {
if (empty($categoryTree)) return '';
$str = '<ul' . (!empty($id) ? ' id="'.$id.'"' : '') . '>';
foreach ($categoryTree as $node => $children) {
$currentPath = $parents . (empty($parents) ? '' : $pathSeparator) . $node;
$str .= '<li title="' . $currentPath . '">' . $node .
displayHtmlCategoryTree($children, null, $pathSeparator, $currentPath) .
'</li>';
}
$str .= '</ul>';
return $str;
}
echo displayHtmlCategoryTree($categoryTree, "test", '>');
?>
I´m trying to shuffle articles with the PHP-shuffle function and with the Simple HTML Parser.
For example, this is my content:
<p>This is my article.</p>
<h2>This is a subheading</h2>
<p>This is an paragraph with an image inside it <img src="http://image.jpg">
</p>
The output should be something like this:
<p>article is This my .</p>
<h2>This subheading is a</h2>
<p>is an with an image paragraph inside This it <img src="http://image.jpg"></p>
However, using the Simple HTML DOM parser, I find it difficult to prevent the images from being shuffeled because they sometimes are placed inside paragraphs.
This is my current script. I feel like it is way to complicated, and it sometimes doesn't output the correct result.
Hopefully someone can help me.
$tags = 'p, ul, ol, blockquote, h1, h2, h3, h4, h5, h6, h7';
$html = str_get_html( $html );
/**
* Loop through HTML and set output
*/
foreach( $html->find( $tags ) as $article ) {
$element = $article->outertext;
$array = $article;
$tag = $article->tag;
$innerHTML = '';
// Nested paragraphs
foreach ( $array->find('p') as $el ){
$word_array = preg_replace( "#[\s]+#", " ", $el->innertext );
$words = explode( " ", $word_array );
$w = '';
shuffle( $words );
foreach ( $words as $word ){
$w .= $word . ' ';
}
$innerHTML .= $el->innertext = $w;
}
// List items
foreach ( $array->find('li') as $el ){
$word_array = preg_replace( "#[\s]+#", " ", $el->innertext );
$words = explode( " ", $word_array );
$w = '';
shuffle( $words );
foreach ( $words as $word ){
$w .= $word . ' ';
}
$innerHTML .= $el->innertext = '<li>' . $w . '</li>';
}
// Images
foreach ( $array->find('img') as $el ) {
// Blur image
$src = stripslashes( str_replace( '"', '', $el->src ) );
$new_src = $this->create_blur_image( $src );
// Replace url with base64 encode
$src = $el->src = $new_src;
$innerHTML .= $el->outertext;
}
// Output
if ( $innerHTML ){
$element = $article->innertext = $innerHTML;
} else {
$word_array = preg_replace( "#[\s]+#", " ", $article->innertext );
$words = explode( " ", $word_array );
$w = '';
shuffle( $words );
foreach ( $words as $word ){
$w .= $word . ' ';
}
$element = $article->innertext = $w;
}
$output .= $article->outertext;
}
$html = $output;
return $html;
Use:
function shuffle($text){
$text_array = array_shuffle(explode(" ",$text));
$text_string = implode($text_array," ");
return $text_string;
}
I'm currently working on a Magento installation with multiple websites and store views. I'm attempting to redesign one of the four sub websites.
There has been a custom module added which appears to rewrite/extend the default top navigation menu to automatically include CMS pages and add a banner slot to the menu. The problem is that I want to restore the default Magento top menu (i.e. no CMS pages) for a single website view.
I've tried disabling the module inside System -> Config -> Advanced -> Advanced for that website, however this seems to make the entire top navigation disappear. I believe the function I want to remove is this:
<?php
/**
* extend functions from navigation.php
*
*/
class Fvzzy_Category_Block_Navigation extends Mage_Catalog_Block_Navigation
{
protected $_menus;
protected function _getCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$html = array();
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array)$category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = ($children && $childrenCount);
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = ($activeChildrenCount > 0);
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
//$classes[] = 'nav-' . $this->_getItemPosition($level);
$text = preg_replace('/[^A-Za-z0-9]/i', '-', strtolower($category->getName()));
//$classes[] = $category->;
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="'.$outermostItemClass.'"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
//$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
if(strtolower($text) == 'sale') $classes[] = strtolower($text);
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
// render children
$htmlChildren = '';
$j = 0;
foreach ($activeChildren as $child) {
$htmlChildren .= $this->_getCategoryMenuItemHtml(
$child,
($level + 1),
($j == $activeChildrenCount - 1),
($j == 0),
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
$j++;
}
$promotion = $this->addPromotions($category->getId());
if (!empty($htmlChildren)) {
if ($childrenWrapClass) {
$html[] = '<div class="' . $childrenWrapClass . '">';
}
$html[] = '<ul class="level' . $level . '"><div class="menu-text">';
if($promotion) $html[] = '';
$html[] = $htmlChildren;
if($promotion) $html[] = '';
if($promotion) $html[] = '</div><li class="level1 parent menu-promotion">'.$promotion.'</li>';
$html[] = '</ul>';
if ($childrenWrapClass) {
$html[] = '</div>';
}
}
$html[] = '</li>';
$html = implode("\n", $html);
return $html;
}
public function renderCategoriesMenuHtml($level = 0, $outermostItemClass = '', $childrenWrapClass = '')
{
$activeCategories = array();
foreach ($this->getStoreCategories() as $child) {
if ($child->getIsActive()) {
$activeCategories[] = $child;
}
}
$activeCategoriesCount = count($activeCategories);
$hasActiveCategoriesCount = ($activeCategoriesCount > 0);
if (!$hasActiveCategoriesCount) {
return '';
}
$html = '';
$j = 0;
foreach ($activeCategories as $category) {
$html .= $this->_getCategoryMenuItemHtml(
$category,
$level,
($j == $activeCategoriesCount - 1),
($j == 0),
true,
$outermostItemClass,
$childrenWrapClass,
true
);
$j++;
}
//main store
if(Mage::app()->getStore()) $html .= $this->addMenu($childrenWrapClass,Mage::app()->getStore());
return $html;
}
protected function addPromotions($id = 0){
if($id){
$base = Mage::getBaseUrl('media',true).'promotion_box_images/';
$file_base = Mage::getBaseDir('media').'/promotion_box_images';
$html = ''; $img = '';
$promotion = Mage::getModel('promotion/box')->getCollection()->addFieldToFilter('menu_ids',array(
array('like'=>$id),
array('like'=>$id.',%'),
array('like'=>'%,'.$id.',%'),
array('like'=>'%,'.$id)))->setOrder('position')->getFirstItem(); //default is desc
if($promotion && $promotion->getId()){
$type=$promotion->getDisplayType();
$link = ''; $img = ''; $content = ''; $width = '';
if(file_exists($file_base.'/'.$promotion->getImage())){
list($width) = getimagesize($file_base.'/'.$promotion->getImage());
}
if($type!=null){
switch($type){
case 0:
if($promotion->getImage()!='') $img = '<img src="'.$base.$promotion->getImage().'" alt="'.$promotion->getTitle().'" width="'.$width.'"/>';
if(trim($promotion->getLink())!='') $link = $promotion->getLink();
break;
case 1:
if($promotion->getImage()!='') $img = '<img src="'.$base.$promotion->getImage().'" alt="'.$promotion->getTitle().'" width="'.$width.'"/>';
if($promotion->getCategoryId()){
$c = Mage::getModel('catalog/category')->load($promotion->getCategoryId());
if($c->getId() && $c->getIsActive()) $link = Mage::helper('catalog/category')->getCategoryUrl($c);
}
break;
case 2:
if($promotion->getImage()!='') $img = '<img src="'.$base.$promotion->getImage().'" alt="'.$promotion->getTitle().'" width="'.$width.'"/>';
if($promotion->getProductSku()){
$id = Mage::getModel('catalog/product')->getIdBySku($promotion->getProductSku());
$p = Mage::getModel('catalog/product')->load($id);
if($p->getId()) $link = $p->getProductUrl();
}
break;
case 3:
if($promotion->getImage()!='') $img = '<img src="'.$base.$promotion->getImage().'" alt="'.$promotion->getTitle().'" width="'.$width.'"/>';
if($promotion->getPageId()){
$_link = Mage::Helper('cms/page')->getPageUrl($promotion->getPageId());
if($_link != ''){
$nodes = Mage::getModel('enterprise_cms/hierarchy_node')->getCollection()
->addFieldToFilter('page_id', array('eq' => $promotion->getPageId()));
foreach($nodes as $_node){
$link = $_node->getRequestUrl();
}
if(!$link){$link = Mage::Helper('cms/page')->getPageUrl($promotion->getPageId());}
}
}
break;
case 4:
$content = $promotion->getContent();
break;
}
}
if($img && $link){
$html = ''.$img.'';
}
elseif($img){
$html = ''.$img.'';
}
else{
$html = $content;
}
}
return $html;
}else{return false;}
}
//$menu = array( array('label'=>'News','href'=>'blog','module'=>'blog','sub'=>array(array('label'=>'submenu','href'=>'blog2','module'=>'blog'))) );
public function setOtherMenu($menu){
$this->_menus = $menu;
}
public function addMenu( $childrenWrapClass = '', $store ) {
$this->_node_ids = array();
$current_module = $this->getRequest()->getModuleName();
$page_id = $this->getRequest()->getParam('page_id');
// get all the cms page nodes not folder or containers
$nodes = Mage::getModel('enterprise_cms/hierarchy_node')->getCollection()
->joinMetaData()
->addFieldToFilter( 'level', 1 )
//->addFieldToFilter( 'menu_visibility', 1 )
->addFieldToFilter( 'main_table.page_id', array( 'notnull' => true ))
->setOrder('sort_order','ASC');
if ( $store instanceof Mage_Core_Model_Store ) {
$store = $store->getId();
$storeIds = array( 0, $store );
$nodes->getSelect()
->joinLeft( array( 'cs' => 'cms_page_store' ), 'main_table.page_id=cs.page_id', array( 'cs.store_id' ) )
->where( 'cs.store_id IN ('. implode( ',', $storeIds ) .')' ); // not the best sql here but it works as store id will be one at a time.
}
$active_node = Mage::registry('current_cms_hierarchy_node');
$active_node_ids = array();
if($active_node){
$xpath = $active_node->getXpath();
$all = explode( '/', $xpath );
foreach ( $all as $index ) $active_node_ids[] = $index;
}
$this->_node_ids = $active_node_ids;
if ( $this->_menus ) {
$menus = $this->_menus;
}
else {
$menus = array();
}
$links = '';
foreach ( $nodes as $node ) {
$tree = $node->setCollectActivePagesOnly(true)
->setCollectIncludedPagesOnly(true)
->setTreeMaxDepth(0)
->setTreeIsBrief(1) //this way it won't show the container link
->getTreeSlice(0, 1); //up to tree top and down to one level
$links .= $this->drawCmsMenu($tree,0,1,$childrenWrapClass);
}
foreach ( $menus as $menu ) {
if(isset($menu['sub'])) $has_sub_class = ' parent'; else $has_sub_class = '';
if (isset($menu['module']) && $current_module == $menu['module'] ) {
$links .= '<li class="level0 level-top active'.$has_sub_class.'">';
}
else {
$links .= '<li class="level0 level-top'.$has_sub_class.'">';
}
$html = '';
if(isset($menu['sub']) && is_array($menu['sub'])){
$submenu = $menu['sub'];
$html .= '<div class="'.$childrenWrapClass.'"><ul class="level0">';
foreach($submenu as $sub){
if(is_array($sub) &&isset($sub['href']) && isset($sub['label']))
//2012-11-20 AU TEAM coding for change <h2> -> <span>
$html .= '<li class="level1"><span>'.$sub['label'].'</span></li>';
}
$html .= '</div>';
}
if(isset($menu['href']) && isset($menu['label']))
$links .= '<a class="level-top" href="'.Mage::getBaseUrl().$menu['href'].'"><span>'.$menu['label'].'</span></a>';
//add submenu
if($html != '') $links .= $html;
$links .= '</li>';
}
return $links;
}
/* Add Maximal Depth filter
* 2012.04.11 by Bruce
*/
public function drawCmsMenu( array $tree, $parentNodeId = 0, $level = 0, $childrenWrapClass = '' ) {
$html = '';
if ( !isset($tree[$parentNodeId ])) return $html;
foreach ( $tree[ $parentNodeId ] as $nodeId => $node ) {
/* #var $node Enterprise_Cms_Model_Hierarchy_Node */
$nested = $this->drawCmsMenu( $tree, $nodeId, $node->getLevel()+1, $childrenWrapClass);
$hasChildren = ( $nested != '' );
// set style classes
$class = array();
$class[] = 'level'. ( $level - 1 );
if ( $level - 1 == 0 )
$class[] = 'level-top';
if ( $this->_node_ids && in_array( $node->getNodeId(), $this->_node_ids ) )
$class[] = 'active';
if ( $hasChildren )
$class[] = 'parent';
// li wrapper header
$html .= '<li class="'. implode( ' ', $class ) .'">';
$html .= $this->_getNodeLabel( $node, $level - 1 );
// div wrapper header
if ( $hasChildren ){
if ( $childrenWrapClass ) $html .= '<div class="'. $childrenWrapClass .'">';
$html .= '<ul class="level'. ( $level - 1 ) .'">';
}
// children
$html .= $nested;
// div wrapper footer
if ( $hasChildren ) {
$html.='</ul>';
if ( $childrenWrapClass ) $html .= '</div>';
}
// li wrapper footer
$html .= '</li>';
}
return $html;
}
protected function _getNodeLabel($node,$level)
{
if($level==0) $class = 'level-top'; else $class = '';
if($node->getPageTitle()) return '<a class="'.$class.'" href="'.$node->getUrl().'"><span>'.$node->getPageTitle().'</span></a>';
else return '<a class="'.$class.'" href="'.$node->getUrl().'"><span>'.$node->getLabel().'</span></a>';
}
}
I know that the config file for this module looks like the following:
<?xml version="1.0"?>
<config>
<modules>
<Fvzzy_Category>
<version>0.1.0</version>
</Fvzzy_Category>
</modules>
<global>
<blocks>
<fvzzy_category>
<class>Fvzzy_Category_Block</class>
</fvzzy_category>
<catalog>
<rewrite>
<navigation>Fvzzy_Category_Block_Navigation</navigation>
</rewrite>
</catalog>
</blocks>
<resources>
<fvzzy_category_setup>
<setup>
<module>Fvzzy_Category</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
</fvzzy_category_setup>
</resources>
</global>
</config>
And that if I'm able to remove the following part from that file, I get my intended outcome:
<catalog>
<rewrite>
<navigation>Fvzzy_Category_Block_Navigation</navigation>
</rewrite>
</catalog>
The problem is, I just want to get the top navigation menu function restored back to normal for one website view.
Is there any way to overwrite that navigation rewrite event for one store/website view?
If not, is it possible to disable this module without it disabling my whole top menu for that website view?
I've tried completely duplicating the module, disabling the original one and enabling the new one in my desired website but that also appears to be making the top menu disappear entirely.
I'm really not sure what else to do with this - if anyone is able to help it would be hugely appreciated.
Thanks so much.
if you want this extension still for your Magento application, then disabling the extension will not produce expecting result.
In this case, you can do two things
Overwrite this custom extension with your module and make changes according to your need
comment out the config section that defines that core block overwrite. You have already tried it and worked it
There is another alternative. You can do a condition checking inside the rewrite block class. This condition check somewhat look like this.
if(Mage::app()->getStore()->getCode()== 'website_code_for_sub_site'){
//execute existing code
}
This method ensure that, the method that defined inside the rewrite block class will get executed only when the site with a code website_code_for_sub_site is viewing.
Hope that helps