Useful Resources for sNusers

Print This Page
Pages:  Main  Adding Content  Template Structure  HTML Entity Conversion
Utilities:  HTML Entity Converter
Styles and Designing:  CSS Resource Links
Templates:  sNews Templates
Templates Ported with sNews 1.5-rc3:  GoFlexible
Converting HTML Entities for sNews CMS

Converting HTML Entities

This page considers a couple of ways to present raw code within quoteboxes so that a viewer may copy the code directly from the page and paste it into their own location.

Example 1

Figure 1 contains a couple of PHP language variables from within the snews.php file. We can use span-class styles - defined in the styles.css file - to colorize each part of the code strings. The colors define each part of the string... the array variable, the definition, and the text displayed by the definition wherever it is located throughout a given file (snews.php in this case). This works fine as long as the code displayed does not contain HTML entities.

$l['login'] = "Login";
$l['login_error'] = "Error message goes here"; // Insert your login error message here
Example 2

The goal here is to display functional code that is full of HTML entities. If we just copy and paste it into place the traditional way... everything from the first HTML entity on will not display. You can replace each HTML entity manually with its character replacement but that takes a lot of time. To speed this up, we can convert all the HTML entities into their character equivalents at once, using this utility. It runs as a stand-alone add-on (no modification required for sNews). After converting, copying and pasting your code into the quotebox in your HTML page, you'll then need to add line-returns to the end of each line where they should be, and spacing where spacing is required for indentation. Otherwise, it will all display as one continuous paragraph with no line breaks as shown in Figure 2. Figure 3 shows the same code block with line-returns and spacing added manually.

function userblock() { global $user, $cookie, $db, $user_prefix; if((is_user($user)) AND ($cookie[8])) { $sql = "SELECT ublock FROM ".$user_prefix."_users WHERE user_id='$cookie[0]'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $title = ""._MENUFOR." $cookie[1]"; themesidebox($title, $row[ublock]); } }
function userblock() {
   global $user, $cookie, $db, $user_prefix;
     if((is_user($user)) AND ($cookie[8])) {
      $sql = "SELECT ublock FROM ".$user_prefix."_users WHERE user_id='$cookie[0]'";
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $title = ""._MENUFOR." $cookie[1]";
      themesidebox($title, $row[ublock]);

And there you have it... functional PHP code you can copy from the screen.

HTML Entity Converter

If you would like to install the HTML Converter on your sNews website, you are welcome to download it.
1. Un-zip the file and copy the utilities folder into your sNews site's root directory.
2. Open the page in your browser by adding utilities/htmlentities.php to your site's URL.
3. The page has no styled template. You can open the file in your code editor and add your own HTML template to it.