Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SimplePie image render 1

Status
Not open for further replies.

ralphonzo

Programmer
Apr 9, 2003
228
GB
As SimplePie's help files are worse than rubbish, I'm turning to you guys to help me out! I'm trying to get the blog post image to render in the rss feed that I'm fetching into my web site. The only help I've found is either two line inadequate or PhD level!! This is what I have, which is great - if I didn't want an image:

Code:
require_once('php/autoloader.php');
$feed = new SimplePie();
$feed->set_feed_url('[URL unfurl="true"]http://festivalgear.wordpress.com/');[/URL]
$feed->init();
$feed->handle_content_type();

and

Code:
<?php
foreach ($feed->get_items() as $item): ?>
    <div class="item">
    <h2><i><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></i></h2>
    <p><span class="oddtext"><?php echo $item->get_description(); ?></span></p>
    <p><span class="noddtext">sdggds</span><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
    <hr />
    </div><?php 
endforeach; ?>

Can anyone offer a "simple(pie)" solution?
 
are the images you want typically the first image in the content?
 
Yes. There's generally just one image from the post. It's a Wordpress blog - Mixfolio theme.
 
never having used simplepie I'd guess something like this

Code:
[b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]getImage[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
 [b][COLOR=#000000]preg_match[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'/\(<img\s.*?\>)/im'[/color][COLOR=#990000],[/color] [COLOR=#009900]$node[/color][COLOR=#990000],[/color] [COLOR=#009900]$match[/color][COLOR=#990000]);[/color]
 [b][COLOR=#0000FF]if[/color][/b] [COLOR=#990000](![/color][b][COLOR=#0000FF]empty[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$match[/color][COLOR=#990000][[/color][COLOR=#993399]1[/color][COLOR=#990000]])[/color] [b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$match[/color][COLOR=#990000][[/color][COLOR=#993399]1[/color][COLOR=#990000]];[/color]
 [b][COLOR=#0000FF]return[/color][/b] false[COLOR=#990000];[/color]
[COLOR=#FF0000]}[/color]

and use it in your foreach loop like this
Code:
[COLOR=#990000]<[/color]p[COLOR=#990000]><[/color]span [b][COLOR=#0000FF]class[/color][/b][COLOR=#990000]=[/color][COLOR=#FF0000]"oddtext"[/color][COLOR=#990000]><?php[/color] [b][COLOR=#0000FF]echo[/color][/b] [b][COLOR=#000000]getImage[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$item[/color][COLOR=#990000]->[/color][b][COLOR=#000000]getContent[/color][/b][COLOR=#990000]([/color] true [COLOR=#990000]));[/color] [COLOR=#990000]?></[/color]span[COLOR=#990000]></[/color]p[COLOR=#990000]>[/color]
 
No joy I'm afraid. What's supposed to be passed via $node? When I upload the page I get nothing rendering, even if I set to E_ALL. I scoured and changed the code, but I'm presuming it's because $node doesn't exist. I tried substituting $node for $feed, but to no avail. I'm a bit stumped not knowing what format the data in $node should take.
 
$node is passed by the call to getImage. the node is the content from $item->getContent( true ).

if the content is not being passed then it is probably not being offered by the feed. have you tried dumping the whole feed to check? echo '<pre> ' . print_r($item, true ). '</pre>';
 
Yikes. I just tried what you suggested and I've pasted the resultant data in the file attached. I'm afraid it's totally meaningless to me. There are images, but cutting them out...? Does it mean anything to you?
 
 http://festgear.co.uk/feed_dump.txt
ok. so plenty of stuff in there. i think there is an error in the regex pattern I used. so try this instead

Code:
preg_match('/(\<img\s.*?\>)/im', $node, $match);
the alternative is to load up a domdoc with the content. parse it manually or use something like phpquery. see whether the above works and if not we can debug some more.

 
No, still no joy. Thanks for your help though. The last things that you advised are far beyond my scope, so I'll try to harass the SimplePie people to make what should be a 'simple' operation simple - or at least logical for a basic PHP scripter!
 
can you give an xml example of the feed you are grabbing? then I can (easily) write something to grab it for you.
if that's beyond you for the moment, then can you point us to the url of the feed?

 
sorry for the delay.
i've written an alternative script to parse this (and other) wordpress rss feeds. It relies on phpquery which is available here.
change the require_once line to refer to the relevant install for your phpquery (the one-file variant is best).
you need to set the time zone. I've set it to utc in this script.
I've changed the syntax a bit. so instead of get_xxxxx, you call get('xxxx'). seems more logical to me.
two things - I parse for all the images associated with the content, but the example just uses the thumbnail. if you want the others then I can show you how to access them (they will be in $item->get('image')).
let me know if this doesn't work for you. i've only halfheartedly tested it.

Code:
[COLOR=#990000]<?php[/color]

[b][COLOR=#0000FF]class[/color][/b] rssItem [COLOR=#FF0000]{[/color]
[tab]
[tab]public [COLOR=#009900]$categories[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]();[/color]
[tab]public [COLOR=#009900]$images[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]();[/color]
[tab]public [COLOR=#009900]$fields[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b] [COLOR=#990000]([/color]
[tab][COLOR=#FF0000]'categories'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'pubDate'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'link'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'title'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'guid'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'description'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'content'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'media:thumbnail'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'media:content'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'dc:creator'[/color][COLOR=#990000]);[/color]
[tab]
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]__construct[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]foreach[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]fields [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$field[/color][COLOR=#990000]):[/color]
[tab][tab][tab][b][COLOR=#0000FF]switch[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$field[/color][COLOR=#990000]):[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'title'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]title [COLOR=#990000]=[/color]  [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'title:first'[/color][COLOR=#990000])->[/color][b][COLOR=#000000]text[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'description'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]description [COLOR=#990000]=[/color]  [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'description'[/color][COLOR=#990000])->[/color][b][COLOR=#000000]text[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'link'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]link [COLOR=#990000]=[/color] [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'link'[/color][COLOR=#990000])->[/color][b][COLOR=#000000]text[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'categories'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]foreach[/color][/b] [COLOR=#990000]([/color][b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'category'[/color][COLOR=#990000])[/color] [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$c[/color][COLOR=#990000]):[/color]
[tab][tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]categories[COLOR=#990000][][/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$c[/color][COLOR=#990000])->[/color][b][COLOR=#000000]text[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'pubDate'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][COLOR=#009900]$d[/color] [COLOR=#990000]=[/color]  [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color] [COLOR=#009900]$node[/color] [COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color] [COLOR=#FF0000]'pubDate'[/color] [COLOR=#990000])->[/color][b][COLOR=#000000]text[/color][/b][COLOR=#990000]()[/color] [COLOR=#990000];[/color]
[tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]pubDate [COLOR=#990000]=[/color] [b][COLOR=#000000]strtotime[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$d[/color][COLOR=#990000])[/color] [COLOR=#990000];[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'content'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]content [COLOR=#990000]=[/color] [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'content|encoded'[/color][COLOR=#990000])->[/color][b][COLOR=#000000]html[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'media:thumbnail'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]thumbnail [COLOR=#990000]=[/color] [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'media|thumbnail'[/color][COLOR=#990000])->[/color][b][COLOR=#000000]attr[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'url'[/color][COLOR=#990000]);[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'media:content'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]foreach[/color][/b] [COLOR=#990000]([/color][b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'media|content'[/color][COLOR=#990000])[/color] [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$image[/color][COLOR=#990000]):[/color]
[tab][tab][tab][tab][tab][tab][COLOR=#009900]$i[/color][COLOR=#990000]=[/color][b][COLOR=#0000FF]new[/color][/b] [b][COLOR=#000000]image[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][tab][tab][tab][COLOR=#009900]$i[/color][COLOR=#990000]->[/color]url [COLOR=#990000]=[/color] [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$image[/color][COLOR=#990000])->[/color][b][COLOR=#000000]attr[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'url'[/color][COLOR=#990000]);[/color]
[tab][tab][tab][tab][tab][tab][COLOR=#009900]$i[/color][COLOR=#990000]->[/color]title [COLOR=#990000]=[/color] [b][COLOR=#000000]trim[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$image[/color][COLOR=#990000])->[/color][b][COLOR=#000000]text[/color][/b][COLOR=#990000]());[/color]
[tab][tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]images[COLOR=#990000][][/color] [COLOR=#990000]=[/color] [COLOR=#009900]$i[/color][COLOR=#990000];[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'dc:creator'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]author [COLOR=#990000]=[/color] [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'dc|creator'[/color][COLOR=#990000])->[/color][b][COLOR=#000000]text[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]endswitch[/color][/b][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[tab][COLOR=#FF0000]}[/color]
[tab]
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color] [COLOR=#009900]$node[/color] [COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]switch[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000]):[/color]
[tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'thumbnail'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]return[/color][/b] [COLOR=#FF0000]'<img src="'[/color] [COLOR=#990000].[/color] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]thumbnail [COLOR=#990000].[/color] [COLOR=#FF0000]'" />'[/color][COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'image'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]images[COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'categories'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]return[/color][/b] [b][COLOR=#000000]implode[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]' | '[/color][COLOR=#990000],[/color] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]categories[COLOR=#990000]);[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'pubDate'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]pubDate[COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]case[/color][/b] [COLOR=#FF0000]'author'[/color][COLOR=#990000]:[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]author[COLOR=#990000];[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]break[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]default[/color][/b][COLOR=#990000]:[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]in_array[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000],[/color] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]fields[COLOR=#990000]))[/color] [b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color][COLOR=#009900]$node[/color][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]endswitch[/color][/b][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]return[/color][/b] false[COLOR=#990000];[/color]
[tab][COLOR=#FF0000]}[/color]
[COLOR=#FF0000]}[/color]

[b][COLOR=#0000FF]class[/color][/b] image  [COLOR=#FF0000]{[/color]
[tab]public [COLOR=#009900]$fields[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'url'[/color][COLOR=#990000],[/color] [COLOR=#FF0000]'title'[/color][COLOR=#990000],[/color] [COLOR=#FF0000]'link'[/color][COLOR=#990000]);[/color]
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]__construct[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color] [COLOR=#990000]=[/color] null[COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000](![/color][b][COLOR=#000000]is_null[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])):[/color]
[tab][tab][tab][b][COLOR=#0000FF]foreach[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]fields [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$field[/color][COLOR=#990000]):[/color]
[tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color][COLOR=#009900]$field[/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])->[/color][b][COLOR=#000000]find[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$field[/color][COLOR=#990000])->[/color][b][COLOR=#000000]text[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]endif[/color][/b][COLOR=#990000];[/color]
[tab][COLOR=#FF0000]}[/color]
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color] [COLOR=#009900]$node[/color][COLOR=#990000]=[/color]NULL [COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]in_array[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000],[/color] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]fields[COLOR=#990000]))[/color] [b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color][COLOR=#009900]$node[/color][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]return[/color][/b] false[COLOR=#990000];[/color]
[tab][COLOR=#FF0000]}[/color]
[COLOR=#FF0000]}[/color]
[b][COLOR=#0000FF]class[/color][/b] jIterator implements Iterator[COLOR=#FF0000]{[/color]
[tab]private [COLOR=#009900]$var[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]();[/color]

[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]__construct[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$array[/color][COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]if[/color][/b] [COLOR=#990000]([/color][b][COLOR=#000000]is_array[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$array[/color][COLOR=#990000]))[/color] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color][b][COLOR=#0000FF]var[/color][/b] [COLOR=#990000]=[/color] [COLOR=#009900]$array[/color][COLOR=#990000];[/color]
[tab][COLOR=#FF0000]}[/color]

[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]rewind[/color][/b][COLOR=#990000]()[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#000000]reset[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color][b][COLOR=#0000FF]var[/color][/b][COLOR=#990000]);[/color]
[tab][COLOR=#FF0000]}[/color]
  
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]current[/color][/b][COLOR=#990000]()[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]return[/color][/b] [b][COLOR=#000000]current[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color][b][COLOR=#0000FF]var[/color][/b][COLOR=#990000]);[/color]
[tab][COLOR=#FF0000]}[/color]
  
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]key[/color][/b][COLOR=#990000]()[/color] [COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]return[/color][/b] [b][COLOR=#000000]key[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color][b][COLOR=#0000FF]var[/color][/b][COLOR=#990000]);[/color]
[tab][COLOR=#FF0000]}[/color]
  
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]next[/color][/b][COLOR=#990000]()[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]return[/color][/b] [b][COLOR=#000000]next[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color][b][COLOR=#0000FF]var[/color][/b][COLOR=#990000]);[/color]
[tab][COLOR=#FF0000]}[/color]
  
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]valid[/color][/b][COLOR=#990000]()[/color][COLOR=#FF0000]{[/color]
[tab][tab][COLOR=#009900]$key[/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]key[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color][b][COLOR=#0000FF]var[/color][/b][COLOR=#990000]);[/color]
[tab][tab][b][COLOR=#0000FF]return[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$key[/color] [COLOR=#990000]!==[/color] NULL [COLOR=#990000]&&[/color] [COLOR=#009900]$key[/color] [COLOR=#990000]!==[/color] FALSE[COLOR=#990000]);[/color]
[tab][COLOR=#FF0000]}[/color]

[COLOR=#FF0000]}[/color]
[b][COLOR=#0000FF]class[/color][/b] rssFeed implements IteratorAggregate [COLOR=#FF0000]{[/color]
[tab]
[tab]public [COLOR=#009900]$items[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]();[/color]
[tab]public [COLOR=#009900]$fields[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color]
[tab][COLOR=#FF0000]'title'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'link'[/color][COLOR=#990000],[/color]
[tab][COLOR=#FF0000]'description'[/color][COLOR=#990000]);[/color]
[tab]
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]getIterator[/color][/b][COLOR=#990000]()[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]return[/color][/b] [b][COLOR=#0000FF]new[/color][/b] [b][COLOR=#000000]jIterator[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]items[COLOR=#990000]);[/color]
[tab][COLOR=#FF0000]}[/color]
[tab][tab]
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]__construct[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$url[/color][COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
[tab][tab]phpQuery[COLOR=#990000]::[/color][b][COLOR=#000000]newDocumentFileXML[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$url[/color][COLOR=#990000]);[/color]
[tab][tab][b][COLOR=#0000FF]foreach[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]fields [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$field[/color][COLOR=#990000]):[/color]
[tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color][COLOR=#009900]$field[/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color] [COLOR=#FF0000]"channel > $field"[/color][COLOR=#990000])->[/color][b][COLOR=#000000]html[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][b][COLOR=#0000FF]foreach[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'channel > image'[/color][COLOR=#990000])[/color] [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$image[/color][COLOR=#990000]):[/color]
[tab][tab][tab][tab][COLOR=#009900]$i[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]new[/color][/b] [b][COLOR=#000000]image[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$image[/color][COLOR=#990000]);[/color]
[tab][tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]images[COLOR=#990000][][/color] [COLOR=#990000]=[/color] [COLOR=#009900]$i[/color][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[tab][tab]
[tab][tab][b][COLOR=#0000FF]foreach[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]pq[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'channel > item'[/color][COLOR=#990000])[/color] [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$item[/color][COLOR=#990000]):[/color]
[tab][tab][tab][COLOR=#009900]$i[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]new[/color][/b] [b][COLOR=#000000]rssItem[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$item[/color][COLOR=#990000]);[/color]
[tab][tab][tab][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]items[COLOR=#990000][][/color] [COLOR=#990000]=[/color] [COLOR=#009900]$i[/color][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[tab][COLOR=#FF0000]}[/color]
[tab]
[tab]public [b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color] [COLOR=#009900]$node[/color] [COLOR=#990000]=[/color] NULL[COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
[tab][tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]is_null[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000])):[/color]
[tab][tab][tab][b][COLOR=#0000FF]foreach[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$this[/color][COLOR=#990000]->[/color]fields [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$f[/color][COLOR=#990000]):[/color]
[tab][tab][tab][tab][COLOR=#009900]$return[/color][COLOR=#990000][[/color][COLOR=#009900]$f[/color][COLOR=#990000]][/color] [COLOR=#990000]=[/color] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color][COLOR=#009900]$f[/color][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$return[/color][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]endif[/color][/b][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]in_array[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color][COLOR=#990000],[/color] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]fields[COLOR=#990000])):[/color]
[tab][tab][tab][b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color][COLOR=#009900]$node[/color][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]endif[/color][/b][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$node[/color] [COLOR=#990000]==[/color] [COLOR=#FF0000]'image'[/color][COLOR=#990000]):[/color]
[tab][tab][tab][b][COLOR=#0000FF]return[/color][/b] [COLOR=#009900]$this[/color][COLOR=#990000]->[/color]images[COLOR=#990000][[/color][COLOR=#993399]0[/color][COLOR=#990000]];[/color]
[tab][tab][b][COLOR=#0000FF]endif[/color][/b][COLOR=#990000];[/color]
[tab][tab][b][COLOR=#0000FF]return[/color][/b] false[COLOR=#990000];[/color]
[tab][COLOR=#FF0000]}[/color]
[COLOR=#FF0000]}[/color]

[b][COLOR=#000080]require_once[/color][/b] [COLOR=#FF0000]'/Users/jpadie/Sites/mfptwister/phpQuery-onefile.php'[/color][COLOR=#990000];[/color]
[b][COLOR=#000000]date_default_timezone_set[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'utc'[/color][COLOR=#990000]);[/color]
[COLOR=#009900]$feed[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]new[/color][/b] [b][COLOR=#000000]rssFeed[/color][/b][COLOR=#990000]([/color] [COLOR=#FF0000]'[URL unfurl="true"]http://festivalgear.wordpress.com/?feed=rss'[/URL][/color][COLOR=#990000]);[/color]
[COLOR=#990000]?>[/color]
[COLOR=#990000]<[/color]div[COLOR=#990000]>[/color]
[tab][COLOR=#990000]<[/color]div[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]<[/color]div[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]span[COLOR=#990000]>[/color]Feed title[COLOR=#990000]:</[/color]span[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]span[COLOR=#990000]><[/color]a href[COLOR=#990000]=[/color][COLOR=#FF0000]"<?=$feed->get('link');?>"[/color][COLOR=#990000]><?=[/color][COLOR=#009900]$feed[/color][COLOR=#990000]->[/color][b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'title'[/color][COLOR=#990000]);?></[/color]a[COLOR=#990000]></[/color]span[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]</[/color]div[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]<[/color]div[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]span[COLOR=#990000]>[/color]Feed Image[COLOR=#990000]:</[/color]span[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]span[COLOR=#990000]><[/color]img src[COLOR=#990000]=[/color][COLOR=#FF0000]"<?=$feed->get('image')->get('url');?>"[/color] [COLOR=#990000]/></[/color]span[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]<[/color]div[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]span[COLOR=#990000]>[/color]Feed Description[COLOR=#990000]:</[/color]span[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]span[COLOR=#990000]><?=[/color][COLOR=#009900]$feed[/color][COLOR=#990000]->[/color][b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'description'[/color][COLOR=#990000]);?></[/color]span[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]</[/color]div[COLOR=#990000]>[/color]
[tab][COLOR=#990000]</[/color]div[COLOR=#990000]>[/color]
[tab]
[tab][COLOR=#990000]<?php[/color] [b][COLOR=#0000FF]foreach[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$feed[/color] [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$item[/color][COLOR=#990000]):[/color] [COLOR=#990000]?>[/color]
[tab][COLOR=#990000]<[/color]div [b][COLOR=#0000FF]class[/color][/b][COLOR=#990000]=[/color][COLOR=#FF0000]"item"[/color] style[COLOR=#990000]=[/color][COLOR=#FF0000]"border-bottom: solid thin black;"[/color][COLOR=#990000]>[/color]
[tab][tab] [COLOR=#990000]<[/color]h2[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]i[COLOR=#990000]><[/color]a href[COLOR=#990000]=[/color][COLOR=#FF0000]"<?=$item->get('link');?>"[/color][COLOR=#990000]><?=([/color] [COLOR=#009900]$item[/color][COLOR=#990000]->[/color][b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'title'[/color][COLOR=#990000])[/color] [COLOR=#990000]);[/color] [COLOR=#990000]?></[/color]a[COLOR=#990000]></[/color]i[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]</[/color]h2[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]<[/color]p[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]span [b][COLOR=#0000FF]class[/color][/b][COLOR=#990000]=[/color][COLOR=#FF0000]"oddtext"[/color][COLOR=#990000]>[/color]
[tab][tab][tab][tab][COLOR=#990000]<?=[/color][COLOR=#009900]$item[/color][COLOR=#990000]->[/color][b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'thumbnail'[/color][COLOR=#990000]);?><?=[/color][COLOR=#009900]$item[/color][COLOR=#990000]->[/color][b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]"description"[/color][COLOR=#990000]);[/color] [COLOR=#990000]?>[/color]
[tab][tab][tab][COLOR=#990000]</[/color]span[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]</[/color]p[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]<[/color]p[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]span [b][COLOR=#0000FF]class[/color][/b][COLOR=#990000]=[/color][COLOR=#FF0000]"noddtext"[/color][COLOR=#990000]>[/color]Posted by [COLOR=#990000]<?=[/color][COLOR=#009900]$item[/color][COLOR=#990000]->[/color][b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'author'[/color][COLOR=#990000]);?></[/color]span[COLOR=#990000]>[/color]
[tab][tab][tab][COLOR=#990000]<[/color]small[COLOR=#990000]>&[/color]nbsp[COLOR=#990000];[/color]on [COLOR=#990000]<?=[/color][b][COLOR=#000000]date[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'j F Y | g:i a'[/color][COLOR=#990000],[/color] [COLOR=#009900]$item[/color][COLOR=#990000]->[/color][b][COLOR=#000000]get[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'pubDate'[/color][COLOR=#990000]));[/color] [COLOR=#990000]?></[/color]small[COLOR=#990000]>[/color]
[tab][tab][COLOR=#990000]</[/color]p[COLOR=#990000]>[/color]
[tab][COLOR=#990000]</[/color]div[COLOR=#990000]>[/color]
[tab][COLOR=#990000]<?php[/color] [b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];?>[/color]
[tab]
[COLOR=#990000]</[/color]div[COLOR=#990000]>[/color]
 
Thanks. This is going to take some time. I'll get back to you as soon as I can implement it.
 
Er...no different I'm afraid. I downloaded the phpQuery-onefile.php file and set the correct path in the require once command. It's highly likely that it's pilot error and I'm doing something wrong, as none of the formatting comes through either.
 
if you just put the code on a webpage on its own, not changing anything at all other than the url for phpquery-onefile.php, and then run the code (visit the page) what happens?

my version (with only the addition of an html5 doctype and utf8 charset meta) is here:
is that not what you were after?
 
Yay! There must be something else on the other page that clashes. I'll track it down from here. Thanks a lot - you're a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top