Forums / Install & configuration / Finding the email-adress...

Finding the email-adress...

Author Message

Atle Enersen

Sunday 19 January 2003 2:42:01 am

I have a full_class_*.tpl for an article content object that shall display both the authors name and email-adress. The authors name is no problem, this is found via the {$content_object.owner.name} (or {$node.object.owner.name} if one prefers) but how the he.. do I find the rest of the userdata (from ezuser) for the owner/creator...?

As I understand the owner.name refers to ezcontentobject (in the DB) referred from the ower_id field - yes, I looked in the DB-structure. In this case the author will allways be the one that has written the article.

So, how to get the data from the table ezuser where the email-adress is stored?

\atle\
--

Luc Chase

Thursday 16 October 2003 5:13:59 am

Atle,
did you ever solve this?? I really need the solution to this also.

The Web Application Service Provider

Paul Borgermans

Thursday 16 October 2003 6:52:28 am

This is what I use in a line view template:

$node.contentobject_version_object.creator.contentobject_attributes.2.content.email}

Sometimes you have to dig deep ;-)

-paul

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

Luc Chase

Thursday 16 October 2003 7:26:44 am

It worked!! Thank you!
Can you explain how one should normally find these things? What should I have been looking at to find that attribute on my own? So that when I need something else I can try to help myself.

The Web Application Service Provider

Paul Borgermans

Thursday 16 October 2003 8:41:08 am

{$node|attribute(show,<level>)}

With <level> set to a large depth, the default is 2 (large output too, you're warned)

-paul

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

Luc Chase

Thursday 16 October 2003 9:34:34 am

Tres Cool! Thanks.

The Web Application Service Provider

Jan Borsodi

Friday 17 October 2003 12:56:32 am

A better way of accessing the user data is to trough the data_map attribute, the data_map will return an array with all content attributes where the content attribute identifier is the lookup name, in this case it's user_account which is defined by the User content class.

The line would then be
{$node.contentobject_version_object.creator.data_map.user_account.content.email}

Some more info on the data_map can be read here:
http://ez.no/developer/ez_publish_3/documentation/customization/custom_design/node

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Luc Chase

Saturday 18 October 2003 12:31:26 am

Jan, your method seems easier but when you say 'better' do you mean that it is more reliable? Would the two methods allways return the same value or are their circumstances that would cause them to return a different value? For example, is one the email of the creator (of the first version) and the other the email of the last editor (creator of the current version)?
I'm trying to use this in each item of the shop basket so that I can send an email to {$basket.items.....contentobject_version_object.creator.data_map.user_account.content.email}

The Web Application Service Provider

Luc Chase

Saturday 18 October 2003 12:58:04 am

Eureka!!!!
{$Basket:ProductItem:item.item_object.contentobject.main_node.contentobject_version_object.creator.data_map.user_account.content.email}
or
{$Basket:ProductItem:item.item_object.contentobject.main_node.contentobject_version_object.creator.contentobject_attributes.2.content.email}
Thanks to Paul and Jan!... now how to e-mail the order (including header details) with only this item....

The Web Application Service Provider

Paul Forsyth

Saturday 18 October 2003 4:09:03 am

With lines of this length its a good idea to create some useful variables:

{let my_datamap=$Basket:ProductItem:item.item_object.contentobject.main_node.contentobject_version_object.creator.data_map}

{$my_datamap.user_account.content.email}
{$my_datamap.others...}
{/let}

With the second example you can be neater:

{let my_attributes=$Basket:ProductItem:item.item_object.contentobject.main_node.contentobject_version_object.creator.contentobject_attributes}

{attribute_view_gui attribute=$my_attributes.2.content.email}

{/let}

and so on.

Saves using scroll bars ;)

paul

Luc Chase

Saturday 18 October 2003 5:30:13 am

Do you think there is a simple way to send an email to the 'creator/owner' of the item in the basket (along with the order header i.e. who is ordering it.)?

The Web Application Service Provider

Jan Borsodi

Wednesday 22 October 2003 5:18:51 am

> Jan, your method seems easier but when you say 'better' do
> you mean that it is more reliable?

Yes, the first one relies on the order/placement of the attribute while the second (data_map) relies on the name of the attribute. Order/placement may change but the identifer name rarely change (if ever).
The other advantage with identifier names is that you can use the same identifier in multiple classes and just have one template for all of them (or PHP code for that matter).

Generally you shouldn't change the identifier name (You can still change the displayed name) in a class once objects has been made from it, that ensures that your templates don't need any changes to them.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq