We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

EE1.x: Plugin position in template parse order

Development and Programming

Russ Back's avatar
Russ Back
142 posts
15 years ago
Russ Back's avatar Russ Back

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?

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
15 years ago
Sue Crocker's avatar Sue Crocker

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

       
Russ Back's avatar
Russ Back
142 posts
15 years ago
Russ Back's avatar Russ Back

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?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
15 years ago
Lisa Wess's avatar Lisa Wess

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

       
Russ Back's avatar
Russ Back
142 posts
15 years ago
Russ Back's avatar Russ Back

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?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
15 years ago
Lisa Wess's avatar Lisa Wess

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.

       
Russ Back's avatar
Russ Back
142 posts
15 years ago
Russ Back's avatar Russ Back

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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.