<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.creativecommons.org/index.php?action=history&amp;feed=atom&amp;title=Cchost%2Fdeveloper%2FCommon_HOWTO%27s</id>
		<title>Cchost/developer/Common HOWTO's - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.creativecommons.org/index.php?action=history&amp;feed=atom&amp;title=Cchost%2Fdeveloper%2FCommon_HOWTO%27s"/>
		<link rel="alternate" type="text/html" href="https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;action=history"/>
		<updated>2026-05-09T10:24:13Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;diff=19734&amp;oldid=prev</id>
		<title>Fourstones: Cchost/developer/customize moved to Cchost/developer/Common HOWTO's</title>
		<link rel="alternate" type="text/html" href="https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;diff=19734&amp;oldid=prev"/>
				<updated>2008-11-12T11:06:50Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;a href=&quot;/wiki/Cchost/developer/customize&quot; class=&quot;mw-redirect&quot; title=&quot;Cchost/developer/customize&quot;&gt;Cchost/developer/customize&lt;/a&gt; moved to &lt;a href=&quot;/wiki/Cchost/developer/Common_HOWTO%27s&quot; title=&quot;Cchost/developer/Common HOWTO&amp;#039;s&quot;&gt;Cchost/developer/Common HOWTO&amp;#039;s&lt;/a&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 11:06, 12 November 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Fourstones</name></author>	</entry>

	<entry>
		<id>https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;diff=19732&amp;oldid=prev</id>
		<title>Fourstones at 10:54, 12 November 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;diff=19732&amp;oldid=prev"/>
				<updated>2008-11-12T10:54:24Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;amp;diff=19732&amp;amp;oldid=19619&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Fourstones</name></author>	</entry>

	<entry>
		<id>https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;diff=19619&amp;oldid=prev</id>
		<title>Fourstones at 20:18, 6 November 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;diff=19619&amp;oldid=prev"/>
				<updated>2008-11-06T20:18:52Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 20:18, 6 November 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:ccHost]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:ccMixter]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Developer]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Software]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Technology]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{draft}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{lowercase}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Where your custom code lives=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Where your custom code lives=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;All files with a .PHP extension that reside in the &amp;lt;local_files&amp;gt;/lib directory will be parsed and executed on every page request to a ccHost installation. Where &amp;lt;local_files&amp;gt; is the name of the directory the administrator specified during installation as to where site customizations reside.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;All files with a .PHP extension that reside in the &amp;lt;local_files&amp;gt;/lib directory will be parsed and executed on every page request to a ccHost installation. Where &amp;lt;local_files&amp;gt; is the name of the directory the administrator specified during installation as to where site customizations reside.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l330&quot; &gt;Line 330:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 338:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; define ( 'URL_TO_WIZBANG_ADMIN', 'admin/wizbang' );&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; define ( 'URL_TO_WIZBANG_ADMIN', 'admin/wizbang' );&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;deifne &lt;/del&gt;( 'NAME_OF_WIZBANG_CONFIG', 'wizbang' );&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;define &lt;/ins&gt;( 'NAME_OF_WIZBANG_CONFIG', 'wizbang' );&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; // Register to get notified when the admin menu is being built&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; // Register to get notified when the admin menu is being built&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Fourstones</name></author>	</entry>

	<entry>
		<id>https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;diff=19561&amp;oldid=prev</id>
		<title>Fourstones: New page: =Where your custom code lives= All files with a .PHP extension that reside in the &lt;local_files&gt;/lib directory will be parsed and executed on every page request to a ccHost installation. Wh...</title>
		<link rel="alternate" type="text/html" href="https://wiki.creativecommons.org/index.php?title=Cchost/developer/Common_HOWTO%27s&amp;diff=19561&amp;oldid=prev"/>
				<updated>2008-11-02T18:17:44Z</updated>
		
		<summary type="html">&lt;p&gt;New page: =Where your custom code lives= All files with a .PHP extension that reside in the &amp;lt;local_files&amp;gt;/lib directory will be parsed and executed on every page request to a ccHost installation. Wh...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Where your custom code lives=&lt;br /&gt;
