tommyquang Posted December 15, 2009 Share Posted December 15, 2009 Anyone know how can I show 3 latest announcements on portal home? 0 Quote Link to comment Share on other sites More sharing options...
bear Posted December 15, 2009 Share Posted December 15, 2009 http://wiki.whmcs.com/Linking_to_WHMCS#Showing_Announcements_on_your_Site 0 Quote Link to comment Share on other sites More sharing options...
tommyquang Posted December 15, 2009 Author Share Posted December 15, 2009 Thanks for the link, but I want to show 3 latest announcements on the portal home page, not on my website. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted December 16, 2009 Share Posted December 16, 2009 Have you tried that? What happens when you do? You may not need the first two lines and the opening and closing PHP tags, or you could try inserting the full block with {PHP}{/PHP} if you're getting smarty errors. 0 Quote Link to comment Share on other sites More sharing options...
chrismfz Posted December 16, 2009 Share Posted December 16, 2009 <?php $query = "SELECT * from tblannouncements WHERE published='on' ORDER BY date DESC"; $result=mysql_query($query); $num=0; while($data = mysql_fetch_array($result) and $num<3 ) { $num = $num +1; $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = $data["announcement"]; $date = fromMySQLDate($date); echo("$date <br />"); echo(" - <b>$title</b> -<br />"); echo("$announcement"); echo('<br />___________________________<br />'); } ?> You can insert this code in template using {php} tags or simpler, create a file like announcements.php paste the code there, make any changes you want with the format (font, color, css, etc) and then just include the file using {php}include announcements.php{/php} 0 Quote Link to comment Share on other sites More sharing options...
kits Posted March 12, 2012 Share Posted March 12, 2012 Below code are use with smarty and SEF urls. Hopefuly englighten who ever stucked with $announcements loop. {if $announcements} <div class="latest_news"> {foreach from=$announcements item=announcement name=foo} {if $smarty.foreach.foo.index < 3} <div class="n_date">{$announcement.date}</div> <div class="n_tite"><a href="{if $seofriendlyurls}announcements/{$announcement.id}/{$announcement.urlfriendlytitle}.html{else}announcements.php?id={$announcement.id}{/if}">{$announcement.title}</a></div> <div class="n_para">{$announcement.text|strip_tags|truncate:100:"..."}</div> <div class="n_rear"><a href="{if $seofriendlyurls}announcements/{$announcement.id}/{$announcement.urlfriendlytitle}.html{else}announcements.php?id={$announcement.id}{/if}"">read more</a></div> {/if} {/foreach} {/if} you can use index to control the loop condition. {if $smarty.foreach.foo.index < 3} means you will get 3 latest announcements. 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.