Re: Localization Structure Model



> OK - I like all your ideas upto here. Please to make this easy for a
> spectrum of people from hardcoders to hardcore designers we need to use
> some kind of template system - anything but echo statements! My personal
> preference is PHPLIB template system. Let's hear other suggestions (like
> I need to ask ;-)

Yes yes, most definately. Sorry if I made anyone think something different,
we need templates. But, there are two ways to implement templates. You can
html, and put here and there some php in it to display things like the
gettext, or you can use functions. Here at work, we use a system that
captures templates into functions:
function print_new_software_screen($arguments, $lang, $site) {
echo "<html>",
  <inserts lots of html here>,
  "<table>";

for($i = 0 ; $i < $arguments['number_of_shown_entries'] ; $i++) {
  echo "print a new software entry here"
}

echo "</table>",
  gettext($lang, "copyrightnotice", $site);
  "<even more html></html>";
}

The advantages are that you can make a very clear distinction between the
processing of any input, and the actual display of the page. You'd have php
with a code structure like:

include global variable file;
include function libraries;
switch($action)
{
  case "search":
    include("display_search.inc");
    include("process_search.inc");
    print_search_page(process_search_variables(), $lang, $site);
    break;
  case "login":
    include("display_login.inc");
    include("process_login.inc");
    print_login_page(process_login_variables(), $lang, $site);
    break;
  default:
    include("display_main_page.inc");
    print_main_page();
    break;
}

The process_ functions return a string indexed array, like used in the
first print_new_software_screen example.
All pages always submit to _one_ page, let's say index.php. There _must_ be
a variable set called 'action', and this variable determines what is
actually shown. Now, for every major function of the website (searching,
displaying new software, showing news, or even just redirecting) all we
need is a .inc for displaying (that would be the template), and a .inc that
processes the variables submitted and returns an array. There can be made a
lot of improvements to this  design, it's just a quick overview of a system
that I have found very easy and maintainable.

cheers,

roel








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]