Troubleshooting


These hacks require standard PHP string manipulation. If you are having regular trouble getting your code to echo properly, try reviewing the content in Chapter 19, "Dynamic PHP and PostNuke." It details the majority of the pitfalls you might encounter with PostNuke hacks.

Linefeed Characters Not Rendered

The PHP linefeed escape sequence, \n, is used a great deal in this chapter's hacks. You might find it's very easy to make a minor mistake in your code, and instead of rendering a linefeed, the sequence is echoed like common text. This effect happens because PHP renders single- and double-quoted strings differently. Single-quoted strings are handy because they let you write HTML straight, without escaping every double quote around tag attributes:

 echo '<img src="/books/1/160/1/html/2/helloworld.gif" />'; 

Because the single quote is defining the string, the double quotes are rendered as normal text. But if you include a linefeed at the end of that string inside the single quotes, it does not work:

 echo '<img src="/books/1/160/1/html/2/helloworld.gif" />\n'; 

To use both single quotes for your HTML and still include a linefeed, use the string concatenation operator and combine two strings with differing quotes:

 echo '<img src="/books/1/160/1/html/2/helloworld.gif" />'."\n"; 

The preceding example provides the best of both worlds for most simple echo lines. But keep in mind that not all PostNuke code uses this string display method.

Different people have developed the PostNuke CMS, and you will see many different methods of rendering content when working with PostNuke code. When in doubt, try to keep the style of the code you are adding or changing consistent with the code around it. It makes it easier to follow and helps to reduce the likelihood that any conflicts will occur between the original code and your changes.



    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