vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Users Can create their own drop down list in navbar (https://vborg.vbsupport.ru/showthread.php?t=72980)

Michael Morris 12-15-2004 10:00 PM

Users Can create their own drop down list in navbar
 
This hack is part of Lesson #6 of my Using the PHPINCLUDE_START template" tutorial thread. It is presented here individually. While techinically a user feature, it is put here with mini-mods since it requires no code edits. Instead you have 2 template edits: navbar and phpinclude_start. You must also add a user profile field.

For a more complete explaination of the code please visit the tutorial thread.

AND NOW THE HACK...

To begin create a user profile field that is multiple text lines and has a character limit of at least 2000. Note the user profile field # the system assigns to the new field - you'll need it below.

Once you do that crack into your navbar and look for this code:

HTML Code:

                        <!-- nav buttons bar -->
                                <div align="center">
                                        <table class="thead" cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
                                                <tr align="center">
                                                        <if condition="$show['popups']">

Immediately after add.

HTML Code:

                                                                <if condition="!empty($mylinks)">
                                                                        <td id="mylinks" class="vbmenu_control"><a href="#mylinks">My Links</a> <script type="text/javascript"> vbmenu_register("mylinks"); </script></td>               
                                                                </if>

Next look for this code in the navbar

HTML Code:

        <!-- / NAVBAR POPUP MENUS -->
Immediately above it insert the following code

HTML Code:

<if condition="!empty($mylinks)">
<!-- My Links Menu -->
        <div class="vbmenu_popup" id="mylinks_menu" style="display:none">
                <table cellpadding="4" cellspacing="1" border="0">
                        $mylinks
                </table>
        </div>
<!-- /My Links -->
</if>

Now insert the following into PHPINCLUDE_START at either the very start or the very end.

PHP Code:

if (!empty($bbuserinfo['fieldX']))
    {
    require_once(
'./includes/functions_bbcodeparse.php');
    
$mylinks parse_bbcode2($bbuserinfo['fieldX'], 0001);
    
$mylinks str_replace('<br />'''$mylinks);
    
$mylinks str_replace('</a>''</a></td></tr>'$mylinks);
    
$mylinks str_replace('<a''<tr><td class="vbmenu_option"><a'$mylinks);    
    } 

You will need to plug the correct user profile field # into the spot occupied by "fieldX" above. So if your new profile field created above was field #9 you'd refer to $bbuserinfo['field9']

And with that you're done. Enjoy.

Compatibility Note
If you are running a version of vbulletin prior to version 3.0.3 you'll need to run a database query in order to have field lengths longer than 250 characters. This query is:

ALTER TABLE userfield MODIFY COLUMN fieldX TEXT

You'll need to change fieldX to the field# appropriate to your forums.

jluerken 12-16-2004 09:55 PM

Sounds cool. A screenshot would be nice.

Polo 12-16-2004 10:15 PM

Thank you Michael Morris, I may use this ;)

Michael Morris 12-16-2004 10:30 PM

Quote:

Originally Posted by jluerken
Sounds cool. A screenshot would be nice.

Two added.

Note, minor glitch found for RC4 - you can't have user input fields beyond 500 characters or so (odd). I presume this is fixed in later versions.

Koutaru 12-16-2004 10:31 PM

