Post by fragantes » Fri Aug 08, 2014 3:37 am

Hola, compre una extensión para el menu categoria y subniveles ilimitado, pero quisiera que al seleccionar la categoria padre, me aparezcan unicamente en el menu categoria, lo que seleccione de la categoria padre, y quitar las demas categorias al seleccionar esa, pensaba en un filtro, lo se hacer para el menu categoria normal, pero no hallo realizar lo que quiero aqui, el codigo del controller/module/category es este:

Code: Select all

<?php
class ControllerModulecategoryEnhanced extends Controller {
	protected function index($setting) {
		$this->language->load('module/category_enhanced');
		
    	$this->data['heading_title'] = $this->language->get('heading_title');
									
		$this->load->model('module/category_enhanced');

		if (file_exists('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/category_enhanced.css')) {
			$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/category_enhanced.css');
		} else {
			$this->document->addStyle('catalog/view/theme/comprasit/stylesheet/category_enhanced.css');
		}
		
		$this->document->addScript('catalog/view/javascript/jquery/category_enhanced.js');

		$categories = $this->model_module_category_enhanced->getAllCategories($parts[0]);
		$sorter = array();
		foreach ($categories as $key => $row) {
		    $sorter[$key] = $row['sort_order'];
		}
		array_multisort($sorter, SORT_ASC, $categories);
		$this->data['categories'] = $categories;
		$this->data['categories'] = $this->createTemplate(0, $categories, 'category');
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category_enhanced.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/category_enhanced.tpl';
		} else {
			$this->template = 'comprasit/template/module/category_enhanced.tpl';
		}
		
		$this->render();
  	}

	private function createTemplate($parent, $categories, $ulClass=null) {
		$currentUrl = $this->curPageURL();
		$ul = '<ul class="'.$ulClass.'">';
		$return = null; 
		$n=1;
		foreach ($categories as $category) {
			$url = $this->get_category_link($category, $categories);
			$class='';
			if($url == $currentUrl) {
				$class='active';
			}
			if ($category['status'] && $parent == $category['parent_id']) {
				$return .= '<li class="'.$class.' cli">'; 
				$return .= '<a href="'. $url .'">'.$category['name'].'</a>';  
				$return .= $this->createTemplate($category['category_id'], $categories, 'child'); 
				$return .= '</li>'; 
				++$n;
			}
		}
		if($return!=null) {
			$ul .= $return; 
			$ul .= '</ul>';
			return $ul;
		} else {
			return null;
		}
	}

	private function get_category_link($category, $categories) {
		$path = 'path='.$category['category_id'];
		$categories_parents = $this->find_pat($categories, $category['category_id']);
		if($categories_parents) {
			foreach ($categories_parents as $ctkey => $ctcat) {
				$path .= '_' . $ctcat['category_id'];
			}
		}
		$link = $this->url->link('product/category', 'path=' . $parts[0] . '_');
		return $link;
	}

	private function find_pat($a, $n, $key='category_id' ){
	    $out = array();
	    foreach ($a as $r){
	        if ($r[$key] == $n){
	            $out = $this->find_pat($a, $r['parent_id'],'category_id');
	            $out[]=$r;
	        }
	    }
	    return $out;
	}
	private function curPageURL() {
		$pageURL = 'http';
		if (isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on") { $pageURL .= "s"; }
		$pageURL .= "://";
		if ($_SERVER["SERVER_PORT"] != "80") {
			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
		} else {
			$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		}
		return $pageURL;
	}
}
?>

New member

Posts

Joined
Wed Mar 26, 2014 1:06 pm

Post by fragantes » Fri Aug 08, 2014 9:41 am

Holaa! Quien me puede ayudar? Por favor!

New member

Posts

Joined
Wed Mar 26, 2014 1:06 pm
Who is online

Users browsing this forum: Semrush [Bot] and 4 guests