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

Working with Plugins, Conditionals, and Plugin Parameters

Development and Programming

Bransin's avatar
Bransin
157 posts
14 years ago
Bransin's avatar Bransin

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();
        
    }
       
Lisa Wess's avatar
Lisa Wess
20,502 posts
14 years ago
Lisa Wess's avatar Lisa Wess

Bransin, is this the one we helped with in EE Help Chat? Thanks!

       
Bransin's avatar
Bransin
157 posts
14 years ago
Bransin's avatar Bransin

Hi Lisa,

My question was answered in the EE help chat. Turning them into pair tags was the solution. Thanks again!

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team
Turning them into pair tags was the solution.

Awesome 😊

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

Rockin’! Thanks for the update. =)

       

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.