Include website in another

Author Message

Aurore Hublé

Friday 15 December 2006 3:19:13 am

Hi,

I need to include a website in another. I tried to do that with php include fonction in an extension. It's work but instead of be between <div></div>, the included part is at the top.

In pagelayout.tpl I add

<div id="block-contenu">
	{web_include(''http://localhost/boutique/index.php/boutique')}

And in my extension :

function web_include($path)
{
	include($path); 
}

And the result

       ___________________________________________________
   |  included part                                    |
___|__ (http://localhost/boutique/index.php/boutique')_|
|                                                      |
|   Main website                                       |
|______________________________________________________|

instead of

 _____________________________
|                             |
|    Main website             |
|_____________________________|__________________
|     included part                              |
| (http://localhost/boutique/index.php/boutique')|
|________________________________________________|
|________________________________________________|

Kåre Køhler Høvik

Friday 15 December 2006 3:44:42 am

Hi

The include() function will output the result to the std. out output. This is displayed before any result from the templates. Make your extension function return the content instead, example:

function web_include( $path )
{
    return file_get_contents(  $path );
}

Kåre Høvik

Aurore Hublé

Friday 15 December 2006 5:05:56 am

Ok thanks !!

Mark Marsiglio

Friday 15 December 2006 5:18:12 am

I have done something similar using an iframe. It can either go in the template code directly, or using the literal html class in the Online Editor:

<iframe src ="/default.asp" width="100%" border="0">
</iframe>

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

kracker (the)

Friday 15 December 2006 7:35:00 am

Alternately you can use a php template operator as the above php function uses just one parameter (limitation).

PHP Function: '<i>file_get_contents</i>'
<i>http://us2.php.net/file_get_contents</i>

Add this line to your setting file, '<i>settings/siteaccess/example/template.ini.append.php</i>'.

[PHP]
PHPOperatorList[file_get_contents]=file_get_contents

Add this line to your pagelayout file, '<i>design/example/templates/pagelayout.tpl</i>'.

{'http://yahoo.com/'|file_get_contents()}

Alternately, if you need to use a php function using many arguments, you will want to use the 'wrap_operator' extension (in contributions). <i>http://ez.no/community/contribs/template_plugins/wrapper_operator</i>

Add this line to your setting file, '<i>settings/override/wrap_operator.ini.append.php</i>'.

[PHPFunctions]
PermittedFunctionList[]
PermittedFunctionList[]=file_get_contents

Add this line to your pagelayout file, '<i>design/example/templates/pagelayout.tpl</i>'.

{wrap_php_func('file_get_contents', 'http://google.com/' )}

Well still you could pass additional arguments as well using this method.

{wrap_php_func('file_get_contents', array( 'http://google.com/', FALSE, NULL, 0, 0 ) )}

And and after that you can write as many user defined functions in php and use them as php or template operators with the wrap_operator extension. A very flexible tool to provide for simple solutions.

Still ... beware of cache and cache block (possible) related considerations.

//kracker
<i>tv: metalocalypse</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Jianjun Hu

Saturday 07 July 2007 8:18:43 pm

Very helpful!
Thanks!

OnlyBlue

☆..·°∴°.☆°°.☆°.
°∴ °☆ .·enjoy star° .·★°∴°
∴°.°★ .·°
  ミ☆°∴°.★☆° ∴·°
°.☆° .·∴° 

Is it a pleasure after all to practice in due time what one has learnt?

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 19:32:48
Script start
Timing: Jan 18 2025 19:32:48
Module start 'layout'
Timing: Jan 18 2025 19:32:48
Module start 'content'
Timing: Jan 18 2025 19:32:48
Module end 'content'
Timing: Jan 18 2025 19:32:48
Script end

Main resources:

Total runtime0.0400 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 589.0313152.6250
Module start 'layout' 0.00500.0037 741.656339.4453
Module start 'content' 0.00870.0289 781.101697.4453
Module end 'content' 0.03760.0023 878.546938.3047
Script end 0.0400  916.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00256.3374140.0002
Check MTime0.00123.0900140.0001
Mysql Total
Database connection0.00061.537310.0006
Mysqli_queries0.00328.099930.0011
Looping result0.00020.429810.0002
Template Total0.00194.710.0019
Template load0.00092.324710.0009
Template processing0.00092.334810.0009
Override
Cache load0.00071.662410.0007
General
dbfile0.00020.602680.0000
String conversion0.00000.025640.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