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

eZ debug

Timing: Jan 18 2025 21:16:12
Script start
Timing: Jan 18 2025 21:16:12
Module start 'content'
Timing: Jan 18 2025 21:16:12
Module end 'content'
Timing: Jan 18 2025 21:16:12
Script end

Main resources:

Total runtime0.0142 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 587.9375180.8281
Module start 'content' 0.00530.0039 768.7656102.0078
Module end 'content' 0.00920.0049 870.773478.7031
Script end 0.0142  949.4766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002215.2078120.0002
Check MTime0.00107.0600120.0001
Mysql Total
Database connection0.00074.899410.0007
Mysqli_queries0.003726.133140.0009
Looping result0.00000.092220.0000
Template Total0.004732.810.0047
Template load0.00085.702310.0008
Template processing0.003927.110310.0039
Override
Cache load0.00064.111610.0006
General
dbfile0.00031.8119100.0000
String conversion0.00000.026830.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs