Move categories list to top menu
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Move categories list to top menu
Hi everybody) I have a top menu on the shop, and I want to add category dropdown to top menu. The main question here is I need to get categories on all pages. What should I extend and where (on which file/controller) I have to get categories to pass them to view that show them on top menu ?
Also the problem is that files app.blade.php and aimeos-nav.blade.php are blade views. If I create decorator or something and pass new values to view - sees I can't use it in blade..(( Here I am confused..
For example I created decorator:
But how can I use it in blade templates ?
Thank you all!
Also the problem is that files app.blade.php and aimeos-nav.blade.php are blade views. If I create decorator or something and pass new values to view - sees I can't use it in blade..(( Here I am confused..
For example I created decorator:
Code: Select all
<?php
namespace Aimeos\Client\Html\Common\Decorator;
class Mydecorator extends Base
{
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
{
$view = parent::addData( $view, $tags, $expire );
// access already added data
// $products = $view->get( 'listsItems', [] );
// fetch some items from the database
$view->var = 'data';
return $view;
}
}
Thank you all!
Re: Move categories list to top menu
You can use the catalog frontend controller in your Laravel controller action to retrieve the category tree and assign it to the Blade template:
Laravel doesn't support decorators in that context.
Code: Select all
$tree = \Aimeos\Controller\Frontend::create( $context, 'catalog' )->getTree();
return Response::view( 'shop::catalog.list', $params + ['categories' => $tree] );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Move categories list to top menu
Great thank you!! I was hanging at this point and didn't have ideas)
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Move categories list to top menu
How to get context in Laravel controller ?
Re: Move categories list to top menu
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Move categories list to top menu
Yes it works, I have displayed the categories at the top menu. But problem is how to generate correct url for categories ? I am in blade view, here the aimeos functions are not accessable ((
Re: Move categories list to top menu
The Aimeos url() method only uses the Laravel route() method internally:
https://laravel.com/docs/6.0/urls#urls-for-named-routes
https://laravel.com/docs/6.0/urls#urls-for-named-routes
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Move categories list to top menu
Where can I take a look at Aimeos url function ? I am confused because url function has less params that route function.
Code: Select all
$this->url( ( $item->getTarget() ?: $target ), $controller, $action, $params, [], $config )
Code: Select all
route('post.show', ['post' => 1]);
Re: Move categories list to top menu
It boils down to this:
https://github.com/aimeos/ai-laravel/bl ... l5.php#L61
Code: Select all
route('aimeos_shop_list', ['f_catid' => 1])
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Move categories list to top menu
Yes it works, but then url looks ugly /?f_catid=2. Can I customize this route. For example make it shop/category/{id}