Accessing Jojo:: functions from a template, a forum discussion on Jojo CMS. Join us for more discussions on Accessing Jojo:: functions from a template on our Themes Support forum.
You must be logged in to post a reply
| |
Here's a short bit of code that allows you to create your own filter for Dwoo that you can then use in your template.
For example if you wanted to access Jojo::cleanUrl() from a template:
In your theme's api.php add:
if (!function_exists('Dwoo_Plugin_cleanurl_compile')) {
function Dwoo_Plugin_cleanurl_compile(Dwoo_Compiler $compiler, $value)
{
return 'Jojo::cleanUrl('.$value.')';
}
}
In your template you can now use:
{$variable|cleanurl}
That's it.
You could easily modify this to call any function from any class. See the Dwoo docs for other ways to write plugins.
For example if you wanted to access Jojo::cleanUrl() from a template:
In your theme's api.php add:
if (!function_exists('Dwoo_Plugin_cleanurl_compile')) {
function Dwoo_Plugin_cleanurl_compile(Dwoo_Compiler $compiler, $value)
{
return 'Jojo::cleanUrl('.$value.')';
}
}
In your template you can now use:
{$variable|cleanurl}
That's it.
You could easily modify this to call any function from any class. See the Dwoo docs for other ways to write plugins.
ayoub
16 Aug 2010
Posts: 33
hey guys!
anything similar for smarty?
Would you recommand leaving smarty for dwoo?
Thx
anything similar for smarty?
Would you recommand leaving smarty for dwoo?
Thx
I would recommend you switch to dwoo from smarty. But it's similar for smarty (totally untested so you might need to debug some issues with this):
Add this to your theme's global.php
if (!function_exists('smarty_modifier_cleanurl')) {
function smarty_modifier_cleanurl($value)
{
return Jojo::cleanUrl($value);
}
$smarty->register_modifier('cleanurl', 'smarty_modifier_cleanurl');
}
If this works it would be good if you could let us know here in case other people are looking for a smarty solution too.
Add this to your theme's global.php
if (!function_exists('smarty_modifier_cleanurl')) {
function smarty_modifier_cleanurl($value)
{
return Jojo::cleanUrl($value);
}
$smarty->register_modifier('cleanurl', 'smarty_modifier_cleanurl');
}
If this works it would be good if you could let us know here in case other people are looking for a smarty solution too.
| Back to Forum Index : Back to Themes Support |
|
