Page 1 of 1

include it where i want my include file?

Posted: Fri Nov 26, 2004 4:07 am
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...

Posted: Fri Nov 26, 2004 4:14 am
by snicolas
try this
<?include("yourfile.php")?>


s

Posted: Fri Nov 26, 2004 4:15 am
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...

Just inlcude it

Posted: Fri Nov 26, 2004 4:42 am
by asterinex
Just Put the include where you want to Print or Include the .

Posted: Fri Nov 26, 2004 5:17 am
by mudkicker
i have to do it dynamically!!!

Posted: Fri Nov 26, 2004 5:30 am
by asterinex
Please explain your problem a bit more detailed.

Posted: Fri Nov 26, 2004 5:34 am
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...

Posted: Fri Nov 26, 2004 8:04 am
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

Posted: Fri Nov 26, 2004 5:44 pm
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.

Posted: Fri Nov 26, 2004 5:47 pm
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..

Posted: Fri Nov 26, 2004 5:52 pm
by rehfeld
$layout = set_layout($args);

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