1
playsome
How to add item title into pagetitle?
  • 2009/5/8 20:01

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hi,

I have managed to clone wordbook v1.16 and rename it for use as a module to list game cheats, however I would like to have the cheat title display inbetween the tags, for example MySite.com - Cheats - Call of Duty 4

At the moment it just displays my sitename and the module name. Is there an easy way to do this?

Cheers.

2
tcnet
Re: How to add item title into pagetitle?
  • 2009/5/8 21:46

  • tcnet

  • Friend of XOOPS

  • Posts: 297

  • Since: 2006/5/12


Edit modules/wordbook/entry.php to add the glossary term to the page title.
ADD THIS:
// page title hack tcnet
$wbpagetitle $myts->htmlSpecialChars$xoopsModule->getVar('name').' - '.$glossaryterm);

if (
is_object($xoTheme)) {      
$xoTheme->addMeta'meta''title'$wbpagetitle);
else {
$xoopsTpl->assign('xoops_pagetitle'$wbpagetitle);

//end page hack

BEFORE THIS:
include_once 
XOOPS_ROOT_PATH.'/footer.php';

3
playsome
Re: How to add item title into pagetitle?
  • 2009/5/8 23:01

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hi tcnet,

I have added the code as instructed but I am getting a parse error on line 184, line 184 is
else {


System:
xoops 2.3.3
PHP Version 5.2.8
Apache/2.2.11
MySQL 5.1.30
Wordbook version 1.16

Installed locally using WAMP

Thanks

4
trabis
Re: How to add item title into pagetitle?
  • 2009/5/8 23:42

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


use this:
} else {

5
playsome
Re: How to add item title into pagetitle?
  • 2009/5/9 0:19

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Thanks trabis, that fixed the parse error but I stil can't get the cheat title to show on the pagetitle it is still just showing 'sitename - cheats'.

On looking at the errors in debug I am getting alot of errors like this one:
Quote:
Warning: MyTextSanitizer::makeTareaData4Show is deprecated in file /class/module.textsanitizer.php line 699


My only guess is perhaps this version of wordbook is too old and doesnt conform to the newest XOOPS coding standards?

heres the fule code of cheat.php (was entry.php)there references to makeTareaData4Show in the file and im wondering if thats what is calling up the errors.

/**
 * $Id: cheat.php v 1.0 8 May 2004 hsalazar Exp $
 * Module: Cheats - a multicategory glossary
 * Version: v 1.00
 * Release Date: 8 May 2004
 * Author: hsalazar
 * Licence: GNU
 */

include( "header.php" );
include_once( 
XOOPS_ROOT_PATH "/header.php" );
include_once 
XOOPS_ROOT_PATH "/class/module.textsanitizer.php"

$xoopsOption['template_main'] = 'ch_cheat.html';

global 
$xoopsUser$xoopsUser$xoopsConfig$xoopsDB$modify$xoopsModuleConfig$xoopsModule$XOOPS_URL
$myts =& MyTextSanitizer::getInstance();

$cheatID = isset($_GET['cheatID']) ? intval($_GET['cheatID']) : 0;

$xoopsOption['template_main'] = 'ch_cheat.html';

if (
$xoopsModuleConfig['multicats'] == 1)
    {
    
$xoopsTpl->assign('multicats'1);
    }
else
    {
    
$xoopsTpl->assign('multicats'0);
    }

// If there's no cheats yet in the system...
$pubwords $xoopsDB -> query"SELECT * FROM " $xoopsDB -> prefix"chcheats" ) . " WHERE submit = '0' AND offline ='0' " );
$publishedwords $xoopsDB -> getRowsNum $pubwords );
$xoopsTpl->assign('publishedwords'$publishedwords);
if ( 
$publishedwords == )
    {
    
$xoopsTpl -> assign ('empty''1');
    
$xoopsTpl -> assign ('stillnothing'_MD_CH_STILLNOTHINGHERE);
    }

// To display the linked letter list
$alpha alphaArray();
$xoopsTpl->assign('alpha'$alpha);

$sql $xoopsDB -> query "SELECT * FROM " $xoopsDB -> prefix "chcheats") . " WHERE init = '#' " );
$howmanyother $xoopsDB -> getRowsNum$sql );
$xoopsTpl->assign('totalother'$howmanyother);

if ( 
$xoopsModuleConfig['multicats'] == )
    {
    
// To display the list of categories
    
$block0 = array();
    
$resultcat $xoopsDB -> query "SELECT categoryID, name, total FROM " $xoopsDB -> prefix "chcategories") . " ORDER BY name ASC" );
    while (list( 
$catID$name$total) = $xoopsDB->fetchRow($resultcat))
        {
        
$catlinks = array();
        
$xoopsModule XoopsModule::getByDirname("cheats");
        
$catlinks['id'] = $catID;
        
$catlinks['total'] = intval($total);
        
$catlinks['linktext'] = $myts -> makeTboxData4Show$name );

        
$block0['categories'][] = $catlinks;
        }
    
$xoopsTpl -> assign 'block0'$block0 );
    }

if ( !
$cheatID )
    {
    
$result $xoopsDB -> query"SELECT cheatID, categoryID, term, init, definition, ref, url, uid, submit, datesub, counter, html, smiley, xcodes, breaks, block, offline, notifypub FROM " $xoopsDB -> prefix"chcheats" ) . " WHERE datesub < " time() . " AND datesub > 0 AND (submit = 0) ORDER BY datesub DESC"1);
    }
else
    {
    if ( !
$xoopsUser || ( $xoopsUser->isAdmin($xoopsModule->mid()) && $xoopsModuleConfig['adminhits'] == ) || ( $xoopsUser && !$xoopsUser -> isAdmin$xoopsModule -> mid() ) ) )
        {
        
$xoopsDB -> queryF"UPDATE " $xoopsDB -> prefix"chcheats" ) . " SET counter = counter+1 WHERE cheatID = $cheatID " );
        }    

    
$result $xoopsDB -> query"SELECT cheatID, categoryID, term, init, definition, ref, url, uid, submit, datesub, counter, html, smiley, xcodes, breaks, block, offline, notifypub FROM " $xoopsDB -> prefix"chcheats" ) . " WHERE cheatID = $cheatID);
    }

while (list( 
$cheatID$categoryID$term$init$definition$ref$url$uid$submit$datesub$counter$html$smiley$xcodes$breaks$block$offline$notifypub ) = $xoopsDB->fetchRow($result))
    {
    
$thisterm = array();
    
$xoopsModule XoopsModule::getByDirname("cheats");
    
$thisterm['id'] = intval($cheatID);

    if (
$xoopsModuleConfig['multicats'] == 1)
        {
        
$thisterm['categoryID'] = intval($categoryID);
        
$catname $xoopsDB -> query "SELECT name FROM " $xoopsDB -> prefix "chcategories" ) . " WHERE categoryID = $categoryID ");
        while (list (
$name) = $xoopsDB -> fetchRow $catname ))
            {
            
$thisterm['catname'] = $myts -> makeTboxData4Show$name );
            }
        }

    
$glossaryterm $myts -> makeTboxData4Show$term );
    
$thisterm['term'] = ucfirst($myts -> makeTboxData4Show$term ));
    if (
$init == '#')
        {
        
$thisterm['init'] = _MD_CH_OTHER;
        }
    else
        {
        
$thisterm['init'] = ucfirst($init);
        }

    if (
$xoopsModuleConfig['linkterms'] == 1)
        {
        
// Code to make links out of glossary terms
        
$parts explode(">"$definition);

        
// First, retrieve all terms from the glossary...
        
$allterms $xoopsDB -> query"SELECT cheatID, term FROM " $xoopsDB -> prefix"chcheats" ));
        while ( list( 
$cheatID$term ) = $xoopsDB -> fetchrow$allterms ))
            {
            foreach(
$parts as $key=>$part)
                {
                if ( 
$term != $glossaryterm)
                    {
                    
// singular
                    
$term_q preg_quote($term'/');
                    
$search_term "/b$term_qb/i";
                    
$replace_term ".XOOPS_URL."/modules/".$xoopsModule->dirname()."/cheat.php?cheatID=".ucfirst($cheatID)."'>".$term."";
                    
$parts[$key] = preg_replace($search_term$replace_term$parts[$key]);

                    
// plural
                    
$term $term."s";
                    
$term_q preg_quote($term'/');
                    
$search_term "/b$term_qb/i";
                    
$replace_term ".XOOPS_URL."/modules/".$xoopsModule->dirname()."/cheat.php?cheatID=".ucfirst($cheatID)."'>".$term."";
                    
$parts[$key] = preg_replace($search_term$replace_term$parts[$key]);

                    
// plural with e
                    
$term $term."es";
                    
$term_q preg_quote($term'/');
                    
$search_term "/b$term_qb/i";
                    
$replace_term ".XOOPS_URL."/modules/".$xoopsModule->dirname()."/cheat.php?cheatID=".ucfirst($cheatID)."'>".$term."";
                    
$parts[$key] = preg_replace($search_term$replace_term$parts[$key]);
                    }
                }
            }
        
$definition implode(">"$parts);
        }

    
