phpgroupware-developers
[Top][All Lists]
Advanced

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

Re: [Phpgroupware-developers] Coding Assistance


From: Chris Weiss
Subject: Re: [Phpgroupware-developers] Coding Assistance
Date: Tue, 25 Feb 2003 15:17:57 +0000

I would first just ignore the skel app cause it's a very basic example and 
isn't a
working app.

As far as working with templates, here is what I have managed to teach myself 
about
them, I don't know that all this is "correct" but I'm sure someone will correct 
me
where i am wrong :)

Lets take this apart:

$this->t-set_file(array('header' => 'header.tpl'));
this line tells "t", the template object, what tpl file to use.  You find these 
in
the template dirs.  Search order is {your app}/templates/{your template}, then
{your app}/templates/default, then phpgwapi/templates/{your template}, finaly
phpgwapi/templates/default

$this->t-set_block('header','notes_header');
In the header.tpl you will see some HTML comments like:
<!-- BEGIN notes_header -->
<!-- END notes_header -->
Some tpl files have more, these are "blocks".  Unless you "set" the block, it 
will
get deleted from the output.  This line defines a label "header" for the block 
and
sets it for use.

$this->t->set_var('link_categories',$GLOBALS['phpgw']->link
('/index.php','menuaction=preferences.uicategories.index&cats_app=notes&cats_level=T
rue&global_cats=True'));
set_var() is the template function that replaces text in {} from the tpl file 
block
with your text.  In this case, the clip from the header.tpl is '<a
href="{link_categories}">', so link_categories is the label that gets replaced 
with
the nice URL link() gives us.  Link takes care of the site base and if the site
isn't using cookies, adds the SESSID to the url too.  The second parameter to 
link
() can also take an array, you will see examples of that in other places in the
notes app IIRC.

$this->t->fp('app_header','notes_header');
This "writes" the block to the output buffer, waiting for a pfp() to "finish" 
the
output and send it to the broswer.  Though what I don't get here, maybe someone
else can answer, shouldn't this be "$this->t->fp('header','notes_header');"?

Anyway, this is just what I've been able to teach myself about the template 
class.

For your error, "Template Error: loadfile: myappname_header is not a valid 
handle.
Halted". simply means that it didn't find the block myappname_header in the tpl
file set with set_file.

Joe Vandegrift (address@hidden) wrote*:
>
>I am looking at the notes application in order to get a better understanding
>of
>this three
>tier architecture style.  I am attempting to use the notes and skel
>modules as a bases for my
>first application.  These two modules really aren't as
>consistent with each other as I
>would have hoped.
>In the notes module in "/inc/class.ui.inc.php" in the
>"display_app_header()"
>function I replaced "'notes_header'" with
>"'myappname_header'" and when I
>call this function I get the error "Template Error:
>loadfile: myappname_header
>is not a valid handle.  Halted".  It gives this error when it
>tries to exute
>the line of code "$this->t-fp('app_header','myappname_header');  What is
>the
>proper way to configure my applciations header.  Could someone explain the
>
>following lines of code or show me where to find the internals of the
>template
>
>object?
>
>               function display_app_header()
>               {
>                       $this->t-
>>set_file(array('header' => 'header.tpl'));
>            $this->t-
>>set_block('header','notes_header');
>
>                       $this->set_app_langs();
>
>                       $this-
>>t->set_var('link_categories',$GLOBALS['phpgw']-
>>link
('/index.php','menuaction=preferences.uicategories.index&cats_app=notes&cats_level=T
rue&global_cats=True'));
>                       $this-
>>t->set_var('link_notes',$GLOBALS['phpgw']-
>>link('/notes/index.php','menuaction=notes.ui._list'));
>                       $this->t-
>>fp('app_header','notes_header');
>
>                       $GLOBALS['phpgw']->common-
>>phpgw_header();
>                       echo parse_navbar();
>               }
>
>Thanks, you can also reply
>directly to me at address@hidden
>
>
>
>
>_______________________________________________
>Phpgroupware-developers mailing list
>address@hidden
>http://mail.gnu.org/mailman/listinfo/phpgroupware-developers
>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]