Hi, I am trying to build a plugin that reads out an XML file specified in the tag and then outputs data. So here is my code so far:
<?php
/*
=====================================================
Copyright (c) 2008 Frecuencies
-----------------------------------------------------
http://frecuencies.com/
=====================================================
File: pi.favorites_ranking.php
-----------------------------------------------------
Purpose: Grabs ranking from XML file
=====================================================
Changelog:
-Version 1.0
First release
*/
$plugin_info = array(
'pi_name' => 'Favorites Ranking',
'pi_version' => '1.0.1',
'pi_author' => 'Maximilian Schöning',
'pi_author_url' => 'http://maximilianschoening.com/',
'pi_description' => 'Grabs ranking from XML file.',
/*'pi_usage' => Favorites_ranking::usage()*/
);
class Favorites_ranking {
var $entry_id = '';
var $xml = '';
var $xml_path = '';
var $return_data = '';
function Favorites_ranking() {
global $TMPL, $LOC, $FNS, $PREFS, $SESS, $REGX, $DB;
$xml_path = $TMPL->fetch_param('xml_path');
$entry_id = $TMPL->fetch_param('entry_id');
if (file_exists($xml_path)) {
$xml = simplexml_load_file($xml_path);
$this->return_data = $xml->id_$entry_id;
}
else {
exit('No rank available.');
}
}
}
?>
And here is my tag:
{exp:favorites_ranking entry_id="23" xml_path="{path=list/ranking}"}
Now which of these variables do I have to load for it to work:
global $TMPL, $LOC, $FNS, $PREFS, $SESS, $REGX, $DB;
I know I need to load the $TMPL and one other in order to parse the {path=list/ranking} but which one is it?
Also I get the following error:
Parse error: syntax error, unexpected T_VARIABLE in //pi.favorites_ranking.php on line 42
The line 42 is:
$this->return_data = $xml->id_$entry_id;
By the way my XML looks like this:
<?xml version="1.0" encoding="{charset}" ?>
<deejays>
{exp:weblog:entries orderby_favorites="yes" status="open" weblog="deejays"}
<id_{entry_id}>{absolute_count}</id_{entry_id}>
{/exp:weblog:entries}
</deejays>
Thanks, Max
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.