Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 19 Feb 2021, 10:50
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Real name: Ryan
Question [General Development] Highlighting active page in a navbar?

When it comes to highlighting the active page in a navbar I find myself using if conditions, just what I've grown accustomed to.

Example: (may not be perfect, just going from the top of my head)

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I was wondering to avoid the multiple if's, is their an easier way (or better way) for achieving this concept?

I'm asking here rather than on stack because we are vBulletin users, and a lot of stack members tend to have issues with vb lol, and maybe vb has a whole different way of detecting the current page.
__________________
If you need custom work done please use Dirt RIF CustUmz
Owner of vBTeam
vBulletin 3.8.14 DRC Edition PHP 7.4 Compatible- NOT a null, NOT complete files Requires a legit copy of vBulletin 3.8.11.
Reply With Quote
  #2  
Old 19 Feb 2021, 15:57
yilmaz's Avatar
yilmaz yilmaz is offline
 
Join Date: Sep 2004
Change

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

To

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Donations always appreciated.
vByilmaz.com
vBulletin-forum.de
Nobody has a monopoly on vBulletin templates. Stay away from selfish, self-righteous and parasitic.
Reply With Quote
  #3  
Old 19 Feb 2021, 16:52
puertoblack2003's Avatar
puertoblack2003 puertoblack2003 is offline
 
Join Date: Aug 2005
Originally Posted by yilmaz View Post
Change

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

To

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
isn't that vb 4 vb statement ?
__________________
Android Custom Creations
Reply With Quote
  #4  
Old 19 Feb 2021, 16:57
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Real name: Ryan
Originally Posted by yilmaz View Post
Change

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

To

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
no no no lol, I'm sorry if I wasn't clear its not about vb3 or vb4. It's about coding in general. I'm wondering if there is a better approach to detecting which page I am on, rather than having to use an if condition for each link.

I got to thinking a jQuery solution, I may add classes based on links. It would look something like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Which I'm thinking will be way better than a bunch of if conditions. it would turn that top piece of code into:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Which is much easier to work with rather than having a bunch of ifs
as for the link we want styled if its not the current page, add its own class to it, and tell jQuery to remove it if it is the current page.
__________________
If you need custom work done please use Dirt RIF CustUmz
Owner of vBTeam
vBulletin 3.8.14 DRC Edition PHP 7.4 Compatible- NOT a null, NOT complete files Requires a legit copy of vBulletin 3.8.11.
Reply With Quote
  #5  
Old 19 Feb 2021, 19:06
yilmaz's Avatar
yilmaz yilmaz is offline
 
Join Date: Sep 2004
Originally Posted by puertoblack2003 View Post
isn't that vb 4 vb statement ?
Sorry, I replied as the topic is in the vb4 section.
__________________
Donations always appreciated.
vByilmaz.com
vBulletin-forum.de
Nobody has a monopoly on vBulletin templates. Stay away from selfish, self-righteous and parasitic.
Reply With Quote
  #6  
Old 19 Feb 2021, 19:14
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Real name: Ryan
It was more a coding in general type of question, maybe should have posted in private coders, but i feel this section gets the most viewers lol.

It's something that could be applied too ANY vb version though.
__________________
If you need custom work done please use Dirt RIF CustUmz
Owner of vBTeam
vBulletin 3.8.14 DRC Edition PHP 7.4 Compatible- NOT a null, NOT complete files Requires a legit copy of vBulletin 3.8.11.
Reply With Quote
  #7  
Old 19 Feb 2021, 19:33
yilmaz's Avatar
yilmaz yilmaz is offline
 
Join Date: Sep 2004
Originally Posted by Dr.CustUmz View Post

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
This is the most logical.

Note: Maybe you know, you should always specify the name of that file first in the custom php page.
custom.php

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Donations always appreciated.
vByilmaz.com
vBulletin-forum.de
Nobody has a monopoly on vBulletin templates. Stay away from selfish, self-righteous and parasitic.
Reply With Quote
  #8  
Old 19 Feb 2021, 19:36
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Real name: Ryan
so using if conditions is the way you would do? It just felt like too much, and I got to thinking of alternative ways lol
__________________
If you need custom work done please use Dirt RIF CustUmz
Owner of vBTeam
vBulletin 3.8.14 DRC Edition PHP 7.4 Compatible- NOT a null, NOT complete files Requires a legit copy of vBulletin 3.8.11.
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add-On Releases Navbar Mod - adds social bookmarking, notifications highlighting, & search fields vbboarder vBulletin 3.7 Add-ons 32 09 Mar 2012 05:08
Add-On Releases Navbar - adds social bookmarking, notifications highlighting, & search fields vbboarder vBulletin 3.8 Add-ons 41 30 Nov 2009 05:51



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 10:14.

Layout Options | Width: Wide Color: