Excluding sections & subsections from collapso menu
-
- Posts: 7
- Joined: Thu Jul 12, 2007 3:16 pm
Excluding sections & subsections from collapso menu
I've played around and achieved half-results but I just can't quite get this right.
I want to upload a section with 3 subsections to my website (Budget Bumps) but I don't want them to appear in the navigation (effectively, I want them hidden unless directly typed in to the address bar)
I think I have my blockif right but I can't for the life of me work out where it needs to go, presumably somewhere within the collapso 5 menu layout but trial and error (LOL) hasn't found the right place!
Any help would be greatly appreciated
Many thanks
Tracey
I want to upload a section with 3 subsections to my website (Budget Bumps) but I don't want them to appear in the navigation (effectively, I want them hidden unless directly typed in to the address bar)
I think I have my blockif right but I can't for the life of me work out where it needs to go, presumably somewhere within the collapso 5 menu layout but trial and error (LOL) hasn't found the right place!
Any help would be greatly appreciated
Many thanks
Tracey
-
- Posts: 7
- Joined: Thu Jul 12, 2007 3:16 pm
Thanks Norman.
I'm using V1.16 if that's what you mean.
I did eventually come up with a workable solution to this, documented below
http://community.actinic.com/showpost.p ... stcount=18
I appreciate that this solution probably isn't universal though and may not even be strictly correct. It does work for me though
I'm using V1.16 if that's what you mean.
I did eventually come up with a workable solution to this, documented below
http://community.actinic.com/showpost.p ... stcount=18
I appreciate that this solution probably isn't universal though and may not even be strictly correct. It does work for me though
I now have a general purpose sulution that will work with the current Collapso (V1.17). It uses a new section-level variable Hide From Collapso that, if set true, hides that section and it's children. This is for use on top-level sections only. It should not be used on lower level sections.
Patch for Collapso V1.17 ONLY is:
Patch for Collapso V1.17 ONLY is:
Code: Select all
Collapso modification to allow hiding of certain top-level sections.
FOR Collapso V1.17 ONLY
INSTALLATION
Go to Design / Library / Variables / Section. Right-click Section and choose New Variable.
Make the following settings
Name: Hide From Collapso
Description: Whether to hide the Section in the Collapso Menu.
Defaults to false for all Sections.
Prompt: Hide From Collapso
Group: Section
Place Of Setting: Section
Tab Name: Properties
Allow <Use Parent>.. Checked
Type: True/False
Searchable: Unchecked
Upload: Unchecked
Initial Value: Use Parent ()
Top Level Value: False
Replace (in Site1) the file collapso-5.js with the following
// Collapso-5 support V1.13 - HIDE TOP LEVEL SECTION MOD
var parentlist = new Array();
var levellist = new Array();
var imagelist = new Array();
function shM(obj){ // [+] or [-] image has been clicked
var result = obj.id.match(/_(.*)_(.*)/);
if (result == null) return false;
var level = result[1] - 0;
var index = result[2] - 0;
var subid = 'ul_' + (level + 1) + '_' + (index + 1);
// first close any open menus at this level
if ( levellist[level] != null )
{
// swap back to [+] and deal with brochure home page
var oldimg = document.getElementById(imagelist[level]).src;
var newimg = oldimg.replace(/(.*\/).*/, '$1c-p' + '.gif');
document.getElementById(imagelist[level]).src = newimg;
// hide the sub-level
document.getElementById(levellist[level]).className = 'hOb';
}
// if we're clicking an already open menu just close it
if ( levellist[level] == subid )
{
levellist[level] = null;
return false;
}
// now open any sub-menu if it exists
if ( document.getElementById(subid) )
{
// swap back to [-] and deal with brochure home page
var imgid = 'im_' + (level) + '_' + (index);
var oldimg = document.getElementById(imgid).src;
var newimg = oldimg.replace(/(.*\/).*/, '$1c-m' + '.gif');
document.getElementById(imgid).src = newimg;
// show the sub-level
document.getElementById(subid).className = 'sOb';
// remember where we've opened sub-sections
levellist[level] = subid;
imagelist[level] = imgid;
}
return false;
}
function collclks(rootid){ // set an onclick event for our [+] images
var divs = document.getElementById(rootid).getElementsByTagName('div');
for(i = 0; i < divs.length; i++)
{
var imgs = divs[i].getElementsByTagName('img');
if ( imgs[0].id ) imgs[0].onclick = function(){shM(this);};
var ancs = divs[i].getElementsByTagName('a');
// if we're using OnlyFinalLinks turn intermediate links into [+] image onclicks.
if ( ancs[0].href.indexOf('#') > -1 ) ancs[0].href="javascript:document.getElementById('" + imgs[0].id + "').onclick();";
}
}
function walktree(list, level){ // traverse list and open up sections that match breadcrumb trail
if ( strail.length == 0 ) return; // not on a Section page
var list = document.getElementById(list);
var cnodes = list.childNodes;
for ( var i = 0; i < cnodes.length; i++ )
{
var thisnode = cnodes[i];
if ( thisnode.nodeType != 1 ) continue; // skip non element type nodes
var links = thisnode.getElementsByTagName('a'); // get all anchor tags (we want 1st one)
var images = thisnode.getElementsByTagName('img'); // and all img tags (we want 1st one)
if ( links[0].innerHTML == strail[level] ) // if section name matches breadcrumb
{
// first and only image is the [+] icon if it has an id tag (no id tag if null icon)
if ( images[0].id ) document.getElementById(images[0].id).onclick(); // found it so fire onclick
var sublist = thisnode.getElementsByTagName('ul'); // see if any sub-lists
if ( sublist.length > 0 ) walktree(sublist[0].id, level + 1); // if so recurse and look for next breadcrumb
return; // all done so exit early
}
}
}
Go to Design / Library / Layouts / Collapso-5 Dynamic Menu / Collapso-5 Menu and replace
all code with the following
<actinic:block php="true">
// V1.17 - HIDE TOP LEVEL SECTION MOD
$firstid = '';
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoDiagnostics%22%20%2f%3e%20%3d%3d%20true" >
<actinic:block php="true">
list($startusec, $startsec) = explode(" ", microtime());
</actinic:block>
</actinic:block>
<actinic:block php="true">
// V1.17 (also in code at bottom)
$thispage = '';
$classadjust = '';
$charcount = 0;
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Section%22" >
<actinic:block php="true">
$thispage = '<actinic:variable name="SectionPageName" encoding="perl" selectable="false" />';
</actinic:block>
</actinic:block>
<div id="collapso5">
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoShowBrochure%22%20%2f%3e" >
<ul class="sOb">
<actinic:block type="BrochurePagesList">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/> <a class="nsa" href="<actinic:variable name="BrochurePageURL" />"><actinic:variable name="BrochureName" /></a></div></li>
</actinic:block>
</ul>
</actinic:block>
<actinic:block type="EntireSectionList">
<actinic:block php="true">
/*
Menu needs unordered list of format
<div id="collapso5">
<ul class="sOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 1</a></div></li>
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 2</a></div></li>
<li class="hsc"><div><img class="hsi" src="c-p.gif"/><a class="hsa" ... ">Top Section 3 with sub-section</a></div>
<ul class="hOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Sub Section A</a></div></li>
<li class="hsc"><div><img class="hsi" src="c-p.gif"/><a class="hsa" ... ">Sub Section B with sub-sub-section</a></div>
<ul class="hOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Sub-sub Section X</a></div></li>
</ul>
</li>
</ul>
</li>
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 4</a></div></li>
</ul>
</div>
Each call of this code is for a Section line.
We can't generate the code right away as we need to wait to see if the next section is
at the same level.
So we save the link and name and output it at the next iteration.
*/
$thislevel = <actinic:variable name="SectionLevel" encoding="perl" selectable="false" />;
$index = <actinic:variable name="ListIndex" encoding="perl" selectable="false" />;
$hidefromcollapso = <actinic:variable name="Hide From Collapso" encoding="perl" selectable="false" />;
$currentid = 'ul_' . $thislevel . '_' . $index;
if ( (($maxdepth == 0) || ($thislevel <= $maxdepth)) && (! $hidefromcollapso) )
{
if ( $firstid == '' ) $firstid = $currentid;
if ( $thislevel > $lastlevel ) // Start a new list (also done for first item)
{
// no LI if very first call - we just need to start an UL
if ( $inlist )
{
// show that previous item has sub-section
if ( $onlyfinallinks ) $linkhref = '#';
$bits[0] = "<img class=\"hsi\" id=\"im_$linklevel" . "_$linkindex\" src=\"c-p.gif\"/>";
$bits[1] = "<a class=\"hsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"hsc\"><div>$bits[0]$iconspacer$bits[1]</div>";
echo $html;
$charcount += strlen($html);
}
// now start sub-section list
while ( $lastlevel < $thislevel )
{
$nmclass = ( $thislevel == 1 ) ? 'class="sOb"' : 'class="hOb"'; // show only 1st level lists
$html = "<ul id=\"$currentid\" $nmclass >";
echo $html;
$charcount += strlen($html);
$lastlevel++;
}
}
else if ( $thislevel < $lastlevel ) // Returning from a sub-section
{
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
echo $html;
$charcount += strlen($html);
while ( $lastlevel > $thislevel )
{
echo '</ul></li>';
$charcount += 10;
$lastlevel--;
}
}
else // same level as previous item
{
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
echo $html;
$charcount += strlen($html);
}
$inlist = true;
// store LI code for next iteration
$linkhref = '<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" encoding="perl" selectable="false" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" encoding="perl" selectable="false"/></actinic:block>';
$linkname = htmlspecialchars('<Actinic:Variable Name="SectionName" php="true" encoding="perl" selectable="false" />');
$linklevel = $thislevel;
$linkindex = $index;
$currentsection = '<actinic:variable name="SectionPageName" encoding="perl" selectable="false" />';
$classadjust = ( $currentsection == $thispage ) ? '_c' : '';
}
</actinic:block></actinic:block>
<actinic:block php="true">
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
echo "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
while ( $thislevel-- > 1 )
{
echo '</ul></li>';
$charcount += 10;
}
</actinic:block></ul>
</div>
<script type="text/javascript">
<!-- V1.17
collclks('<actinic:block php="true">echo $firstid;</actinic:block>');
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoShowTree%22%20%2f%3e" >
var strail = new Array();
<actinic:block type="ParentSectionList">
strail.push('<actinic:block php="true">
echo str_replace("'", "\'", htmlspecialchars('<actinic:variable name="SectionName" encoding="perl" selectable="false" />'));
</actinic:block>');
</actinic:block>
walktree('<actinic:block php="true">echo $firstid;</actinic:block>',0);
</actinic:block>
// -->
</script>
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoDiagnostics%22%20%2f%3e%20%3d%3d%20true" >
<actinic:block php="true">
list($endusec, $endsec) = explode(" ", microtime());
$duration = ((float)$endusec + (float)$endsec) - ((float)$startusec + (float)$startsec);
echo "<br><b>Duration: $duration <br>Bytes: $charcount </b>";
</actinic:block>
</actinic:block>
That's installation finished
OPERATION
In a top-level Section Details / Properties, set Hide From Collapso to true for those Sections
that you want to hide. Do not use on sub-sections and make sure that all sub-sections
have Use Parent set for this variable.
NOTES
This is supplied without any guarantees that it will work in all cases.
Norman
-
- Posts: 7
- Joined: Thu Jul 12, 2007 3:16 pm
Kevin
Yes. Create the Hide From Collapso variable and and add Brochure to Place of Setting. Details below:
Now edit layout Collapso-5 Menu and look for the line
replace it with
And now Hide From Collapso works on Brochure pages too.
Yes. Create the Hide From Collapso variable and and add Brochure to Place of Setting. Details below:
Code: Select all
Go to Design / Library / Variables / Section. Right-click Section and choose New Variable.
Make the following settings
Name: Hide From Collapso
Description: Whether to hide the Section in the Collapso Menu.
Defaults to false for all Sections.
Prompt: Hide From Collapso
Group: Section
Place Of Setting: Section, Brochure
Tab Name: Properties
Allow <Use Parent>.. Checked
Type: True/False
Searchable: Unchecked
Upload: Unchecked
Initial Value: Use Parent ()
Top Level Value: False
Code: Select all
<li class="nsc"><div><img class="nsi" src="c-n.gif"/> <a class="nsa" href="<actinic:variable name="BrochurePageURL" />"><actinic:variable name="BrochureName" /></a></div></li>
Code: Select all
<actinic:block if="%3cactinic%3avariable%20name%3d%22Hide%20From%20Collapso%22%20%2f%3e%20%3d%3d%20false" >
<li class="nsc"><div><img class="nsi" src="c-n.gif"/> <a class="nsa" href="<actinic:variable name="BrochurePageURL" />"><actinic:variable name="BrochureName" /></a></div></li>
</actinic:block>
Norman
Re: Excluding sections & subsections from collapso menu
Here's the ReadMe for Collapso V1.18.
I now have a general purpose sulution that will work with the current Collapso (V1.18). It uses a new section-level variable Hide From Collapso that, if set true, hides that section and it's children. This is for use on top-level sections only. It should not be used on lower level sections.
Patch for Collapso V1.18 ONLY is:
I now have a general purpose sulution that will work with the current Collapso (V1.18). It uses a new section-level variable Hide From Collapso that, if set true, hides that section and it's children. This is for use on top-level sections only. It should not be used on lower level sections.
Patch for Collapso V1.18 ONLY is:
Code: Select all
Collapso modification to allow hiding of certain top-level sections.
FOR Collapso V1.18 ONLY
INSTALLATION
Go to Design / Library / Variables / Section. Right-click Section and choose New Variable.
Make the following settings
Name: Hide From Collapso
Description: Whether to hide the Section in the Collapso Menu.
Defaults to false for all Sections.
Prompt: Hide From Collapso
Group: Section
Place Of Setting: Section
Tab Name: Properties
Allow <Use Parent>.. Checked
Type: True/False
Searchable: Unchecked
Upload: Unchecked
Initial Value: Use Parent ()
Top Level Value: False
Replace (in Site1) the file collapso-5.js with the following
// Collapso-5 support V1.18 - HIDE TOP LEVEL SECTION MOD
var parentlist = new Array();
var levellist = new Array();
var imagelist = new Array();
function shM(obj){ // [+] or [-] image has been clicked
var result = obj.id.match(/_(.*)_(.*)/);
if (result == null) return false;
var level = result[1] - 0;
var index = result[2] - 0;
var subid = 'ul_' + (level + 1) + '_' + (index + 1);
// first close any open menus at this level
if ( levellist[level] != null )
{
// swap back to [+] and deal with brochure home page
var oldimg = document.getElementById(imagelist[level]).src;
var newimg = oldimg.replace(/(.*\/).*/, '$1c-p' + '.gif');
document.getElementById(imagelist[level]).src = newimg;
// hide the sub-level
document.getElementById(levellist[level]).className = 'hOb';
}
// if we're clicking an already open menu just close it
if ( levellist[level] == subid )
{
levellist[level] = null;
return false;
}
// now open any sub-menu if it exists
if ( document.getElementById(subid) )
{
// swap back to [-] and deal with brochure home page
var imgid = 'im_' + (level) + '_' + (index);
var oldimg = document.getElementById(imgid).src;
var newimg = oldimg.replace(/(.*\/).*/, '$1c-m' + '.gif');
document.getElementById(imgid).src = newimg;
// show the sub-level
document.getElementById(subid).className = 'sOb';
// remember where we've opened sub-sections
levellist[level] = subid;
imagelist[level] = imgid;
}
return false;
}
function collclks(rootid){ // set an onclick event for our [+] images
var divs = document.getElementById(rootid).getElementsByTagName('div');
for(i = 0; i < divs.length; i++)
{
var imgs = divs[i].getElementsByTagName('img');
if ( imgs[0].id ) imgs[0].onclick = function(){shM(this);};
var ancs = divs[i].getElementsByTagName('a');
// if we're using OnlyFinalLinks turn intermediate links into [+] image onclicks.
if ( ancs[0].href.indexOf('#') > -1 ) ancs[0].href="javascript:document.getElementById('" + imgs[0].id + "').onclick();";
}
}
function walktree(list, level){ // traverse list and open up sections that match breadcrumb trail
if ( strail.length == 0 ) return; // not on a Section page
var list = document.getElementById(list);
var cnodes = list.childNodes;
var thistrail = "" + strail[level]; // extract current levels name
thistrail = thistrail.replace(/\s+/g,''); // despace (IE despaces innerHTML)
for ( var i = 0; i < cnodes.length; i++ )
{
var thisnode = cnodes[i];
if ( thisnode.nodeType != 1 ) continue; // skip non element type nodes
var links = thisnode.getElementsByTagName('a'); // get all anchor tags (we want 1st one)
var images = thisnode.getElementsByTagName('img'); // and all img tags (we want 1st one)
if ( links[0].innerHTML.replace(/\s+/g,'') == thistrail ) // if section name matches breadcrumb
{
// first and only image is the [+] icon if it has an id tag (no id tag if null icon)
if ( images[0].id ) document.getElementById(images[0].id).onclick(); // found it so fire onclick
var sublist = thisnode.getElementsByTagName('ul'); // see if any sub-lists
if ( sublist.length > 0 ) walktree(sublist[0].id, level + 1); // if so recurse and look for next breadcrumb
return; // all done so exit early
}
}
}
Go to Design / Library / Layouts / Collapso-5 Dynamic Menu / Collapso-5 Menu and replace
all code with the following
<actinic:block php="true">
// V1.17 - HIDE TOP LEVEL SECTION MOD
$firstid = '';
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoDiagnostics%22%20%2f%3e%20%3d%3d%20true" >
<actinic:block php="true">
list($startusec, $startsec) = explode(" ", microtime());
</actinic:block>
</actinic:block>
<actinic:block php="true">
// V1.17 (also in code at bottom)
$thispage = '';
$classadjust = '';
$charcount = 0;
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Section%22" >
<actinic:block php="true">
$thispage = '<actinic:variable name="SectionPageName" encoding="perl" selectable="false" />';
</actinic:block>
</actinic:block>
<div id="collapso5">
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoShowBrochure%22%20%2f%3e" >
<ul class="sOb">
<actinic:block type="BrochurePagesList">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/> <a class="nsa" href="<actinic:variable name="BrochurePageURL" />"><actinic:variable name="BrochureName" /></a></div></li>
</actinic:block>
</ul>
</actinic:block>
<actinic:block type="EntireSectionList">
<actinic:block php="true">
/*
Menu needs unordered list of format
<div id="collapso5">
<ul class="sOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 1</a></div></li>
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 2</a></div></li>
<li class="hsc"><div><img class="hsi" src="c-p.gif"/><a class="hsa" ... ">Top Section 3 with sub-section</a></div>
<ul class="hOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Sub Section A</a></div></li>
<li class="hsc"><div><img class="hsi" src="c-p.gif"/><a class="hsa" ... ">Sub Section B with sub-sub-section</a></div>
<ul class="hOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Sub-sub Section X</a></div></li>
</ul>
</li>
</ul>
</li>
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 4</a></div></li>
</ul>
</div>
Each call of this code is for a Section line.
We can't generate the code right away as we need to wait to see if the next section is
at the same level.
So we save the link and name and output it at the next iteration.
*/
$thislevel = <actinic:variable name="SectionLevel" encoding="perl" selectable="false" />;
$index = <actinic:variable name="ListIndex" encoding="perl" selectable="false" />;
$hidefromcollapso = <actinic:variable name="Hide From Collapso" encoding="perl" selectable="false" />;
$currentid = 'ul_' . $thislevel . '_' . $index;
if ( (($maxdepth == 0) || ($thislevel <= $maxdepth)) && (! $hidefromcollapso) )
{
if ( $firstid == '' ) $firstid = $currentid;
if ( $thislevel > $lastlevel ) // Start a new list (also done for first item)
{
// no LI if very first call - we just need to start an UL
if ( $inlist )
{
// show that previous item has sub-section
if ( $onlyfinallinks ) $linkhref = '#';
$bits[0] = "<img class=\"hsi\" id=\"im_$linklevel" . "_$linkindex\" src=\"c-p.gif\"/>";
$bits[1] = "<a class=\"hsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"hsc\"><div>$bits[0]$iconspacer$bits[1]</div>";
echo $html;
$charcount += strlen($html);
}
// now start sub-section list
while ( $lastlevel < $thislevel )
{
$nmclass = ( $thislevel == 1 ) ? 'class="sOb"' : 'class="hOb"'; // show only 1st level lists
$html = "<ul id=\"$currentid\" $nmclass >";
echo $html;
$charcount += strlen($html);
$lastlevel++;
}
}
else if ( $thislevel < $lastlevel ) // Returning from a sub-section
{
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
echo $html;
$charcount += strlen($html);
while ( $lastlevel > $thislevel )
{
echo '</ul></li>';
$charcount += 10;
$lastlevel--;
}
}
else // same level as previous item
{
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
echo $html;
$charcount += strlen($html);
}
$inlist = true;
// store LI code for next iteration
$linkhref = '<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" encoding="perl" selectable="false" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" encoding="perl" selectable="false"/></actinic:block>';
$linkname = htmlspecialchars('<Actinic:Variable Name="SectionName" php="true" encoding="perl" selectable="false" />');
$linklevel = $thislevel;
$linkindex = $index;
$currentsection = '<actinic:variable name="SectionPageName" encoding="perl" selectable="false" />';
$classadjust = ( $currentsection == $thispage ) ? '_c' : '';
}
</actinic:block></actinic:block>
<actinic:block php="true">
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
echo "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
while ( $thislevel-- > 1 )
{
echo '</ul></li>';
$charcount += 10;
}
</actinic:block></ul>
</div>
<script type="text/javascript">
<!-- V1.17
collclks('<actinic:block php="true">echo $firstid;</actinic:block>');
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoShowTree%22%20%2f%3e" >
var strail = new Array();
<actinic:block type="ParentSectionList">
strail.push('<actinic:block php="true">
echo str_replace("'", "\'", htmlspecialchars('<actinic:variable name="SectionName" encoding="perl" selectable="false" />'));
</actinic:block>');
</actinic:block>
walktree('<actinic:block php="true">echo $firstid;</actinic:block>',0);
</actinic:block>
// -->
</script>
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoDiagnostics%22%20%2f%3e%20%3d%3d%20true" >
<actinic:block php="true">
list($endusec, $endsec) = explode(" ", microtime());
$duration = ((float)$endusec + (float)$endsec) - ((float)$startusec + (float)$startsec);
echo "<br><b>Duration: $duration <br>Bytes: $charcount </b>";
</actinic:block>
</actinic:block>
That's installation finished
OPERATION
In a top-level Section Details / Properties, set Hide From Collapso to true for those Sections
that you want to hide. Do not use on sub-sections and make sure that all sub-sections
have Use Parent set for this variable.
NOTES
This is supplied without any guarantees that it will work in all cases.
Norman
Re: Excluding sections & subsections from collapso menu
Morning Norman. Hope you're enjoying the snow on the East coast this morning, I know I'm not!
Back to work.
I am using the Collapso add-on, with filename "Collapso-5-V118-Actinic900"
I see the latest modification you have added to the forum was on July '08, dubbed as v1.18. However, it appears that this modification to the add-on isn't in the 1.18 release which I have. I wondered if you have an updated fix for the release version 1.18, or will this work by applying your latest July 2008 update?
Cheers,
Grant
Back to work.
I am using the Collapso add-on, with filename "Collapso-5-V118-Actinic900"
I see the latest modification you have added to the forum was on July '08, dubbed as v1.18. However, it appears that this modification to the add-on isn't in the 1.18 release which I have. I wondered if you have an updated fix for the release version 1.18, or will this work by applying your latest July 2008 update?
Cheers,
Grant
Re: Excluding sections & subsections from collapso menu
This is an add-on to Collapso and is not part of the supplied patch. You have to add it yourself. You'll need to create the "Hide From Collapso " variable as per earlier [posts and then do the bit that's 1.18 specific from the most recent post.
Norman
Re: Excluding sections & subsections from collapso menu
Thanks for the assistance Norman. Will get to this just now. As a 'wish list' entry, I think this extra feature would be good to be rolled into the next release if possible, should you see the need to create a further Collapso release.
Cheers,
Grant
Cheers,
Grant
Re: Excluding sections & subsections from collapso menu
I'll probably leave this out. The code that Collapso uses is complex and I don't want to make it any more so by adding in features that would only be used by a small minority of users.
Norman
Re: Excluding sections & subsections from collapso menu
Here's the ReadMe for Collapso V1.19.
I now have a general purpose sulution that will work with the current Collapso (V1.19). It uses a new section-level variable Hide From Collapso that, if set true, hides that section and it's children. This is for use on top-level sections only. It should not be used on lower level sections.
Patch for Collapso V1.19 ONLY is:
I now have a general purpose sulution that will work with the current Collapso (V1.19). It uses a new section-level variable Hide From Collapso that, if set true, hides that section and it's children. This is for use on top-level sections only. It should not be used on lower level sections.
Patch for Collapso V1.19 ONLY is:
Code: Select all
Collapso modification to allow hiding of certain top-level sections.
FOR Collapso V1.19 ONLY
INSTALLATION
Go to Design / Library / Variables / Section. Right-click Section and choose New Variable.
Make the following settings
Name: Hide From Collapso
Description: Whether to hide the Section in the Collapso Menu.
Defaults to false for all Sections.
Prompt: Hide From Collapso
Group: Section
Place Of Setting: Section
Tab Name: Properties
Allow <Use Parent>.. Checked
Type: True/False
Searchable: Unchecked
Upload: Unchecked
Initial Value: Use Parent ()
Top Level Value: False
Replace (in Site1) the file collapso-5.js with the following
// Collapso-5 support V1.19 - HIDE TOP LEVEL SECTION MOD
var parentlist = new Array();
var levellist = new Array();
var imagelist = new Array();
function shM(obj){ // [+] or [-] image has been clicked
var result = obj.id.match(/_(.*)_(.*)/);
if (result == null) return false;
var level = result[1] - 0;
var index = result[2] - 0;
var subid = 'ul_' + (level + 1) + '_' + (index + 1);
// first close any open menus at this level
if ( levellist[level] != null )
{
// swap back to [+] and deal with brochure home page
var oldimg = document.getElementById(imagelist[level]).src;
var newimg = oldimg.replace(/(.*\/).*/, '$1c-p' + '.gif');
document.getElementById(imagelist[level]).src = newimg;
// hide the sub-level
document.getElementById(levellist[level]).className = 'hOb';
}
// if we're clicking an already open menu just close it
if ( levellist[level] == subid )
{
levellist[level] = null;
return false;
}
// now open any sub-menu if it exists
if ( document.getElementById(subid) )
{
// swap back to [-] and deal with brochure home page
var imgid = 'im_' + (level) + '_' + (index);
var oldimg = document.getElementById(imgid).src;
var newimg = oldimg.replace(/(.*\/).*/, '$1c-m' + '.gif');
document.getElementById(imgid).src = newimg;
// show the sub-level
document.getElementById(subid).className = 'sOb';
// remember where we've opened sub-sections
levellist[level] = subid;
imagelist[level] = imgid;
}
return false;
}
function collclks(rootid){ // set an onclick event for our [+] images
var divs = document.getElementById(rootid).getElementsByTagName('div');
for(i = 0; i < divs.length; i++)
{
var imgs = divs[i].getElementsByTagName('img');
if ( imgs[0].id ) imgs[0].onclick = function(){shM(this);};
var ancs = divs[i].getElementsByTagName('a');
// if we're using OnlyFinalLinks turn intermediate links into [+] image onclicks.
if ( ancs[0].href.indexOf('#') > -1 ) ancs[0].href="javascript:document.getElementById('" + imgs[0].id + "').onclick();";
}
}
function walktree(list, level){ // traverse list and open up sections that match breadcrumb trail
if ( strail.length == 0 ) return; // not on a Section page
var list = document.getElementById(list);
var cnodes = list.childNodes;
var thistrail = "" + strail[level]; // extract current levels name
thistrail = thistrail.replace(/\s+/g,''); // despace (IE despaces innerHTML)
for ( var i = 0; i < cnodes.length; i++ )
{
var thisnode = cnodes[i];
if ( thisnode.nodeType != 1 ) continue; // skip non element type nodes
var links = thisnode.getElementsByTagName('a'); // get all anchor tags (we want 1st one)
var images = thisnode.getElementsByTagName('img'); // and all img tags (we want 1st one)
if ( links[0].innerHTML.replace(/\s+/g,'') == thistrail ) // if section name matches breadcrumb
{
// first and only image is the [+] icon if it has an id tag (no id tag if null icon)
if ( images[0].id ) document.getElementById(images[0].id).onclick(); // found it so fire onclick
var sublist = thisnode.getElementsByTagName('ul'); // see if any sub-lists
if ( sublist.length > 0 ) walktree(sublist[0].id, level + 1); // if so recurse and look for next breadcrumb
return; // all done so exit early
}
}
}
Go to Design / Library / Layouts / Collapso-5 Dynamic Menu / Collapso-5 Menu and replace
all code with the following
<actinic:block php="true">
// V1.17 - HIDE TOP LEVEL SECTION MOD
$firstid = '';
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoDiagnostics%22%20%2f%3e%20%3d%3d%20true" >
<actinic:block php="true">
list($startusec, $startsec) = explode(" ", microtime());
</actinic:block>
</actinic:block>
<actinic:block php="true">
// V1.19 (also in code at bottom)
$maxdepth = <actinic:variable name="CollapsoMaxDepth" encoding="perl" selectable="false" />;
$iconafter = <actinic:variable name="CollapsoIconAfter" encoding="perl" selectable="false" />;
$iconspacer = '<actinic:variable name="CollapsoSeparator" encoding="perl" selectable="false" />';
$lastlevel = 0;
$inlist=false;
$onlyfinallinks = <actinic:variable name="CollapsoOnlyFinalLinks" selectable="false" selectable="false" />;
$thispage = '';
$classadjust = '';
$charcount = 0;
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Section%22" >
<actinic:block php="true">
$thispage = '<actinic:variable name="SectionPageName" encoding="perl" selectable="false" />';
</actinic:block>
</actinic:block>
<div id="collapso5">
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoShowBrochure%22%20%2f%3e" >
<ul class="sOb">
<actinic:block type="BrochurePagesList">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/> <a class="nsa" href="<actinic:variable name="BrochurePageURL" />"><actinic:variable name="BrochureName" /></a></div></li>
</actinic:block>
</ul>
</actinic:block>
<actinic:block type="EntireSectionList">
<actinic:block php="true">
/*
Menu needs unordered list of format
<div id="collapso5">
<ul class="sOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 1</a></div></li>
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 2</a></div></li>
<li class="hsc"><div><img class="hsi" src="c-p.gif"/><a class="hsa" ... ">Top Section 3 with sub-section</a></div>
<ul class="hOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Sub Section A</a></div></li>
<li class="hsc"><div><img class="hsi" src="c-p.gif"/><a class="hsa" ... ">Sub Section B with sub-sub-section</a></div>
<ul class="hOb">
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Sub-sub Section X</a></div></li>
</ul>
</li>
</ul>
</li>
<li class="nsc"><div><img class="nsi" src="c-n.gif"/><a class="nsa" ... ">Top Section 4</a></div></li>
</ul>
</div>
Each call of this code is for a Section line.
We can't generate the code right away as we need to wait to see if the next section is
at the same level.
So we save the link and name and output it at the next iteration.
*/
$thislevel = <actinic:variable name="SectionLevel" encoding="perl" selectable="false" />;
$index = <actinic:variable name="ListIndex" encoding="perl" selectable="false" />;
$hidefromcollapso = <actinic:variable name="Hide From Collapso" encoding="perl" selectable="false" />;
$currentid = 'ul_' . $thislevel . '_' . $index;
if ( (($maxdepth == 0) || ($thislevel <= $maxdepth)) && (! $hidefromcollapso) )
{
if ( $firstid == '' ) $firstid = $currentid;
if ( $thislevel > $lastlevel ) // Start a new list (also done for first item)
{
// no LI if very first call - we just need to start an UL
if ( $inlist )
{
// show that previous item has sub-section
if ( $onlyfinallinks ) $linkhref = '#';
$bits[0] = "<img class=\"hsi\" id=\"im_$linklevel" . "_$linkindex\" src=\"c-p.gif\"/>";
$bits[1] = "<a class=\"hsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"hsc\"><div>$bits[0]$iconspacer$bits[1]</div>";
echo $html;
$charcount += strlen($html);
}
// now start sub-section list
while ( $lastlevel < $thislevel )
{
$nmclass = ( $thislevel == 1 ) ? 'class="sOb"' : 'class="hOb"'; // show only 1st level lists
$html = "<ul id=\"$currentid\" $nmclass >";
echo $html;
$charcount += strlen($html);
$lastlevel++;
}
}
else if ( $thislevel < $lastlevel ) // Returning from a sub-section
{
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
echo $html;
$charcount += strlen($html);
while ( $lastlevel > $thislevel )
{
echo '</ul></li>';
$charcount += 10;
$lastlevel--;
}
}
else // same level as previous item
{
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
$html = "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
echo $html;
$charcount += strlen($html);
}
$inlist = true;
// store LI code for next iteration
$linkhref = '<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" encoding="perl" selectable="false" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" encoding="perl" selectable="false"/></actinic:block>';
$linkname = htmlspecialchars('<Actinic:Variable Name="SectionName" php="true" encoding="perl" selectable="false" />');
$linklevel = $thislevel;
$linkindex = $index;
$currentsection = '<actinic:variable name="SectionPageName" encoding="perl" selectable="false" />';
$classadjust = ( $currentsection == $thispage ) ? '_c' : '';
}
</actinic:block></actinic:block>
<actinic:block php="true">
$bits[0] = "<img class=\"nsi\" src=\"c-n.gif\" />";
$bits[1] = "<a class=\"nsa$classadjust\" href=\"$linkhref\">$linkname</a>";
if ( $iconafter ) $bits = array_reverse($bits);
echo "<li class=\"nsc\"><div>$bits[0]$iconspacer$bits[1]</div></li>";
while ( $thislevel-- > 1 )
{
echo '</ul></li>';
$charcount += 10;
}
</actinic:block></ul>
</div>
<script type="text/javascript">
collclks('<actinic:block php="true">echo $firstid;</actinic:block>');
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoShowTree%22%20%2f%3e" >
var strail = new Array();
<actinic:block type="ParentSectionList">
strail.push('<actinic:block php="true">
echo str_replace("'", "\'", htmlspecialchars('<actinic:variable name="SectionName" encoding="perl" selectable="false" />'));
</actinic:block>');
</actinic:block>
walktree('<actinic:block php="true">echo $firstid;</actinic:block>',0);
</actinic:block>
</script>
<actinic:block if="%3cactinic%3avariable%20name%3d%22CollapsoDiagnostics%22%20%2f%3e%20%3d%3d%20true" >
<actinic:block php="true">
list($endusec, $endsec) = explode(" ", microtime());
$duration = ((float)$endusec + (float)$endsec) - ((float)$startusec + (float)$startsec);
echo "<br><b>Duration: $duration <br>Bytes: $charcount </b>";
</actinic:block>
</actinic:block>
That's installation finished
OPERATION
In a top-level Section Details / Properties, set Hide From Collapso to true for those Sections
that you want to hide. Do not use on sub-sections and make sure that all sub-sections
have Use Parent set for this variable.
NOTES
This is supplied without any guarantees that it will work in all cases.
Modified 18-12-10 to remove DesignPreview buw that was ignoring code within JavaScript comments.
Norman
Re: Excluding sections & subsections from collapso menu
I've just applied this to a site I'm building in Designer v9.0.5, which works perfectly, but I'm getting a Javascript error on every page (at the top of the Design tab view - it's not showing up in Internet Explorer or any of the other browsers).
The error is:
"A Javascript error has been found on the page (''document.getElementByld(...)' is null or not an object').
Does this need fixing or is it OK to leave it?
Malcolm
The error is:
"A Javascript error has been found on the page (''document.getElementByld(...)' is null or not an object').
Does this need fixing or is it OK to leave it?
Malcolm