Forums / Developer / Absolute referencing an attached image in xml text

Absolute referencing an attached image in xml text

Author Message

Andrew K

Monday 19 March 2007 3:20:46 pm

I've created an extension that will email the content output of an object to a specified email address. These objects have an xml text block that will be referencing attached images and node links. The problem is that the urls are referenced relative to the install of eZ. I need the referenced absolutely with the domain name, so that when people view these in their email they will be able to see the image.

Here's how I'm pulling the xml content in the action handler php...

$object =& eZContentObject::fetch( $objectID );
$nodeID = $object->attribute( 'main_node_id' );
$dataMap = $object->dataMap();
$body =& $dataMap['body']->content();
$bodyOutput =& $body->attribute('output');
$bodyOutputText = $bodyOutput->attribute('output_text');

If I include a link to a node or a image it will show up like this...

<img src="/var/tcbc/storage/images/media/images/sample_image/2153-1-eng-US/sample_image_small.jpg" width="125" height="94"  style="border: 0px;" alt="" title="" />
<a href="/">node link here</a>

Is there a php function I can use to get the absolute url for everything referenced in the xml block?

Thanks.

--Andrew

Bruce Morrison

Monday 19 March 2007 3:39:09 pm

Hi Andrew

Try adding the following before your code:

include_once( "lib/ezutils/classes/ezhttptool.php" );
$http =& eZHTTPTool::instance();
$http->UseFullUrl = true;

HTH

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Andrew K

Monday 19 March 2007 3:53:03 pm

Yup. That did it.

Where is this type of stuff documented? I would really like to know what php functions I have available when coding an extention.

Thanks Bruce.

--Andrew

Heath

Monday 19 March 2007 4:19:50 pm

There exists a wealth of knowledge within the eZ publish kernel source code itself. Much of this code is documented inline, take a long look at the generated source code documentation built from the subversion trunk very regularly.

<i>http://pubsvn.ez.no/doxygen/</i>

hth

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Bruce Morrison

Monday 19 March 2007 4:20:03 pm

Hi Andrew

It's not that I know of. The best places to look is the doxygen documentation (generated from the source) http://pubsvn.ez.no/doxygen/index.html and the source code.

I stumbled across this one. Noticed the setting when investigating the set/layout module and followed it through the source from there. There is quite a bit in eZ like this.

Be aware it causes issues with mailto: links http://issues.ez.no/IssueView.php?Id=7904

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish