Forums / Developer / Determine page URL using eZContentObject::fetchByRemoteID

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

eZ debug

Timing: Jan 18 2025 05:18:36
Script start
Timing: Jan 18 2025 05:18:36
Module start 'content'
Timing: Jan 18 2025 05:18:37
Module end 'content'
Timing: Jan 18 2025 05:18:38
Script end

Main resources:

Total runtime1.7223 sec
Peak memory usage4,096.0000 KB
Database Queries208

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0078 587.9688180.7969
Module start 'content' 0.00781.4660 768.7656629.9531
Module end 'content' 1.47380.2485 1,398.7188341.0234
Script end 1.7223  1,739.7422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.2538210.0002
Check MTime0.00160.0911210.0001
Mysql Total
Database connection0.00100.056010.0010
Mysqli_queries1.628794.56272080.0078
Looping result0.00260.15272060.0000
Template Total1.685897.920.8429
Template load0.00230.132420.0011
Template processing1.683597.747020.8418
Template load and register function0.00020.008910.0002
states
state_id_array0.00100.057910.0010
state_identifier_array0.00220.126820.0011
Override
Cache load0.00200.1172390.0001
Sytem overhead
Fetch class attribute can translate value0.00310.178540.0008
Fetch class attribute name0.00200.114790.0002
XML
Image XML parsing0.00170.097440.0004
class_abstraction
Instantiating content class attribute0.00000.0029120.0000
General
dbfile0.00290.1704340.0001
String conversion0.00000.000330.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
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
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs