December 30, 2009
When it comes to Magento, I’m mostly a frontend developer. I’ve written some modules – some of which I’m working on sharing with you, public – but for the most part I stick with it’s core functionalities and just edit the template HTML & CSS files.
As such, I found myself wondering how I could add a new class name to the body tag in the HTML. I at first checked the skeleton template files in the page/ directory of the template; and it just referenced a function. After a little hunting, I found out the correct way to add a new class in Magento – via the layout files.
If you don’t get the layout file concept of Magento, you really ought to look into it. I’m not here to enlighten you about that.
Anyway – you can add new body classes on a per module basis. So let’s say we want to give all the “my account” pages a body class of… account-control. This can be very useful to add a generic style across the board to each account page that is separate from the styling of the rest of the site.
You’d need to find the appropriate module block (I believe it is customer_account) and paste the following code in
-
-
<reference name="root">
-
<action method="addBodyClass"><classname>account-control</classname></action>
-
</reference>
-
That’s it! Make sure you refresh your cache if necessary, and refresh the account pages after logging into a user account. Check the source – an additional body class of “account-control” has been added!
I wasn’t as specific as I could have been about things in this article; let me know if you have any troubles and I’ll update as necessary for all you n00bs.
Cheers
December 29, 2009
So in my previous post, I’ve brought light to the fact that I shifted servers for my site, resulting in unexpected down time.
Why unexpected? My brash, unwitting decision to jump on the Rackspace Cloud Server service. Not to say anything poor or negative about it – being on the Cloud Servers has been a fun (wait for the keyword) learning experience. And with a little work, I got my site back up.
To do so, I installed some Plesk control panel software to manage my server, just like so many shared hosting sites I’ve been on! This time though; I have complete control over the server – full root access and the ability to do whatever I want. However, I don’t really wanna do too much besides get my site up and manage my domain!
So I’ll go over the steps and point you in the right direction to get your site setup on Rackspace Cloud servers as well, and give you the ability to easily manage your site using Plesk. I’m not gonna write things out for you though, so be warned – I’ll just go over the steps and point you in the right direction to the appropriate tutorials.
(more…)
December 16, 2009
But you may have not been able to reach me for the past few days.
Sorry about that – just had a few hiccups while moving my domain + hosting onto the rackspace cloud.
I was attracted to cloud hosting by it’s price and a previous positive interaction with Rackspace through a client. Naively, without much reading and a quick trigger finger, I purchased some cloud hosting.
Little did I know I was escaping my safe world of Panels and easy DNS administration – this was a little more complicated than moving some files around.
When you sign up onto the rackspace cloud, you’re literally portioned off a bare bones linux machine. You choose the distro; and that’s it. Everything else you have to setup yourself. A little daunting for those of us not totally comfortable setting up our own servers; not all developers are necessarily IT guys, and I certainly am not.
But as you can see, I made it out alive and am posting again! Will provide further details in a “5 minute” tutorial of how to get your website up and running on the rackspace cloud servers in no time!
December 11, 2009
For me, one of the most annoying things about Magento is the fact that the home page needs to be written in the Admin’s CMS. For that matter, any “custom” page you wanna build in Magento has to be done through the CMS.
I heart my text editors, and I hate writing HTML code into a CMS. It’s just not friendly. Tab indenting is impossible; if you hit tab your browser thinks you wanna select the next button! Think a textarea is gonna give you code hinting? Forget it!
Futhermore; I’m not a big fan of hosting files whose code I must edit regularly within the database. It’s just not practical.
Brad Frost recently blogged about the power of using Magento’s CMS blocks. I’m gonna take it one step further – let’s use the short code Brad Frost shows us in his blog to create custom pages that we can control through PHTML files in our theme; not code that is stored in the database. All you have to do is follow these steps:
- In the backend, create a new CMS page. Make sure to choose the appropriate layout (in the sidebar, click “custom design”) and enter in the page’s title, as well as it’s URL reference.
- Instead of writing your code in the textarea, stick this guy in there:
{{block type=”core/template” name=”yourPageTitle” template=”cms/custom/your-file.phtml”}}
- In the above line, replace “yourPageTitle” with your page’s title – this isn’t terribly necessary, but good practice.
- More importantly, replace “cms/custom/your-file.phtml” with the directory that your PHTML file will be stored within the template folder of the theme you’re using. I store all my files in the “cms” folder under the template folder, and I created a folder called “custom” to store all my custom PHTML files. You can do the same or choose your own path; whatevs.
And that’s it! Save the page within the CMS, write some code into the PHTML file, and you should now be able to visit the URL you specified and see the code you wrote OUTSIDE of the CMS!