Last month began our look at PostNuke (http://www.postnuke.com), a popular PHP-based Web site framework. Out of the box, PostNuke provides a modular and customizable interface for building community Web sites. However, PostNuke's default setup is only intended as a starting point. So this month we'll look at some ways to add features and flavor to your PostNuke site.
Last month began our look at PostNuke (http://www.postnuke.com), a popular PHP-based Web site framework. Out of the box, PostNuke provides a modular and customizable interface for building community Web sites. However, PostNuke’s default setup is only intended as a starting point. So this month we’ll look at some ways to add features and flavor to your PostNuke site.
|Figure One: Basic PostNuke site customization|
Reusing the PostNuke installation from last month (instructions are available in the May 2002 column, also online at http://www.linux-mag.com/2002-05/lamp_01.html), we’ll start by customizing the Administration menu. Log in as the administrative user, click on Administration and then click Preferences.
The Preferences page controls the basic attributes of your PostNuke site. While the list of items you can customize is extensive, you can probably get by (at least initially) with only adjusting cosmetic items: site name, slogan, logo, and e-mail address. (Many settings won’t be meaningful until you’ve been running your site a while; once you’ve gained experienced with PostNuke, they will become more useful.)
Figure One shows the top section of the Preferences page after a few simple changes. After you’ve made your changes, click the Save Changes link to save them. Then go back to the Administration menu. (You may want to check out your home page to see your changes. You’ll probably find yourself jumping back and forth a few times to get things adjusted to your liking.)
Several readers have pointed out that we never clearly explained what LAMP is all about. LAMP is an acronym for Linux, Apache, MySQL, and PHP/Perl/Python — the platform upon which Open Source users often build their Web applications. The term originated in Europe as a simple name for this powerful combination of technologies and quickly caught on around the world.
One of the common complaints about PostNuke is that it looks a little, well … dull. If you’d like to dress up your site a little, you’ll find that there are a lot of downloadable themes available for PostNuke.
Themes are largely the result of the PostNuke team’s work to separate the “display logic” from the true “application logic” in the PHP code. By cleanly separating much of the user interface and providing basic guidelines, they’ve made it easy for anyone who knows about Web design and Cascading Style Sheets (CSS) to produce a theme. (See http://www.w3c.org/Style/CSS/ for more on CSS.)
If you’ve ever downloaded or experimented with creating skins for Mozilla or a GTK-based application, you’ll have a good idea of what’s possible with PostNuke themes. A theme in PostNuke is a collection of images, style sheets (.css files), and bits of PHP code. PostNuke comes with two themes included (PostNuke and ExtraLite) which can be found in the themes subdirectory of your PostNuke installation.
Each theme is stored in its own subdirectory. Installing a new theme is as easy as copying the theme’s directory into place under themes. PostNuke will automatically detect the new theme and present it in the list of available themes.
Let’s try downloading and installing some new themes. First, head over to the PostNuke themes site (http://themes.postnuke.com/) and click the download link and then the Themes link. What you’ll find are some individual themes and a multi-part Theme Pack, which is an archive containing hundreds of themes. The easiest way to try out a number of themes is to download the theme pack and experiment with it.
Once you’ve downloaded the theme pack, you’ll need to unzip the archives:
$ unzip PHP5_ML_Themes_PN.zip
$ unzip PHP5_ML_Themes_2_PN.zip
$ unzip PHP5_ML_Themes_3_PN.zip
What you’re left with are a few small files and larger archives, such as PHP5_ML_Themes_PN.rar. You’re probably wondering what a .rar file is. The RAR archive isn’t a very common format. It’s similar to ZIP, ARJ, and others. To find the software to unpack the archive, check your Linux distribution or visit the Freshmeat project page for RAR (http://freshmeat.net/projects/rar/). RPM and Debian packages are also available.
Once rar is installed, you can extract all the theme files from the archive:
$ rar x PHP5_ML_Themes_PN.rar
$ rar x PHP5_ML_Themes_2_PN.rar
$ rar x PHP5_ML_Themes_3_PN.rar
|Figure Two: The XP-Silver theme|
After you’ve unpacked the archive, you’ll see a themes directory with almost 300 themes to try. To try them out, copy some (or all) of them into the themes subdirectory of your PostNuke installation:
# mv themes/* /www/nuke/themes
and visit the the My Account page on your PostNuke site. Click on Select theme, choose a theme from the list, and click Save Changes. Figure Two shows our PostNuke site with the XP-Silver theme, from the third theme pack. Figure Three illustrates the Maroon theme, and shows that themes can control fonts and font sizes as well as images and colors.
|Figure Three: The Maroon theme and larger fonts|
As you experiment with themes, you’ll quickly discover that they can radically alter the appearance of your site. The XP-Silver and Maroon themes are some of the tamer options. If you poke around enough, you’ll eventually encounter themes that use audio, animated images, and even Shockwave Flash animation.
Aside from allowing users to select a theme, you can set the default theme for new visitors to your site (those not logged in). To do this, simply go back to the Preferences page and select a default theme. Then log out and log back in again to verify that your default theme works.
|Figure Four: Block administration in PostNuke|
It’s easy to customize the various rectangular areas that contain the elements on your PostNuke site. (PostNuke calls these areas “blocks”; in Slashcode they’re known as “Slashboxes”, or simply boxes.) If you don’t like the order or placement of the blocks, you can adjust them on the Advanced Blocks Administration page, shown in Figure Four. Head over to the Administration menu again and click on the Blocks link.
You can adjust every block’s title, position, and weight. The position, either left or right, controls which side of the page the block appears on. The weight is used to change the order of blocks from top to bottom on the page. If you’d like the “Who’s Online” block to appear at the top of the page, it’s just a matter of increasing its weight a few times. If you’d like to remove it entirely, just click the Delete button for that block.
Moving existing blocks around really isn’t all that interesting if you’re not happy with the types of blocks you’re working with. Luckily, PostNuke comes with a number of pre-built blocks that you can add to your site. It’s easy to add a new poll or the top headlines from Slashdot or Linux Today.
|Figure Five: Block administration in PostNuke|
Scroll down on the Advanced Blocks Administration page and you’ll see a form for adding a new block. All you need to do is supply a title and select the type of block you’d like to use (HTML, Generic Menu, Plain Text, Random Quotes, RSS Newsfeed, etc.). To add a new block, enter a title (“Slashdot”), select a type (“RSS Newsfeed”), and click on Create Block. Next you’ll see the “Block page in Figure Five.
To configure the block, simply do the following:
- Select Slashdot from the RSS File URL menu
- Pick the position and weight you’d like the block to have
- Make sure to enable the “Activate?” check-box (if you don’t, the block will not appear)
- Select a refresh time (how often you’d like it to refresh the list of headlines)
- ClickSave block
That’s it. Go back to your home page and you’ll have a block displaying the latest Slashdot headlines.
If you find yourself wanting a block to do something that’s not already part of PostNuke, try visiting the PostNuke Block site (http://blocks.postnuke.com/). The site is loaded with information about building your own blocks as well as blocks you can download and use.
Scratching the Surface
Themes and blocks are two of the more visual (and fun) ways to customize your PostNuke site. If you’re so inclined, you can even jump into the PHP code and produce themes or blocks on your own.
If custom blocks and themes are still not enough, you can extend the entire PostNuke system through the use of modules. Modules are subsystems — blocks, images, HTML, and code — that add custom features to the PostNuke framework. Modules have been developed to add bulletin boards, calendars, address books, and galleries to PostNuke.
We’ve only scratched the surface of what can be done with PostNuke. Its built-in blocks and other modules provide a lot of flexibility.
Spend some time experimenting with PostNuke and you’ll probably stumble across a few gems. If you come up with an idea for a new block or modification but don’t know how to get started or don’t want to do the programming yourself, head over to the PostNuke Web site (http://www.postnuke.com/). The PostNuke developer community is full of hackers and coders looking for ideas to implement.
Jeremy Zawodny uses Open Source tools in Yahoo! Finance by day and is is writing a MySQL book for O’Reilly & Associates by night. You can reach him at Jeremy@Zawodny.com.
Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62