Forums / Developer / Finding the url of a document?

Finding the url of a document?

Author Message

Kristofer Pettersson

Wednesday 04 January 2006 5:25:33 am

I'm trying to find the url of a particular object. For this my guess was to first find the mainNode attached to the document (ezcontentobject):

	$process_id = $this->attribute("process_id");
    	$process_document = eZContentObject::fetch( $process_id );
    	if( !is_object($process_document) ) {
			eZDebug::writeError( 'Unable to identify the process_document. Process ID = '. $process_id );
			return;
		}

    	$process_main_node = $process_document->mainNode();
    	if( !is_object($process_main_node) ) {
    		eZDebug::writeError( 'Unable to identify the process_main_node.' );
    	}
    	
    	$process_url = $process_main_node->attribute( 'url_alias' );

The above code gives me an <i>"Unable to identify the process_main_node"</i>. What should I do instead to get the URL of the $process_document?

Ɓukasz Serwatka

Tuesday 10 January 2006 3:06:13 am

Hi Kristofer,

Try with

       $process_id = $this->attribute("process_id");
       $process_document =& eZContentObject::fetch( $process_id );

       if( !is_object($process_document) ) {
                        eZDebug::writeError( 'Unable to identify the process_document. Process ID = '. $process_id );
                        return;
                }

               $nodeID = $process_document->attribute('main_node_id');
               $process_main_node =& eZContentObjectTreeNode::fetch( $nodeID );

       if( !is_object($process_main_node) ) {
               eZDebug::writeError( 'Unable to identify the process_main_node.' );
       }

       $process_url = $process_main_node->attribute( 'url_alias' );

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