Foundation Magellan auto generate - php

I'd like to auto generate magellan on subpages from h3 tags.
For this purpose I tried jameswlane script (https://gist.github.com/jameswlane/f1eabeedf430ef67318d), and I changed only h2 tags to h3. It seems I dont aunderstand this code well.
I thought I only need to paste this code in my header.php file from wordpress theme and it will automatically sweep the DOM content for h3 tags, but it didn't.
Nothing shows up, even an empty div.
Used the followinf line as init:
<?php $tag = 'h3'; $html = get_the_content(); $items = getTextBetweenTags( $tag, $html ); ?>
Can I ask you for an advise in this matter?
<?php
function getTextBetweenTags($tag, $html, $strict=0) {
$dom = new domDocument;
if($strict==1) {
$dom->loadXML($html);
} else {
$dom->loadHTML($html);
}
$dom->preserveWhiteSpace = false;
$content = $dom->getElementsByTagname($tag);
$out = array();
foreach ($content as $item) {
$out[] = $item->nodeValue;
}
return $out;
}
function create_slug($string){
$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
return $slug;
}
function create_magellan($items){
$output .= '<div data-magellan-expedition="fixed">' . PHP_EOL;
$output .= '<dl class="sub-nav">' . PHP_EOL;
foreach( $items as $item ) {
$output .= '<dd data-magellan-arrival="' . create_slug( $item ) . '">' . $item . '</dd>';
}
$output .= '</dl>' . PHP_EOL;
$output .= '</div>' . PHP_EOL;
add_filter('the_content', 'my_formatter', 99);
echo $output;
}
function my_formatter($content) {
$new_content = '';
$tag = 'h3';
$pattern_full = '{(<' . $tag . '>.*?</' . $tag . '>)}is';
$pattern_contents = '{<' . $tag . '>(.*?)</' . $tag . '>}is';
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$test = $matches[1];
$new_content .= '<a name="'.create_slug($test).'"></a>'.PHP_EOL.'<'.$tag.' data-magellan-destination="'.create_slug($test).'">'.$test.'</'.$tag.'>'.PHP_EOL;
} else {
$new_content .= wptexturize(wpautop($piece));
}
}
return $new_content;
}
?>
EDIT
Something worked and returned error:
Warning: DOMDocument::loadHTML(): Empty string supplied as input in /www/ilee_www/www/2.goldbaltic/dev.goldbaltic.pl/wp-content/themes/dermiclab_fs/partials/2.Nav/mainNav.php on line 47
the line number 47 in my file is
$dom->loadHTML($html);
from
function getTextBetweenTags($tag, $html, $strict=0) {
$dom = new domDocument;
if($strict==1) {
$dom->loadXML($html);
} else {
$dom->loadHTML($html);
}
$dom->preserveWhiteSpace = false;
$content = $dom->getElementsByTagname($tag);
$out = array();
foreach ($content as $item) {
$out[] = $item->nodeValue;
}
return $out;
}

Related

Proper way to pass an array

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", '>');
?>

Show only Published custom type posts with Custom Metaboxes in the WordPress Archive page

I am using the SitePoint post to create a Post Series with Custom Post Type and have Custom Boxes for Post series number.
Below function is providing the list of all post published in the specific Taxonomy. Problem is it also listing the deleted & hidden posts as well:
function sitepoint_post_series_content_filter($content) {
$slug = "sitepoint-postseries";
if ($slug != get_post_type()) {
return $content;
}
$post_series_list = get_option("post_series_" . get_the_ID() . "_ids", "");
$post_series_list_array = explode(',', $post_series_list);
$post_series_serial_number = array();
foreach ($post_series_list_array as $key => $value) {
$serial_number = get_post_meta($value, "sitepoint-postseries-serial-number", true);
$post_series_serial_number[$value] = $serial_number;
}
asort($post_series_serial_number);
$html = "<ul class='sitepoint-post-series'>";
foreach ($post_series_serial_number as $key => $value) {
$post = get_post($key);
$title = $post->post_title;
$html = $html . "<li><h3><a href='" . get_permalink($key) . "'>" . $title . "</a></h3></li>";
}
$html = $html . "</ul>";
return $content . $html;
}
add_filter("the_content", "sitepoint_post_series_content_filter");
How can I exclude the Deleted & Hidden posts from this list.
Replace your code with below code.
function sitepoint_post_series_content_filter($content) {
$slug = "sitepoint-postseries";
if ($slug != get_post_type()) {
return $content;
}
$post_series_list = get_option("post_series_" . get_the_ID() . "_ids", "");
$post_series_list_array = explode(',', $post_series_list);
$post_series_serial_number = array();
foreach ($post_series_list_array as $key => $value) {
$serial_number = get_post_meta($value, "sitepoint-postseries-serial-number", true);
$post_series_serial_number[$value] = $serial_number;
}
asort($post_series_serial_number);
$finalArray = array();
foreach ($post_series_serial_number as $keyPostID => $valueID) {
if('publish' == get_post_status($keyPostID)){
$finalArray[$keyPostID] = $keyPostID;
}
}
$html = "<ul class='sitepoint-post-series'>";
foreach ($finalArray as $key => $value) {
$post = get_post($key);
$title = $post->post_title;
$html = $html . "<li><h3><a href='" . get_permalink($key) . "'>" . $title . "</a></h3></li>";
}
$html = $html . "</ul>";
return $content . $html;
}
add_filter("the_content", "sitepoint_post_series_content_filter");

