1
shivaji
META Tag hacks for Xoops 2.0.5.1
  • 2003/12/29 14:06

  • shivaji

  • Friend of XOOPS

  • Posts: 179

  • Since: 2003/9/18


Some users will not find this META tags hacks very useful on a temporary basis, but commercial site would sure to get a huse benefit with this hacks. A module like e-xoops Meta Tags is not impossible but I am requesting XOOPS core team to add this features in their next XOOPS release.

Anyway I have successfully added META tags for all of my majore Modules like Forum, MyLinks, MyDownload, Shop etc. in my XOOPS 2.5.1 site www.123ecominfo.com using this hacks.

I am not suggesting anyone to use this hacks, but someone with little PHP knowledge ( but good knowledge of english )can esily add this to their existing pages on their own risk.

Quote:

// META TAGS FOR INDIVIDUAL MODULES //

If I want to set individual keywords, description (as meta tags for searching) and page title for each module then what I have to do?


If you notice carefully then you will find that each module contain one file called "xoops_version.php", which contain some important information regarding that module.

Let say, you want to set some keywords, description (as meta tags) and page title for module "contact us". Don't worry, you have to do only two things.

Step: 1. Open the "xoops_version.php" file located in "\modules\contact" and write
three lines :-

// if you want to set "keywords" for "contact us" module, it's not mandatory

a:) $modversion['keywords']="contact us, admin@coswap.com, contact us form";


// if you want to set "description" for "contact us" module, it's not mandatory

b:) $modversion['desc']="contact us, admin@coswap.com, contact us form";


// if you want to set "page title" for "contact us" module, it's not mandatory
c:) $modversion['slogan']="We are waiting for your query";



now save "xoops_version.php" and close it.


step: 2. Now open "header.php" file located in "" and paste the following lines before code for showing 'banners' ( // show banner? Line no. 79 approx.).


// META TAGS FOR INDIVIDUAL MODULES //


if (!empty($xoopsModule))
{
$mid=$xoopsModule->mid();

if (is_numeric($mid))
{
$module_handler =& xoops_gethandler('module');
$versioninfo =& $module_handler->get($mid);
}
elseif (file_exists(XOOPS_ROOT_PATH.'/modules/'.$mid.'/xoops_version.php'))
{
$module_handler =& xoops_gethandler('module');
$versioninfo =& $module_handler->create();
$versioninfo->loadInfo(trim($mid));
}

$module_keywords =$versioninfo->getInfo('keywords');
$module_desc =$versioninfo->getInfo('desc');
$slogan=$versioninfo->getinfo('slogan');
}


if ($module_keywords)
{ $xoopsTpl->assign('xoops_meta_keywords', $module_keywords); }

if ($module_desc)
{ $xoopsTpl->assign('xoops_meta_description', $module_desc); }


//---------------------------------
and overwrite the following code

-------------------------------------

if (!empty($xoopsModule))
{
// set page title

$xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name'));

if (preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) && $xoopsConfig['startpage'] == $xoopsModule->getVar('dirname'))
{
$block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), $xoopsModule->getVar('mid'), true, XOOPS_BLOCK_VISIBLE);
}
else
{
$block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), $xoopsModule->getVar('mid'), false, XOOPS_BLOCK_VISIBLE);
}

}


----------------------
with
----------------------


if (!empty($xoopsModule))
{
// set page title

if($slogan)
{
$xoopsTpl->assign('xoops_pagetitle', $slogan);
}

else
{
$xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name'));
}


if (preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) && $xoopsConfig['startpage'] == $xoopsModule->getVar('dirname'))
{
$block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), $xoopsModule->getVar('mid'), true, XOOPS_BLOCK_VISIBLE);
}
else
{
$block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), $xoopsModule->getVar('mid'), false, XOOPS_BLOCK_VISIBLE);
}

}

-------------------
and
-------------------

