Create Node Template

drupal_branding_2012By default, all Drupal themes have a default node template. But you can create individual custom node templates based on the content type. Creating one is quite easy. Just duplicate the node.tpl.php file and rename it by adding the machine name of the content type i.e.

node–machinename.tpl.php

For example if your content type is Resources then the machine name will be resources:

node–resources.tpl.php

Please note the two hyphens that precede the machine name.

For further reading:

https://drupal.org/node/17565

https://drupal.org/node/1089656

April 28, 2014

Posted In: Information Technology

Tags: ,

Leave a Comment

Custom page.tpl.php Template

How do you create a custom page template based on content type for a Drupal 7 site? Simply start from the page.tpl.php, the Drupal default page template. The process of creating a custom page template involves:

  1. Renaming the template file
  2. Creating a pre-processor function
  3. Clearing cache

Renaming the template file

In this step, you add the machine name of the content type to the file name i.e. page.tpl.php:

page–content-type-machine-name–.tpl.php

Create Pre-processor Function

This function is placed in template.php as follows:

[php]
function themename_preprocess_page(&$vars, $hook) {
if (isset($vars[‘node’]->type) && !empty($vars[‘node’]->type) && ($vars[‘node’]->type == ‘content_type_machine_name’)) {

$vars[‘theme_hook_suggestions’][] = ‘page__’ . $vars[‘node’]->type;
}
}
[/php]

Replace the ‘themename‘ and ‘content_type_machine_name ‘with your own values i.e. the name of your theme and the content type respectively.

Clear Cache

Clear cache under admin/config/development/performance to allow for the reloading of template file.

April 23, 2014

Posted In: Information Technology

Tags: ,

Leave a Comment

Is WordPress in Trouble?

Another interesting post I discovered through the previous Reddit discussion I have posted on the most previous post. Is WordPress in a dire state?

http://jshak.es/the-dire-state-of-wordpress/

More discussion on the same issue by the same author of the above article:

https://news.ycombinator.com/item?id=5407879

Update (1:04pm EAT, 17th April 2014):

So what I’m getting from these discussions is that WordPress architecture really sucks. Well I’m not a pro WordPress developer but from what I’ve seen so far during my time customizing WordPress sites its true. Development and design should be separate but developers and designers usually access the same files. A recommendation by the author of the “The Dire State of WordPress” is that Automattic, the owners of WordPress, should adopt the PHP MVC framework to make the code base manageable  i.e. put functions and visuals separately. I will do more research on this and see how this can be adapted.

April 17, 2014

Posted In: Information Technology, Random Stuff

Tags: ,

Leave a Comment

Disable Drupal Admin Overlay

The admin back-end of Drupal 7 usually makes use of an overlay to display administration content. The overlay is an admin page that displays above the main web page, a way of reducing distraction and make it look ‘hip’; administration doesn’t have to be boring. But for my case it was a distraction because at times the overlay does not load after clicking a link. For instance, I was trying to rebuild permissions for node access permission but this action was rendered incomplete during the process because the overlay page did not load fully.

Solution: I simply disabled the overlay module under the modules page. The module is found under the core modules section. Of course I was able to rebuild permissions without a hitch. Some things are just good for aesthetics; but get rid of them if they do not offer any productive value.

March 13, 2014

Posted In: Information Technology

Tags: ,

Leave a Comment

Remove ‘Add Comment’ Custom Module

drupal_branding_2012One of the advantages of using Drupal as a CMS is the ability to extend its core functions using modules that can be either downloaded from the main Drupal site (contributed modules) or created locally/in-house for custom functions. It also allows for the creation of custom themes that can meet the needs of a client or the main users of the site.

I recently created a custom site for a client using Drupal as the foundation. The child theme I made was based on the Twitter Bootstrap theme and along the way I discovered that I needed to make use of the template.php (pre-processor functions) and custom modules to modify some core functions of Drupal. One thumb rule when developing any web project based on a CMS is to never modify the core files. This is because updates for the various CMSs come in every now then and its the core files that need to be updated. If you modify any of the core files two things can happen:

Continue reading Remove ‘Add Comment’ Custom Module

February 6, 2014

Posted In: Information Technology

Tags: ,

Leave a Comment

Is Twitter used as a DDoS tool?

It was heading to midnight when I received a mention on Twitter from my sister; I was just about to shut down my computer after working for almost 2 hours on a UI design. I found it strange that she had sent me a mention and yet we are in the same house and she had just said goodnight. What was more strange was the Twitter message that read, “haha this blog by you is nuts“, followed by a link of which I foolishly clicked.

DDoS Tweet
DDoS Tweet

You should know I am always conscious of security stuff especially cyber security. I guess I was too tired to think about it; I was just about to head to bed after a long day of running up and down.

On clicking the link, I was taken to a site that had a 500 server error message. On seeing this error a quick thought came into my head that this was most likely a DDoS attack. My guess is that either someone used my sister’s twitter account (hacked) to spread the link through the mentions feature or Continue reading Is Twitter used as a DDoS tool?

January 21, 2014

Posted In: Information Technology

Tags: , ,

Leave a Comment

Multiple Box Shadows in LESS CSS

Currently I’m working on a project that requires the use of LESS. It seems with every new project, I get to learn new things and its one of the reasons I enjoy web design and development. And while using LESS, my CSS code has become more clean, readable and manageable. So what is LESS? I won’t repeat how it has been defined by the creators of this dynamic stylesheet language. Find out more about it here. But in brief, its a CSS pre-processor that kind of makes CSS act like a real programming language, with help of Javascript.

/*VARIABLES - This section stores constants*/
@highlight-color:#fcd432;/*Main color - yellow*/
@color-base:black;
@main-color:#ffffff;
@font-base:HelveticaNeue, Arial;

An example of LESS CSS code

Continue reading Multiple Box Shadows in LESS CSS

December 19, 2013

Posted In: Information Technology

Tags: , ,

Leave a Comment

Text Rendering in CSS

Digging deep into CSS research as I worked on a site, I came across a new CSS feature called text-rendering. It basically helps in improving legibility of text (kerning improvements) and is actually an SVG property (not defined in any CSS standard). It has four values:

  • auto: allows the browser to choose a setting itself
  • optimizeSpeed: focuses on speed
  • optimizeLegibility: focuses on advanced rendering
  • geometricPrecision: precise rendering

Example:

.myClass { text-rendering: optimizeLegibility; }

Browser support for this property is not consistent but its not noticeable when used unless you’re a hawk eye :). I tried it out and actually just noticed a single word change its kerning upon refreshing the page. The rest of the text values didn’t change but this property is based on kerning.

Image showing kerning demonstration
Kerning. Source: Wikipedia

 

For further reading:

November 29, 2013

Posted In: Information Technology

Tags: , ,

Leave a Comment