illutic
Joined: 03 Mar 2006 Posts: 3 Location: the Netherlands
|
Posted: Fri Mar 03, 2006 7:12 pm Post subject: Switching assignInclude |
|
|
I'm trying to make my own cms with a seperate admin section, I want to use templates for almost everything, so layoutchanges can be made easy.
I first wanted to know for sure that the layout of the cms itself looked as it should, before I started working on the admin section.
Now I'm trying to get the admin section running, i found a little problem...
In the index page of the admin section I'm using an if statement to see which page should be included, the login page, or the admin page.
The navigation is also included in the template (with assingInclude) and with the login page everything goes as it should, but when I'm logged in, the admin page doesn't work (the navigation still does).
Here's the index.php:
| Code: |
<?php
ob_start();
define('_ILLUTIC_CMS', true);
error_reporting(E_ALL);
include('../config.php');
include('session.php');
include('../include/class/class.Admin.inc.php');
include('../include/class/class.TemplatePower.inc.php');
include('../include/class/class.Modules.inc.php');
include('../include/class/class.TextEditor.inc.php');
include('../include/class/class.Templates.inc.php');
require('../config.lang.php');
$var = new Modules;
$text = new TextEditor;
$tpls = new Templates;
$mod = new Modules;
$tpl = new TemplatePower('../themes/'.$var->FetchUpdateConfVar('website_theme').'/admin.tpl'); // admin template (layout)
$tpl->assignInclude( 'pngfix', '../themes/'.$var->FetchUpdateConfVar('website_theme').'/png_fix.tpl' ); // png fix template
$tpl->assignInclude('navigation', 'navigation.php');
if ( !admin_logged() )
{
$tpl->assignInclude('login', 'login.php');
}
else
{
$tpl->assignInclude('AdminContent', 'content.php');
}
$tpl->prepare();
$tpl->assignGlobal('root', $var->FetchUpdateConfVar('website_url'));
$tpl->assignGlobal('adminroot', $var->FetchUpdateConfVar('website_url') . '/admin');
$tpl->assignGlobal('themeroot', $var->FetchUpdateConfVar('website_url').'/themes/'.$var->FetchUpdateConfVar('website_theme'));
$tpl->assignGlobal('imgroot', $var->FetchUpdateConfVar('website_url').'/themes/'.$var->FetchUpdateConfVar('website_theme').'/images');
$tpl->assign('WebsiteTitle', $var->FetchUpdateConfVar('website_name'));
$tpl->assign('WebsiteTitleAdmin', $var->FetchUpdateConfVar('website_name') . ' Admin');
$tpl->printToScreen();
ob_end_flush();
?> |
I won't show all classes and stuff, cos that's way too much code, but here's the navigation.php and content.php:
navigation.php
| Code: | <?php
if ( !@$_GET['module'] )
{
$module = 'a';
}
else
{
$module = $_GET['module'];
}
$adm = new Admin;
echo $adm->selectNav($module,$language);
echo 'bla';
|
content.php
| Code: |
<?php
error_reporting(E_ALL);
if ( !@$_GET['module'] )
{
$module = 'a';
}
else
{
$module = $_GET['module'];
}
$adm = new Admin;
echo $adm->selectModule($module,$language);
echo 'bla';
?> |
As you can see, navigation.php and content.php are almost identical.
The echo 'bla'; was only included because I wanted to test if the function or the inclusion failed.
Whether I'm logged in or not, the navigation.php works, when I'm logged off, the login.php is included, but when I'm logged in, I don't get to see anything! (well, only the bla of navigation.php)
I even added a new includescript block named admincontent (and for login named login), because I wanted to know if it had something to do with trying to change the file used for the same inclusion (login.php and content.php used to be called by the assignInclude content), but that didn't work either..
I really hope someone can help me on this, because I'm about to lose my mind over it..
----------------------------------------------------------------------------------
Okay, just found out that if i delete the if/else statement and only leave the assignInclude for content.php, it does work.. but how can i get it to work with the if/else statement?? Because it's critical that the admin logs in before he/she has access to the admin section... |
|