Extending Aimeos Controller
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!
-
- Posts: 26
- Joined: 22 Jun 2015, 09:12
Extending Aimeos Controller
Hello again!
I'm trying to extend the CatalogController to change the listAction so I can add a bit of my own code.
The core problem lies in the fact that Aimeos uses the same view for /list and /list?catalogname=123. This means I don't have a difference in my homepage and an overview page of the products in a specific catalog.
I created a new controller, extended Catalogcontroller and wrote my own listAction function, only problem is that the routes are ofcourse, pointing to the original CatalogController, I'm not sure how to fix this so it uses my catalogController?
Thanks again!
I'm trying to extend the CatalogController to change the listAction so I can add a bit of my own code.
The core problem lies in the fact that Aimeos uses the same view for /list and /list?catalogname=123. This means I don't have a difference in my homepage and an overview page of the products in a specific catalog.
I created a new controller, extended Catalogcontroller and wrote my own listAction function, only problem is that the routes are ofcourse, pointing to the original CatalogController, I'm not sure how to fix this so it uses my catalogController?
Thanks again!
Re: Extending Aimeos Controller
What exactly do you want to achieve? Maybe there's a simpler method to get what you want if you can tell me what your two pages should contain.Bananamoon wrote: I'm trying to extend the CatalogController to change the listAction so I can add a bit of my own code.
The core problem lies in the fact that Aimeos uses the same view for /list and /list?catalogname=123. This means I don't have a difference in my homepage and an overview page of the products in a specific catalog.
-
- Posts: 26
- Joined: 22 Jun 2015, 09:12
Re: Extending Aimeos Controller
the list page (homepage) should contain a slider, which should not be shown on the overview.aimeos wrote:What exactly do you want to achieve? Maybe there's a simpler method to get what you want if you can tell me what your two pages should contain.Bananamoon wrote: I'm trying to extend the CatalogController to change the listAction so I can add a bit of my own code.
The core problem lies in the fact that Aimeos uses the same view for /list and /list?catalogname=123. This means I don't have a difference in my homepage and an overview page of the products in a specific catalog.
The overview on the other hand should have the filter showing.
In total, there's a whole different setup for both views.
Re: Extending Aimeos Controller
OK, I would do it the same wayBananamoon wrote: the list page (homepage) should contain a slider, which should not be shown on the overview.
The overview on the other hand should have the filter showing.
In total, there's a whole different setup for both views.
To use another route, for your homepage, you have to change the configuration in your action:
Code: Select all
class HomepageController extends Controller
{
public function listAction()
{
$context = app( 'Aimeos\Shop\Base\Context' )->get();
$context->getConfig()->set( 'client/html/catalog/list/url/target', 'myproject_homepage' );
// get and assign catalog list component to your view
}
}
Code: Select all
Route::match( array( 'GET', 'POST' ), '/', array(
'as' => 'myproject_homepage,
'uses' => 'HomepageController@listAction'
));
-
- Posts: 26
- Joined: 22 Jun 2015, 09:12
Re: Extending Aimeos Controller
Just to make sure I understand it all, in the code you wrote above, I am redefining my '/list' route, right? So for the overview page I can just use the default /list for these kind of urls: list?f_name=cat-1&f_catid=4451?aimeos wrote:OK, I would do it the same wayBananamoon wrote: the list page (homepage) should contain a slider, which should not be shown on the overview.
The overview on the other hand should have the filter showing.
In total, there's a whole different setup for both views.
To use another route, for your homepage, you have to change the configuration in your action:Afterwards, you need to define a new route:Code: Select all
class HomepageController extends Controller { public function listAction() { $context = app( 'Aimeos\Shop\Base\Context' )->get(); $context->getConfig()->set( 'client/html/catalog/list/url/target', 'myproject_homepage' ); // get and assign catalog list component to your view } }
There's one thing to note: We need to merge a change made yesterday to the stable branch. Otherwise, the changed configuration will be stored if you use APCu and this would result in a flaky routeCode: Select all
Route::match( array( 'GET', 'POST' ), '/', array( 'as' => 'myproject_homepage, 'uses' => 'HomepageController@listAction' ));
about the merge, I can just update through composer and all is fine? or not?
Thanks for your help!
Re: Extending Aimeos Controller
Not exactly a redefinition but you create a new route (myproject_homepage) instead. The "/list" route will continue to work as expected, you only change the used route name in the catalog list component for the homepage.Bananamoon wrote: Just to make sure I understand it all, in the code you wrote above, I am redefining my '/list' route, right? So for the overview page I can just use the default /list for these kind of urls: list?f_name=cat-1&f_catid=4451?
Yes, that will be the caseBananamoon wrote: about the merge, I can just update through composer and all is fine? or not?
-
- Posts: 26
- Joined: 22 Jun 2015, 09:12
Re: Extending Aimeos Controller
Superb, thanks!aimeos wrote:Not exactly a redefinition but you create a new route (myproject_homepage) instead. The "/list" route will continue to work as expected, you only change the used route name in the catalog list component for the homepage.Bananamoon wrote: Just to make sure I understand it all, in the code you wrote above, I am redefining my '/list' route, right? So for the overview page I can just use the default /list for these kind of urls: list?f_name=cat-1&f_catid=4451?
Yes, that will be the caseBananamoon wrote: about the merge, I can just update through composer and all is fine? or not?
About the views itself, I will have to rewrite components for the homepage too. I found in the shop config file the pages, where you can add and remove components. Can I create my own component/page to go with the homepage?
I tried earlier to create a component (catalog/overview), but failed to succeed. It gave me an error about a missing factory.php file or something.
Re: Extending Aimeos Controller
Yes, sure! Here's the documentation:Bananamoon wrote: About the views itself, I will have to rewrite components for the homepage too. I found in the shop config file the pages, where you can add and remove components. Can I create my own component/page to go with the homepage?
I tried earlier to create a component (catalog/overview), but failed to succeed. It gave me an error about a missing factory.php file or something.
https://aimeos.org/docs/Laravel/Create_new_pages
https://aimeos.org/docs/Developers/Html ... components
For the factory, simply copy and adapt the Factory.php of the catalog list component. We will add that part to the documentation too
-
- Posts: 26
- Joined: 22 Jun 2015, 09:12
Re: Extending Aimeos Controller
Nice, thanks! Really appreciate the work you guys put in this shop!aimeos wrote:Yes, sure! Here's the documentation:Bananamoon wrote: About the views itself, I will have to rewrite components for the homepage too. I found in the shop config file the pages, where you can add and remove components. Can I create my own component/page to go with the homepage?
I tried earlier to create a component (catalog/overview), but failed to succeed. It gave me an error about a missing factory.php file or something.
https://aimeos.org/docs/Laravel/Create_new_pages
https://aimeos.org/docs/Developers/Html ... components
For the factory, simply copy and adapt the Factory.php of the catalog list component. We will add that part to the documentation too
Re: Extending Aimeos Controller
Thank you very much but don't forget the girls!Bananamoon wrote:Nice, thanks! Really appreciate the work you guys put in this shop!
The documentation for creating the factory class is now available too:
https://aimeos.org/docs/Developers/Html ... tory_class
If you finished you project, would you mind answering a few questions?