PDA


View Full Version : VBA Links Navbar Drop-Down Menu (Auto-install)


drynax
07-05-2008, 01:37 AM
VBA Links Navbar Drop-Down Menu 1.4 Beta
(with Auto-Install)

There are two versions of VBA Links Navbar Drop-Down Menu. The 1st version is 1.4 (which is the Manual Version). The 2nd version is 1.6 (which is the Auto-install).

Manual Version (without Auto-install)

Description: I wanted to make a VBA Links drop-down menu on all my pages, but didn't want to make a lot of template edits. This Product makes it easier to install a VBA Links drop-down menu on all navbar templates in every style.

Instructions:

1) Install the product file.
2) Add the following code where you want the drop-down to appear in the template:

<!-- VBA Links Drop Down Menu -->
<td id="zakvbalinksmenu" class="vbmenu_control"><a href="$vboptions[homeurl]/links/index.php$session[sessionurl_q]">$vbphrase[zak_vbalinks]</a> <script type="text/javascript">vbmenu_register("zakvbalinksmenu"); </script></td>
<!-- End of VBA Links Drop Down Menu -->

That's it. Then you will have a drop-down menu with the following links:

Links Directory
Link to Us
Add Links
What's New
Top Visited Links
Top Rated Links
Top Replied To
Search


Please Give Me Suggestions for Links on the Navbar Drop-Down and I can add them!

(Got the original links from this thread: http://www.vbadvanced.com/forum/showthread.php?t=9811 )

drynax
07-05-2008, 01:42 AM
VBA Links Navbar Drop-Down Menu 1.6 Beta
(with Auto-Install)


There are two versions of VBA Links Navbar Drop-Down Menu. The 1st version is 1.4 (The Manual Version, which is up above). The 2nd version is 1.6 (which is the Auto-install, which is down below).

Auto-Install Version

Description: I wanted to make a VBA Links drop-down menu on all my pages, but didn't want to make a lot of template edits. This Product makes it easier to install a VBA Links drop-down menu on all navbar templates in every style.

Instructions:

1) Install the product file.

That's it. Then you will have a drop-down menu with the following links:

Links Directory
Link to Us
Add Links
What's New
Top Visited Links
Top Rated Links
Top Replied To
Search

2) In some cases, the navbar templates have been changed and it won't work. In this case, add the following code where you want the drop-down to appear in the template:

<!-- VBA Links Drop Down Menu -->
<td id="zakvbalinksmenu" class="vbmenu_control"><a href="$vboptions[homeurl]/links/index.php$session[sessionurl_q]">$vbphrase[zak_vbalinks]</a> <script type="text/javascript">vbmenu_register("zakvbalinksmenu"); </script></td>
<!-- End of VBA Links Drop Down Menu -->



Please Give Me Suggestions for Links on the Navbar Drop-Down and I can add them!

