ISO Image
Creator


Template System...., Any ideas?
Dec 28 2005, 01:03 PM
![]()
Themer
![]()
Group: Members
Posts: 120
Joined: 17-March 05
From: England
Member No.: 29,841
United Kingdom
![]()
If I were to have templates, would I use preg and str replace or just build up variables (eg. $output .= 'Hello')? This is difficult...
Come on Brandon, you work for IPS, you give me some ideas ![]()
It needs to be a bit more complex than normal, and I want a challenge
. I know IPB has a very complex sort of thing, and something like that, but maybe a little easier
Just give me ideas and I'll try my best.
Thanks all
-Mackins
Dec 31 2005, 02:59 AM

Back; Down you Hooligans! :P
![]()
Group: Members
Posts: 1,012
Joined: 2-November 04
From: Rochester, MN
Member No.: 23,596
United States
![]()
Dec 31 2005, 08:29 AM
![]()
Administrator
![]()
Group: Admin
Posts: 10,302
Joined: 9-February 03
From: Jacksonville, FL
Member No.: 1
United States
![]()
This is all passed to a function in the output/display class which just appends the html to it's existing html.
Finally the html is output.
Dec 31 2005, 10:09 AM
![]()
Themer
![]()
Group: Members
Posts: 120
Joined: 17-March 05
From: England
Member No.: 29,841
United Kingdom
![]()
![]()
Anyway, I've started it but I'm not too sure on how to actually output it as I've put it all into variables. How about this:
// This function makes a new class in the 'templates' variable in the class
// The line will create $skin->templates['global'];
$skin->load_template('global');
// I was thinking about making this: btw $func is my main misc function class
$func->output($skin->templates['global']->template_bit();
// Or should I put it all in a variable:
$func->output .= $skin->templates['global']->template_bit();
?>
But then, when shall I output the output variable? at the end of the index page?
And another thing is that I'm not too sure on how to get the page title to change, but I figure the only way to do it is to load up the page into a variable before you ouput anything, which means the pages that have been loaded have the opportunity to change the title if they want.
A little help would be fine, cheers
-Mackins
This post has been edited by Mackins: Dec 31 2005, 09:13 PM
Jan 6 2006, 04:58 PM
![]()
Themer
![]()
Group: Members
Posts: 120
Joined: 17-March 05
From: England
Member No.: 29,841
United Kingdom
![]()
and things are really beginning to take shape (well, a better one than before). Now all I need to do is find out how that I can let the admin edit them. Any ideas?
The structure of each template is basically just like IPBs.
class template_name {
var $mackins; // the class that contains everthing :)
function template_bit_name(data_needed) {
return <<<E0F // is it zero or o ??
template_html
E0F;
}
}
?>
I need to know how to stop sessions being created by web bots such as google.
Or just add them as a session like in ipb.
One more thing. What does the @ do when put before a function eg. @mysql_db_select(db);
-Mackins
This post has been edited by Mackins: Jan 6 2006, 05:25 PM
Jan 7 2006, 07:21 AM
![]()
Administrator
![]()
Group: Admin
Posts: 10,302
Joined: 9-February 03
From: Jacksonville, FL
Member No.: 1
United States
![]()
![]()
You should output everything after all script execution is done. Not during shutdown (if you are using register_shutdown_func for anything) of course, but after everything else in your script is done.
Best bet I've found is to do this at the end of each of your source files like IPB. This allows you to process anything you need to process in your source files and then output it, or not output anything in the case of a redirection. You could put the output call in your index file if you wanted though, as it would essentially work the same.
<<<NAME
is the same one you use with the
NAME;
call, it's fine. You can put anything you want, those two lines just have to match. The traditional usage though, is the letter o (stands for End of Function).
I'm not entirely sure what you mean, but if you mean pull content from one function, then overwrite that content rather than append it, what you should do is when this *could* happen, save the content of your output to a different variable temporarily, and then when you have decided you don't need to overwrite it, THEN assign it to your main output variable. Like this
$temp_output = $skin->templates['global']->whatever_func();
//you've decided to overwrite it here
$temp_output = $skin->templates['global']->diff_func();
// No more need to overwrite it
$func->output .= $temp_output;
All the @ symbol does is repress warnings. It doesn't repress fatal errors or anything like that, but it will stop a warning from displaying on the screen.
Jan 7 2006, 10:42 AM
![]()
Themer
![]()
Group: Members
Posts: 120
Joined: 17-March 05
From: England
Member No.: 29,841
United Kingdom
![]()
![]()
Say the admin wanted to change the layout of a certain skin, which means the template file would have to be edited. The editing of it would be pretty easy as you would just use a textarea but then how would you rewrite the template file with the data of the edited function (plus everything else in the file)?
$data_to_replace = $skin->template['global']->global_header();
$safe_data = $mackins->safe_string($data_to_replace); // convert ascii thingies
// just skip form data to textarea because i can't be bothered to write the rest at the mo
$mackins->output = <<<EOF
<textarea cols="70" rows="25" name="data">$safe_data</textarea>
EOF;
?>
After that, I'm not too sure what to do. I know how to write to files and everything, but how would I replace that data? str_replace(), should work with the $data_to_replace, but there must be a more advanced way of doing it.
And as an initial installation of the system I'm thinking about using xml to hold data so I can parse it and insert it into the database so I can have master skin sets, like ipb does. So I'll be researching on xml for the next year
One more thing. The same question about the @ (thanks by the way) but this time with an & after = and before variables. Thanks big B. lol
-Mackins
This post has been edited by Mackins: Jan 8 2006, 02:51 PM
Jan 10 2006, 07:30 AM
![]()
Administrator
![]()
Group: Admin
Posts: 10,302
Joined: 9-February 03
From: Jacksonville, FL
Member No.: 1
United States
![]()
You wouldn't really be replacing a function in the skin file, but rather just generating a new file with the most up to date content.
XML with PHP is trickier than I thought originally, but once you get the hang of it it's not too bad. ![]()
The & symbol forces a reference of a variable, array, or object rather than copying it.
If you do
$test = $somevar;
then $somevar is copied over to test. This means changes to either one do not affect the other. If you do this instead
$test =& $somevar;
(or $test = &$somevar; - the & can be against the = sign or the variable or have a space between either)
then you are making $test a reference of $somevar. This uses less memory, however if you edit $test, it edits $somevar as well. This can be desirable at times. You want to use references when possible because it uses a LOT less memory to make a reference to something than to actually copy it over to a new variable. This is especially true for objects.
Jan 10 2006, 03:00 PM
![]()
Themer
![]()
Group: Members
Posts: 120
Joined: 17-March 05
From: England
Member No.: 29,841
United Kingdom
![]()
Now that I've merged my $func $skin and $info objects into one, and have converted everything using OOP, i can use this:
// my new $mackins class loaded here- everything merged (easier for me to get at)
// another class loaded into $run (as in $run = new mr_class)
$run->mackins =& $mackins;
?>
Will it be loaded into it and everything work OK?
Good idea about pulling stuff from the database. Appreciate it
.
But its the tricky bit of getting xml to work first.
Any tips on writing my XML class will be greatly appreciated. I know the basics now and stuff about character data, I just need to know what kind of array my xml class should create.
Oooooooooooh, I hate difficult stuff ![]()
-Mackins
This post has been edited by Mackins: Jan 10 2006, 03:01 PM


Lo-Fi Version
Time is now: 24th May 2012 - 04:29 AM
![]()
Webber Enhanced skin created by Im4eversmart of RuneHQ.