Hi
I have a very simple plugin that takes a related gallery entry ID and returns the gallery category of the image:
function Gallerycategory()
{
global $TMPL, $DB;
$query = $DB->query("SELECT rel_data FROM exp_relationships WHERE rel_id = '" . $TMPL->fetch_param('relationship_id') . "'");
$row['rel_data'] = $query->row['rel_data'];
if ($reldata = @unserialize($row['rel_data']))
{
$this->return_data = $reldata['query']->result[0]['cat_id'];
}
}This works fine in a template as follows (I’m passing in the category ID from a parent template):
cat id = {exp:gallerycategory relationship_id='{embed:gallery_category}'}Results in:
cat id = 5
But when I try to use this in a gallery:entries tag, I get no results:
{exp:gallery:entries gallery="{embed:gallery}" category="{exp:gallerycategory relationship_id='{embed:gallery_category}'}" orderby="date" sort="asc" columns="1" rows="100" log_views="off" dynamic="off"}Hardcoding the category parameter works fine, so I know there are images in the category.
Do plugins not return their data before the gallery entries are searched?
Hi, russback - did you see the comments on parse order in the plugin docs? you can change it using the parse= parameter.
Hi.
Yes I did but this appears to make no difference as it’s not 2 embedded plugins that are causing the problem - it’s the fact that the galleries tag appears to be parsed before the plugin. This is a problem because the plugin outputs the category parameter for the gallery tag.
Does that make sense?
OK, thanks - that’s fixed it eventually.
However what confused matters was that for some reason the rel_data column in the exp_relationships table had become blank. Do you know of any situations that would empty this value? Resaving the weblog entry created a new entry in the table but I’m at a loss as to why the data in that column would have been removed.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.