Blocks offer a quick way to incorporate content in PHP-Nuke. They are happily used to display modules/PHP-Nuke_HOWTO/images, since they can be placed anywhere in the three layout columns - and their position can be comfortably changed from the administration panel. A very common use of blocks in PHP-Nuke is to display dynamic modules/PHP-Nuke_HOWTO/images, i.e. modules/PHP-Nuke_HOWTO/images that change depending on some parameter of dynamic nature, most offen time: a daily quote, a daily weather forecast or a daily comic.
Most of the time you will not be the original author of the quote, forecast or comic. You will want to fetch this content from some popular source on the Internet.
![]() |
Before you proceed: think on copyright! |
---|---|
We will describe the tecnology that allows you to use somebody else's work to make your site more beautiful, attractive or informative. This almost certainly touches that person's copyright. Please take the time to read the admonition on copyright in Section 8.2.3! |
PHP enables you to read a remote URL, store its whole content in one (!) variable, then search the contents of the variable for any regular expression (for regular expressions, see Section 25.3). We will use this technique to find out the filename of the User Friendly daily comic strip, in order to display it in a PHP-Nuke block. This UserFriendly block reads the User Friendly daily cartoon page line by line, searches for the pattern
whatever<IMG ALT="Latest Strip"whateverSRC="imagefile">whatever |
extracts the location of the image file (imagefile) from it and displays it in the block. The PHP code of the User Friendly block is a classic example of how you can do this "scrapping" in PHP (-Nuke):
whatever<IMG ALT="Latest Strip"whateverSRC="imagefile">whatever |
where "whatever" may be any content, including space. The regular expression contains a subexpression in the place of the image filename. This results in the file name being stored in the $out array, as its first element.
A similar technique is used in news aggregators, like the MyHeadlines module (see Section 8.3.9), that "scrap" news sources for pieces of dynamic information that are not otherwise available (i.e. not available as RSS/RDF news feeds), see Template Based Scraping. For each source page, a regular expression is stored in a table. Its subexpressions will automatically store the dynamic information pieces that are of interest to us in the elements of some $out array. We would then only have to display those elements for each source.
![]() |
Quod medicina aliis, aliis est acre venenum[1] |
---|---|
If you are an artist whose modules/PHP-Nuke_HOWTO/images are being hot-linked with the above methods without your permission, you are certainly not excited. But don't despair! You can defend your work with a simple technique that requires only the Apache mod_rewrite module and a few lines in your .htaccess file. See Section 25.6. |
[1] |
One person's medicine is another's foul poison. |
Prev | Home | Next |
How to show advertisements in PHP-Nuke blocks | Up | How to display random modules/PHP-Nuke_HOWTO/images in PHP-Nuke blocks |
Help us make a better PHP-Nuke HOWTO!Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum! Chris Karakas, Maintainer PHP-Nuke HOWTO |