Forums / General / Roles & Classes and the fetch function ...

Roles & Classes and the fetch function ...

Author Message

Thomas Schamm

Friday 03 October 2003 6:01:37 pm

I've a problem with the User Roles & Classes and another one with fetch function:

I created a new Class ('trainer') with a few attributes ('surename', 'age', ...). I added the Class 'trainer' to the Role Anonymous as it is shown here: content read Class( Folder , Info page , ... , trainer ).

Two Problems:

- I don't see objects of this new class with my user Anonymous. I see them, when i'm logged in and when i add a '*' instead of Class ( ... ). What am I doing wrong?

- I want to show the attributes of all 'trainer' on one page. So i created a fetch function
fetch('content','list',hash(parent_node_id, $node.node_id,
class_filter_type, include,
class_filter_array, array( 14 ) ) )}
How will i get access to all the attributes of this class. I tried it with {$trainer_list:item.surename} and {$trainer_list:item.age}, but i don't get the content written in these text fields.

Thank you for your help,
greetz, Thomas

Thomas Schamm

Saturday 04 October 2003 3:57:20 am

Ok, the first problem, concerning the roles, is solved. After I woke up this morning and restarted my pc, everything worked. I tried a few things, now i come to the point, that i have to close and reopen my browser, so the role settings get updated. I don't know if it's a bug, but i'm happy that i can see the objects now.
The second problem isn't solved yet, i will continue my search in the docs & forum.
Greetz, Thomas

Marco Zinn

Saturday 04 October 2003 5:25:54 am

Hi,

can you show us your complete template block?

Your problem seems to be with the section block, which you did not post.

Either you have none or it is somehow wrong.
For accessing Items in the $trainer_list, you must contruct a section like
{section name=Trainers loop=$trainer_list}
and then access the items like $Trainers:item and the attribues as $Trainers:item.age

You might want to refer to this code about the section and the variable naming (from News Pagelayout, showing the news box, simplified):

{let news_list=fetch( content, tree, hash(
parent_node_id, 2,
limit, 5,
sort_by, array( published, false() ),
class_filter_type, include,
class_filter_array, array( 2 )) ) }

{section name=News loop=$news_list}
<p class="readmore"><a href={concat("/content/view/full/", $News:item.node_id, "/")|ezurl}>{$News:item.name|wash}</a></p>
{/section}

{/let}

Let us know, if it works.

Marco

PS: The role problem was probably, that you didn't close your browser window. When you change roles, I guess, they are only checked, when you log in. Even an anonymous user is "logged in" (automatically) and gets a session. Close the browser and open the page again. This should give you a new session and check your permissions/roles again.

Marco
http://www.hyperroad-design.com

Thomas Schamm

Saturday 04 October 2003 7:19:25 am

Hi,
that the roles are loaded when the user session is created, sounds logic. My fault :-/

I have the section block the same as you wrote it down.
I can access items with $Trainers:item.name or $Trainers:item.node_id, but i don't get the attributes with eg. $Trainers.item.age.
I'm not sure if i have to use {attribute_view_gui attribute=$node.object.data_map.age} for it, but then i'm not sure how to show all Trainers with all their attributes on one page.

Greetz, Thomas

Marco Zinn

Saturday 04 October 2003 8:00:44 am

Hm, when you can access .name and .node_id, then your namespaces are fine. With that, you access the node (not the object, yet).

Now, for accessing the object attribute data, you should be able to just print $Trainers:item.data_map.age (so, sorry, my first posting was wrong: You must access the datamap first).
Provided, that this is a simple attribute (no XML), this should work.
If it is more complex, you must use
{attribute_view_gui attribute=$Trainers:item.data_map.age}

You should consider another option:
Use the function node_view_gui to view the Trainer items in the section (search docs for "node_view_gui" for more info).
You will need something like:
{node_view_gui view=line content_node=$articleLoop:item}
ez should then print the "Trainer" node incl. all attributes. Then, you should override the line template of your class to print it nicely. Do this in Admin -> Setup -> Template -> node/view/line and create an override template for your (user) siteaccess, matching your new class (Trainer)

Marco
http://www.hyperroad-design.com

Thomas Schamm

Monday 06 October 2003 9:07:01 am

Hi Marco,

thx again, the hint with {attribute_view_gui attribute=$Trainers:item.data_map.age} worked :-)

There comes up another question:

I want to view the trainers in a table, the table should be 2 columns and x rows, where x is as much as there are rows needed to show all Trainers.
I have solved this problem with sequences, but i'm not sure, if the sequence function should be used for adding <tr> and </tr> at the right places. Look at my code:

<table cellpadding="0" cellspacing="15">
{let ausbilder_liste=fetch('content','list',hash(parent_node_id, $node.node_id, class_filter_type, include, class_filter_array, array( 14 ), sort_by, array( name, true() ) ) )}
{sequence name=Leftbracket loop=array("<tr>","")}
{sequence name=Rightbracket loop=array("","</tr>")}
{section name=Ausbilder loop=$ausbilder_liste}
{$Leftbracket:item}
<td>
{attribute_view_gui attribute=$Ausbilder:item.data_map.vorname}
{attribute_view_gui attribute=$Ausbilder:item.data_map.nachname}
</td>
{$Rightbracket:item}
{sequence name=Leftbracket}
{sequence name=Rightbracket}
{/section}
{/let}
</table>