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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 00:36:38
Script start
Timing: Jan 19 2025 00:36:38
Module start 'layout'
Timing: Jan 19 2025 00:36:38
Module start 'content'
Timing: Jan 19 2025 00:36:39
Module end 'content'
Timing: Jan 19 2025 00:36:39
Script end

Main resources:

Total runtime1.0286 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.1328152.6250
Module start 'layout' 0.00640.0030 741.757839.4453
Module start 'content' 0.00941.0177 781.2031652.1563
Module end 'content' 1.02710.0014 1,433.359420.1563
Script end 1.0285  1,453.5156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3199160.0002
Check MTime0.00140.1334160.0001
Mysql Total
Database connection0.00090.089410.0009
Mysqli_queries0.902487.7331660.0137
Looping result0.00070.0701640.0000
Template Total0.995096.720.4975
Template load0.00210.201520.0010
Template processing0.992996.530320.4965
Template load and register function0.00030.027310.0003
states
state_id_array0.00090.091810.0009
state_identifier_array0.00150.149720.0008
Override
Cache load0.00230.22252200.0000
Sytem overhead
Fetch class attribute can translate value0.00070.065720.0003
Fetch class attribute name0.00190.181270.0003
XML
Image XML parsing0.00080.074720.0004
class_abstraction
Instantiating content class attribute0.00000.002590.0000
General
dbfile0.00090.0882180.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
48content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
54content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 117
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs