October CMS resources and help articles

Simple and to the point. Optimized by the community.

Add Counter in plugin.yaml

1
by Slevin, last modified on November 20th, 2021
  1. In your plugin.yaml, add counter and counterLabel like this:
side-menu-item:
  label: yourLabel
  url: your/controller/url
  icon: your-icon
  ...
  counter: \AuthorName\PluginName\Models\YourClass::Yourfunction
  counterLabel: Your Label
  1. then in your model PHP file, add your function which is returning a number like this for example :
<?php namespace  \AuthorName\PluginName\Models;

class YourClass extends Model{

  ...

  public static function Yourfunction(){
    // you can do whatever you need right here, you just need to not forget to return a number.
    return self::count();

  }
}
  1. check the result in your backend

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?