Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Overriding the Default Styling, Drupal 7

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 100
    Comment on it

    Overriding the Default Styling

    Three approaches we can adopt to override templates in Drupal 7 Themes

    1. Overriding templates
    2. Overriding functions
    3. Converting themable functions into new template

    Theme Registry Plays a vital role while playing around with above three approaches. It provides the Drupal with a cached registry of information on the available functions and templates in theme, when we do any changes in templates or override and theme function or we have created a template we are required to clean the theme registry otherwise drupal wont show you the changes you have made.

    Clean Theme Registry

    1. Go to the Configuration Manager
    2. Visit the Performance page
    3. Select the option Clear cached data.
    4. OR, download the Devel module enable it, it will provide you on the very left hand side a HUT icon under which you will get an option Flush all cache that's it click it and you are done with `clean theme registry`.

    Lets Start with

    Overriding templates

    Steps to Overriding templates
    1. Create a duplicate template of one of the default template files and then place it in the active theme's directory
    2. New files will now be called instead of Drupal default file, Drupal will always display the template in the active directory rather than the default template.
    3. Do some custom changes to the code in the new template file
    4. Save the file
    5. Now Clear the Theme Register By following the above mentioned steps

    For example . The page.tpl.php file is solely responsible for the results that appear on the html pages in browser, Basically it defines the overall layout of a page of the site. Now what if you want

    To customize the user pages, By default Drupal will use the page.tpl.php file. and if we want a custom page to be displayed, we will need to create a new template named page--user.tpl.php and place it in the active theme's directory. Now, when a user clicks on the My account link, the system will display the file page--user.tpl.php rather than the Drupal default page.tpl.php file.

    Best Resource to understand is here About overriding themable output

    Please visit related Theming Blogs

    1. Overriding the Default Styling

    2. Overriding Theme functions

    3. Converting Themeable functoin to templates

    Thanks

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: