Object name pattern for class

Author Message

Marc Boon

Thursday 02 March 2006 8:33:18 am

I want to specify an attribute of an atribute of the class in the object name pattern.

For example, I have a class of type 'Country Folder', which contains as a required attribute the country, of datatype ymccountry, and some optional other attributes like map and flag images.

I would like to use the country name from the country attribute to appear as the object name. Otherwise, I have to add another text line attribute containing the country name, and including all translations for my multi-language site, which seems redundant, since these names are already contained in the ymccountry datatype.

I tried object name pattern like <country.name>, <country.data_map.name>, <country.title> etc, but they all didn't work, giving a blank name.

Any suggestions?

Sergiy Pushchin

Thursday 02 March 2006 9:08:00 am

Hi as far as I understand this is your own datatype, right?
If so you need to define function "title" in your datatype, this function should return a string, which than will be used in object name.

   /*!
     Returns the content of the string for use as a title
    */
    function title( &$contentObjectAttribute )
    {
       $countryObject = $contentObjectAttribute->attribute('content');
        return $countryObject->attribute( 'name' );
    }

I do not know your datatype (how is it written and what is returned as datatype content) so the code above mostprobably will not work for it. ;)

Marc Boon

Thursday 02 March 2006 9:42:53 am

It's actually a datatype from Contributions:
http://ez.no/community/contribs/datatypes/ymc_country

It does contain a function title():

function title( &$contentObjectAttribute )
{
    $data =& $this->countryInformation( $contentObjectAttribute );
    return $data['name'];
}

But using <country.title> or just <country> doesn't give me the title in the content tree.
How should I specify the object name pattern?

Sergiy Pushchin

Thursday 02 March 2006 2:04:52 pm

I'll check this contribution, maybe I can help you.
It is not possible to use attributes of attributes, so if the identifier of your attribute is in the class is country, then you can only use name pattern <country> and make sure that function title of the datatype returns string you need. I'll look to this datatype probably tomorrow.

Regards,
SP

Sergiy Pushchin

Thursday 02 March 2006 2:14:50 pm

Ok, I have not tested it, but from the code of the datatype it looks like to use name of the chosen country in the object name pattern you should just write identifier of your class attribute:

<country>

please let me know if it does not work.. make sure that you used correct identifier of your class attribute..

Marc Boon

Friday 03 March 2006 12:42:08 am

I had already tried <country> and it didn't work, but for a different reason.
After changing the object name pattern of a class, the names of existing objects are not updated, even after clearing all caches. You have to re-publish each existing object individually in order for the object name to be updated.

Ɓukasz Serwatka

Friday 03 March 2006 12:45:38 am

Hi Marc,

eZ publish has PHP script which you can use and update object names.

From eZ publish root directory run

php -s site_access update/common/scripts/updatecontentobjectname.php

Remember do make backup before run the script.

For full list of available options run:

php update/common/scripts/updatecontentobjectname.php -h

Useful might be also script, updateniceurls.php which updates nice urls
update/common/scripts/updateniceurls.php

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

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 18 2025 11:25:11
Script start
Timing: Jan 18 2025 11:25:11
Module start 'layout'
Timing: Jan 18 2025 11:25:11
Module start 'content'
Timing: Jan 18 2025 11:25:12
Module end 'content'
Timing: Jan 18 2025 11:25:12
Script end

Main resources:

Total runtime0.9495 sec
Peak memory usage4,096.0000 KB
Database Queries71

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 589.3438152.6250
Module start 'layout' 0.00790.0037 741.968839.4453
Module start 'content' 0.01160.9365 781.4141636.5078
Module end 'content' 0.94810.0014 1,417.921916.1641
Script end 0.9495  1,434.0859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.4211160.0002
Check MTime0.00160.1727160.0001
Mysql Total
Database connection0.00240.254110.0024
Mysqli_queries0.875092.1538710.0123
Looping result0.00080.0809690.0000
Template Total0.899894.820.4499
Template load0.00240.257920.0012
Template processing0.897494.506320.4487
Template load and register function0.00020.019610.0002
states
state_id_array0.00290.302910.0029
state_identifier_array0.00480.500620.0024
Override
Cache load0.00210.2263460.0000
Sytem overhead
Fetch class attribute can translate value0.00060.059030.0002
Fetch class attribute name0.00140.148190.0002
XML
Image XML parsing0.00110.117630.0004
class_abstraction
Instantiating content class attribute0.00000.0025110.0000
General
dbfile0.00110.1111240.0000
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 38
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs