Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

put contents of linked file into section of document

0 views
Skip to first unread message

Christina

unread,
May 7, 2006, 4:52:06 PM5/7/06
to
I'm pretty new to using PHP, so please bear with me.

This subject has probably been covered a hundred times, but I can't find a
clear answer on the web or in a newsgroup. I have a 650 page intranet site
that I am working on with categories and subcategories (each in their own
subsequent folders) and I am using PHP (4.1+) and MySQL for populating
links. There will be a dynamically populated menu from the database. The
users will be uploading files whose links will be added to the database
through a form.

I have the header, navigation, and footer sections in their own PHP/HTML
files to be included on page with the <?PHP include
("includes/filename.html"); ?>. This part is easy, but I have to create a
whole new page for each and every web page that includes this code. What I
need to do is have the basic .html page show up in the content section of
the current page when a person clicks a link in the navigation menu or
current page. Essentially I would want it to work like a framed page (<a
href: "linkedpage.html" target="content">, but I don't want to use frames or
iframes.

I would also like to have the page that was inserted be reflected as a URL
in the browser location for bookmarking, as well as have the page title be
automatically assigned. In my search on the web I find a lot of reference to
combining PHP and Javascript. I believe I've seen it done with Javascript
using the GetElementByID method, but it's been a while since I've written
Javascript.

I'm sure there is a simple basic way to format each link itself in just PHP.
Should I assign a variable to hold the value of the link? I assume it
includes having a <div id="content">. Should I format the link or the
content section with HTTP_REFERRER or use File_Include_Path or does this
have to do with fopen_wrapper? There are so many different things I've
seen, but nothing conclusive, that my head is spinning.

Thanks,

Chris

Rene Pot

unread,
May 7, 2006, 7:34:19 PM5/7/06
to
If each page has his own ID/name, then you can use the get "script":

<?
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
$id = 0;
}
?>

If you use this code, you need to link to a page like: <a
href="?page&amp;id=20">Link</a>
If you want the title to change, just use <title><? echo (&id) ?> That
makes the title change into the ID
The same with link's ;)

Christina

unread,
May 7, 2006, 10:47:53 PM5/7/06
to
Thank you Rene...would the if/else go in the content section?

I guess I'm not clear on how to generate the linking text into propogated
menu either. Can you clarify the use of &amp; for me? Is it there to tell
the browser that it's an html ampersand? Wouldn't it need to use a
variable? (id=$pageid). The links table in the database will have the
pageID, pagename, pagetitle, category, subcategory, etc.

Thanks again,

Chris

"Rene Pot" <ren...@chello.nl> wrote in message
news:1ab9d$445e83e4$3ec2ab98$83...@news.chello.nl...

MS

unread,
May 8, 2006, 8:59:24 AM5/8/06
to
Your basic index.php would be something like the following.

<?php
require_once "header.php";

// Set Default Page ($pageid)
if(!isset($pageid) || !file_exists($pageid.".php")) $pageid= "default";


if(file_exists($pageid.".php")){
include $pageid.".php";
}

require_once "footer.php";
?>

where pageid can be "words" or "numbers"

links are created by ....

echo "<a href='?pageid=".$linkid.">Link</a>";

--
----------------------------------------------------------------------------
http://www.myclubweb.co.uk - The Home of Club Websites
----------------------------------------------------------------------------


"Christina" <desi...@centurytel.net> wrote in message
news:2KydnQNgXqP...@centurytel.net...

Christina

unread,
May 8, 2006, 9:40:30 AM5/8/06
to
Thank you, that makes more sense to me. A couple more questions: What is
the purpose/function of inserting the ".php" into the file exists code?
Does that mean all called/inserted pages will have to be .php? What is
the $linkid variable attached to? I like to understand each part in order
to be able to alter if needed.

Thanks again,

Chris

"MS" <nospamplae...@yahoo.co.uk> wrote in message
news:WKGdndoCFbe...@bt.com...

MS

unread,
May 8, 2006, 6:53:39 PM5/8/06
to
What is the purpose/function of inserting the ".php" into the file exists
code?
This is just how my site is set up. There is only one page...but 3 steps to
"index.php"

Step 1) index.php outputs the header.php (require_once "header.php";)

Step 2)
then index.php includes a file dependant upon $pageid
eg. $pageid = "profile"
therefore the profile.php page is included (if it exists)

Step 3)
index.php then outputs the footer (require_once "footer.php";)

Does that mean all called/inserted pages will have to be .php?

pages ending with .php do not need to contain any php code. (they can be
plain html) if they do contain php code... the code will be parsed.

What is the $linkid variable attached to?

$linkid is same as $pageid i just changed the name so you didn't get
confused... lol.. silly me.

$linkid would contain your page names... eg "profile" or "calendar" so that
when clicked it includes the profile.php page or calendar.php page...


"Christina" <desi...@centurytel.net> wrote in message

news:HomdnY1Rt63...@centurytel.net...

Christina

unread,
May 9, 2006, 9:42:50 AM5/9/06
to
Excellent. This is a great help. I'm sure I'll be back with more
questions...It's not easy for a novice to write groupware...

Thanks again...

Chris

"MS" <nospamplae...@yahoo.co.uk> wrote in message

news:lPqdnSwLhsO...@bt.com...

0 new messages