Skip to content

[6.2] Plugin for category change when a transition is executed for article - #45968

Open
Dileepadari wants to merge 16 commits into
joomla:6.2-devfrom
Dileepadari:6.0-dev
Open

[6.2] Plugin for category change when a transition is executed for article#45968
Dileepadari wants to merge 16 commits into
joomla:6.2-devfrom
Dileepadari:6.0-dev

Conversation

@Dileepadari

@Dileepadari Dileepadari commented Aug 23, 2025

Copy link
Copy Markdown
Contributor

Summary of Changes

This PR introduces a workflow plugin that allows setting a category change when a transition is executed for articles.

Testing Instructions

  • Confirm that the plugin is enabled by default in Manage Extensions.
  • Enable Workflows, then go to any workflow and open its Transitions.
  • Edit a transition -> go to the Transition Actions section -> you should now see a Category field.
  • Select any category that the article should switch to when this transition executes.
  • Open an article that uses the workflow you configured. Execute the transition.
    • The article’s category should update automatically.
    • The article’s category field will be disabled while the plugin is active.

Actual result BEFORE applying this Pull Request

In Extensions when searching for "workflow":
manage_extensions_before

In the Transition Actions section:
transition_options_before

Expected result AFTER applying this Pull Request

In Extensions when searching for "workflow":
manage_extension_after

In the Transition Actions section:
transition_options_after

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-6.0-dev labels Aug 23, 2025
@Dileepadari Dileepadari changed the title [6.0] Integration of category change when workflow transitions applied on article [6.0] Plugin for category change when a transition is executed for article Aug 23, 2025
Comment thread plugins/workflow/category/category.xml Outdated
Comment thread plugins/workflow/category/layouts/scripts/disableCategoryBatch.js Outdated
Comment thread plugins/workflow/category/src/Extension/Category.php Outdated
Comment thread plugins/workflow/category/src/Extension/Category.php Outdated
Comment thread plugins/workflow/category/src/Extension/Category.php Outdated
@brianteeman

Copy link
Copy Markdown
Contributor

The plugin needs to be added to the list of core extensions here libraries/src/Extension/ExtensionHelper.php

@Dileepadari

Copy link
Copy Markdown
Contributor Author

Thank you @brianteeman for review, will update the pr soon with the changes.

Comment thread administrator/components/com_admin/sql/updates/mysql/6.0.0-2025-08-23.sql Outdated
Comment thread administrator/components/com_admin/sql/updates/postgresql/6.0.0-2025-08-23.sql Outdated
Comment thread installation/sql/mysql/base.sql Outdated
Comment thread installation/sql/postgresql/base.sql Outdated
@richard67

Copy link
Copy Markdown
Member

It might be that we have to move this to 6.1 as soon as we have created a 6.1-dev branch necause 6.0 has already had feature freeze with 6.0.0-beta1.

@joomla-cms-bot joomla-cms-bot added the NPM Resource Changed This Pull Request can't be tested by Patchtester label Aug 23, 2025
@Dileepadari

Copy link
Copy Markdown
Contributor Author

Thanks @brianteeman and @richard67 for the review. I’ve made all the suggested changes. I really appreciate your time and feedback.

@richard67

Copy link
Copy Markdown
Member

@Dileepadari Now you have produced invalid SQL syntax in the update SQL scripts by using only a part of administrator/components/com_admin/sql/updates/mysql/6.0.0-2025-08-02.sql.

The correct syntax is (exmaple from the mentioned other SQL):

INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`)
SELECT 0, 'plg_schemaorg_article', 'plugin', 'article', 'schemaorg', 0, 0, 1, 0, 1, '', '{}', '', -1, 0
WHERE NOT EXISTS (SELECT * FROM `#__extensions` e WHERE e.`type` = 'plugin' AND e.`element` = 'article' AND e.`folder` = 'schemaorg' AND e.`client_id` = 0);

It is an INSERT INTO ... SELECT ... statement which should not have a VALUES key word.

Your statement has still VALUES but no SELECT.

This will result in an SQL syntax error.

So it seems you did not check your SQL e.g. in phpMyAdmin.

@bembelimen

Copy link
Copy Markdown
Contributor

Thank you @Dileepadari this is a very nice addition to the workflow 👍

Comment thread libraries/src/Extension/ExtensionHelper.php Outdated
@Dileepadari

Copy link
Copy Markdown
Contributor Author

Hi @richard67, sorry for that. Can you let me know how can i test with PhpMyAdmin. Should I replace the #__extensions with the table name including table prefix?

Comment thread administrator/components/com_admin/sql/updates/mysql/6.0.0-2025-08-23.sql Outdated
Comment thread administrator/components/com_admin/sql/updates/postgresql/6.0.0-2025-08-23.sql Outdated
@richard67

