Programatically fetch links/images with PHP

Author Message

Felix Laate

Friday 20 January 2006 12:55:05 am

Hi all,

In an extension I'm developing I need to fetch URL's and relplace the links in the XML-output generated by the online editor:

<linktarget="_self"url_id="9">Very boring link</link>

needs to get into:

<a href="http://my.link.com">Very boring link</a>

How can I programatically do this (with PHP)?

And then I need to do the same for images..

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Bård Farstad

Friday 20 January 2006 1:33:33 am

Hi Felix,

not sure which parts you are looking for. Assuming that you already know how to parse the XML you have you can fetch the URL by id (if it's eZ publish URL's you have) like this:

       $href = eZURL::url( $linkID );

Then you can just print the href and the text to make up the URL.

--bård

Documentation: http://ez.no/doc

Felix Laate

Friday 20 January 2006 3:46:31 am

Hi Bård,

Thnak you for your answer!

This is what I need. Only problem is the I get the error <i>Undefined class name 'ezurl' </i> when I try to use it. I guess it has something to do with initiating.. a topic I don't know to much about..

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Felix Laate

Friday 20 January 2006 3:59:37 am

Hi again,

Got it! Just put:

include_once( "kernel/classes/ezurltype.php" );

at the top of my file.

Thanks for helping!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Felix Laate

Friday 20 January 2006 4:51:43 am

Me again..

Now I need the title and target of the link.. is there any good way to get a grab on these?

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

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 31 2025 01:25:15
Script start
Timing: Jan 31 2025 01:25:15
Module start 'layout'
Timing: Jan 31 2025 01:25:15
Module start 'content'
Timing: Jan 31 2025 01:25:15
Module end 'content'
Timing: Jan 31 2025 01:25:15
Script end

Main resources:

Total runtime0.0311 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.2656151.2266
Module start 'layout' 0.00520.0040 739.4922220.7188
Module start 'content' 0.00920.0205 960.21091,001.8672
Module end 'content' 0.02970.0014 1,962.078137.9922
Script end 0.0311  2,000.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00257.9197140.0002
Check MTime0.00113.3884140.0001
Mysql Total
Database connection0.00061.997410.0006
Mysqli_queries0.00289.126330.0009
Looping result0.00000.039010.0000
Template Total0.00103.210.0010
Template load0.00082.597610.0008
Template processing0.00020.613210.0002
Override
Cache load0.00061.782210.0006
General
dbfile0.00309.548980.0004
String conversion0.00000.025340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs