You might someday (or perhaps you already have) come across a case where you want one module to be loaded after another module, but don’t necessarily want it to depend on the other module. Reasons might be that one config value should override another (such as a model/block/controller rewrite), or one layout should be applied after another (such as to remove a block added by the former). There might not actually be a dependence, or perhaps adding a dependence would create a circular dependency. There are two possible solutions for this:
- Merge the two (or more) module .xml files manually into one .xml file with the proper XML element order.
- Name the .xml files (or symlinks a.la. modman) such that they sort alphabetically in the proper order.
The element order within a single file will be stable (SimpleXML), and Magento loads the files alphabetically except that those beginning with Mage_ come first. Problem solved.
Example:
Before:
app/etc/modules/My_Module.xml
app/etc/modules/Their_Module.xml
After:
app/etc/modules/50_Their_Module.xml
app/etc/modules/60_My_Module.xml
Now “My_Module” is loaded after “Their_Module” so I can override their config and/or layout without modifying their files and without My_Module depending on Their_Module!
Uncategorized
I recently had a need to include some code from two subversion repositories in a git-based project. A bit of Googling brought me to the disappointing conclusion that there is no easy maintenance-free way of doing this with git.. Modman to the rescue! With a simple one-liner added to my modman file I can accomplish what is essentially an svn:externals declaration in my git-based project, or a subversion repository as a git submodule! Behold:
EDIT: Updated to use multi-line continuations for readability.
# Substitute for svn:externals
@shell \
SRC=https://example.com/source/magento/common; \
DEST=modules; \
if [ -d $DEST/.svn ]; then \
svn update $DEST; \
else \
svn checkout $SRC $DEST; \
fi
# Import subversion-based modules
@import modules/Foo
@import modules/Bar
Now, when I clone the module (git is supported natively as of 1.1.0) or any time I run an update, deploy or repair, the subversion modules will be checked out or updated as well. So, if you ever need to mix and match SCM’s, go right ahead. I still recommend the use of git submodules for all-git projects and svn:externals for all-subversion projects, of course.
I’ll consider adding a builtin function that tidies up the above and handles things like switching urls..
Uncategorized
While researching Magento performance optimizations you have probably already read about how to optimize Apache’s configuration by moving your configuration directives into the configuration files and out of the .htaccess files. Of course you need root to do this, but assuming you can, there are still very very wrong ways to do this that will result in no real performance gains, leave gaping security holes, and consume more time than necessary. Read on, a handy script for solving these problems and before and after performance benchmarks to prove the gains are included.
Read more…
Uncategorized
apache, bash, Magento
Ok, so what kind of web developer doesn’t have a website? Me, but not anymore. :)
Uncategorized