Jump to content

Display 1 announcements in sidebar


sequencehost

Recommended Posts

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.

Link to comment
Share on other sites

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 by panacheweb
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