Jump to content

Where to put my function?


crushisai

Recommended Posts

I've created this funciton :

 

static protected $cacheName = array();
public static function getCmsNameById($id_cms_category)
{
if (!isset(self::$cacheName[$id_cms_category]))
self::$cacheName[$id_cms_category] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `name`
FROM `'._DB_PREFIX_.'cms_category_lang`
WHERE `id_cms_category` = '.(int)$id_cms_category.'
'
);


return self::$cacheName[$id_cms_category];
}

as you can see its just a copy from getNameById in manufacturer.php just with it being adapted to display cmscategory name with a given ID. 

The issue I have is I dont know where to put this code, if I put it in link.php Im able to retrieve the information via

{$link->getCmsNameById(2)}

but Im pretty sure thats not the right way to do it.. I tried placing my code in CMS.php and also CMSCategory.php with no success, 

 

I've tried to look on the documentation but Im not able to find whats the correct way.

 

If you can help me understand the system better or pointing me where to read would be awesome. 

Thanks in advance

 

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...