CassidyDNS Posted November 8, 2020 Share Posted November 8, 2020 Does anyone know if there is a way I can add alerts into the smarty variable please? In the clientareadomaindetails.tpl file, we have the below: {if $alerts} {foreach $alerts as $alert} {include file="$template/includes/alert.tpl" type=$alert.type msg="<strong>{$alert.title}</strong><br>{$alert.description}" textcenter=true} {/foreach} {/if} I would like to add to these alerts to display my own custom messages. Using the below I have managed to create my own custom alerts within my registrar module function modulename_ClientArea($params) { global $smarty; $alerts = array(); $alerts[] = array( 'title' => 'Title', 'description' => 'description', 'type' => 'info' ); $smarty->assign('customalerts', $alerts); return ''; } But this would involve maintaining the tpl file mentioned above, which I'd like to avoid. I have tried the below as well, but anything I add doesn't exist by the time it gets the tpl file gets loaded, even when there are alerts already in the array when I add to them. function modulename_ClientArea($params) { global $smarty; $alerts = $smarty->getTemplateVars('alerts'); $alerts[] = array( 'title' => 'Title', 'description' => 'description', 'type' => 'info' ); $smarty->assign('alerts', $alerts); return ''; } FYI the reason I am not simply returning the alerts as html instead is because they would be put at the bottom of the domain overview page. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 8, 2020 Share Posted November 8, 2020 1 hour ago, CassidyDNS said: I have tried the below as well, but anything I add doesn't exist by the time it gets the tpl file gets loaded, even when there are alerts already in the array when I add to them. if that's v8, i'm not sure that gTV would work as it might get blocked by the Smarty Security Policy. I also wouldn't bother using smarty assign, i'd just be returning the arrays in the return. 1 hour ago, CassidyDNS said: FYI the reason I am not simply returning the alerts as html instead is because they would be put at the bottom of the domain overview page. only because that's the current position where they're output is specified in the clientareadomaindetails template (line ~ 120) - there's nothing to stop you moving that block to the top by the alerts code you specify.. same would apply to the hook output if you used ClientAreaDomainDetailsOutput (though if you're in a registrar module, you shouldn't need to use that I wouldn't have thought). annoyingly I couldn't find a domain with an existing alert, but if you can get the existing alerts array (won't exist unless there are existing alerts), you should be able to append it - assuming the array exists before the module runs. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.