Closed aljawaid closed 2 years ago
I need help. I've tried to do as a helper but the test wont work.
helper:
<?php
namespace Kanboard\Plugin\PluginManager\Helper;
use Kanboard\Core\Base;
class PluginManagerHelper extends Base
{
public function checkPluginType($value='')
{
if (isset($plugin['remote_install']) && $plugin['remote_install']) {
return 'hello'; // this will be an svg icon when it works
} else {
return 'none'; // this will be an svg icon when it works
}
}
}
calling in template directory.php
:
<?php if (isset($plugin['remote_install']) && $plugin['remote_install']): ?>
<span id="PluginType" class="plugin-type">
<?= $this->helper->pluginManagerHelper->checkPluginType($this->text->e($plugin['remote_install'])) ?>
</span>
<?php endif ?>
@creecros @alfredbuehler any advice what I am doing wrong?
remote_install
(waiting for new properties to be updated- 80% done)is_type
property which is a string as the resultis_type
is "theme" then show the theme icon, if it is "plugin" then show the generic plugin icon etc etc and from there i will also be able to count the totals of each typeit works in the template so I will just do it in there
but what about the totals?
at first glance, I don't see where $plugin
was ever defined in your helper. I'll take a closer look tomorrow.
pushed type total rough draft for you, you can finish it from there, as i am not a front end person. Only did three as an example and to test:
to get the other totals, just use:
isset($countTypes['multi']) ? $countTypes['multi'] : '0'
in the template.
So that you understand how it works:
In the template we define $countTypes
using the helper function countTypes
, and sending the variable $available_plugins
:
<?php $countTypes = $this->helper->pluginManagerHelper->countTypes($available_plugins); ?>
Then in the template we can get the totals for each type by using the conditional:
isset($countTypes['multi']) ? $countTypes['multi'] : '0'
The return is a number, if it is set, if it is not set, then it is 0.
pushed type total rough draft for you, you can finish it from there, as i am not a front end person. Only did three as an example and to test:
to get the other totals, just use:
isset($countTypes['multi']) ? $countTypes['multi'] : '0'
in the template.
So that you understand how it works: In the template we define
$countTypes
using the helper functioncountTypes
, and sending the variable$available_plugins
:<?php $countTypes = $this->helper->pluginManagerHelper->countTypes($available_plugins); ?>
Then in the template we can get the totals for each type by using the conditional:
isset($countTypes['multi']) ? $countTypes['multi'] : '0'
The return is a number, if it is set, if it is not set, then it is 0.
above all its nice to see these numbers starting to show up.... done a majore cleanup of that json file and glad that Frederic is still accepting updates.
I will look into the above code tonight, thats for that explanation.... makes more sense when its broken down
Fix 26adefe
Based on the new
is_type
json property, count the totals and display to the user like a legendRelated to: #13 #12