How to show single level of subcategories with images on home page?
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
How to show single level of subcategories with images on home page?
This is my first Aimeos project. Currently I have the catalog filter tree residing in a menu that slides out from the left side when a menu icon is clicked. This is working fine.
However, on the home page I wish to show only the first level of sub-categories along with their category images and descriptions.
My catalog tree is
HOME
>Bakery
> >Breads
> >Cakes
>Meals
> >Single Serve
> >Family Size
So on the home (HOME Level) page I wish to display just the Bakery and Meals categories (not the products) with their category images and descriptions.(without altering the catalog filter in the slideout menu)
How would I achieve that?
I tried using <?= $aibody['catalog/filter'] ?> but this just duplicated my slideout menu.
from my composer.json:
"require": {
"php": "^7.2",
"aimeos/ai-payments": "^2019.10",
"aimeos/aimeos-laravel": "~2019.10",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.0",
"laravel/tinker": "^1.0",
"laravel/ui": "^1.0",
"league/omnipay": "^3.0",
"omnipay/stripe": "^3.1",
"guzzlehttp/guzzle":">=6.3.0 <6.5.0 || ^6.5.1"
},
However, on the home page I wish to show only the first level of sub-categories along with their category images and descriptions.
My catalog tree is
HOME
>Bakery
> >Breads
> >Cakes
>Meals
> >Single Serve
> >Family Size
So on the home (HOME Level) page I wish to display just the Bakery and Meals categories (not the products) with their category images and descriptions.(without altering the catalog filter in the slideout menu)
How would I achieve that?
I tried using <?= $aibody['catalog/filter'] ?> but this just duplicated my slideout menu.
from my composer.json:
"require": {
"php": "^7.2",
"aimeos/ai-payments": "^2019.10",
"aimeos/aimeos-laravel": "~2019.10",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.0",
"laravel/tinker": "^1.0",
"laravel/ui": "^1.0",
"league/omnipay": "^3.0",
"omnipay/stripe": "^3.1",
"guzzlehttp/guzzle":">=6.3.0 <6.5.0 || ^6.5.1"
},
Re: How to show single level of subcategories with images on home page?
In your home controller, you can use the Catalog facade to retrieve the data:
Code: Select all
$categories = \Aimeos\Shop\Facades\Catalog::uses(['text', 'media'])
->getTree(\Aimeos\MW\Tree\Manager\Base::LEVEL_LIST);
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
Re: How to show single level of subcategories with images on home page?
This doesn't appear to work but perhaps I've implemented it incorrectly?
I've copied the shop\app\Http\Controllers\HomeController up into my active extension directory
ext\myshop\controller\frontend\HomeController.php
In the index method I now have
public function index()
{
$categories = \Aimeos\Shop\Facades\Catalog::uses(['text', 'media'])
->getTree(\Aimeos\MW\Tree\Manager\Base::LEVEL_LIST);
return view('home')->with('categories', $categories);
}
-----------------------
If I dump the categories in the controller it doesn't interrupt the application indicating that this HomeController is not active in http://localhost:8000/shop
(I have cleared the cache)
I've copied the shop\app\Http\Controllers\HomeController up into my active extension directory
ext\myshop\controller\frontend\HomeController.php
In the index method I now have
public function index()
{
$categories = \Aimeos\Shop\Facades\Catalog::uses(['text', 'media'])
->getTree(\Aimeos\MW\Tree\Manager\Base::LEVEL_LIST);
return view('home')->with('categories', $categories);
}
-----------------------
If I dump the categories in the controller it doesn't interrupt the application indicating that this HomeController is not active in http://localhost:8000/shop
(I have cleared the cache)
Re: How to show single level of subcategories with images on home page?
You can't overwrite the Laravel shop\app\Http\Controllers\HomeController.php controller. Instead, you have to add your code in that class directly.
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
Re: How to show single level of subcategories with images on home page?
Sou iniciante no Aimeos, por favor onde fica este controlador?aimeos wrote: ↑27 Mar 2020, 17:07 In your home controller, you can use the Catalog facade to retrieve the data:Code: Select all
$categories = \Aimeos\Shop\Facades\Catalog::uses(['text', 'media']) ->getTree(\Aimeos\MW\Tree\Manager\Base::LEVEL_LIST);