I'm sending these tips I use on my site in the hope you could find them useful. Maybe someone could tell better ways to do these tasks as well.
------------
Per page meta tags with no hacksFor good search engine ranking is vital to be able to change meta tags on a per page basis.
In XOOPS it is possible to change meta-tags and page title with few lines of smarty code in "theme.html", without php coding.
All we need is to check the first 4 characters of the smarty variable
$xoops_pagetitle.
$xoops_pagetitle holds the current page title that may change depending on the module you are using (eg: News module 1.0 puts just the module name in $xoops_pagetile, but News 1.2 fills the same variable with module name, news topic and title). But what all modules do is placing the module name as first thing.
All we need to do is to modify few lines inside the "head" tag in your theme.html.
Look for:
<meta name="keywords" content="<{$xoops_meta_keywords}>" />
<meta name="description" content="<{$xoops_meta_description}>" />
Replace with:
<{if $xoops_pagetitle|truncate:4:""=="NewB" }>
<meta name="description" content="This is the meta description will appear if you are in the NewBB module." />
<meta name="keywords" content="meta, keywords, for, newbb, forum" />
<{elseif $xoops_pagetitle|truncate:4:""=="News" }>
<meta name="description" content="Here we are in the news section." />
<meta name="keywords" content="we, love, news" />
<{else}>
<meta name="keywords" content="<{$xoops_meta_keywords}>" />
<meta name="description" content="<{$xoops_meta_description}>" />
<{/if}>
What we do is checking the first 4 characters of $xoops_pagetitle variable and serving different contents depending on the module the user is browsing. This is not a per-page solution, but at least each modules may have their own meta tags. Obviously you may also change the page title for each or some modules adding the "title" tag in each if/elseif clause.
Note: Actually, with the same trick you may serve completly different layouts for each module! But I don't know if this is good for your server performances.
Important!!! Depending on your XOOPS setup and language the module name may change! Eg: this site's forum is named "Support Forums", so the first 4 characters we need to check would be "Supp" (and it should be case sensitive).
------------
"Read More..." anywhere in news bodyThis trick probably is not needed anymore with the latest News Module releases, but as long as XOOPS 2.0.7 comes with news 1.0 I think you may find handy this trick. No php hack required.
In your news_item.html template add wherever you want the following code:
<{if $story.morelink|count_words > 2}> <a href="/modules/news/article.php?storyid=<{$story.id}>">Read more...a><{/if}>
This basically checks the number of words in the $story.morelink variable. If this number is greater than 2 means that "more text" is present for that news and "Read more..." text is displayed.
Important!!! The number of words you need to check may vary depending on your language. You need to check the number of words the "comments" text in your language is formed by. The formula is: 1+(number of words the "comments" text is formed by). Eg: If you use "comment this news" the number of words you need to check is: 4.
------------
New PMs in any blockThe following code may be used to show in any PHP block the number of new private messages any user has.
global $xoopsUser;
if( $xoopsUser )
{
$pm_handler =& xoops_gethandler('privmessage');
$criteria = new CriteriaCompo(new Criteria('read_msg', 0));
$criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid')));
$pm = $pm_handler->getCount($criteria);
}
if( $pm )
{
echo "/viewpmsg.php" title="Read your new Private Messages">Private Messages ($pm)n";
}
else
{
echo "No new Private Messagesn";
}
The block must be a
PHP block.
------------
Google AdSense strage behaviourI noticed that if I set the news module as the homepage module sometimes AdSense is not able to show advs, but if I point explicitly to "http://sitedomain.com/modules/news/index.php" Google always feeds the banner correctly.
If you have this same issue you need to make small change in
/index.php.
Search for:
header('Location: '.XOOPS_URL.'/modules/'.$xoopsConfig['startpage'].'/');
Replace with:
header('Location: '.XOOPS_URL.'/modules/'.$xoopsConfig['startpage'].'/index.php');
Now AdSense works like a charm. This issue probably comes out when your site is not yet well indexed by Google.