Copy link
Copy Markdown
Member

Hi @richard67, sorry for that. Can you let me know how can i test with PhpMyAdmin. Should I replace the #__extensions with the table name including table prefix?

That would be one way to test it on the current Joomla installation.

Another way would be to copy the CREATE TABLE statement from the base.sql and use it as it is to create an #__extesions table without the suffix to be replaced, then you could fiddle with SQL in that table without having to replace the prefix in your SQL statement and without messing up the table from the Joomla installation.

And when developing database stuff for Joomla it is a good idea to have a PostgreSQL database in addition to the MySQL (or MariaDB).

@Dileepadari

Copy link
Copy Markdown
Contributor Author

Thanks for the info, it helps a lot in testing quickly.

@tecpromotion tecpromotion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adapt the two SQL files for Joomla 6.1.

@tecpromotion tecpromotion added PBF Pizza, Bugs and Fun and removed Updates Requested Indicates that this pull request needs an update from the author and should not be tested. labels Jan 9, 2026

@heelc29 heelc29 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plugin only works with com_content. However, since third-party components could also use the workflow function, this should not be the case.

Comment thread plugins/workflow/category/forms/action.xml Outdated
Comment thread plugins/workflow/category/src/Extension/Category.php Outdated
Comment thread plugins/workflow/category/src/Extension/Category.php Outdated
@HLeithner
HLeithner changed the base branch from 6.1-dev to 6.2-dev March 17, 2026 09:13
@HLeithner

Copy link
Copy Markdown
Member

This pull request has been automatically rebased to 6.2-dev.

@HLeithner HLeithner changed the title [6.1] Plugin for category change when a transition is executed for article [6.2] Plugin for category change when a transition is executed for article Mar 17, 2026
@MacJoom

MacJoom commented Jul 10, 2026

Copy link
Copy Markdown
Member

@Dileepadari - thank you for the PR - are planning to work on this? as there are changes requested.

@Delhiproject0

Copy link
Copy Markdown

are planning to work on this? as there are changes requested.

Thank you for the reminder, will update this ASAP

@HermanPeeren

HermanPeeren commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

I wanted to use this on a site and tested it by making an installable plugin from it. See github.com/HermanPeeren/workflow-plugins/tree/main/src/plg_workflow_category.

  • an error when using this: a category is required, but in the initial stage the plugin prevents saving any category. So I cannot save a new item. There should be a default category (to be set in the plugin parameters, not in the action form), which can default to the "uncategorised" category. And that category should be set for the initial stage of the workflow. More general this could be an improvement for the workflow plugins: if some value is set with a transaction, then we cannot set that value for the initial stage.
  • I added some comments to the code in my repo (my comments start with HP:) to make it more general, not only com_content: split $context into the component name and the table name. Then instantiate the table directly from the component's MVCFactory.
  • The processArticle() method (which should be renamed to processItem()) boots the component (here com_content) at every call, but it is called in a loop: $pks is an array, because it can be used in a batch command. Boot the component before the loop.
  • the layout folder should not be anymore under <files> in the manifest. That js is now in the media folder.
  • I think there are two superfluous lines changin the modified and modified_by properties.
  • Some minor things, like adding a return type to a method (2x), and a static cal to a non-static method,

@joomla-cms-bot joomla-cms-bot removed the NPM Resource Changed This Pull Request can't be tested by Patchtester label Jul 22, 2026
@Dileepadari

Copy link
Copy Markdown
Contributor Author
  • Some minor things, like adding a return type to a method (2x), and a static cal to a non-static method,

Thanks @HermanPeeren for taking time and giving your detailed review and suggestions, I have updated the pr accordingly. Please test it if you get some time. Thanks everyone for the reviews.

@Dileepadari
Dileepadari requested a review from heelc29 July 22, 2026 16:26

@heelc29 heelc29 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Category is not displayed when edit item (the field is disabled)

Image

Comment thread plugins/workflow/category/forms/action.xml Outdated
Comment thread plugins/workflow/category/services/provider.php
Comment thread plugins/workflow/category/src/Extension/Category.php Outdated
@Dileepadari

Copy link
Copy Markdown
Contributor Author

Category is not displayed when edit item (the field is disabled)
Image

Thanks @heelc29 for the review, I resolved all the comments you have given but for the category not showing part, I am not sure why its not displayed. The category change is disabled when you are editing the article but still you will be able to see the category. you will be able to set the category if you are creating the article or if the category is not set. Please provide me with theme details if you still can't see the category, I'll try to debug.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Language Change This is for Translators PBF Pizza, Bugs and Fun PR-6.2-dev

Projects

None yet

Development

Successfully merging this pull request may close these issues.