Determine page URL using eZContentObject::fetchByRemoteID

Author Message

Jim Thaxton

Monday 16 March 2009 9:14:20 pm

How can I get the URL using this eZ Api call for another application to display the page? Do I need to make another API call or should I get be getting the data from dataMap()? Thanks!
--Jim

Web Developer
Coupon Cabin
Chicago, IL

Jean-Yves Zinsou

Tuesday 17 March 2009 1:47:04 am

Hi there,

What you can do is, once you got the object, get his main node and the url of this node:

     $obj = eZContentObject::fetchByRemoteID($id);
$main_node=$obj->mainNode();
$url=$main_node->urlAlias  (  );   	
 

Code not tested, but it gives you some track to follow..

Hope this helps !!
Jey

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

André R.

Tuesday 17 March 2009 1:55:37 am

$obj           = eZContentObject::fetchByRemoteID( $id );
$mainNode = $obj->attribute('main_node');
$urlAlias     = $mainNode->attribute('url_alias');

// to get same effect as |ezurl() in templates
$relativeUrl = $urlAlias;
eZURI::transformURI( $relativeUrl );

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

Jean-Yves Zinsou

Tuesday 17 March 2009 2:14:42 am

Oh my god ! so many mistakes in my code .... Thanx André

@ André : Question :
Using
eZContentObject::mainNode ( ) and eZContentObjectTreeNode::urlAlias ( )
as
$main_node=$obj->mainNode() and $url=$main_node->urlAlias ( );

Is wrong ?

By the way thanx for the tip on eZURI::transformURI( $relativeUrl );

jey

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

André R.

Tuesday 17 March 2009 12:00:35 pm

Not wrong, but using attribute makes the code a bit more future proof according to official saying.
According to unofficial saying the overhead of using attribute is bigger then the frequency of changes that would make attribute worth using, but you didn't hear that from me :)

But if you make patches for eZ Publish, use attribute.

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

Jean-Yves Zinsou

Tuesday 17 March 2009 1:47:10 pm

Thanx man...

Really kind of you to answer my question...

Jey

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

Jim Thaxton

Tuesday 17 March 2009 4:59:13 pm

Worked like a charm, thanks so much!

Web Developer
Coupon Cabin
Chicago, IL

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 21:41:56
Script start
Timing: Jan 30 2025 21:41:56
Module start 'layout'
Timing: Jan 30 2025 21:41:56
Module start 'content'
Timing: Jan 30 2025 21:41:56
Module end 'content'
Timing: Jan 30 2025 21:41:56
Script end

Main resources:

Total runtime0.0323 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.3906151.2422
Module start 'layout' 0.00600.0054 739.6328220.7500
Module start 'content' 0.01140.0196 960.38281,005.9922
Module end 'content' 0.03100.0013 1,966.375037.9922
Script end 0.0323  2,004.3672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00267.9461140.0002
Check MTime0.00103.2295140.0001
Mysql Total
Database connection0.00072.064010.0007
Mysqli_queries0.003912.137430.0013
Looping result0.00000.046510.0000
Template Total0.00092.810.0009
Template load0.00072.255810.0007
Template processing0.00020.560610.0002
Override
Cache load0.00051.479010.0005
General
dbfile0.00030.924380.0000
String conversion0.00000.033940.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