Archive for June, 2009
Howto: Repackageable custom extension development in Magento – Part 9 – Frontend – List
Author: gaweee | Filed under: development, howto Frontend – List
Let us revisit our frontend controller. Surely by now you’ve gotten a better grasp of the controller and models. So we’ll be revisiting those concepts here. So lets say you want to allow users to view you current Twits as well as create a new Twit.
- Some new file structure loving
app/ design/ frontend/ default/ default/ template/ twit/ - twits_list.phtml etc/ modules/ - SavantDegrees_All.xml (Or what ever your company name might be) code/ local/ SavantDegrees/ (Or what ever your company name might be) Twit/ (Or whatever your module name might be) Block/ Admin/ - Main.php Main/ - Grid.php - Edit.php Edit/ - Form.php - New.php New/ - Form.php - Index.php controllers/ - AdminController.php - IndexController.php etc/ - config.xml Helper/ - Data.php Model/ - Twit.php Mysql4/ - Twit.php Twit/ - Collection.php sql/ twit_setup/ - mysql4-install-0.2.0.php - mysql4-upgrade-0.1.0-0.2.0.phpWe’ve added a whole nasty branch of subdirectories under
app/designs. Read on to understand what its all for… - Let us return to our
IndexController.php<?php class SavantDegrees_Twit_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->getLayout() ->getBlock('content')->append( $this->getLayout()->createBlock('twit/index') ); $this->renderLayout(); } }
Hold your horses, this code is EXACTLY the same as the Part 1. Its just a revision. However, that being said, we see that in Part 1, we made the system create a
Blockcalledindex. That’s an opening… - So let us modify our
index.phpblock:<?php class SavantDegrees_Twit_Block_Index extends Mage_Core_Block_Template { public function __construct() { parent::__construct(); $this->setTemplate('twit/twits_list.phtml'); } public function getTwits() { $model = Mage::getModel('twit/twit'); $collection = $model ->getCollection() ->load(); return $collection->getItems(); } }
What the difference here? We made the block load the template from
twits/twit_list.phtml. We can create/find this file in/app/design/frontend/default/default/template/twits/twit_list.phtml. Some explanation is due here:- When you say
setTemplatein the block, it means, use this file as the presentation/view - This file exists in the some subdirectory of
/app/design/frontend/default/default/template. That is the path to your default template. Even though you may have other templates, this is the default 1. So when Magento cant find your template file in the other template directories, it always reverts back to this folder. Its a directory form of inheritance/ancestory/precedence.
- When you say
- Lastly, the
twit_list.phtmlfile:<?php $_twits = $this->getTwits(); if ($_twits) { $count = 0; foreach ($_twits as $i=>$twit) { ?> <div class="twit"> <div class='name'><?= $twit->getName() ?></div> <div class='summary'><?= $twit->getSummary() ?></div> </div> <?php } } ?>Since the whole purpose of
twits_list.phpis to prepare the view for the list of twits, it obviously needs to get the data from somewhere. It turns out, theTemplateis the extension of theBlock. So by calling$this->getTwits(), we’re calling theBlock'sgetTwits()method. - There you have it! check your twits list at http://127.0.0.1/magento/index.php/twit
Hi all its us again, In the past few months we’ve been asked many a times to help improve the progressbar code. We’ve also been referenced by several websites as THE progressbar to use. In all, we felt we owed it to you guys to make it better.
So here we are, after all those emails and bug reports, we finally got down to it. Always good to take a couple of months to have a fresh prespective of things. We ripped out the old code and made it much better and more extensible than its predecessors. So much that we decided it was enough to qualify as a major revision.
Let see whats been done…
- Cleaned up the code, yes its lighter, cleaner faster. (Still lacks documentation though)
- Callbacks! Everyone’s favourite
- Max values, you can now set it to be 150/2000 instead of just a percentage
- Text formats. Show 75/100 or 75% by toggling the
textFormataccordingly - Steps, how many steps to get to your target value
- Step Duration, how long each step lasts
- Webkit (Chrome/Safari) compatibility. More like, Webkit Hacks
Once again, many a thanks for all those who have so generously provided the feature requests as well as bug fixes every now and then. And thanks for all your patience in waiting for this new release. ![]()
If its working for you, drop us a comment and tell us where we can see your stuff!
Download the new jQuery progressbar here: jQuery progressbar
or view the demo here
HOWTO: Find icons for your new prototype system
Author: gaweee | Filed under: development, howtoHaving a good UI is 30% of your customer won. No i dont know, 30% was completely arbitrary but absolutely believable. As such, please dont try to make those icons yourself! As all developers know, we try our best not to reinvent the wheel. Unless the wheel sucks and we have the budget, then we knock ourselves out. ![]()
So its time to share those little icon secrets! Where do you find nice icons!?
- famfamfam. If you dont know this site, you should be SHOT. Mark James spent good time making a fantastic set of icons so that everyone else could use them. Kudos to him!
- crystal iconsAnother awesome job done by Everaldo. Download link’s not working. Use this instead. Made primarily for the KDE workspace. Which brings us to my next point
- Any other Linux icons sources. These includes kde-look, tango, interfacelift, deviantart
- Iconfinder. Its new, its awesome and apparently they’re license-friendly! If everything’s as promised, they’re gonna kick some serious internet butt! We’re fans already!
- Ok we admit, sometimes we’re really tempted to use existing packages icons. Joomla has a really nice set.
All in all, plenty of icons. And if that doesnt work out. Go buy some from istockphoto and stock.xchng! They’re the pros for a good reason!
And a final word in licensing. Respect it. Not so much for the hard work, but more for the fact that designers can do what we cannot. Even if we tried, we probably wouldn’t have as much flair. Just like magicians.
In our work we like to create Google Maps links for our client’s (offices, stores, etc). However, the larger our clients presence, the more random links there are bound to be. When it comes to using Google Map’s javascript API to control the map, thats still perfectly fine. But how do I create a google maps link that only shows 1 entry? Turns out, there are several ways to do this:
- Manipulate the request such that it only shows your entryHow? For example, searching for “Holland, Singapore” will lead us to about 1,356 results. See here. So lets tweak it a little:
- Append
&mrt=ypto the url – That returns us all the business listings. (852 results) - Append
&start=16to the url – That skips the first 16 results (Shows results 17-26 of 852) - Append
&num=2to the url – That returns us only 2 results (Only shows 2 results)
For a more complete listing of Google Maps Parameters, consult mapki.com. Kudos to those guys for compiling that list. Really useful stuff
So there you have it, a simple way to link your business such that its the only entry there. However this method is relatively dangerous. Why? Cause you’ve got no idea of the exact ordering that Google maps may return. Today you could be entry 17, surely not in a year (hopefully for the better). As such, this is not the recommended solution. - Append
- Use the address with your long/lat coordinates to generate your entry.
- First get your GPS coordinates, there are a number of ways to do this. Check our this link
- Then create your link via the following structure:
http://www.google.com/maps?&ie=UTF8&hl=en&q=[urlescaped address]&ll=[GPS lat,long]&z=[Zoom]&iwloc=A - Still too troublesome? We’ve created a simple tool for our clients to use. Save yourself some time. Try it!
Done! Whats the downside to this? You can only show the address for the business. Because searching by business names returns us way too many results. So instead, we have to search for an address, Google interprets this as an address and only returns 1 result (which is the whole point of geocoding). At this point its easy to the map to what we need. We’d use this typically for this nifty little “Find us on a map” links (instead of embedding the actual map on your site).
Once again, if you’d rather embed Google maps directly into your site via the JS, then your options are much more open.
Good luck! Let us know if it works for you, of if you find a better way of doing things!

