extensions.Siliana.com

Home arrow shCustomTags arrow Documentation
Please make a small donation
(big donation ok too)
Article Index
Main features
Changelog
Installation
Operation

2 - Operation


FIRST the module rewrites TITLE, META DESC, META KEYWORDS and META ROBOTS tags in your header. They will be replaced, respectively, by the content of :

$shCustomTitleTag,
$shCustomDescriptionTag,
$shCustomKeywordsTag
$shCustomRobotsTag

These variables are declared as global by the module. You can just set them anywhere in your code if you can PHP a little bit.
In order to avoid modifying existing components to set these variables, you can write your own plugin for building these title, description and tags as you wish. Just like you can write a com_mycomponent.php in sef_ext directory for URL rewriting, you can write a com_mycomponent.php and put it in modules/shCustomTags directory. shCustomTags will include your plugin, and the title, desc, keywords and robots tags eventually will be automatically placed in the page.
The purpose of the plugin is to programatically build those 4 variables. Included with the module is tags plugin for virtuemart. I suggest you look at it if you want to modify the way the page title is set. It will also serve as a model if you want to write a plugin for another component. If you do so, I would appreciate you send it to me, for inclusion in next release.

SECOND the module will look for a manually set up tags list. A tag list is simply typing in a text file the TITLE, META DESC, META KEYWORDS and META ROBOTS tags you require for any given URL. The tags definition found is this file will replace those obtained through the plugin system, so if there is something you can't do with a plugin, you can set it up manually here.
The file is modules/shCustomTags/shHandCustomTags.php. Open it up in a text editor. There is a sample custom tags list, for one URL. Just copy the same 6 lines over and over, adjusting data as needed. For instance:

$shCustomTags[] = array(
'nonSefURL' => 'option=com_content&task=view&id=strong>2&Itemid=8⟨=fr',
'title' => 'My own title',
'descMeta' => 'my own description',
'keywordsMeta' => 'my keywords, one more, and another one',
'robotsMeta' => 'nono, le petit robot'
);
$shCustomTags[] = array(
'nonSefURL' => 'option=com_content&task=view&id=6&Itemid=8⟨=fr',
'title' => 'My own title number 2',
'descMeta' => 'my own description number 2',
'keywordsMeta' => 'my keywords, one more, and another one, and one more',
'robotsMeta' => 'nono, the small robot'
);

Please note that you should not copy the line before and the line after the sample (those with ---------------- in them), they are just here to prevent the sample to be processed

LAST, the module will apply replacement rules set in the module parameters, in the backend.
For now, you can set up three rules per page. Each rule has the following parameters :
- a 'new' text
- an 'old' text to look for, which will be replaced by the 'new' text above
- a select list for the replacement method, which can be:

  • insert in head : no replacement here, the 'new' text will simply be inserted in the head section of the page. Useful for inserting javascript file r css file links in head section of page, for XHTMl validation.
  • Replace first occurence of tag : shCustomTags will search for 'old' text and replace the first occurence only by 'new' text
  • Replace all occurences of tag : shCustomTags will search for 'old' text and replace all occurences by 'new' text
  • Output as regular module : 'new' text will simply be output as normal text. Really useless!
  • perform a preg_replace() : shCustomTags will perform a preg_replace(old_text, new_text) on the page


Please also note that:
- you can publish the module only on those pages that requires it
- you can also make several copies of the module, and have various replacement rules based on the current page.

Note on languages for VirtueMart plugin: shCustomTags works hand in hand with my URL rewriting component sh404SEF . For this reason, I use the same language strings in the Virtuemart plugins that sh404SEF, in order to have the exact same strings in URL and title, description,... The drawback is that I have only done four languages : French, English, Spanish and German. If you feel like helping, you can supply translation for other languages. Look for /modules/shCustomTags/sh_vm_lang.php.

Jozsef Tamas Herczeg has already contributed an Hungarian translation, included in the module.

 



 
Advertisement