Page Lang

You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Two years ago I created a module to increase the relevance of my webistes/pages for search engines, using SEO techniques.

This module doesn't increase the general relevance, but increases the relevance in a particular country without changing the relevance elsewhere. For example, if you have Spanish schools in Canada and your clients are Canadian you have to specify some code in the header of your page such as “en-ca”.
Normally this sets the language, but the search engines also take into account the country. This is good for multilingual businesses, such as language schools that have clients from all around the world, but for a school in Spain it's easier to teach Spanish to clients from Europe.
In the same way for a South American school it's easier to offer Spanish courses to North Americans. That's why you have to change these parameters.
In drupal you only could change the language with the variable $language. This module Page_lang changed this.
With the arrival of drupal 6 I was invited to update the module for the new version of drupal but it didnt make much sense as there already exists a way to obtain the same results with the modules cck and contemplate. Here I want to explain how by using these two modules you can acheive the same results.

First install the modules contemplate and cck. You can find them at:
http://drupal.org/project/contemplate
http://drupal.org/project/cck

respectively

Once these have been installed, activate the modules Content Templates, Content and Text of CCK go first to
Administer – Site Configuration – Content Template Settings

tick
Remove $nove – Content from variable list

and save the configuration. Then go to:
Administer – Content Type - mange fields of the page or story that you wish to control.

Add a new field:
Label: Page Lang
Field name: page_lang
Type of data to store: text
From element to edit the data: text field

Save and your are taken to the configuration page where we put
size of Text 7 and save again.

Go to Display Fields and in our Page Lang we select the two options which are “exclude”.
This will ensure that it will not appear on the article unless we write it expressly. We also can exclude RSS, if we want to.

Choose Create template for the type of content you wish to create, for example “page”.

Go to the menu in the template window and open the file page.tpl.php

In the first file of the file there is a line that begins:
language

Change this to:

if($node->field_page_lang[0]['view']){print $node->field_page_lang[0]['view'];}else{print $language->language;}

With this you specify a value for the article, with a fallback to the local system default.

You can find further information about this subject at:
http://www.sismo.info/iso/3166.asp
http://www.sismo.info/iso/639.asp