if (isset($xoopsModule))
{
// set page title
$xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name'));

if (preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) && $xoopsConfig['startpage'] == $xoopsModule->getVar('dirname'))
{
$block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, $xoopsModule->getVar('mid'), true, XOOPS_BLOCK_VISIBLE);
}
else
{
$block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, $xoopsModule->getVar('mid'), false, XOOPS_BLOCK_VISIBLE);
}
}

-----------------------
with
-----------------------


if (isset($xoopsModule))
{
// set page title
if($slogan)
{
$xoopsTpl->assign('xoops_pagetitle', $slogan);
}
else
{
$xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name'));
}

if (preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) && $xoopsConfig['startpage'] == $xoopsModule->getVar('dirname'))
{
$block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, $xoopsModule->getVar('mid'), true, XOOPS_BLOCK_VISIBLE);
}
else
{
$block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, $xoopsModule->getVar('mid'), false, XOOPS_BLOCK_VISIBLE);
}
}


------------------------


and save "header.php".

Now open your site in your browser and go to the "contact us" module. Click on view->source link in your browser and you will see that this page contains those meta tags (keywords, description) which you have define in "xoops_version.php".Page title of your "contact us" module has been changed to "We are waiting for your query".

** If you haven't set any keywords or description or page title in "xoops_version.php" then default keywords,description and page title selected by admin from admin section will be set by default.




Thanks,

2
Herko
Re: META Tag hacks for Xoops 2.5.1
  • 2003/12/29 15:07

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


I will have the dev teams look at adding this to the XOOPS code

Thanks!

Herko

3
Stewdio
Re: META Tag hacks for Xoops 2.5.1
  • 2003/12/29 17:34

  • Stewdio

  • Community Support Member

  • Posts: 1560

  • Since: 2003/5/7 1


Nice Job! For anyone who's more serious about their XOOPS installation, these refinements are a great addition to any site!

Thanks

4
Draven
Re: META Tag hacks for Xoops 2.5.1
  • 2003/12/29 18:54

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


Wow, there's no need to do all that just to add custom meta tags. Just open your theme.html theme file and remove the metatags (Keywords, description and title). Then add the following code inplace of the meta tag like this:


<{php}>
$mod $GLOBALS['xoopsModule'];
$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');
$GLOBALS['xoopsTpl']->assign'xoops_cmod'$dirname );
<{/
php}>
<{include 
file="themedir/<{$xoops_cmod}>_meta.html"}>


Once this is in place, all you have to do is make a {mod name}_meta.html file for each module. Inside include the meta tags you want for that module. Much less hacking this way.

So if I have news, wfsection and contact us, I would have the following files in my theme directory:

news_meta.html
wfsection_meta.html
contactus_meta.html
system_meta.html

System refers to anything that is not a module like the homepage (If not using a module), user info pages etc.

This isn't a hack since everything is just included in the theme, no core files are changed. This allows you to upgrade without a problem.

Hope that helps.

PS. Still a nice job shivaji, the above is just a another way without hacking core files.

5
CBlue
Re: META Tag hacks for Xoops 2.5.1

Thanks for showing us all an easier way, Draven!

6
shivaji
Re: META Tag hacks for Xoops 2.5.1
  • 2003/12/30 7:42

  • shivaji

  • Friend of XOOPS

  • Posts: 179

  • Since: 2003/9/18


Hi Draven

You have done a nice job but I am not agreeing with your logic. I am working with XOOPS 2.0.5.1. First of all I put your code

<{php}>
$mod = $GLOBALS['xoopsModule'];
$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');
$GLOBALS['xoopsTpl']->assign( 'xoops_cmod', $dirname );
<{/php}>
<{include file="/themes/phpkaox/<{$xoops_cmod}>_meta.html"}>

in “theme.html” at meta tags section and my theme file is located at “themes\phpkaox\” folder.

Now I create some html files against each module like news_meta.html, wfsection_meta.html, contactus_meta.html, system_meta.html etc and put all those files in “themes\phpkaox\” folder. I think my procedure is correct. Isn’t?

But I am sorry to say it does not working properly. It showing some errors like

Warning: filemtime(): Stat failed for /themes/phpkaox/news.html (errno=2 - No such file or directory) in c:\inetpub\wwwroot\class\smarty\Smarty.class.php on line 1650

Can you tell me why it’s showing error?


2. “$xoops_cmod” variable fetching each module name and you append “_meta.html” for each module with that variable. Now you create html pages for each module, which contain meta tags and title etc. Let say I have installed 15 modules in my XOOPS and as per your logic I have to create 15 [module name]_meta.html pages and put all these pages in my selected themes directory. It is so ridiculous. Isn’t it?

3. Now I uninstall two modules out of 15 from my application and delete all these 2 module folders from server. If you notice carefully then you will see that those two [module name]_meta.html files are still stored in my selected themes directory. As a XOOPS module developer you know that, whenever you delete any modules from application then related files and evens tables are deleted automatically from xoops. But in this case those html files I have to remove manually from server and it does not support xoops’s basic feature.


4. From admin section admin can set Meta tags (keywords, description) and title. Let say
I overwrite those Meta (keyword, description) tags with your code in my theme.html. Now in my news module I want to use the default keywords and description (selected by admin). Then what I do? I already overwrite the code in theme.html. Who are familiar with XOOPS code to them it’s not a big problem but who are unaware about XOOPS code it’s a problem to them.

If you go through my code, may be my code is big but you have to only copy and paste.

Thanks

7
Mithrandir
Re: META Tag hacks for Xoops 2.5.1

Quote:

Now I create some html files against each module like news_meta.html, wfsection_meta.html, contactus_meta.html, system_meta.html etc and put all those files in “themes\phpkaox\” folder. I think my procedure is correct. Isn’t?

But I am sorry to say it does not working properly. It showing some errors like

Warning: filemtime(): Stat failed for /themes/phpkaox/news.html (errno=2 - No such file or directory) in c:\inetpub\wwwroot\class\smarty\Smarty.class.php on line 1650

As I can see, it tried to open news.html and not news_meta.html

Quote:
2. “$xoops_cmod” variable fetching each module name and you append “_meta.html” for each module with that variable. Now you create html pages for each module, which contain meta tags and title etc. Let say I have installed 15 modules in my XOOPS and as per your logic I have to create 15 [module name]_meta.html pages and put all these pages in my selected themes directory. It is so ridiculous. Isn’t it?

I fail to see the logic here. You want module-specific meta tags, but won't make them? Just as ridiculous, I'd say
Quote:
3. Now I uninstall two modules out of 15 from my application and delete all these 2 module folders from server. If you notice carefully then you will see that those two [module name]_meta.html files are still stored in my selected themes directory. As a XOOPS module developer you know that, whenever you delete any modules from application then related files and evens tables are deleted automatically from xoops. But in this case those html files I have to remove manually from server and it does not support xoops’s basic feature.

then place them in the module folder and make the link <{include file="<{$xoops_url}>/modules/<{$xoops_cmod}>/<{$xoops_cmod}>_meta.html"}>

Quote:
4. From admin section admin can set Meta tags (keywords, description) and title. Let say
I overwrite those Meta (keyword, description) tags with your code in my theme.html. Now in my news module I want to use the default keywords and description (selected by admin). Then what I do? I already overwrite the code in theme.html. Who are familiar with XOOPS code to them it’s not a big problem but who are unaware about XOOPS code it’s a problem to them.

Then add the module-keywords to the system keywords instead of over-writing them in theme.html

8
Draven
Re: META Tag hacks for Xoops 2.5.1
  • 2003/12/30 16:44

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


Quote:

shivaji wrote:
Hi Draven

You have done a nice job but I am not agreeing with your logic. I am working with XOOPS 2.0.5.1. First of all I put your code

<{php}>
$mod = $GLOBALS['xoopsModule'];
$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');
$GLOBALS['xoopsTpl']->assign( 'xoops_cmod', $dirname );
<{/php}>
<{include file="/themes/phpkaox/<{$xoops_cmod}>_meta.html"}>

