PDA

View Full Version : In or Out? Hack-Version 1.1


ladyfyre
08-05-2002, 10:00 PM
Ok all...this is my VERY first hack written all by myself...so if it sucks, don't pick on me!!!!!

What it does: Well, the primary purpose is to give you separate user navigation/button bar for users who are logged in vs. users who have not registered or are not logged in.
**hint** this could also be used to encourage users to register. You can also add banners at the bottom of the unreg_navbar template which will appear to non-members, but will not appear to members. As they say...membership has it's priviledges :)

Now...my own site is EXTENSIVELY hacked. Many template changes and a few VERY minor hacks here and there of my own invention, along with 35+ hacks from here. If the code in the templates doesn't work perfectly for your site, feel free to change it around. You can also choose to simply copy the code you are currently using in your header file, and delete whatever doesn't apply to each group for that template.
In my version, I have prefixed each image with the imagesfolder replacement code. This is because I offer my users several styles to choose from, and this allows me to easily implement new styles without having things get wonky. Feel free to remove that part if you wish.

Time to implement: about 5 minutes.
Files edited: global.php (1 addition, 1 insertion)
templates edited: header
templates added: loggedin_navbar and unreg_navbar


Ok...here are the steps we need to take:

1. create a new template called loggedin_navbar and paste the contents of the .txt file by that name inside it.
2. create a new template called unreg_navbar and paste the contents of the .txt file by that name inside it.
3. BACKUP YOUR ORIGINAL FIRST, then open global.php and do the following:

Find this section:

// ###################### Start templates #######################
//prepare default templates **********************
if ($templatesused!='') {
$templatesused.=',';
}

Just after it, the line begins like this:

$templatesused.='gobutton,timezone,username_logged out,username_loggedin,phpinclude,headinclude,heade r,footer

Insert this:

loggedin_navbar,unreg_navbar,

after header, but before footer in that line.

Still in global.php

Find This:

// parse PHP include ##################
eval(gettemplate('phpinclude',0,0));

Add After it:


//In or Out Hack
if ($bbuserinfo['userid']<1) {
eval("\$menu_navbar = \"".gettemplate("unreg_navbar")."\";");
} else {
eval("\$menu_navbar = \"".gettemplate("loggedin_navbar")."\";");
}
//In or Out Hack



4. Last but not least...

Edit your header template.

You can remove everything between these lines:

<!-- logo and buttons -->
<!-- logo and buttons -->


and replace them with this:

$menu_navbar


and that is all there was to it.

yeah...i know....kid stuff here...but everyone has to start somewhere..and since most of what i have hacked into our boards is only really applicable there, I am glad to finally have something to share here, since the folks here have given so much to me and my site!!!

If support or help is needed, post it here, and I will happily help if I can :)
Zip and instructions update to include merge the two variables into one.

ladyfyre
08-06-2002, 05:10 AM
Screenshot of view when logged in:

ladyfyre
08-06-2002, 05:11 AM
Screenshot of user logged out or unregistered:

DestyNova
08-06-2002, 05:28 AM
Nice small hack

:thumb up: =)

snyx
08-06-2002, 05:51 AM
love it, installing it now :)

Dean C
08-06-2002, 06:16 AM
:D

Chris M
08-06-2002, 09:30 AM
Nice:)

But you could easily do this in the phpinclude template:)

Satan

ladyfyre
08-06-2002, 09:56 AM
thx to all for the support :)

hellsatan: you are correct, i could have...but i prefer not to use the PHP include unless there is a good reason. My site averages about 200-340 users online at any given time, and despite being on a colocated server, we are seriously in need of a server upgrade, and i have to really watch resources.

Using phpinclude means that the entire phpinclude is loaded into every page, according to my understanding.

Also according to my understanding, routines put into the global.php file are not accessed EVERY time a page loads....but only when they are called.

by all means feel free to correct me if i am wrong on this one.

ladyfyre
08-06-2002, 09:59 AM
for those who prefer hellsatan's way of using phpinclude, follow all the same steps listed above EXCEPT Step 3.

The alternative to step 3 is putting the following code in your phpinclude template, at the very bottom:

if ($bbuserinfo['userid']<1)
{
eval("\$unreg_navbar = \"".gettemplate("unreg_navbar")."\";");
}
else {
eval("\$loggedin_navbar = \"".gettemplate("loggedin_navbar")."\";");
}

DemiNeo0101
08-06-2002, 01:18 PM
Great Job Ladyfyre. This will be really handy for my site. I have alot of Buttens on my nav bar that only work for members. Thanks for releasing it.

[D]Vincent
08-06-2002, 01:34 PM
Vincent]Just wondering but wouldn't it make more sense to use
if ($bbuserinfo['groupid']!=1)
{
eval("\$unreg_navbar = \"".gettemplate("unreg_navbar")."\";");
}
else {
eval("\$loggedin_navbar = \"".gettemplate("loggedin_navbar")."\";");
}

than

if ($bbuserinfo['userid']<1)
{
eval("\$unreg_navbar = \"".gettemplate("unreg_navbar")."\";");
}
else {
eval("\$loggedin_navbar = \"".gettemplate("loggedin_navbar")."\";");
}

Works both way but most people would have used the first one, I wouldn't have even thought about using it that way lol btw nice hack

ladyfyre
08-06-2002, 02:42 PM
[D]Vincent: first of all, i must be losing my mind, because the two blocks of code you just posted appear to be identifcal. unless of course you were trying to be facetious :)
second: while this would have been about a forty second project for many on these boards....it actually took me a couple of hours to get it all done and together...much of that spent looking through php sites and the online manual for the exact thing i was trying to find. My brain has always been wired a little backwards i guess...so i suppose i honestly would not be surprised to find out that i had done different than the norm. Before my site went to vb, i had actually mastered the art of making cgi changes to UBB....and made at least two i am aware of that the tech staff at infopop said wasn't even possible to do without corrupting the db. Unfortunately, my talent has always been having the ideas for things that would make things better....knowing just enough to know what mechanics would work behind it......and having no clue how to write the code to make those mechanics a reality.

Sorry...i will shut up....i guess i am a bit like a mom defending her first born!

g-force2k2
08-06-2002, 03:00 PM
[D]Vincent your's imo would not work... because if you're a guest you don't have a usergroup so it would not equal one but zero...

ladyfyre nice work... but you can change it too...

if ($bbuserinfo[userid]==0)
{
eval("\$unreg_navbar = \"".gettemplate("unreg_navbar")."\";");
}
else {
eval("\$loggedin_navbar = \"".gettemplate("loggedin_navbar")."\";");
}

g-force2k2

Boofo
08-09-2002, 11:19 AM
Great hack there, young lady. :)

I'm using a javascript menu so this is exactly what I need. I can make two menus and call whichever one I need.

Keep up the great work! ;)

Sparkz
08-09-2002, 11:36 AM
Hmm - why not just do like this?

EDIT: Should have chosen a variable that's not used by vB from the start :)
Thanks ladyfyre for reminding me :)


if ($bbuserinfo['userid']<1) {
eval("\$mynavbar = \"".gettemplate("unreg_navbar")."\";");
} else {
eval("\$mynavbar = \"".gettemplate("loggedin_navbar")."\";");
}


And then just use that one variable...
No point in having two different variables for the navbar :)

Boofo
08-09-2002, 12:07 PM
I was going to suggest the same thing earlier, but I think she did a great job with her first hack. It will work either way. ;)

Originally posted by Sparkz
Hmm - why not just do like this?

if ($bbuserinfo['userid']<1) {
eval("\$navbar = \"".gettemplate("unreg_navbar")."\";");
} else {
eval("\$navbar = \"".gettemplate("loggedin_navbar")."\";");
}


And then just use that one variable...
No point in having two different variables for the navbar :)

Webmasta XT
08-09-2002, 01:56 PM
very nice hack...

ladyfyre
08-09-2002, 03:07 PM
Thanks bunches guys...and Sparkz, that is a great idea....i guess sometimes i miss the forest for all the trees!!

Also, special thanks to Boofo :)

You are truly a born diplomat :)

Updating the original file and instructions to include the change.

Boofo
08-09-2002, 03:22 PM
I believe in giving credit where it is due. You did a great job and, in time you'll learn, as we all do, easier ways to do things that can acclomplish the same task in about a hundred different ways. :) I'm still learning and I still have a long way to go.

I just wish my hack was even close to being as useful as yours. Maybe your brain isn't as backwards as you think it is. Looks like it is functioning 110 % to me. :)

Keep up the great work. ;)

Originally posted by ladyfyre
Thanks bunches guys...and Sparkz, that is a great idea....i guess sometimes i miss the forest for all the trees!!

Also, special thanks to Boofo :)

You are truly a born diplomat :)

Updating the original file and instructions to include the change.

Sparkz
08-09-2002, 06:40 PM
Not having an option to show different navbars to logged in and not logged in users as default always annoyed me. I have something similar on my own board.

Good luck with your future hacks :)

ladyfyre
08-09-2002, 06:46 PM
thanks Sparkz :)

Just for the record, in case you want to edit your post above to prevent any confusion from those who might not read down the thread further.....

i got a pm saying that the $navbar variable would cause problems as that is a variable used by the vb software. Just thought i would let you know.

Sparkz
08-09-2002, 06:54 PM
When you mention it, you're right... I just took the first thing I could think of.

Boofo
08-09-2002, 06:58 PM
And here I was thinking that we had cured Sparkz of that thinking stuff. ;)

Originally posted by Sparkz
When you mention it, you're right... I just took the first thing I could think of.

Sparkz
08-09-2002, 07:03 PM
Hehehe :)

No comment on that one :)

Zombie-F
01-02-2003, 08:11 PM
Originally posted by ladyfyre
// parse PHP include ##################
eval(gettemplate('phpinclude',0,0));

Add After it:


//In or Out Hack
if_($bbuserinfo['userid']<1) {
eval("\$menu_navbar = \"".gettemplate("unreg_navbar")."\";");
} else {
eval("\$menu_navbar = \"".gettemplate("loggedin_navbar")."\";");
}
//In or Out Hack


There's an error in your instructions. The line that says:
if_($bbuserinfo['userid']<1) {

Should say:
if ($bbuserinfo['userid']<1) {

The underscore causes a fatal error. You may probably want to fix it in the first post here as well as the instructions. Thanks for the useful hack. :)

ladyfyre
01-02-2003, 08:57 PM
Actually, the underscore i think somehow got added here on the forums, because it doesn't exist in the zip file instructions.....and none of my other copies have it there either.

Zombie-F
01-31-2004, 11:19 AM
Argh! I can't get this to work with version 2.3.4. I get the following Error Message:

Parse error: parse error in /home2/www/badassuniverse/forums/global.php on line 347

Fatal error: Call to undefined function: getpermissions() in /home2/www/badassuniverse/forums/index.php on line 10

Zombie-F
02-02-2004, 10:21 PM
Anyone have any ideas as to why this doesn't seem to work with vBulletin 2.3.4? :ermm:

vdich
06-20-2004, 06:54 AM
Anyone have any ideas as to why this doesn't seem to work with vBulletin 2.3.4? :ermm:


u have to insert the folow code in php-include not in the global.php:

if ($bbuserinfo['userid']<1)
{
eval("\$menu_navbar = \"".gettemplate("unreg_navbar")."\";");
}
else {
eval("\$menu_navbar = \"".gettemplate("loggedin_navbar")."\";");
}