[Solved] Replacing old {sitemap} tag
Posted: Sun Jun 10, 2012 5:08 am
When I finally upgraded my site to 1.10.3 I ran into problems with the {sitemap} tag that was part of previous installations. I don't know when it was discontinued and replaced by the {site_mapper} tag. Anyway, during all the previous upgrades the {sitemap} tag had survived in the plugin folder and kept working fine. Only with last upgrade to version 1.10 the output contained a number of warnings because of the use of "split" function.
I had used {sitemap} quite extensively in my pages to list sub pages. I first thought of replacing if with {site_mapper} but I realised that the new tag has no parameters to select what to show and how (class). Looking at the description I noted the new tag is anyway just a shortcut to the {menu} tag. Thus I decided to write an UDT {sitemap} that mirrors the old functionality and saves the hazzle of changing all pages that used the old tag.
This UDT uses a menu template called "Sitemap" which is based on the "minimum_menu.tpl" template.
Hope some people find it helpful.
I had used {sitemap} quite extensively in my pages to list sub pages. I first thought of replacing if with {site_mapper} but I realised that the new tag has no parameters to select what to show and how (class). Looking at the description I noted the new tag is anyway just a shortcut to the {menu} tag. Thus I decided to write an UDT {sitemap} that mirrors the old functionality and saves the hazzle of changing all pages that used the old tag.
This UDT uses a menu template called "Sitemap" which is based on the "minimum_menu.tpl" template.
Code: Select all
$gCms = cmsms(); //global $gCms;
$smarty = &$gCms->GetSmarty();
if ($params['start_element']<>'') { $start = "start_element='".$params['start_element']."'"; }
if ($params['number_of_levels']<>'') {
$levels = "number_of_levels='".$params['number_of_levels']."'";
} else {
$start = "childrenof='".$params['start_element']."'";
}
$smarty_data = "{menu template='Sitemap' ".$start." ".$levels."}";
$smarty->_compile_source('temporary template', $smarty_data, $_compiled );
@ob_start();
$smarty->_eval('?>' . $_compiled);
$_contents = @ob_get_contents();
@ob_end_clean();
echo "<div class='".$params['class']."'>".$_contents."</div>";