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

First Plug-In... simple concept... going about this right?

Development and Programming

upshot's avatar
upshot
85 posts
14 years ago
upshot's avatar upshot

I’m trying to create a simple plugin that paginates an html string (allowing for AJAX pagination). This is what I’m trying to do…

{exp:cwk_gallery:gallery perpage="9"}
     {exp:channel:entries channel="videos"}
          <div></div>
     {/exp:channel:entries}
{exp:cwk_gallery:gallery}

This code will output a span of 20 empty DIVs. I’m simply try to wrap every 9 DIVs in a LI tag to create an unordered list that I can easily paginate with Javascript.

So my plan in the Cwk_gallery plugin is to parse the HTML string to determine where to place the tags. Am I way offbase here? Doing this “the ExpressionEngine way”?

       
upshot's avatar
upshot
85 posts
14 years ago
upshot's avatar upshot

EDIT: This thread can be deleted. It’s some kind of issue with parsing template embeds within my plugin. I’ve started a new thread: http://ellislab.com/forums/viewthread/188904/

       
Wes Baker's avatar
Wes Baker
343 posts
14 years ago
Wes Baker's avatar Wes Baker

What happens when you var_dump $this->EE->TMPL->tagdata?

var_dump($this->EE->TMPL->tagdata);

Does tagdata have anything at all in it?

       
upshot's avatar
upshot
85 posts
14 years ago
upshot's avatar upshot

I am retrieving $this->EE->TMPL->tagdata OK, but I just can’t do what I need to do. I’m trying to do AJAX pagination of a gallery of channel entries, but the number of entries shown is different based upon the user’s member_group. The problem is that the member_group stuff is one of the last things parsed. It’s almost like I need to rewrite the channel entries tag completely, I don’t know. My code:

{exp:cwk_galleries:gallery perpage="9"}
    {exp:channel:entries channel="recipes" dynamic="off" sort="desc" search:categories="{if freebie_2 == 'bycategory'}{freebie_3}{/if}" search:meals="{if freebie_2 == 'bymeal'}{freebie_3}{/if}" status="open|Open - Admins Only"}
        {if status == 'open' OR (member_group == '1' OR member_group == '6' OR member_group == '7')}
            {embed="embed/recipe-gallery-entry" entry_id="{entry_id}" dynamic="no"}
        {/if}
    {/exp:channel:entries}
{/exp:cwk_galleries:gallery}

I can successfully parse the “tagdata” variable but the problem is that the member_group stuff is basically the last thing to get parsed so I really have no idea how I’m supposed to go about this, short of rewriting the channel:entries tag completely.

It sucks because I’m a pretty experience CodeIgniter developer but the EE template parsing system is thwarting me at every turn.

       
Wes Baker's avatar
Wes Baker
343 posts
14 years ago
Wes Baker's avatar Wes Baker

Why not remove the entries tag pair and do all the heavy lifting inside of your plugin? You can get the entries using the Database Class (although I’d recommend using the Active Record queries) and have the member groups be a parameter:

{exp:cwk_galleries:gallery perpage="9" member_groups="1|6|7"}

And inside your plugin:

$member_groups = $this->EE->TMPL->fetch_param('member_groups', '');
$member_groups = explode('|', $member_groups);

if (in_array($this->EE->session->userdata('group_id'), $member_groups) {
    // then...
}
       
upshot's avatar
upshot
85 posts
14 years ago
upshot's avatar upshot
Why not remove the entries tag pair and do all the heavy lifting inside of your plugin? You can get the entries using the Database Class (although I’d recommend using the Active Record queries) and have the member groups be a parameter:
{exp:cwk_galleries:gallery perpage="9" member_groups="1|6|7"}
And inside your plugin:
$member_groups = $this->EE->TMPL->fetch_param('member_groups', '');
$member_groups = explode('|', $member_groups);

if (in_array($this->EE->session->userdata('group_id'), $member_groups) {
    // then...
}

Yeah I suppose I will need to go about things that way. I was hesitant because I’m not really sure where all the various channel entry data rests in the EE database and I haven’t seen anything in the documentation on that subject. I figured I would instead try to build off the back of the existing channel entries tag. I’ll give this a shot…

       

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.