• A reminder that Forum Moderator applications are currently still open! If you're interested in joining an active team of moderators for one of the biggest Pokémon forums on the internet, click here for info.
  • Due to the recent changes with Twitter's API, it is no longer possible for Bulbagarden forum users to login via their Twitter account. If you signed up to Bulbagarden via Twitter and do not have another way to login, please contact us here with your Twitter username so that we can get you sorted.

Tutorial: Fix your CuteNews comments! [doesn't work]

Status
Not open for further replies.

Koroku

Ninja Master!
Joined
Apr 27, 2005
Messages
1,137
Reaction score
4
Beginning Note: I am pretty sure this'll work, but I haven't tested it myself. Instead of doing this, I really suggest you change your $id to $page or something, if you can. This is a messy and most likely badly coded fix. Hell, it might not even work. :/ But if it does.................................

Title: Fix your CuteNews comments!
Author: JKaizer

Okay, you're the l33t webmaster. You're SO l33t that you use PHP! :O! And you even use CuteNews to make your life a billion times simpler! But... alas, there is a problem. You have this code:
Code:
<?php
if (!$id) {
$id = "news";
$include = $id . ".txt";
}
else {
$include = $id . ".txt";
}
if (is_file($include) == "1") {
        include $include;
}
else {
include "404.txt";
}
?>
and it doesnt't work with CuteNews. The comments give you a 404. o_O;

Here's the reason:
CuteNews uses $id and the code in there uses $id. The two $id's conflict, and give you a 404.

And Greg has found the answer! But it has an interesting little flaw, which has been put into account here.

okay, your website is l33t, and here is the code for it right now:
Code:
[b]index.php[/b]
<html><title>My l33t non-XHTML comlpiant site</title><table><tr><td colspan="2"><img src="banner.gif"></td></tr><tr>
<td width="33%">
This is where hte navigation and affiliates hang out.
</td>
<td width="66%"><?php
if (!$id) {
$id = "news";
$include = $id . ".txt";
}
else {
$include = $id . ".txt";
}
if (is_file($include) == "1") {
        include $include;
}
else {
include "404.txt";
}
?></td></tr>
<tr><td colspan="2">I own j00, but I don't own "l33t" Don't sue</td></tr></table></html>
Code:
[b]news.txt[/b]
<? $number = "20"; include("news/show_news.php"); ?>

There are just a few changes that you're gonna have to make to get your news working again. First, rename news.txt to news.php. And then open up index.php. Take out this part:
Code:
<html><title>My l33t non-XHTML comlpiant site</title><table><tr><td colspan="2"><img src="banner.gif"></td></tr><tr>
<td width="33%">
This is where hte navigation and affiliates hang out.
</td>
<td width="66%">
And put it into a file named layout1.txt. Then go make layout2.txt with:
Code:
</td></tr>
<tr><td colspan="2">I own j00, but I don't own "l33t" Don't sue</td></tr></table></html>
All that's left in index.php is now:
Code:
<?php
if (!$id) {
$id = "news";
$include = $id . ".txt";
}
else {
$include = $id . ".txt";
}
if (is_file($include) == "1") {
        include $include;
}
else {
include "404.txt";
}
?>
Make a few quick changes, by including the layout at the beginning and at the end.
Code:
<? include("layout1.txt"); ?><?php
if (!$id) {
$id = "news";
$include = $id . ".txt";
}
else {
$include = $id . ".txt";
}
if (is_file($include) == "1") {
        include $include;
}
else {
include "404.txt";
}
?><? include("layout2.txt"); ?>
Now we'll take a look at the flaw: there is no way to have index.php default to the news anymore! So we'll do this: create a file called news.txt:
Code:
Redirecting you to the news
And then create another new file called redirectcode.txt:
Code:
<meta http-equiv="refresh" content="0; url=news.php">
Simple enough, ne? Now just create a blank file called blank.txt. And now we're gonna open layout1.txt add this to the <head>:
Code:
<? if {
$id = "news";
include("redirectcode.txt");
} 
else { include("blank.txt"); ?>

Because our layout1.txt was simple and I wasn't thinking, we have to add the head code.
Code:
<html><head><title>My l33t non-XHTML comlpiant site</title>
<? if {
$id = "news";
include("redirectcode.txt");
} 
else { include("blank.txt"); ?>
</head><table><tr><td colspan="2"><img src="banner.gif"></td></tr><tr>
<td width="33%">
This is where hte navigation and affiliates hang out.
</td>
<td width="66%">
Still with me? Okay, we're almost done.

Now we open up news.php and include the layout:
Code:
<? include("layout1.txt"); $number = "20"; include("news/show_news.php"); include("layout2.txt"); ?>

And now we're done. ^_^ Open up layout1.txt and change your link from "?id=news" to "news.php" and it should work fine. ^_^;;


At the end, these are the files you should have:
Code:
[b]layout1.txt[/b]<html><head><title>My l33t non-XHTML comlpiant site</title>
<? if {
$id = "news";
include("redirectcode.txt");
} 
else { include("blank.txt"); } ?>
</head><table><tr><td colspan="2"><img src="banner.gif"></td></tr><tr>
<td width="33%">
This is where hte navigation and affiliates hang out.
</td>
<td width="66%">
layout2.txt
Code:
</td></tr>
<tr><td colspan="2">I own j00, but I don't own "l33t" Don't sue</td></tr></table></html>
news.txt
Code:
Redirecting you to the news
blank.txt
Code:
{blank - nothing here}
redirectcode.txt
Code:
<meta http-equiv="refresh" content="0; url=news.php">
news.php
Code:
<? include("layout1.txt"); $number = "20"; include("news/show_news.php"); include("layout2.txt"); ?>
index.php
Code:
<? include("layout1.txt"); ?><?php
if (!$id) {
$id = "news";
$include = $id . ".txt";
}
else {
$include = $id . ".txt";
}
if (is_file($include) == "1") {
        include $include;
}
else {
include "404.txt";
}
?><? include("layout2.txt"); ?>


Hope you enjoy this messy fix. ^_^
 
Last edited:
Wow! 0-0;; No wonder I was confused XD

But thanks JK! I think I'll take your advice and revamp my site tomorrow >>;

=D Can't wait to actually have WORKING comments!
 
I hadn't thought of the no-news-at-first problem, and had to ponder quite some time to figure out a fix. :/
 
So when it redirects, will the layout still be there, or just news?
 
You include the layout on the news page, so it'll still be there.
 
Ok ^-^

This'll be tomorrow's project me thinks. It was really nice of you to write this up =3

This is a bit more complex than KipKip's code ^0^
 
It's building onto Kip-kip's code... XD
 
This does NOT work and I can't figure out why! I follow the Parse errors:

{ instead of ( [changed]
unexpected ; [changed]
wrong include thingying! [Can't figure out~]
 
I see one error. layout1.txt
Code:
else { include("blank.txt"); ?>
Should be
Code:
else { include("blank.txt"); } ?>
 
Ok ^.^;;

*trying...trying...trying...trying...trying...*

Didn't work -.-;; I can help out by providing the correct code for layout1:

Code:
<?
if ($id == 'news'){
    include("redirectcode.txt");
} else {
    include("blank.txt");
} 
?>

All I'm getting is Redirecting you to the news... without any redirect...but the script should work!
 
Last edited:
redirectcode.txt
Code:
<meta http-equiv="refresh" content="0; url=news.php">

You sure you have that?
 
wow that is complicated. doesn't PHP have any way to do.. scoping?
 
Not that I know of, I'm pretty much a n00b at PHP. I can do:

1) simple "if" statements
2) include
3) echo/print

And that's about it >.o
 
XD I always regarded you as a PHP Genius. Now I know that we can both do abou the same =P

shouldn't have told me >>;

And yes, that's what I have for the redirect code V.V;;
 
the problem now i think is that there is nothing that calls a "blank" page

why not just make a link right now... and we can get a superior coder to help us out...
 
A link....?


XD I'll try and find Richie. or maybe Shawn. Or maybe...*<infinity sign>*

Is JA good at this stuff? Or maybe Morkula could come...?
 
None of us are good at PHP :(

Richie knows basically no coding, Shawn can't be trusted on anything, and Robo is just as bad as us. :p

JA is the only one that *might* have a clue out of the people you listed.


Try asking Kip-kip. :3
 
Good idea XD Gary to the rescue!

I guess I'll make a thread at PC about this~
 
Whoa...Way 2 messy

Very nice Greg, this is way too messy. The easiest way to git rid of this cutenews problem is use ?page=file instead of ?id=. It's simpler to comprehend then what Greg said.

~ CC
 
Yes, it is easier... but alas, for some people that'd be hours of work.
 
Status
Not open for further replies.
Back
Top Bottom