PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 9th, 2004, 06:31 PM
hughzen hughzen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 hughzen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Pass Data over include()?

Hi,


I'm quite new to PHP and I need some help. I want to create a completely templated site - such that index.htm would call on "body.php", and "body.php" would call "header.php", "sidebar.php" and "content.php" - all of which include both HTML and PHP code.

Using include(), I can manage to do that flawlessly. The problem is that I realised that part of the header (say the picture on it) needs to be distinct and different from each page - perhaps even the sidebar too. Reading around, I've found that one can use the include() function and the appropriate code from the called file to generate a returned statement; but that's not what I'm after. My initial thoughts of solving this would be to pass, say "index" to body.php, and that body.php would pass the same to header.php, which would then analyze it and produce the appropriate picture for the page. In that sense, index.htm and news.htm would then have different pictures for their headers.

Is that the right/best way of doing it? If so, what am I missing? If not, what alternative methods can I employ to work around this?

I read also that forms are one way of passing data through but I'd imagine that to be overly complicated for this a simple html file deployment.

Anyways, thanks for your time and I look forward to your replies


Sincerely,
Hugh Zen

Reply With Quote
  #2  
Old June 10th, 2004, 07:10 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
If you set a variable (or pass one at the query string), it's good for all includes. So if index.php has a variable named $page whose value is "index," then referring to $index from any of the sub-includes should allow you to differentiate your headers, etc., using an if or switch block and pulling in the appropriate headers.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old June 12th, 2004, 03:22 AM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
so in all sence. The "index.php" after having included all the subpages. will act as ONE page. that have all the subpages hardcoded into it

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Pass Data over include()?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT