rik72 Posted November 19, 2007 Share Posted November 19, 2007 Having issues including my file in the right place using templates.. <?PHP require("includes/inc.config.php"); require("includes/inc.classes.php"); require("includes/inc.functions.php"); $template['main'] = load_template("main"); $template['main'] = str_replace("{{COLUMN_LEFT}}", load_column(1), $template['main']); $template['main'] = str_replace("{{COLUMN_RIGHT}}", load_column(2), $template['main']); $template['main'] = str_replace("{{COLUMN_MIDDLE}}", INCLUDE GOES HERE, $template['main']); echo $template['main']; ?> Here is what i want to include include("login/login.php"); Here is where.. $template['main'] = str_replace("{{COLUMN_MIDDLE}}", INCLUDE GOES HERE, $template['main']); but when i do it using logic, it includes at the top of the page. Link to comment https://forums.phpfreaks.com/topic/77997-simple-includes/ Share on other sites More sharing options...
trq Posted November 20, 2007 Share Posted November 20, 2007 You'll might need to save the output of the include into a variable. <?php ob_start(); include "login/login.php"; $login = ob_get_flush(); require "includes/inc.config.php"; require "includes/inc.classes.php"; require "includes/inc.functions.php"; $template['main'] = load_template("main"); $template['main'] = str_replace("{{COLUMN_LEFT}}", load_column(1), $template['main']); $template['main'] = str_replace("{{COLUMN_RIGHT}}", load_column(2), $template['main']); $template['main'] = str_replace("{{COLUMN_MIDDLE}}", $login, $template['main']); echo $template['main']; ?> Link to comment https://forums.phpfreaks.com/topic/77997-simple-includes/#findComment-394796 Share on other sites More sharing options...
rik72 Posted November 20, 2007 Author Share Posted November 20, 2007 That works, although it repeats it at the top, so i have two instances of login.php on the page.. Link to comment https://forums.phpfreaks.com/topic/77997-simple-includes/#findComment-394809 Share on other sites More sharing options...
rik72 Posted November 21, 2007 Author Share Posted November 21, 2007 Does anybody know how to fix this so that it includes the file only once, i can see the solution coming from what thorpe has put, but i cant put my finger to why it is repeating the include. Link to comment https://forums.phpfreaks.com/topic/77997-simple-includes/#findComment-395819 Share on other sites More sharing options...
trq Posted November 21, 2007 Share Posted November 21, 2007 Sorry, my fault, use... <?php ob_start(); include "login/login.php"; $login = ob_get_contents(); ob_clean(); instead. Link to comment https://forums.phpfreaks.com/topic/77997-simple-includes/#findComment-395822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.