Прошу помощи с php
Буду еще сотрудничать с Иваном.
Спасибо за работу.
Здравтсвуйте.
Сайт на Joomla 2.5 + JoomShopping 3.15
На странице выводятся категории.
Среди этих категорий есть одна , которая не должна быть показана. Отключать ее нельзя.
Если ставлю условие на данную категорию, то вывод сбивается, получчается в ряду просто пропуск.
Вот кусок кода:
<div class="jshop_list_category">
<?php
if (count($this->categories)){?>
<table class = "jshop">
<?php foreach($this->categories as $k=>$category){?>
<?php if ($k%$this->count_category_to_row==0) print "<tr>"; ?>
<td class="jshop_categ" width="<?php print (100/$this->count_category_to_row)?>%">
<a class="img" href="<?php print $category->category_link;?>"><img src="<?php print $this->image_category_path;?>/<?php if ($category->category_image) print $category->category_image; else print $this->noimage;?>" alt="<?php print htmlspecialchars($category->name);?>" title="<?php print htmlspecialchars($category->name);?>" /></a>
<a class="product_link" href="<?php print $category->category_link?>"><?php print $category->name?></a>
</td>
<?php if ($k%$this->count_category_to_row==$this->count_category_to_row-1) print '</tr>'; ?>
<?php } ?>
<?php if ($k%$this->count_category_to_row!=$this->count_category_to_row-1) print '</tr>'; ?>
</table>
<?php } ?>
</div>Спасибо за внимание.
Бюджет: 50 UAH Срок: 1 день
Обращайтесь, сделаю.
Бюджет: 20 USD Срок: 1 день
Здравствуйте, быстро и качественно выполню ваш заказ, мой email : [email protected]
Бюджет: 990 UAH Срок: 1 день
Ну у вас массив категорий. Сделайте var_dump массива, посмотрите какой ключ в необходимой категории и сделайте unset
Бюджет: 50 USD Срок: 1 день
Сделаю быстро!
C ув. Вадим. Опыт web-разработки - более 7 лет.
skype: lovesexguns
после
foreach($this->categories as $k=>$category)
попробуйте поставить что-то типа
if ($category->id != укажите id нужной категории ) {
...остальной код
}
if ($category->category_id != 188 ) {
...остальной код
}Так я делал, категория скрывается, но ломается структура
Через unset попробуйте. Если не выйдет, то в скайп стучите alexxxx12345g5 , просто так помогу.
По ключу не вариант, если категорию снять с публикации ключи сместятся и все слетит
На крайняк можно переверстать
не делать через table, а например блочную верстку сделать
Снимать с публикации не желательно. Эта категория содержит один товар.
Через unset - как?
<?php $var = ['bar','foo']; print_r($var); unset($var[1]); print_r($var);
Больше кода можно? Как вариант то можно было бы запрос к БД отредачить..
<div class="jshop_list_category">
<?php
if (count($this->categories)){?>
<table class = "jshop">
<?php foreach($this->categories as $k=>$category){?>
<?php /* if ($category->category_id != 188 ) { */?>
<?php if ($k%$this->count_category_to_row==0) print "<tr>"; ?>
<td class="jshop_categ" width="<?php print (100/$this->count_category_to_row)?>%">
<a class="img" href="<?php print $category->category_link;?>"><img src="<?php print $this->image_category_path;?>/<?php if ($category->category_image) print $category->category_image; else print $this->noimage;?>" alt="<?php print htmlspecialchars($category->name);?>" title="<?php print htmlspecialchars($category->name);?>" /></a>
<a class="product_link" href="<?php print $category->category_link?>"><?php print $category->name?></a>
</td>
<?php if ($k%$this->count_category_to_row==$this->count_category_to_row-1) print '</tr>'; ?>
<?php } ?>
<?php/* } */ ?>
<?php if ($k%$this->count_category_to_row!=$this->count_category_to_row-1) print '</tr>'; ?>
</table>
<?php } ?>
</div>
условие
[php]
<?php /* if ($category->category_id != 188 ) { */?>
[/php]
закройте после
[php]
<?php if ($k%$this->count_category_to_row!=$this->count_category_to_row-1) print '</tr>'; ?>
[/php]а не перед
Здраствуйте!
Возможно попробуйте так?
<div class="jshop_list_category">
<?php
if (count($this->categories)){?>
<table class = "jshop">
<?php foreach($this->categories as $k=>$category){?>
<?php if ($category->category_id == 188 ) { continue; }/?>
<?php if ($k%$this->count_category_to_row==0) print "<tr>"; ?>
<td class="jshop_categ" width="<?php print (100/$this->count_category_to_row)?>%">
<a class="img" href="<?php print $category->category_link;?>"><img src="<?php print $this->image_category_path;?>/<?php if ($category->category_image) print $category->category_image; else print $this->noimage;?>" alt="<?php print htmlspecialchars($category->name);?>" title="<?php print htmlspecialchars($category->name);?>" /></a>
<a class="product_link" href="<?php print $category->category_link?>"><?php print $category->name?></a>
</td>
<?php if ($k%$this->count_category_to_row==$this->count_category_to_row-1) print '</tr>'; ?>
<?php } ?>
<?php if ($k%$this->count_category_to_row!=$this->count_category_to_row-1) print '</tr>'; ?>
</table>
<?php } ?>
</div>
а вывод в 3 колонки можно попробовать сделать так заменить
<?php if ($k%$this->count_category_to_row==0) print "<tr>"; ?>
на
<?php if ($k % 3 == 0) print "<tr>"; ?>
Правда закладываться на идентификатор категории не рекомендую, так как это явный костыль )), как вариант в категории добавить класс, либо какое то описание и по нему уже ориентироваться.
может так -
<div class="jshop_list_category">
<?php
if (count($this->categories)){?>
<table class = "jshop">
<?php foreach($this->categories as $k=>$category){?>
<?php if ($category->category_id != 188 ) continue; ?>
<?php if ($k%$this->count_category_to_row==0) print "<tr>"; ?>
<td class="jshop_categ" width="<?php print (100/$this->count_category_to_row)?>%">
<a class="img" href="<?php print $category->category_link;?>"><img src="<?php print $this->image_category_path;?>/<?php if ($category->category_image) print $category->category_image; else print $this->noimage;?>" alt="<?php print htmlspecialchars($category->name);?>" title="<?php print htmlspecialchars($category->name);?>" /></a>
<a class="product_link" href="<?php print $category->category_link?>"><?php print $category->name?></a>
</td>
<?php if ($k%$this->count_category_to_row==$this->count_category_to_row-1) print '</tr>'; ?>
<?php } ?>
<?php if ($k%$this->count_category_to_row!=$this->count_category_to_row-1) print '</tr>'; ?>
</table>
<?php } ?>
</div>
Дмитрий и Генадий, варианты не подошли.
Все так же товар только скрывается.
Как написать условия, что мол выводим все категории кроме "id188" ? Надо , наверное, где-то в helpere писать..
нет. не в контроллере, можно и в шаблоне.
Почему вы не хотите доверить дело специалисту и оплатить за его знания и труд ?
Тут фриланс, а не форум для обсуждения проблем на сайте.
У Вас вывод колонок формируется
в этой строке
<?php if ($k%$this->count_category_to_row==0) print "<tr>"; ?>
а вот таким образом вы можете управлять количеством колонок
<?php if ($k % 3 == 0) print "<tr>"; ?>
ну и ниже также нужно исправить, или найти где происходит инициализация переменной $this->count_category_to_row и исправить ее
CMS 31 ставка 2 августа
Создание сайта под ключ 58 ставок 30 июля
Десктопные приложения 66 ставок 28 июля
28 ставок 28 июля
10 ставок 26 июля