Scroll To Top

Enter a query to search our site. Note that you can use "*" and "?" as wildcards. Enclosing more than one word in double quotes ("CSS Layout") will search for the exact phrase.

PVII Knowledge Base

1. Select a product ...
2. Select category ...
3. Search the Knowledge Base...

Question #228

Is there a way to hide an Accordion Panel Magic (APM) section trigger if there is no associated content, or if there is no content of specific html tag type?

The Answer

Prepared Nov. 2007 by Gerry Jacobsen, PVII

Note: This feature is built into Accordion Panel Magic 2

You can conditionally display a section trigger in Accordion Panel Magic (APM) , depending on whether the trigger's associated content panel is empty, or if it does not contain a specified html markup tag. For example, you can hide the trigger if the associated content panel does not contain an image (the IMG tag).

Here's how:

1. Copy and Paste this new JavaScript function to the end of your p7APscripts.js file:

function P7_ABcd(d,tg){   
 var g,tc,tb=document.getElementById(d);
  if(tb){
    tc=document.getElementById(d.replace("t","c"));
    if(tc){
      g=tc.getElementsByTagName(tg);
    }	
    if(!tc || !g || g.length<1){
      tb.parentNode.style.display='none';
    }   
  }
 }

2. Locate the last 4 lines of the P7_initAB() function, around line 93:

 p7AB=true;
 P7_ABurl();
 P7_ABauto();
}

Insert a new line just after the P7_ABauto(); line and Copy & Paste this code into that new line:

 P7_ABcd('p7ABt1_2','IMG'); 

sot that it now looks like this:

 p7AB=true;
 P7_ABurl();
 P7_ABauto();
 P7_ABcd('p7ABt1_2','IMG'); 
}

The function contains two arguments:

'p7AB1_2' is the id of the section trigger link that you wish to conditionally show. In this example it would be the 2nd trigger.

'IMG' is the html tag to look for in the corresponding content panel. If the system finds an occurrence of this tag ( in this example, and image tag) then the section trigger will show, otherwise it will be hidden. This can be any valid html tag. The tag name must be in caps.

That's it!

Back to the questions list