December 30, 2009

Magento – Adjust the HTML Body Class of your pages via Layout XML

Filed under: Interweb, Magento, Tutorials — Tags: , , , , — sankho @ 2:49 am

magento_logoWhen 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

  1.  
  2. <reference name="root">
  3.   <action method="addBodyClass"><classname>account-control</classname></action>
  4. </reference>
  5.  

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

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter

December 29, 2009

Setting up your website on Rackspace Cloud Servers – Manage Your Own Hosting

affinity-strengthen-link-with-rackspace-187lrgSo 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…)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter

December 11, 2009

Custom Magento Pages using your Text Editor, not the Admin CMS

Filed under: Interweb, Magento, Tutorials — sankho @ 1:29 pm

magento_ecommerceFor 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:

  1. 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.
  2. 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”}}
  3. In the above line, replace “yourPageTitle” with your page’s title – this isn’t terribly necessary, but good practice.
  4. 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!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter

July 28, 2009

Wordpress 2.8 Media Upload Issue

Filed under: Interweb, Tutorials, wordpress — sankho @ 11:16 am

Gotta love that Wordpress. It seems like instead of doing a real, thorough QA, they rely on us to bitch and wine when shit doesn’t work until a.) one of us figures it out, or b.) we complain enough until they figure it out.

Then again, at least it’s a pure open source solution, unlike those greedy bastards at Varien who decided Magento was worth more than the price of a growing community.

But again, I digress.

So, are you among the dozens in this post that can’t upload their images after installing the new Wordpress v 2.8?

Me to. At least I was until I figured out a small solution. I commented on the above post with the information below.

In the wordpress admin, go to “settings,” then “miscellaneous.”

The first input field should be for the directory to which you store your images… for me it was the absolute path to my wp-content/uploads directory so it looked sort of like this

/a/lot/of/directories/until/blog/wp-content/uploads

And that was the error… simply replace whatever is in those fields to

wp-content/uploads

Notice there is no backslash at the beggining! As long as you’re storing your files in the same directory as any normal wordpress user, this ought to work. Basically the trick is to not use the absolute path to the folder and just use whatever folder is under the main wordpress directory.

Make sense?

If this hack manages to work for you, let others know! Or, if it didn’t, let me know so I don’t feel so good about myself (this can be accomplished with numerous other approaches as well).

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter

June 24, 2009

Add Facebook Connect to your PHP Web App

Honestly, it’s pretty easy to do. But when searching for documentation, it wasn’t easy to find exactly what I wanted to do, so I figured I should blog about it.

What I needed was a way to easily connect my existing web application with facebook connect. What’s Facebook Connect? In a nutshell, it allows users to log in and register to your site via their facebook credentials. Here’s some more in – depth detail if you’re looking for more information; this tutorial assumes you know what the deal is with Facebook Connect and want to get it onto your application soon.

I added facebook connect to a site running PHP and using MySQL for the database; this tutorial assumes you will be doing so as well. I used Facebook’s PHP API to connect my site, and the same goes with that. If you’ve ever build a facebook application before, you’re familiar with Facebook’s API.

The last assumption I make is that you have already built a site with a full user login system, your site allows cookies, and caters to javascript enabled browsers. Basically, you built this site of yours after 2002 or so.

After the break we’ll get to it.

(more…)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter

January 3, 2009

A Simple HTML Tip – Link to Images Without Annoying Borders

Filed under: Interweb, Tutorials, iPhone — Tags: , , , , , — Sankho @ 11:12 am

I was working on a site recently and a client wanted an image linked to a feedback form. But everytime I linked an image, it gave a nasty blue border around it! Check below the break for the simple tip!

(more…)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter

December 29, 2008

Make Custom iPhone Ringtones via iTunes

Skip the boring stuff, and figure out how to make ringtones here.

A few years ago when my friend got some fancy smart phone, I was immediately jealous of the fact that he could easily use his MP3’s as ringtones. As a (barely) post adolescent with a need for musically identification, the ringtone market for phones sucked. I was lucky enough to have M.O.P.’s “Ante up” as my ringtone for a few years. It generated a lot of dirty looks, but I was never able to find another ringtone that was quite as obnoxious. The jealousy incurred upon hearing my friend’s phone play 2Pac’s “I aint mad at ya” was depressing to say the least.

(more…)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter

December 17, 2008

Tutorial: Using Zend_Captcha_Image

Update – check out the post at AmpTools, if you’re using a copy of Zend Framework version 1.7.8 or above – the below code may not work for you.

—–

Recently on a project I was developing using the Zend Framework, I needed to validate a form using a CAPTCHA image.

CAPTCHA example image

CAPTCHA example image

For those who don’t know, CAPTCHA stands for Completely Automated Public Turing test to tell Computers and Humans Apart. Ever been to a website and seen an image like the one to the right? Basically, it’s a way to make sure a human is filling out the form and not just some robot. How? Robots can’t decifer what words *might* be from an image – only a human can.

Zend Framework has a set of great classes included to take away a lot of the headaches involved with setting up a CAPTCHA system. The one I use is Zend_Captcha_Image, which creates an image for you and sets up a Session so you will be able to validate all information appropriately. Problem is, there’s little documentation out there on this.

The best example I found was on Robert Basic’s Blog. My only gripe about it was that it used Zend_Form.

Zend_Form is a great class and all, but if you’re like me, you don’t like using it because you give up the control you get over Form creation + validation. It’s a great way to skip writing HTML for a form – but what if your client wants a very specific design attached to their form? Then Zend_Form becomes a hassle to design to a specification. And yes, Zend_Form makes validation easy, but what if your client wants to set up very specific validation messages? Again, Zend_Form becomes more trouble than it’s worth. Yes, it is flexible enough as a class to edit it any way you want, but I feel NOT using Zend_Form will ultimately make your forms more flexible.

So, beyond the break, I’ll show you everything you need to know to use Zend_Captcha_Image WITHOUT Zend_Form! If you’d like to learn the implementation using Zend_Form, please visit Robert Basic’s Blog.

(more…)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter