Display list of categories ?
Posted: 19 Jul 2017, 12:12
I had created a html template and now i am going to convert it in laravel with your package .
I want to display a list of categories in menu but when add below code to display categories in app.blade.php it shows an error that
(4/4) ErrorException
Undefined variable: enc (View: D:\xampp\htdocs\myproject\resources\views\app.blade.php) (View: D:\xampp\htdocs\myproject\resources\views\app.blade.php) (View: D:\xampp\htdocs\myproject\resources\views\app.blade.php)
<ul class="level-<?= $enc->attr( $level ); ?>">
<?php foreach( $this->get( 'nodes', [] ) as $item ) : ?>
<?php if( $item->getStatus() > 0 ) : ?>
<?php $id = $item->getId(); $config = $item->getConfig(); ?>
<?php $params['f_name'] = $item->getName( 'url' ); $params['f_catid'] = $id; ?>
<?php $class = ( $item->hasChildren() ? ' withchild' : ' nochild' ) . ( isset( $path[$id] ) ? ' active' : '' ); ?>
<?php $class .= ' catcode-' . $item->getCode() . ( isset( $config['css-class'] ) ? ' ' . $config['css-class'] : '' ); ?>
<li class="cat-item catid-<?= $enc->attr( $id . $class ); ?>" data-id="<?= $id; ?>" >
<a class="cat-item" href="<?= $enc->attr( $this->url( ( $item->getTarget() ?: $target ), $controller, $action, $params, [], $config ) ); ?>"><!--
--><div class="media-list"><!--
<?php foreach( $item->getListItems( 'media', 'icon' ) as $listItem ) : ?>
<?php if( ( $mediaItem = $listItem->getRefItem() ) !== null ) : ?>
<?= '-->' . $this->partial(
$this->config( 'client/html/common/partials/media', 'common/partials/media-default.php' ),
array( 'item' => $mediaItem, 'boxAttributes' => array( 'class' => 'media-item' ) )
) . '<!--'; ?>
<?php endif; ?>
<?php endforeach; ?>
--></div><!--
--><span class="cat-name"><?= $enc->html( $item->getName(), $enc::TRUST ); ?></span><!--
--></a>
<?php if( count( $item->getChildren() ) > 0 ) : ?>
<?php $values = array( 'nodes' => $item->getChildren(), 'path' => $path, 'params' => $params, 'level' => $level + 1 ); ?>
<?= $this->partial( $this->config( 'client/html/catalog/filter/partials/tree', 'catalog/filter/tree-default.php' ), $values ); ?>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
In short i want to display categories , products in with my own design template.
I want to display a list of categories in menu but when add below code to display categories in app.blade.php it shows an error that
(4/4) ErrorException
Undefined variable: enc (View: D:\xampp\htdocs\myproject\resources\views\app.blade.php) (View: D:\xampp\htdocs\myproject\resources\views\app.blade.php) (View: D:\xampp\htdocs\myproject\resources\views\app.blade.php)
<ul class="level-<?= $enc->attr( $level ); ?>">
<?php foreach( $this->get( 'nodes', [] ) as $item ) : ?>
<?php if( $item->getStatus() > 0 ) : ?>
<?php $id = $item->getId(); $config = $item->getConfig(); ?>
<?php $params['f_name'] = $item->getName( 'url' ); $params['f_catid'] = $id; ?>
<?php $class = ( $item->hasChildren() ? ' withchild' : ' nochild' ) . ( isset( $path[$id] ) ? ' active' : '' ); ?>
<?php $class .= ' catcode-' . $item->getCode() . ( isset( $config['css-class'] ) ? ' ' . $config['css-class'] : '' ); ?>
<li class="cat-item catid-<?= $enc->attr( $id . $class ); ?>" data-id="<?= $id; ?>" >
<a class="cat-item" href="<?= $enc->attr( $this->url( ( $item->getTarget() ?: $target ), $controller, $action, $params, [], $config ) ); ?>"><!--
--><div class="media-list"><!--
<?php foreach( $item->getListItems( 'media', 'icon' ) as $listItem ) : ?>
<?php if( ( $mediaItem = $listItem->getRefItem() ) !== null ) : ?>
<?= '-->' . $this->partial(
$this->config( 'client/html/common/partials/media', 'common/partials/media-default.php' ),
array( 'item' => $mediaItem, 'boxAttributes' => array( 'class' => 'media-item' ) )
) . '<!--'; ?>
<?php endif; ?>
<?php endforeach; ?>
--></div><!--
--><span class="cat-name"><?= $enc->html( $item->getName(), $enc::TRUST ); ?></span><!--
--></a>
<?php if( count( $item->getChildren() ) > 0 ) : ?>
<?php $values = array( 'nodes' => $item->getChildren(), 'path' => $path, 'params' => $params, 'level' => $level + 1 ); ?>
<?= $this->partial( $this->config( 'client/html/catalog/filter/partials/tree', 'catalog/filter/tree-default.php' ), $values ); ?>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
In short i want to display categories , products in with my own design template.