When I turn on template logging, I see why the gallery:entries tag doesn’t work, the tag parameters are corrupted somehow (no closing ” in the category parameter):
(0.139350) Calling Class/Method: Categoree/categoree
(0.139381) Nested Plugins in Tag, Parsing Outward First
(0.000040) Tag: {exp:gallery:entries gallery="photos" category="{cat_id}
(0.000254) Closing Tag Found
(0.000347) Module Tag: Gallery/entries</code></pre>
Here is the relevant template code:
<pre><code>{exp:categoree parse="inwards"}
cat is {cat_id}
{exp:gallery:entries gallery="{gallery_name}" category="{cat_id}" orderby="random" columns="1" rows="1"}
{image_url}
{/exp:gallery:entries}
{/exp:categoree}
And here is the plugin code:
function Categoree()
{
global $DB, $IN, $TMPL, $FNS;
$cat_id = $TMPL->fetch_param('cat_id');
if ( $cat_id == '' )
{
if ( ! preg_match("#(^|\/)C(\d+)#", $IN->QSTR, $match))
{
return '';
}
$cat_id = $match['2'];
}
$query = $DB->query("SELECT exp_gallery_categories.cat_id, exp_gallery_categories.cat_name
FROM exp_gallery_categories, exp_galleries
WHERE exp_gallery_categories.gallery_id = exp_galleries.gallery_id AND
exp_gallery_categories.parent_id = '".$DB->escape_str($cat_id)."'");
if ($query->num_rows == 0)
{
return '';
}
$tagdata = '';
foreach ( $query->result as $row )
{
$tagdata .= $FNS->prep_conditionals($TMPL->tagdata, $row);
foreach ($TMPL->var_single as $key => $val)
{
switch ($val)
{
case "cat_name":
$tagdata = $TMPL->swap_var_single($val, $row['cat_name'], $tagdata);
break;
case "cat_id":
$tagdata = $TMPL->swap_var_single($val, $row['cat_id'], $tagdata);
break;
}
}
}
$this->return_data = $tagdata;
}
Can anyone see my error? I am confused as I can get the data just fine if I put {cat_id} or {cat_name} outside the module params.
OK, I must have some fatal flaw in all of my code, as I now have this issue in several functions in my plugin.
The data looks fine if I just put the call in my template. But if I try to embed my plugin inside another call (like gallery:entries) I get the funkyness I pointed out above.
I can’t do any more work until I figure this out, so any help would be much appreciated.
I am happy to give anyone access to the code and site.
Thanks
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.