All files with a .PHP extension that reside in the &amp;lt;local_files&amp;gt;/lib directory will be parsed and executed on every page request to a ccHost installation. Where &amp;lt;local_files&amp;gt; is the name of the directory the administrator specified during installation as to where site customizations reside.&lt;br /&gt;
&lt;br /&gt;
=Add or remove form fields=&lt;br /&gt;
==Editing the fields of the form==&lt;br /&gt;
Sometimes you may want to change the fields in a form that already exists in the system (e.g. the upload content form). In order to add form fields, remove them or change some properties on existing one, you first need to register a handler for the CC_EVENT_FORM_FIELDS event and direct it to a PHP function.&lt;br /&gt;
&lt;br /&gt;
This event is triggered every time a form is built, but before the HTML is generated for it. The 'form' parameter is a reference to an object derived from CCForm and 'fields' parameter is a reference to an array that has all the current information about the fields.&lt;br /&gt;
&lt;br /&gt;
===Add fields===&lt;br /&gt;
Put the following into a module with a .PHP extension into the &amp;lt;local_files&amp;gt;/lib directory:&lt;br /&gt;
&lt;br /&gt;
 // 1. Register for form_fields event&lt;br /&gt;
 CCEvents::AddHandler(CC_EVENT_FORM_FIELDS, 'form_fields_handler');&lt;br /&gt;
 &lt;br /&gt;
 // 2. Here's the handler&lt;br /&gt;
 function form_fields_handler( &amp;amp;$form, &amp;amp;$fields )&lt;br /&gt;
 {&lt;br /&gt;
     // 3. Uncomment these lines to peek into the variables...&lt;br /&gt;
        // CCDebug::Enable(true);&lt;br /&gt;
        // CCDebug::PrintVar($form);&lt;br /&gt;
 &lt;br /&gt;
     // 4. Here is where we check to see if it's a form we care about&lt;br /&gt;
 &lt;br /&gt;
     if( is_subclass_of($form,'CCUploadMediaForm') ||&lt;br /&gt;
                    is_subclass_of($form,'ccuploadmediaform') )&lt;br /&gt;
     {&lt;br /&gt;
            /*&lt;br /&gt;
            * 5. Check if the field already in the field list. &lt;br /&gt;
            *&lt;br /&gt;
            * The name of our example field is 'upload_bpm' - you can&lt;br /&gt;
            * name yours whatever you like.&lt;br /&gt;
            *&lt;br /&gt;
            */&lt;br /&gt;
            if( empty($fields['upload_bpm']) )&lt;br /&gt;
            {&lt;br /&gt;
                // 6. The field does not exist, let's add it...&lt;br /&gt;
                  &lt;br /&gt;
                $fields['upload_bpm'] = &lt;br /&gt;
                            array( 'label'  =&amp;gt; 'Tempo',&lt;br /&gt;
                                   'form_tip'   =&amp;gt; 'Please enter the tempo in beats per minute',&lt;br /&gt;
                                    'class'     =&amp;gt; 'form_input_short',&lt;br /&gt;
                                   'formatter'  =&amp;gt; 'textedit',&lt;br /&gt;
                                   'flags'      =&amp;gt; CCFF_NOUPDATE);&lt;br /&gt;
             }&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All forms in the system are of a particular class so you can check for the class name or a derivation of that class in order to make sure you have the right. In step 4. above we are only interested in content submit forms.&lt;br /&gt;
&lt;br /&gt;
Always check to see if the field you are adding hasn't already been added and if you are deleting or editing that the field actually exists using the PHP 'empty()' as in step 5. above.&lt;br /&gt;
&lt;br /&gt;
===Remove an existing field===&lt;br /&gt;
If you want to remove a field completely from the forum you use PHP's '''unset'''. Replace step 5 above with something like:&lt;br /&gt;
&lt;br /&gt;
  if( isset($fields['topic_name']) )&lt;br /&gt;
  {&lt;br /&gt;
     unset( $fields['topic_name'] ); // this will remove the topic name field from form&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This can have bad side-effects if the system's form POST handling code expects the field to be there. A better option may be to hide the field in the form:&lt;br /&gt;
&lt;br /&gt;
  $form-&amp;gt;SetHiddenField( 'topic_name' );&lt;br /&gt;
&lt;br /&gt;
===Edit existing fields===&lt;br /&gt;
If you want to change the properties of field (like say, change the Topic Name field from a 'textedit' to a larger 'textarea' when submitting a form message or review) it would look something like this:&lt;br /&gt;
&lt;br /&gt;
        if( is_subclass_of($form,'CCTopicForm') ||&lt;br /&gt;
                    is_subclass_of($form,'cctopicform') )&lt;br /&gt;
        {&lt;br /&gt;
            /*&lt;br /&gt;
            * First we check to make sure the field exists at all&lt;br /&gt;
            */&lt;br /&gt;
            if( !empty($fields['topic_name']) )&lt;br /&gt;
            {&lt;br /&gt;
                // override whatever was there with 'textarea'&lt;br /&gt;
 &lt;br /&gt;
                $fields['topic_name']['formatter'] = 'textarea';&lt;br /&gt;
             }&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
==Pre-filling the field with values==&lt;br /&gt;
Sometimes a record in the system is edited and we have a custom field in the form we would want to pre-populate the value (like when the user selects 'Edit Properties' for an upload). In order to set the value of field before it is displayed to the user, you need to capture the event that is triggered as the form is populating with values:&lt;br /&gt;
&lt;br /&gt;
    CCEvents::AddHandler(CC_EVENT_FORM_POPULATE,  'form_populate_handler');&lt;br /&gt;
 &lt;br /&gt;
    function form_populate_handler(&amp;amp;$form,&amp;amp;$values)&lt;br /&gt;
    {&lt;br /&gt;
        // check to see if it's the kind of form we &lt;br /&gt;
        // care about...&lt;br /&gt;
 &lt;br /&gt;
        if( !is_subclass_of($form,'CCUploadMediaForm') &amp;amp;&amp;amp;&lt;br /&gt;
                    !is_subclass_of($form,'ccuploadmediaform') )&lt;br /&gt;
        {&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        // $values might have our value in it (in the case&lt;br /&gt;
        // of an upload &amp;quot;Edit Properties&amp;quot; form &lt;br /&gt;
        if( !empty($values['upload_extra']['bpm']) )&lt;br /&gt;
        {&lt;br /&gt;
            $value = $values['upload_extra']['bpm'];&lt;br /&gt;
 &lt;br /&gt;
            // Call 'SetFormValue' with our value...&lt;br /&gt;
 &lt;br /&gt;
            $form-&amp;gt;SetFormValue( 'upload_bpm', $value );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Validating your form field's user input==&lt;br /&gt;
If you've added a new field you must validate the user's input and notify them if something causes the value to be rejected. This is phase of the form POST handling where the code extracts the value from PHP's $_POST array and transfers the data to ccHost's field list.&lt;br /&gt;
&lt;br /&gt;
Here's the hook and hanlder for that scenario:&lt;br /&gt;
&lt;br /&gt;
    CCEvents::AddHandler(CC_EVENT_FORM_VERIFY,  'form_verify_handler');&lt;br /&gt;
 &lt;br /&gt;
    function form_verify_handler( &amp;amp;$form, &amp;amp;$retval )&lt;br /&gt;
    {&lt;br /&gt;
        if( !is_subclass_of($form,'CCUploadMediaForm') &amp;amp;&amp;amp;&lt;br /&gt;
                    !is_subclass_of($form,'ccuploadmediaform') )&lt;br /&gt;
        {&lt;br /&gt;
            // this is not a form we care about &lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        if( !array_key_exists('upload_bpm', $_POST) )&lt;br /&gt;
        {&lt;br /&gt;
            // for whatever reason, our field is not in the form _POST&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        // It's always a good idea to 'strip' user' input from a form&lt;br /&gt;
 &lt;br /&gt;
        $bpm = CCUtil::StripText($_POST['upload_bpm']);&lt;br /&gt;
        if( empty($bpm) )&lt;br /&gt;
            return;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
        $ok = 'YOUR_CODE_TO_VALIDATE_GOES_HERE';&lt;br /&gt;
 &lt;br /&gt;
        if( $ok )&lt;br /&gt;
        {&lt;br /&gt;
            // success! Set it into the form&lt;br /&gt;
 &lt;br /&gt;
            $form-&amp;gt;SetFormValue('upload_bpm',$bpm );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            // wups, stop the form post, return the user and show this error:&lt;br /&gt;
 &lt;br /&gt;
            $form-&amp;gt;SetFieldError( 'upload_bpm',  &lt;br /&gt;
                                  &amp;quot;BPM must be between 30 and 200&amp;quot; );&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         $retval = $ok; // Make to tell the form system what happened (!!!)&lt;br /&gt;
 &lt;br /&gt;
         return $ok;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Saving your form field's user input==&lt;br /&gt;
You probably want to commit the data in a form to disk for use in later sessions. When to do that depends on the operation. For example if the form you are manipulating is the upload submit form, then you should register for the even triggered when everything else in the upload has succeeded and dig your value out of $_POST. &lt;br /&gt;
&lt;br /&gt;
Here's an example we do just that:&lt;br /&gt;
&lt;br /&gt;
  CCEvents::AddHandler( CC_EVENT_UPLOAD_DONE, 'upload_done_handler' );&lt;br /&gt;
 &lt;br /&gt;
  function upload_done_handler( $upload_id, $op )&lt;br /&gt;
  {&lt;br /&gt;
        if( ($op == CC_UF_NEW_UPLOAD || $op == CC_UF_PROPERTIES_EDIT) &amp;amp;&amp;amp;&lt;br /&gt;
            array_key_exists('upload_bpm',$_POST)&lt;br /&gt;
          )&lt;br /&gt;
        {&lt;br /&gt;
            $uploads =&amp;amp; CCUploads::GetTable();&lt;br /&gt;
            $uploads-&amp;gt;SetExtraField( $upload_id, 'bpm', $_POST['upload_bpm']);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=Add data per user=&lt;br /&gt;
{{Infobox|Note: this only works in 5.0.1 or later}}&lt;br /&gt;
In order to add data to a user's record you will need their unique identifier number - this is the index key in cc_tbl_user. If you don't have it readily you should have the short user name - this is the user_name field in cc_tbl_user - and convert it to the id number. &lt;br /&gt;
&lt;br /&gt;
   $user_id = CCUser::IDFromName($user_name);&lt;br /&gt;
&lt;br /&gt;
If you are looking for the currently logged in user you can call:&lt;br /&gt;
&lt;br /&gt;
   $user_id = CCUser::CurrentUser();  // Returns -1 if failed (not logged in)&lt;br /&gt;
&lt;br /&gt;
To save your data to the user's record:&lt;br /&gt;
&lt;br /&gt;
   $users =&amp;amp; CCUsers::GetTable(); // note the 's' in CCUsers&lt;br /&gt;
   $users-&amp;gt;SetExtraField($user_id,'YOUR_DATA_KEY_GOES_HERE', 'YOUR_VALUE_GOES_HERE' );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To retrieve it at a later time:&lt;br /&gt;
&lt;br /&gt;
   $users =&amp;amp; CCUsers::GetTable();&lt;br /&gt;
   $value = $users-&amp;gt;SetExtraField($user_id,'YOUR_DATA_KEY_GOES_HERE');&lt;br /&gt;
&lt;br /&gt;
If you are using SQL you will next expand the 'user_extra' field like this:&lt;br /&gt;
&lt;br /&gt;
   $user_row = CCDatabase::QueryRow('SELECT * FROM cc_tbl_user WHERE user_id = ' . $user_id );&lt;br /&gt;
   $user_extra = unserialize($user_row['user_extra']);&lt;br /&gt;
   $value = $user_extra['YOUR_DATA_KEY_GOES_HERE'];&lt;br /&gt;
&lt;br /&gt;
If you want to remove the data key and it's value completely from the record (e.g. to save space), then use the following method:&lt;br /&gt;
&lt;br /&gt;
   $users =&amp;amp; CCUsers::GetTable();&lt;br /&gt;
   $users-&amp;gt;UnsetExtraField($user_id,'YOUR_DATA_KEY_GOES_HERE');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Add data per upload=&lt;br /&gt;
In order to add data to an upload record you will need their unique identifier number - this is the index key in cc_tbl_uploads. &lt;br /&gt;
&lt;br /&gt;
To save your data to the upload record:&lt;br /&gt;
&lt;br /&gt;
   $uploads =&amp;amp; CCUploads::GetTable();&lt;br /&gt;
   $uploads-&amp;gt;SetExtraField($upload_id,'YOUR_DATA_KEY_GOES_HERE', 'YOUR_VALUE_GOES_HERE' );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To retrieve it at a later time:&lt;br /&gt;
&lt;br /&gt;
   $uploads =&amp;amp; CCUploads::GetTable();&lt;br /&gt;
   $value = $uploads-&amp;gt;SetExtraField($upload_id,'YOUR_DATA_KEY_GOES_HERE');&lt;br /&gt;
&lt;br /&gt;
If you are using SQL you will next expand the 'upload_extra' field like this:&lt;br /&gt;
&lt;br /&gt;
   $upload_row = CCDatabase::QueryRow('SELECT * FROM cc_tbl_uploads WHERE upload_id = ' . $upload_id );&lt;br /&gt;
   $upload_extra = unserialize($upload_row['upload_extra']);&lt;br /&gt;
   $value = $upload_extra['YOUR_DATA_KEY_GOES_HERE'];&lt;br /&gt;
&lt;br /&gt;
If you want to remove the data key and it's value completely from the record (e.g. to save space), then use the following method:&lt;br /&gt;
&lt;br /&gt;
   $uploads =&amp;amp; CCUploads::GetTable();&lt;br /&gt;
   $uploads-&amp;gt;UnsetExtraField($upload_id,'YOUR_DATA_KEY_GOES_HERE');&lt;br /&gt;
&lt;br /&gt;
=Using custom data in a template=&lt;br /&gt;
The typical template will display a record that is in a loop. The custom data is probably going to be in upload_extra or user_extra depending on the type of record you are displaying.&lt;br /&gt;
&lt;br /&gt;
The PHP template version:&lt;br /&gt;
&lt;br /&gt;
  foreach( $A['records'] as $R )&lt;br /&gt;
  {&lt;br /&gt;
       if( !empty($R['upload_extra']['YOUR_DATA_KEY_HERE']) )&lt;br /&gt;
       {&lt;br /&gt;
         print &amp;lt;nowiki&amp;gt;'&amp;lt;span&amp;gt;' . $R['upload_extra']['YOUR_DATA_KEY_HERE'] . '&amp;lt;/span&amp;gt;';&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
       }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The TPL version:&lt;br /&gt;
&lt;br /&gt;
  %loop(records,R)%&lt;br /&gt;
      %if_not_null(#R/upload_extra/YOUR_DATA_KEY_HERE)%&lt;br /&gt;
          &amp;lt;nowiki&amp;gt;&amp;lt;span&amp;gt;%(#R/upload_extra/YOUR_DATA_KEY_HERE)%&amp;lt;/span&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
      %end_if%&lt;br /&gt;
  %end_loop%&lt;br /&gt;
{{Infobox|Note that the upload_extra field is not guaranteed to be available in the template. You have to ask for it specifically in the dataview that is feeding the template.}}&lt;br /&gt;
=Saving and retrieving system configuration data=&lt;br /&gt;
There may be times when you want to save data that is available across sessions that is not associated with any user or upload. You will need the CCConfigs table to do that.&lt;br /&gt;
&lt;br /&gt;
To save settings data into configs:&lt;br /&gt;
&lt;br /&gt;
  $myoptions['option1'] = 'OPTION_1_VALUE';&lt;br /&gt;
  $myoptions['option2'] = 'OPTION_2_VALUE';&lt;br /&gt;
  $configs =&amp;amp; CCConfigs::GetTable();&lt;br /&gt;
  $configs-&amp;gt;SaveConfig('YOUR_SETTINGS_NAME_HERE', $myoptions );&lt;br /&gt;
&lt;br /&gt;
To retrieve them later:&lt;br /&gt;
&lt;br /&gt;
  $configs =&amp;amp; CCConfigs::GetTable();&lt;br /&gt;
  $myoptions = $configs-&amp;gt;GetConfig('YOUR_SETTINGS_NAME_HERE');&lt;br /&gt;
  $opt_1 = $myoptions['option1'];&lt;br /&gt;
=Mapping URLs to custom code=&lt;br /&gt;
In order to map a PHP function to the url '''some/url''':&lt;br /&gt;
&lt;br /&gt;
    CCEvents::AddHandler(CC_EVENT_MAP_URLS, 'map_urls_handler');&lt;br /&gt;
 &lt;br /&gt;
    function map_urls_handler()&lt;br /&gt;
    {&lt;br /&gt;
        CCEvents::MapUrl( ccp( 'some', 'url' ), 'some_url_handler', CC_DONT_CARE_LOGGED_IN );&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    function some_url_handler_handler()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If the user appends to the URI path (e.g. '''some/url/arg1/arg2''') those will be passed in as arguments, so you should write your handler like this:&lt;br /&gt;
&lt;br /&gt;
    function some_url_handler( &amp;lt;nowiki&amp;gt;$arg1='', $arg2=''&amp;lt;/nowiki&amp;gt; )&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The last parameter in CCEvents::MapUrl determines who is allowed to process the URL. These are valid values:&lt;br /&gt;
&lt;br /&gt;
*CC_MUST_BE_LOGGED_IN    ''Registered users''&lt;br /&gt;
*CC_ONLY_NOT_LOGGED_IN   ''Anonymous users only''&lt;br /&gt;
*CC_DONT_CARE_LOGGED_IN  ''Everybody''&lt;br /&gt;
*CC_ADMIN_ONLY           ''Admins only''&lt;br /&gt;
*CC_SUPER_ONLY           ''Super admins only''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Infobox|Note: Every time you change the URL map you must perform '''?update&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;1''' on your site }}&lt;br /&gt;
&lt;br /&gt;
=Adding settings to the admin menus=&lt;br /&gt;
If you only have one or a few settings, you can it/them directly onto the admin 'Settings' page. If you have many settings (a whole screen full) things a little more verbose.&lt;br /&gt;
&lt;br /&gt;
==Adding an admin option Settings==&lt;br /&gt;
ccHost will trigger an event when it is gathering options for the admin Settings page. Capture the event and fill in the fields like this:&lt;br /&gt;
&lt;br /&gt;
  CCEvents::AddHandler(CC_EVENT_GET_CONFIG_FIELDS,  'config_fields_handler');&lt;br /&gt;
 &lt;br /&gt;
  function config_fields_handler(&lt;br /&gt;
    {&lt;br /&gt;
        if( $scope == CC_GLOBAL_SCOPE )&lt;br /&gt;
        {&lt;br /&gt;
            $fields['YOUR_SETTINGS_NAME_HERE'] =&lt;br /&gt;
               array(  'label'      =&amp;gt; 'My wizbang enabled'&lt;br /&gt;
                       'value'      =&amp;gt; 'Check here to enable my wizbang feature.',&lt;br /&gt;
                       'formatter'  =&amp;gt; 'checkbox', // any field here will work&lt;br /&gt;
                       'flags'      =&amp;gt; CCFF_POPULATE);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Adding a whole admin settings form==&lt;br /&gt;
If you have many settings you want to add you should do so by adding an admin menu item that maps to a custom url that in turn invokes the form:&lt;br /&gt;
&lt;br /&gt;
    // Let's make some defines to avoid typos and show the relationship &lt;br /&gt;
    // between key phrases &lt;br /&gt;
 &lt;br /&gt;
    define ( 'URL_TO_WIZBANG_ADMIN', 'admin/wizbang' );&lt;br /&gt;
    deifne ( 'NAME_OF_WIZBANG_CONFIG', 'wizbang' );&lt;br /&gt;
 &lt;br /&gt;
    // Register to get notified when the admin menu is being built&lt;br /&gt;
 &lt;br /&gt;
    CCEvents::AddHandler(CC_EVENT_ADMIN_MENU,  'admin_menu_handler');&lt;br /&gt;
 &lt;br /&gt;
    // This function will be called when the admin menu is about to be&lt;br /&gt;
    // generated. Add your menu item(s) to '$items'&lt;br /&gt;
 &lt;br /&gt;
    function admin_menu_handler( &amp;amp;$items, $scope )&lt;br /&gt;
    {&lt;br /&gt;
        if( $scope == CC_GLOBAL_SCOPE )&lt;br /&gt;
        {&lt;br /&gt;
            $items += array(&lt;br /&gt;
                NAME_OF_WIZBANG_CONFIG =&amp;gt; array( &lt;br /&gt;
                                 'menu_text'  =&amp;gt; 'My Wizbang Settings',&lt;br /&gt;
                                 'menu_group' =&amp;gt; 'configure',&lt;br /&gt;
                                 'help' =&amp;gt; 'Config settings for My Wizbang functionality',&lt;br /&gt;
                                 'access' =&amp;gt; CC_ADMIN_ONLY,&lt;br /&gt;
                                 'weight' =&amp;gt; 300,&lt;br /&gt;
                                 'action' =&amp;gt;  ccl( URL_TO_WIZBANG_ADMIN )&lt;br /&gt;
                                 ),&lt;br /&gt;
                );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    CCEvents::AddHandler(CC_EVENT_MAP_URLS, 'map_urls_handler');&lt;br /&gt;
 &lt;br /&gt;
    function map_urls_handler()&lt;br /&gt;
    {&lt;br /&gt;
        CCEvents::MapUrl( ccp( URL_TO_WIZBANG_ADMIN ), 'admin_mywizbang_handler', CC_ADMIN_ONLY );&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    function admin_mywizbang_handler()&lt;br /&gt;
    {&lt;br /&gt;
       require_once('&amp;lt;local_files&amp;gt;/lib/mywizbang_admin_form.inc');&lt;br /&gt;
       require_once( 'cchost_lib/cc-page.php');&lt;br /&gt;
       require_once('cchost_lib/cc-admin.php');&lt;br /&gt;
 &lt;br /&gt;
       // Build up page adornments&lt;br /&gt;
 &lt;br /&gt;
       $title = 'Admin Settings for MyWizBang';&lt;br /&gt;
       CCPage::SetTitle( $title );&lt;br /&gt;
       CCAdmin::BreadCrumbs( true, array('url'=&amp;gt;'','text'=&amp;gt;$title));&lt;br /&gt;
 &lt;br /&gt;
       // Display the form&lt;br /&gt;
       // NOTE: $_POST handling will be handled by ccHost.&lt;br /&gt;
 &lt;br /&gt;
       $form = new CCMyWizBangAdminForm();&lt;br /&gt;
       CCPage::AddForm( $form-&amp;gt;GenerateForm() );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In another file '''&amp;lt;local_files&amp;gt;/lib/mywizbang_admin_form.inc''' (do NOT use PHP extension) put code that does something like this:&lt;br /&gt;
&lt;br /&gt;
    // NB: The name of your form MUST start with 'CC' and end with 'Form'&lt;br /&gt;
 &lt;br /&gt;
    class CCMyWizBangAdminForm : extends CCEditConfigForm&lt;br /&gt;
    {&lt;br /&gt;
       function CCMyWizBangAdminForm()&lt;br /&gt;
       {&lt;br /&gt;
         $this-&amp;gt;CCEditConfigForm( NAME_OF_WIZBANG_CONFIG ); &lt;br /&gt;
 &lt;br /&gt;
         // replace these fields with something meaningful:&lt;br /&gt;
 &lt;br /&gt;
         $fields = array( &lt;br /&gt;
            'option1' =&amp;gt;  // name of the setting&lt;br /&gt;
                array(  &lt;br /&gt;
                   'label'     =&amp;gt; 'Set Option 1 here',&lt;br /&gt;
                   'form_tip'  =&amp;gt; 'Check this to enable option 1',&lt;br /&gt;
                   'value'     =&amp;gt; '',&lt;br /&gt;
                   'formatter' =&amp;gt; 'textedit',&lt;br /&gt;
                   'flags'     =&amp;gt; CCFF_POPULATE | CCFF_REQUIRED ),&lt;br /&gt;
 &lt;br /&gt;
            'option2' =&amp;gt;  &lt;br /&gt;
                array(  &lt;br /&gt;
                   'label'     =&amp;gt; 'Set Option 2 here',&lt;br /&gt;
                   'form_tip'  =&amp;gt; 'Check this to enable option 2',&lt;br /&gt;
                   'value'     =&amp;gt; '',&lt;br /&gt;
                   'formatter' =&amp;gt; 'checkbox',&lt;br /&gt;
                   'flags'     =&amp;gt; CCFF_POPULATE ),&lt;br /&gt;
 &lt;br /&gt;
           );&lt;br /&gt;
 &lt;br /&gt;
          $this-&amp;gt;SetModule(__FILE__);&lt;br /&gt;
          $this-&amp;gt;AddFormFields($fields);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;/div&gt;</summary>
		<author><name>Fourstones</name></author>	</entry>

	</feed>