Adding a Static Block in Magento

29 08 2009

Static Blocks are a great way to display banner ads notices or any  html content on various pages,

Its also fairly easy to work with.

1) Create the Static Block by going into CMS / Static Block and put your html content there. and give it a unique identifier like ” mybanner” or something like that.

Now if you want to add the banner within an CMS page that you simply need to write the following code to diplay the block there

{{block type="cms/block" block_id="mybanner"}}

However if you want the static block to be a part if your header or left column or the right one then you’ll need to go in an change the respective .phtml file

Say you want the static block on the left column then

Locate the left_col.phtml file it should be at this path

/app/design/frontend/default/default/template/callouts/left_col.phtml

open it up and add the following line where ever you want to display the block

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('mybanner')->toHtml() ?>

That should do the trick.
Oh and make sure you have Cache Disabled  all this while, otherwise its like banging your head against a brick wall !!
System > Cache Management




Handy commands for a Linux Administrator

21 06 2009

Recently I had to SSH into one of our servers to try and fix a pesky little problem and I realized I was quite rusty  so I thought I’d put together a list of commands that would come in handy These are for a Fedora Box so Debian guys please excuse me for now

The basics or starting and stopping things

Apache

service httpd start
service httpd stop
service httpd restart

MySQL

service mysql start
service mysql stop
service mysql restart

Reboot the  server

reboot

Check the server load

uptime you can also use top.. but I prefer using uptime

View all corrently running processes

ps -aux or ps -ax

Kill a SQL query thats running very slow

mysql
mysql>show processlist; # Identify the ID of the query that's slow
mysql>kill 133 ; # where 133 is the ID of the slow query

These are commands that I needed to use I’ll keep updating it with commands that I need to use often.

This by no way is a complete list of commands that an Administrator should know.





Check for Slow Running Queries in MySQL

21 06 2009

While building applications for high traffic sites, making sure your queries are optimized is a very important step..  Even a single bad  query can lock up your database and bring down the entire server

Here are a couple of ways to check for such Slow queries.

1)  If you have Graphical interface available on your server then you can install MySQL Administrator

After installing Launch MySQL Administrator. Select Startup Variables from the Left Pane. Go to the Log Files Tab and Activate Slow Queries Log . Once its enabled all the queries taking more than 10 seconds would get logged. Obviously you can change that value to whatever you thing is slow for you.

To view this log

Select Server Logs from the left pane and then Go to the Slow Query Log tab which should give you a real time view of the ‘bad’ queries that are slowing down your server.

However in most cases you would be remotely managing a Linux server and SSH would be your only way to get in.

If that’s the case, then the nicest tool that I found was mytop a really sweet console based tool that gives you a list of the slow queries.

There were talks of mytop being available as an RPM so if you are lucky, a

yum install mytop
or

apt-get install mytop

should work for you.. However when I last tried, it didnt work for me so I had to do it the hard way ;-)

Luanch Putty or any other tool that you use to SSH into your server

and starting firing away at these commands

wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz
tar -zxvf mytop-1.6.tar.gz
cd mytop-1.6
perl Makefile.PL
make
make test
make install

If everything goes fine..  type in mytop to launch the application.

Now some of you like ‘moi’ might get the error message while trying to launch mytop

Error in option spec: “long|!”

To get rid of this we’ll need to comment out a line …so on the console type in

pico /usr/bin/mytop or gedit /usr/bin/mytop
Search for a line that says “”long|!” => \$config{long_nums}” and comment it out.. ( I have no idea what that line does anyways)

After you’ve done that save the file and relaunch mytop and hopefully you should see a constantly updating  screen of slow queries.

Hitting q should bring you back to command prompt.

So now you are set to fix up all those queries that are messing up your server.





Magento Templating Jumpstart

12 06 2009

This Article has move to a new location:

http://www.vinznet.com/index.php?id=99





Changing the default boot selection from Ubuntu to Windows

16 11 2008

After installing Ubuntu with Windows the first thing that you’ll notice is that Ubuntu is set to be the default boot option so if you don’t manage to select Windows within 10 seconds the computer will boot into Ubuntu.

Now if you are a full time Ubuntu user then thats cool, but if you mainly work in Windows then this could turn out to be quite annoying, and hence it makes sense to make Windows as your default boot.

The way to do that is as follows:

The Starting  Boot sequence usually shows

  • Ubuntu
  • Ubuntu (Recovery mode)
  • memtest
  • other operating systems:
  • MS Windows XP

Boot into Ubuntu and open up the Terminal window. You can find it here

Applications > Accessories > Terminal

and type the following command

sudo gedit /boot/grub/menu.lst

This should open up the menu.lst file in gedit (the default text editor  on Ubuntu)

Locate the line where it says

Default 0 and change it to Default 4

The reason you need to say 4 even though Windows XP is the 5th item on the boot sequence  is because the numbering starts from 0

Once you’ve made the changes.. save the file and Restart and you should now see that in the boot sequence, Windows XP should be selected by default.






Installing Ubuntu was easier than WinXP or Vista.

9 11 2008

Ok, I’m sure many of you have probably not heard that statement before. The first thing that comes to your mind when you talk about installing Linux is driver incompatibility and non availability of drivers for Linux.. The Linux community have been working real hard on this, and I think with the Release of Ubuntu 8.10, things have changed now.. I found  its now a lot easier to install Ubuntu than Windows even for first timers like me..

Here is a brief rundown of what I went though while trying to install the different OS..
I was keen on buying the Compaq CQ60 101 AU, which is kind of a regular laptop with an AMD processor, Nvidia Graphics card and Atheros Wireless. People at the store made it clear that it would not run WinXP and I’ll need to run Vista on it.. I was keen on giving Ubutntu a try and was kind of skeptical.. if this laptop can’t run WinXP then probably getting Ubuntu to run is going to he really difficult. Searching and posting on the Ubuntu forums didn’t quite help. While inquiring with friends, Tushar Mahajan a good friend and colleague (..a linux fanboy..his email goes as tushar.iuselinux@…com) was very confident in saying “.. even if Vista or XP doesnt work.. I’m sure Ubuntu will work..” I thought that was kind of impulsive and arrogant on his part.. Nevertheless I did take the risk and bought this one..

With the laptop in hand I decided to take the safer bet and went about setting up Vista..
Things went pretty fine, everything installed and running except for the Nvidia graphics drivers. The HP site had the drivers.. about 140 MB of download, which I tried downloading multiple times over a period of 2 days, but the downloads speeds were terrible, things kept timing out and the damn server didn’t suppose resuming. I hopped on to the Nvida site and tried to download the ones I thought were right for my card.. but Vista/Nvidia didnt think they were right.. kept getting a message couldn’t find the hardware for the selected drivers. I never managed to get the graphics working.. and after about 2 days of Vista.. decided to give up.

Next tried the old faithful Windows XP. A technical guy at the store helped me get a XP  version of the drivers.
After installing XP, it didn’t pickup the drivers for any of the hardware. Even after pointing the hardware wizard to look into the right folders on the Driver CD it couldn’t install anything.  At the end I had to point the wizard to the respective .ini files, and manually select what drivers that it should install. Doing that for each of the hardware, I finally managed to get XP working fully. There were still some glitches though like the wirefless icon continued to show disconnected even when I’m  connected to the net and surfing. Other than that things were fine. This took me about a day to get up and running and then another couple of hours to install the software I needed. ( this doesn’t include the time spent in searching for the installation Cds and downloads)

Finally I tried to install Ubuntu 8.10 on a partition I had kept aside for it.
After burning the .iso onto the CD I gave Live CD a try, it took over 5 minutes to get to the login screen with a whole bunch of i/o read errors.  Hoping for the worst I went ahead and  installed Ubuntu, things went very smooth and after the install I was pleasantly surprised to see that audio, wireless and pretty much everything else was working great, as usual Nivida wasn’t working. A quick search on the ubuntu forums suggested I should try to do an update and then restart, which I did, and lo after the restart, Nivida is working,  so here I have a laptop up and running  on Ubuntu in under 2 hours and I didn’t even have to open up the Terminal window. Surely things have really changed in favour of Ubuntu and open source software. The best thing is after installing Ubunutu you already have all the software you need, Open Office, Firefox, Gimp, Pidgin, and  you can get to work right away. Installing other things like Thunderbird,  or other software is a breeze through the Synaptics Package Manager, no need to visit all those different sites and download their software individually or hunt for installation CDs.

So hats off to the Ubuntu Team and the Linux Developer Community, you guys have a winner….. em atleast until Windows 7 comes out, but I’m sure you’d be way ahead by then.








Follow

Get every new post delivered to your Inbox.