Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-30-2008, 07:36 AM   #1 (permalink)
wolf99
Code Monkey
 
wolf99's Avatar
 
Join Date: Jan 2006
Location: jobless (again) in rural Eire
Posts: 54
wolf99 is on a distinguished road
n00b echos and includes

Hi All

I have recently started learning PHP in rather peicemeal fashion, trying bits on my site as i go.

i have been using a switch loop in navigation for a while to include the page's main content. Now I want to change the heading text (that is part of the static page) to reflect teh current page content.

Currently I have settled on using a second switch that echo's out the change dependant on th passed id (as is the other switch is also), but this is a bit heavy handed. Is there any sleeker standards compliant (accessibility v. important) method of acheiving same??

thanks for help or pointers!
__________________
Current Project
wolf99 is offline   Reply With Quote
Old 12-31-2008, 05:16 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,704
sde is on a distinguished road
hmm .. what exactly are you working on? .. a normal web site? can you show any examples of what you're talking about?

i could take a guess at what you're trying to achieve, but it would probably be way off cause i'm not certain what you're talking about.

Maybe you're in need of a templating system, or maybe you're just looking for an alternate way of doing things? There's a million ways to architect re-usable headerr/nav/footers in a site, ... here's one very simple example.

includes/global_header.php
PHP Code:
<html>
<title><?php echo $page_title?></title>
<body>
  <h1>My Cool Site</h1>
  <div class="nav">
    <a href="/">Home</a>
    <a href="some_page.php">Some Page</a>
  </div>
includes/global_footer.php
PHP Code:
<br />
&
copy 2008 All Rights Reserved
</body>
</
html
some_page.php
PHP Code:
<?php
$page_title 
"Some Page";

include 
'includes/global_header.php';
?>

This is some page ...

<?php
include 'includes/global_footer.php';
?>
__________________
Mike
sde is online now   Reply With Quote
Old 01-08-2009, 08:16 AM   #3 (permalink)
wolf99
Code Monkey
 
wolf99's Avatar
 
Join Date: Jan 2006
Location: jobless (again) in rural Eire
Posts: 54
wolf99 is on a distinguished road
thanks

hey sde

thanks for your help, I was following up on it when I came across a method I think will sit better into the page I have

PHP Code:
Re: n00b include and echo Q
to keep the basic layout of the PHP on your page, you could just have your switch at the beginning of the page, and make variables for the title and include. a quick example:

PHP Code:
<?php
  
switch($_GET['page']){
    case 
"about":
      
$title "About Me";
      
$include "abt.php";
      break;
    case 
"contact":
      
$title "Contact Me";
      
$include "cntct.php";
      break;
    case else:
      
$title "Home";
      
$include "home.php";
  }
?>
<h1><?php echo $title?></h1>
<blockquote>
<?php include($include); ?>
</blockquote>
If ya wan to check the site out: Curriculum Vitae of Toby Mole just a cv site i made to experiment with code and stuff

thanks again
__________________
Current Project
wolf99 is offline   Reply With Quote
Old 01-08-2009, 11:50 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,704
sde is on a distinguished road
great to hear. thanks for the update.
__________________
Mike
sde is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net help.. (n00b) crisischris MS Technologies ( ASP, VB, C#, .NET ) 1 03-02-2006 06:01 AM
managing directories(total n00b) glglgl Platform/API C++ 2 09-23-2005 08:31 AM
ASP N00b - How to check if a variable is set? or empty? helz MS Technologies ( ASP, VB, C#, .NET ) 3 11-04-2004 11:19 AM
n00b question re: java sde Java 5 08-04-2003 04:26 AM
Yup. Another n00b. Rie Lounge 3 03-07-2003 09:36 PM


All times are GMT -8. The time now is 03:41 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting