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.

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

eZ debug

Timing: Jan 30 2025 00:51:34
Script start
Timing: Jan 30 2025 00:51:34
Module start 'layout'
Timing: Jan 30 2025 00:51:34
Module start 'content'
Timing: Jan 30 2025 00:51:34
Module end 'content'
Timing: Jan 30 2025 00:51:34
Script end

Main resources:

Total runtime0.0197 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.1328151.2109
Module start 'layout' 0.00690.0024 739.343836.6484
Module start 'content' 0.00930.0086 775.9922106.7500
Module end 'content' 0.01780.0019 882.742245.9922
Script end 0.0197  928.7344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002613.3300140.0002
Check MTime0.00115.8207140.0001
Mysql Total
Database connection0.00147.265310.0014
Mysqli_queries0.002211.318930.0007
Looping result0.00000.095410.0000
Template Total0.00147.010.0014
Template load0.00115.329110.0011
Template processing0.00031.620910.0003
Override
Cache load0.00073.617510.0007
General
dbfile0.002311.622080.0003
String conversion0.00000.030240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs