i've created a custom service as php class ( ServiceClass ) with some functions ( generateInfo() ) and i'm looking for a way to call this function from other views
thanks for help.
i've created a custom service as php class ( ServiceClass ) with some functions ( generateInfo() ) and i'm looking for a way to call this function from other views
thanks for help.
You can create your own View Helper
Now create an entry in the module.config.php for that helper:
And now you can call it in your views:
And for calling the generateInfo():
You can also call it from a controller:
Without View Helper
Not the best practice because this generates repeated code but, if you do not want to create a View Helper, then you can always create an instance of your service in a controller and then pass it to the View.