Product | Technical support | Version | Video exhibits | Manuals | Job Search | Contact
English   menu-arrow-gray-horizontal.gif
Home > Support > Inserting HTML from External Projects
Related information
Search


Video demonstration
Drag&drop in the Visual PHP™ Environment

Latest video samples:
Job Search
Company
E-VISION International s.r.o.

is looking for PHP 5 and JavaScript programmers for long-term cooperation.




More information ...
Wrote about Visual PHP™
News by e-mail
Your e-mail

Visual PHP Recommends
For Visual PHP™
(for work in both the developer and the administration interface), we recommend using the Mozilla Firefox web browser, on the basis of which the whole software is developed because of stability, complying with the W3C standards and protecting elements of the browser.

Inserting HTML from External Projects

In some cases it is necessary to insert an HTML code into pages that is regularly generated by another server. The method using inserting this code into IFRAME is commonly used, but this method brings a number of problems (from the impossibility of styling the content with ease up to SEO optimizations). Visual PHP™ contains the download() function that downloads URL content from a foreign server and returns the content into a variable. The content of this variable can be displayed directly in the content of the pages in a usual way.

Properties of the Download Function 

The download function is defined as follows:
function download($url, $post=array(), $cookies=array(), $params=array())
The following parameters can be given to this function:

$url An URL address to be downloaded. (This may be an HTML page or a file link.)
$post A field with parameters that is send using the POST method. (It is used to simulate downloading the content generated by forms.)
$cookies A field with the parameters of the content of cookies. (Some servers verify the content of cookies, e.g. for logging in.)
$params A field with parameters extending the settings of this function.

timeout The number of second upon the lapse which the function aborts downloading.
Default value: 20 s
followRedirect In the case of redirection by means of HTTP REDIRECT this redirection follows.
Default value: true
headersOnly It will return HTTP headers only. (This allows e.g. getting the size of a file before downloading it or determining whether a page exists.)
Default value: false
headersAsArray If the headersOnly option is on, it will return HTTP headers parsed as an array.
Default value: false
agent User Agent – A header in which browsers send their name, version and platform or browser robots are identified by means of it. You can identify a server this way, e.g. as FireFox 3 under Windows or googlebot.

The aforementioned parameters $post, $cookies and $params can be used on such servers only on which a CURL extension is available. If it be to the contrary, you can use the $url parameter only (and load using the GET method only).

Displaying Downloaded Content on Your Own Pages

At the beginning, it is necessary to understand that it is not possible to insert a complete downloaded page into pages. All pages contain the headers <head> and the body <body>. If we enter this code as a whole into the pages, the page would break completely and lose its validity. Consequently, it is necessary for an URL from which we download the data to contain the HTML of the content only and not the complete HTML page. That is why it is necessary to have such clean content prepared by the operator of external pages. This has the advantage that such contain displayed will respect CSS styles defined on your local pages.

An example of a script for downloading and displaying content
$content = download("http://www.domena.cz/export/obsah.html");

echo $content;

Sharing Content on Your Own Project under Visual PHP™

For the case you want certain parts of a Web site to be shared by your projects under Visual PHP™, we will show you how to prepare such content. It is necessary to create such script on a remote server from which we want to load data that will generate the content. As an example, we will give the script that will return the HTML of the content of a list of the last 5 news. Go to the Presentation -> Scripts menu, create a new script with tid, e.g. news_export, and insert the following source code into it:
$content = getTable("news")->getContent("itemsPerPage=5,orderBy=date DESC,template=news_export");

echo $content;
exit;

The getContent method of a table object functions completely in the same way as a Table Content component – consequently, it will return the content of a table processed by a template. We will display this content in the script and use the exit command to terminate the processing. Thanks to this termination, neither the content of the global layout nor the <head> headers nor other tags but the clean HTML of the content of the list of news will be displayed.

In the project that is to load and display this content, you have only to enter the following PHP code to the place where it is required:
$content = download("http://www.domena.cz/scripts.php?tid=news_export");

echo $content;




NOTICE

Some properties published in this article can only be functional with the latest core version. If you have any older core version, we recommend you to update to the latest version.

Login
Free trial

for 30 days
Latest core version
Single Developer 1.7.9.680
january 20, 2012

Professional 1.7.9.680
january 20, 2012

Enterprise 1.7.9.680
january 20, 2012


Latest developer guide
Developer Guide 1.0.5
july 10, 2009 9:36:42 AM

Latest user guide
Administrator Guide 1.0.24
august 27, 2010 11:58:08 AM

Latest install script
install.php 1.9.22
april 12, 2012 6:02:40 PM

Comming up in next version
more ...

rss.gif
Support

Fotogalerie 5/10/2012
Section: Tvorba prezentací
Chyba v hromadné korespondenci, nelze odeslat příloha (nová verze 4/6/2012
Section: Bug reporty
AntiSpam obrázek 4/6/2012
Section: Programování
Chyba při opravách textů 4/4/2012
Section: Bug reporty
Admin může smazat Developera, je to ok? 3/27/2012
Section: Bug reporty
Mapa webu 3/19/2012
Section: Tvorba prezentací


rss.gif
News

Weather Component Update
november 18, 2011
Server weather.com decided to stop providing weather information for free and passed to the paid version (about $ 60 per month). For this reason, we were forced to modify the Weather component to pulling weather information from another data source, namely from the server www.worldweatheronline.com . This site also provides information about weather all around the world, but the amount of information is smaller than the original source.

For proper functionality of the Weather component please update core to version 1.7.9.638.
Added new tutorials
october 4, 2011
He added new instructions Using another HTML editor
Powered by Visual PHP ™
© 2008 - 2010 E-VISION International, s.r.o.
Product | Technical support | Version | Video exhibits | Manuals | Job Search | Contact