EllisLab text mark
Advanced Search
     
EE1.x: Plugin position in template parse order
Posted: 23 June 2010 06:32 AM   [ Ignore ]
Avatar
Joined: 2009-01-21
206 posts

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?

 
Posted: 23 June 2010 09:44 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2002-04-29
26055 posts

russback, we don’t provide direct support for writing plugins. Moving to the Plugins folder for additional community support.

 
Posted: 23 June 2010 10:00 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-21
206 posts

Hi Sue

This isn’t a plugin support request as such - I’m just trying to understand the parse order of the EE templates as I would have expected the plugin to be parsed befpre the gallery tag?

 
Posted: 23 June 2010 12:56 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-14
20504 posts

Hi, russback - did you see the comments on parse order in the plugin docs?  you can change it using the parse= parameter.

 
Posted: 23 June 2010 02:10 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-21
206 posts

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?

 
Posted: 23 June 2010 03:57 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-14
20504 posts

Right, it doesn’t matter if it’s two plugins or the gallery tag.  Try adding that tag to either your plugin or the galleries tag to change the parse order.

 
Posted: 24 June 2010 05:14 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-21
206 posts

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.