WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: jjj on February 06, 2008, 01:51:34 PM

Title: Examples or documentation of the template parser/engine...
Post by: jjj on February 06, 2008, 01:51:34 PM
I am trying to build my own module and get confused by the working of the backend  :cry:

When looking at the module "code" I see the use of some sort of template parser/engine (files: modules/code/modify.php and template.html)
Code: [Select]
// Setup template object
$template = new Template(WB_PATH.'/modules/code');
$template->set_file('page', 'modify.html');
$template->set_block('page', 'main_block', 'main');

I'm used to work with smarty (http://www.smarty.net/). Is there any documentation available for this parser/engine?
I am interested in the loop construction of this parser/engine.

thanks in advance!

Jeroen
Title: Re: Examples or documentation of the template parser/engine...
Post by: ruebenwurzel on February 06, 2008, 02:03:12 PM
Hello,

for modul developpers we have built a "Hello World" modul wich you can download from our addons Page. This modul includes all needed files and has a lot of eplanation in the files what they do. So to developp your own modul, the Hello World should be the basis.

Smarty we don't have integrated in WB. So if you wanna use it, you have to integrate it yourself. And before we start here again a new discussion about the use of smarty, read all post about this here in the forum. Smarty will definetely not be part of the WB 2.x versions.

Matthias
Title: Re: Examples or documentation of the template parser/engine...
Post by: jjj on February 06, 2008, 03:16:44 PM
Dear Matthias,

Thanks for your reaction.

I am using the code (Hello world module) as you suggested. In that module I see the functions I mentioned.

After looking into the source code (and fgrep-ing) I found that those functions are stored in a module called phplib/template.inc (Session Management for PHP3, (C) Copyright 1999-2000 NetUSE GmbH).

For me the text "Session Management for PHP3" was a little bit confusing   :-D

I do not want to add/change or do suggestions for modifying the core. I realize wb has a long history and I am way to new to wb to ask such a question  :wink:.

The reasons for my questions in this forum are simple:
- I want to understand how wb works
- I want to make a module what will be usable for others and completely confirms to wb standards.
- When a new version of the core will be available i hope upgrading this module will be little work.

I am going to study the template.inc file for a while. I hope to finish my module soon so u can be the judge (if you want) if it conforms...

Thanks again;

jeroen
Title: Re: Examples or documentation of the template parser/engine...
Post by: ruebenwurzel on February 06, 2008, 03:41:28 PM
Hello,

template.inc in the phplib dir is a third party script wich we use without any changes. So this is no WB script. In the next version of WB this file is updated to the latest phplib version. (http://phplib.sourceforge.net/ (http://phplib.sourceforge.net/)).

Matthias
Title: Re: Examples or documentation of the template parser/engine...
Post by: doc on February 06, 2008, 08:00:04 PM
Hello Jeroen,

Ralf (Berlin) and myself were thinking of making a Hello World 2 module which make use of the template class. However we have both too much other projects so we skipped this project for time beeing.

In general the template engine class provides functions to searches a specific file (e.g. template.html) for a placeholder like: {PLACEHOLDER} and allows to replace the text PLACEHOLDER with whatever you want. This allows to seperate styling (HTML) and coding (PHP). Most PHP codes suffer from tons of echo statements which generate pure HTML code.

A simple example of how this class works can be found in the WB core files folder: /admin/start/
- template.html contains basic HTML code and placeholder strings {XXXX}
- index.php (line 27, 30-44, 128-130) show an working example of how placeholder are replaced

You can use this tequnique for your own modules or ...

Regards Christian
Title: Re: Examples or documentation of the template parser/engine...
Post by: jjj on February 13, 2008, 12:31:48 PM
You can use this tequnique for your own modules or ...

Christian,

I got the hint :wink:

When I finish my first module this week and this website is up and running, I hope to use WB for my own website. But I will wait for the upcoming  release;

I would love to see a Hello world 2 module as you described (a separation of programming logic and layout would be a great addition); I can not promise that I will write it but the idea is tempting; certainly  if you, or a "colleague" will check if this module is programmed according the "WB-standards"...

Regards Jeroen

ps. Yes it is really tempting   :wink: