2011
16
Sep

Blocks in Magento

One of the things Magento got right is blocks. It’s one of the few things I am continually impressed by. There are a lot of ways to add a static block to the page.

XML is probably the most common place to add a static block. You find whatever block you want to add your static block into and you add something like:

<block type="cms/block" name="YOUR_BLOCK_ID" before="-">
	<action method="setBlockId"><block_id>YOUR_BLOCK_ID</block_id></action>
</block>

Adding a static clock through layout XML can be very useful if you need to add a static block to a sidebar on a single page for example instead of all pages.

<reference name="left">
	<block type="cms/block" name="YOUR_BLOCK_ID">
		<action method="setBlockId"><block_id>YOUR_BLOCK_ID</block_id></action>
	</block>
</reference>

Adding you static block through PHP may be the least common way. This, however, can be very useful if you want to define areas in your theme where a menu or a widgets could go. To add a static block in PHP you would use:

echo $this->getLayout()->createBlock('cms/block')->setBlockId('YOUR_BLOCK_ID')->toHtml();

Adding a static block through a short code is very powerful. It allows you to add a static block into a CMS page or even your products.

{{block type="cms/block" block_id="YOUR_BLOCK_ID"}}
2011
15
Sep

To the shores of Tripoli

Before the uprising in Libya, even though it is part of the Marine Corps Hymn, I really doubt most Marines knew were Tripoli was located. ‘To the shores of Tripoli’ in the Marine Corps Hymn stems from the Battle of Derne. It is the first recorded land battle fought overseas by the United States. It was after this battle that 1st Lt. O’Bannon was presented the Mameluke sword, which is still worn by Marine officers today.

More Marines are aware that ‘The Halls of Montezuma’ is from the Battle of Chapultepec, only because it is from this battle that we get the blood stripe that NCOs wear to commemorate the Marines that died during this battle. I doubt most Marines know that the Battle of Chapultepec was fought during the Mexican-American War were US forces fought Mexican forces holding Chapultepec Castle located west of Mexico City.

2011
18
Jul

Setting Up Virtual Hosts in Zend Server CE on OS X

What is a virtual host? Virtual hosting is a method for hosting multiple domain names on a computer using a single IP address. Shared hosting uses this same method for all of the sites they host. Aren’t those URLs you use in Zend Server getting pretty ugly? Would you like to change http://localhost/my/awesome/website into http://www.super-awesome.local You can!

Last time we talked about general Zend Server setup. This time, we will be going through setting up virtual hosts on your local machine. This again will involve Terminal.

This assumes you have Zend Server set up and running. If it is not, go here.

Continue reading “Setting Up Virtual Hosts in Zend Server CE on OS X” »

2011
16
Jul

Installing Zend Server CE on OS X: A Guide For the Terminal Timid

I use MAMP Pro both at home and at work for development. It quick, it’s easy and I really don’t have to fiddle with it a lot after it is set up. It’s perfect for me.

At work we have a project to be built with Codeigniter sitting on a Linux machine but we wanted to use Microsoft SQL Server on a different machine as the database. Turns out, it’s not a simple as changing the database type in Codeigniter to “mssql” to get it up and running. If this is all you do, you get the dreaded white screen. You need a PHP extension to do it. Problem is, Microsoft only makes this PHP extension for Windows. There are a lot of tutorials out there on how to build the extension yourself on Mac or Linux machine (this site for example), but none seemed to work for me.

Instead of setting up a Windows virtual machine and being forced into developing that way, I decided to install Zend Server CE. Zend comes with a MSSQL extension, it just needs to be enabled.

This tutorial does include Terminal work. I am going to walk through step-by-step, so even if you are not comfortable with Terminal, you will be up and running with Zend Server CE in no time. The only requirement is you are running an Intel Mac OS X.

Continue reading “Installing Zend Server CE on OS X: A Guide For the Terminal Timid” »

2011
04
Apr
2011
03
Apr

Mercurial .hgignore file

If you are using Mercurial, there is this handy file in your repository root called .hgignore. This is a file that keeps track of all of the files that should not be tracked by Mercurial. For example, log files or cache files should not be committed to repositories.

I do a lot of work with PHP, Codeigniter, and Eclipse on the Mac. This is what my .igignore file looks like:

application/logs/(?!index\.html|\.htaccess)
application/cache/(?!index\.html|\.htaccess)
syntax: glob
.DS_Store
*.[Bb][Aa][Kk]
[Bb][Aa][Kk]
*.[Cc]ache
.buildpath
.project
.settings

The first two lines keep my logs and cache directories empty on commit except for the index.html and .htaccess files that are in there. .DS_Store is used by Finder. It’s similar to the desktop.ini file on Windows. The last three lines are to keep my Eclipse project files out of the repo. Everything else is files and directories that I tend to call things.

If you are on Windows, instead of .DS_Store you will probably need [Tt]humbs.db as well. If you are working with Microsoft Visual Studio and .Net, you are going to need a few more things. The ones I can think of off the top of my head are:

syntax: glob
*.suo
*.webinfo
[Bb]in
*/[Bb]in
[Rr]elease
*/[Rr]elease
[Dd]ebug
*/[Dd]ebug

All of this will of course change depending on the IDE, preferences, and framework you are using. This will help you get started.