Table des matières
- The template language -- Langage des templates
- Comments -- Commentaires
- Variable types -- Types de variables
- Variable usage -- Utilisation des variables
- Array and object inspection -- Inspection des tableaux et objets
- Control structures -- Structures de contrôle
- Functions and operators -- Fonctions et opérateurs
Array and object inspection -- Inspection des tableaux et objets
Date de publication: le mardi 29 mars 2011 à 20h39
Dernière modification: par Pascal BOYER le vendredi 1 avril 2011 à 17h25
versions 3.9, 3.10, 4.x
By using the "attribute" template operator, it is possible to quickly inspect the contents of arrays and template objects. The operator creates an overview of available keys, attribute names and/or methods in an object or an array. By default, only the array keys and object attribute names (also called identifiers) are shown. By passing "show" as the first parameter, the operator will also display the values.
L'opérateur de template
attribute
permet d'inspecter rapidement le contenu de tableaux et d'objets. Cet opérateur crée une vue d'ensemble des clefs disponibles, des noms des attributs et/ou des méthodes d'un objet ou d'un tableau. Par défaut, seules les clefs de tableaux et les noms des attributs des objets (aussi appelés identifiants) sont affichés. En passant le paramètre show en premier paramètre, l'opérateur affichera aussi les valeurs.
The second parameter can be used to control the number of levels/children that will be explored (the default setting is 2). The following example demonstrates how the operator can be used to inspect the contents of an "ezcontentobjecttreenode" object.
Le second paramètre est utilisé pour contrôler le nombre de niveaux/d'enfants à explorer (par défaut, 2 niveaux sont explorés). Voici un exemple d'utilisation de l'opérateur pour inspecter le contenu d'un objet
ezcontentobjecttreenode
.
{$node|attribute( show, 1 )}
The following output will be produced:
La sortie suivante sera produite:
| Attribute | Type | Value |
|---|---|---|
| node_id | string | 2 |
| parent_node_id | string | 1 |
| main_node_id | string | 2 |
| contentobject_id | string | 1 |
| contentobject_version | string | 10 |
| contentobject_is_published | string | 1 |
| depth | string | 1 |
| sort_field | string | 8 |
| sort_order | string | 1 |
| priority | string | 0 |
| modified_subnode | string | 1108118324 |
| path_string | string | '/1/2/' |
| path_identification_string | string | '' |
| is_hidden | string | 0 |
| is_invisible | string | 0 |
| name | string | 'eZ publish' |
| data_map | array | Array(6) |
| object | object[ezcontentobject] | Object |
| subtree | array | Array(114) |
| children | array | Array(44) |
| children_count | string | 44 |
| contentobject_version_object | object[ezcontentobjectversion] | Object |
| sort_array | array | Array(1) |
| can_read | boolean | true |
| can_create | boolean | false |
| can_edit | boolean | false |
| can_hide | boolean | false |
| can_remove | boolean | false |
| can_move | boolean | false |
| creator | object[ezcontentobject] | Object |
| path | array | Array(0) |
| path_array | array | Array(2) |
| parent | object[ezcontentobjecttreenode] | Object |
| url | string | '' |
| url_alias | string | '' |
| class_identifier | string | 'folder' |
| class_name | string | 'Folder' |
| hidden_invisible_string | string | '-/-' |
| hidden_status_string | string | 'Visible' |
As the output shows, there is a lot of information that can be extracted from a node object. In addition to strings and numbers the object also consists of other objects. For example, the creator of the node is a "ezcontentobject" object. The creator object can be further inspected by doing the following:
Comme le montre la sortie ci-dessus, une grande quantité d'information peut être extraite d'un objet. En plus de chaînes de caractères et de nombres, un objet se compose également d'autres objets. Par exemple, le créateur du nœud est un objet
ezcontentobject
. L'objet creator peut de plus être inspecté de la manière suivante:
{$node.creator|attribute( show, 1 )}
The following output will be produced:
La sortie suivante sera alors produite:
| Attribute | Type | Value |
|---|---|---|
| id | string | 14 |
| section_id | string | 2 |
| owner_id | string | 14 |
| contentclass_id | string | 4 |
| name | string | 'Administrator User' |
| is_published | string | 0 |
| published | string | 1033920830 |
| modified | string | 1033920830 |
| current_version | string | 1 |
| status | string | 1 |
| current | object[ezcontentobjectversion] | Object |
| versions | array | Array(1) |
| author_array | array | Array(1) |
| class_name | string | 'User' |
| content_class | object[ezcontentclass] | Object |
| contentobject_attributes | array | Array(5) |
| owner | object[ezcontentobject] | Object |
| related_contentobject_array | array | Array(0) |
| related_contentobject_count | string | 0 |
| reverse_related_contentobject_array | array | Array(0) |
| reverse_related_contentobject_count | string | 0 |
| can_read | boolean | false |
| can_create | boolean | false |
| can_create_class_list | array | Array(0) |
| can_edit | boolean | false |
| can_translate | boolean | false |
| can_remove | boolean | false |
| can_move | boolean | false |
| data_map | array | Array(5) |
| main_parent_node_id | string | 13 |
| assigned_nodes | array | Array(1) |
| parent_nodes | array | Array(1) |
| main_node_id | string | 15 |
| main_node | object[ezcontentobjecttreenode] | Object |
| default_language | string | 'eng-GB' |
| content_action_list | boolean | false |
| class_identifier | string | 'user' |
| class_group_id_list | array | Array(1) |
| name | string | 'Administrator User' |
| match_ingroup_id_list | boolean | false |
Again, this object consists of a lot of information. As mentioned above, the "attribute" operator can be used on both objects and arrays. The following example demonstrates how to inspect the "data_map" array (which reveals the object's attributes) of the node's creator object.
À nouveau, cet objet se compose d'un grand nombre d'informations. Comme mentionné ci-dessus, l'opérateur
attribute
peut être utilisé à la fois avec les objets et les tableaux. L'exemple ci-dessous montre comment inspecter le tableau data_map (qui révèle les attributs de l'objet) de l'objet creator du nœud.
{$node.creator.data_map|attribute( show, 1 )}
The following output will be produced:
La sortie suivante sera à présent produite:
| Attribute | Type | Value |
|---|---|---|
| first_name | object[ezcontentobjectattribute] | Object |
| last_name | object[ezcontentobjectattribute] | Object |
| user_account | object[ezcontentobjectattribute] | Object |
| signature | object[ezcontentobjectattribute] | Object |
| image | object[ezcontentobjectattribute] | Object |
Table des matières
- The template language -- Langage des templates
- Comments -- Commentaires
- Variable types -- Types de variables
- Variable usage -- Utilisation des variables
- Array and object inspection -- Inspection des tableaux et objets
- Control structures -- Structures de contrôle
- Functions and operators -- Fonctions et opérateurs
Commentaires














