Welcome to WebmasterWorld Guest from 188.8.131.52
Right now I use php require to call up the head, two sides and the footer. I see alot of people use php include... what's the dif and what's better with include?
Also can I have a dynamic page call up another dynamic page? I'm sure you can but is it wise.
In the <title> tag, is there a way to call up a page taht I want? Like since my layouts change and I don't want to go through every page and cut and paste codes, is there a way to just call up a .txt file that I want shown. I have one do this in the body, but can it be done in the title.
Now one question with templates that still is getting to me, alot of people are using $content=... but when you have alot of pages... why would u have that... unless there is a way... like a database... ah...
So you have that call up a page the user requested and it's stored in a database... Wouldn't a database in php terms be just another file with all the pages listed with an ID? Then have the $content= call up from that page whatever the person called for?
Haha frustrating yes, but it really helps me out ^.^ Thank you!
Also can I have a dynamic page call up another dynamic page?
I don't know what you mean. You mean one page that redirects to another? That's absolutely fine depending on circumstances.
In the <title> tag, is there a way ... to just call up a .txt file that I want shown.
<title><? include('title.txt');?> </title>
alot of people are using $content=... but when you have alot of pages... why would u have that.
Because you do all your processing and put your page into variables like $title, $content, etc. Then all your template does is variable substitution like
===== file: my_page.php ========
$content = "<p>This is my content from my database, files or wherever I get it.</p>";
$title = "Title of the page from my database";
======== end file my_page.php ==============
===== file: default_template.php ========
=========== end file ===========
So the page would be like...
then when you call it up it prints what you call on the page, correct?
Then you have the layout come after (but wouldn't it have to be called before to make it all show up correctly?).
Then in your template page is "?" the title? because the code was <title><?=$title?></title> make it look like? was the value of $title. Oh no your asking what is the title, and it equals $title oops.
And I meant if I have a dynamic page (side.php) call up something like... (version.txt) is it safe, i'm already doing it so it was stupid to ask, but i figured it out after i asked...
Now this opens doors for me...
If I have one page that has all the different headers and footers of pages... then I call up the page and the value... that's fine... correct? I can show you an example if you'd like but you just helped me alot (if all be true) otherwise i'm more confused lol.
Thanks for the answer :)
I also initialize variables
$content = "";
so I don't get errors.
Then page.php defines $title and $content for that page.
Finally, at the end of page.php, I include the template which defines layout.
call up something like... (version.txt
Fine. Though it's easier to keep track of to use an extension that corresponds to content
.txt if no markup
.html if no php
.php if there is php
I think this article will help you get your head around things:
So I CAN make a page taht is all variables and call from them right?
And u make the end of the page the template, i c i c... I think i'm gettin git...
So have the variables, then make a page that calls on these variables. and then wrap the layout around this in a page that is called after all this... I think I get it... if i'm right that is ^.~
Right now i have the template to just:
$content is a variable in the page originally being called, yet it keeps giving me an error that the variable doesn't exist!
It's REALLY basic!
$content="<p>This is my content from my database, files or wherever I get it.</p>";
$title="Title of the page from my database";
what can POSSIBLE be wrong!?!? The template keeps bring up an error on line 7 which is the echo $content'! Waht is going wrong >.<
(sighs) so close! lol.
[edited by: jatar_k at 1:36 am (utc) on July 18, 2004]
[edit reason] removed url [/edit]
So the settings.php is for like the title and headers and stuff right?
No. It is for sitewide setting that will be used on every page, like initializing the database connection. Including fundamental classes and function libraries that will be used on every page. There is NO HTML there.
I put my doctype, html tag and all that in the template. The page variables then get thrown into to the template, which also has include statements for the page header (that's the header AS VIEWED not the stuff in the <head> tag; you can put that in the template or in an included file. I put it in the template and add any page-specific html there that I need with page-specific variables in page.php).
Well it reads your text, but I have the echo command underthat, it doesn't have an error, and it doesn't even recognize what the content is.
For some reason it's like the template isn't reading the page with the variables. So very odd.
Now I just re-copied what the other guy had and made other files... they work... sorta... and it's a tad more complex (realize I was just fooling around seeing if i can find the source of the error)
$content = "<p> Version 4 only has this one page, but you can see where i'm going with it. Below is a list of what
else you can expect from Version 4:";
$title = "Test";
That oddly works, except the bottom page is showing right after the header... >.< I dunno why!? lol
Ok... I just crossed my files, where the old went with the new files, worked fine both combinations, but them back to how they work, still fine... then on the old files I changed the title... error on $content again... When it did work when I loaded it b4 the title change the title still read that there was an error... yet it loaded.... it's odd...
[edited by: jatar_k at 4:29 pm (utc) on July 19, 2004]
[edit reason] removed urls [/edit]