Forums / Setup & design / How to set attribute into variable

How to set attribute into variable

Author Message

Tomasz Cebula

Sunday 22 January 2006 4:09:23 pm

Hi
I can't find resolution how to set attribute into variable.
I have found a topic with this question :
http://ez.no/community/forum/developer/put_attribute_into_variable/re_put_attribute_into_variable__9

But all answer didn't help .
Can anyone help me ???

Bobolak

Łukasz Serwatka

Sunday 22 January 2006 11:31:04 pm

Hi Tomasz,

Could you past here piece of your code which not working?

Have you tried with code below?

{*Assign value from "Name" attribute to variable $name*}
{def $name=$node.object.data_map.name.content}

{$name}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Tomasz Cebula

Monday 23 January 2006 12:58:50 am

Hi Lukasz
As I wrote any advices from this post:

http://ez.no/community/forum/deve...le/re_put_attribute_into_variable__9
don't works, so it is no sense to past them again. I've changed only the attribute name from: formulaire
to: pierwszy.

{$node.object.data_map.pierwszy.contentclass_attribute.name}

{attribute_view_gui attribute=$node.object.data_map.pierwszy}

I wat to assign value from pierwszy attribute to variable.
When I try to use your code:

{def $przykl=$node.object.data_map.pierwszy.content}
{$przykl}
Result is: Object(ezenum)

This attribute come from my own class Ankieta:
Maybe my class is incorrect???

Name: Ankieta
Identifier: ankieta
Object name pattern: ankieta
Container: No
Object count: 3
Attributes
1. 1.Jaki jest w Pani/ Pana ocenie poziom uprzejmosci pracowników dziekantu ? [Enum] (id:186)
Name:

1.Jaki jest w Pani/ Pana ocenie poziom uprzejmosci pracowników dziekantu ?

Identifier:

pierwszy

Flags:

Is required

Is searchable

Does not collect information

Translation is enabled
Style:

Single choice
Interface:

Radiobuttons / checkboxes
Elements:
Element Value
bardzo wysoka 1
wysoka 2
normalna 3
niska 4
bardzo zle 5
nie mam zdania 6
2. 2. Jak ocenia Pani/Pan wiedze pracowników ? [Enum] (id:187)
Name:

2. Jak ocenia Pani/Pan wiedze pracowników ?

Identifier:

drugi

Flags:

Is required

Is searchable

Does not collect information

Translation is enabled
Style:

Single choice
Interface:

Radiobuttons / checkboxes
Elements:
Element Value
bardzo wysoka 1
wysoka 2
normalna 3
niska 4
bardzo zla 5
nie mam zdania 6
3. 3. Czy pracownicy potrafili w sposób komunikatywny i zrozumialy udzielic informacji? [Enum] (id:188)
Name:

3. Czy pracownicy potrafili w sposób komunikatywny i zrozumialy udzielic informacji?

Identifier:

trzeci

Flags:

Is required

Is searchable

Does not collect information

Translation is enabled
Style:

Single choice
Interface:

Radiobuttons / checkboxes
Elements:
Element Value
tak 1
nie 2
czesciowo 3
4. 4. Czy organizacja obslugi interesanta jest Pani /Pana zdaniem na odpowiednim poziomie? [Enum] (id:189)
Name:

4. Czy organizacja obslugi interesanta jest Pani /Pana zdaniem na odpowiednim poziomie?

Identifier:

cztery

Flags:

Is required

Is searchable

Does not collect information

Translation is enabled
Style:

Single choice
Interface:

Radiobuttons / checkboxes
Elements:
Element Value
tak 1
nie 2
czesciowo 3
5. 5. Czy obsluga przebiega szybko i sprawnie? [Enum] (id:190)
Name:

5. Czy obsluga przebiega szybko i sprawnie?

Identifier:

piaty

Flags:

Is required

Is searchable

Does not collect information

Translation is enabled
Style:

Single choice
Interface:

Radiobuttons / checkboxes
Elements:
Element Value
tak 1
nie 2
czesciowo 3
6. 6. Pozostale uwagi i komentarze dotyczace pracy i obsługi studenta: [Text block] (id:191)
Name:

6. Pozostale uwagi i komentarze dotyczace pracy i obsługi studenta:

Identifier:

szesc

Flags:

Is not required

Is searchable

Does not collect information

Translation is enabled
Preferred number of rows:

10
7. 7. Plec [Enum] (id:192)
Name:

7. Plec

Identifier:

siedem

Flags:

Is not required

Is searchable

Does not collect information

Translation is enabled
Style:

Single choice
Interface:

Radiobuttons / checkboxes
Elements:
Element Value
mezczyzna 1
kobieta 2
8. 8. Kierunek studiów [Enum] (id:193)
Name:

8. Kierunek studiów

Identifier:

osiem

Flags:

Is not required

Is searchable

Does not collect information

Translation is enabled
Style:

Single choice
Interface:

Radiobuttons / checkboxes
Elements:
Element Value
informatyka 1
mbm 2
energetyka 3
silniki 4

Bobolak

Łukasz Serwatka

Monday 23 January 2006 1:35:09 am

You will need to loop enum and assign value to variable

{def $my_var}

{foreach $node.object.data_map.enum_attrib.content.enumobject_list as $element}
{if eq( $element.enumelement, 'something')}
    {set $my_var=$element.enumelement}
{/if}
{/foreach}

or just directly

{def $my_var=$node.object.data_map.enum.content.enumobject_list[0].enumelement}

Check also:

$current_node.object.data_map.enum.content.enumobject_list|attribute

Hope it will help you.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Tomasz Cebula

Monday 23 January 2006 1:24:28 pm

Thanks Lukasz for your help
Everthing is working now ! :)
I used this instruction :

{def $zmienna=$:item.object.data_map.enum.content.enumobject_list[0].enumelement}

Bobolak

Łukasz Serwatka

Monday 23 January 2006 2:35:02 pm

Great, Tomasz! You are welcome :)

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog