Forum Moderators: coopster

Message Too Old, No Replies

Php require conflict

Simplepie wordpess adding rss feeds

         

cheaperholidays

7:46 pm on Feb 11, 2008 (gmt 0)

10+ Year Member



Hello Everyone

I wonder if you can help we use simplepie to add rss feeds via include files to our wordpress blog posts.

This all works very well on single posts, until you have a category where you may have 3 posts all with php include files.

So you you may have say a Category canaries deals, with a post called canaries with a php include file and say a thomson holidays post also with an include file, both different include files but both calling this

<?php
require 'deals/simplepie.inc'; so you get the fatal error "cannot redeclare class"

I was thinking perhaps a php "if" command but cannot figure it out for the life of me.

I have been toying with this but cannot figuire it out,
// Include the required SimplePie library.

if(!class_exists("SimplePie"))
{
require_once $simplepiefile;
}

Many thanks for reading

Peter

cameraman

8:49 pm on Feb 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Change the requires to require_once [php.net]

cheaperholidays

8:10 am on Feb 12, 2008 (gmt 0)

10+ Year Member



Thank you for taking the time to answer will change on all feeds and report back

cheaperholidays

8:39 am on Feb 12, 2008 (gmt 0)

10+ Year Member



Hi Cameraman

It partly worked as before you would get the error and the sidebars would disappear.

Now the posts and sidebar are displayed, but you still get the warning cannot redeclare

Habtom

8:48 am on Feb 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



but you still get the warning cannot redeclare

You are probably trying to include (require) a certain class twice. That was the reason cameraman suggested you use the require_once instead of require.

Try replacing all the require to require_once and see it makes a difference.

cheaperholidays

9:05 am on Feb 12, 2008 (gmt 0)

10+ Year Member



Hi Habtom

Yes changed all the require to require once as in previous post but error is still there, on single post its not a problem its category post that cause the problem where you have 3 or 4 post all calling for simplepie.

As before you lost the sidebars now you get the sidebars back but if you have say 3 posts only one will now show the error if that make sense.

Habtom

9:08 am on Feb 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post the relevant code.

cheaperholidays

9:36 am on Feb 12, 2008 (gmt 0)

10+ Year Member



Thanks everyone i think i have fixed it will post solution asap