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.