Overriding Joomla core component file - joomla

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

Related

How to make joomla check different folder for html overrides first?

I am making system plugin for Joomla 2.5 and 3.x that should check for different html overrides folder first before the templates/template_name/html , it works well but I honestly do not like it because it is a hack that can be easily killed by joomla update. For example to override module chrome
In my plugin I have :
public function onAfterInitialise() {
JLoader::register('JModuleHelper','path to my application module helper');
}
and in my custom helper.php I changed the JModuleHelper class method renderModule() to check for html overrides in following order:
check my plugin html folder if module override file is there use it
if no override in my plugin check template html folder
if none of the above use joomla default.
joomla default is:
check my template html folder if module override file is there use it
if no override in template html, use joomla default.
isn't there an easier way to achieve this ?
Any help is appreciated. Thank you!
The best way to achieve what I am after is this
http://docs.joomla.org/How_to_override_the_component_mvc_from_the_Joomla!_core
http://extensions.joomla.org/extensions/style-a-design/templating/15611

Magento Module Development

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!

What is the use of Controller overriding in Magento?

In magento what is the use of overriding a controller?? In java, it can be helpful to call the super class method to the sub class. So is both the overridings are same?? If so, when and where we will override the controller? I knew that magento itself provides modules at app/code/core/Mage path. So instead of this at what situations we will over ride the controllers?
I searched for the google and it shows how to override a controller and I havent find about why to override a controller in magento?
Can anyone explain me about this??
Overriding Controller it mean we can override the Magento Core Controller(app/code/core/Mage/) into Our Custom Magento Module(app/code/local/).
you can implement your custom operations While Overriding Magento Core Controller in custom modules.
Below are the reference for Magento Controller Overriding
https://stackoverflow.com/questions/6980026/override-magento-controller
Magento override controller
Adding to the answer given by #Man kingdom
Overriding a controller avoids messing or playing with core files which magento does not likes.
Even you're overridden controller is false you have a option left to recover from default core files.
Moreover overriding a controller helps you a lot when you want to upgrade your magento version.
Following url's I always refer:
Link 1
Link 2
Hopes this helps you.

base controller zend framework 2

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

Zend multiple directories and MVC routing

I'm building my first personal website using Zend 1.11. To create the directory structure I've used the zf script that comes with the framework. I can use the same script to create controllers/views like so:
/home
/contact
/blog
/about
Yet where I've come unstuck is trying to encompass multiple directories e.g.
/contact/address
/about/cv/workhistory
...I just get an error saying the content cannot be found. There is no model, just a controller (route?) and a view. I've tried adding the desired directory structure when I use zf but this results in an error e.g.
zf create controller about/cv/workhistory
Is this even possible in MVC or does it show a lack of understanding of what MVC is on my part? Thanks in advance for any help/tips/pointers
ok you've created some controllers. Now it looks as though you want to add some functions to your controllers.
In order to do /contact/address it would be appropriate to have the addressAction() inside your ContactController().
A controller is a group of actions (read METHODS). When you built your application 2 controllers were built with it, one of them was the IndexController() that also gave you your first action indexAction() and your first view index.phtml located at /application/views/scripts/index:
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
}
}
Zend Framework implements the MVC paradigm with actual Models, Views and Controllers. In the controllers are your actions grab data and prepare it to be viewed.
Go ahead and do yourself a favor and run through some tutorials, here are some suggestions.
Rob Allens ZF 1.11 tutorial
Zend Framework Quickstart
The naming conventions are important to understand and can be found at:
Zend Framework Naming conventions

Resources