I am trying to hide the 'help' button on the dashboard by override. But the override is not being used. So I was wondering what am I doing wrong? Why is the override not used?
I found it in: classes/controller/AdminController.php. Then I created a new file: override/classes/controller/AdminController.php.
I could not get the override to work, so I tried to check if it was taken into account at all by:
<?php
class AdminControllerCoreOverride extends AdminControllerCore
{
echo 'askdjfkdjfksl';
}
?>
But nothing happened. I deleted cache: index_cache and the override is not turned off in performance menu. In the index_cache.php I found the AdminController but override was false.
PS: using Prestashop 1.6
If you create an override file manually, you must delete the file cache/class_index.php for your override file to work.
Then, in override/classes/controller/AdminController.php you must override a function like so:
<?php
class AdminController extends AdminControllerCore
{
public function initPageHeaderToolbar()
{
Your code
}
}
You don't need to put ?> at this end of this file.
I faced similar issue (with PS7). In my case the problem was caused by file permission.
Prestashop needs write permision to the file you want to override. Otherwise the file is ignored without any warning/error message. You can delete class_index.php file like crazy with no help.
Also, for some reason, I had to reset my module anytime I do anychange in my override controller.
BTW in PS7 the cache_index is located under /app/cache/dev folder (and /app/cache/prod folder).
you can try this:
update your class name from AdminCoreControllerOverride to AdminCoreOverrideController
and AdminControllerCore to AdminController
<?php
class AdminCoreOverrideController extends AdminController
{
public function init() {
parent::init();
}
}
then you can test in your browser by this link:
http://localhost/YOUR_ADMIN_DIR/index.php?controller=AdminCoreOverride
Related
i am new to Prestashop and i am trying to override a function of a class inside modules/moduleName/src in my custom module in override folder but it is not working.
The path of original file is: modules/moduleName/src/Adapter/file.php
The path of the changed file is: modules/myModuleName/override/src/Adapter/file.php
Extending the class this way it is not woking, it does not use the function of the the changed file.
class MyFileOverride extends MyFile{
public function myFunction(){
//funtion to be changed
}
}
What is the best way to override this file?
Thank you!
Complicated to do. It's not really possible for me...
Otherwise, we can hijack the thing...
The class of your module should extends the class you want to modify and you should change all the calls of the class you want to modify by a call to your class.
Constantin,
I understand that we should not directly edit the vendor files in Laravel, however I wish to know how I can override the loggedOut function of the trait AuthenticatesUsers so that I can perform some action when the user logs out.
Please could someone show me with some code snippet how this can be achieved.
Thank You
You can override this method in the LoginController or wherever else you're using that trait.
class LoginController {
use AuthenticatesUser;
public function loggedOut()
{
// Your custom code
}
}
I have followed many tutorials, but they are either cryptic or they did not work, or they wanted you to use the terrible CMS block module which gives you limited control over the custom elements of a page.
So far:
I created a controller called ProgramsController.php and put it into ps_root/controllers/front
class ProgramsControllerCore extends FrontController
{
public $php_self = 'programs';
public function init()
{
parent::init();
}
public function initContent()
{
parent::initContent();
$this->setTemplate(_PS_THEME_DIR_.'programs.tpl');
}
}
I created a template called programs.tpl and put it into ps_root/themes/mytheme/ folder
I then use: localhost/index.php?controller=programs or I use the SEO and links builder to create a localhost/programs link, and I get an error: Fatal error: Class 'ProgramsController' not found in ...\classes\controller\Controller.php on line 135
But that's not right since the path ought to be a ../controllers/front path, why is it looking in ../classes/controller? I assume from all the tutorials that the dispatcher should know to hook my front controller to the correct template. Why is this not working?
Basic Question:
In PrestaShop 1.6 I just want to know how to create custom pages like: http://myshop.com/mycustompage
But that it also utilizes the existing header and footer.
For creating a new custom page you have to follow some steps:
you have to create a new folder in your modules folder of prestashop like
C:\wamp\www\prestashop\modules\your_module_name
Then you put your controller file in your module folder like:
C:\wamp\www\prestashop\modules\your_module_name\controller\front\your_file.php
And in that you code like:
class ProgramsControllerCore extends FrontController
{
public $php_self = 'programs';
public function init()
{
parent::init();
}
public function initContent()
{
parent::initContent();
$this->setTemplate(_PS_THEME_DIR_.'programs.tpl');
}
}
Then you make a new folder views in your module like:
C:\wamp\www\prestashop\modules\your_module_name\views
Then in that you make another folder named template and in that another a folder named front like:
C:\wamp\www\prestashop\modules\your_module_name\views\templates
C:\wamp\www\prestashop\modules\your_module_name\views\templates\front
Then in that file you have to put your theme file Like
C:\wamp\www\prestashop\modules\your_module_name\views\templates\front\programs.tpl
and now render your file. I hope it would work.
How can I have a custom layout for a 404 page in Cake? I know you can create your own view but I also want a custom layout for it as I don't want it inheriting my site design and want it to have a unique look and feel.
I've created my own views and then added my own app_error in /app/ with the following code:
<?php
class AppError extends ErrorHandler
{
function error()
{
$this->layout = 'error';
}
}
?>
But it doesn't load the error layout? Any ideas why?
Thanks.
Create your own AppError class (in app/app_error.php and override the _outputMessage method, something like:
class AppError extends ErrorHandler {
function _outputMessage($template) {
$this->controller->render($template, 'NAME OF THE LAYOUT');
$this->controller->afterFilter();
echo $this->controller->output;
}
}
I believe you just create a file at /views/errors/error404.thtml. It may end in .ctp actually, but give both a shot.
Create/edit the app/views/errors/error404.ctp page. See CakePHP Error Handling.
I have following code:
class MY_Router extends CI_Router {
function __construct() {
parent::__construct();
log_message('debug', "My Child Router Class is here");
} }
I have run the web page and saw log, but didn't find any log message there.
My purpose is that, instaed of default router, I want to use custom made router.
Can some one guide me what and where Iam doing wrong. And how it can be rectified.
Thanks in advance
If you are simply testing to see if the class if being constructed properly, it may be easier to just call an error message. If the error message displays then you're good to go.
show_error("My child router class is up and running.");
Also, ensure that your file is named "MY_Router.php" and is placed in your /application/core directory.
The user guide entry relating to extending core classes can be found at http://codeigniter.com/user_guide/general/core_classes.html