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?
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
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
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.