Issue with UDT and Smarty Variables in Custom Module
Posted: Fri Mar 28, 2025 8:25 am
Hi everyone, I'm new to CMS Made Simple and trying to create a custom solution using a User-Defined Tag (UDT) along with Smarty variables, but I’m running into issues.
I have a UDT that fetches data from a custom database table and assigns it to a Smarty variable like this:
Then, in my template, I try to use:
However, the variable does not seem to be available in the template. I’ve tried clearing the cache and debugging with `{$smarty.debug}` but don’t see `my_custom_data` in the list of assigned variables.
Am I missing something in how CMSMS handles UDTs and variable assignment? Any help would be greatly appreciated!
I have a UDT that fetches data from a custom database table and assigns it to a Smarty variable like this:
Code: Select all
global $smarty, $db;
$query = "SELECT title, content FROM cms_my_custom_table WHERE id = ?";
$result = $db->GetRow($query, [1]);
if ($result) {
$smarty->assign('my_custom_data', $result);
}
Code: Select all
{$my_custom_data.title}
{$my_custom_data.content}
Am I missing something in how CMSMS handles UDTs and variable assignment? Any help would be greatly appreciated!