Cchost/Static HTML Pages

From Creative Commons
Revision as of 10:53, 12 November 2008 by Fourstones (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Docs Home Install Upgrade Troubleshoot Customize Admins Devs Content Query Templates Commands Skins


The easiest way to create pages is to author them directly in ccHost.

However if you have HTML pages authored outside ccHost you can add pages 'manually' into your system.

  1. Create a file with either a html or php extension
  2. Place the file into <local_files>/pages
  3. To see your page, browse to <your_installation_root>/docs/<filename_without_extension>

The command for viewing documents is docs (or alias viewfile). The parameter is the name of a PHP file in <local_files>/pages (Admins control what the actual path is in the 'docs Path' found in Global Settings -> Paths (admin/paths).

For example, create a file <local_files>/pages/credits.php

You can display that file via:

 http://ccmixter.org/viewfile/credits   OR
 http://ccmixter.org/docs/credits

(Leave off the PHP from the URL command)

Since the docs command is the default command you don't even have to specify the command in the browser.

 http://ccmixter.org/credits

Not strictly 'static'

For PHP developers there are actually several dozen variables and a template-safe set of PHP calls immediately available.

Inspecting available variables

All of the variables available are in a variable called $A for 'array'. You can dump these by putting the following code into your PHP script:

 <?
    CCDebug::Enable(true);
    CCDebug::PrintVar($A);
 ?>

Template functions available

The template object used to render your page is a variable called $T for 'template'.

Some method of interest may be:

 // To embed the results of another template in the system:

 $T->Call('path_to_template_file_or_macro');
 // To use a ccHost string lookup ('str_' prefix)
 // You can also pass variable argument list ala sprintf

 $T->String('string_id');
 // To find a file in the skins locations (include javascript,
 // css and images)

 $T->URL('partial_path_to_file');

There are a set of template friendly PHP functions you could use:

 // returns an array of settings from config
 cc_get_config($configName)

 // embeds a query directly into the page
 cc_query_fmt($qstring,$debug=0)

 // chop a string and append an ellipse
 cc_strchop($str,$maxlen)