Jump to content

Classes


radar

Recommended Posts

First off it's been a while since I've visited here as I've been without the internet.  I must say I like the new design and the new setup you've got here..  It looks Great..  And now on with the Show..

I've just barely been getting into using classes and making a site templateable in php and I'm trying to incorporate this into my site though not having much luck...

First off I must say I am not the best at programming functions and stuff like that so I robbed the class files from PHPBB2.. Perhaps a bad choice, but It works so far for what I need... 

So here is what I am doing...  I am working on the Administration Console of my site first...  I am programming everything on my site from the front end, to the console and even the forums.  I want it all to be templatable so that I can easily switch interfaces if I ever decide to...

So 2 Admins log in.. one is a Root Admin the other is a Forum Admin..  On my site the layout will be the exact same but I need 1 of 3 files to load on the left hand side..  these files are either..

left_root.tpl
left_site.tpl
left_forum.tpl

This is strictly the Template itself for the navigation..  The main template is main.tpl  -- I can't figure out how to load the other tpl's within the other one where they need to go by like using {left_admin} where they should go...  here is my code thus far on just this part..

[CODE]
include('../includes/template.php');
include('../includes/db.php');
include('../includes/functions.php');

$template = new Template();
$template->set_filenames(array(
'body' => '../templates/cesite/admin/main.php',
)
);
$template->assign_vars(array(
'admin_note' => 'note: clicking any of the links at the top or bottom of this page will take you away from the admin console',
'left_admin' => 'I hate a gang of HTML here just for testing purposes'
));
[/CODE]

If you need me to attach the included files to look at the coding there please let me know and I will..  all the code above is in index.php -- So I need to figure out how to load other tpl files into the main.tpl file from index.php..  any help would be grateful.. and thank you in advance.
Link to comment
Share on other sites

Anyone know anything about this?

If you need a visual you can go to http://www.cetutorials.com/cesite/admin/test.php

The whole template is main.tpl -- then the boxes on the left side with the links (the navigation) should be in either left_root.tpl, left_site.tpl or left_forum.tpl..  Then the box in the center should be in body.tpl..  and all these files should be brought together by pulling everything and putting it in the right place within the index.php...
Link to comment
Share on other sites

Okay well I figured this out with the help of PHP Builder...  So I am posting the way I am doing it with my class and all that good stuff for future reference for anyone else

[CODE]
<?php
include('../includes/template.php');
include('../includes/db.php');
include('../includes/functions.php');
$db = new sql_db(host, user, pass, db, false);
$tpl = new Template('../templates/cesite');
$username = "Guest";

switch($act) {
case '' :
if (!$submit) {
if ($username == "Guest") {
$tpl->define(array(login => "admin/login.tpl"));
                                      // assigning error to blank just gets rid of {error} on the site
$tpl->assign(error, '');
                                      // this is for the form
$tpl->assign(php_self, $PHP_SELF);
$tpl->parse(MAIN, "login");
$tpl->PPrint(MAIN);
} else {
echo "logged in";
}
} else {
                          // this is where we process the submitted form.
echo "lets get this workin right";
}
break;
}
?>
[/CODE]
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.