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

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 18 2025 10:53:51
Script start
Timing: Jan 18 2025 10:53:51
Module start 'layout'
Timing: Jan 18 2025 10:53:51
Module start 'content'
Timing: Jan 18 2025 10:53:52
Module end 'content'
Timing: Jan 18 2025 10:53:52
Script end

Main resources:

Total runtime0.8291 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.0469152.6406
Module start 'layout' 0.00540.0037 740.687539.4922
Module start 'content' 0.00910.8186 780.1797602.5391
Module end 'content' 0.82770.0013 1,382.718816.1250
Script end 0.8290  1,398.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4306160.0002
Check MTime0.00140.1669160.0001
Mysql Total
Database connection0.00070.085510.0007
Mysqli_queries0.764692.2241650.0118
Looping result0.00080.0984630.0000
Template Total0.796396.020.3981
Template load0.00190.232920.0010
Template processing0.794395.808520.3972
Template load and register function0.00020.019610.0002
states
state_id_array0.00130.159110.0013
state_identifier_array0.00070.086620.0004
Override
Cache load0.00170.2041370.0000
Sytem overhead
Fetch class attribute can translate value0.00070.082530.0002
Fetch class attribute name0.00120.148670.0002
XML
Image XML parsing0.00480.579730.0016
class_abstraction
Instantiating content class attribute0.00000.002380.0000
General
dbfile0.00570.6935230.0002
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs