Changing header & body for mini basket?

Help for integrating the Laravel package
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!
bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Changing header & body for mini basket?

Post by bill » 20 Jun 2017, 22:06

Hello

I have added two files in my ext folder I have created under >>
client/html/templates/basket/mini/body-default.php

client/html/templates/basket/mini/header-default.php
and in this file I have this code >>
------
foreach( $this->miniBasket->getProducts() as $product ) {
$quantity += $product->getQuantity();
}

echo $quantiy;
-------

basically when I call this <?= $aiheader['basket/mini'] ?> I want to return the quanity of the basket??
I added this to my balde template <?= $aiheader['basket/mini'] ?> and its returning empty??

what I am doing wrong here?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Changing header & body for mini basket?

Post by aimeos » 21 Jun 2017, 13:09

Maybe the content of the basket is cached if you didn't configure otherwise in your dev environment:
https://aimeos.org/docs/Configuration/C ... che/enable
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Changing header & body for mini basket?

Post by bill » 21 Jun 2017, 15:51

aimeos wrote:Maybe the content of the basket is cached if you didn't configure otherwise in your dev environment:
https://aimeos.org/docs/Configuration/C ... che/enable
I already have it cached , how can I make sure that when I display this : <?= $aiheader['basket/mini'] ?> . in my blade template I want it to work across the whole site, but right now its not working I am getting undefined error on some pages?

could you help me?

Thanks

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Changing header & body for mini basket?

Post by aimeos » 21 Jun 2017, 21:03

OK, if you want to use the mini basket component in your own pages (not only those that are offered by the Aimeos Laravel package by default), you should have a look into this article explaining the details:
https://aimeos.org/docs/Laravel/Create_new_pages
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Changing header & body for mini basket?

Post by bill » 21 Jun 2017, 21:15

Yes I see your point

but I need to make it available in ALL pages Aimeos and my pages , basically in the header.blade I have created that I need to be able to call that array and it will work?

do I need to create a new serviceprovider?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Changing header & body for mini basket?

Post by aimeos » 21 Jun 2017, 21:28

No, you don't. Only configure a new section in your ./config/shop.php:

Code: Select all

'page' => array(
    // ... existing entries
    'aimeosall' => array('basket/mini'),
),
Add this to your actions:

Code: Select all

$params = app( '\Aimeos\Shop\Base\Page' )->getSections( 'mypage' );
// do some more stuff
return \View::make('mypagetmpl', $params);
Then you can use "<?= $aiheader['basket/mini'] ?>" in every template.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Changing header & body for mini basket?

Post by bill » 21 Jun 2017, 21:49

for this :
$params = app( '\Aimeos\Shop\Base\Page' )->getSections( 'mypage' );
// do some more stuff
return \View::make('mypagetmpl', $params);

What you mean add to your action? where exactly?

I am not trying to create a new page I just need to use the $aiheader['basket/mini'] in ALL my template

ujackson
Posts: 6
Joined: 29 Jun 2015, 16:36

Re: Changing header & body for mini basket?

Post by ujackson » 21 Jun 2017, 22:07

See the post on Github: https://github.com/aimeos/aimeos-laravel/issues/103
Substitute "catalog/filter" with "basket/mini".

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Changing header & body for mini basket?

Post by bill » 22 Jun 2017, 15:36

Thanks

but when you do this in ./config/shop.php you are specifying that variable $aiheader['basket/mini'] in the HOME PAGE only

Code: Select all

'page' => array(
		// ...
		'home' => array( 'catalog/filter' ),
	),
I need to be able to add this variable if I want in my layout blade template and it will used by all the pages without getting error of undefined

right now I get undefined error on the other pages

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Changing header & body for mini basket?

Post by aimeos » 23 Jun 2017, 15:51

In this case, a common Laravel service provider might be really the best option:
https://laravel.com/docs/5.4/views#shar ... -all-views

There you can inject the output of the "Page" object you've defined in the config for all templates.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply