PHP

Drupal Themes in Relation to Templates and Engines

Drupal can use four different types of engines to render themes: PHP, PHPTAL, Smarty, and the default engine, PHPTemplate. Engines are interface libraries, like DLLs in Windows or other libraries you’ve seen used to prevent having to write the same code over and over. Themes are a folder made up of CSS style sheets, images, and so on, but they also contain the template file. The template file typically contains large portions of HTML with small snippets of PHP which get replaced by dynamic content. The syntax of the PHP in the template file depends on the engine being used.

You can tell which engine is being used by the extension of the template file:

Template File Extension

Theme Engine

.theme PHP
.tpl.php PHPTemplate
.tal PHPTAL
.tpl Smarty

Be the first to comment - What do you think?  Posted by administrator - February 5, 2011 at 9:58 am

Categories: PHP   Tags:

How to Version CSS Files with a Query String to Prevent Cached CSS Use

How to force a browser cache refresh using a CSS query string

Have you ever seen a ‘d’ query string on a CSS link in HTML source code and wondered what it did? The ‘d’ is mostly just a semantic way of describing the parameter that follows it, which is the date. The web server will ignore the string because it isn’t programmed to understand it, but it allows an easy way to cause browsers to think that the CSS file has changed thereby forcing a cache replacement.

<link href="/style.css?d=20101204" rel="stylesheet" type="text/css" />

The only downside is that each time the CSS file is updated, the parameter, which in the above example is a date string, has to be updated. Depending on the software you are using you can use tags to automatically change the date.

How to automatically version the CSS file for cache refresh in WordPress

In WordPress you would use the ‘time’ template tag after the ‘d’ query string like this:

<link href="/style.css?d=" rel="stylesheet" type="text/css" />

Thanks to Stack Overflow for the tip. Some call this the “Expires or Cache-Control Header”.

Be the first to comment - What do you think?  Posted by administrator - December 4, 2010 at 8:00 am

Categories: CSS, HTML, PHP   Tags: ,

Plug-In PHP: 100 Power Solutions

Book with 100 ready-to-run PHP plug-ins you can use to create dynamic Web content: Plug-In PHP: 100 Power Solutions: Simple Solutions to Practical PHP Problems.

Read more...

Be the first to comment - What do you think?  Posted by administrator - October 21, 2010 at 6:31 am

Categories: PHP, XML   Tags: , , ,

How to Use a Query String in PHP

Learn how to pass variables to a PHP web page using the query string, and how to access the variables from that page. Once you know how to pass information between pages with the query string parameter and how you can add some increased interactivity to your web page using PHP. There are a lot of other uses, such as selecting which section of a site to display based on a variable in the query string and processing form data.

Read more...

1 comment - What do you think?  Posted by administrator - September 17, 2009 at 9:05 pm

Categories: PHP   Tags: , ,