DennisHermannsen Posted January 24, 2019 Share Posted January 24, 2019 I'm having trouble returning a string using ClientAreaPageSubmitTicket. If I use AdminAreaViewTicketPage, the div is shown just fine when viewing a ticket as an admin. <?php add_hook('ClientAreaPageSubmitTicket', 1, function($vars) { return '<div class="alert alert-info alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>Check <b><a href="/client/serverstatus.php">serverstatus</a></b> before submitting a new ticket</div>'; }); Any reason why this doesn't work? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 24, 2019 Share Posted January 24, 2019 1 hour ago, DennisMidjord said: Any reason why this doesn't work? because ClientAreaPageSubmitTicket returns a Smarty array, not a string - so you effectively have two simple choices (there would be other complicated ones too!) - either rewrite the hook to return an array... <?php # Submit Ticket String Hook # Written by brian! function submit_ticket_string_hook($vars){ $submitstring = '<div class="alert alert-info alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>Check <b><a href="/client/serverstatus.php">serverstatus</a></b> before submitting a new ticket</div>'; return array("submitstring" => $submitstring); } add_hook("ClientAreaPageSubmitTicket", 1, "submit_ticket_string_hook"); ... but then you'd have to edit the template to decide where to output that array and add {$submitstring} there... or just edit the template and add your code to it directly. given that you're going to have to edit the template anyway going down this road, you might as well just edit the template. 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted January 24, 2019 Author Share Posted January 24, 2019 32 minutes ago, brian! said: ...you might as well just edit the template. Too bad. I thought this was a nice way of handling changes to the theme we're using, but I guess not 😉 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 24, 2019 Share Posted January 24, 2019 Hi Dennis, the thing about hooks returning strings is that it only works when the template has been designed to expect it - some of them have, most haven't... even if your original hook did return a string, it wouldn't know exactly where to output it in the template - nor could you tell it in the hook. I suppose that you could use one of the headoutput hooks to add your banner along the page, but I wouldn't think that it would look particularly impressive... 😧 I don't know where you wanted to output the alert, but there would be alternatives to returning a string in a hook or editing the template... use a Language Override and change the header text used on the support page... $_LANG['supportticketsheader'] = "If you can't find a solution to your problems in our knowledgebase, you can submit a ticket by selecting the appropriate department below.<br><div class=\"alert alert-info alert-dismissible\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>Check <b><a href=\"serverstatus.php\">serverstatus</a></b> before submitting a new ticket</div>"; if memory serves, you only use Danish & English on your site, so you should only need to create an override for each of those languages - and they shouldn't be removed / overwritten during a WHMCS update. you can open a bootstrap modal window on the page using a hook (technically 2 hooks in the same file)... it uses language overrides were possible (obviously not your string!)... the hook code is just a slightly varied version of the one i demo'd two years ago in the thread below and still works fine in v7.7 (or earlier) in the "Six" template... given time I could probably think of other solutions, but for your situation, that Language Overrides option might be the quickest one, without editing the template, that is the closest to what you wanted to do in the hook. 1 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.