// Snippet name: PoweredBy
// Snippet description: A little link to Etomite.
// Revision: 1.00 ships with Etomite 0.6.1-Final
$version = $etomite->getVersionData();
return '<a href="http://etomite.com" title="Etomite Website">Powered by Etomite <b>'.$version['version'].$version['patch_level'].'</b> <i>('.$version['code_name'].')</i>.</a>';
Etomite 0.6.1.0 Prelude Snippets All of the snippets as shipped
#31
Posted 31 May 2006 - 09:26 AM
PoweredBy - A little link to Etomite
#32
Posted 31 May 2006 - 09:27 AM
RelatedInfo - Output a related chunk into the document
// Snippet name: RelatedInfo
// Snippet description: Outputs a related chunk into the document
// Revision: 1.0 ships with Etomite 0.6.1-Final
// Author: Lloyd Borrett - 2006-04-09
// Description:
// Outputs a chunk into the document based on the
// document's alias/id, and optionally, a prefix
// passed to the chunk.
// Usage:
// Insert [[RelatedInfo]] or [[RelatedInfo?prefix=<YourPrefix>]]
// in your template where you want the required document
// specific content to appear.
// e.g. [[RelatedInfo]], [[RelatedInfo?prefix=RightColumn]],
// [[RelatedInfo?prefix=MiddleColumn]] etc.
// Create a chunk called "RelatedInfo-<value>" and/or
// "<YourPrefix>-<value>" for each document where you want
// to display document related content.
// "<value>" is the document alias (if specified), or the
// document id number if there is no alias value.
// "<YourPrefix>" is a prefix value passed to the chunk.
// For example: "RelatedInfo-home", "RelatedInfo-1",
// "MiddleColumn-home", "MiddleColumn-1" etc.
// The snippet will insert the content of your "RelatedInfo-<value>" and/or
// "<YourPrefix>-<value>" chunks into the appropriate document.
// If there is no output from "RelatedInfo-<value>" and/or "<YourPrefix>-<value>",
// typically because the chunks don't exist, the you can request that the default
// "RelatedInfo" or "<YourPrefix>" chunks are used, if they exist.
// Problem 1:
// You want to be able to put some content into a section of
// your document template. But you would like to be able to have
// different content for different documents.
// Typically this might be document related content for another
// column or something similar.
// Solution 1:
// Insert [[RelatedInfo]] into your template where you want the content to appear.
// Now create a chunk called "RelatedInfo-<value>" for each document where you want
// document specific content to appear.
// For example, if you have a document with an alias "productx",
// the chunk would be called "RelatedInfo-productx".
// If the document has no alias, then it's id value is used,
// for example "RelatedInfo-23".
// Into the "RelatedInfo-<value>" chunk you can put the content you want,
// and/or calls to other chunks and snippets.
// If you don't have document specific content for that document,
// then you can let the default content from the "RelatedInfo" chunk
// be output, if it exists.
// If there is no "RelatedInfo-<value>" or "RelatedInfo" chunks,
// then nothing is output.
// Problem 2:
// Okay so you can use [[RelatedInfo]] to do document specific
// content for say your middle column.
// But on some documents you might also might want some page
// specific extra content in another part of the document.
// For example, the right column.
// Solution 2:
// Insert [[RelatedInfo?prefix=<YourPrefix>]] into your template
// where you want the content to appear.
// Now create a chunk called "<YourPrefix>-<value>" for each page
// where you want this document specific content to appear.
// For example, you want to put some content into the right
// column of your template.
// So you put [[RelatedInfo?prefix=RightColumn]] into your template.
// And if you have a document with an alias "productx", the chunk would be
// called "RightColumn-productx". If the document has no alias,
// then it's id value is used, for example "RightColumn-23".
// Into the "<YourPrefix>-<value>" chunk you can put the content you want,
// and/or calls to other chunks and snippets.
// If you don't have document specific content for that document,
// you can let the default content from the "<YourPrefix>" chunk
// be output, if it exists.
// If there is no "<YourPrefix>-<alias>" or "<YourPrefix>" chunks,
// then nothing is output.
// Explanation:
// The power of this snippet is that a chunk doesn't have to just
// contain raw HTML code.
// The chunk can also have calls to other chunks, and even calls to snippets.
// Thus each document specific chunk you create can be extremely
// flexible in what gets put into your document, with you having
// to duplicate raw HTML code here, there and everywhere.
// (So much to explain such a simple snippet!)
// Configuration Setting
// $showDefaultCrumb [true | false]
// If there is no output from calling the crumb for the specific document,
// which typically occurs if you haven't created the crumb,
// instead of getting nothing you can ask for a default crumb
// to be used by setting this value to true.
// Of course, if you don't set up a default crumb, you still get nothing.
// If you don't want to have this feature enabled just set this value to false.
$showDefaultCrumb = true;
$output = "";
if (!isset($prefix)) {
$prefix = "RelatedInfo";
} else {
if ($prefix == "") {
$prefix = "RelatedInfo";
}
}
$alias = $etomite->documentObject['alias'];
if ($alias == "") {
$alias = $etomite->documentIdentifier;
}
$output .= $etomite->putChunk($prefix.'-'.$alias);
if ($output == "" && $showDefaultCrumb) {
$output .= $etomite->putChunk($prefix);
}
return $output;
#33
Posted 31 May 2006 - 09:28 AM
SearchForm - All-in-one snippet to search the site
// Snippet name: SearchForm
// Snippet description: All-in-one snippet to search the site
// Revision: 1.1 ships with Etomite 0.6.1-Final
$searchString =
isset($_POST['search']) &&
$_POST['search']!= "{{" &&
$_POST['search']!= "[[" &&
$_POST['search']!= "[(" &&
$_POST['search']!= "[~" &&
$_POST['search']!= "[*" ?
$_POST['search'] : "";
$SearchForm .= '<form name="SearchForm" action="" method="post">'."\n";
$SearchForm .= '<input type="text" name="search" class="text" value="'.$searchString.'" /><br />'."\n";
$SearchForm .= '<input type="submit" name="sub" class="button" value="Search" />'."\n";
$SearchForm .= '</form>';
if(isset($_POST['search']) && $_POST['search']!='') {
$search = explode(" ", $_POST['search']);
$tbl = $etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix']."site_content";
$sql = "SELECT id, pagetitle, parent, description FROM $tbl WHERE ($tbl.content LIKE '%".$search[0]."%'";
for ($x=1;$x < count($search); $x++) {
$sql .= " AND $tbl.content like '%$search[$x]%'";
}
$sql .= " OR $tbl.pagetitle LIKE '%".$search[0]."%' ";
for ($x=1;$x < count($search); $x++) {
$sql .= " AND $tbl.pagetitle like '%$search[$x]%'";
}
$sql .= " OR $tbl.description LIKE '%".$search[0]."%' ";
for ($x=1;$x < count($search); $x++) {
$sql .= " AND $tbl.description like '%$search[$x]%'";
}
$sql .= ") AND $tbl.published = 1 AND $tbl.searchable=1 AND $tbl.deleted=0;";
$rs = $etomite->dbQuery($sql);
$limit = $etomite->recordCount($rs);
if($limit>0) {
$SearchForm .= "<p>The following results were found:</p>\n";
$SearchForm .= "<table cellspacing=\"0\" cellpadding=\"0\">\n";
for ($y = 0; $y < $limit; $y++) {
$SearchFormsrc=$etomite->fetchRow($rs);
$SearchForm.="<tr><td style=\"padding: 1px\"><a href=\"[~".$SearchFormsrc['id']."~]\"><b>".$SearchFormsrc['pagetitle']."</b></a></td>\n";
$SearchForm.="<td style=\"padding: 1px\">";
$SearchForm.=$SearchFormsrc['description']!='' ? " - <small>".$SearchFormsrc['description']."</small>" : "";
$SearchForm .= "</td></tr>";
}
$SearchForm .= "</table>";
} else {
$SearchForm.="<p>Sorry, couldn't find anything!</p>";
}
}
return $SearchForm;
#34
Posted 31 May 2006 - 09:29 AM
SearchPrompt - Search prompt snippet for use with SearchResults
// Snippet name: SearchPrompt // Snippet description: Search prompt snippet for use with SearchResults // Revision: 1.00 ships with Etomite 0.6.1-Final // Use: [!SearchPrompt?resultsid=###!] snippet call where ### is the // document id of the page which contains the [!SearchResults!] snippet call $resultsDefault = "16"; // Document id to use if $resultsid not sent $resultsid = isset($resultsid) ? $resultsid : $resultsDefault; $prompt = "<br />Search this site<br />"; // Search box label text $submit = "Search"; // Submit button label $output = ' <div class="searchbox" style="text-align:center;">'.$prompt.' <form name="SearchForm" action="[~'.$resultsid.'~]" method="post"> <p><input type="text" name="search" value="" /></p> <p><input type="submit" name="sub" class="button" value="'.$submit.'" /></p> </form> </div> '; return $output;
#35
Posted 31 May 2006 - 09:30 AM
SearchResults - Displays results of SearchPrompt snippet
// SearchResults
// Displays results of SearchPrompt snippet
$noResults = "<p>No search results were found.</p>";
$resultsText = "<p>The following results were found:</p>";
$searchString =
isset($_POST['search']) &&
$_POST['search']!= "{{" &&
$_POST['search']!= "[[" &&
$_POST['search']!= "[(" &&
$_POST['search']!= "[~" &&
$_POST['search']!= "[*" ?
$_POST['search'] : "";
if(isset($_POST['search']) && $_POST['search']!='') {
$search = explode(" ", $_POST['search']);
$sql = "SELECT id, pagetitle, parent, description FROM ".$etomite->db.site_content." WHERE (content LIKE '%".$search[0]."%'";
for ($x=1;$x < count($search); $x++) {
$sql .= " AND content like '%$search[$x]%'";
}
$sql .= " OR pagetitle LIKE '%".$search[0]."%' ";
for ($x=1;$x < count($search); $x++) {
$sql .= " AND pagetitle like '%$search[$x]%'";
}
$sql .= " OR description LIKE '%".$search[0]."%' ";
for ($x=1;$x < count($search); $x++) {
$sql .= " AND description like '%$search[$x]%'";
}
$sql .= ") AND published = 1 AND searchable=1 AND deleted=0;";
$rs = $etomite->dbQuery($sql);
$limit = $etomite->recordCount($rs);
if($limit>0) {
$SearchForm .= $resultsText."<p><table cellspacing='0' cellpadding='0'>";
for ($y = 0; $y < $limit; $y++) {
$SearchFormsrc=$etomite->fetchRow($rs);
$SearchForm.="<tr><td style='padding: 1px'><a href='[~".$SearchFormsrc['id']."~]'><b>".$SearchFormsrc['pagetitle']."</b></a></td><td style='padding: 1px'>";
$SearchForm.=$SearchFormsrc['description']!='' ? " - <small>".$SearchFormsrc['description']."</small>" : "";
$SearchForm .= "</td></tr>";
}
$SearchForm .= "</table>";
} else {
$SearchForm .= $noResults;
}
}
return $SearchForm;
#36
Posted 31 May 2006 - 09:31 AM
SiteUpdate - Returns date of most recent document update
// Snippet name: SiteUpdate
// Snippet description: Returns date of most recent document update
// Revision: 1.1 ships with Etomite 0.6.1-Final
// Author: Ralph A. Dahlgren -- 2005-07-13
// Usage: [!SiteUpdate?dateFormat=%B %e, %Y!] Returns date formatted: July 13, 2005
// See strftime() documentation for additional formatting options
// Changes:
// v1.1 by Lloyd Borrett -- 2006-04-07
// Return local time based on Etomite server offset time
// Default Date/Time format to use if not sent in snippet call
$format = isset($dateFormat) ? $dateFormat : "%B %e, %Y";
// get the Etomite server offset time in seconds
$server_offset_time = $etomite->config['server_offset_time'];
if (!$server_offset_time) {
$server_offset_time = 0;
}
$sql = "SELECT editedon FROM ".$etomite->db."site_content ORDER BY editedon DESC";
$rs = $etomite->dbQuery($sql);
if ($etomite->recordCount($rs) >= 1){
$row = $etomite->fetchRow($rs);
$update= strftime($format,$row['editedon'] + $server_offset_time);
} else {
$update="";
}
return $update;


Help
This topic is locked
Back to top
MultiQuote








