Skip to main content

Blogs

$("a[rel^=lightframe]").each(function() { $(this).attr("href", $(this).attr("href") + "?format=simple");
});
Lightbox.initList();

There may be instances when you want to show sample XML code on a web page. I'm referring to the raw XML code with any and all markup intact. When the browser believes that the entire page is an XML page (because the page begins with an XML declaration), it will usually do the right thing and display the XML. If, however, you have the XML on an HTML page, the XML markup will be read by the browser instead of displayed.

For example, here is some sample XML data:

<?xml version="1.0" encoding="ISO-8859-1"?>

Aliya
Yasir
Note
Hello!

If you put these lines in an HTML page, they will not display correctly because they look like markup code. Without any modification, they will look like this:

<?xml version="1.0" encoding="ISO-8859-1"?>

Aliya
Yasir
Note
Hello!

The fix is pretty simple. Replace all instances of the open bracket and close bracket with their corresponding HTML character entities, e.g. < and >. After doing so, the HTML should look like the following:

<?xml version="1.0" encoding="ISO-8859-1"?> <text> <to>John</to> <from>Ed</from> <heading>Note</heading> <body>Hello!</body> </text>

When the above HTML is displayed in a browser, the character entities become brackets and the XML data will display correctly. If you do a view source on this web page and look at the first block of XML code above, you will see that it displays correctly because it is using character entities!

When you have a lot of code to display, you may want to use your favorite text editor to search and replace all instances of < and >.

This article is for web-developers who are interested in creating their Drupal themes. It would tell you how to create themes for different content types. As a bonus, you’ll get know how to create theme for an individual page (the default theme will be used for other site pages). Let’s start!
Theme for content type

Usually a few content types are used for Drupal-based site. And every content type should have unique appearance. There is pretty simple solution for this.

Open folder containing the default theme for your site and create the following file there: node-{type}.tpl.php

where {type} – is name of the required content type.

View the folder. You will see node.tpl.php file there. It is the default file which defines the standard appearance of every content type.

Copy content of node.tpl.php to node-{type}.tpl.php and modify it according to your needs. From now, content of the specified content type will appear according to node-{type}.tpl.php.
Theme for page

Sometimes you may need to change theme for some page on your site (for example, http://site/my/page). And other pages should use the default theme.

Open the folder which contains theme for your site and create page-my-page.tpl.php file there. So, name of the created file must consist of page-{next_argument}-{next_argument}.tpl.php.

Than copy content of the default page.tpl.php file to page-my-page.tpl.php and make the desired changes.

Attention! You should use system URL for the page. Make sure that there are no aliases there.