PHP array splice not working

I'm trying to build a shortcode in wp that displays data from 2 RSS feeds.
The problem is that I can't limit the number of items in array. I tried these solutions and none worked.
function rss_posts_func( $atts ){
$feed = fetch_feed(array('rss-feed-1', 'rss-feed-2'));
$feed = array();
$feed = array_splice($feed, 0, 3);
// Loop the results
$content = '<ul class="rss-aggregator">';
foreach($feed->get_items() as $item) {
$content .= '<li class="feed-item">';
$content .= '<a href='.$item->get_permalink().'>';
$content .= $item->get_title();
$content .= '</a></li>';
}
$content .= '</ul>';
return $content;
}
Fixed with:
function rss_posts_func( $atts ){
$i = 1;
$feed = fetch_feed(array('rss-feed-1', 'rss-feed-2'));
$content = '<ul class="rss-aggregator">';
foreach($feed->get_items() as $item) {
$content .= '<li class="feed-item">';
$content .= '<a href='.$item->get_permalink().'>';
$content .= $item->get_title();
$content .= '</a></li>';
if($i++ == 8) break;
}
$content .= '</ul>';
return $content;
}

Function to add HTML tags depending on string content

I have tried to create a function to handle text from the database to be publish with automatic formating.
If there is a \n : it should be converted to <p>...</p>
If there is a - : it should also add the list tags
My problem is that I cant really figure out how to add the <ul> and </ul> tags.
function nl2p($string){
$string = explode("\n", $string);
$paragraphs = '';
foreach ($string as $line) {
if (trim($line)) {
if (substr($line,0,1) == '-'){
$paragraphs .= '<li>' . substr($line,1) . '</li>'."\r\n";
} else {
$paragraphs .= '<p>' . $line . '</p>'."\r\n";
}
}
}
return $paragraphs;
}
Use a variable ($ul in my example):
function nl2p($string){
$string = explode("\n", $string);
$paragraphs = '';
$ul = 0;
foreach ($string as $line) {
if (trim($line)) {
if (substr($line,0,1) == '-'){
if($ul == 0){
$paragraphs .= "<ul>\r\n";
$ul = 1;
}
$paragraphs .= '<li>' . substr($line,1) . '</li>'."\r\n";
} else {
if($ul == 1){
$paragraphs .= "</ul>\r\n";
$ul = 0;
}
$paragraphs .= '<p>' . $line . '</p>'."\r\n";
}
}
}
return $paragraphs;
}
Collect all continuous <li> elements with text in a string and then enclose this string in a <ul> and </ul>.
I would search for the first character to be a dash and, if the previous line did not start with a dash, add the <ul> there. Then wrap the line in li tags and the same check at the end - if the next line does not start with a dash, then add an </ul>.
Then, as a default action, wrap the line in a paragraph.
$string = "this is a string.
New line 1.
New line 2.
- List item
- Another list item
Some more lines of text";
function nl2p($input) {
$lines = explode("\r\n",$input);
$return = '';
foreach($lines as $key => $line) {
if(strpos($line,'-') === 0) {
if(array_key_exists($key-1,$lines) AND strpos($lines[$key-1],'-') === FALSE) {
$return .= '<ul>' . "\r\n";
}
$return .= '<li>' . $line . '</li>' . "\r\n";
if(array_key_exists($key+1,$lines) AND strpos($lines[$key+1],'-') !== 0) {
$return .= '</ul>' . "\r\n";
}
continue;
}
$return .= '<p>' . $line . '</p>' . "\r\n";
}
return $return;
}
var_dump(nl2p($string));
/*
<p>this is a string.</p>
<p>New line 1.</p>
<p>New line 2.</p>
<ul>
<li>- List item</li>
<li>- Another list item</li>
</ul>
<p>Some more lines of text</p>
*/
function nl2p($input) {
if(strpos($input, "\n")) {
$slash = explode("\n",$input);
$newPara = '';
foreach($slash as $slashval) {
$slashval = '#'.$slashval;
if(strpos($slashval,"-")) {
$slashval = substr($slashval, 1);
$hypen = explode("-",$slashval);
$newPara .= '<ul>';
foreach($hypen as $hypenval) {
if(!empty($hypenval)) {
$newPara .= '<li>'.$hypenval.'</li>';
}
}
$newPara .= '</ul>';
} else {
$slashval = substr($slashval, 1);
$newPara .= '<p>'.$slashval.'</p>';
}
}
return $newPara;
} else {
$slashval = $input;
if(strpos($slashval,"-")) {
$hypen = explode("-",$slashval);
$newPara .= '<ul>';
foreach($hypen as $cnt => $hypenval) {
if($cnt == 0) {
$start = $hypenval;
} else {
if(!empty($hypenval)) {
$newPara .= '<li>'.$hypenval.'</li>';
}
}
}
$newPara .= '</ul>';
$newPara = $start.$newPara;
} else {
$slashval = '#'.$input;
if(strpos($slashval,"-")) {
$slashval = substr($slashval, 1);
$hypen = explode("-",$slashval);
$newPara .= '<ul>';
foreach($hypen as $hypenval) {
if(!empty($hypenval)) {
$newPara .= '<li>'.$hypenval.'</li>';
}
}
$newPara .= '</ul>';
}
}
return $newPara;
}
return $input;
}

Restore standard Mage_Catalog_Block_Navigation functionality in top navigation for a single website in a multi-store Magento installation

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

Categories