User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,490 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,230 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1923 | Replies: 11
Reply
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation: roryt will become famous soon enough roryt will become famous soon enough 
Rep Power: 6
Solved Threads: 9
roryt's Avatar
roryt roryt is offline Offline
Veteran Poster

Help Repeat text from somewhere else in a document without actually writing it!

  #1  
Nov 17th, 2006
Ok, so I am a total PHP n00b so I will explain my problem then say how I would personally logically solve it.

I am creating a website using a php include at the top of the page (same for every page on the site) and one for the bottom of the page. Basically what I want to do is have (what I call) a tree at the top of my page inside my header include file. By tree I mean something like "Home> Tutorial> Html Tutorial > using tables Tutorial". This would of course change based on the page that is being viewed.

My logical solution:

Instead of my tree text in pure html I would have something like "home + Variable". The variable would then be specified at the top of my html file that is the content for the page.

I hope that all makes sense. I would be really grateful if someone could tell me how to do this using PHP. Thank in advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Posts: 35
Reputation: boo_lolly is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
boo_lolly boo_lolly is offline Offline
Light Poster

Re: Repeat text from somewhere else in a document without actually writing it!

  #2  
Nov 17th, 2006
i'm very interested. i'm a noob too, but i think i can do it. but i'm a little baked right now and jamming TOOL. so i'll get back to you later tonight for sure. very interesting.
Reply With Quote  
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation: roryt will become famous soon enough roryt will become famous soon enough 
Rep Power: 6
Solved Threads: 9
roryt's Avatar
roryt roryt is offline Offline
Veteran Poster

Re: Repeat text from somewhere else in a document without actually writing it!

  #3  
Nov 19th, 2006
I really need help with this. If anyone can help me I would be very grateful!!!
Reply With Quote  
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation: roryt will become famous soon enough roryt will become famous soon enough 
Rep Power: 6
Solved Threads: 9
roryt's Avatar
roryt roryt is offline Offline
Veteran Poster

Re: Repeat text from somewhere else in a document without actually writing it!

  #4  
Nov 21st, 2006
Hi guys,

I still haven't found an answer for this and it is vital for my site. I would be so grateful for any response. I will give a gmail invite to anyone who help me, I promise!!!
Reply With Quote  
Join Date: Oct 2006
Posts: 7
Reputation: nickclarson is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
nickclarson nickclarson is offline Offline
Newbie Poster

Re: Repeat text from somewhere else in a document without actually writing it!

  #5  
Nov 22nd, 2006
ok here we go:

header.php
<html>
<body>

Home > <?php echo $variable; ?>

page.php
  1. <?php
  2.  
  3. $variable = "Current Page";
  4. include "header.php";
  5.  
  6. ?>

I hope that helps you out =)
Reply With Quote  
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation: roryt will become famous soon enough roryt will become famous soon enough 
Rep Power: 6
Solved Threads: 9
roryt's Avatar
roryt roryt is offline Offline
Veteran Poster

Re: Repeat text from somewhere else in a document without actually writing it!

  #6  
Nov 22nd, 2006
You had me going for a bit but I have cracked it. It wasn't that you were wrong it was that I didn't realise that you had done the include for me too. Thank you very much mate excellent. Please see the gmail invite in your inbox!
Reply With Quote  
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation: roryt will become famous soon enough roryt will become famous soon enough 
Rep Power: 6
Solved Threads: 9
roryt's Avatar
roryt roryt is offline Offline
Veteran Poster

Re: Repeat text from somewhere else in a document without actually writing it!

  #7  
Nov 26th, 2006
Another question related to this:

What happens if i want to turn all the parts of my tree into hyperlinks which will need to be from http:// upwards. Eg.

[PHP]<?php

$variable = ("<a href="http://www.mysite.co.uk/tutorials/">Tutorial</a>&gt;
<span><a href="http://www.mysite.co.uk/tutorials/photoshop/">Photoshop Tutorial Home</a></span>");

include ("includes/header.php");

?>[/PHP]

Basically what happens is the tree goes through each page it is logical to go through to get to the current page and puts them as links and then has the page you are currently on inside span tags which I have used to make the text larger.

any help would be gratefully recieved.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 943
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: Repeat text from somewhere else in a document without actually writing it!

  #8  
Dec 1st, 2006
if you arange your folders like a tree, and have each page as the folder index... then you can just link relatively to the folder above*, like this: "../". if you don't arrange your files into a neat and logical tree, i'd advise that you do.

*above being towards the http:// in matt-syntax
Last edited by MattEvans : Dec 1st, 2006 at 4:52 pm.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation: roryt will become famous soon enough roryt will become famous soon enough 
Rep Power: 6
Solved Threads: 9
roryt's Avatar
roryt roryt is offline Offline
Veteran Poster

Re: Repeat text from somewhere else in a document without actually writing it!

  #9  
Dec 1st, 2006
Yes obviously but!

Because my folders are done nice and neatly and I do only have one header.php all the links must be done down to http:// otherwise when the html is inserted into the content php the links will break depending on which folder they are in. I hope this makes sense.

Still looking for an answer.. Anybody?
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 943
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: Repeat text from somewhere else in a document without actually writing it!

  #10  
Dec 1st, 2006
hmmm, not sure I understand that? you should be able to include a file from the document root directory, by preceding it with a slash, ie:
include ("/includes/header.php");
... maybe that will go to your "home" directory though...

EDIT: Well, on my server, / goes to the server root folder. So, you'll need to know the path from the server root folder to your document root (public_html) folder. You can find that using:
<?php echo getcwd() ?>
For me, that's /home/fusion/public_html/(+ the path to the folder where the echo getcwd script is running in).

So, to get a file from the "includes" folder in my document root in PHP, I'd use:

include ("/home/fusion/public_html/includes/header.php");

This will be different for your server, and it may even be based from a "C:\" drive if you're hosted on a Windows flavour...

There is an environment variable you can use to find the server's document root I think, don't know which one, but it's probably DOCUMENT_ROOT... =)

EDIT (2): You should use absolute hrefs if your header includes ok but the links are 'broken'. Or, write some complex logic ^_-
Last edited by MattEvans : Dec 1st, 2006 at 7:43 pm.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 12:16 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC