RPS Posted April 24, 2009 Author Share Posted April 24, 2009 Sorry RPS i have spent the last hour reading and changing the code as stated in this topic but still no luck. the code i am using is here http://www.cg-computers.co.uk/announcements.php - Read post # 36. The guy has the exact same problem as you. He fixed it by using a php extension. If you did that, then there is probably something wrong with php. Maybe try replacing that file with <? phpinfo(); ?> and see if anything comes up. 0 Quote Link to comment Share on other sites More sharing options...
Bucket Posted May 23, 2009 Share Posted May 23, 2009 My Version: <? $x=1; // requested edit // truncate the text to only 65 chars, add ... to the end function truncate($text) { $text = substr($text,0,60); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } // format the date to mm/dd/yyyy function formatdate($date) { $year = substr ($date, 0, 4); $month = substr ($date, 5, 2); $day = substr ($date, 8, 2); return $month.'/'.$day.'/'.$year; } // limit the number of announcements to return $limit = 2; echo('<p class="header">Announcements</p>'); require '/home/USERNAME/public_html/WHMCSLINK/configuration.php'; $link = mysql_connect($db_host,$db_username,$db_password); mysql_select_db($db_name); $result = mysql_query("SELECT * FROM tblannouncements WHERE published='on' ORDER BY id DESC LIMIT ".$limit); while($data = mysql_fetch_array ($result)) { $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = $data["announcement"]; $date = fromMySQLDate($date); echo("<p><font color=#cccccc>$date</font> - <b>$title</b> <br>$announcement</p>"); echo('<a href="/whmcs/announcements.php?id='.$id.'">More Info</a><br>'); echo('<hr />'); } if(!$x) echo '<p>News & Announcements: <a href="announcements.php">View More</a></p>'; if($x) echo '<p>News & Announcements: <a href="announcements.php">View More</a></p>'; ?> 0 Quote Link to comment Share on other sites More sharing options...
AxlF Posted May 25, 2009 Share Posted May 25, 2009 ... echo("<p><font color=#cccccc>$date</font> - <b>$title</b> ... I don't wanna bash you. This is only a hint: The <font> tag in HTML is deprecated 0 Quote Link to comment Share on other sites More sharing options...
Parnian Posted May 26, 2009 Share Posted May 26, 2009 My Version: <? $x=1; // requested edit // truncate the text to only 65 chars, add ... to the end function truncate($text) { $text = substr($text,0,60); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } // format the date to mm/dd/yyyy function formatdate($date) { $year = substr ($date, 0, 4); $month = substr ($date, 5, 2); $day = substr ($date, 8, 2); return $month.'/'.$day.'/'.$year; } // limit the number of announcements to return $limit = 2; echo('<p class="header">Announcements</p>'); require '/home/USERNAME/public_html/WHMCSLINK/configuration.php'; $link = mysql_connect($db_host,$db_username,$db_password); mysql_select_db($db_name); $result = mysql_query("SELECT * FROM tblannouncements WHERE published='on' ORDER BY id DESC LIMIT ".$limit); while($data = mysql_fetch_array ($result)) { $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = $data["announcement"]; $date = fromMySQLDate($date); echo("<p><font color=#cccccc>$date</font> - <b>$title</b> <br>$announcement</p>"); echo('<a href="/whmcs/announcements.php?id='.$id.'">More Info</a><br>'); echo('<hr />'); } if(!$x) echo '<p>News & Announcements: <a href="announcements.php">View More</a></p>'; if($x) echo '<p>News & Announcements: <a href="announcements.php">View More</a></p>'; ?> This code has a problem! in echo's, you need to put your parameters like this : ". $title ." So, this : echo("<p><font color=#cccccc>$date</font> - <b>$title</b> <br>$announcement</p>"); Would just display $date, $title and $announcement. But if you change it to this : echo("<p><font color=#cccccc>". $date ."</font> - <b>". $title ."</b> <br>". $announcement ."</p>"); It works completly. I have tested this and I wanted to help users that don't have PHP experience and are stuck on this. Hope it helps... 0 Quote Link to comment Share on other sites More sharing options...
Bucket Posted June 1, 2009 Share Posted June 1, 2009 What do you think of my code. The only thing is that it shows the WHOLE announcement... I do not know how to fix it... Lol... if someone can please post it. 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted June 1, 2009 Author Share Posted June 1, 2009 What do you think of my code. The only thing is that it shows the WHOLE announcement... I do not know how to fix it... Lol... if someone can please post it. - Look at my first post: // truncate the text to only 65 chars, add ... to the end function truncate($text) { $text = substr($text,0,60); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } 0 Quote Link to comment Share on other sites More sharing options...
Bucket Posted June 3, 2009 Share Posted June 3, 2009 Can you post the my version with the 65 text limit added? 0 Quote Link to comment Share on other sites More sharing options...
Bucket Posted June 3, 2009 Share Posted June 3, 2009 Updated with 65 character Limit: <? $x=1; // requested edit // truncate the text to only 65 chars, add ... to the end function truncate($text) { $text = substr($text,0,60); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } // format the date to mm/dd/yyyy function formatdate($date) { $year = substr ($date, 0, 4); $month = substr ($date, 5, 2); $day = substr ($date, 8, 2); return $month.'/'.$day.'/'.$year; } // limit the number of announcements to return $limit = 2; echo('<p class="header">Announcements</p>'); require '/home/USERNAME/public_html/WHMCSLINK/configuration.php'; $link = mysql_connect($db_host,$db_username,$db_password); mysql_select_db($db_name); $result = mysql_query("SELECT * FROM tblannouncements WHERE published='on' ORDER BY id DESC LIMIT ".$limit); while($data = mysql_fetch_array ($result)) { $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = $data["announcement"]; $date = fromMySQLDate($date); echo("<p><font color=#cccccc> '.$date.' </font> - <b> '.$title.' </b> <br> '.$announcement.' </p>"); echo('<a href="/whmcs/announcements.php?id='.$id.'">More Info</a><br>'); echo('<hr />'); } if(!$x) echo '<p>News & Announcements: <a href="announcements.php">View More</a></p>'; if($x) echo '<p>News & Announcements: <a href="announcements.php">View More</a></p>'; ?> 0 Quote Link to comment Share on other sites More sharing options...
messer Posted September 9, 2009 Share Posted September 9, 2009 small modification if someone want to use mysqli instead mysql <?PHP $x=1; // truncate the text to only 65 chars, add ... to the end function truncate($text) { $text = substr($text,0,65); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } // format the date to mm/dd/yyyy function formatdate($date) { $year = substr ($date, 0, 4); $month = substr ($date, 5, 2); $day = substr ($date, 8, 2); return $year.'/'.$month.'/'.$day; } // limit the number of announcements to return $limit = 2; require '/home/user/public_html/whmcs/configuration.php'; $sql = new mysqli($db_host,$db_username,$db_password,$db_name); $result = $sql->query("SELECT * FROM tblannouncements WHERE published='on' ORDER BY id DESC LIMIT ".$limit); while ($row = $result->fetch_object()) { $id = $row->id; $date = $row->date; $announcement = truncate($row->announcement); $date = formatdate($date); echo'<p><span>'.$date.'</span> - '.$announcement.' <a href="/whmcs/announcements.php?id='.$id.'"><img src="/images/more.gif" alt="more info" /></a></p>'; echo'<hr />'; $x=false; } $result->close(); $sql->close(); if(!$x) echo '<p>News & Announcements: <a href="announcements.php">View More</a></p>'; if($x) echo '<p>News & Announcements: <a href="announcements.php">View More</a></p>'; ?> 0 Quote Link to comment Share on other sites More sharing options...
epicseeds Posted April 10, 2010 Share Posted April 10, 2010 sorry to bring an old thread back to life, but this seems like a neat feature. I am just a bit confused how to do this - at first I thought you were just supposed to copy the code and put it somewhere inside you index.html and change the code around a bit...but this is wrong lol apparently it is supposed to be in its own .php file? I just made its own .php file - now how do i get it to display on one of my webpages?! lol...sorry I am completely ignorant in how these things work! 0 Quote Link to comment Share on other sites More sharing options...
sgrayban Posted April 10, 2010 Share Posted April 10, 2010 You can use something like this... {php} echo file_get_contents("/path-to/remote.php"); {/php} 0 Quote Link to comment Share on other sites More sharing options...
Greenix Posted June 10, 2010 Share Posted June 10, 2010 I have a simple .html page and for obvious reasons don't want to convert to .php extensions. How would I go about including the announcements via WHMCS? Thanks! Meredith 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted June 10, 2010 Author Share Posted June 10, 2010 You would have to use javascript to grab the content, and display it that way. Check out something like this: http://www.javascriptkit.com/dhtmltutors/ajaxincludes.shtml 0 Quote Link to comment Share on other sites More sharing options...
Greenix Posted June 10, 2010 Share Posted June 10, 2010 That's a help!! I was searching and saw a few similar scripts but they weren't working out. Thanks, I'll try it. 0 Quote Link to comment Share on other sites More sharing options...
nimafire Posted June 22, 2010 Share Posted June 22, 2010 Hello how can i change unicod to utf-8 ? becasue it show me وزارت خزانه داری آمریکا تØ*ریم های اینترنتی علیه کاربران ایران سودان Ùˆ کوبا را لغو کرده Ùˆ از شرکت های ارایه دهنده Û 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted June 22, 2010 Author Share Posted June 22, 2010 Pretty sure you need to do that within your HTML template. Applying this mod shouldn't require you to change anything like that. 0 Quote Link to comment Share on other sites More sharing options...
Greenix Posted June 23, 2010 Share Posted June 23, 2010 I just found some great ones today - but this is the one I like the most. It's nice to be able to upgrade and then you can remove the linkbacks which doesn't always look good in certain circumstances. Plus you can use with multiple sites and this can help you easily tie your network together. http://www.rssinclude.com/ 0 Quote Link to comment Share on other sites More sharing options...
Riply Posted June 24, 2010 Share Posted June 24, 2010 You could always use a RSS feedburner or something like that? I am using wordpress and will use a RSS feed reader/publisher plugin to grab the announcements and put them on the front-end. 0 Quote Link to comment Share on other sites More sharing options...
Greenix Posted June 24, 2010 Share Posted June 24, 2010 That's about the only thing I miss with CMS are the super handy collections of extensions. I did away with Joomla on some new sites as I was tired of the security problems, but now I have to go and search out the old fashioned way for my plain ole html pages. But I have to say, (knock on wood) not one of them has been hacked from external sources as long as I've had them since 1998 thanks for the rss feedburner tip. 0 Quote Link to comment Share on other sites More sharing options...
Nimitz1061 Posted June 25, 2010 Share Posted June 25, 2010 I have a simple .html page and for obvious reasons don't want to convert to .php extensions. How would I go about including the announcements via WHMCS? Thanks! Meredith Javascript? Sheesh. Just configure your system to parse html files for PHP code - then follow the instructions previously given.. David 0 Quote Link to comment Share on other sites More sharing options...
Greenix Posted June 25, 2010 Share Posted June 25, 2010 Is javascript awful now? talk to me... 0 Quote Link to comment Share on other sites More sharing options...
sajthosting Posted August 12, 2010 Share Posted August 12, 2010 Thanks for this tutorial, it helps alot. 0 Quote Link to comment Share on other sites More sharing options...
luangjokaj Posted November 27, 2010 Share Posted November 27, 2010 Thanks for this. But for example if i want the news box in another language and not in default language? How can i do that? 0 Quote Link to comment Share on other sites More sharing options...
urbee Posted December 13, 2010 Share Posted December 13, 2010 I also cannot fix the encoding (scarons). They work on the website (joomla) they work in whmcs, but with this link the announcements are not encoded correctly on the website. 0 Quote Link to comment Share on other sites More sharing options...
Buzz Posted September 26, 2011 Share Posted September 26, 2011 (edited) I am wanting to display my announcements in my header banner image and want it to scroll through the announcements I was looking for an rss feed to work with my site and whmcs to pull announcements from whmcs and display it in a certain area of my website the area is a small box so it is going to be limited to how much information is displayed so I was thinking that rss feeds would work better this way I have have it scroll through it or something Edited September 26, 2011 by Buzz 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.