handsonwebhosting Posted July 29, 2008 Share Posted July 29, 2008 Thanks for the fix Apollo1. I've never NOT had new announcements, so I never got the error. Thanks for the fix, I'll add that to my local code! 0 Quote Link to comment Share on other sites More sharing options...
sally24 Posted August 23, 2008 Share Posted August 23, 2008 it's possible to visualize the news without php but only with HTML? 0 Quote Link to comment Share on other sites More sharing options...
WO-Jacob Posted September 3, 2008 Share Posted September 3, 2008 it's possible to visualize the news without php but only with HTML? Well, yes, but it takes a little trickery... here's what I did: First, you have to make one php file. in WHMCS/libs/plugins, I made the file: function.fetch_announcements.php which contains: <?php function smarty_function_fetch_announcements($params, &$smarty) { if (empty($params['var'])) { $smarty->_trigger_fatal_error("[plugin] parameter 'var' cannot be empty"); return; } $params['count'] = intval($params['count']); $query = "SELECT * FROM tblannouncements WHERE published='on' ORDER BY date DESC LIMIT 0,".$params['count']; $result = mysql_query($query); $out = array(); while ($data = mysql_fetch_array($result)) { $data['date'] = fromMySQLDate($data['date']); $data['link'] = 'announcements.php?id='.$data['id']; $out[] = $data; } mysql_free_result($result); $announcement_count = count($out); if ($announcement_count == 1) $out = $out[0]; elseif ($announcement_count == 0) $out = null; $smarty->assign($params['var'], $out); return ''; } ?> Then in any template inside of WHMCS, you can pull announcements very easily: Here's the code to display the latest announcement: {fetch_announcements var=announcement count=1} {if $announcement != null} <div class="announcement"> <h2>{$announcement.title}</h2> <div class="announcement_body">{$announcement.announcement|truncate:100} <a href="{$announcement.link}">Read more</a></div> </div> {/if} now say you want to pull up to the last 5? but only show titles? {fetch_announcements var=announcements count=5} {if $announcements == null} <p>We're sorry, there are no announcements.</p> {else} <h2>Latest Announcements</h2> <ul> {foreach item=announcement key=key from=$announcements} <li><a href="{$announcement.link}">{$announcement.name}</a></li> {/foreach} {/if} Basically, fetch_announcements acts as a 'shortcut' to all the code to get the content of the announcements. Fun stuff. 0 Quote Link to comment Share on other sites More sharing options...
djrino Posted September 23, 2008 Share Posted September 23, 2008 WO-Jacob many tnx is possible to give a scroll on this? like sccroll last 5 or 10 anouncements? Tnx 0 Quote Link to comment Share on other sites More sharing options...
WO-Jacob Posted September 24, 2008 Share Posted September 24, 2008 WO-Jacob many tnx is possible to give a scroll on this? like sccroll last 5 or 10 anouncements? Tnx {fetch_announcements var=announcements count=5} {if $announcements == null} <p>We're sorry, there are no announcements.</p> {else} <div style="width: 100%; height=300px; overflow: scroll;"> <h2>Latest Announcements</h2> <ul> {foreach item=announcement key=key from=$announcements} <li><a href="{$announcement.link}">{$announcement.name}</a></li> {/foreach} </ul> </div> {/if} Should do at least close to the trick. 0 Quote Link to comment Share on other sites More sharing options...
djrino Posted September 24, 2008 Share Posted September 24, 2008 Hi many many tnx for reply but not work for me i have 5 anouncement if i put this code {fetch_announcements var=announcement count=1} {if $announcement != null} {$announcement.title} {$announcement.announcement|truncate:100} Ler Mais {/if} all work good an i see the last anouncement if i put the other code with the scroll or not i not see any anouncement only the box can you test please? many tnx for the help 0 Quote Link to comment Share on other sites More sharing options...
djrino Posted September 24, 2008 Share Posted September 24, 2008 I'm not a professional programer but is somethink like this For show the last 5 anouncement {fetch_announcements var=announcements count=5} {if $announcements == null} <p>We're sorry, there are no announcements.</p> {else} <h2>Latest Announcements</h2> <ul> {foreach item=announcement key=key from=$announcements} <li><a href="{$announcement.link}">{$announcement.announcement|truncate:100}</a></li> <div class="announcement_body"><a href="{$announcement.link}">Read more</a></div> {/foreach}{/if} but the code need improvment if you can i apreciate so much many TNX 0 Quote Link to comment Share on other sites More sharing options...
WO-Jacob Posted October 15, 2008 Share Posted October 15, 2008 I'll see if I can test with this on thursday. We have two announcements now, so I should be able to tell if it's working or if I had a bug. 0 Quote Link to comment Share on other sites More sharing options...
LemonBarley Posted October 15, 2008 Share Posted October 15, 2008 can you post up a screenshot of your clienthomearea and show it? 0 Quote Link to comment Share on other sites More sharing options...
WO-Jacob Posted October 16, 2008 Share Posted October 16, 2008 can you post up a screenshot of your clienthomearea and show it? Here is what i'm using currently: {fetch_announcements var=announcement count=1} {if $announcement != null} <div class="announcement"> <h2>{$announcement.title}</h2> <div class="announcement_body">{$announcement.announcement|truncate:100} <a href="{$announcement.link}">Read more</a></div> </div> {/if} which produces the attached image... 0 Quote Link to comment Share on other sites More sharing options...
SkGold Posted May 19, 2009 Share Posted May 19, 2009 Here the code I used: {php} function truncate($text) { $text = substr($text,0,390); $text = substr($text,0,strrpos($text,' ')); return $text; } include("support/dbconnect.php"); include("support/includes/functions.php"); $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 = truncate($data['announcement']); $date = fromMySQLDate($date); echo'<div style="border:solid 1px #e8e8e8; padding:5px;background-color:#f7f7f7;">'.$date.'*-*<strong><a href="announcements.php?id='.$id.'">'.$title.'</a></strong> <p class="sfont2">'.$announcement.' <a href="announcements.php?id='.$id.'">...more</a></p></div>'; } {/php} Now I start using SEO Friendly URLs. How can I change <a href="announcements.php?id='.$id.'"> to SEO Friendly??? Thanks in advance, Sergey 0 Quote Link to comment Share on other sites More sharing options...
SkGold Posted May 21, 2009 Share Posted May 21, 2009 Any ideas? Is it possible to make this URL SEO Friendly? Any help much appreciated. Here the code I used: {php} function truncate($text) { $text = substr($text,0,390); $text = substr($text,0,strrpos($text,' ')); return $text; } include("support/dbconnect.php"); include("support/includes/functions.php"); $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 = truncate($data['announcement']); $date = fromMySQLDate($date); echo'<div style="border:solid 1px #e8e8e8; padding:5px;background-color:#f7f7f7;">'.$date.'*-*<strong><a href="announcements.php?id='.$id.'">'.$title.'</a></strong> <p class="sfont2">'.$announcement.' <a href="announcements.php?id='.$id.'">...more</a></p></div>'; } {/php} Now I start using SEO Friendly URLs. How can I change <a href="announcements.php?id='.$id.'"> to SEO Friendly??? Thanks in advance, Sergey 0 Quote Link to comment Share on other sites More sharing options...
p30delta Posted September 19, 2012 Share Posted September 19, 2012 plaese help me how can i show news in html code? 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.