Object relation list

Author Message

Trond Åge Kvalø

Friday 05 March 2004 2:49:35 am

Ok, we have now upgraded to 3.3-3 to be able to use the object relation list.

We have created a course_license class that consists of:

1. A name
2. One object relation list where you can choose a user
3. One object relation list where you can choose a course

Each course_license object shall contain only one user and one course (for now)

We have created three course_license objects. (i.e. they're not show in the content tree).

1: user1 course1
2: user1 course2
3: user2 course1

Now, by clicking a certain link, we want to show the current user a list of all the courses that is available to him.

Is this possible using only template code, or do we need to create our own operator or module? In which database table are these object relations stored, and how?

best regards
trondåge

trondåge

Trond Åge Kvalø

Friday 05 March 2004 8:23:39 am

Ok here's the results so far.
We've managed to get the current user's contentobject_id by issuing a
fetch('user', 'current_user').

We have also managed to get a list of licenses from the licenses folder (node id 107)

Then we managed to do a section show that only showed the course_id from the licenses that matched our user.

The puzzling part is that when we use:

{$mylicenses:item.object.data_map.kurs.content.relation_list.0.contentobject_id|wash}

to show the course id we get the two course_id's that we expect displaying nicely on the screen.

But if we use:

{let mylicense=$mylicenses:item.object.data_map.kurs.content.relation_list.0.contentobject_id)
  {$mylicense|wash}
{/let}

We don't see anything on screen.

Anyway the next step then, is to issue a fetch based on the course_id's that we have got like this:

{let coursename=fetch( 'content', 'node', hash( 'node_id', $mylicenses:item.object.data_map.kurs.content.relation_list.0.contentobject_id) ) }
  {$coursename.name}
{/let}

But this doesn't work either. Maybe because the course_id is a string and the node_id in the fetch shall be an integer? If this is the case, how do we convert a string to an integer?

Anyway, if someone could please take a look at the code below and enlighten us as to what is wrong, we'd be very happy.

{let myuser=fetch('user','current_user')}
The current user's user_id is: {$myuser.contentobject_id}<br />

{*node_id 107 is the licenses folder*}
{let licenses=fetch( 'content', 'list', hash( 'parent_node_id', 107 ) )}
  {section name=mylicenses loop=$licenses}
    {section name=thisuser show=$mylicenses:item.object.data_map.bruker.content.relation_list.0.contentobject_id|eq($myuser.contentobject_id)}

    {*this next line displays 115 and 113, the course contentobject_id's*}     
	  {$mylicenses:item.object.data_map.kurs.content.relation_list.0.contentobject_id|wash}

	  {*These ones doesn't work*}
	  {let mylicense=$mylicenses:item.object.data_map.kurs.content.relation_list.0.contentobject_id)
	    {$mylicense|wash}
	  {/let}
    {/section}
   <br />
  {/section}
{/let}
{/let}

trondåge

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