PDA

View Full Version : Cutenews help



Seads
30-10-2008, 07:40 PM
Hey does anyone know how to display the latest news published on cutenews in a box and so it auto-updates, for example www.clubhabbo.net?

iUnknown
30-10-2008, 07:48 PM
Yep, just use an iframe and add a refresh code at the bottom of /cutenews/show_news.php

Refresh code:

You can edit the 120 to whatever you like, but it means it refreshes every 120 seconds (recommended - don't want to use up bandwith when you could be saving it and you're not going to be having articles posted every minute)


<META HTTP-EQUIV='Refresh' CONTENT='120; URL=show_news.php'>

Iframe code:

(Edit width/height)


<iframe src="/cutenews/show_news.php" name="news" width="200" height="120" frameborder="0" scrolling="no" allowtransparency="true"></iframe>

Seads
30-10-2008, 08:08 PM
Hey thanks, but is there a way i can make it just display the title then when they click it, it opens in main content?

D-Man22
30-10-2008, 08:10 PM
Okay, IFRAMES are so OUT-dated.
I have an ajax solution to help you!
edit: you have to find and download prototype.js and you can get effects from http://simplehabbo.net/effects.js
ADD THIS TO <HEAD> section >;]

<script type="text/javascript" language="javascript" src="proto.js"></script>
<script type="text/javascript" language="javascript" src="effects.js"></script>

<script type="text/javascript">




function GetXmlHttpObject( )

{



var xmlHttp = null;



try

{



xmlHttp = new XMLHttpRequest();



}



catch( e )

{



try

{



xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP" );



}



catch( e )

{



xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );



}



}



return xmlHttp;



}



function GetNews()

{



xmlHttp = GetXmlHttpObject();



if( xmlHttp == null )

{



alert ( "Browser does not support HTTP Request" )



return;



}



var url = "path/to/cutenews/show_news.php";



xmlHttp.open( "GET", url, true );



xmlHttp.onreadystatechange = function( )

{



if ( xmlHttp.readyState == 4 )

{



if ( xmlHttp.status == 200 )

{



document.getElementById( "news" ).innerHTML = xmlHttp.responseText;



}



}



};



xmlHttp.send( null );



}



GetStats();



setInterval( "GetStats()", 30000 );
</script>
</head>


Change var url to ur cutenews/show news.php
You'll have to create a div called "news" have it empty where you would like the headlines to be shown :)
Change the 30000 in setInterval( "GetNews()", 30000 ); a period of time in which you want it to change.

Now when you start the page, you wanna get the headlines right on page load so we ddo:

<body onLoad="GetNews();">ur done!

Seads
30-10-2008, 08:27 PM
I don't understand that :P lmao

Seads
31-10-2008, 12:28 AM
Sorry to double post, please merge.

How would I do this with php includes instead of iframes?

Please reply.

Thanks.

Jxhn
31-10-2008, 07:51 AM
Sorry to double post, please merge.

How would I do this with php includes instead of iframes?

Please reply.

Thanks.

Put

<?php include('pathtocutenews/show_news.php'); ?>
where the iframes would be.
I think that's right. I never know which type of quotes to use.
The extension of the page has to be .php, eg index.php not index.html.

Want to hide these adverts? Register an account for free!