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

eZ debug

Timing: Jan 18 2025 04:08:44
Script start
Timing: Jan 18 2025 04:08:44
Module start 'content'
Timing: Jan 18 2025 04:08:45
Module end 'content'
Timing: Jan 18 2025 04:08:45
Script end

Main resources:

Total runtime0.8332 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0104 588.9922180.8125
Module start 'content' 0.01040.6906 769.8047607.6328
Module end 'content' 0.70100.1322 1,377.4375337.3672
Script end 0.8332  1,714.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.5045210.0002
Check MTime0.00170.2028210.0001
Mysql Total
Database connection0.00100.116110.0010
Mysqli_queries0.756490.78012020.0037
Looping result0.00210.24932000.0000
Template Total0.796295.620.3981
Template load0.00220.259120.0011
Template processing0.794095.295420.3970
Template load and register function0.00010.016710.0001
states
state_id_array0.00130.159110.0013
state_identifier_array0.00150.180520.0008
Override
Cache load0.00180.2178370.0000
Sytem overhead
Fetch class attribute can translate value0.00140.167040.0003
Fetch class attribute name0.00150.184270.0002
XML
Image XML parsing0.00150.181740.0004
class_abstraction
Instantiating content class attribute0.00000.002380.0000
General
dbfile0.00240.2929340.0001
String conversion0.00000.000830.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs