Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Coding Releases > Coding Snippets
You last visited: Today at 03:37

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release] Dynamic current page in menu

Discussion on [Release] Dynamic current page in menu within the Coding Snippets forum part of the Coding Releases category.

Reply
 
Old   #1
 
turk55's Avatar
 
elite*gold: 130
Join Date: Oct 2007
Posts: 1,655
Received Thanks: 705
[Release] Dynamic current page in menu

Code:
var url = window.location.pathname, 
    urlRegExp = new RegExp(url.replace(/\/$/,'') + "$"); 
if(url == '/') {
	$('#menu a').first().addClass('active');
} else {
	$('#menu a').each(function(){
		if(urlRegExp.test(this.href.replace(/\/$/,''))){
			$(this).addClass('active');
		} 
	});		
	if($('#menu a').hasClass('active') == false) {
		$('#menu a').first().addClass('active');
	}
}
turk55 is offline  
Old 02/17/2014, 22:54   #2

 
adistoe's Avatar
 
elite*gold: 63
Join Date: Oct 2012
Posts: 1,181
Received Thanks: 139


Warum mit jQuery?
Ginge doch auch einfacher nur mit php?
adistoe is offline  
Old 02/18/2014, 15:50   #3
 
turk55's Avatar
 
elite*gold: 130
Join Date: Oct 2007
Posts: 1,655
Received Thanks: 705
Quote:
Originally Posted by adistoe View Post


Warum mit jQuery?
Ginge doch auch einfacher nur mit php?
JQuery makes it alot easier.
This way you don't have to add the current page class item in the menu manually, it will be done automatically for you.
turk55 is offline  
Old 02/20/2014, 22:24   #4
 
Hyukisawa's Avatar
 
elite*gold: 133
Join Date: May 2007
Posts: 506
Received Thanks: 194
in php you can do it also automatically

you need also the class item but its also possible ^^
Hyukisawa is offline  
Old 02/21/2014, 01:38   #5
 
turk55's Avatar
 
elite*gold: 130
Join Date: Oct 2007
Posts: 1,655
Received Thanks: 705
Quote:
Originally Posted by ci40pg View Post
in php you can do it also automatically

you need also the class item but its also possible ^^
I know that it can be done in php but if you are not building the menu dynamically from the database and just have a single php file with the menu you might want to reconsider using php. Don't forget that this can be used in combination with many other languages and not necessarily php.
turk55 is offline  
Reply


Similar Threads Similar Threads
[Release]Dynamic Maps(5165 Houses)
07/28/2019 - CO2 PServer Guides & Releases - 60 Replies
Alright well I found this on another forum and I got the creator's permission to post here with all credits towards him. 100% credits to pringle, you may know him. DO NOT PRESS THANKS! THIS IS NOT MY WORK! After following my guide previous guide, then proceed with the following. in DMaps.cs under: public static ArrayList MapsNeeded = new ArrayList() { 601, 700, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1018, 1020, 1021,...
[RELEASE]Dynamic say->color
11/28/2012 - Metin2 PServer Guides & Strategies - 14 Replies
Hello, I've been gone for a long time. I want to do something. This is questlib.lua for say function I'm create class. Source code: -- poXavincS from first published to elitepvpers.com -- 19/11/.12 SAY = {} SAY.__index = SAY
[Release]Solution for c9 Behind Router / Dynamic
12/24/2011 - SRO Private Server - 10 Replies
If you read the guide on how to run a server with a Dynamic IP or behind a router then you most likely ran into the issue with the c9 from a wan connection outside your Ip. The issue seems to be the server programs and files not being able to pass your router when a connection comes in. No matter what ports you forward or what exceptions you add anywhere. Our solution was this. If your internet is set up like this Modem > Router > Computer / Wireless PC's



All times are GMT +1. The time now is 03:37.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.