Accessing Jojo:: functions from a template

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.

Back to Forum Index : Back to Themes Support   RSS
mikec

Lead Developer

mikec

2 Aug 2010
Posts: 67

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.
Rick Rick

2 Aug 2010
Posts: 336

Thanks for sharing, it looks like a useful snippet.
ayoub

16 Aug 2010
Posts: 39

hey guys!
anything similar for smarty?
Would you recommand leaving smarty for dwoo?
Thx
mikec

Lead Developer

mikec

16 Aug 2010
Posts: 67

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.
ayoub

18 Aug 2010
Posts: 39

Thx very much. Havn't tried it yet but i will asap and post a reply
Back to Forum Index : Back to Themes Support   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.