$thisterm['definition'] = $myts -> displayTarea$definition$html$smiley$xcodes1$breaks );
    
    
$thisterm['ref'] = $myts -> makeTboxData4Show$ref );
    
$thisterm['url'] = $myts->makeClickable($url$allowimage 0);
    
$thisterm['submitter'] = xoops_getLinkedUnameFromId $uid );
    
$thisterm['submit'] = intval($submit);
    
$thisterm['datesub'] = formatTimestamp($datesub,$xoopsModuleConfig['dateformat']);
    
$thisterm['counter'] = intval($counter);
    
$thisterm['block'] = intval($block);
    
$thisterm['offline'] = intval($offline);
    
$thisterm['notifypub'] = intval($notifypub);
    
$thisterm['dir'] = $xoopsModule->dirname();
    }
$xoopsTpl -> assign'thisterm'$thisterm );

$microlinks serviceLinks $thisterm );

$xoopsTpl -> assign 'microlinks'$microlinks );

$xoopsTpl -> assign 'lang_modulename'$xoopsModule->name() );
$xoopsTpl -> assign 'lang_moduledirname'$xoopsModule->dirname() );

$xoopsTpl -> assign 'cheatID'$cheatID);
$xoopsTpl -> assign 'submitted'sprintf(_MD_CH_SUBMITTED$thisterm['submitter'], $thisterm['datesub']) );
$xoopsTpl -> assign 'counter'sprintf(_MD_CH_COUNT$thisterm['counter']) );

$xoopsTpl->assign("xoops_module_header"'');

//Mondarse
include XOOPS_ROOT_PATH.'/include/comment_view.php';
//Mondarse
// page title hack tcnet
$chpagetitle $myts->htmlSpecialChars$xoopsModule->getVar('name').' - '.$glossaryterm);
if (
is_object($xoTheme)) {      
$xoTheme->addMeta'meta''title'$chpagetitle);

} else {
$xoopsTpl->assign('xoops_pagetitle'$chpagetitle); 
}
//end page hack
include_once XOOPS_ROOT_PATH.'/footer.php';
?>


I appreciate any help you can give me I think this would be a great module for cheats (or something else maybe if cloned again) once the bugs are ironed out.

Cheers

6
DarinAllan
Re: How to add item title into pagetitle?

There is Lexikon that seems to have more features and from what I can see is basically an Upgrade to wordbook, I updated my old wordbook to lexikon, no problems it supports importing/upgrading from a few different modules of this type. Wordbook is really quite old now.

Oh there is also Lexique, but I haven't used that.

7
tcnet
Re: How to add item title into pagetitle?
  • 2009/5/9 3:26

  • tcnet

  • Friend of XOOPS

  • Posts: 297

  • Since: 2006/5/12


I think this one will work:
$chpagetitle $myts->htmlSpecialChars$xoopsModule->getVar('name').' - '.$glossaryterm); 
$xoopsTpl->assign('xoops_pagetitle'$chpagetitle);

if (
is_object($xoTheme)) {       
$xoTheme->addMeta'meta''title'$chpagetitle); 
}


Your page and meta titles may be modified in your theme's index.html head as well. Sometimes sitename or slogan is added there.

The module is old but not hopeless. Debug Warnings are there to alert the module developer of updated core functions. Most old functions still work thanks to core devs insuring backward compatibility. Here is a list of depreciated functions and their replacements.

8
DarinAllan
Re: How to add item title into pagetitle?

Lexikon is an upgrade to wordbook, of course wordbook is a great module, but it is old.

Here is Lexikon how I use it, it upgraded wordbook, have a look. See if the page titles are how you want them. Lexikon on my site used to be wordbook full of terms, but it wasn't doing what I wanted, lexikon fixed some of the problems. Maybe when there is a developer for wordbook I will go back to it but there isn't, which is a shame, Lexikon also does not seem to have a developer, but it does have some enhancements over wordbook.

Oh I should say that when you install Lexikon, it doesn't overwrite wordbook, but it can detect wordbook and there is an import function to get all the entries, once imported see if it has done the job then you can decide if you want to use lexikon or delete it and continue to use wordbook, they are separate modules yet the same.

Anyway it is the last time I will mention it lol ;o)

9
playsome
Re: How to add item title into pagetitle?
  • 2009/5/9 12:42

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Thanks for all your help guys. tcnet, your new code works like a charm, I will have a go with the cloned wordbook module for now as it will save me having to clone/rename the lexicon module, and if i have cloned the wb module correctly I should be able to use lexicon module aswell for something else.

Thanks for all your help guys, no doubt I'll be posting again soon when im stuck with something else.

Cheers.


Login

Who's Online

297 user(s) are online (221 user(s) are browsing Support Forums)


Members: 0


Guests: 297


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