1
wizanda
Sitemap Newbb XML failure after adding sub pages?
  • 2008/6/13 21:58

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


For some reason after adding sub pages into the XOOPS version file of Newbb, sitemap has turned these into forums as well as sub pages on the google_xml.php….Could anyone see a reason for this happening from the sitemap newbb plugin?

/* $Id: newbb.php,v 1.1 2005/04/07 09:23:42 gij Exp $
// FILE        ::    newbb.php
// AUTHOR    ::    Ryuji AMANO 
// WEB        ::    Ryu's Planning 
// NewBBversion/newbb2 plugin: D.J., https://xoops.org.cn*/
function b_sitemap_newbb(){global $sitemap_configs;
$sitemap = array();
// Get the NewBB version Info
$module_handler = &xoops_gethandler('module');
$newbb $module_handler->getByDirname('newbb');
$newbb_version intval($newbb->getInfo('version'));
// For NewBB 2. If the syntax is wrong, correct me plz.
if($newbb_version>=2){
// Get All Forums with access permission
$forum_handler =& xoops_getmodulehandler('forum''newbb');
$_forums $forum_handler->getForums(0'access');
// Some transformation; Might ugly but works :=)
$forums = array();
$forums_sub = array();
foreach (
$_forums as $forumid => $forum){if($forum->isSubForum()) $forums_sub[$forum->getVar('parent_forum')][$forumid] = array(
'id' => $forumid,
'url' => "viewforum.php?forum=".$forumid,
'title' => $forum->getVar('forum_name'));
else 
$forums[$forumid] = array(
'id' => $forumid,
'cid' => $forum->getVar('cat_id'),
'url' => "viewforum.php?forum=".$forumid,
'title' => $forum->getVar('forum_name'));}
unset(
$_forums);
foreach (
$forums as $id => $forum){if(!empty($forums_sub[$id]))
$forums[$id]['fchild'] =& $forums_sub[$id];}
// Why not enable subcategory?
if($sitemap_configs["show_subcategoris"])
{
$category_handler =& xoops_getmodulehandler('category''newbb');
$categories $category_handler->getAllCats('access');
if(
count($categories)>0) foreach ($categories as $key=>$category){$cat_id=$category->getVar("cat_id");
$i=$cat_id;
$sitemap['parent'][$i]['id'] = $cat_id;
$sitemap['parent'][$i]['title'] = $category->getVar("cat_title");
$sitemap['parent'][$i]['url'] = "index.php?cat=".$cat_id;}
if(
count($forums)>0) foreach ($forums as $id=>$forum){$cid=$forum['cid'];
$sitemap['parent'][$cid]['child'][$id] = $forum;
$sitemap['parent'][$cid]['child'][$id]['image'] = 2;
if(!empty(
$forum['fchild'])) foreach($forum['fchild'] as $_id=>$_forum){$sitemap['parent'][$cid]['child'][$_id] = $_forum;
unset(
$_forum);
$sitemap['parent'][$cid]['child'][$_id]['image'] = 3;}
unset(
$forum);}
/* In case not enable subcategory, do the following; Sorry, I have not tested with this mode yet. If any bugs, feel free to fix.*/
}else{if(count($forums)>0) foreach ($forums as $id=>$forum){$sitemap['parent'][$id] = $forum;
if(!empty(
$forum['fchild'])) foreach($forum['fchild'] as $_id=>$_forum){$sitemap['parent'][$id]['child'][$_id] = $_forum;
$sitemap['parent'][$cid]['child'][$id]['image'] = 2;
unset(
$_forum);}
unset(
$forum);}}
return 
$sitemap;}
/** My part ends, D.J. :=)*/
$db =& Database::getInstance();
$myts =& MyTextSanitizer::getInstance();
if(
$sitemap_configs["show_subcategoris"]){$sql 'SELECT DISTINCT c.* FROM '.$db->prefix('bb_categories').' c, '.$db->prefix("bb_forums").' f WHERE f.cat_id=c.cat_id GROUP BY c.cat_id, c.cat_title, c.cat_order ORDER BY c.cat_order';
$result $db->query($sql);
$categories = array();
while (
$cat_row $db->fetchArray($result)){$i $cat_row["cat_id"];
$sitemap['parent'][$i]['id'] = $cat_row["cat_id"];
$sitemap['parent'][$i]['title'] = $myts->makeTboxData4Show($cat_row["cat_title"]);
$sitemap['parent'][$i]['url'] = "index.php?cat=".$cat_row["cat_id"];
$categories[] = $cat_row["cat_id"];}}
$sql "SELECT f.* FROM ".$db->prefix("bb_forums")." f LEFT JOIN ".$db->prefix("bb_categories")." c ON f.cat_id=c.cat_id ORDER BY f.forum_id";
$result $db->query($sql);
$i=0;
while(
$forum_row $db->fetchArray($result))
{if(
$sitemap_configs["show_subcategoris"]){$j $forum_row["cat_id"];
$sitemap['parent'][$j]['child'][$i]['id'] = $forum_row["forum_id"];
$sitemap['parent'][$j]['child'][$i]['title'] = $myts->makeTboxData4Show($forum_row["forum_name"]);
$sitemap['parent'][$j]['child'][$i]['image'] = 2;
$sitemap['parent'][$j]['child'][$i]['url'] = "viewforum.php?forum=".$forum_row['forum_id'];}
else{
$sitemap['parent'][$i]['id'] = $forum_row["forum_id"];
$sitemap['parent'][$i]['title'] = $myts->makeTboxData4Show($forum_row["forum_name"]);
$sitemap['parent'][$i]['url'] = "viewforum.php?forum=".$forum_row['forum_id'];}
$i++;}
//print_r($categories);
return $sitemap;}
?>

