You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 221 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
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

Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.024 Seconds - 364 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::