Ok first off this snippet works mostly but there is an issue with it. You have to add extra spaces to all the snippet calls or else modx strips them all out.
I kind of dont understand this issue. I’m I’m trying to simply display data wh ywould it all be stripped out?
You can see the snippet in action here:
http://www.liquidthemes.com/theme-testing/wordpress-themes/greentrack.web
and take note how all the snippet calls have extra spaces in them to allow them ot be left alone. I tried after the highliting to take the spaces back out but most of the snippets are still stripped out the funny thing is modx still leaves some of them alone.
anyway maybe others looking at this can find a way arround the issue
# DisplayTemplateCode - MODx - 2005-08-15
# Created By: Brook Humphrey - [email protected]
# Usage: [[DisplayTemplateCode?template=TemplateName]]
# If no tempalte is given then it will pull the template for the current page
$output = "";
# grab template from db.
# If no template name is passed, use current page
$table = $etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix'];
if (!isset($template)) {
$template = $etomite->documentObject['template'];
$sql = "SELECT * FROM ".$table."site_templates WHERE id = ".$template;
} else {
$sql = "SELECT * FROM ".$table."site_templates WHERE templatename LIKE '%".$template."%'";
}
$result = $etomite->dbQuery($sql);
$rowCount = $etomite->recordCount($result);
if ( $rowCount!=1 ) $etomite->messageQuit("Incorrect number of templates returned from database", $sql);
$row = $etomite->fetchRow($result);
$documentSource = $row['content'];
$documentSource = str_replace("[(", "[ (", $documentSource);
$documentSource = str_replace("[[", "[ [", $documentSource);
$documentSource = str_replace("[*", "[ *", $documentSource);
$documentSource = str_replace("[~", "[ ~", $documentSource);
$documentSource = str_replace("[^", "[ ^", $documentSource);
# If template code is not found, display message
if($documentSource == "") {
$output = "Error -- " . $template . " is either an invalid name or is empty.";
}
# If template code exists, process it for display
else {
# Add PHP Begin and End tags and use highlight_string() to colorize the code
$output = highlight_string("<?php\n\n".chr(13).$documentSource."\n\n?>", true);
# Create an array containing the lines of code
$temp = explode(chr(13), $output);
# Calculate how many lines of code we have
$limit = count($temp);
# Open a fieldset to hold the snippet code or error message
$output = "<fieldset><legend>$template</legend><font color='#000000'>";
# Loop through array of formatted code, scrapping the first and last lines which have the PHP Begin and End tags
for ($y = 1; $y < $limit-1; $y++) $output .= $temp[$y];
# Insert some padding and close the fieldset
$output .= "</font><br /><br /></fieldset>";
#$output = str_replace("[ (", "[(", $output);
#$output = str_replace("[ [", "[[", $output);
#$output = str_replace("[ *", "[*", $output);
#$output = str_replace("[ ~", "[~", $output);
#$output = str_replace("[ ^", "[^", $output);
}
return $output;
# END of Code
oh and sorry it still says etomite but I know it’s working like it is and dont want to mess it up by changing a bunch of things right before i post it here without testing.