laying the cornerstones
Author: zwee | Filed under: entrepreneurshipAfter a few years of doing freelance consulting for Wit.sg, we incorporated a new company, Savant Degrees in February 2009. We have since been trying to get people on board. It wasn’t the easiest job to do. Yes, sure, there’s that part about getting sales, talking to clients who wants it their way (even though we are the consultants) and everything else, but hiring gives us the biggest headache.
Most people tells us that the current economy is bad and people are graduating right now. I hear all the time that it’s going to be easy picking someone out of that pool, but I totally disagree. It seems like there’s more noise from people that won’t fit in our company. We were discussing about it one day and was told by one of the new guys that we were picky and we had to be realistic. “Who starts work the same day they finish their exams?”, he asked. The entire team raised our hands.
People
I learned that most fresh graduates look forward to that so-called graduation trip. Most of us in the company graduated twice from a polytechnic then college, and both times we dive straight into work. Perhaps we were a little different, perhaps we are weird. We all agreed that it takes someone a little different to work in a start up. Someone who wants to do something to leave behind a legacy. I started thinking about it and noticed a few things about us.
Insanely optimistic
We have to be. We gave up cushy job offers, Ivy league school offers, inheritance and other more certain opportunities to be here knowing we can get more. Can we finish 3 projects in a week. Yep sure. Can we do something better than the bigger boys. We’ll beat them. Of course, there’s a thin line to thread between being optimistic and being delusional and we make sure we don’t cross that line.
“next working day”
Where “next working day” is literally the next day. Our social and work lives becomes intertwined and colleagues become friends and vice versa. Even without overtime pay or big bonuses, we get people here on Sundays. The average sleeping time of the team is probably 6 hours. I figured it’s the waking up to something bigger than ourselves that gives us that boost. Also, hanging out together so often gives us time to bond and plan for crazy stuff like booking fifty tickets for Wolverine opening night where we got all our friends together. Nothing beats having a mass movie hang out for one of the best 2009 movie.
Penchant for DIY
When we first got our office, every one started playing music and very soon it becomes a cacophony of songs and discussions. We wrote a jukebox with an unbiased(sometimes i doubt it) queuing system tied to the main speakers. We are engineers at heart and we like to solve problems, big or small. Visit t.wits.sg and you might get some of our gems and great products we use in the office. We wrote it, we use it and we will made sure it’s good.
Guns, guitars and wolverine
Before we moved into our office, we knew that this will be our second home, and we rightfully made it so. Big screens, big tables, comfortable chairs and the lot. We started bringing stuff from home to the office. Piano, guitars, weights and personal mugs. Stuff that makes a place a home. Stuff that gives us a little fun once in a while. That said, every one in the office gets a nerf air gun when they join. It’s just not safe without one when there is a gun rack and the occasional all-out nerf gun war. Perhaps a little work culture is forming, a culture that will give us that energy and drive to strive for more than we should and to challenge the status quo. One of the reasons why we want to work in our own start-up is so we can have the opportunity to work with smart, excited and motivated people. The people that will constantly challenge us to make things that we are proud to use and potentially make a positive difference. With that in mind, we told our new guy, we will continue to be very selective about who gets on board.

Most Popular
- HOWTO: PHP and jQuery upload progress bar (47)
- JQuery Progress Bar 1.1 (41)
- Howto: Repackageable custom extension development in Magento - Part 2 - Admin Controller (24)
- Howto: Repackageable custom extension development in Magento - Part 8 - CRUD - Update (13)
- HOWTO: struts 2 i18n (12)
- JQuery Progress Bar 2.0 (11)
- JQuery Progress Bar 1.2 (10)
- Howto: Repackageable custom extension development in Magento - Part 3 - Database (9)
- Howto: Repackageable custom extension development in Magento (8)
- Howto: Repackageable custom extension development in Magento - Part 5 - CRUD - Retrieve (6)
Recent Comments
- donald: Hi Wen, I have checked out
- donald: Hi Ashley, Currently, I simply use
- donald: Hi Noemi, there are many
- Serge: Thanks a lot. It's the simplest
- Zoran: Excellent posts you got here...
- Craig: Brilliant tutorial! There's NOTHING on
- Will: Thnak you! I was
- Margots: Thank you a lot for
- Aswin S: Wow great dude.. For the
- Noemi Heier: This is great! How did
Latest Entries
- jQuery Progress Bar Configuration
- Extracting email addresses from inbox
- 10 Good (Free and Legal) Source for Photos and Images
- Howto: Backup Microsoft SQL Server Database, as in Dump it to a SQL Script (like MYSQL's sqldump)
- Managing client's expectation with wireframe software
- Howto: Repackageable custom extension development in Magento - Part 9 - Frontend - List
- JQuery Progress Bar 2.0
- HOWTO: Find icons for your new prototype system
- Google Maps Helper
- laying the cornerstones
