BAJI26 Posted November 8, 2015 Share Posted November 8, 2015 (edited) I really need help getting the Announcements to show in the footer.tpl they work fine in html pages. Need suggestions~! Don't want to Enable Smarty tags because it mentions its a security risk! Edited November 8, 2015 by BAJI26 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted November 9, 2015 Share Posted November 9, 2015 check the reply in this thread, brian's code should do the trick, if you don't like to enable the {php} tag then place the query code in ActionHook:ClientAreaPage and pass the result to your template! http://forum.whmcs.com/showthread.php?92467-announcements-in-footer&p=388554#post388554 0 Quote Link to comment Share on other sites More sharing options...
BAJI26 Posted November 9, 2015 Author Share Posted November 9, 2015 How would I place the query code in the ActionHook? Can you write it for me so I can see how to do it and learn?! 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted November 9, 2015 Share Posted November 9, 2015 I will make a quick example for you, this code is from the thread i mentioned above: 1) Create new file inside /includes/hooks/ folder, name it footerAnnouncements.php or anything you prefer, then place the following code inside it: <?php function hook_footerAnnouncements($vars){ $output = ""; $query = "SELECT * FROM tblannouncements WHERE published='on' ORDER BY date DESC LIMIT 0,3"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = $data["announcement"]; $date = fromMySQLDate($date); $output .= '<p><font color="#cccccc">'.$date.'</font> - <b>'.$title.'</b><br />'.$announcement.'</p>'; } return array("footerannouncements" => $output); } add_hook("ClientAreaPage", 1, "hook_footerAnnouncements"); 2) inside your /template-name/footer.tpl, use this smarty tag to display the results: {$footerannouncements} 0 Quote Link to comment Share on other sites More sharing options...
BAJI26 Posted November 9, 2015 Author Share Posted November 9, 2015 Thanks, I tried that and still blank... do I have to enable Smarty in order for this method to work? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted November 9, 2015 Share Posted November 9, 2015 if you get blank page then enable the debugging option to see what's wrong: http://docs.whmcs.com/Blank_Pages#If_you_can_access_the_Admin_Area 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 9, 2015 Share Posted November 9, 2015 I don't think he meant a blank page, just that it didn't output anything in the footer - it doesn't for me either! the problem will be caused by WHMCS making changes to the database structure of tblannouncements since my original code was posted - in v5.3, the published field was either "on" or blank; in v6, it is now either "1" or "0". so the hook should be along the lines of... <?php function hook_footerAnnouncements($vars){ $output = ""; $query = "SELECT * FROM tblannouncements WHERE published='1' ORDER BY date DESC LIMIT 0,3"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = $data["announcement"]; $date = fromMySQLDate($date); $output .= '<p><font color="#cccccc">'.$date.'</font> - <b>'.$title.'</b><br />'.$announcement.'</p>'; } return array("footerannouncements" => $output); } add_hook("ClientAreaPage", 1, "hook_footerAnnouncements"); ... though the official docs says to use - WHERE published != '0' AND published != '' - either should work. for me, the above hook now displays the announcements in the footer. 1 Quote Link to comment Share on other sites More sharing options...
BAJI26 Posted November 9, 2015 Author Share Posted November 9, 2015 I don't think he meant a blank page, just that it didn't output anything in the footer - it doesn't for me either! the problem will be caused by WHMCS making changes to the database structure of tblannouncements since my original code was posted - in v5.3, the published field was either "on" or blank; in v6, it is now either "1" or "0". so the hook should be along the lines of... <?php function hook_footerAnnouncements($vars){ $output = ""; $query = "SELECT * FROM tblannouncements WHERE published='1' ORDER BY date DESC LIMIT 0,3"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = $data["announcement"]; $date = fromMySQLDate($date); $output .= '<p><font color="#cccccc">'.$date.'</font> - <b>'.$title.'</b><br />'.$announcement.'</p>'; } return array("footerannouncements" => $output); } add_hook("ClientAreaPage", 1, "hook_footerAnnouncements"); ... though the official docs says to use - WHERE published != '0' AND published != '' - either should work. for me, the above hook now displays the announcements in the footer. Works perfectly! THANKS!!!!!!! 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.