Jump to content

Announcements in Footer.tpl


BAJI26

Recommended Posts

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 by BAJI26
Link to comment
Share on other sites

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}

Link to comment
Share on other sites

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. :idea:

Link to comment
Share on other sites

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. :idea:

 

Works perfectly! THANKS!!!!!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated