php - Prestashop 1.6 - How I can get the admin directory name dynamically? -


i want put module in prestashop market place, , make standard can use it. plugin needs know admin directory name dynamically service.

i have searched on internet lot of times, didn't find solution issue.

you can use _ps_admin_dir_ witch set in [your_admin_dir]/index.php:

if (!defined('_ps_admin_dir_')) {     define('_ps_admin_dir_', getcwd()); } 

this constant set when you're on admin context. frontoffice doesn't have knowledge of directory , should not obvious security reason.

there's getadminlink method in class link:

/**  * use controller name create link  *  * @param string $controller  * @param bool $with_token include or not token in url  * @return string url  */ public function getadminlink($controller, $with_token = true) {     $id_lang = context::getcontext()->language->id;      $params = $with_token ? array('token' => tools::getadmintokenlite($controller)) : array();     return dispatcher::getinstance()->createurl($controller, $id_lang, $params, false); } 

example:

// here create link dashboard without token $this->context->link->getadminlink(tab::getclassnamebyid(1), false) 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -