I have a template. This template include header, leftColumn, rightColumn and footer. In these, header and footer is no change in any page. I want to take the name of them (example: http://localhost/Demo/function_server_refer/redirect.php –> I need “redirect.php”) to know which this page and include some parts corresponding with leftColumn and rightColumn.
@ralph_m ; I think that is a fine solution. First time I read the question, I wasn’t exactly sure what the original poster wanted, after seeing your response and re-reading his question, the solution seems to fit what I now believe he wants.
Hi! Thank a lot ralph.m. I’ll try it now. But my page have four columns, three columns in these is change when I direct to any page. I don’t want copy code from this file to that file and then use the code of your. Example:
index.php
<div id="indexLeftColumn">
<div id="navigation">
// if 'index.php' then include ('abc.php');
</div><!-- end # -->
</div><!-- end #indexLeftColumn -->
<div id="indexRightColumn">
<div id="innner">
// if 'category.php' then include('def.php');
</div><!-- #inner -->
</div><!-- end #indexRightColumn -->
cart.php
<div id="indexLeftColumn">
<div id="navigation">
// if 'cart.php' then include ('c.php');
</div><!-- end # -->
</div><!-- end #indexLeftColumn -->
<div id="indexRightColumn">
<div id="innner">
// if 'cake.php' then include('d.php');
</div><!-- #inner -->
</div><!-- end #indexRightColumn -->
index.php’s code and cart.php’s code are similar. How can I arrange the main page and include page to more easy?
I’m afraid I don’t quite understand the question. If you just want to include things in those places, you could do something like this:
<?php $page = basename($_SERVER['PHP_SELF']); ?>
<div id="navigation">
<?php if ($page == "cart.php") {
include $_SERVER["DOCUMENT_ROOT"] . "c.php";
}; ?>
</div>
But if you want a more sophisticated template that serves all pages at once, youll have to set things up a little differently. (What I’m suggesting is just a simple noob solution.)