Share » Forums » General » A niave designer question on embed...

A niave designer question on embed related objects

A niave designer question on embed related objects

Saturday 18 October 2003 3:12:24 pm - 4 replies

Author Message

Paul Borgermans

Sunday 19 October 2003 3:02:28 am

As I understand it, you have a related object pointing to a folder? If so, just grab the node id and do a fetch of this folder with a limit set to 5. You can then display the items in a column on the right.

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Alan Sparkes

Sunday 19 October 2003 5:16:04 am

Thanks for the reply. I appreciate it.

However, i don't think this is enough information to complete the task.

1. The code to acheive this is documented I suspect - ok i'll read and experiment - I am not asking to be completely spoon fed!
2. Once I have the template code does inserting it into embed_class_x.tpl and placing this in the correct override dir automatically produce the desired result?
3. What else is there to do to complete the task?

Like I said previously, "The help i have read seems to assume to much knowledge to complete the process .."

many thanks for persevering with me!

alans

Paul Borgermans

Sunday 19 October 2003 7:04:16 am

1. Yes and no: it is scattered a bit in the docs section.

Your point of depature is the $node structure, do an

{$node|attribute(show)} to find the related object array.
Then use the nodeid of the related object to do a fetch (see template docs).

You can use that to display each item in the view template of your object class.

2. So not the embed_class_x.tpl file, this is used to embed objects in xml text fields. Use the view template of your folder class.

3. If you complete 1 and 2, there is nothing more to be done (except clearing caches)

To start with ez publish, it's a bit difficult. But the docs are getting better and you will appriciate the way ez publish works more and more (not that it is perfect though)

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

James Ward

Sunday 19 October 2003 8:05:10 am

Hi Alan,
I actually did something similar for articles on my web design. In your case you want to relate folders. Your solution will be a little different but basically the same idea. If you want to do folders, override your full folder view with your own folder.tpl (you may have done that already) and add the following code to your folder.tpl wherever you want your list to appear i.e. right column:

{*Related Objects List*}
{let enableendtag=0 name=Rel}
{section show=count($node.object.related_contentobject_array)|gt(0)}
{section loop=$node.object.related_contentobject_array}
{section-exclude match=$:item.contentclass_id|eq(5)}
{switch match=$:index}
{case match=0}
{* if starttag *}
{set enableendtag=1}
<table width="150" border=0 cellpadding=3 cellspacing=0 class="related-information-table">
<tr>
<td align="center">Related Information<td>
</tr>
<tr>
<td><ul>
<li><a class="related-information-link" href={concat("/content/view/full/",$:item.main_node.node_id)|ezurl}>{$:item.name}</a></li>
{/case}
{case}
<li><a class="related-information-link" href={concat("/content/view/full/",$:item.main_node.node_id)|ezurl}>{$:item.name}</a></li>
{/case}
{/switch}
{/section}
{section show=$:enableendtag}
</ul></td>
</tr>
</table>
{/section}
{/section}
{/let}
{*End Related Information Link*}

The line {section-exclude match=$:item.contentclass_id|eq(5)} ensures that any related images are not included in your related items list. This was particualrily important for relating articles since most articles contain related images but it will likely be a non-issue for folders.

Hope this helps.

working at www.wardnet.com
blogging at www.jamesward.ca

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu