Author Archive

Using Magento as a CMS

Posted on: November 13th, 2009 by Zach

Magento

Making a page in Magento packed full of your lovely SEO keyword driven content is easy, really easy. But what happens when you want to get that content somewhere that isn’t one of those pages? That’s when everything falls apart…

Let’s get this straight from the get go- Magento is not a content management system and at this point it’s not really trying to be one… well, maybe just a little. It’s got pages, templates and static blocks which can be embedded within each other. Confused? I’d suggest taking a look at the Design Terminologies page. With these 3 main tools and some imagination you can do quite a bit in terms of ensuring that content on a site is editable via the cms.

Unfortunately other than a brief front-end overview, Magento’s developer documentation is non-existent. Luckily there’s a pretty good community of developers willing to share what they’ve learned. Throughout my adventures with Magento I’ve kept a running list of different ways you can grab content from somewhere else, here’s some of the most commonly used ones.

Embed a Static Block Within a Page

So you’ve got a static block of content that you want to put inside of a page, cool. Just drop this snippet in the page’s content textarea and the static block with and id of "foo-block" will magically appear.

  {{block type="cms/block" block_id="foo-block"}}

Get a Static Block’s Content From Within a Template File

This does the same thing as above except instead of being used in a page, it’s used in a template file.

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

Inserting a Template file Inside of a Page’s Content

You’ll notice the curly braces, that means it’s a CMS tag like our first example. Just two things have changed, The type of block is different and in the template attribute you specify the path relative to your templates folder.

 {{block type="core/template" template="path-to-template.phtml"}} 

Templates in Templates

You’re in a template file and you want to include another template file in it, chances are you should probably be using Magento’s block layout system for this rather than manually including it the template. Regardless of best practices, here’s how it’s done.

 $this->getLayout()->createBlock('Mage_Adminhtml_Block_Template', 'block-name')->setData('template', 'path-to-your-file.phtml')->toHtml();

Here is a great resource that dives deeper into various CMS syntax tags Magento CMS syntax – part1

NetBeans Sunburst Color Theme

Posted on: July 1st, 2009 by Zach 16 Comments

sunburst

I’m a long time TextMate lover who might just be turning into a NetBeans user. In my in-between-editors state I’ve ported the Sunburst TextMate theme to NetBeans so I feel more at home. As you can see above, it’s a dark theme with a black background and some easter eggy colors mixed in for readability.

I’ve gone ahead and done HTML, CSS, PHP and JavaScript to the best of the syntax coloring abilities of Netbeans, so there’s still some stuff that may be janky. Grab it from my GitHub repo or just Download it here.

An Open Source Web App Theme

Posted on: June 24th, 2009 by Zach

Here at PRPL we’ve crafted quite a few sites that include an admin section or intranet of some kind. A few weeks ago I was browsing around Github, and found this really great project Web-App-Theme.

The project is described as:

A simple layout by Andrea Franz that you can use in your web applications. Inspired by cool themes like Lighthouse, Basecamp, RadiantCMS and others, it wants to be an idea to start developing a complete web application layout.

This project is really well done, it’s got a myriad of pre-built ui items like tabs, sidebar navigation, tables, feedback messages, etc. all created in a way that makes it trivial to extend and change the look completely. There are about half a dozen contributed themes ready to use, within a few hours I had a customized theme to match the rest of the site I was working on.

Along the way I found a few Internet Explorer 6 bugs (crazy right?), added a few bells and whistles, and modified some things to match our standards here. Overall It sped up development time quite a bit and I will definitely use it again in the future.

3 Movies Every Cyclist Needs to See

Posted on: April 27th, 2009 by Zach

I’m pretty sure everyone is into bikes as much as I am, with that in mind I’m recommending movies you are sure to love.

Breaking away

Breaking Away

Okay, 2 racing teams, the poor townie kids (cutters), and the richie filthy rich college frat boys. Protagonist gets a bike, trains a bunch, races a semi truck on the highway, showdown with frat boys…

Coolest part is that the Greeks vs. Cutters race is real, and the cutters finally won the race in 2005. The movie’s Won an Oscar, is the #8th most inspiring movie of all time, and is indisputably rad.

 

 

Quicksilver

Quicksilver

A hotshot wall street whiz-kid Kevin Bacon quits his high roller day job to become a bike messenger. Includes several scenes with Kev performing bike-ballet on a 1-1 geared fixie with the drops flipped up for bar spins. He basically invents hipster in this movie.

 

 

American Flyers

american_flyer

Kevin Costner is pretty cool too. In this one he’s riding The Hell of the West. Either him or his brother may or may not have a terminal disease, but they’re not really sure. I don’t recall either. This one’s a tear jerker in a good way.

 

 

Others That I mostly Haven’t Seen

Loads more here, although many are literally impossible to find. Also it’s hosted on GeoCities, soo the site’s likely to be gone soon. http://uk.geocities.com/mikstar123/films.html

Myth Busting CSS Reset Speeds

Posted on: April 25th, 2009 by Zach

I’ve always heard and read that the zeroing of margin and padding on all elements in a page via css slows down browser rendering speeds because of all the extra style rules the engine has to apply to every single element. After a question came up on twitter about it, I couldn’t think of or find any real numbers to validate that theory. So I decided to test it.

The Code

Here’s the declaration I’m talking about:

* {
margin: 0;
padding: 0;
}

To put this in scope, all browsers have slightly different ways of applying default margin and padding to elements, so the idea is that to avoid dealing with these differences you just steamroll them down to nothing, building up from there, this is known as a "reset" and has always been fairly commonly used and accepted. The legendary Eric Meyer was one of the first to speak up about how this just wasn’t acceptable in a number of ways and offered a better solution.

The Test

I used a css rendering benchmark tool created by nontroppo. It tests how long it takes a browser to render 2500 positioned divs. That is a LOT of elements, I would estimate a large sized page having at most a few hundred. Hopefully this will give us a wider degree of variation between the tests.

I ran two tests, one without the aforementioned declaration, one with. In each case I loaded the test, ran it a few times to be sure the rendering engine was warmed up (yes, as silly as it sounds they are affected by "cold starts"), then recorded the next 10 speeds averaging them out to produce the following results.

Results

Test Speed
No styles applied 424.4ms
margin & padding: 0 438.8ms

As you can see, applying the reset was about 14.4 milliseconds slower to rendering the page.

Coincidentally that almost exactly the same amount of time it takes for a honey bee to flap it’s wings 3 times. In more useable terms, it’s in the ballpark of sending about .9kb of data across the internet on a high speed connection. If you’re that concerned with time, there are far better optimization tactics to get those milliseconds back.

Is this test a definitive answer?

Pff, yeah right.

This test would have gotten me a "C-" in a 5th grade science fair. I only tested 10 times, on one browser, on a page with nothing but div elements. There are thousands of variables in the DOM alone that could potentially affect the speed tests, but I would say I generally got the numbers that I expected. Resetting in this fashion is slower, but nothing you would ever notice; even on a gigantic page.

We Have Germination!

Posted on: April 14th, 2009 by Zach

Today marked a milestone in my farming career, the first sprouts of a new garden! From what I can tell Shayne and I have the largest, most successful vegetable garden on the western side Uptown Apartments. Here’s a few shots:

My half of the garden

My half of the garden

I’m pretty sure these are tomatoes

Tomato sprouts

Either Peppers or Cilantro

Peppers or Cilantro

You Call That Epic?

Posted on: April 4th, 2009 by Zach

I moved into a new apartment last week and in doing so stumbled upon this gem; a shirt my mom gave me as a gift a few years ago. It’s a medium, but unfortunately fits like an XXL.

epic_shirt

Upon further investigation, I discovered this exact shirt can be found at depandagifts.com. Along with others like:

Night Breed

nightbreed

And what is surely a Florida favorite…

Alligator

alligator