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 Plugin

Development and Programming

Chris Davies Web Design's avatar
Chris Davies Web Design
369 posts
13 years ago
Chris Davies Web Design's avatar Chris Davies Web Design

Hi all.

I am looking to start work on my first plugin. My knowledge of PHP is low, but I am learning!

Before I start, I thought it might be best to seek some advice as I am not entirely sure how the best way to achieve my goal would be.

My main objective with the plugin is to take a member id and submit it into the EE database. The idea is that a user can click a button when logged in and the button would contain a member id. I want this to be saved into the database where I can then load entries from the list of member ids that particular user has saved.

Is this something that is possible?

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
13 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Hi Chris,

It sure is possible. You’d need to look into creating a Module so you can have your own database table(s) for this functionality. Then you’d have a module file that supports tags like {exp:your_module:member_button id="4"} and the HTML for the button / link is returned.

There are a number of things to learn along the way, so it depends on the full scope of your requirements. Here are a few links that might help:

http://ellislab.com/expressionengine/user-guide/development/module_tutorial.html http://ellislab.com/expressionengine/user-guide/development/packages.html

Erik

       
Chris Davies Web Design's avatar
Chris Davies Web Design
369 posts
13 years ago
Chris Davies Web Design's avatar Chris Davies Web Design

Hi Erik.

Thank you for getting back to me.

Since posting this thread I have been reading up on everything I can find, and have started building my module.

I so far have it so on install it creates a table, with id, follow id (profile member id) and member id (logged in member id). I have a form which has the param ‘follow_id’. When the form is submitted I have just about managed to get it to store the info in the database, and it works.

It currently creates a new row for each submission. I am hoping I can find a way to store multiple ‘follow_id’s’ in the same row separated with a line (1|2|3) and have one row per member id. My aim is to then print these id’s into the channel entries tag pairs param entry_id. Is this possible?

My current function to add to the db is, could possibly you show me how I would achieve the above?

public function follow_user() {
     
     $follow_id = $this->EE->input->post("follow_id", TRUE);  
     $member_id = $this->EE->session->userdata('member_id');  
     
     $data = array(
      "follow_id" => $follow_id,
      "member_id" => $member_id
     );

     $this->EE->db->insert('follow', $data);  
    
    }

Many Thanks

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
13 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

I’d recommend keeping each follow in a separate row and just letting your select query + some php create a string like 1|2|3|4. By doing that you can get more creative with sql down the road if you try to add new functionality.

       
Chris Davies Web Design's avatar
Chris Davies Web Design
369 posts
13 years ago
Chris Davies Web Design's avatar Chris Davies Web Design

Thank you for your advice.

I think I know how to do this. I can use the query module and output the member ids into an embed. Then in the embed file have the expression engine entries tag pair and place the embed variable in the author param.

Thank you!

       

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.