The Joomla com_content has small toggle button for the article’s status “publish” to publish or unpublish the articles. So, I want to have same type of toggle button in my component also to approve or disapprove users.
Now, I want some advice from experts on how to go about. I have gone through com_content but I don’t really understand that how should i begin. I can’t understand com_content approach and code because I am not coding in line with Joomla 2.5.
How should I start with this ?
i made it work on my own. let me share the experience for those who will need it in future. my table field or database field is approved and its value is 0 initially (which means the record is unapproved by the admin)
in my layout/default page i have the code as below for the toggle button:
Note that i’ve $row->approved which is my field from db. then i’ve job.approve for which i have created a job.php file and placed in helpers directory. the code for job.php is:
Then i’ve registered two tasks in controller as approve and unapprove along with approve function:
Thereafter, i’ve added the following function in model to update the value to 0 or 1.
Please don’t forget to include the job.php file in your view/view.html.php file as below:
And remember i am not using JForm nor my code is in joomla 1.7 style. But i am following the MVC architecture. So, i am not sure if my method will work for people who are coding in joomla 1.7 and above style.