Trying to figure out object relation, but documentation is pretty weak

Author Message

Vincent Macaluso

Wednesday 12 May 2004 12:46:27 pm

I'm trying to come up with a way to do a site for a group that wants a directory that's laid out in sort of menu fashion.

Thing of it this way:

I have business-1 that does several services:
service-1, service-2, service-3, service-4

I have business-2 that does several services:
service-1, service-2, service-3

and so on. For each service I will need a price and description.

SO I thought I could have a class for the busineses and a class for services. But how do I point each service I enter to the business to which it belongs? I can't wrap my noggin around this yet. I think I'm confused over classes and groups and that such thing.

There is almost no documentation on Object Relations in the doc pages!

Thanks for any help you can offer.

VIncent

Vincent Macaluso

Wednesday 12 May 2004 1:50:47 pm

Well, I tried creating a new folder called Restaurants (to keep the model simple) and then created another called italian under that. Created a new class called restaurant and created a restarant called Vincent's Restaurant within the Italian folder. This doesn't get listed under the Italian folder. Only new articles are listed. How do I list Restaurants under this folder? (They can be listed using the same template as an Article.) Next I'd like to be able to use the class Menu Item to add items that will be listed under the restaurant.

I imagine this is done using templates, but the more I try to copy a template or even create a new one, the more I go around in circles without actaully creating anything.

Tore Skobba

Wednesday 12 May 2004 2:20:22 pm

Hi

Some quick tips. Check that anonymous users are allowed to view the new Resturant class (admin - users -roles -anonymous roles - to * * * for DEVELOPING only. Remember to click the store button!

Secondly check the fetch in your template.. Does it have an class_id, XX or class_filter_array, XX Where XX is an number (the id of the CLASS to fetch.

Cheers
Tore

Vincent Macaluso

Wednesday 12 May 2004 2:30:33 pm

hehe thanks! Ok, I see it now. How do I use the regular article template for the restaurant template? I'd like it to look the same, except show any of the Menu class items that I create under it. :) Maybe I'm moving too fast for my own good. :)

Vincent Macaluso

Wednesday 12 May 2004 2:57:11 pm

Ok, I'm looking at the restaurant and it says: "Default object view. Click to create a custom template, Node ID: 217, Object ID: 304" and it's all ugly nad barely formatted and it has all sorts of adminstrative-type links on it that I'm sure the anonymous user should not be seering.. I assume I must have to create a new template for the Restaraunt class I created. So, I click on "Click to create a custom template" and it takes me to:

> Error / kernel (1)
Template view /node/view/full.tpl

Default template resource design/standard/templates 
[user    ] [Set]
[Create New] [Update] [Remove]

In the drop down do I want want user, admin, demo, news or news_admin?

I imagine I want user since I want to ceate a template for the users to see. So I click on Create New

I'll call it restaurant.tpl why not?

Overide keys:
Class Restaurant
Section Any
Node (blank)

I want to copy the Article base template, so I select Copy of default template.

Permission denied. Let's try from the admin site.

news_admin > Advanced > Templates

I see a list, but no way to create a new one.

Ok, did all the above again, and copy/paseed the template from article.full into the new restaurant template.

Now, it looks like the article does, but I no longer have a list of the Menu items that were listed under the original default layout. Hmmm. :)

Will I have to create a template for the Menu class specically for listing it in the restaurant.full template or is that something I can do ffrom withiin this one?

By the way, its found here: http://nolagay.com/ezpub335/index.php/news/news/italian/vincent_s_restaurant__1

Vincent Macaluso

Wednesday 12 May 2004 9:54:30 pm

OMG I'm going crazy now. :) I'm at a new computer, and no matter what I do I cant edit the restaurant.tpl template again. I keep getting "<b>Could not create template, permission denied.</b>"

No matter what I click on, no matter where i go I can't find that screen that lists the templates with the little edit icons next to them. Why is this so hard to find? It's been two hours and still no luck. Any idea why I can't Create New templates all of a sudden? Actually, i don't even want to Create New, I want to edit the template I already made. I called it restaurant.tpl. I tried clicking on Update and it just redrew the same page. I double checked all of my permissions - taking a cue from this link: http://ez.no/community/forum/setup_design/could_not_create_template_permission_denied - but that wasn't the problem since everthing is set to 777 or 666. I guess the problem could be an owner/creater type thing - but if that was the case why was it working earlier today, but not now?

I really wanted to figure out the template system tonight, but I cant even figure out how to LOOK at one in ezPublish. Am I just being dense about this, or is it this obtuse on purpose? Why doesn't the Admin > Template listing have EDIT icons next to them?

Vincent "It's late and I'm stressed and annoyed" Macaluso :)

Vincent Macaluso

Thursday 13 May 2004 7:41:56 am

Ok, slowly but not-so-surely getting this. ALthough whoever named this "ez" and wrote that there's no need for HTML or programming was smoking crack. :)

On this link:
http://nolagay.com/ezpub335/index.php/news/restaurants/italian/vincent_s_restaurant__1

I have my before and after templates (which I admit is just the default Article template with some addition - but hey, I'm proud I figured that much. Now what I'm trying to do is format the listing of children so that users, instead of looping through and displaying the default::

 Name  	 Class  	 Section  	 Copy
{where'd it get the name?) $Child:item.object.class_name $Child:item.object.section_id etc...
{where'd it get the name?) $Child:item.object.class_name $Child:item.object.section_id etc..

I'd like users to get:

Menu Item                  Price
$Child:??????.item_name       $Child:?????.item_price
$Child:?????.item_description

I've tried $Child:item.object.item_name, $Child:$content_version.data_map.item_name, $Child:data_map.item_name, $Child:item_name and of course, nothing. I'm looking through the documentation, but I just don't understand these templates at all.

Chris Fullerton

Thursday 13 May 2004 8:00:25 am

Agree that the documentation is weak, but there is a lot of useful stuff there - it's just not easy to find.

That said, one thing that you'll find useful:

{$object|attribute(show,2)}

Replace $object with the thing you're having problems with.

It's also helpful to sometimes turn on the template debugging - I think you can add:

[TemplateSettings]
Debug=enabled

and you'll see exactly what templates are getting included. You can then copy them into your local tree and change them to suit what you're doing.

It's usually more helpful to view the debug output with view->source.

Vincent Macaluso

Thursday 13 May 2004 8:03:32 am

Ok, I've tried this:(which I got from this link: http://ez.no/ez_publish/documentation/customization/tips_tricks/fetch_function_examples )

{section loop=fetch( 'content', 'list', hash(parent_node_id, $node.node_id)}

<a href={$:item.url_alias|ezurl}>{$:item.item_name}</a><br>

{/section}

And this isn't working either. I swear, I'm trying!

Vincent Macaluso

Thursday 13 May 2004 8:30:29 am

That said, one thing that you'll find useful:

{$object|attribute(show,2)}

Hmm. I don't quite understand what you mean. Sorry!

Chris Fullerton

Thursday 13 May 2004 8:47:15 am

Well, in your above example, you used

{section loop=fetch( 'content', 'list', hash(parent_node_id, $node.node_id)}

<a href={$:item.url_alias|ezurl}>{$:item.item_name}</a><br>

{/section}

Change that to:

{section loop=fetch( 'content', 'list', hash(parent_node_id, $node.node_id)}

{$:item|attribute(show,2)}
<a href={$:item.url_alias|ezurl}>{$:item.item_name}</a><br>

{/section}

and you'll see everything in the object. (If nothing show up, then it's probably because there's nothing returned by the fetch.)

Vincent Macaluso

Thursday 13 May 2004 9:03:53 am

Hmmm. Nothing showed up. Am I doing the fetch wrong? The current node ID is 217 so I tried using the following and it returned blank as well:

{section loop=fetch( 'content', 'list', hash(parent_node_id, 217)}

{$:item|attribute(show,2)}
<a href={$:item.url_alias|ezurl}>{$:item.item_name}</a><br>

{/section}

Paul Borgermans

Thursday 13 May 2004 9:42:22 am

You are missing a closing ")" in the first line.

Should be:

{section loop=fetch( 'content', 'list', hash(parent_node_id, 217))}
{$:item|attribute(show,2)}
<a href={$:item.url_alias|ezurl}>{$:item.item_name}</a><br>
{/section}

Earned another beer maybe :-)

-paul

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

Vincent Macaluso

Thursday 13 May 2004 11:55:55 am

Awesome! Now, one more and I think I'm on my way to figuring this out.

Now that I have a list of all attributes, how do I just pick out the three that I want?
Could you break apart what each part of {$:item|attribute(show,2)} is doing, so I can put it together?

I promise once I get the baby steps I'll be able to get more on my own! Thanks so much for your help!

<b>Edit:</b>
Ok, I got it. Sort of. I used

{section loop=fetch( 'content', 'list', hash(parent_node_id, 217))}
<a href={$:item.url_alias|ezurl}>{$:item.name|wash}</a><br>
{/section}

And it gace me the links to each item.

Ok, so lets say I want to go one further and take out the information from the object itself. (are these what the >'s indicate? One is >item_price Is this located within the datamap?

{section loop=fetch( 'content', 'list', hash(parent_node_id, 217))}
{$:item|attribute(show,2)}
<a href={$:item.url_alias|ezurl}>{$:item.name|wash}</a><br>
{$ContentObject:item.item_description|washl} {$ContentObject:item.item_price|wash}
{/section}

Didn't work. Maybe something like:

{section loop=fetch( 'content', 'list', hash(parent_node_id, 217))}
{$:item|attribute(show,2)}
<a href={$:item.url_alias|ezurl}>{$:item.name|wash}</a><br>
{$ContentObject:item.data_map.item_description|washl} {$ContentObject:item.data_map.item_price|wash}
{/section}

Vincent

Paul Borgermans

Thursday 13 May 2004 12:06:32 pm

See

http://ez.no/ez_publish/documentation/reference/template_operators/miscellaneous/attribute

for an explanation. One thing is wrong in the docs: the default is not unlimited but set to 2.

I'll correct this

-paul

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

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