1
Cubiq
4 Tips for xoops
  • 2004/12/12 12:03

  • Cubiq

  • Just popping in

  • Posts: 7

  • Since: 2004/11/23


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 hacks
For 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 body
This 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}>&nbsp;<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 block
The 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 behaviour
I 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.

2
limecity
Re: 4 Tips for xoops
  • 2004/12/12 14:34

  • limecity

  • Friend of XOOPS

  • Posts: 1602

  • Since: 2003/7/6 0


Interesting..

should submit this to the XOOPS core hacks.
or Hack Review.

3
JMorris
Re: 4 Tips for xoops
  • 2004/12/12 16:52

  • JMorris

  • XOOPS is my life!

  • Posts: 2722

  • Since: 2004/4/11


RE: Per page meta tags with no hacks

Interesting. I've been experimenting with some simple php include and define statements to define custom Meta data for each page. I've had great success with this on non-xoops sites, but I’m trying to come up with a small module that will allow webmasters to define their own title, keywords, and description on a per module/page basis for Xoops. Your tip has given me some good food for thought.

Thanks.

4
emagin
Re: 4 Tips for xoops
  • 2005/1/21 19:18

  • emagin

  • Just popping in

  • Posts: 17

  • Since: 2005/1/8 1


Bump!

Has anyone made any progress on this?
Compared to Mambo, this per page meta issue and the ability to create STANDARD content in a 3 level menu navigation (dynamic) is somewhat lacking. I hope to see more work on this and will gladly test offer feedback on this.

5
carnuke
Re: 4 Tips for xoops
  • 2005/1/21 19:28

  • carnuke

  • Home away from home

  • Posts: 1955

  • Since: 2003/11/5


Take a look at the FAQ on individual page metadata, from hoorah's post HERE .

BTW, I will put all these into the FAQ section so they dont get lost. Thanks for submitting these tips/hacks

Richard

6
panigrc
Re: 4 Tips for xoops
  • 2005/6/3 7:50

  • panigrc

  • Not too shy to talk

  • Posts: 133

  • Since: 2005/4/14


I have AdSense on my site too! And I couldn't figure out why it's not displaying the ads.

Thanx a lot !!!

7
Herko
Re: 4 Tips for xoops
  • 2005/6/3 8:03

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


FIrst of all, Mambo is not the bar we're aspiring for... We're aspiring for a better XOOPS

Secondly, for XOOPS 2.2, Marcan is now working on a metadata generation class that will be the basis for real metadata management for XOOPS. So no workarounds in theme files (they work for XOOPS 2.0.x), in XOOPS 2.2 we'll make it a proper feature

Herko

8
giba
Re: 4 Tips for xoops
  • 2005/6/3 10:49

  • giba

  • Just can't stay away

  • Posts: 638

  • Since: 2003/4/26



9
Herko
Re: 4 Tips for xoops
  • 2005/6/3 11:04

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


Quote:

Giba wrote:
I can implementarion in my core this

Your core? Are you forking as well?? I don't get it.

Herko

10
bluenova
Re: 4 Tips for xoops

Will everybody stop forking about

Login

Who's Online

288 user(s) are online (224 user(s) are browsing Support Forums)


Members: 0


Guests: 288


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits