Content or Images for Certain Pages

// July 19th, 2007 // Joomla

This neat little code snippet will allow you to target a particular article, and show content specific to that only.

One of the main problems Joomla! faces, is the fact that the $id variable, can be shared across a section, category or article. If you want the ability to change the image in the header of your template to suit a particluar article, this neat little code snippet will allow you to do just that.

In your index.php template, use the following code wherever you want the dynamic content to be:

<?php
$task = mosGetParam($_REQUEST,'task');
$id = mosGetParam($_REQUEST,'id');
if (($task != "section") && ($task != "category")) {
switch ($id) {
case 1; case 2; case 3;
echo 'This is content for my articles 1, 2 & 3';
break;
case 4;
echo 'This is content for my article 4';
break;
case 5;
echo 'This is content for my article 5';
break;
default:
echo'This is default content for any other articles';
}
}
else {
echo'This is default content for any other articles, or Sections & categories';
}?>

My case statements, ie: 1, 2 3 etc, are the "id’s of my news articles.

Enjoy!

Leave a Reply