(Got the original links from this thread: http://www.vbadvanced.com/forum/showthread.php?t=9811 )

drynax
07-05-2008, 10:20 AM
Is there a way to make this fully automatic?

Can the following code be made into a hook?

<!-- VBA Links Drop Down Menu -->
<td id="zakvbalinksmenu" class="vbmenu_control"><a href="$vboptions[homeurl]/links/index.php$session[sessionurl_q]">$vbphrase[zak_vbalinks]</a> <script type="text/javascript">vbmenu_register("zakvbalinksmenu"); </script></td>
<!-- End of VBA Links Drop Down Menu -->


On this thread, Brian talks about "Adding link in vb Navbar via plugin/hook system":

http://www.vbadvanced.com/forum/showthread.php?t=28542

And uses the Code:

$template_hook['navbar_buttons_right'] .= '<td class="vbmenu_control"><a href="/links/index.php' . $vbulletin->session->vars['sessionurl_q'] . '">Links</a></td>';

Can I take the code from this mod and change it into a hook like it is above, then put it in an xml file?

Brian
07-05-2008, 01:43 PM
Yes, you should be able to use the same code for yours.

And thanks for sharing, I'm sure others will find this useful. :)

PhilMcKrackon
07-05-2008, 09:28 PM
You could easily use the $template_hook[navbar_buttons_left] or the $template_hook[navbar_buttons_right] hook in the navbar template.

Instead of editing the navbar template, create your own custom template (call it whatever), I'll use 'custom_links_navbar' as the template name. Put all your template edits in your custom template.

Add a plugin to the global_setup_complete Hook Location and use the code below - leave execution order at 5.

eval('$template_hook[\'navbar_buttons_right\'] .= "' .fetch_template('custom_links_navbar') . '";');Don't forget to activate it and don't forget to revert your navbar template or you'll have two menus.

This will load your custom template at the hook location for you and won't need any template edits. The only draw back is you are stuck with the left or right side of the navbar.

This will not load your template into the cache though. To do so (may be a better way but this works) - add another plugin in the 'cache_templates' hook location. The code below will add it to the template cache array.$globaltemplates = array_merge($globaltemplates, array('custom_links_navbar'));

An easy way to tell if you have uncached templates is to turn on debug mode. The uncached templates will be shown in RED.


BTW - You could also use the navbar hook to insert your code directly into the navbar without the need to create a template. I used the template insert as an example of what you could do. Sometimes it's a pain to search for a specific phrase.

drynax
07-05-2008, 10:26 PM
Thanks Phil / Brian,

I'll have to experiment with this the next couple days. Thanks for the detailed explanation, Phil, it makes things a lot clearer.

drynax
07-05-2008, 11:43 PM
Okay. I got the hook working. There are two versions now, depending on which one someone wants to use (auto or manual). A special thanks to Brian and Phil for helping me figure that out. It was easier than expected, however, I have another question...

Currently, my plugin code is as follows:

$template_hook['navbar_buttons_right'] .= '<td id="zakvbalinksmenu" class="vbmenu_control"><a href="$vboptions[homeurl]/links/index.php' . $vbulletin->session->vars['sessionurl_q'] . '">Links</a> <script type="text/javascript">vbmenu_register("zakvbalinksmenu"); </script></td>';

Now, here's my problem. I want "Links" to be ""$vbphrase[zak_vbalinks]". If I use a $vbphrase, then I can use multiple languages and just change the language table. Yet, whenever I replace "Links" with "$vbphrase[zak_vbalinks]", I get errors within the hook.

How would I write the PHP, so I can put $vbphrase within the hook?

KW802
07-05-2008, 11:57 PM
... and if anybody tries the automatic version and the changes do not appear in your custom styles navbar, then check your navbar template to see if the new hook locations are present. If they are not, then either use the 'template history' option to see what has changed in the navbar template and update your custom style accordingly or use the manual method that Tazzarkin has also provided.

PhilMcKrackon
07-05-2008, 11:59 PM
Here is the best explanation I have found concerning adding phrases using the add_phrase_type function in adminfunctions_language.php.

I created a php file and I ran it via the browser that includes that function with all the phrases I wanted to create.

http://www.vbulletin.com/forum/showthread.php?t=176699

I'm no genius at this but I would guess that you could create a plugin that did the same, run it once then remove it.

drynax
07-06-2008, 12:33 AM
Thanks for the answer Phil. The information you sent me is useful and I'm learning from it, however, my question was actually a more simple one. I guess I need to be more specific in my question:

Right now I want to know how I can take my code that does work (code I'm currently using):

$template_hook['navbar_buttons_right'] .= '<td id="zakvbalinksmenu" class="vbmenu_control"><a href="$vboptions[homeurl]/links/index.php' . $vbulletin->session->vars['sessionurl_q'] . '">Links</a> <script type="text/javascript">vbmenu_register("zakvbalinksmenu"); </script></td>';

And change it into the following (code that does not work):

$template_hook['navbar_buttons_right'] .= '<td id="zakvbalinksmenu" class="vbmenu_control"><a href="$vboptions[homeurl]/links/index.php' . $vbulletin->session->vars['sessionurl_q'] . '">$vbphrase[zak_vbalinks]</a> <script type="text/javascript">vbmenu_register("zakvbalinksmenu"); </script></td>';

All I tried to do was change Link into $vbphrase[zak_vbalinks]. However, when I use $vbprase, it gets an error. When I use Link, it works.

How would I re-write the PHP, so I can put $vbphrase within the hook?

I've been searching vbulletin's websites for over an hour and can't find anything about this stuff.

Lionel
07-06-2008, 12:56 AM
Try this

' . $vbphrase[zak_vbalinks] . '

drynax
07-06-2008, 01:10 AM
It worked!! Thanks!! Updated the file, so now we can use the language table with it. :)

-------------
Try this

Lionel
07-06-2008, 01:14 AM
you need to also do the same thing for
$vboptions[homeurl]

drynax
07-06-2008, 01:20 AM
Ouch. Glad you mentioned that. Okay, I changed that too. This stuff should be so common sense, but I missed it. Thanks again!

---------------
you need to also do the same thing for
$vboptions[homeurl]

24HourForum.com
08-04-2008, 03:58 PM
Thanks very much for the auto hack, works great YOU ROCK!

drynax
08-05-2008, 03:50 PM
LOL. Thanks for the double praise in both threads.
----------
Thanks very much for the auto hack, works great YOU ROCK!