EE 2.2 I’ve been scratching my head over this, thinking about parse order, and whether it’s possible to pass a parameter to a plugin within a conditional. It doesn’t seem to be working, and I could have sworn I’ve done this before.
This does not work, and this statement continues to the “else” conditional even though the plugin returns a value of 1.
{exp:channel:entries channel="article" status="open" limit="1" disable="categories|member_data|pagination"}
{if "{exp:duct_tape:current_issue entry_id='{entry_id}'}" == "1"}
You must be a subscriber to access current issue.
{if:else}
Serve the content
{/if}
{/exp:channel:entries}This however seems to work if I call the plugin before the conditional as well as place it within the conditional statement.
{exp:channel:entries channel="article" status="open" limit="1" disable="categories|member_data|pagination"}
{!-- this does return a value of 1 for that entry --}
{exp:duct_tape:current_issue entry_id='{entry_id}'}
{if "{exp:duct_tape:current_issue entry_id='{entry_id}'}" == "1"}
You must be a subscriber to access current issue.
{if:else}
Serve the content
{/if}
{/exp:channel:entries}I’ve tried PHP parsing on input and output with no luck. In another template I’ve resorted to using an embed variable. I’m trying to avoid another embed in this template.
Function current_issue code
/* CHECK IF ARTICLE BELONGS TO THE LATEST CURRENT ISSUE */
function current_issue()
{
// parameters
$entry_id = ctype_digit($entry_id = $this->EE->TMPL->fetch_param('entry_id')) ? $entry_id : FALSE;
if ($entry_id == "") return;
// find the entry_id of the current issue with status set to Open
$ci_query = $this->EE->db->query('
/* how many queries */
SELECT entry_id
FROM exp_channel_titles
WHERE channel_id = 16
AND status = "Open"
ORDER BY entry_date DESC
LIMIT 1
');
// could not find current issue
if ($ci_query->num_rows() == 0) return;
// we have now have the entry_id of the current issue
$current_issue_id = $ci_query->row('entry_id');
// see if the provided article entry_id has a relationship with the current_issue_id
$rel_query = $this->EE->db->query('
SELECT *
FROM exp_playa_relationships
WHERE parent_entry_id = '. $this->EE->db->escape_str($current_issue_id) .'
AND child_entry_id = '. $this->EE->db->escape_str($entry_id) .'
');
// could not find relationship
if ($rel_query->num_rows() == 0) return;
return $rel_query->num_rows();
}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.