), пытался добавить условие "product_parent_id=0", но видимо добавляю его не туда.
P.S. добавлял его в это место
<?php
/**
* VM alpha-numeric search - version 3
* English and Russian letters now available !
*
* @copyright (C) 2010 copyrights Romik Jan
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
*
*/
//only for DEBUG !
//error_reporting(E_ALL);
// Get module options
$show_rus_letters = $params->get('show_rus_letters', '');
$show_ukr_letters = $params->get('show_ukr_letters', '');
$show_eng_letters = $params->get('show_eng_letters', '');
$show_numbers = $params->get('show_numbers', '');
$set_def_keyword = $params->get('set_def_keyword','');
$limit_enable = $params->get('limit_enable','0');
$enable_anchor = $params->get('enable_anchor', '');
$letters_color = $params->get('letters_color', '');
$letters_bg_color = $params->get('letters_bg_color', '');
$letters_font_size = $params->get('letters_font_size', '');
$letters_font_family = $params->get('letters_font_family', 'Courier New');
$letter_top_color = $params->get('letter_top_color', '');
$letter_top_bg_color = $params->get('letter_top_bg_color', '');
$letter_top_font_size = $params->get('letter_top_font_size', '');
$product_link_color = $params->get('product_link_color', '');
$product_link_bg_color = $params->get('product_link_bg_color', 'white');
$product_link_font_size = $params->get('product_link_font_size', '');
$custom_style = $params->get('custom_style', '');
?>
<style type="text/css">
#sidenav #navigation_header {
margin: 0px;
}
#sidenav #navigation {
margin-left: 4px;
background: white;
}
.linksDiv .top_letter {
<?php if($letter_top_color != null) echo " color: $letter_top_color; \n"?>
<?php if($letter_top_font_size != null) echo " font-size: ".$letter_top_font_size."; \n"?>
<?php if($letter_top_bg_color != null) echo " background-color: $letter_top_bg_color; \n"?>
font-weight: bold;
padding: 3px 0pt 3px 8px;
margin-top: 10px;
}
.eng, .rus, .ukr, .num {
padding: 0px;
margin-bottom: 5px;
}
.num {
text-align: center; }
#navigation_header .letter, #navigation_header .number {
<?php if($letters_color != null) echo " color: $letters_color; \n"?>
<?php if($letters_font_size != null) echo " font-size: ".$letters_font_size."; \n"?>
<?php echo " font-family: ".$letters_font_family."; \n"?>
<?php if($letters_bg_color != null) echo " background-color: $letters_bg_color; \n"?>
font-weight: bold;
border: 0px;
margin: 1px;
padding: 0px;
padding-left: 3px;
padding-right: 3px;
}
#navigation_header .letter:hover, #navigation_header .number:hover {
text-decoration: none;
background-color: white;
margin: 0px;
border: 1px solid <?php if($letters_color != null) echo "$letters_color; \n"; else echo "red; \n";?>
}
#navigation_header .clean {
text-decoration: none;
}
#navigation_header .active {
text-decoration: none;
margin: 0px;
border: 1px solid <?php if($letters_color != null) echo "$letters_color; \n"; else echo "red; \n";?>
}
#navigation_header .active:hover {
text-decoration: none;
background-color: transparent;
}
.product_found {
position: relative;
padding: 3px 5px 3px 8px;
/*
background: white none repeat scroll 0% 0%;
*/
<?php echo " background-color: $product_link_bg_color; \n"?>
}
.product_found a.products {
<?php if($product_link_color != null) echo " color: $product_link_color; \n"?>
<?php if($product_link_font_size != null) echo " font-size: ".$product_link_font_size."; \n"?>
}
/* Custom CSS-style for alpha-numeric search module */
<?php if($custom_style != null) echo "$custom_style\n"?>
</style>
<div id="sidenav">
<div id="navigation_header">
<!-- <div id="chooseProduct" class="smcopy" style="padding: 8px; font-weight: bold; color: rgb(103, 58, 105);"> -->
<?php
$anchor_label = 'vm_alphasearch_en_ru'; // this is anchor, where we will return, if this option is on
$num_link_label = '# (0-9)'; // this is label for link of number search
if ($limit_enable != 0) $limit_enable = " LIMIT $limit_enable";
else $limit_enable = null;
echo "<a nohref name='$anchor_label'></a>";
// We choose the default letter and don't search anything ...
if (isset($set_def_keyword) && $set_def_keyword != '0' && $_GET['keywordabc'] == null) {
// Initialize array of letters. Not beautiful, but work very good !
$alpabet_ru_en_ua = array (
// ... rus letters
"01_ru" => "А", "02_ru" => "Б", "03_ru" => "В", "04_ru" => "Г", "05_ru" => "Д", "06_ru" => "Е", "07_ru" => "Ж",
"08_ru" => "З", "09_ru" => "И", "10_ru" => "К", "11_ru" => "Л", "12_ru" => "М", "13_ru" => "Н", "14_ru" => "О",
"15_ru" => "П", "16_ru" => "Р", "17_ru" => "С", "18_ru" => "Т", "19_ru" => "У", "20_ru" => "Ф", "21_ru" => "Х",
"22_ru" => "Ц", "23_ru" => "Ч", "24_ru" => "Ш", "25_ru" => "Щ", "26_ru" => "Ъ", "27_ru" => "Ы", "28_ru" => "Ь",
"29_ru" => "Э", "30_ru" => "Ю", "31_ru" => "Я",
// ... ua letters
"01_ua" => "А", "02_ua" => "Б", "03_ua" => "В", "04_ua" => "Г", "05_ua" => "Д", "06_ua" => "Е", "07_ua" => "Є",
"08_ua" => "Ж", "09_ua" => "З", "10_ua" => "И", "11_ua" => "І", "12_ua" => "Ї", "13_ua" => "Й", "14_ua" => "К",
"15_ua" => "Л", "16_ua" => "М", "17_ua" => "Н", "18_ua" => "О", "19_ua" => "П", "20_ua" => "Р", "21_ua" => "С",
"22_ua" => "Т", "23_ua" => "У", "24_ua" => "Ф", "25_ua" => "Х", "26_ua" => "Ц", "27_ua" => "Ч", "28_ua" => "Ш",
"29_ua" => "Щ", "30_ua" => "Ю", "31_ua" => "Я",
// ... eng letters
"01_en" => "A", "02_en" => "B", "03_en" => "C", "04_en" => "D", "05_en" => "E", "06_en" => "F", "07_en" => "G",
"08_en" => "H", "09_en" => "I", "10_en" => "J", "11_en" => "K", "12_en" => "L", "13_en" => "M", "14_en" => "N",
"15_en" => "O", "16_en" => "P", "17_en" => "Q", "18_en" => "R", "19_en" => "S", "20_en" => "T", "21_en" => "U",
"22_en" => "V", "23_en" => "W", "24_en" => "X", "25_en" => "Y", "26_en" => "Z",
);
foreach ($alpabet_ru_en_ua as $letters => $values) {
if ($letters == $set_def_keyword) { $keywordabc = $alpabet_ru_en_ua[$letters]; break; }
}
}// ... or get keyword for search
else $keywordabc = $_GET['keywordabc'];
// destroy this array. I'll be missing you :'( But you don't need me any more :P
unset($alpabet_ru_en_ua);
function PrintLetters_EN_RU($alphabet, $enable_anchor, $anchor_label, $keywordabc) // BEGIN function PrintLetters_EN_RU
{
switch ($alphabet) {
case 'eng':
$first_letter = "A";
$last_letter = "Z";
break;
case 'rus':
$first_letter = "А";
$last_letter = "Я";
break;
default:
echo "I dont know what is language your using. David Blain, get out ! O_o";
break;
}
echo "<div class='$alphabet'>";
switch ($enable_anchor) {
case 1 :
$anchor_label = "#$anchor_label";
$css_style = "anchor";
break;
default:
$anchor_label = null;
$css_style = "clean";
break;
}
for($i=$first_letter;$i<=$last_letter;$i++) {
if($keywordabc == $i) echo "<a class='letter $css_style active' nohref>" . $i . "</a> ";
else echo "<a class='letter $css_style' href='index.php?category_id=" . $_GET["category_id"] . "&keywordabc=" . $i . "$anchor_label'>" . $i . "</a> ";
if($i == $last_letter) break; // print the last letter and get out of this circle
}
echo "</div>";
} // END function PrintLetters
function PrintLetters_UA($alphabet, $enable_anchor, $anchor_label, $keywordabc) // BEGIN function PrintLetters_UA
{
$alphabet_ua = array ( "А", "Б", "В", "Г", "Д",
"Е", "Є", "Ж", "З", "И",
"І", "Ї", "Й", "К", "Л",
"М", "Н", "О", "П", "Р",
"С", "Т", "У", "Ф", "Х",
"Ц", "Ч", "Ш", "Щ", "Ъ",
"Ю", "Я" );
echo "<div class='$alphabet'>";
switch ($enable_anchor) {
case 1 :
for($i=0;$i<count($alphabet_ua);$i++) {
if($keywordabc == $alphabet_ua[$i]) { echo "<a class='letter anchor active' nohref>" . $alphabet_ua[$i] . "</a> "; }
else { echo "<a class='letter anchor' href='index.php?category_id=" . $_GET["category_id"] . "&keywordabc=" . $alphabet_ua[$i] . "#$anchor_label'>" . $alphabet_ua[$i] . "</a> "; }
}
break;
default:
for($i=0;$i<count($alphabet_ua);$i++) {
if($keywordabc == $alphabet_ua[$i]) { echo "<a class='letter clean active' nohref>" . $alphabet_ua[$i] . "</a> "; }
else { echo "<a class='letter clean' href='index.php?category_id=" . $_GET["category_id"] . "&keywordabc=" . $alphabet_ua[$i] . "'>" . $alphabet_ua[$i] . "</a> "; }
}
break;
}
echo "</div>";
} // END function PrintLetters_UA
function PrintNumbers($enable_anchor, $anchor_label, $num_link_label, $keywordabc)
{
echo "<div class='num'>";
switch ($enable_anchor) {
case 1 :
if($keywordabc == "1") { echo "<a class='number anchor active' href='index.php?category_id=" . $_GET["category_id"] . "&keywordabc=1#$anchor_label'>$num_link_label</a>"; }
else { echo "<a class='number anchor' href='index.php?category_id=" . $_GET["category_id"] . "&keywordabc=1#$anchor_label'>$num_link_label</a>"; }
break;
default:
if($keywordabc == "1") { echo "<a class='number clean active' nohref>$num_link_label</a>"; }
else { echo "<a class='number clean' href='index.php?category_id=" . $_GET["category_id"] . "&keywordabc=1'>$num_link_label</a>"; }
break;
}
echo "</div>";
}
// Change the order of lines, if you want print a numbers at first ...
if ($show_rus_letters == 1) PrintLetters_EN_RU("rus", $enable_anchor, $anchor_label, $keywordabc);
if ($show_ukr_letters == 1) PrintLetters_UA("ukr", $enable_anchor, $anchor_label, $keywordabc);
if ($show_eng_letters == 1) PrintLetters_EN_RU("eng", $enable_anchor, $anchor_label, $keywordabc);
if ($show_numbers == 1) PrintNumbers($enable_anchor, $anchor_label, $num_link_label, $keywordabc);
$db =& JFactory::getDBO();
if ($keywordabc != "") {
if($keywordabc != "1") { // search a product, started on a LETTER
if($_GET["category_id"] != "") { // we are in catalog of VM, in category now
$query = "SELECT a.* "
. " FROM #__vm_product a, #__vm_product_category_xref c"
. " WHERE a.product_id=c.product_id"
. " AND c.category_id='" . $_GET["category_id"] . "'"
. " AND a.product_name LIKE '" . $keywordabc . "%' "
. $limit_enable;
} else {
$query = "SELECT * "
. " FROM #__vm_product "
. " WHERE product_name LIKE '" . $keywordabc . "%' "
. $limit_enable;
}
}
else { // search a product, started on a NUMBER
if($_GET["category_id"] != "") { // we are in catalog of VM, in category now
$query = "SELECT a.* "
. " FROM #__vm_product a, #__vm_product_category_xref c"
. " WHERE a.product_id=c.product_id"
. " AND c.category_id='" . $_GET["category_id"] . "'"
. " AND a.product_name REGEXP '[[:digit:]]'"
. " AND ( a.product_name LIKE '6%'"
. " OR a.product_name LIKE '7%'"
. " OR a.product_name LIKE '8%'"
. " OR a.product_name LIKE '9%'"
. " OR a.product_name LIKE '0%'"
. " OR a.product_name LIKE '1%'"
. " OR a.product_name LIKE '2%'"
. " OR a.product_name LIKE '3%'"
. " OR a.product_name LIKE '4%'"
. " OR a.product_name LIKE '5%' )"
. $limit_enable;
} else {
$query = "SELECT a.* "
. " FROM #__vm_product a "
. " WHERE a.product_name REGEXP '[[:digit:]]'"
. " AND ( a.product_name LIKE '6%'"
. " OR a.product_name LIKE '7%'"
. " OR a.product_name LIKE '8%'"
. " OR a.product_name LIKE '9%'"
. " OR a.product_name LIKE '0%'"
. " OR a.product_name LIKE '1%'"
. " OR a.product_name LIKE '2%'"
. " OR a.product_name LIKE '3%'"
. " OR a.product_name LIKE '4%'"
. " OR a.product_name LIKE '5%' )"
. $limit_enable;
}
}
}
else $hide_this=' style="display: none;"';
$db->setQuery( $query );
$product = $db->loadObjectList();
?>
</div>
</div>
<div id="navigation">
<div id="A" class="linksDiv"<?php echo $hide_this; ?>>
<div class="top_letter"><?php if ($keywordabc != "1") echo $keywordabc; else echo $num_link_label;?></div>
<?php if ($product) foreach ($product as $row){?>
<div class="product_found"><a class="products" href="index.php?page=shop.product_details&product_id=<?php echo $row->product_id?>&option=com_virtuemart&Itemid=71&keywordabc=<?php echo $keywordabc?>" target="_top"><?php echo $row->product_name?> </a></div>
<?php }?>
</div>
</div>