I need to modify Menu.php located at app/code/core/Mage/Adminhtml/Block/Page/Menu.php. My question is can I change the directory path to local (app/code/local/Mage/Adminhtml/Block/Page/Menu.php) without having any issues in the future?
The best practice for overriding a Magento core class is explained in the following article
You need to create your own basic module, and rewrite the core class to point to your module's class. That class may then extend the existing Magento core class, overriding or extending any methods.
However, you could simply copy the file and its path to the local directory, since Magento's autoloader defaults there first when looking for classes. The problem with this is that, when you decide to upgrade Magento, you must fully copy the new file to your path (if it were modified by the upgrade) and reapply your modifications.
The rewrite/extend is a much more maintainable solution, but the latter is quick and easy. The choice is yours!
Related
is it important to use the same directories for views controllers and models or you can be free to create files inside created folders and refer to them when needed
in Laravel MVC
Check docs Directory Structure
The default Laravel application structure is intended to provide a great starting point for both large and small applications. But you are free to organize your application however you like. Laravel imposes almost no restrictions on where any given class is located - as long as Composer can autoload the class.
I myself haven't tried doing my own folder structure. I would personally stick with the standard created by Laravel and follow that.
I wonder if someone here can help, I am just starting with Zend Framework 2 and I am find it slightly daunting to get a project started off properly..
I am trying to create a base controller that I can be extended from. I am currently using the Zend Framework 2 skeleton application.
I have created a Resources folder in vendor/zendframework/zendframework/library. Within the the Resources folder, I have a Controllers folder which houses a BaseController.php file.
How do I get my project to autoload the BaseController in the Resources folder for it to be available through out the entire site?
Any help will be most appreciated.
Thanks
You shouldn't need to create a base controller, ZF2 already provides a number of base controllers for you, such as the RestController and the AbstractActionController
http://framework.zend.com/manual/2.0/en/modules/zend.mvc.controllers.html
If you are going to create a base controller, create you own module and put it in the vendors directory.
You should never need to go into third party modules and modify code as you should be able to inherit and extend the classes that are provided by such libraries
I am trying to override the com_content/views/article/view.html.php file in joomla using the instructions given in this page
It says I have to create a folder named 'code' in base directory and create the same directory structure. I tried it , but its not working. Can someone confirm whether its working.
Where should I create code folder? Is it on root of joomla installations?
PS- The edit is working correctly when applied on core file
You can override (nearly) any class in Joomla, if your class with the same name is loaded first. To ensure that, you need to create a system plugin.
Here is an example for root/components/com_content/views/article/view.html.php:
class plgSystemOverride extends JPlugin
{
public function onAfterRoute()
{
JLoader::register('ContentViewArticle', 'path/to/override.php', true);
}
}
CAVEAT: Overriding a core class can lead to problems with other extensions, if you're not very careful. For views, though, any interferrence with other extensions is less likely.
You can't override component controllers, models and views in core Joomla! without using a 3rd party plugin.
The plugin you need can be found here: http://extensions.joomla.org/extensions/style-a-design/templating/15611
The code folder then goes into your Joomla root unless you're overriding a back-end view in which case it goes into /administrator
Hope this helps :)
You can use the Class Overrider Plugin http://extensions.joomla.org/extensions/tools/development-tools/23994
just adding some simple human reading commands
I want to include an external configuration file in a Magento Observer Model
My observer is in magento/app/code/local/Mycompany/Mymodulue/Model/Observer.php and i want to put my code in magento/scripts/examplename.php
I don't want to use a helper because this code will also be used in other scripts paced in that folder and code repetition is not a good practice
Which is the best way to do this?
Magento is a php application and you can use include() and require() everywhere in your code however this is a bad idea to place classes and spaghetti code inclusions in random places on your server as Magento already includes lib folder and autoloader for those if you follow the naming conventions.
The way I found to do what i was looking for is:
require_once BP.DS.'scripts'.DS.'examplename.php';
where BP and DS are Magento constants, BP=Base Path and DS= Directory Separator
I'm using Joomla 2.5.3.
I have this module that incorporates with authentication. For some reasons I want this module to be duplicated, so I save it as another copy.
Now, as its Module Type is same as the original one,say Auth, how do I customize the files of the copied module?
There is no folder for the copied module inside modules. Only the original one is there.
Thanks.
It depends on what you want to modify and how the module was created.
If the module was created using the MVC design pattern you want to modify ONLY the view (layout, html, css, js), then you'll need to check if the module supports multiple views/layouts or override the layout and create a view for each module depending on its Id. http://www.minitek.gr/tutorials/joomla-16-tutorials/item/21-how-to-create-a-new-custom-module-in-joomla-16.html
If the module wasn't created using the MVC design pattern, you could duplicate the module folder with another name and modify the name of the module in the xml, however it also depends on what the module does (does it write anything to the db?).
Maybe the easiest (probably not the best), would be modifying the current module depending on the module id. Check this out: http://docs.joomla.org/JModuleHelper/getModule
Think of a module as being similar to a class. You have one instance of the module created already. When you either clone the current instance or create a new instance there is still only one underlying set of files.
Each instance of the module contains its own individual settings so they should not clash with each other.
I can't think of any reason why you would need to customise the underlying files. If you do find a need then your best bet is to copy all of the files from the original module and use them as a base to build your own - entirely new - module, with a new name, new class names, etc.