I want to build a module where , we like to build the form and table using smarty.
In prestashop module controller load template file like
/modules/my_module/views/templates/front/my_module.tpl
where admin will be /modules/my_module/views/templates/admin/admin_module.tpl
My point is how can i show this admin_module.tpl in the prestashop module configuration page.
It is really easy. You just have to create views/templates/admin/foo.tpl and then only display your template in getContent() method:
public function getContent()
{
return $this->display(__FILE__, 'views/templates/admin/foo.tpl');
}
Related
I 've added custom page and js for it in stencil bigcommerce.
It works fine locally but when I push it on bigcommerce, it does not work well.
I have added custom template template/pages/custom/page/custom-layout.html and I've added custom js for it in assets/js/custom/custom.js.
I've configured some loading settings in assets/js/app.js as follows:
const customClasses = {
'pages\\custom\\page\\custom-layout': () => import('./custom/custom')
}
It works locally; but, on a server, it does not at all.
Your customClasses object should use forward slashes like so:
"pages/custom/page/custom-layout": () => import("./custom/custom")
You should also make sure that your custom.js file is extending the PageManager class like so:
import PageManager from "../page-manager";
export default class CustomClass extends PageManager {
constructor(context) {
super(context);
// other constructor code here
}
onReady() {
// your code for the onReady event here
}
// ... any other code
}
If this is done properly your custom JS class will be injected to the page. However, once you bundle and upload your theme, you must also make sure to apply your custom template to the page, as the config.stencil.json file is not packaged with your theme. This can be done from within the BigCommerce control panel by going to Storefront > Web Pages > [Your page] and changing the Template Layout File accordingly.
I would like to edit and add features to the prestashop Store Locator page.
Prestashop's documentation isn't really clear, and i would like to know if it's possible to implement a Controller in a custom module.
I would like to create a module which is able to extends StoreFrontController and it's features without starting from scratch.
Is it possible ? Have you some documentation for me ?
A beginner,
Best.
As you have many requirements, you will have to go with an override of class StoresController.php.
Your module folder should look like this:
/mymodule
/mymodule.php
/config.xml
/override
/controllers
/front
StoresController.php
/views
/templates
/front
stores.tpl
In StoresController.php you will have to override initContent():
<?php
class StoresController extends StoresControllerCore
{
/**
* Assign template vars related to page content
* #see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
// here add any smarty variables you want
$this->setTemplate(_PS_MODULE_DIR_.'mymodule/views/templates/front/stores.tpl');
}
}
Now you can add as many variables as you want in this controller and customized its template in your own module.
We you create an override in a module, it will be only parsed once at installation. If your module is already installed you will have to uninstall it and install it again. Then your override file will be copied to the root /override folder.
Any change made in your module override will not be reflected to the root override folder. So you will have to uninstall and install your module each time you want to make a change.
So I advise you to make all your changes directly in the root override folder, and when you're done copy this file back into your module folder. And if you don't want to uninstall your module and install it again to declare this file, you can put it directly in the root override folder and delete the file /cache/class_index.php so that Prestashop knows that an overrides has been added.
If you have any questions :)
You can start by overriding front controller like
`"/modules/mymodule/override/controllers/front/StoresController.php" and in this fine add class "class StoresControllerCore extends FrontController {
public function initContent()
{
parent::initContent();
//here do whatever you like
}
}"
though you must know coding to proceed further.
Working on a project that consist to create thumbs for the product's features,
is there a way to override the core controller *AdminFeaturesController*using a module?
In your module you can create a /override directory. Under this directory you will create this file /override/controllers/admin/AdminFeaturesController.php.
This file should look as follow:
<?php
class AdminFeaturesController extends AdminFeaturesControllerCore
{
// Only override the functions that should be modified
public function function_that_i_want_to_override() {
}
}
The override will be effective after module installation.
Is it possible to integrate javascript in a module without a direct injection in the template smarty?
Solved ,
I added a Js file in my module directory (ex : mymodule/views/js/abo_front.js).
In my module class, I created a Hook to the header to declare my js file in the header.
public function install()
{
return parent :: install() && $this->resetDb()
&& $this->registerHook('header');
}
public function hookHeader($params)
{
$this->context->controller->addJS(($this->_path).'views/js/abo_front.js');
}
I started writing my first Zend Framework 2.0 (beta 1) PHP application using php 5.3.
I actually created a skeleton project and module based on the following url: http://packages.zendframework.com/docs/latest/manual/en/zend.mvc.quick-start.html
I want to add forms to the module I created. the my question is how do I configure the module to know where to fetch the forms in?
my module name is called LoginModule and I created a new form called LoginForm (that extends Zend_Form) and I placed it in my_proj/module/LoginModule/src/LoginModule/forms
how do I configure that module to know where to fetch the form class from ?
thanks
found the answer at http://akrabat.com/getting-started-with-zend-framework-2/
Everything has changed... (got better) in zend framework 2.
I created a directory called 'Form' in the src directory of my module.
inside I create the class that extends Form (not Zend_Form)
example from the tutorial above:
<?php
namespace Album\Form;
use Zend\Form\Form,
Zend\Form\Element;
class AlbumForm extends Form
{
public function init()
{
$this->setName('album');
$id = new Element\Hidden('id');
$id->addFilter('Int');
$artist = new Element\Text('artist');
$artist->setLabel('Artist')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$title = new Element\Text('title');
$title->setLabel('Title')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$submit = new Element\Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $artist, $title, $submit));
}
}
i really recommend reading the tutorial for all zend framework 2 beginner :)
thanks!