Хочу сделать модуль вывода подкатегорий, что бы выводит имеено подкатегории товаров визуально, так как выводит продукты в категориях модуль jxtc_vmshowcase в шаблоне Teqmart. За основу взяла модуль frontpage_categories и подправила вывод информации. Но столкнулась с двумя проблемами: 1. модуль выводит подкатегории, но вывод информации о под категориях не под описанием гланой категории, а на категорию ниже. В иноге все сбивается. На рисунке стрелками показано в какой строке должны быть указанные строки подкатегорий. Как это исправить не могу понят. 2.Хотелось бы, что бы система не все подряд главные катеогрии мне выдавала, а только выбранные, через админ Джумлы. Что я не знаю как реализовать. Правку осуществляла только php фаилов, ни css, ни xml не трогала. Помогите, пожалуйста, разобраться с этим.
mod_frontpage_categories.php Код (PHP): <?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); include_once "mod_frontpage_categories_functions.php"; global $jscook_type, $jscookMenu_style, $jscookTree_style; // Load the virtuemart main parse code if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) { require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' ); $mosConfig_absolute_path = realpath( dirname(__FILE__).'/../..' ); } else { require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' ); } $category_id = vmGet( $_REQUEST, 'category_id'); /* Get module parameters */ $class_sfx = $params->get( 'class_sfx', "" ); $num_columns = $params->get( 'num_columns', "3" ); $mod_height = $params->get( 'mod_height', "200" ); $mod_width = $params->get( 'mod_width', "700" ); $cat_height = $params->get( 'cat_height', "90" ); $image_width = $params->get( 'image_width', "90" ); $sub_categories_display = $params->get( 'sub_categories_display', '1' ); $_REQUEST['root_label'] = $params->get( 'root_label', 'Shop' ); $class_mainlevel = "mainlevel".$class_sfx; global $VM_LANG, $sess; if( vmIsJoomla('1.5' )) { $vm_path = $mosConfig_absolute_path.'/modules/mod_virtuemart'; } else { $vm_path = $mosConfig_absolute_path.'/modules'; } require_once(CLASSPATH.'ps_product_category.php'); $ps_product_category = new ps_product_category(); #echo $ps_product_category->get_category_tree( $category_id, $class_mainlevel ); #echo $ps_product_category->get_subcategory( '1'); '.$mosConfig_absolute_path.' echo '<link rel="stylesheet" href="modules/mod_frontpage_categories/mod_frontpage_categories.css" type="text/css" /> <div style="width: '.$mod_width.'px;background:#FFF;">'; echo get_category_tree2( $category_id, $class_mainlevel,$num_columns,$cat_height,$image_width,$sub_categories_display); echo '</div>'; ?> mod_frontpage_categories_functions.php Код (PHP): <?php function find_cat_image($cat_id,$db_username,$db_password,$db_name) { $con = mysql_connect("localhost",$db_username,$db_password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db_name, $con); $q = 'SELECT * FROM jos_vm_category WHERE category_id='.$cat_id; $return = mysql_query( $q ); $row = mysql_fetch_array($return); $return_val = $row['category_thumb_image']; return $return_val; } /** * This function is used for the frontend to display a * complete link list of top-level categories * * @param int $category_id The category to be highlighted * @param string $links_css_class The css class that marks mainlevel links * @param string $list_css_class (deprecated) * @param string $highlighted_style The css styles that format the hightlighted category * @return string HTML code with the link list */ function get_category_tree2( $category_id=0, $links_css_class="mainlevel",$numcolumns=5, $cat_height,$image_width, $sub_categories_display=1, $list_css_class="mm123", $highlighted_style="font-style:italic;") { global $sess; $config =& JFactory::getConfig(); $db_username = $config->getValue( 'config.user' ); $db_password = $config->getValue( 'config.password' ); $db_name = $config->getValue( 'config.db' ); $categories = ps_product_category::getCategoryTreeArray(); // Get array of category objects $result = ps_product_category::sortCategoryTreeArray($categories); // Sort array of category objects $row_list = $result['row_list']; $depth_list = $result['depth_list']; $category_tmp = $result['category_tmp']; $nrows = sizeof($category_tmp); $numcolumns = 100/$numcolumns-3; $category_list = $result ['category_list']; $k = 0; $tt = 0; // Copy the Array into an Array with auto_incrementing Indexes $key = array_keys($categories); // Array of category table primary keys $nrows = $size = sizeOf($key); // Category count $html = ""; $pos_cat = $neg_cat = array() ; $cat_ids = explode("|",$category_list); if (count($cat_ids) > 0) { foreach ($cat_ids as $cat_id) { if ($cat_id < 0) $neg_cat[] = abs($cat_id); else if ($cat_id > 0) $pos_cat[] = $cat_id; } } // Find out if we have subcategories to display $allowed_subcategories = Array(); if( !empty( $categories[$category_id]["category_parent_id"] ) ) { // Find the Root Category of this category $root = $categories[$category_id]; $allowed_subcategories[] = $categories[$category_id]["category_parent_id"]; // Loop through the Tree up to the root while( !empty( $root["category_parent_id"] )) { $allowed_subcategories[] = $categories[$root["category_child_id"]]["category_child_id"]; $root = $categories[$root["category_parent_id"]]; } } // Fix the empty Array Fields if( $nrows < count( $row_list ) ) { $nrows = count( $row_list ); } // Now show the categories for($n = 0 ; $n < $nrows ; $n++) { if( !isset( $row_list[$n] ) || !isset( $category_tmp[$row_list[$n]]["category_child_id"] ) ) continue; if( $category_id == $category_tmp[$row_list[$n]]["category_child_id"] ) $style = $highlighted_style; else $style = ""; $allowed = true; if( $depth_list[$n] > 0 ) { // Subcategory! if( isset( $root ) && in_array( $category_tmp[$row_list[$n]]["category_child_id"], $allowed_subcategories ) || $category_tmp[$row_list[$n]]["category_parent_id"] == $category_id || $category_tmp[$row_list[$n]]["category_parent_id"] == @$categories[$category_id]["category_parent_id"]) { $allowed = true; } } else $allowed = true; $append = ""; if( $allowed ) { if( $style == $highlighted_style ) { $append = 'id="active_menu2"'; } if( $depth_list[$n] > 0) { $css_class = "sublevel_frontpage_categories"; $ttype = 2; } else { $css_class = $links_css_class; $css_class = 'mainlevel_frontpage_categories'; $ttype = 1; } $catname = shopMakeHtmlSafe( $category_tmp[$row_list[$n]]["category_name"] ); if ($ttype == 1) { if ($k > 0) { $html .= '</div></div><br>'.$k; } else { #$html .= '<div style="float:left;text-align: left;padding:3px;background:#000;width:'.$numcolumns.'%;margin:5px;border:100px solid #888;">testtest'; $html .= $k; } $cat_image = 'components/com_virtuemart/shop_image/category/'; $base_image = find_cat_image($category_tmp[$row_list[$n]]["category_child_id"],$db_username,$db_password,$db_name); if ($base_image != '') { $cat_image .= $base_image; list($width, $height, $ttype, $attr) = getimagesize($cat_image); $ttarget = $image_width; if ($width != '' && $height != '') { if ($width > $height) { $percentage = ($ttarget / $width); } else { $percentage = ($ttarget / $width); } //gets the new value and applies the percentage, then rounds the value $width = round($width * $percentage); $height = round($height * $percentage); } } } if ($depth_list[$n] < $sub_categories_display+1) { if ($depth_list[$n] == 0) { if ($tt == 0) { $html .= '<div class="listheading">'; $html .= '<div style="margin-right:7px; margin-top:1px; float:left; padding-left:3px;"><img src="/images/arrow.png"></div>'; $html .= '<p style="float:left; margin-top:-2px; font-size: 12px; font-weight: bold;"><a href="'. $sess->url(URL."index.php?page=shop.browse&category_id=".$category_tmp[$row_list[$n]]["category_child_id"]) .'" '.$append.'" style="color#999999 !important!">'.$catname.'</a></p></div>'; $html .= "<div><table border='0' cellpadding='0' cellspacing='0' style='float:left;width:700px'><tr ></tr></div>"; } else { $html .= '</tr></div>'; $tt = 0; $html .= '<div class="listheading">'; $html .= '<div style="margin-right:7px; margin-top:1px; float:left; padding-left:3px;"><img src="/images/arrow.png"></div>'; $html .= '<p style="float:left; margin-top:-2px; font-size: 12px; font-weight: bold;"><a href="'. $sess->url(URL."index.php?page=shop.browse&category_id=".$category_tmp[$row_list[$n]]["category_child_id"]) .'" '.$append.'" style="color#999999 !important!">'.$catname.'</a></p></div>'; $html .= "</div><div><table border='0' cellpadding='0' cellspacing='0' style='float:left;width:700px'><tr >"; } } else { $html .= "<td width='20%' align='center' valign='middle' ><div style='padding:0px 20px 0px 0px;margin:0px 10px 0px 3px; width:116px; border-right:1px dotted #dddddd; '>"; $html .= '<a class="listtext" title="'.$catname.'" href="'. $sess->url(URL."index.php?page=shop.browse&category_id=".$category_tmp[$row_list[$n]]["category_child_id"]).'">'.$catname.'</a>'; $html .= '<a title="'.$catname.'" href="'. $sess->url(URL."index.php?page=shop.browse&category_id=".$category_tmp[$row_list[$n]]["category_child_id"]).'"><img src="components/com_virtuemart/shop_image/category/'.find_cat_image($category_tmp[$row_list[$n]]["category_child_id"],$db_username,$db_password,$db_name).'" width='.$width.' height='.$height.'style="margin-top:-33px;padding:0px" title="'.$catname.'" alt="'.$catname.'" /></a>'; $html .= '<div class="listdotted">'; $html .= '<div align="center" style="padding-top:5px;"><a href="href="'. $sess->url(URL."index.php?page=shop.browse&category_id=".$category_tmp[$row_list[$n]]["category_child_id"]).'"><img src="/images/democontent/readmore.gif">'; $html .= '</a> </div></td>'; $tt = $tt + 1; } } $k = $k + 1; } } $html .= '</td></div>'; return $html; }