Could this be domain specific (ie it can only be your domain they link to?

Michael Morris 12-16-2004 11:09 PM

Not without major recoding. This simply takes advantage of an existing vbulletin mechanic (the url tag) and uses it to create the links for a new feature.

ericgtr 12-16-2004 11:10 PM

Quote:

Originally Posted by Koutaru
Could this be domain specific (ie it can only be your domain they link to?

Very cool, clicks install for near future use, thanks!

???`S?LV?R???` 12-17-2004 12:20 AM

nice hack

docvader 12-17-2004 12:22 AM

works nicely. Only thing I've found is that if you don't put bb codes in that box correctly, it can make your browser hang up. Otherwise, nice addition.

OrangeFlea 12-17-2004 12:54 AM

Nice Hack!!!!!!!!

(cool, you're from Enworld? We have our banner on your webring. That's awesome.)

SVTOA 12-17-2004 01:39 PM

I have it working in 3.0.0
I'm having trouble getting this to display on the navbar in my Vbadvanced CMPS index page though. Displays fine in the forum. Any ideas?

jluerken 12-17-2004 02:38 PM

Quote:

Originally Posted by SVTOA
I'm having trouble getting this to display on the navbar in my Vbadvanced CMPS index page though. Displays fine in the forum. Any ideas?

Yes, thats right. Its also not displaying for me in the CMPS Portal.
Would be nice if this can be fixed :D

Michael Morris 12-17-2004 02:53 PM

I'm not having this problem - but my dropdown system was moved to the header template.

I guess check to make sure your cmps page isn't using a different navbar from you're forums - and that both are executing the PHPINCLUDE_START template.

Speaking of which - I intend to write a module that displays this information in vba cmps - eventually.

Lottis 12-17-2004 03:01 PM

Sorry, but i need some help.

To begin create a user profile field that is multiple text lines and has a character limit of at least 2000. Note the user profile field # the system assigns to the new field - you'll need it below.

Im not quite shure what this means. :blush:

Michael Morris 12-17-2004 03:54 PM

Quote:

Originally Posted by Lottis
Sorry, but i need some help.

To begin create a user profile field that is multiple text lines and has a character limit of at least 2000. Note the user profile field # the system assigns to the new field - you'll need it below.

Im not quite shure what this means. :blush:

You can read up on creating user profile fields here.

In brief, log in to your admincp and scroll down the left menu till you see "User Profile Fields" Expand that box, then click "Create New"

In the first dialog select "Multiple line text box"

On the next screen choose "2000" as the maximum length of user input, then set the last option to display on "Edit Options - Other"

Leave everything else on their defaults. When you exit this screen you'll see a list of all the availabe user profile fields. Look at you're newly create one. You'll see an id#. Note that number and plug it into the phpinclude_start script above.

Guy G 12-17-2004 03:55 PM

looks fantastic.
no queries aye?

Michael Morris 12-17-2004 03:57 PM

No queries required. The data is stored in a custom user profile field.

SVTOA 12-17-2004 06:22 PM

Michael, thanks for the reply.. I use the same navbar for CMPS as I do for the forum, other links I have added work fine in both sections. I'll look a little closer and see if I can get it to work..

Sooner95 12-18-2004 04:03 AM

i did this, but nothing changed lol I will keep looking but.. havnt had this happen before..

SVTOA 12-18-2004 02:20 PM

Ugh, I am pulling my hair out trying to get this to work with with CMPS. I still have my old VbAdvanced index page and when I call that page in a browser the "my links" displays fine! if I call up the vBa CMPS it's no dice. There must be a way to get this to work and I am overlooking it.. :(

SVTOA 12-18-2004 02:44 PM

I have been comparing the code between vBAdvanced homepage and VBA CMPS, and began to play with the index.php files for both. I took this bit of code from vbAdvanced homepage:

Code:

if ($vboptions['home_navbar'])
{
        eval('$navbar = "' . fetch_template('navbar') . '";');
       
        $navbar = str_replace(
        array(
                '"memberlist.php',
                '"usercp.php',
                '"register.php',
                '"faq.php',
                '"calendar.php',
                '"search.php',
                '"login.php',
                '"forumdisplay.php',
                '"profile.php',
                '"private.php',
                '"subscription.php',
                '"member.php',
                '"online.php',
                '"clientscript',
                '\'misc.php',
                "$vboptions[bbtitle]</strong>"
        ),
        array(
                "\"$vboptions[bburl]/memberlist.php",
                "\"$vboptions[bburl]/usercp.php",
                "\"$vboptions[bburl]/register.php",
                "\"$vboptions[bburl]/faq.php",
                "\"$vboptions[bburl]/calendar.php",
                "\"$vboptions[bburl]/search.php",
                "\"$vboptions[bburl]/login.php",
                "\"$vboptions[bburl]/forumdisplay.php",
                "\"$vboptions[bburl]/profile.php",
                "\"$vboptions[bburl]/private.php",
                "\"$vboptions[bburl]/subscription.php",
                "\"$vboptions[bburl]/member.php",
                "\"$vboptions[bburl]/online.php",
                "\"$vboptions[bburl]/clientscript",
                "'$vboptions[bburl]/misc.php",
                "$vboptions[hometitle]</strong>"
        ), $navbar);
}

and went to the CMPS index.php and inserted it directly below this:

Code:

require_once('./global.php');
Renamed the page as test.php and called it up in my browser. This "my links" hack started working on that page.
The ratio of php-to-mysql and page load time changed very little, if any.
I get no errors either. Is this an acceptable fix or have I introduced bad code into the CMPS page?

SVTOA 12-18-2004 03:10 PM

Quote:

Originally Posted by Michael Morris
Two added.

Note, minor glitch found for RC4 - you can't have user input fields beyond 500 characters or so (odd). I presume this is fixed in later versions.

Ugh, I think I have to give up on this one. In 3.0.0:

"Maximum Input (Input, Textarea only)
This setting is how many characters a user is allowed to enter into this field. This can be any number between 1 and 250."

Nice idea but it's not working out like I had hoped. :(

Michael Morris 12-18-2004 07:37 PM

Quote:

Originally Posted by SVTOA
Ugh, I think I have to give up on this one. In 3.0.0:

"Maximum Input (Input, Textarea only)
This setting is how many characters a user is allowed to enter into this field. This can be any number between 1 and 250."

Nice idea but it's not working out like I had hoped. :(

I'm pretty sure you can run a query to override this - run the query after the table is created.

SVTOA 12-18-2004 07:41 PM

And that query would be?

Michael Morris 12-18-2004 07:46 PM

Testing it now - Such things can royally mess up a board if done incorrectly :)

BTW, 3.0.3 allows you to set any length.

Michael Morris 12-18-2004 08:12 PM

The correct query is..

ALTER TABLE userfield MODIFY COLUMN fieldX TEXT

You need to change fieldX to the actual field # you're going to use.

PS you can use this script to up the lengths of the other profile fields, such as biography, if you want.

SVTOA 12-18-2004 08:24 PM

Thank you for the followup, if this works then the hack becomes extremely useful to me and my members. Will check back in a bit.

Jaxx 12-18-2004 08:27 PM

Nice Michael. :)

Along the same lines as the msg I sent you, just got to figure out how to get the actual links to work in the profile view if other members look at it.

I know I could keep it a private field, but whats the fun in that. :p

SVTOA 12-18-2004 08:35 PM

BRAVO!!!! Worked perfectly!!! Much appreciated!!!!

SVTOA clicks *INSTALL*

wirewolf 12-27-2004 08:12 PM

Michael, very nice hack. Installed it today and it went smoothly. However, I have the "Links Directory v1.0.0 RC3" by vBadvanced installed on my forum. All of the "links" directory scripts call for their links_config.php file, which in turn calls for the vbulletins' global.php file, where the PHPINCLUDE_START is called. The "links" templates also call for the vbulletin $navbar. But the "My Links" drop down does not show when you go to the Links Directory Pages. I suspect it has to do with the PHPINCLUDE_START not being called apon correctly in the "links" files, but I'm not sure. I'm not getting any errors. The "Links Directory" files are in a separate directory within my main forum directory.
/home/vbforum/links

See the two attachments. Any clue where to start looking?
Thanks, John

MikaK 12-28-2004 12:56 PM

*click*:)

wirewolf 12-28-2004 01:59 PM

Quote:

Originally Posted by wirewolf
................................... Any clue where to start looking?
Thanks, John

After looking again at the code again (after getting a nights sleep) I think I found the answer. In the code for includes/functions_links.php around line 398:
Quote:

// ##################### Construct Navbar #################################
if (!function_exists('construct_adv_navbar'))
{
function construct_adv_navbar($navbits, $index = 'false')
{
global $vboptions, $vba_options, $vbphrase, $stylevar, $bbuserinfo, $show, $pmbox;
I added $mylinks to the one line:
Quote:

// ##################### Construct Navbar #################################
if (!function_exists('construct_adv_navbar'))
{
function construct_adv_navbar($navbits, $index = 'false')
{
global $vboptions, $vba_options, $vbphrase, $stylevar, $bbuserinfo, $show, $pmbox, $mylinks;
The "My Links" now shows in the navbar when going to my "Links Directory" Pages. The only thing I'm not sure of is in the rest of the code in the Construct Navbar section:
Quote:

if (!empty($navbits))
{
$navbits = construct_navbits($navbits);
}
eval('$navbar = "' . fetch_template('navbar') . '";');

$navbar = str_replace(
array(
'"memberlist.php',
'"usercp.php',
'"register.php',
'"faq.php',
'"calendar.php',
'"search.php',
'"login.php',
'"forumdisplay.php',
'"profile.php',
'"private.php',
'"subscription.php',
'"member.php',
'"online.php',
'"clientscript',
'\'misc.php',
$vboptions['bbtitle'],
'"' . $vboptions['forumhome'] . '.php'
),
array(
'"' . $vboptions['bburl'] . '/memberlist.php',
'"' . $vboptions['bburl'] . '/usercp.php',
'"' . $vboptions['bburl'] . '/register.php',
'"' . $vboptions['bburl'] . '/faq.php',
'"' . $vboptions['bburl'] . '/calendar.php',
'"' . $vboptions['bburl'] . '/search.php',
'"' . $vboptions['bburl'] . '/login.php',
'"' . $vboptions['bburl'] . '/forumdisplay.php',
'"' . $vboptions['bburl'] . '/profile.php',
'"' . $vboptions['bburl'] . '/private.php',
'"' . $vboptions['bburl'] . '/subscription.php',
'"' . $vboptions['bburl'] . '/member.php',
'"' . $vboptions['bburl'] . '/online.php',
'"' . $vboptions['bburl'] . '/clientscript',
'\'' . $vboptions['bburl'] . '/misc.php',
iif($vba_options['links_navbarhomelink'], $vboptions['hometitle'], $vba_options['links_title']),
'"' . iif($vba_options['links_navbarhomelink'], $vboptions['homeurl'], $vba_options['links_homeurl'])
), $navbar);
return $navbar;
}
}
Would any changes have to be made in this section too? I know this coding comes from vbadvanced, but I'm just asking as a general coding question.
John

Michael Morris 12-28-2004 04:40 PM

I don't think so - but I'm soon to find out. I have to install vbadvanced links directory to ENWorld next month :) I'll let you know if I hit any snags.

wirewolf 12-28-2004 06:01 PM

Got an answer from Brian over at vbadvanced. Everything in your coding is fine. The includes/functions_links.php constructs the navbar. The links scripts read the PHPINCLUDE_START template but you have to include $mylinks in the global line and then the "My Links" shows in the navbar on the links directory pages. The only changes in the array section would be if a user did not write in a full url path in the My Links text box. Such would be the case as in [ post=475]Post #475[/post]. The url would show in the "Directory" navbar with the "links directory folder in front of showthread.php - /links/showthread.php etc.. of course being wrong. One fix is to include showthread.php in the array:
Try replacing that function in includes/functions_links.php with this:
Quote:

// ##################### Construct Navbar #################################
if (!function_exists('construct_adv_navbar'))
{
function construct_adv_navbar($navbits, $index = 'false')
{
global $vboptions, $vba_options, $vbphrase, $stylevar, $bbuserinfo, $show, $pmbox, $mylinks;

if (!empty($navbits))
{
$navbits = construct_navbits($navbits);
}
eval('$navbar = "' . fetch_template('navbar') . '";');

$navbar = str_replace(
array(
'"memberlist.php',
'"usercp.php',
'"register.php',
'"faq.php',
'"calendar.php',
'"search.php',
'"login.php',
'"forumdisplay.php',
'"profile.php',
'"private.php',
'"subscription.php',
'"member.php',
'"online.php',
'"clientscript',
'\'misc.php',
'"showthread.php',
$vboptions['bbtitle'],
'"' . $vboptions['forumhome'] . '.php'
),
array(
'"' . $vboptions['bburl'] . '/memberlist.php',
'"' . $vboptions['bburl'] . '/usercp.php',
'"' . $vboptions['bburl'] . '/register.php',
'"' . $vboptions['bburl'] . '/faq.php',
'"' . $vboptions['bburl'] . '/calendar.php',
'"' . $vboptions['bburl'] . '/search.php',
'"' . $vboptions['bburl'] . '/login.php',
'"' . $vboptions['bburl'] . '/forumdisplay.php',
'"' . $vboptions['bburl'] . '/profile.php',
'"' . $vboptions['bburl'] . '/private.php',
'"' . $vboptions['bburl'] . '/subscription.php',
'"' . $vboptions['bburl'] . '/member.php',
'"' . $vboptions['bburl'] . '/online.php',
'"' . $vboptions['bburl'] . '/clientscript',
'\'' . $vboptions['bburl'] . '/misc.php',
'"' . $vboptions['bburl'] . '/showthread.php',
iif($vba_options['links_navbarhomelink'], $vboptions['hometitle'], $vba_options['links_title']),
'"' . iif($vba_options['links_navbarhomelink'], $vboptions['homeurl'], $vba_options['links_homeurl'])
), $navbar);
return $navbar;
}
}
I tried the changes above and they work. But it might be just as easy to have users enter the full url path. Most of mine aren't too good with bbcodes anyway. So I just left in the global line - $mylinks, instructed my users to put in the full url path and everything is working fine.
BTW Michael - you may find other scripting problems in the vbadvanced links program where the links directory folder is placed in front of a typical forum file path - /forum/links/member.php? for example. Look in any array section in the links php files (like browslinks.php, showlink.php, misc.php, etc) that deal with a forum function(member.php is one). Had that problem when I first installed "Links Directory". Brian has cleaned up a lot of the code, but you may hit a snag.
Thanks and have a Happy New Year!!
John

nautiqeman 01-21-2005 06:45 PM

I'm having a simliar problem in the vba Gallery -- I put in the steps above (but of course reflected for the gallery portion), but for some reason, it's not showing up. Any ideas??

jamesyfx 02-02-2005 11:24 AM

Hello,

I'm wondering, would it be possible for an option to click an "Add to Links" button in threads, so it would add a link to the thread to your menu?

A member of my team suggested it, I think it could be useful.. but I don't know how to do it myself.

OrangeFlea 02-11-2005 11:14 PM

I can't get it to show on my navbar. I'm not running Vbadvanced. What's the deal?

mikexxx 02-12-2005 10:06 AM

If i use this link:

PHP Code:

[url=http://www.vbulletin.com/search.php?do=getdaily&days=7]7 Dagen[/url] 

This is the link when i use it:

PHP Code:

http://www.vbulletin.com/search.php?do=getdaily&amp;days=7 

The & (replaced by: &amp;) is not in the link. Is there a solution for this?

OrangeFlea 02-13-2005 03:33 PM

I use vB 3.0.3 without the vbadvanced hack. I entered the information exactly as outlined in the instructions and read every single post in this thread even remotely related to my dilemma, but the link is just not appearing on my navbar.

Can someone -- anyone -- help?

Michael Morris 02-14-2005 03:38 AM

Check to make sure there isn't a parse error in your PHPINCLUDE_START template. To do this, put this in your footer.

$phpinclude_output

Then, if there's a parse error, it will appear in your footer.


All times are GMT. The time now is 05:40 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01699 seconds
  • Memory Usage 1,870KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_html_printable
  • (3)bbcode_php_printable
  • (11)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete