On Thu, 2005-11-17 at 14:34, Dan Baker wrote:
> <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> > Hi to all,
> > always wondered what's better way to mix html and php code. Here are three 
> > "ways" of the same code. Which one you prefer? (And why, of caurse :))
> (snip)
> > I think third solution would be the best solution?
> 
> IF you are doing a complex site, then the third option is almost mandatory. 
> You typically do not know what code will be in the header, until you have 
> processed some of the page.  Building the page as-you-go, allows for easy 
> alteration of previously built HTML code.  Complex sites are extremely 
> difficult to create using the "template" approach, because of the variety of 
> output.

Ummm... bullturds :)

Here is an example of a layout template:

-----------------------------------------------------------------------------
<jinn:prepend/>
<html>

<head>
  <title><jinn:pageTitle/></title>

  <style type="text/css">
  <!--
    <jinn:template path="css/main.template"/>
  -->
  </style>

  <jinn:accumulatorFlush name="javaScriptTags"/>
  <jinn:accumulatorFlush name="javaScriptTags" dynamic="true"/>

  <script type="text/javascript" language="javascript">
  <!-- //

  <jinn:accumulatorFlush name="javaScript"/>
  <jinn:accumulatorFlush name="javaScript" dynamic="true"/>

  function onLoadRoutines()
  {
    <jinn:accumulatorFlush name="javaScriptOnLoad"/>
    <jinn:accumulatorFlush name="javaScriptOnLoad" dynamic="true"/>
  }

  // -->
  </script>

</head>

<body onLoad="javascript:onLoadRoutines()" bgcolor="#ffffff"
marginheight="5" marginwidth="10" topmargin="0" l
-----------------------------------------------------------------------------

Now anywhere in the modules (which incidentally get loaded before the
content), or anywhere else in a sub-template content can be accumulated
in any of the above accumulator names. I have worked on plenty of
complex sites, and my JavaScript and other content always goes EXACTLY
where it's supposed to be, regardless of where the logic exists that
determines it's need to exist. For instance to include on load
javascript from any module:
-----------------------------------------------------------------------------

$sAcc = $this->getServiceRef( 'accManager' );
$acc = &$sAcc->getAccumulatorRef( 'javaScriptOnLoad' );

$acc->append( "alert( 'Foooooooo!' );\n" );

> I would highly agree with James Benson about CSS.

I agree CSS is great, but it's not everything. Custom tags allow one to
embed macro and meta semantics into a page without the cumbersome nature
of PHP function calls. For instance I find this meta tag handy in many
sites I create:

    <project:searchable>
    Some content that the site's search feature can search upon.
    </project:searchable>

Another one that my designer friends REALLY like:

    <project:restrict access="admin, manager">
    Some content that only admin and management can view.
    </project:restrict>

So templates aren't just about making pretty tables, though they can do
that quite well too.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to