Geshan's Blog

Jimmy Neutron ▲ Rocks. Geshan Manandhar's Blog,Diversity simplified.

Taming Drupal Node Teaser and Node Title

Friday, June 27, 2008
You might be wondering what is the use of this article / tutorial when Drupal system of handling title and teasers is so good and there are modules like node teaser to customize the teaser as per your need. But lets picture a scenario you are developing a website with a custom front page (required by majority of websites) so you have created your page-front.tpl.php and created a … panel kicking out your left and right sidebar selection and example below.
Now the problem is you can tell the people who create nodes to put a title of just five words or less and a teaser of 300 characters or less so what to do? If they put a node title of more than say 25 letters your design will be hampered so the solution is tame your Drupal title how is what you get below:

In your node.tpl.php (recommended node-content_type.tpl.php for better results)
The original code to render node title is something like below (I’m using Amor_Azul theme, just find the $title printed in your theme’s node.tpl.php):











Change it to or add:

Now the trick is if the page is Front page and the displayed content is teaser then I get the string length of the title of the node and if the string length is more than 25 characters I print … after it else I print the title. Easy it seems, I think the page==0 is for the full content display.

Ok time to tame the teaser for the front page, the original code for the $content is given below with the tweak:

Original code for content in node.tpl.php in your theme folder (I’m using Amor_Azul theme and recommend using node-content_type.tpl.php to try this)
Change it to:


So what did I do here?:-) Easy on it, in the content div I checked if teaser is being displayed in the front page if yes again the string length tweak as its content I used two hundred and ninety characters which suited my need. If teaser length was more than 290 I added … to the teaser else printed the teaser. In case it was not the front page and teaser the regular content was printed. Or the output for the above experiment that worked successfully is below:


Sorry for the code in pictures, code text here.

Some add-ons you can try, a problem may be what if the 25th character of the title is a space then it’ll display “title …” looking awkward so it can be handled. Another possible extension is adding link to the full node in the “…” in the teaser’s … (continued pointer). Well try out for yourself, if you tweak and get something interesting don’t forget to comment here.

Its been time I snapped Some Good Pictures

Sunday, June 8, 2008

I been a while I clicked some good pictures, but here are some I clicked some time back.


A year and half but petrol dismay continues...

Wednesday, June 4, 2008

Feb 10, 2007 – In search of petrol as my motorbike’s fuel status was in critical condition I reached a petrol pump. It was not a very good sight (See above picture) as at least I was behind 1 hundred or so motorbikes. After a long wait of around 2 hours I got my chance to fill valued liquid which was just enough for me for the next 2 week at the maximum.


May 27, 2008 - We are in the queue of more than 2 hundred motorbikes (See above picture) for around 3 hours and there is no sign of petrol being distributed to us till now. Employees of the petrol pump argue they can’t guarantee the distribution and they don’t know when the tanker carrying the petrol to be distributed will arrive. On top of it its load shedding in that area and it’s obvious that we will get to buy the fuel only after 9 PM when the light is back so as the run the pump to put the petrol in our machines. Meanwhile, the wait still continues the tanker arrived at around 8 PM but the distribution started at around 9:15 PM and when I got my quota and was back home the clock was already striking 10:30 PM. Well after wasting around 5 and half hours the ray of hope was at least I got some petrol for the next week or so.

The government I think has tried every trick in the book be it odd even numbers to give fuel, petrol diesel alternate days etc. But why isn’t there a clear plan in this shortage I don’t know. What are the responsible authorities doing for it is the biggest question? The media has highlighted this issue time and again but at the end we the common people always have to suffer. Just imagine the no. of human hours wasted in the line if there are 2 hundred people an at an average they spend 2 hours in the line 4 hundred productive hours are going waste. Who is to blame for it?

Our country and the so called would be “New Nepal” in two years or so is going through a very painful transition phase. There is shortage of everything water, electricity (we were in a state to encounter 42 hours of load shedding a week), fuel (diesel, petrol, kerosene and Air fuel) etc. The prices have skyrocketed in the past year or so and there is no sign of prices coming down.

Let’s hope things get on track very soon as 1 and half years is a very long time. With the patience let’s hope and pray we’ll get all necessary amenities like fuel, water, electricity, food supplies etc as soon as possible.


Around 460 Words,
Geshan Manandhar