No Code Attached Yet Information Required
avatar sergeytolkachyov
sergeytolkachyov
25 Mar 2022

Problem identified

Joomla 4.1.
I want to create custom article vote plugin. There is no problem with plugin itself, but I found an interesting thing:
If plugin Content - Vote is disabled there is no "Voting" setting in Article manager setting - Article.

In plugins/content/vote/vote.php we see a checking $params (line 116):
if (empty($params) || !$params->get('show_vote', null)) { return ''; }

The fields with types Voteradio and Votelist has it's own checking:
File administrator/components/com_content/src/Field/VotelistField.php (line 47)
File administrator/components/com_content/src/Field/VoteradioField.php (line 47)

if (!PluginHelper::isEnabled('content', 'vote')) { return false; }

The problem...

  1. If I want to use custom vote plugin - I'll disable a standart plugin.
  2. Then if I'll disable a standart plugin - I'll loose an oportunity to enable voting in Article manager settings.
  3. Then I can't to show my custom plugin's output because I'll make the same checking
    if (empty($params) || !$params->get('show_vote', null)) { return ''; }

Proposed solution

The decision is to remove checking if (!PluginHelper::isEnabled('content', 'vote')) from fields files:
File administrator/components/com_content/src/Field/VotelistField.php (line 47)
File administrator/components/com_content/src/Field/VoteradioField.php (line 47)

Open questions

So If the community agrees I can make a PR.

avatar sergeytolkachyov sergeytolkachyov - open - 25 Mar 2022
avatar joomla-cms-bot joomla-cms-bot - change - 25 Mar 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 25 Mar 2022
avatar brianteeman
brianteeman - comment - 25 Mar 2022

The problem is that for those people not using your plugin they will no longer be able to disable votes

avatar sergeytolkachyov
sergeytolkachyov - comment - 25 Mar 2022

if (empty($params) || !$params->get('show_vote', null))

True, I didn't think about it.
$params->get('show_vote', null)
here
if (empty($params) || !$params->get('show_vote', null)) { return ''; }
could changed to $params->get('show_vote', 0) != 0
Result
if (empty($params) || $params->get('show_vote', 0) != 0) { return ''; }

It seems to me it makes more sense to explicitly set the parameter than not to have it at all.

avatar chmst
chmst - comment - 3 Apr 2022

@sergeytolkachyov is this an issue for joomla core? If not, could you please close it?

avatar Quy Quy - change - 3 Apr 2022
Labels Added: Information Required
avatar Quy Quy - labeled - 3 Apr 2022
avatar sergeytolkachyov sergeytolkachyov - change - 4 Apr 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-04-04 10:02:50
Closed_By sergeytolkachyov
avatar sergeytolkachyov sergeytolkachyov - close - 4 Apr 2022

Add a Comment

Login with GitHub to post a comment