Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2000071

Re: [PHP] Layout Wizards From: Alex Black (enigma <email protected>)
Date: 07/14/00

well,

though I doubt you will want to (initially) use binarycloud, here's a simple
explanation:

go to http://www.nintendorks.com/content.php?ContentID=102

they probably have a master template set up which takes care of all the
navigation, the ad, etc.

So content.php does this:

includes 'header'
includes 'left_nav'
includes 'ad'
includes 'header'

constructs content by:

-querying the DB for recent articles
-including a standard 'article' summary template:

includes 'article_summary'

and looping through the database result set with the article summary
template until there are no more results.

it then:

includes 'footer'

and bing, you have a page.

?ContentID=102

is probably used to determine what kind of call to make to the DB, or I
suppose it could all just be static html.

--------------

binarycloud's template system is freakishly powerful, a little at the
expense of learning curve, but I think the payoff is worth it:

our top level templates are included, but they are embedded in functions.
those top level templates use our core_template class to build modules
passed in an array (modules are widgets on page that make sense as separate
objects: a form, a press release, etc) and sequentially execute the module
functions.

most template systems (at the high level) use a number of different
templates for:

-header
-left navigation
-title
-footer

which is really because they want to do everything in a logical sequence:

-print my header
-print my left nav
-print my title

now do all the page-specific stuff to get my content for this page

-print the footer

our template calls the logic which builds the content. yes, that is kind of
weird, but it works incredibly well, and scales up to massive sites with
deep functionality:

$page->modules = array("example_module" =>
array(
"logic" => MODULES."example_module/example_module.php",
"template" => MODULES."example_module/templates/module_tmpl.phtml"
));

and the template:
--------------
<html>
<head><title>hi</title></head>
<body>

<? build_modules(); ?>

</body>
</html>

you'll notice that the above is a complete, balanced html page with a
function call in the middle.

That build_modules() function has been passed a configuration array which
tells it:

-what modules to include
-any module-specific values that need to be passed

the template function then goes and executes those modules.

think of it more as a hierarchy, than a sequence, then it stops being
counterintuitive :)

top level template
    module
        sub-component
    module
    module
        sub-component
        sub-component
        sub-component

_alex

--
Alex Black, Head Monkey
enigma <email protected>

The Turing Studio, Inc. http://www.turingstudio.com

vox+510.666.0074 fax+510.666.0093

Saul Zaentz Film Center 2600 Tenth St Suite 433 Berkeley, CA 94710-2522

> From: discodude <email protected> ("Donald Allen") > Newsgroups: php.general > Date: 14 Jul 2000 17:19:08 -0700 > Subject: RE: [PHP] Layout Wizards > > heh, yeah, it was just an example. But here's a real sample: > > http://www.nintendorks.com/content.php?ContentID=102 > > It looks like the story is pulled from a database, then put into the > content.php layout... I just have no idea how to do it. > > Don > > -----Original Message----- > From: Brian Clark [mailto:brianj <email protected>] > Sent: Friday, July 14, 2000 6:09 PM > To: Donald Allen > Subject: Re: [PHP] Layout Wizards > > > Donald Allen: > >> Hey, >> >> I'm very new at PHP (still don't know what it is), but I'm looking for a >> tutorial that shows you how to create a layout for your site in PHP... I > see >> so many times sites that use something like: >> >> http://www.site.com/newslayout.php?id=13213 > > Sorry, where is my brain. I was browsing through my mail and I clicked and > got a 404, but I see now that you were just using that URL as an example.. > > OOps.. LOL > > >> Or something like that. Are there any tutorials on the web that will show > me >> how to do this? >> >> Thanks! >> >> Don > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe <email protected> > For additional commands, e-mail: php-general-help <email protected> > To contact the list administrators, e-mail: php-list-admin <email protected> >

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>