\t "author":"[+json_author+]", \t "description":"[+json_description+]", \t "introtext":"[+json_introtext+]" \t}, TPL; $json_tpl_last = <<<TPL \t{ \t "title":"[+json_pagetitle+]", \t "link":"[(site_url)][~[+id+]~]", \t "date":"[+json_createdon+]", \t "guid":"[(site_url)][~[+id+]~]", \t "author":"[+json_author+]", \t "description":"[+json_description+]", \t "introtext":"[+json_introtext+]" \t} TPL; $json_footer = <<<TPL ] } TPL; // --------------------------------------------------- // Pass JSON Templates To Snippet // --------------------------------------------------- $header = isset($header) ? $header : template::replace($json_placeholders, $json_header); $tpl = isset($tpl) ? $tpl : "@CODE:" . $json_tpl; $tplLast = isset($tplLast) ? $tplLast : "@CODE:" . $json_tpl_last; $footer = isset($footer) ? $footer : $json_footer; // set emptytext $noResults = " ";
[+xml_xsl+] <xml version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"> \t\t<channel> \t\t\t\t<title>[*pagetitle*]</title> \t\t\t\t<link>[+xml_link+]</link> \t\t\t\t<description>[*description*]</description> \t\t\t\t<language>[+xml_lang+]</language> \t\t\t\t<copyright>[+xml_copyright+]</copyright> \t\t\t\t<ttl>[+xml_ttl+]</ttl> TPL; $xml_tpl = <<<TPL \t\t<item> \t\t\t<title>[+xml_pagetitle+]</title> \t\t\t<link>[(site_url)][~[+id+]~]</link> \t\t\t<summary><![CDATA[ [+xml_introtext+] ]]></summary> \t\t\t<date>[+xml_createdon+]</date> \t\t\t<createdon>[+xml_createdon+]</createdon> \t\t\t<author>[+xml_author+]</author> \t\t\t[+tags+] \t\t</item> TPL; $xml_footer = <<<TPL \t\t\t</channel> </xml> TPL; // set template values $header = isset($header) ? $header : template::replace($xml_placeholders, $xml_header); $tpl = isset($tpl) ? $tpl : "@CODE:" . $xml_tpl; $footer = isset($footer) ? $footer : $xml_footer; // set emptytext $noResults = " ";
xml:lang="[+atom_lang+]" xml:base="[(site_url)]"> \t<id>[(site_url)][~[*id*]~]</id> \t<title>[*pagetitle*]</title> \t<link rel="self" type="text/xml" href="[+atom_link+]" /> \t<author><name>[(site_name)]</name></author> \t<updated>[+atom_lastmodified+]</updated> \t<generator>Ditto 2.0 running on MODx</generator> TPL; $atom_tpl = <<<TPL \t<entry> \t\t<title>[+atom_escaped_pagetitle+]</title> \t\t<link rel="alternate" type="text/html" href="[+url+]" /> \t\t<author><name>[+atom_author+]</name></author> \t\t<id>[+url+]</id> \t\t<updated>[+atom_editedon+]</updated> \t\t<published>[+atom_createdon+]</published> \t\t<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">[+summary+]</div></content> \t</entry> TPL; $atom_footer = <<<TPL </feed> TPL; // set template values $header = isset($header) ? $header : template::replace($atom_placeholders, $atom_header); $tpl = isset($tpl) ? $tpl : "@CODE:" . $atom_tpl; $footer = isset($footer) ? $footer : $atom_footer; // set emptytext $noResults = " ";
\t<channel> \t\t\t<title>[*pagetitle*]</title> \t\t\t<link>[+rss_link+]</link> \t\t\t<description>[*description*]</description> \t\t\t<language>[+rss_lang+]</language> \t\t\t<copyright>[+rss_copyright+]</copyright> \t\t\t<ttl>[+rss_ttl+]</ttl> TPL; $rss_tpl = <<<TPL \t\t\t<item> \t\t\t\t<title>[+rss_pagetitle+]</title> \t\t\t\t<link>[(site_url)][~[+id+]~]</link> \t\t\t\t<description><![CDATA[ [+summary+] ]]></description> \t\t\t\t<pubDate>[+rss_date+]</pubDate> \t\t\t\t<guid isPermaLink="false">[(site_url)][~[+id+]~]</guid> \t\t\t\t<dc:creator>[+rss_author+]</dc:creator> \t\t\t\t[+tagLinks+] \t\t\t</item> \t\t TPL; $rss_footer = <<<TPL \t</channel> </rss> TPL; // set template values $header = isset($header) ? $header : template::replace($rss_placeholders, $rss_header); $tpl = isset($tpl) ? $tpl : "@CODE:" . $rss_tpl; $footer = isset($footer) ? $footer : $rss_footer; // set emptytext $noResults = " ";
function tagLinks($tags, $tagDelimiter, $tagID = false, $format = "html") { global $ditto_lang, $modx; if (count($tags) == 0 && $format == "html") { return $ditto_lang['none']; } else { if (count($tags) == 0 && ($format == "rss" || $format == "xml" || $format == "xml")) { return "<category>" . $ditto_lang['none'] . "</category>"; } } $output = ""; if ($this->sort) { ksort($tags); } // set templates array $tplRss = "\r\n" . "\t\t\t\t<category>[+tag+]</category>"; $tpl = $this->tpl == false ? '<a href="[+url+]" class="ditto_tag" rel="tag">[+tag+]</a>' : $this->tpl; $tpl = ($format == "rss" || $format == "xml" || $format == "atom") && $templates['user'] == false ? $tplRss : $tpl; if ($this->displayMode == 1) { foreach ($tags as $tag) { $tagDocID = !$tagID ? $modx->documentObject['id'] : $tagID; $url = ditto::buildURL("tags={$tag}&start=0", $tagDocID); $output .= template::replace(array('url' => $url, 'tag' => $tag), $tpl); $output .= $format != "rss" && $format != "xml" && $format != "atom" ? $this->displayDelimiter : ''; } } else { if ($format != "rss" && $format != "xml" && $format != "atom" && $this->displayMode == 2) { $tagList = array(); foreach ($tags as $tag) { $tagDocID = !$tagID ? $modx->documentObject['id'] : $tagID; $url = ditto::buildURL("tags={$tag}&start=0", $tagDocID); $tagList[] = template::replace(array('url' => $url, 'tag' => $tag), $tpl); } $output = $modx->makeList($tagList, $ulroot = 'ditto_tag_list', $ulprefix = 'ditto_tag_', $type = '', $ordered = false, $tablevel = 0); } } return $format != "rss" && $format != "xml" && $format != "atom" ? substr($output, 0, -1 * strlen($this->displayDelimiter)) : $output; }
eval("?>" . $this->out); } private function getDefaultEndTags() { //Custom } private function getDefaultBeginTags() { $this->replace('TPL_TITLE', 'Website Title !'); $this->replace('TPL_CSS', $this->TPLDIR . $this->model . '/design/' . $this->design . '/css/' . $this->css . '.css'); //$this->replace('TPL_CHARSET', CHARSET); $this->replace('TOP3', '<a href="?lang=fr"><img src="templates/default/design/default/icones/langs/french.png"></a> <a href="?lang=en"><img src="templates/default/design/default/icones/langs/english.png"></a>'); } } $Init = new template(); //$Init->setModel('default(2)'); $Init->replaceBoucle('MENUCONTENU,TMENU', 5, 'BOUCLEM'); $Init->replace('MENUCONTENU.1', '{TMENU}'); $Init->replace('MENUCONTENU.2', '{TMENU}'); $Init->replaceBoucle('MENUCONTENU.5,TMENU.5', 2, 'BOUCLEM.5'); $Init->replaceBoucle('TCONTENU,CONTENU', 3, 'BOUCLEC'); $Init->replaceBoucle('CONTENU.2', 2); $Init->replaceBoucle('CONTENU.3', 3); $Init->replaceBoucle('CONTENU.3.1', 2); $Init->replace('CONTENU.1', "Hello world"); $Init->getPage('pro'); $array['error1'] = "My firest error"; $array['error2'] = "My second error"; $Init->replace('TMENU.5.1', 'Messages'); $Init->replace('MENUCONTENU.5.1', $Init->getMessages($array)); $Init->getDisplay(false);