Advertisement

Adding a toggle to list view Topic is solved

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
neo314
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Sat Mar 13, 2010 4:22 am

Adding a toggle to list view

Post by neo314 » Sat Jan 18, 2025 3:04 am

Hi All,

I have a plugin that manages which users are subscribed to an email forwarder on the server. I use a Joomla custom field named crewlist to track this. I have added a column to the list view to show the status of each user in the view.
Screenshot 2025-01-17 172229.png
I would like to turn the On List column into toggles, just like publishing and unpublishing. I know how to do it with a custom component, but not a plugin to a different component's list view.

What link/JS can I use to be able to click on the Yes or the No in that column, trigger a submission that will execute PHP code of my own so I can toggle the value of the custom field? I can't seem to grab any events on the admin list view page load to, for example, check for url parameters to see if the PHP function should be executed.

Can I add an 'action' to the list view form behavior that could then reference a function in my plugin?

Any ideas or pointing to existing code as an example would be great. Thanks.
You do not have the required permissions to view the files attached to this post.

Advertisement
User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2989
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Adding a toggle to list view

Post by ceford » Sat Jan 18, 2025 5:58 pm

This may help: https://docs.joomla.org/J4.x:Joomla_4_T ... le_Toggles

Not a plugin but ...

neo314
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Sat Mar 13, 2010 4:22 am

Re: Adding a toggle to list view

Post by neo314 » Sat Jan 18, 2025 6:42 pm

What I am trying to figure out is illustrated by that example. It is using and ajax request and the url it reaches out to is,

Code: Select all

const url = 'index.php?option=com_mycomponent&task=myview.yntoggle&' + token + '=1';
For a plugin, what good way can I do to get a URL to a php file of my own to handle the request and not get a 404 redirect from Joomla. I can't use "option=com_mycomponent&task=myview..."

SharkyKZ
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3159
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Adding a toggle to list view

Post by SharkyKZ » Sat Jan 18, 2025 7:18 pm


neo314
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Sat Mar 13, 2010 4:22 am

Re: Adding a toggle to list view

Post by neo314 » Sat Jan 18, 2025 7:26 pm

That looks promising. I accomplished the task by adding the code to a template override, which is not desirable. I will try to refactor with this. Thanks. I had not seen that page which has specifics regarding plugins.

neo314
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Sat Mar 13, 2010 4:22 am

Re: Adding a toggle to list view

Post by neo314 » Thu Jan 30, 2025 11:35 pm

BTW, That worked great.

Advertisement

Post Reply

Return to “Joomla! 5.x Coding”