WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: bupaje on July 16, 2013, 01:03:39 AM

Title: [[parentpage]]
Post by: bupaje on July 16, 2013, 01:03:39 AM
Hi. Can someone sell me how I would modify this to enclose in a div? It gets some sort of weird nested boxes so must be doing something wrong.

Code: [Select]
$info = show_menu2(0, SM2_CURR, SM2_START, SM2_ALL|SM2_BUFFER, '[if(class==menu-current){[level] [sib] [sibCount] [parent]}]', '', '', '');
list($nLevel, $nSib, $nSibCount, $nParent) = explode(' ', $info);
if ($nLevel > 0) {
        $lev = $nLevel - 1;
        return show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB|SM2_BUFFER, "[if(level==$lev){[a][menu_title]</a>}]", '', '<div class="kb_submenu"><br />', '</div>');
}

Thank you.
Title: Re: [[parentpage]]
Post by: bupaje on July 16, 2013, 02:26:53 AM
Just a bit more info it generates multiple instances of the div

Code: [Select]
$info = show_menu2(0, SM2_CURR, SM2_START, SM2_ALL|SM2_BUFFER, '[if(class==menu-current){[level] [sib] [sibCount] [parent]}]', '', '', '');
list($nLevel, $nSib, $nSibCount, $nParent) = explode(' ', $info);
if ($nLevel > 0) {
        $lev = $nLevel - 1;
        return show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB|SM2_BUFFER, "[if(level==$lev){[a][menu_title]</a>}]", '', '<div class="kb_submenu">', '</div>');
}
else
        return '';

Code: [Select]
<div class="kb_submenu">
<div class="kb_submenu">
<a target="_top" href="http://allfrom1supply.net/kb/pages/roll-door-coatings/chem-bake-8000.php">Chem-Bake 8000</a>
<div class="kb_submenu">
</div>
</div>
</div>

I just want to surround the parent link with the div and class so I can style it. I can put the code for the div in the page but other users will be using this so I prefer they just copy in the [[droplet call]].

Thanks.

Title: Re: [[parentpage]]
Post by: Ruud on July 16, 2013, 10:15:01 AM
Try this:
Code: (untested) [Select]
<?php
$info 
show_menu2(0SM2_CURRSM2_STARTSM2_ALL|SM2_BUFFER'[if(class==menu-current){[level] [sib] [sibCount] [parent]}]''''''');
list(
$nLevel$nSib$nSibCount$nParent) = explode(' '$info);
if (
$nLevel 0) {
        
$lev $nLevel 1;
$parent show_menu2(0SM2_ROOTSM2_CURRSM2_CRUMB|SM2_BUFFER"[if(level==$lev){[a][menu_title]</a>}]"'''''');
        if(
$parent
return '<div class="kb_submenu">'.$parent.'</div>';
}
return 
true;

Title: Re: [[parentpage]]
Post by: bupaje on July 16, 2013, 06:07:21 PM
Thanks Ruud. That works.  :)