PDA

View Full Version : Setting a condition in a static CMS page to display correct sub-menu


Lloyd32552
05-14-2012, 07:20 PM
I've created a new Navbar tab named Software using a Plugin and a static page that displays (correctly) when I click on that tab. There is also a sub-menu that will display if it finds the string define('THIS_SCRIPT', 'software_navtab'); in the static page. Somehow, I need to embed this string into the php file, but I don't know how to do that since it is created as content.

I posted this at vbulletin.com and was told that it should be posted here, but I was told that I shouldn't use THIS_SCRIPT for this process. What would be an alternate way of setting or determining a condition that would be recognized by the Plugin?

kh99
05-14-2012, 07:33 PM
So if I understand correctly you want a sub menu to appear in certain circumstances - is it always exactly when your new "Software" tab is selected, or does it actually depend on the contents of the page?

Edit: also, how exactly did you add the static page? What's the url you use for your software tab?

Edit: oh, I see now you actually mean a CMS static page. Anyway, maybe someone else will be able to answer with the info you've already given.

Lloyd32552
05-14-2012, 08:09 PM
I want the Software sub-menu to display whenever the software_page or other static pages linked below appear. I believe I can do this by embedding the THIS_SCRIPT statement into each of the linked php files.
Here is my plugin (the links are un-populated at this time), using the Hook location process_templates_complete:

$tablinks = '';
if (THIS_SCRIPT == 'software_navtab')
{
$vbulletin->options['selectednavtab']='navtab_software';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?124-software_page">Software</a>'.$tablinks.'</li>' ;

I created the page by simply clicking the Create <static page> button from CMS which gave it the name: content.php?124-software_page. So even though it says it is a static page, it appears to be dynamic and doesn't exist as a php file I can modify.
Should I be creating this page differently - Dreamweaver, for example? I know that I can then embed php codes into the file. If so, I assume that I'll need to also embed the Header and Footer code to maintain visual consistency.

Perhaps I'm going about this all wrong - I was not expecting to have to learn php to modify a menu in a CMS system and this is the only thing I've come up with so far.

Thanks for your help.
Lloyd

kh99
05-14-2012, 08:25 PM
OK, I don't understand what will be in link1.php, link2.php, link3.php - are those vb pages?

In any case, to show your sub menu only on your static page you could try this in your plugin code:

if ($vbulletin->nodeid == 124)
{
// add sub menu
}


BTW, you are right about "static html" not being an html file. Its called that to distinguish from html that's put together "on the fly" by a php script when it runs. In the case of a static html page the content you enter never changes, it's just saved in the database and output as is.

Lloyd32552
05-14-2012, 08:43 PM
Link1 will be descriptions of the software. Link2 will be a page with download links and installation instructions and Link3 will be the purchase links. All three pages will be static html pages.

When I add:
if ($vbulletin->nodeid == 124)
{
sub-menu code
}

to my plugin, the Software Tab AND the Home tab is highlighted and the Home sub-menu is superimposed over the Software sub-menu.

I'm getting closer, though.

kh99
05-14-2012, 08:53 PM
Link1 will be descriptions of the software. Link2 will be a page with download links and installation instructions and Link3 will be the purchase links. All three pages will be static html pages.

So you're going to create those as CMS static pages and you want the menu to appear on those as well? Then I guess you're going to want to do something like:

if (in_array($vbulletin->nodeid, array(124, 125, 126, 127)))


or whatever the actual node ids turn out to be.


When I add:
if ($vbulletin->nodeid == 124)
{
sub-menu code
}

to my plugin, the Software Tab AND the Home tab is highlighted and the Home sub-menu is superimposed over the Software sub-menu.

I'm getting closer, though.


I guess that's some problem with the way you're adding your sub menu? To be honest I don't know how to do that offhand.