Jump to content

Раскрывающееся боковое меню с подкатегориями (Решено)


Recommended Posts

Раскрывающиеся меню с подкатегориями
В файле index.tpl необходимо заменить:
{fun name=categories_tree categories=$c->subcategories}

на:
{if in_array($category->category_id, $c->subcats_ids)}
{fun name=categories_tree categories=$c->subcategories}
{/if}

Link to post
Share on other sites
  • 4 weeks later...

Если в файле index.tpl написано только это:

<div class="block"><div class="block_top"><div class="block_bottom">
{include file=categories.tpl categories=$categories level=0}
</div></div></div>


А в файле categories.tpl написано это:

{if $categories}
<ul class="catalog_menu">
{foreach item=c from=$categories}
{if $category->category_id != $c->category_id}
<li tooltip='category' category_id='{$c->category_id}'><a href='catalog/{$c->url}'>{$c->name}</a></li>
{else}
<li tooltip='category' category_id='{$c->category_id}'>{$c->name}</li>
{/if}
{include file=categories.tpl categories=$c->subcategories}
{/foreach}
</ul>
{/if}

Link to post
Share on other sites
  • 1 month later...

У нас на сайте субкатегория почему-то после первого клика сразу же сворачивается сразу. Подскажите пожалуйста как можно эту бодягу излечить.Код у нас такой:
<a href='catalog/<?php echo $smarty->_tpl_vars['c']->url; ?>
' tooltip='category' category_id='<?php echo $smarty->_tpl_vars['c']->category_id; ?>
' <?php if ($smarty->_tpl_vars['category']->category_id == $smarty->_tpl_vars['c']->category_id): ?>class="active"<?php endif; ?>><?php echo $smarty->_tpl_vars['c']->name; ?>
</a>
<?php if ($smarty->_tpl_vars['category']->category_id == $smarty->_tpl_vars['c']->category_id): ?><?php smarty_fun_categories_tree($smarty, array('categories'=>$smarty->_tpl_vars['c']->subcategories)); ?><?php endif; ?>
</li>
<?php endforeach; endif; unset($_from); ?>
</ul>
<?php endif; ?>
<?php $smarty->_tpl_vars=$_fun_tpl_vars; }} smarty_fun_categories_tree($this, array('categories'=>$this->_tpl_vars['categories'])); ?>
</div>

У кого есть идеи? В каком направлении копать?

Link to post
Share on other sites
  • 1 year later...
  • 6 months later...

Сделал как был написано в последнем примере, все работает.
Вопрос, как сделать чтобы при нажатии раскрывались (изначально скрыты не активные) только под категории 3 и последующих уровней?

Link to post
Share on other sites
  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...