PHP Web Host - Quality Web Hosting For All PHP Applications Just Great Software
  Login or Register
 • Home • Downloads • Your Account • Forums • 
Site Navigation

Home:

 
Donate o Meter
Help Keep Our Servers Online AND Our Services Free!
Make donations with PayPal!
Donations
Anonymous May-24
Doulos May-15
Webservant May-11
AndyB May-5
Hotdog May-3
 
Please Link To Me!
 
Quality Web Hosting For All PHP Applications
Quality PHP Web Host!

Great Reviews!
Need help setting up your website, installing Apache, PHP, MySQL, or RavenNuke(tm)?
Need help customizing or designing scripts?
Please contact us via the Contact Us option for further details and pricing.

Link to Me

RavenPHPScripts

RavenPHPScripts

There are more Link To Me icons here.
 
Site Info v2.2.2 ©
Your IP: 38.107.179.234

 Welcome, Anonymous
Nickname
Password
Security Code:
Security Code
Type Security Code:

· Register
· Lost Password
Server Date/Time
24 May 2012 22:00:46 EDT (GMT -4)
 
How to display HTML code in a FAQ

27.4. How to display HTML code in a FAQ

Figure 27-3. Administration panel: FAQ.

Administration panel: FAQ.



Using standard tools of a Linux system, like sed and awk, you can automate code generation for some highly repetitive code fragments, like the one in the following example:

Suppose you want to display a table of smilies that are available on your system. Each row should show the smiley and the code needed to insert it in an article. The code that does the job is phpnuke-faq-code-1, for only one smiley, icon_smile.gif:

<table width='100%' border='0' cellspacing='0' cellpadding='3'>
<tr><td>
<a> <img src="./modules/Forums/images/smiles/icon_smile.gif"> </a>
</td><td><b>
&a& &img src="./modules/Forums/images/smiles/icon_smile.gif"& &/a&
</b></td></tr>
</table>

To automate the code generation process for all the smilies you have, do:

cd /usr/local/httpd/htdocs/nuke6/html
ll modules/Forums/images/smiles/* | awk '{print $9}' > smilies

That is, you change to the html directory, list all smilies from the modules/Forums/images/smiles directory and let awk print the 9th field of each line - this is the file name of the smiley. The output is redirected to the smilies file, which will thus contain a list of all smiley filenames.

Create a sed script that produces the HTML code for the smilies and put it in a file named "sedscr" (for sed script):

s/\(^.*$\)/<tr><td><a> <img src="\1"> <\/a>\
<\/td><td><b>\
\&a\& \&img src="\1"\& \&\/a\&\
<\/b><\/td><\/tr>\
/

and run sed on the previously created smilies file, using the above script as the "sed script". For this, just run the runsed script:

runsed sedscr smilies

(runsed accepts two arguments: the sed script and the file to operate on). This produces the right code for our FAQ. You just have to add

<table width='100%' border='0' cellspacing='0' cellpadding='3'>
<tr><td>

at the beginning and

</table>

at the end.


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

 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum