Forums / General / object name pattern issue

object name pattern issue

Author Message

Jon Arvid Ludviksen

Monday 13 October 2008 6:32:36 am

I've made a attribute nick and want the object name pattern for the user-class to be either nick or first_name and last_name.

<first_name> <last_name> works perfect.

<nick|first_name> works perfect but how do I add last_name?

Nabil Alimi

Monday 13 October 2008 1:24:14 pm

Hi Jon,

Have you tried <nick|first_name> <last_name> ?

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Jon Arvid Ludviksen

Tuesday 14 October 2008 12:28:18 am

Yes, I have. <last_name> shows no matter what.

Bård Farstad

Tuesday 14 October 2008 12:50:02 am

Hi Jon Arvid,

long time no see ;)

For the object name pattern you are not able to have a condition that shows either one (nick) or two (first + last name). You can only have one condition like your example.

So, to solve this you should use template code where you want to display the nick (if set) or the full name. The template code would look something like this:

{if $node.object.data_map.nick.content|eq("")}
    {attribute_view_gui attribute=$node.object.data_map.first_name}  {attribute_view_gui attribute=$node.object.data_map.last_name}
{else}
    {attribute_view_gui attribute=$node.object.data_map.nick} 
{/if}

You would then use this template code in wherever you want to show the users profile.

Hope this helps.

--bård

Documentation: http://ez.no/doc

André R.

Tuesday 14 October 2008 1:25:25 am

Bård is correct, but a slight tweak would be to use .has_content as it's more cross datatype safe:

{if $node.object.data_map.nick.has_content}
   {attribute_view_gui attribute=$node.object.data_map.nick} 
{else}
   {attribute_view_gui attribute=$node.object.data_map.first_name} {attribute_view_gui attribute=$node.object.data_map.last_name}
{/if}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Jon Arvid Ludviksen

Tuesday 14 October 2008 1:36:17 am

Thanks Bård. Yes, it has been some time. And now I'm using eZ.. :-)

Too bad that it's not possible to have that condition. But no harm, <nick|first_name> will have to do. My curiosity led me to the question as I didn't want to use the template code to accomplish it.

And André, I would definitely use has_content. Not as messy as Bårds code. :-)

Bård Farstad

Tuesday 14 October 2008 6:16:29 am

Jon Arvid,

we also accept patches for improvements here :)

It would of course be possible to extend this syntax to something like:
<nick|first_name,last_name>
or
<nick|first_name:last_name>

Should not be that much work to modify this function.

-bård

Documentation: http://ez.no/doc

Piotrek Karaś

Thursday 16 October 2008 10:54:46 am

Hi guys,

Just would like to support the availability of more advanced syntax in the future versions of eZ. Object names are very useful especially for they are pre-fetched. We could definitely find some interesting uses for more complex pattern rules.

Cheers,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

A Fowler

Wednesday 22 September 2010 1:00:35 pm

"

Hi guys,

Just would like to support the availability of more advanced syntax in the future versions of eZ. Object names are very useful especially for they are pre-fetched. We could definitely find some interesting uses for more complex pattern rules.

Cheers,
Piotrek

"

I second the request. We have the exact same situation, where we would like to allow the user to have a nick or pen name, but if they don't give one, it falls back to their first_name and last_name, which are two separate fields.

Is this supported yet in eZ Publish? It's 2010 now...

Thanks!

A Fowler

Wednesday 22 September 2010 1:42:11 pm

"
"

Hi guys,

Just would like to support the availability of more advanced syntax in the future versions of eZ. Object names are very useful especially for they are pre-fetched. We could definitely find some interesting uses for more complex pattern rules.

Cheers,
Piotrek

"

I second the request. We have the exact same situation, where we would like to allow the user to have a nick or pen name, but if they don't give one, it falls back to their first_name and last_name, which are two separate fields.

Is this supported yet in eZ Publish? It's 2010 now...

Thanks!

"

According to http://issues.ez.no/6908, it seems to have been solved, and the syntax is as follows: <nickname|(<firstname> <lastname>)>. I'm about to test it.