Forums / Developer / Determine page URL using eZContentObject::fetchByRemoteID
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
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
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.
Tuesday 17 March 2009 1:47:10 pm
Thanx man...
Really kind of you to answer my question...
Jey
Tuesday 17 March 2009 4:59:13 pm
Worked like a charm, thanks so much!