Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 9 Ответов
  • 2090 Просмотров
*

Webych

  • Новичок
  • 7
  • 0 / 0
Вопрос пустячный, и дело стоит только за знанием PHP.
Прогеры, помогите, пожалуйста.

Вывожу список категорий модулем mod_product_categories.
Нужно сделать так, чтобы вместе со ссылками на категории выводились маленькие картинки.

Вот код, который нужно править (в файле ps_product_categiry.php, строка 640)
Код
	function get_category_tree( $category_id=0,
$links_css_class="mainlevel",
$list_css_class="mm123",
$highlighted_style="font-style:italic;" ) {
global $sess;

$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);

// 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 = "";

// 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 = false;
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_menu"';
}
if( $depth_list[$n] > 0 ) {
$css_class = "sublevel";
}
else {
$css_class = $links_css_class;
}

$catname = shopMakeHtmlSafe( $category_tmp[$row_list[$n]]["category_name"] );

$html .= '
          <a title="'.$catname.'" style="display:block;'.$style.'" class="'. $css_class .'" href="'. $sess->url(URL."index.php?page=shop.browse&amp;category_id=".$category_tmp[$row_list[$n]]["category_child_id"]) .'" '.$append.'>'
. str_repeat("&nbsp;&nbsp;&nbsp;",$depth_list[$n]) . $catname
. ps_product_category::products_in_category( $category_tmp[$row_list[$n]]["category_child_id"] )
.'</a>';
}
}

return $html;
}

В этой теме уже решался вопрос о том, как выводить краткое описание, но затрагивался другой участок кода (но принцип, наверное, аналогичный):
http://joomlaforum.ru/index.php/topic,8713.0.html
« Последнее редактирование: 10.07.2009, 19:19:53 от Webych »
*

beagler

  • Moderator
  • 3276
  • 392 / 4
  • https://alorisman.ru/
ну, вообще-то ноги немного в другом месте растут.
нужно в функцию function getCategoryTreeArray() в запрос добавить category_thumb_image
дальше в массив добавить $categories[$db->f("cid")]["category_thumb_image"] = $db->f("category_thumb_image");
и уже потом в Вашей функции использовать его как хочется - $category_tmp[$row_list[$n]]["category_thumb_image"]
Вот и всё.
*

Webych

  • Новичок
  • 7
  • 0 / 0
Спасибо огромное! Сейчас попробуем...
*

Webych

  • Новичок
  • 7
  • 0 / 0
А как в запрос добавить функцию, подскажите к чему приравнивать то плз?
*

Webych

  • Новичок
  • 7
  • 0 / 0
Как это сделать? подскажи плз, а то я в PHP отнють не силён...
*

beagler

  • Moderator
  • 3276
  • 392 / 4
  • https://alorisman.ru/
Код
function getCategoryTreeArray( $only_published=true, $keyword = "" ) {

$db = new ps_DB;
if( empty( $GLOBALS['category_info']['category_tree'])) {

// Get only published categories
$query  = "SELECT category_id, category_description, category_name, category_thumb_image, category_child_id as cid, category_parent_id as pid,list_order, category_publish
FROM #__{vm}_category, #__{vm}_category_xref WHERE ";
if( $only_published ) {
$query .= "#__{vm}_category.category_publish='Y' AND ";
}
$query .= "#__{vm}_category.category_id=#__{vm}_category_xref.category_child_id ";
if( !empty( $keyword )) {
$query .= "AND ( category_name LIKE '%$keyword%' ";
$query .= "OR category_description LIKE '%$keyword%' ";
$query .= ") ";
}
$query .= "ORDER BY #__{vm}_category.list_order ASC, #__{vm}_category.category_name ASC";

// initialise the query in the $database connector
// this translates the '#__' prefix into the real database prefix
$db->query( $query );

$categories = Array();
// Transfer the Result into a searchable Array

while( $db->next_record() ) {
$categories[$db->f("cid")]["category_child_id"] = $db->f("cid");
$categories[$db->f("cid")]["category_parent_id"] = $db->f("pid");
$categories[$db->f("cid")]["category_name"] = $db->f("category_name");
                                             $categories[$db->f("cid")]["category_thumb_image"] = $db->f("category_thumb_image");
$categories[$db->f("cid")]["category_description"] = $db->f("category_description");
$categories[$db->f("cid")]["list_order"] = $db->f("list_order");
$categories[$db->f("cid")]["category_publish"] = $db->f("category_publish");
}

$GLOBALS['category_info']['category_tree'] = $categories;
return $GLOBALS['category_info']['category_tree'];
}
else {
return $GLOBALS['category_info']['category_tree'];
}
}
Код
function get_category_tree( $category_id=0,
$links_css_class="mainlevel",
$list_css_class="mm123",
$highlighted_style="font-style:italic;" ) {
global $sess;

$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);

// 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 = "";

// 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 = false;
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_menu"';
}
if( $depth_list[$n] > 0 ) {
$css_class = "sublevel";
}
else {
$css_class = $links_css_class;
}

$catname = shopMakeHtmlSafe( $category_tmp[$row_list[$n]]["category_name"] );

$html .= '
          <a title="'.$catname.'" style="display:block;'.$style.'" class="'. $css_class .'" href="'. $sess->url(URL."index.php?page=shop.browse&amp;category_id=".$category_tmp[$row_list[$n]]["category_child_id"]) .'" '.$append.'>'
. str_repeat("&nbsp;&nbsp;&nbsp;",$depth_list[$n]) . '<IMG src="'.$category_tmp[$row_list[$n]]["category_thumb_image"].'">'.$catname
. ps_product_category::products_in_category( $category_tmp[$row_list[$n]]["category_child_id"] )
.'</a>';
}
}

return $html;
}
*

Webych

  • Новичок
  • 7
  • 0 / 0
О, спасибо! А то я второй день мучаюсь с этими изображениями...

P.S. тока там должно быть не
Код
<IMG src="'.$category_tmp[$row_list[$n]]["category_thumb_image"].'">
а
Код
<IMG src="'.URL.'components/com_VirtueMart/shop_image/category/'.$category_tmp[$row_list[$n]]["category_thumb_image"].'">
« Последнее редактирование: 11.07.2009, 00:26:39 от Webych »
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Альтернативный модуль вывода категорий товаров (mod_kdz_vm_categories)

Автор kordima

Ответов: 89
Просмотров: 29264
Последний ответ 19.02.2015, 22:02:14
от kordima
Вывод модуля везде, кроме определенных категорий

Автор katjuha6

Ответов: 18
Просмотров: 4299
Последний ответ 13.01.2014, 15:24:40
от Fedor Vlasenko
Карусель категорий на Jquery! Сделал модуль, помогите собрать!

Автор Stems

Ответов: 2
Просмотров: 3763
Последний ответ 24.12.2013, 16:42:28
от KARATIST
VM 1.3 количество категорий на странице?

Автор Myst

Ответов: 24
Просмотров: 15130
Последний ответ 19.12.2013, 13:35:32
от itazura
Вопрос по оформлению товара в категориях

Автор smesharic

Ответов: 15
Просмотров: 1988
Последний ответ 15.05.2013, 13:15:51
от robert