<url>
<
loc>http://localhost/finalize/modules/newbb/
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/index.php?cat=1
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewforum.php?forum=1
loc>
url>
?
    <
url>
<
loc>http://localhost/finalize/modules/newbb/
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewforum.php?forum=2
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewforum.php?forum=3
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewforum.php?forum=4
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewforum.php?forum=5
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewforum.php?forum=6
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewforum.php?forum=7
loc>
url>
?
    <
url>
<
loc>http://localhost/finalize/modules/newbb/search.php
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewpost.php
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewpost.php?new=1
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewall.php
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewall.php?type=digest
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewall.php?type=unreplied
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/viewall.php?type=unread
loc>
url>
?
    <
url>
?
    <
loc>
http://localhost/finalize/modules/newbb/rss.php?c=0
loc>

2
wizanda
Re: Sitemap Newbb XML failure after adding sub pages?
  • 2008/6/13 23:05

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


oops not solved it...deleted the plugin for now....poor Google, don't know how it copes with me

3
trabis
Re: Sitemap Newbb XML failure after adding sub pages?
  • 2008/6/14 1:59

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Could we see that xoops_version.php?

4
wizanda
Re: Sitemap Newbb XML failure after adding sub pages?
  • 2008/6/14 7:59

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


Below the templates....with numbers now added....
/*subpages*/
$modversion['sub'][0]['name'] = _MI_SEARCH;
$modversion['sub'][0]['url'] = "search.php";
$modversion['sub'][1]['name'] = _MI_ALLPOSTS;
$modversion['sub'][1]['url'] = "viewpost.php";
$modversion['sub'][2]['name'] = _MI_VANP;
$modversion['sub'][2]['url'] = "viewpost.php?new=1";
$modversion['sub'][3]['name'] = _MI_ALL;
$modversion['sub'][3]['url'] = "viewall.php";
$modversion['sub'][4]['name'] = _MI_DIGEST;
$modversion['sub'][4]['url'] = "viewall.php?type=digest";
$modversion['sub'][5]['name'] = _MI_UNREPLIED;
$modversion['sub'][5]['url'] = "viewall.php?type=unreplied";
$modversion['sub'][6]['name'] = _MI_UNREAD;
$modversion['sub'][6]['url'] = "viewall.php?type=unread";
$modversion['sub'][7]['name'] = _MI_RSS;
$modversion['sub'][7]['url'] = "rss.php?c=0";

5
trabis
Re: Sitemap Newbb XML failure after adding sub pages?
  • 2008/6/14 11:51

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Sitemap seems to grab sublinks and then the plugin.

Yo can try this
Hack include/sitemap.php at line 42
if (count($sublinks) > && $modules[$i]->getVar('dirname') != 'newbb') {
                foreach(
$sublinks as $sublink){
                    
$block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => XOOPS_URL.'/modules/'.$modules[$i]->getVar('dirname').'/'.$sublink['url']);
                }
            }

It will skip the newbb sublinks.

6
trabis
Re: Sitemap Newbb XML failure after adding sub pages?
  • 2008/6/14 12:43

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Well, probably you want to keep thoose sub pages(links) int sitemap but not in the xml so do this:

replace xml_google.php line 57
with
$sitemap sitemap_show(1);


at sitemap.php line 5
function sitemap_show($skip 0)
{
    global 
$xoopsUser$xoopsConfig$sitemap_configs ;
    
$plugin_dir XOOPS_ROOT_PATH "/modules/sitemap/plugins/";


at sitemap.php line 42
if (count($sublinks) > && !($skip == && $modules[$i]->getVar('dirname') == 'newbb')) {

7
wizanda
Re: Sitemap Newbb XML failure after adding sub pages?
  • 2008/6/14 13:14

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


Thxz, yet the sub links were added purposely for Google...

Thinking to make a simpler plug-in for newbb, as that’s a lot of code to do a simple task....
Something more like this:
function b_sitemap_newbb(){$xoopsDB =& Database::getInstance();
$block sitemap_get_categoires_map($xoopsDB->prefix("bb_forums"), "forum_id""cat_id""forum_name""viewforum.php?forum=""forum_order");
return 
$block;}
?>

As mydownloads, mylinks, etc, look something like that, not sure why we would want all that checking done in the first place.....
Still need to fix that, yet as long as all forums show and all sub links, I will be happy.

Login

Who's Online

393 user(s) are online (258 user(s) are browsing Support Forums)


Members: 0


Guests: 393


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