Example pages

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!
User avatar
aimeos
Administrator
Posts: 7889
Joined: 01 Jan 1970, 00:00

Re: Example pages

Post by aimeos » 29 Jan 2019, 06:43

"getRefItems()" is available in all items that implement the \Aimeos\MShop\Common\Item\ListRef\Iface interface, i.e. products, categories, attributes, customers, services, prices and texts.

"$item->price" and "$item->text" is undefined, you need to call

Code: Select all

$priceItems = $item->getRefItems( 'price', 'default', 'default' );
$textItems = $item->getRefItems( 'text', 'long' );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Trent
Posts: 11
Joined: 31 Dec 2018, 01:06

Re: Example pages

Post by Trent » 29 Jan 2019, 14:19

I've tried using it as: {{$item->getRefItems('text', 'long')}}

But it returns "htmlspecialchars() expects parameter 1 to be string, array given"

I've tried intiallizing it in the controller and no luck either.

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

Re: Example pages

Post by aimeos » 31 Jan 2019, 12:50

Code: Select all

$item->getRefItems('text', 'long')
returns an array of text items which you should output in a loop. This applies to all calls of getRefItems()
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Trent
Posts: 11
Joined: 31 Dec 2018, 01:06

Re: Example pages

Post by Trent » 31 Jan 2019, 17:00

I've tried inserting it into a foreach loop but I still have problems. Would you be able to give me an example?

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

Re: Example pages

Post by aimeos » 02 Feb 2019, 19:59

Code: Select all

@foreach ($item->getRefItems('text', 'long') as $text)
    <p>{{ $text->getContent() }}</p>
@endforeach
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Trent
Posts: 11
Joined: 31 Dec 2018, 01:06

Re: Example pages

Post by Trent » 03 Feb 2019, 13:57

That works thank you! I didn't know about the getContent(). It isn't registering the <p><strong> tags for some reason though.

Is there a similar method to get the images to load? The getContent() doesn't seem to work for it.
Attachments
Screenshot from 2019-02-03 13-54-57.png
Screenshot from 2019-02-03 13-54-57.png (17.33 KiB) Viewed 2403 times

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

Re: Example pages

Post by aimeos » 04 Feb 2019, 09:44

The "{{ ... }}" automatically escapes the tags. Blade offers a different syntax for unchanged output.

For images, you can use getUrl() or getPreview():
- https://aimeos.org/api/latest/class-Aim ... Iface.html
- https://aimeos.org/api/latest/class-Aim ... Iface.html

For the available methods in the different items, please have a look at the API docs:
https://aimeos.org/api/latest/namespace ... MShop.html
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Trent
Posts: 11
Joined: 31 Dec 2018, 01:06

Re: Example pages

Post by Trent » 11 Feb 2019, 09:45

Cool beans! I managed to have a decent looking page now :)

Any chance you could tell me how to add the add to basket option on this? And where I can customize the nav bar?

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

Re: Example pages

Post by aimeos » 12 Feb 2019, 12:00

To show the "add to basket" button in the list view, you have to set this configuration option to "1" or true:
https://aimeos.org/docs/Configuration/C ... basket-add
Furthemore, your have to add the "domain" setting descripted in the documentation page.

This works for the standard template. If you created your own template, you have to adapt your template to the functionality of the standard template.

The navigation bar is defined in your app.blade.php template file and managed by Laravel so you have all options Laravel is offering there.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Trent
Posts: 11
Joined: 31 Dec 2018, 01:06

Re: Example pages

Post by Trent » 12 Feb 2019, 14:31

To make my own functionality do I just pass the five parameters to a separate function to make it work? Or is there an easier way to update the basket contents?

Post Reply