This works:
{exp:image_properties src="<?php echo "$img_url" ?>" }
height is {height} and width is {width}
{if height > width }
foo
{exp:imgsizer:size src="<?php echo $img_url ?>" height="{img_size}" alt="{title}" id="placeholder"}
{if:else}
bar
{exp:imgsizer:size src="<?php echo $img_url ?>" width="{img_size}" alt="{title}" id="placeholder"}
{/if}
{/exp:image_properties}
and this doesn’t:
{exp:image_properties src="<?php echo "$img_url" ?>" }
{if height > width }
foo
{exp:imgsizer:size src="<?php echo $img_url ?>" height="{img_size}" alt="{title}" id="placeholder"}
{if:else}
bar
{exp:imgsizer:size src="<?php echo $img_url ?>" width="{img_size}" alt="{title}" id="placeholder"}
{/if}
{/exp:image_properties}
Why would that be?
Does it?
While I did find this problem with a plugin (or two), I seems to be an EE parsing issue or something, does it not?
The way I see it, EE can’t do the {if} statement until it parses the {height} and {weight}. Does that sound right? Perhaps I am misunderstanding things, which is very possible.
Shall I see if I can duplicate this with EE plugins?
Thanks
Erin, I’m going to move this out of the general EE tech support queue. This question has to do with third party code.
Could I get some help on why this is happening? I have created a plugin that has only one tag (num_entries) and I would like to use it in a conditional. But it seems I can’t do it unless I first put the tag on the page ({num_entries}).
Is this a parse order problem or something?
I would like to do this:
{exp:categoree parse="inward"}
{if num_entries > 0 }
Do STUFF
{/if}
But it doesn’t work unless I do this:
{exp:categoree parse="inward"}
{num_entries}
{if num_entries > 0 }
Do STUFF
{/if}
Are you sending your variable and tagdata through the conditional prep routine in the Functions class? Conditional Variables (Template Class docs) Functions Class
Nope, I didn’t know I had to as I hadn’t seen any examples of that in any code.
The example you linked to references boolean values. Mine is not, is that relevant?
So you are saying I need to create an array of my out values then pass it to the prep_conditionals function? Do I do that before or after my swap_var_single?
Regarding the correct order for conditionals and variable parsing (from my link above):
If you are scripting conditional variables in your module, then they should be done first when processing tag data before any other variables are parsed.
No, that they are boolean or not isn’t material. Check out mod.weblog.php, mod.comment.php, mod.simple_commerce.php etc. for real world usage examples.
OK, I now have this in my plugin:
$result = $query->row;
$num_entries = $query->row['total_files'];
$tagdata = $FNS->prep_conditionals($TMPL->tagdata, $result);
foreach ($TMPL->var_single as $key => $val)
{
switch ($val)
{
case "num_entries":
$tagdata = $TMPL->swap_var_single($val, $num_entries, $tagdata);
$this->return_data = $tagdata;
break;
}
}
And it still isn’t working when I do this:
{exp:categoree parse="inward"}
{if num_entries > 0 }
{exp:gallery:entries gallery="{gallery_name}" orderby="date" sort="desc" columns="10" rows="1"}
{entries}
{row_start} {/row_start}
{row}
<div class="thumbnail">
{if width > height}
<div class="landscape">
<a href="#" onclick="return getLandscapeImage('placeholder','{image_url}');">{exp:imgsizer:size src="{image_url}" width="{thumb_size}" alt="{title}" }</a>
</div>
{if:else}
<div class="portrait">
<a href="#" onclick="return getPortraitImage('placeholder','{image_url}');">{exp:imgsizer:size src="{image_url}" height="{thumb_size}" alt="{title}" }</a>
</div>
{/if}
</div> <!-- thumbnail -->
{/row}
{row_blank} {/row_blank}
{row_end} {/row_end}
{/entries}
{paginate}
<div class="paginate">
{pagination_links}
</div> <!-- paginate -->
{/paginate}
{/exp:gallery:entries}
{/exp:categoree}
You are only setting $this->return_data to the modified $tagdata if the plugin has a variable that it can parse. Since there’s no variable for it to parse, $this->return_data is never modified.
OK, you lost me. I thought I was getting it to parse ‘num_entries’ because it is inside the conditional? I must be not getting something simple here.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.