sequencehost Posted April 16, 2012 Share Posted April 16, 2012 Hello, I'm looking to display 1 announcement in the sidebar of WHMCS, I've found the following code in the view announcements file: {if $announcements} {foreach from=$announcements item=announcement} <p>{$announcement.date} - <a href="announcements.php?id={$announcement.id}">{$announcement.title}</a> - {$announcement.text|strip_tags|truncate:100:"..."}</p> {/foreach} {/if} Would anyone happen to know how I can use this code to display just 1 announcement rather than all of them. Thanks George. 0 Quote Link to comment Share on other sites More sharing options...
panacheweb Posted April 17, 2012 Share Posted April 17, 2012 (edited) yes.. use the rss feed to pull the data back into the website.. <?php $xml=("https://www.yourwebsite.com/whmcsdir/announcementsrss.php"); $xmlDoc = new DOMDocument(); $xmlDoc->load($xml); //get and output "<item>" elements $x=$xmlDoc->getElementsByTagName('item'); for ($i=0; $i<=0; $i++) { $item_title=$x->item($i)->getElementsByTagName('title') ->item(0)->childNodes->item(0)->nodeValue; $item_link=$x->item($i)->getElementsByTagName('link') ->item(0)->childNodes->item(0)->nodeValue; $item_desc=$x->item($i)->getElementsByTagName('description') ->item(0)->childNodes->item(0)->nodeValue; echo ("<h1>Company News:</h1> <a href='" . $item_link . "'>" . $item_title . "</a> <p style=\"color:white;\">". strip_tags($item_desc)."</p>"); } ?> also I got the code from: http://www.w3schools.com/php/php_ajax_rss_reader.asp so no need to thank me.. Edited April 17, 2012 by panacheweb 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.