Get label of attribute type

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!
Icymars
Posts: 12
Joined: 16 Dec 2020, 18:33

Get label of attribute type

Post by Icymars » 09 Mar 2021, 19:23

Hi guys, anyone of you know how to get label of attribute type? I'll explain. In attribute-standard.php of common/partials there is this line of code for print code of attribute type :
<label for="select-<?= $enc->attr( $code ) ?>" class="select-name"><?= $enc->html( $this->translate( 'client/code', $code ) ); ?></label>
but I want to print the label. Anyone know how do it?

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

Re: Get label of attribute type

Post by aimeos » 10 Mar 2021, 11:15

The attribute items have like most items a getLabel() method so you can use:

Code: Select all

$attributeItem->getLabel()
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Icymars
Posts: 12
Joined: 16 Dec 2020, 18:33

Re: Get label of attribute type

Post by Icymars » 10 Mar 2021, 17:12

I think I expressed myself badly.

In the product detail page the code related to the type of the attribute is printed, for example if I had a product with 2 attributes of type Shade color whose code is [shade_color] it would be printed:

shade_color << --- attribute type code
attribute1 || attribute 2 << - associated attributes

I would like the code value to be printed and then:

Shade color << - label of the attribute type
attribute1 || attribute 2 << - associated attributes

So given the implementation:

Code: Select all

<? php foreach ($attrTypeDeps as $code => $positions): asort ($positions); ?>
I would like to exploit the $code to receive the relative associated label but not of the attribute but of the attribute type.

I hope I have explained myself better now.

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

Re: Get label of attribute type

Post by aimeos » 12 Mar 2021, 07:33

The attribute type information including the label isn't available in the templates because it's not fetched from the database. This is the reason we use the type codes for translations.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply