[SOLVED] Search page-hierarchy UDT breaks site
Posted: Tue Feb 12, 2013 6:25 pm
Hello!
CMS MS: 1.11.4
CMSMailer 5.2.1
CMSPrinting 1.0.3
FileManager 1.4.3
MenuManager 1.8.5
MicroTiny 1.2.5
ModuleManager 1.5.5
News 2.12.10
Search 1.7.7
ThemeManager 1.1.7
CGExtensions 1.31.4
JQueryTools 1.2.3
MleCMS 1.11.4
MultiDomains 2.1.1
CGSimpleSmarty 1.5.2
CompanyDirectory 1.17
CGGoogleMaps 2.4.3
I am trying to set up the Search so that it only display results from a specified parent page and it's children. Original post: http://forum.cmsmadesimple.org/viewtopic.php?t=41537
The reason for this is because i am setting up a multi-domain site. And i want the search module to only display pages from a specific site.
For example the page structure could look like this:
site one (1)
Site 1 page 1 (1.1)
Site 1 page 2 (1.2)
Site two (2)
Site 2 page 1 (2.1)
Site 2 page 2 (2.2)
But when i insert the UDT call in a page or template the site breaks. (No CSS, no error msg)
I have tried mixing around with it, and reading here on the forum but i can't figure out what the problem is.
UDT:
Search module result template (This should only display results from parent 2 and it's children 2.1 and 2.2)
Menu template (if that has anything to do with it)
Any ideas what the problem could be? Or do you need more information?
Big thanks in advance for taking the time to help!
/Regards
- Larry
CMS MS: 1.11.4
CMSMailer 5.2.1
CMSPrinting 1.0.3
FileManager 1.4.3
MenuManager 1.8.5
MicroTiny 1.2.5
ModuleManager 1.5.5
News 2.12.10
Search 1.7.7
ThemeManager 1.1.7
CGExtensions 1.31.4
JQueryTools 1.2.3
MleCMS 1.11.4
MultiDomains 2.1.1
CGSimpleSmarty 1.5.2
CompanyDirectory 1.17
CGGoogleMaps 2.4.3
I am trying to set up the Search so that it only display results from a specified parent page and it's children. Original post: http://forum.cmsmadesimple.org/viewtopic.php?t=41537
The reason for this is because i am setting up a multi-domain site. And i want the search module to only display pages from a specific site.
For example the page structure could look like this:
site one (1)
Site 1 page 1 (1.1)
Site 1 page 2 (1.2)
Site two (2)
Site 2 page 1 (2.1)
Site 2 page 2 (2.2)
But when i insert the UDT call in a page or template the site breaks. (No CSS, no error msg)
Code: Select all
{all_content assign='children' parent_hierarchy='00001'}
UDT:
Code: Select all
/*$params['assign']*/
/*$params['parent_hierarchy']*/
if (!empty($params['assign']) && !empty($params['parent_hierarchy'])){
global $gCms;
$contentops =& $gCms->GetContentOperations();
$all_content = $contentops->GetAllContent(false);
$assign = array();
foreach($all_content as $one_page){
if (strpos($one_page->mHierarchy, $params['parent_hierarchy']) === 0){
$assign[] = $one_page->mAlias;
}
}
$smarty = $gCms->GetSmarty();
$smarty->assign($params['assign'], $assign);
}
Code: Select all
{assign var="nocount" value=0}
{if $itemcount > 0}
<ul>
{foreach from=$results item=entry}
{all_content assign='children' parent_hierarchy='00001'}
{foreach from=$children item=child}
{cms_selflink href=$child assign='childurl'}
{if $childurl == $entry->url}
{assign var="show" value="no"}
{/if}
{/foreach}
{if $show != "no"}
<li><a href="{$entry->url}">{$entry->title}</a> ({$entry->weight}%){$entry->id}</li>
{*
You can also instantiate custom behaviour on a module by module basis by looking at
the $entry->module and $entry->modulerecord fields in $entry
ie: {if $entry->module == 'News'}{News action='detail' article_id=$entry->modulerecord detailpage='News'}
*}
{else}
{assign var="nocount" value=$nocount+1}
{/if}
{assign var="show" value=""}
{/foreach}
</ul>
{else}
<ul></ul>
{/if}
{if $nocount == $itemcount}
<p><strong>{$noresultsfound}</strong></p>
{/if}
Code: Select all
{* CSS classes used in this template:
#menuwrapper - The id for the <div> that the menu is wrapped in. Sets the width, background etc. for the menu.
#primary-nav - The id for the <ul>
.menuparent - The class for each <li> that has children.
.menuactive - The class for each <li> that is active or is a parent (on any level) of a child that is active. *}
{assign var='number_of_levels' value=10000}
{if isset($menuparams.number_of_levels)}
{assign var='number_of_levels' value=$menuparams.number_of_levels}
{/if}
{if $count > 0}
<div id="menuwrapper">
<ul id="primary-nav">
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string='<ul class="unli">' times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string='</li></ul>' times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}
{if $node->parent == true or $node->current == true}
{assign var='classes' value='menuactive'}
{if $node->parent == true}
{assign var='classes' value='menuactive menuparent'}
{/if}
{if $node->children_exist == true and $node->depth < $number_of_levels}
{assign var='classes' value=$classes|cat:' parent'}
{/if}
<li class="{$classes}"><a class="{$classes}"
{elseif $node->type == 'sectionheader' and $node->haschildren == true}
<li class="menuparent"><a class="menuparent"><span class="sectionheader">{$node->menutext}</span></a>
{elseif $node->type == 'sectionheader'}
<li><a ><span class="sectionheader">{$node->menutext}</span></a>
{elseif $node->type == 'separator'}
<li style="list-style-type: none;"> <hr class="menu_separator" />
{elseif $node->children_exist == true and $node->depth < $number_of_levels and $node->type != 'sectionheader' and $node->type != 'separator'}
<li class="menuparent"><a class="menuparent"
{else}
<li>
<a
{/if}
{if ($node->type != 'sectionheader' and $node->type != 'separator') or $node->parent == true or $node->current == true }
{if $node->target}target="{$node->target}" {/if}
href="{$node->url}"><span>{$node->menutext}</span></a>
{/if}
{/foreach}
{repeat string='</li></ul>' times=$node->depth-1}
</li>
</ul>
<div class="clearb"></div>
</div>
{/if}
Big thanks in advance for taking the time to help!
/Regards
- Larry