Jump to content

Defining a public static method in a module that can be called from Smarty code


Recommended Posts

Hi all,

How can I set up the PHP code of a module, so that a public static method of a PHP class of this module can then be called from within smarty's code outside of the module's .tpl file ?

 

Example :

Considering the ps_featuredproject module, let's assume

  • that I need to display for example the attached category's name on my front page
  • but outside the block generated by the module's template .tpl file (ie : outside the featured products list, somewhere else on the front page)

A solution would be to define in the module  a public static getFeaturedCateforName() in one of the module's class, then to call this static method from the main  index.tpl file, where I need.

This is likely to be possible : the "prestablog" module defines such smarty-aware static methods, for example.

However, I do not succeed to do so, and do not find a hint in the documentation.

 

My attempts :

  • When defining a static method in the core ps_featureproduct.php file located in the module's root directory , this method cannot be callable from smarty
  • When defining a static method in PHP class placed in the module/class directory, so as it is done in the prestablog module, this method cannot be callable from smarty

 

How should I proceed ?

Should I list explcitely somewhere, in a specific file, what are the methods that can be called from smarty code ?

 

Thank you very much in advance,

Nicolas

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...