How I use CMSMS on this Site
Some CMS Made Simple Modules That I've used
- Album
- Calendar
- Captcha
- Comments
- EditArea
- ErrorEmailer
- FormBuilder
- MovedPages
- News
- PicasaWebAlbumBrowser
- Printing
- RSS
Some of the User Defined Tags that I've used
Ask me and I can try to remember what they are used for an try to provide a description if you'd like. ;)
add_news_title_to_page_title
global $gCms;
$module =& $gCms->modules['News']['object'];
if (isset($module->news_title))
{
$text = $module->news_title;
if (function_exists('str_ireplace'))
{
$params['content'] = str_ireplace('<title>', '<title>'.$text. ' - ', $params['content']);
}
else
{
$params['content'] = eregi_replace('<title>', '<title>'.$text. ' - ', $params['content'] );
}
}
child_list
global $gCms;
$tpl_vars = $gCms->smarty->get_template_vars();
print_r($tpl_vars);
$i = 0;
foreach ($tpl_vars['nodelist'] AS $key => $value) {
$i++;
echo '<li>'.$value[$i]['menutext'].'</li>';
}
count_news_comments
global $gCms;
$db = &$gCms->db;
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments
WHERE page_id =".$params['thenewsid']."
AND module_name='News' AND active='1'";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;
page_alias
global $gCms;
$gCms->smarty->assign('page_alias', $gCms->variables['page_name']);
recently_updated
$output = '<div class="nav"><div class="heading">Most Recently Updated</div>';
$output .= '<ul class="links">';
global $gCms;
$hm =& $gCms->GetHierarchyManager();
$db = &$gCms->db;
// Get list of 10 most recently updated pages excluding the home page
$q = "SELECT * FROM ".cms_db_prefix()."content WHERE (type='content' OR type='link')
AND default_content != 1 AND active = 1 AND show_in_menu = 1
ORDER BY modified_date DESC LIMIT 10";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
while ($dbresult && $updated_page = $dbresult->FetchRow())
{
$curnode =& $hm->getNodeById($updated_page['content_id']);
$curcontent =& $curnode->GetContent();
$output .= '<li class="updated">';
$output .= '<a href="'.$curcontent->GetURL().'">'.$updated_page['content_name'].'</a>';
$output .= '<br />';
$output .= $updated_page['titleattribute'];
$output .= '<br />';
$output .= 'Modified: ' .$updated_page['modified_date'];
$output .= '</li>';
}
$output .= '</ul></div>';
echo $output;
table_of_contents
/**
* Generates a table of contents based on heading tags that have ids
* @example: <h2 id="packages">Packages</h2>
*/
function get_table_of_contents($page_contents)
{
// Generate table of contents
preg_match_all("/<h([[:digit:]])[[:space:]]id=\"([a-z-0-9]+)\">(.*)<\/h[0-9]>/i", $page_contents, $match);
if (FALSE == empty($match[0])) {
$contents = "<h2>Contents</h2>\n";
$contents .= "<ul>\n";
foreach ($match[0] as $key => $value) {
if (2 == $match[1][$key]) {
$contents .= '';
} else {
$contents .= ' ';
}
$contents .= '<li><a href="'.$_SERVER['REQUEST_URI'].'#'.$match[2][$key].'">'.$match[3][$key].'</a>';
// Start a new sub-list if this item has children otherwise just end the list item
if (FALSE == empty($match[1][$key + 1]) && $match[1][$key + 1] == $match[1][$key] + 1) {
$contents .= "\n <ul>\n";
$unclosed_list = TRUE;
} else {
$contents .= "</li>\n";
}
// If the next item is higher level then close this list item (I.E. current item is h3 and next is h2
if (FALSE == empty($match[1][$key + 1]) && $match[1][$key + 1] == $match[1][$key] - 1) {
$contents .= " </ul>\n</li>\n";
$unclosed_list = FALSE;
}
}
if (FALSE == empty($unclosed_list)) {
$contents .= " </ul>\n</li>\n";
}
$contents .= "</ul>\n";
} else {
$contents = '';
}
return $contents;
}
echo get_table_of_contents($params['thepagecontent']);