include it where i want my include file?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

include it where i want my include file?

Post by mudkicker »

hi,

just have another problem.
is there a way to include a file for example foo.php where <!--include here--!> sign is?

can i do that?

Code: Select all

<html>
<body>
<h1><!-- include here --!></h1>
</body
</html>
i want to include my foo.php where <!-- include here --!> sign is (in my example between <h1> tags...
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

Post by snicolas »

try this
<?include("yourfile.php")?>


s
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

i know how to include of course.

i want to know how can i include my page in another page on signed area...
asterinex
Forum Commoner
Posts: 52
Joined: Thu Nov 25, 2004 7:01 am
Location: Belgium

Just inlcude it

Post by asterinex »

Just Put the include where you want to Print or Include the .
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

i have to do it dynamically!!!
asterinex
Forum Commoner
Posts: 52
Joined: Thu Nov 25, 2004 7:01 am
Location: Belgium

Post by asterinex »

Please explain your problem a bit more detailed.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

look,

i have a template file. where i have to include modules.inc.php is signed in template file like {{PAGE_MODULES}}. i have to include my modules.inc.php where this sign is standing in template file automatically...
kral_majales
Forum Commoner
Posts: 36
Joined: Wed Nov 24, 2004 2:47 pm
Location: Dorset, UK

Post by kral_majales »

i think what you are after is a templating system similar to the way phpBB does things. download the code for phpBB and have a look at how they do things - they use *.tpl files as templates and then insert data into them and so on, it's all done dynamically and you can have multiple tempaltes.

K
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

something like this is always simple, and has lower overhead than doing a str_replace and then having to eval the code etc...it avoids your previous dilema


i dont know know how functional you need it, but something to this effect works pretty good for most basic sites. you would still do yourself good to take a look at some templating systems for ideas. you may find a very elegant solution for your needs.


Code: Select all

<?php

// index.php or main page etc....

$header = set_include_header($args); 
$nav = set_include_nav($args); 
$body = set_include_body($args); 

include('template.php');


?>

Code: Select all

// template.php

<html>
<body>
<h1><?php include($header); ?></h1>
<div><?php include($nav); ?></div>
<?php include($body); ?>
</body
</html>
and you can even use a set_include_template() and make_html_head_meta() function etc...

the skys the limit on how many different parts you wanna break it down into. just dont get too crazy or the overhead of all the includes and functions adds up.
Last edited by rehfeld on Fri Nov 26, 2004 5:48 pm, edited 1 time in total.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

for me it is important that user can change the layout (i mean he/she can select which module block is visible/invisible etc.) and i can easily change the skin of my page using another css file etc..
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

$layout = set_layout($args);

$header = set_header($args, $layout); // decides what to do based on the args passed to it
Post Reply