UseBB Community

The official board for UseBB help and discussion

UseBB Community » 2.x Discussion » Some input for 2.0

Some input for 2.0

Page: 1

Author Post
Member
Registered: Aug 2004
Posts: 59
Hi,

in need of a new template system for some testing and developing we replaced our own template functions with Clearsilver technology. Its awesome ;), we stripped down our code about 30-50%, made it more clearer and easier to understand, to program or just to edit the templates.

We wrote down all the important config values in a hdf file, makes it so easy to edit (no php or sql knowledge needed) like:



DBASE {
HOST = localhost
USER = cms
PASS = lala
}

SYSTEM
{
SERVERPATH = /usr/local
URL = http://
ADMIN = admin@boy...
}

PAGE {
CONTENT {
INDEX {
NAME = Indexpage
AUTH = Restricted
TEMP = /usr/local/cs/index.cs
}
}
}



Code example with loops, after pushing the "News" in our virtual HDF-File.


<?cs set:count = #1 ?>
<?cs each:item = NEWS ?>
<?cs if:count % #2 ?>
<div style="float:right; padding-left:15px; margin-left: 15px; margin-top: 0; margin-bottom: 10px; width: 240px; border-left: #ccc 1px solid;">
<h2 style="margin-top:0; padding-top:7px;"><?cs var:item.Subject ?> - <?cs var:item.Date ?></h2>

<?cs else?>
<h2><?cs var:item.Subject ?> - <?cs var:item.Date ?></h2>
<?cs /if?>
<p><?cs var:item.Intro ?> <a href="<?cs var:SYSTEM.URL?>/news.fcgi?nid=news.fcgi?<?cs var:item.Id ?>"><?cs var:LANG.MORE ?></a>
<br /><em><?cs var:item.Autor ?></em></p>
<?cs if:count % #2 ?>

</div>
<?cs /if ?>
<?cs set:count = count + #1 ?>
<?cs /each ?>



We were never a fan of XML/XSLT or something like that, so we are very pleased with Clearsilver. Its also used down there at the new Google Groups V2.

A simple other example would be this

<?cs if:USER.LOGGED_IN==1 ?>
show this in language <?cs var:LANG.PROFILE.WELCOME ?>
<?cs else>
show this in language <?cs var:LANG.PROFILE.PLEASE_LOGIN ?>
<?cs /if?>
show all ;=)


A really good (but quite not so known) template system, could be a really big plus for the next version.

You should take a look at http://www.clearsilver.net - the php module/function is currently in development, see this here: http://www.geodata.soton.ac.uk/software/php_clearsilver/

Greetings, Jay
« Last edit by Joerg on Tue May 03, 2005 1:49 pm. »
Developer
Registered: Apr 2004
Posts: 2215
Location: Belgium
Seems like it needs to compiled in the PHP sources, or am I wrong?

I think it would be better to further develop our own template parser however...
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Aug 2004
Posts: 59
Yep, must be compiled, thats of course a little problem for wide spreaded use.

Its your decision. But your thought was to be more flexible in 2.0, so why dont relay on a system that is known for good reason or a XML/XLST variant or another.

The current system is a pain, maybe not for you as main programmer but from user side.

Having source like this inside php:


$template->parse('confirm_form', 'global', array(
'form_begin' => '<form action="'.$functions->make_url('edit.php', array('post' => $_GET['post'], 'act' => 'delete')).'" method="post">',
'title' => $lang['DeletePost'],
'content' => sprintf($lang['ConfirmDeletePost'], '<em>'.unhtml(stripslashes($postdata['topic_title'])).'</em>'),
'submit_button' => '<input type="submit" name="delete" value="'.$lang['Yes'].'" />',
'cancel_button' => '<input type="submit" value="'.$lang['Cancel'].'" />',
'form_end' => '</form>'
));


or this one:



$options_input[] = '<input type="checkbox" name="enable_bbcode" id="enable_bbcode" value="1"'.$enable_bbcode_checked.' /><label for="enable_bbcode"> '.$lang['EnableBBCode'].'</label>';
$options_input[] = '<input type="checkbox" name="enable_smilies" id="enable_smilies" value="1"'.$enable_smilies_checked.' /><label for="enable_smilies"> '.$lang['EnableSmilies'].'</label>';
if ( $session->sess_info['user_id'] && !empty($session->sess_info['user_info']['signature']) )
$options_input[] = '<input type="checkbox" name="enable_sig" id="enable_sig" value="1"'.$enable_sig_checked.' /><label for="enable_sig"> '.$lang['EnableSig'].'</label>';
if ( $functions->auth($forumdata['auth'], 'html', $_GET['forum']) )
$options_input[] = '<input type="checkbox" name="enable_html" id="enable_html" value="1"'.$enable_html_checked.' /><label for="enable_html"> '.$lang['EnableHTML'].'</label>';
if ( $functions->auth($forumdata['auth'], 'lock', $_GET['forum']) )
$options_input[] = '<input type="checkbox" name="lock_topic" id="lock_topic" value="1"'.$lock_topic_checked.' /><label for="lock_topic"> '.$lang['LockTopicAfterPost'].'</label>';
if ( $functions->auth($forumdata['auth'], 'sticky', $_GET['forum']) )
$options_input[] = '<input type="checkbox" name="sticky_topic" id="sticky_topic" value="1"'.$sticky_topic_checked.' /><label for="sticky_topic"> '.$lang['MakeTopicSticky'].'</label>';
if ( $session->sess_info['user_id'] )
$options_input[] = '<input type="checkbox" name="subscribe_topic" id="subscribe_topic" value="1"'.$subscribe_topic_checked.' /><label for="subscribe_topic"> '.$lang['SubscribeToThisTopic'].'</label>';
$options_input = join('<br />', $options_input);



Or look at global.tpl.php - currently even as a pro altering or modifying layout, design or code is an exhausting act. For 2.0 you should change this really.

Greeting, Jay
« Last edit by Joerg on Tue May 03, 2005 8:08 pm. »
Developer
Registered: Apr 2004
Posts: 2215
Location: Belgium
I am aware of the limitations of the system in 0.x. 2.0 should be a very big improvement.
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog

Page: 1

UseBB Community » 2.x Discussion » Some input for 2.0

UseBB Community is powered by UseBB 1 Forum Software