Forums / Setup & design / Object name pattern for class

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

eZ debug

Timing: Jan 18 2025 04:55:30
Script start
Timing: Jan 18 2025 04:55:30
Module start 'content'
Timing: Jan 18 2025 04:55:30
Module end 'content'
Timing: Jan 18 2025 04:55:30
Script end

Main resources:

Total runtime0.1812 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 589.0781181.6641
Module start 'content' 0.00760.0056 770.7422102.3281
Module end 'content' 0.01310.1680 873.0703530.5547
Script end 0.1811  1,403.6250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00361.9815200.0002
Check MTime0.00140.7628200.0001
Mysql Total
Database connection0.00060.355910.0006
Mysqli_queries0.126569.79611410.0009
Looping result0.00140.74511390.0000
Template Total0.167792.510.1677
Template load0.00080.458110.0008
Template processing0.166892.058010.1668
Override
Cache load0.00060.330010.0006
Sytem overhead
Fetch class attribute can translate value0.00140.785710.0014
XML
Image XML parsing0.00020.128010.0002
General
dbfile0.00935.1583200.0005
String conversion0.00000.003430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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