Page 1 of 2

Changing header & body for mini basket?

Posted: 20 Jun 2017, 22:06
by bill
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?

Re: Changing header & body for mini basket?

Posted: 21 Jun 2017, 13:09
by aimeos
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

Re: Changing header & body for mini basket?

Posted: 21 Jun 2017, 15:51
by bill
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

Re: Changing header & body for mini basket?

Posted: 21 Jun 2017, 21:03
by aimeos
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

Re: Changing header & body for mini basket?

Posted: 21 Jun 2017, 21:15
by bill
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?

Re: Changing header & body for mini basket?

Posted: 21 Jun 2017, 21:28
by aimeos
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.

Re: Changing header & body for mini basket?

Posted: 21 Jun 2017, 21:49
by bill
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

Re: Changing header & body for mini basket?

Posted: 21 Jun 2017, 22:07
by ujackson
See the post on Github: https://github.com/aimeos/aimeos-laravel/issues/103
Substitute "catalog/filter" with "basket/mini".

Re: Changing header & body for mini basket?

Posted: 22 Jun 2017, 15:36
by bill
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

Re: Changing header & body for mini basket?

Posted: 23 Jun 2017, 15:51
by aimeos
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.