in “theme.html” at meta tags section and my theme file is located at “themes\phpkaox\” folder.

Now I create some html files against each module like news_meta.html, wfsection_meta.html, contactus_meta.html, system_meta.html etc and put all those files in “themes\phpkaox\” folder. I think my procedure is correct. Isn’t?

But I am sorry to say it does not working properly. It showing some errors like

Warning: filemtime(): Stat failed for /themes/phpkaox/news.html (errno=2 - No such file or directory) in c:\inetpub\wwwroot\class\smarty\Smarty.class.php on line 1650

Can you tell me why it’s showing error?

As myth pinted out, you're trying to load the wrong file. Double check the PHP code and make sure that the _meta is there.
Quote:

2. “$xoops_cmod” variable fetching each module name and you append “_meta.html” for each module with that variable. Now you create html pages for each module, which contain meta tags and title etc. Let say I have installed 15 modules in my XOOPS and as per your logic I have to create 15 [module name]_meta.html pages and put all these pages in my selected themes directory. It is so ridiculous. Isn’t it?

Well, if you knew Smarty you could just a simply put all the metas in one html page and use IF staments to match a set of metas to the module. I was just trying to keep it simple. The whole point of my post was to give a way of doing it WITHOUT hacking the core files. I never said it was the only or best way to do it. You seem to be taking this quite personal, I'm only trying to help.

Quote:

3. Now I uninstall two modules out of 15 from my application and delete all these 2 module folders from server. If you notice carefully then you will see that those two [module name]_meta.html files are still stored in my selected themes directory. As a XOOPS module developer you know that, whenever you delete any modules from application then related files and evens tables are deleted automatically from xoops. But in this case those html files I have to remove manually from server and it does not support xoops’s basic feature.

As Myth pointed out, you can just change the URL to load from the module dir instead of the theme dir.

Quote:

4. From admin section admin can set Meta tags (keywords, description) and title. Let say
I overwrite those Meta (keyword, description) tags with your code in my theme.html. Now in my news module I want to use the default keywords and description (selected by admin). Then what I do? I already overwrite the code in theme.html. Who are familiar with XOOPS code to them it’s not a big problem but who are unaware about XOOPS code it’s a problem to them.

I agree, but as it stands now, you want them to hack core files to make this possible, I believe my solution is simpler then yours at the moment. I agree though, having this in the core and doing it through the admin panel is the best way, but until that is done, I think a none hack of core files is the best route. That way if a security update is released you don't have to worry about screwing up your install.

Again, I'm just trying to give users an alternative, I'm not trying to attack you. If people want to hack their files then by all means go right ahead, if you don't, now you have an alternative.

Thanks,

D

9
shivaji
Re: META Tag hacks for Xoops 2.5.1
  • 2003/12/30 17:07

  • shivaji

  • Friend of XOOPS

  • Posts: 179

  • Since: 2003/9/18


Dear Draven:

Thanks for the alternative information (i think the best) but I just given you my thought only after testing it in my machine. I will again check, retry and let you know.

I saw you and sunscrapper did a excellent work on friendly URLs , why dont combine both. Make a "htaccess" file without .(dot ) at begining and create a standard rules for every imp modules with proper comments and keep it in XOOPS 2.5.1 root folder with a readme.txt ammeneded to point that users need to rename htaccess to .htaccess in their remote web server root folder.

Thank for your time Draven.



10
Draven
Re: META Tag hacks for Xoops 2.5.1
  • 2003/12/30 17:44

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


Shivaji,

Skalpa is working on a mod_rewrite solution for the core and it would be pointless to create one of our own since I believe (Don't hold me to this) that it will be included in the 2.1 release. A mod_rewrite solution will require some major changes to both the core and all modules wishing to use it. So I'd rather leave that one to the devs. They know we all want it so..

D

Login

Username:
Password:

Lost Password? Register now!

Who's Online

69 user(s) are online (46 user(s) are browsing Support Forums)


Members: 0


Guests: 69


more...

Donat-O-Meter

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

Latest GitHub Commits