Danijelp Posted May 23, 2015 Share Posted May 23, 2015 Hi all, is it possible to include or adapt php code to show in back office.I mean, I create controller and make Update button to menu of back office and want to include this code to show there <?php require(dirname(__FILE__).'/config/config.inc.php'); if ($_SERVER["REQUEST_METHOD"] == "POST") { $new_group = $_POST["new_group"]; $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT DISTINCT c.* FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.') '); foreach($categories as $category){ $categoryObj = new Category($category['id_category'], (int)Context::getContext()->language->id); $categoryObj->addGroups(array($new_group)); } echo 'Updated'; } else { echo' <form method="post" action="'.$_SERVER["PHP_SELF"].'"> Enter New Group id: <input type="text" name="new_group"> <input type="submit" name="update" > </form>'; } ?> thnx in advance Link to comment Share on other sites More sharing options...
las3r Posted May 23, 2015 Share Posted May 23, 2015 If you want to do this in a way that will be compatible in the future I would recommend building a module - this is actually quite simple and can archieve what you want (add a menu item the BO to perform some function More info: here 1 Link to comment Share on other sites More sharing options...
Danijelp Posted May 25, 2015 Author Share Posted May 25, 2015 Thnx Eric, I tried but don't know how get this to work. I tried in this way that create menu button in BO, make controller to call tpl file, but as I saw there is no possibility to include php functions in tpl file. Do you have some working example or something else to help me? thnx in advance D. Link to comment Share on other sites More sharing options...
PascalVG Posted May 26, 2015 Share Posted May 26, 2015 Hi Dani, Did you have a look at the developers guide already? There is some example on how to make a module, and in there, they describe how to add some configuration page, where you add some input fields to modify, and a submit button. There you can see how they act on a submit as well. On creating a module: http://doc.prestashop.com/display/PS16/Creating+a+PrestaShop+Module and a direct link for how to add the configuration page: http://doc.prestashop.com/display/PS16/Adding+a+configuration+page Hope this helps, pascal. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now