Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 02-05-2008, 10:29 AM include
Joshy D's Avatar
Extreme Talker

Posts: 178
Name: Josh
Trades: 0
sorry, title isnt descriptive, i couldnt make this short enough for a title.
also I dont know if the solution is in PHP or CSS so im posting in both places.

ok, so i have 4 files:

* index.php
* indexs.css
* template.php
* templates.css

in index.php i have:
<?php
include 'template.php';
?>

that works so now my page has a template (this same template file is being used for all pages) but now in index.php i want to add seperate content but no matter what i do it just shows up below the template.php and not in the area on the template that i want to have it in,, and i dont want to use position: absolute in the css.
Joshy D is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-05-2008, 11:13 AM Re: include
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Josh... u really need to post the codes for a start! using the [php] and [code] tags of course

as i said probs best using php variables to drop content into template,
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 02-05-2008, 12:38 PM Re: include
Joshy D's Avatar
Extreme Talker

Posts: 178
Name: Josh
Trades: 0
ok,

index.php:
PHP Code:
<body>

<?php
include 'template.php';
?>

</body>
template.php:
PHP Code:
<div id="wrap">

<div id="banner">
</div><!---banner--->

<div id="mainarea">
</div><!---mainarea--->

<div id="footer">
Copyright &copy; Swindon Youth For Christ 2007-<?php echo date("Y"?><br />
<font size="1px">Designed and Constructed by Joshua Davison | Maintained by SYFC</font>
</div><!---footer--->

</div><!---wrap--->
in the div id="mainarea" is where i want to put the content, but also on one page i want to put more div's in that area so that may complicate things.
Joshy D is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 02:30 PM Re: include
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
have something like this mate:
PHP Code:
<div id="wrap">

<div id="banner">
</div><!---banner--->

<div id="mainarea">
<? echo $main_content?>
</div><!---mainarea--->

<div id="footer">
Copyright &copy; Swindon Youth For Christ 2007-<?php echo date("Y"?><br />
<font size="1px">Designed and Constructed by Joshua Davison | Maintained by SYFC</font>
</div><!---footer--->

</div><!---wrap--->
index
PHP Code:
<?php
 
$main_content 
'djvnfvfvfvfjnj <a href="">LinkM</a>';
 
<
body>

<?
php
include 'template.php';
?>

</body>


the rep would be apprieciated
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 02-05-2008, 03:05 PM Re: include
dlaroche22's Avatar
Skilled Talker

Posts: 84
Name: Dustin Laroche
Trades: 0
I really like the solution dansgalaxy came up with, however, trying to put a lot of HTML code in a single string can be frustrating ( i know this personally ). So the solution that I propose to that is using the heredoc which will allow you to see the formating and structure of the HTML code more clearly.


template.php:
PHP Code:
<div id="wrap">
 
<div id="banner">
</div><!---banner--->
 
<div id="mainarea">
<? echo $main_content?>
</div><!---mainarea--->
 
<div id="footer">
Copyright &copy; Swindon Youth For Christ 2007-<?php echo date("Y"?><br />
<font size="1px">Designed and Constructed by Joshua Davison | Maintained by SYFC</font>
</div><!---footer--->
 
</div><!---wrap--->
And for the index.php:
PHP Code:
<?php
 
$main_content 
= <<<CONTENT
// Your HTML code for content here
<a href="somewhere.html">somewhere</a>
....
....
....
....
CONTENT;
 
?>
 
<body>
 
<?php
include 'template.php';
?>
 
</body>
I hope this helps alittle better since it will allow you to use structure your HTML on different lines like you would if you were programming just a simple HTML page. Let me know how this works for you.
__________________
Under Construction, But A Work In Progress
Webhosting isn't cheap, sponsors are important

Please login or register to view this content. Registration is FREE
dlaroche22 is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 04:02 PM Re: include
Joshy D's Avatar
Extreme Talker

Posts: 178
Name: Josh
Trades: 0
ok, dlaroche22, wow, right, ok i can see your point, and its not much different from dansgalaxy's solution, thanks for the help guys, i'll give you both rep.

P.S I take it both of these methods would allow me to use more DIV's inside the content area in the index.php, am i right?

Last edited by Joshy D; 02-05-2008 at 04:05 PM..
Joshy D is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 04:13 PM Re: include
dlaroche22's Avatar
Skilled Talker

Posts: 84
Name: Dustin Laroche
Trades: 0
you are right with the <div> tags. I hope this is the solution you are looking for and I don't see why it shouldn't work for you.
__________________
Under Construction, But A Work In Progress
Webhosting isn't cheap, sponsors are important

Please login or register to view this content. Registration is FREE
dlaroche22 is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 04:20 PM Re: include
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Heredoc has performance issues. Why not just include your content based on a predefined var.

PHP Code:
<?php 
$page
"maincontent.php";
include(
"template.php");
?>


PHP Code:
<div id="wrap">

<div id="banner">
</div><!---banner--->

<div id="mainarea"><?php if (isset($page)){
    include(
$page);
    }
?>
</div><!---mainarea--->

<div id="footer">
Copyright &copy; Swindon Youth For Christ 2007-<?php echo date("Y"?><br />
<font size="1px">Designed and Constructed by Joshua Davison | Maintained by SYFC</font>
</div><!---footer--->

</div><!---wrap--->
maincontent.php
PHP Code:
// whatever 
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 04:23 PM Re: include
dlaroche22's Avatar
Skilled Talker

Posts: 84
Name: Dustin Laroche
Trades: 0
Not a bad idea! Maxxximus, could you inform me of the performance decrease heredoc has or point me to some info so that I could read up on this. I happen to use heredoc alot and would like to learn the advantages and disadvantages.
__________________
Under Construction, But A Work In Progress
Webhosting isn't cheap, sponsors are important

Please login or register to view this content. Registration is FREE
dlaroche22 is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 04:30 PM Re: include
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
I have looked at the heredoc before the only benifit (to me) is that in dreamweaver and stuff it should the colour coded for the html.

but i find them a bit annouying my self, confuses me more makes it more clear using echo '';

anyway.

i dont know what JoshyD thinks but i think that this
<?php
$page
= "maincontent.php"
;
include(
"template.php"
);
?>


would defeat the purpose, he has seperate pages index.php which includes the template so he can have smaller files but whats the point in having three files when it works perfectly fine and more logically with two?..

__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 02-05-2008, 05:15 PM Re: include
Joshy D's Avatar
Extreme Talker

Posts: 178
Name: Josh
Trades: 0
wow, wtf? now im confused...

yer maxxximus, although im sure it works it does defeat the object, or 1 of the objects at least, and i dont have a problem with using echo, i can use it fine, heredoc would of been helpful but if it has performance issues the there is not much point.
Btw, what performance issues does it have?

i think i'll just stick with the echo though.

Last edited by Joshy D; 02-05-2008 at 05:18 PM..
Joshy D is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 05:18 PM Re: include
dlaroche22's Avatar
Skilled Talker

Posts: 84
Name: Dustin Laroche
Trades: 0
What he is trying to tell you is that instead of loading the $main_content variable full of the html code you can place all your content code in another page or file and then use php to grab all of that code out of the content.php file and place it in the proper place. Not a bad idea if you ask me.
__________________
Under Construction, But A Work In Progress
Webhosting isn't cheap, sponsors are important

Please login or register to view this content. Registration is FREE
dlaroche22 is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 05:22 PM Re: include
Joshy D's Avatar
Extreme Talker

Posts: 178
Name: Josh
Trades: 0
Quote:
Originally Posted by dlaroche22 View Post
What he is trying to tell you is that instead of loading the $main_content variable full of the html code you can place all your content code in another page or file and then use php to grab all of that code out of the content.php file and place it in the proper place. Not a bad idea if you ask me.
Oh, right, that was what i was trying to do in the first place but i ddint know how so i just resolved to this, right ok.
Joshy D is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 05:25 PM Re: include
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
But theres absolutly no differance! if the content needs editing whats the differance from editing the variable and the other file... just means more files..
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 02-05-2008, 05:31 PM Re: include
dlaroche22's Avatar
Skilled Talker

Posts: 84
Name: Dustin Laroche
Trades: 0
If you had the content material in a seperate file you can format the code with identations and spaces to make your code clean and easier to maintain. If you put the content code in a variable ( and most content code can be large ) then the string for that variable will become huge and hard to read and maintain. Just my opinion. I guess all the ways that we have discussed works it is now up to Joshy D to pick the way that he is more comftorable with and makes more sense to him.
__________________
Under Construction, But A Work In Progress
Webhosting isn't cheap, sponsors are important

Please login or register to view this content. Registration is FREE
dlaroche22 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to include
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.98887 seconds with 12 queries