Apologies if this question has been answered before but I searched and didn’t find anything pertaining to the issue.
I am currently having an issue where I am using 2 simple, custom-built plugins within a template. The first plugin is called twice, once at the beginning of the template and again later on. The second plugin is called shortly after the first. When the second call to the first plugin rolls around, rather than getting the expected output, I instead receive the output from the second plugin. If there is a better way to do what I am trying to do, please advise.
The first plugin simply decodes url-encoded segment vars:
$plugin_info = array(
'pi_name' => 'Url Decode',
'pi_version' => '0.1',
'pi_author' => 'David Torres',
'pi_author_url' => 'http://www.example.com/',
'pi_description' => 'Decodes Urls, mostly for segment variables',
'pi_usage' => Url_Decode::usage()
);
class Url_Decode
{
var $return_data;
function Url_Decode()
{
global $TMPL;
$value = $TMPL->fetch_param('value'); // the value to decode
$this->return_data = urldecode($value);
}
function usage()
{
return "To decode urls use: {exp:url_decode value=\"{segment_3}\"}. For all other inquiries, read the source.";
}
}The second plugin is a work in progress that I am using to address some of the limitations of the categories module:
$plugin_info = array(
'pi_name' => 'Dynamic Categories',
'pi_version' => '0.1',
'pi_author' => 'David Torres',
'pi_author_url' => 'http://www.example.com/',
'pi_description' => 'Addresses limitations of the categories module',
'pi_usage' => Dynamic_Categories::usage()
);
class Dynamic_Categories
{
function Dynamic_Categories()
{
}
function getList()
{
global $DB;
global $TMPL;
$entry_id = $TMPL->fetch_param('entry_id'); // for this entry id
$show = $TMPL->fetch_param('show_cat'); // show or don't show from given categories
$showSql = "";
if(!empty($show)){
if(strpos($show, '|')) {
$pieces = explode($show, '|');
}
else {
$pieces = array($show);
}
if(!empty($pieces)){
foreach($pieces as $piece){
if(strpos($piece, 'NOT') === false) {
$showSql = " AND ec.cat_id = $piece";
}
else {
$piece = str_replace('NOT ', '', $piece);
$showSql = " AND NOT ecp.cat_id = $piece";
}
}
}
}
$sql = "SELECT cat_url_title, cat_name FROM exp_category_posts ecp
JOIN exp_categories ec ON ec.cat_id = ecp.cat_id
WHERE ecp.entry_id = $entry_id $showSql";
$query = $DB->query($sql);
$dynamic_categories_getlist_arr = array();
foreach($query->result as $row) {
$dynamic_categories_getlist_arr[] = "<a href="/bar/%22>{$row[%27cat_name%27]}</a>%22">Bar</a>The second call to url_decode: {exp:url_decode value="{segment_3}”} Expected output: foo Actual output:
<a href="/bar/">Bar</a>I attempted to assign the value returned by url_decode to a variable using: {assign_variable:varname=”{exp:url_decode value="{segment_3}”}”}
but EE just chokes on the nested tags.
The entire point of approaching the problem this way was to avoid using:
<?php
$varname = urldecode('{segment_3}');
?>
<?php echo $varname; ?>Can anyone explain why my plugins are conflicting? Workarounds? Better ways to solve this problem?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.