Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    A variable changed per page

    Hi there guys. It's obvious through the topic title that I'm not really familiar with HTML. I'm a C/C++ and Objective-C programmer actually. I really need to use and learn HTML now though. Dreamweaver's really helping me, but I still need some help.

    I want to design a navigation bar with few buttons. Every button has a transparent background. When you hover, it gets brightened (or whatever effect it is), and when you click, the background changes to something else. For example, the main background is blue, clicking changes it to green and of course you're on a different page.

    However, I want to set a variable or so, and check the current page so I don't have to write the navigation code at every single page. Is there a way to do so? Must I use php/javascript? If the only way is to use java or php, can someone help as I really suck at both?

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,955
    Thanks
    9
    Thanked 726 Times in 720 Posts
    Are you talking about highlighting the current page link in some way? I think you are...have a look at this which explains how to this with html/css only.

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Yea, I know about the selector thing.

    A problem is there though. The buttons are actually "images". There's no CSS function to set the src of the image. Some guys talk about the background-image thing, but I don't think that's stable and promising enough.

    I guess the only way to solve that would be php or javascript

    Another P.S: I've worked about a year with phpBB, so I have some HTML and CSS experience Never thought about learning php though as that was before I learnt C.

  • #4
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi TheNavigator,

    Why isn't background-image stable or promising? It is kind of standard. There is no danger of it being deprecated soon.

    Good luck

  • #5
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Okay then netsentry. I'll try that and reply with the result

    EDIT: Just decided to let it be hard-coded. Thank you guys for your help anyway
    Last edited by TheNavigator; 08-04-2012 at 08:12 AM.

  • #6
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts
    Code:
    .nav ul li a:hover {brighten effect}
    .nav ul li a:active {background image}
    .nav ul li {background}

  • #7
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts
    You have to use a dynamic page/url

    Example:


    index.php

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
    <head>
    <title>Website Name- <?php echo $_GET['p']; ?> - Slogan!</title>
    	<link rel="shortcut icon" href="/images/favico.ico" />
    <!-- meta -->
    	<meta name="author" content="--" />
    	<meta name="keywords" content="--" />
    	<meta name="description" content="--" />
    
    <!-- styles -->
    	<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
    
    <!-- scripts -->
    	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    	
    </head>
    
    <!-- start //body -->
    <body>
    <div id="wrapper">
    		<?php				
    		$filename = 'includes/header.php';
    			if (file_exists($filename)) {
      				include "$filename";
    			} else {
        				echo "The file $filename does not exist";
    		}
    		?>
    <div id="page">
    	<div id="page-bgtop">
    	<div id="page-bgbtm">
    	<div id="content">
    
    <?php
    
    // This will include your content //
    
    $pages_dir = 'includes'; //pages file dir//
    
    if(isset($_GET['p'])){ $page = $_GET['p'];
       		 if(!strpos($page, '.') && !strpos($page, '/')){
          			  if(file_exists('./'.$pages_dir.'/'.$page.'.php')){
                		include_once('./'.$pages_dir.'/'.$page.'.php');
            	} else {
                	header ('location: /index.php?p=home&error'); //error page //
            }
        } else {
            echo "Access Forbidden!";
        }
    } else {
        include_once('./'.$pages_dir.'/home.php');
    }
    ?>
    </div>	
    		<div style="clear: both;">&nbsp;</div>
    	</div>
    
    		<?php include("includes/sidebar.php"); ?> 
    
    </div>	
      		<?php include("includes/footer.php"); ?>
    </body>
    </html>
    You will create all of your pages in dir "includes"

    This is just an example..

    NOTE: If you look at the title it will take the name of the current page open and display it..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •