Wrappers


Wrappers allow you to integrate content from outside PostNuke's management system seamlessly with your Postnuke website. They essentially "wrap" the other content, such as a static HTML page, a separate web application, or even content on another website, by loading it inside PostNuke's "shell."

A PostNuke wrapper can be very useful in many instances. If you are more familiar with development tools such as Macromedia Dreamweaver or the full Studio MX 2004 suite, but require integration with a PostNuke site structure, you can create your content normally, and simply pass it to a PostNuke wrapper to handle the fusion with the PostNuke site.

Organizations with developers who are not familiar with XHTML, let alone PHP, likely use products such as Microsoft FrontPage or Microsoft Word to quickly generate web content. Their efforts can also be combined with PostNuke quite easily. You can simply have a large existing site that is being converted to PostNuke. A wrapper can simplify and speed up the conversion process to allow the new site to go online much faster than the time it would take to manually convert every file.

You can wrap a PostNuke site around non-PostNuke content in a number of ways, including manually initializing the pnAPI code in PHP, but the two easiest and most popular ways to wrap static pages are the PostWrap module and NukeWrapper script.

PostWrap

PostWrap is a full module that allows you to wrap any web content into your PostNuke site. It integrates the content using the iframe element. The iframe has the immediate drawback of completely separating the embedded content from any visual style or formatting you use in your site, but the same separation is a benefit as it allows you to use any web content, including those generated with otherwise incompatible technologies such as ASP and completely external pages and applications hosted from other servers.

Version 2.5 of PostWrap is included with this book's online materials, and you can download the most current version from the developer's site: spidean.mckenzies.net. The PostWrap archive utilizes a clean root module folder, so you should place its contents under your server's modules directory. Initialize and activate the module from the Modules Administration table.

Browse to the Administration Menu and click the new PostWrap link. Two navigation links are used to manage the module's options: General and URL Security.

General

The Display Off-site Pages? option, shown in Figure 18.1, lets you control whether external pages can be wrapped. If this toggle is set to No, PostWrap only allows pages on your local domain or server.

Figure 18.1. General settings in PostWrap 2.5.


Allow Input from Browser Address Bar? is a security feature that prevents site visitors from entering an address using the PostWrap module into their browser's address bar for browsing. With this feature enabled, only links you create can be used to go to pages wrapped by PostWrap.

The settings in the URL Security Management page are enabled by setting Compare URLs Against URL Security? to Yes. You can restrict PostWrap to display only specific pages with URL Security.

Tip

You can customize any message displayed by PostWrap by editing the language variables found at /modules/PostWrap/pnlang/eng/.


Enable Add Link for Open in New Window? and a simple link written as "[ Open in new window ]" is added above and below your embedded iframe. Clicking the link opens a new browser window and loads the wrapped contents into it.

You can add a descriptive message above and below the PostWrap iframe by setting Use Fixed Title? to Yes. The message assumes you are wrapping an external site (see Figure 18.2), but you can change the message by editing the user.php file in your languages pnlang folder for the module.

Figure 18.2. Wrapping a non-PostNuke page.


The final three options in the General Settings page allow you to set the size of the iframe window. If you set Auto-resize Window? to Yes, PostWrap uses JavaScript to dynamically resize your window. If the value is set to No, you can use the next option to manually fix the height of the window to a value of pixels. The final field sets the width of the iframe window, and it can be defined as either a pixel value or a percentage.

URL Security

The features on this page are activated after the Compare URLs Against URL Security? option is enabled in the General settings. This page allows you to define specific URLs for use with PostWrap, and each URL is maintained with its own display options. The individual options include

  • Open in New Window

  • Use Fixed Title

  • Auto-resize Window

  • Height of Viewing Window

  • Width of Viewing Window

URLs are entered with an additional Alias field. The value you enter in the field can be used to create special links to your wrapped content. For example, if you have a special application you need that exists at http://www.mysite.com/specialapp/, you can use the Alias "specialapp" in PostWrap (see Figure 18.3). Then, you can link directly to the application, wrapped in your PostNuke site by PostWrap using the following:

Figure 18.3. Defining custom settings for content in URL Security.


 <a href="/index.php?module=PostWrap&page=specialapp">Special Application</a> 

Nonaliased URLs can also be linked directly by placing the link after the &page= in the URL:

 <a href="/index.php?module=PostWrap&page=/otherpage.html">Other Page</a> <a href="/index.php?module=PostWrap&page=http://www.othersite.com/">Other site</a> 

PostWrap URLs Block

The PostWrap module also includes a handy block you can use to automatically link to wrapped URLs. All of the content you define in URL Security will be listed. Simply go to Blocks Administration for your site, and add a PostWrap/PostWrap URLs block. It only requires that you enter a title for the block and select a position.

NukeWrapper

NukeWrapper shares many of the same traits found in PostWrap in that it combines both local and external web content into a PostNuke site shell. NukeWrapper is not a PostNuke module; however, it functions as a standalone script. It also has the benefit of providing complete integration of local pages into PostNuke without the use of an iframe. Local web content is placed inside a div tag and subjected to the current styles and theme of your PostNuke site, and text files are even converted to XHTML to preserve the content.

NukeWrapper 2.3.18 is available with this book's online materials, and you can download the most current version from the developer's site: users.tpg.com.au/staer/. The archive includes release notes, optional htaccess file information, and the wrap.php script. To install NukeWrapper, simply copy the wrap.php file to your PostNuke site's root folder.

NukeWraper URLs

Content is wrapped by using specialized URL strings. The basic format just references the NukeWrapper file:

 http://www.yoursite.com/wrap.php 

Call specific files by placing them after the wrap.php file, such as this:

 http://www.yoursite.com/wrap.php?staticpage.html 

or use the long version:

 http://www.yoursite.com/wrap.php?file=staticpage.html 

External sites are wrapped using this format:

 http://www.yoursite.com/wrap.php?url=www.othersite.com 

NukeWrapper also provides two optional variables you can include in the URL: opt and idx.opt toggles themed borders around the wrapped content. It can be set to either "0" or "1." For example:

 http://www.yoursite.com/wrap.php?staticpage.html&opt=1 

The idx variable defines how blocks are displayed when viewing the wrapped content. It can have a value from "0" to "4" and is adjusted according to the following:

  • idx=0 Displays left blocks only. This is the default setting.

  • idx=1 Uses home page settings; left, right, center, and admin messages are all displayed.

  • idx=2 Displays only left and right blocks.

  • idx=3 Displays right blocks only.

  • idx=4 Displays only the header and footer. No left, right, or center blocks.

The idx options 2, 3, and 4 all require an edited theme to work. Additional checks for the $index variable are needed. For non-Xanthia PostNuke themes, this code should be used with the left column:

 <?php if ($index != 3 && $index != 4) { ?> <td  valign="top"> <!-- Begin left block --> <?php blocks('left'); ?> <!-- End left block --> </td> <?php } ?> 

And use this code with the right column:

 <?php if ($index==1 || $index==2 || $index==3) { ?> <td  valign="top"> <!-- Begin right block --> <?php blocks('right'); ?> <!-- End right block --> </td> <?php } ?> 

Tip

You can add these same idx checks to any block, in any combination. If your site uses additional block types (AutoTheme AutoBlocks, for example), simply create additional idx checks for other block types for unlimited display options.


To enable support with AutoTheme, edit the /modules/AutoTheme/autotheme.php file, and below the line:

 include($ThemePath."/theme.cfg"); 

add the following code:

 if ($index==1 || $index==2 || $index==3) $blockdisplay["right"]=true; if ($index != 3 && $index != 4) $blockdisplay["left"]=true; if ($index==4) {     $blockdisplay["right"]=false;     $blockdisplay["left"]=false;     } 

Next, open the main theme.html for your AutoTheme and add checks for the preceding display variable:

 <?php if ($block_display["left"]) { ?> <td  valign="top"> <!-- [left-blocks] --> </td> <?php } ?> 

Then add the same check for the right blocks:

 <?php if ($block_display["right"]) { ?> <td  valign="top"> <!-- [right-blocks] --> </td> <?php } ?> 

As of this writing, direct support for Xanthia themes under PostNuke .750 is not available.

NukeWraper File Locations

NukeWrapper provides a number of configuration variables at the top of the wrap.php file. Open the file and scroll to around line 87. The variable arrays $HTMLdirs and $PHPdirs define the locations where NukeWrapper will look for file content. Add the folder names to the arrays where your content can be found on your server. The paths are relative to your web server root, and not PostNuke, so you can call files from outside your PostNuke install and still wrap them.

Note

In addition to the directories defined in the $HTMLdirs and $PHPdirs arrays, Hypertext Markup Language (HTML) and text files can be called from your PostNuke root folder. To prevent linking to PostNuke system files, wrapping PHP files from the PostNuke root is not enabled by default.


For example, if your PostNuke site is installed at the root of your site, and you want to wrap files in a subdirectory called "html," use this array setting:

 $HTMLdirs = Array('/html'); 

In addition, if your PostNuke site is installed in a subdirectory called "nukesite," and you want to use both the previous subdirectory example, your web server root, and a separate folder called "files," you need these values:

 $HTMLdirs = Array('/nukesite/html', '/', '/files'); 

Other NukeWrapper Options

The other variable settings you can set within the wrap.php file include

  • $AllowPHP Toggles the ability to wrap PHP files. If the $PHPdirs array is empty, this variable is ignored. Can be set to "1" for On or "0" for Off.

  • $FixLinks Dynamically fixes the relative paths references in the wrapped file to work from the wrap.php location. Can be set to "1" for On or "0" for Off.

  • $WrapLinks Determines whether links from a wrapped page are also wrapped or opened in the full window. This variable is ignored if $FixLinks is disabled. Can be set to "1" for On or "0" for Off.

  • $AllowExtLink Toggles whether external linking is allowed. Can be set to "1" for On or "0" for Off.

  • $AllowURLs Enables the url= feature to wrap web content external to your server. Can be set to "1" for On or "0" for Off.

  • $URLs['allow'] Stores a white list of words or URLs that are allowed by NukeWrapper. All sites are allowed if this field is left blank.

  • $URLs['deny'] Stores a black list of words or URLs that are disallowed by NukeWrapper. This feature is disabled if left blank.

  • $wrapUrl Creates an alias for a short URL to make NukeWrapper references easier. For example, define this array entry: 'pnguide' =>'docs.postnuke.com/index.php?module=Static_Docs&func=view&f=/pnguide/' and you can call the long link using /wrap.php?url=pnguide.

  • $UseTables Toggles the use of themed tables and borders around the wrapped content. Can be set to "1" for On or "0" for Off.

  • $Layout Sets the default idx option. Can be set to 0, 1, 2, 3, or 4.

  • $ShowLink Determines whether the Open in New Window link is displayed for external content. Can be set to "1" for On or "0" for Off.

  • $WrapDebug Enables the output of additional debugging information. Useful for troubleshooting problems with your wrapped content. Can be set to "1" for On or "0" for Off.



    PostNuke Content Management
    PostNuke Content Management
    ISBN: 0672326868
    EAN: 2147483647
    Year: 2003
    Pages: 207
    Authors: Kevin Hatch

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net