Smarty Function for HTML
Jamroom Developers
Yes - Use a custom smarty function. Create it with a custom module with just an include.php file that looks like this -
<?php
// make sure we are not being called directly
defined('APP_DIR') or exit();
/**
* meta
*/
function xxHTMLSmarty_meta(){
$_tmp = array(
'name' => 'HTMLSmarty',
'url' => 'htmlsmarty',
'version' => '1.0.0',
'developer' => 'SoftDesigns ©' . strftime('%Y'),
'description' => '????',
'license' => 'mpl',
'category' => 'admin'
);
return $_tmp;
}
/**
* init
*/
function xxHTMLSmarty_init(){
return true;
}
/**
* Smarty function to get html string
* @param $param string Param name
* @return string
*/
function smarty_function_xxHTMLSmarty_get_html($param)
{
return 'The html string to be returned goes here!!';
}
Then in the templates just use {$xxHTMLSmarty_get_html}
If you have several html strings you might want to return, pass in a parameter and return on that -
<?php
// make sure we are not being called directly
defined('APP_DIR') or exit();
/**
* meta
*/
function xxHTMLSmarty_meta(){
$_tmp = array(
'name' => 'HTMLSmarty',
'url' => 'htmlsmarty',
'version' => '1.0.0',
'developer' => 'SoftDesigns ©' . strftime('%Y'),
'description' => '????',
'license' => 'mpl',
'category' => 'admin'
);
return $_tmp;
}
/**
* init
*/
function xxHTMLSmarty_init(){
return true;
}
/**
* Smarty function to get an html string
* @param $param string Param name
* @return string
*/
function smarty_function_xxHTMLSmarty_get_html($param)
{
$_html = array(
1 => 'HTML string 1',
2 => 'HTML string 2',
3 => 'HTML string 3',
);
return $_html[$param['id'];
}
which would be called as {xxHTMLSmarty_get_html id=2}
If the possible html strings to be returned need to be more dynamically configurable, create the module using the Aparna module then add a smarty fuction to that to return html strings created by admin and stored on a datastore.
hth