•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,564 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,522 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 71633 | Replies: 238
![]() |
•
•
Join Date: Sep 2004
Posts: 10
Reputation:
Rep Power: 5
Solved Threads: 0
cscgal>
Thanks for your quick reply. I have actually found a fix for our problem.
Here is the code:
Here is a good example of the code above in action:
http://www.agentserver.net/forum/thread1.html
To explain the code fix to everyone else:
Within Steph Eight of the original #1 Post. Instead of doing this:
we can do something like this
Thanks for your quick reply. I have actually found a fix for our problem.
Here is the code:
$adotempnarvurl = strtolower(
str_replace(" ", "-",
str_replace("/", "-", $forumTitle)
)
);
$navbits["$adotempnarvurl.html"] = $forumTitle; // edited by daniHere is a good example of the code above in action:
http://www.agentserver.net/forum/thread1.html
To explain the code fix to everyone else:
Within Steph Eight of the original #1 Post. Instead of doing this:
foreach ($parentlist AS $forumID)
{
$forumTitle = $forumcache["$forumID"]['title'];
$navbits["forum$forumID.html"] = $forumTitle; // edited by dani
} we can do something like this
foreach ($parentlist AS $forumID)
{
$forumTitle = $forumcache["$forumID"]['title'];
$adotempnarvurl = strtolower(
str_replace(" ", "-",
str_replace("/", "-", $forumTitle)
)
);
$navbits["$adotempnarvurl.html"] = $forumTitle; // edited by dani
} •
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,020
Reputation:
Rep Power: 33
Solved Threads: 117
Cyber-SEO, I just have to say I am completely baffled right now. I have attempted something very similar to what you suggested months ago and was not able to get it to work. The navbits refused to follow the forum hierarchy, and just automatically put every thread directly under a top-level forum, completely ignoring all of the subforums. Still not exactly sure why it works for you but didn't for me, but thanks a billion!
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
•
•
Join Date: Sep 2004
Posts: 10
Reputation:
Rep Power: 5
Solved Threads: 0
Just glas I was able to help.
I think you did the same thing i tried doing at first which was to incorporate the replacment of the title right into the navbits. When I did that it did exactly what you were reffering to above.
I think you did the same thing i tried doing at first which was to incorporate the replacment of the title right into the navbits. When I did that it did exactly what you were reffering to above.
Question:
I just noticed this:
This is my forum layout
Tools for Forex Trading
- - Forex Trading Software
- - - - FXME
My FXME link is showing up as http://www.4xtraders.com/forum/f43-.html and not http://www.4xtraders.com/forum/FXME.htm
( I have RewriteRule ^FXME.html$ forumdisplay.php?f=43 [L] in my .htaccess file)
Did I do something wrong or is it to be like that. Any one
I just noticed this:
This is my forum layout
Tools for Forex Trading
- - Forex Trading Software
- - - - FXME
My FXME link is showing up as http://www.4xtraders.com/forum/f43-.html and not http://www.4xtraders.com/forum/FXME.htm
( I have RewriteRule ^FXME.html$ forumdisplay.php?f=43 [L] in my .htaccess file)
Did I do something wrong or is it to be like that. Any one
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,020
Reputation:
Rep Power: 33
Solved Threads: 117
Double check the forumlist PHP file you edited in the /includes folder.
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
•
•
Join Date: Sep 2004
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Can someone help me solve a few parse errors. I was fairlr careful to make sure I did everything correct.
When I click on a thread it works fine.
When I click on a forum it works fine.
When I click on "Main Category" I get the following error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/myphotos/public_html/forum/includes/functions_forumlist.php(441) : eval()'d code on line 11
And when I goto my forums homepage I get the following error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/myphotos/public_html/forum/includes/functions_forumlist.php(441) : eval()'d code on line 5
I edited all files in notepad not dreamweaver.
If anyone could help me that would be great.
When I click on a thread it works fine.
When I click on a forum it works fine.
When I click on "Main Category" I get the following error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/myphotos/public_html/forum/includes/functions_forumlist.php(441) : eval()'d code on line 11
And when I goto my forums homepage I get the following error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/myphotos/public_html/forum/includes/functions_forumlist.php(441) : eval()'d code on line 5
I edited all files in notepad not dreamweaver.
If anyone could help me that would be great.
•
•
•
•
Originally Posted by cscgal
Double check the forumlist PHP file you edited in the /includes folder.
Could someone double check this to make sure that I did this correct. I have messed with it soo many times.... I am not sure every thing is in the right place now.
This is my forum/includes/functions_forumlist.php
[PHP]<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 3.0.3 - Licence Number L44230c3
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000–2004 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/
error_reporting(E_ALL & ~E_NOTICE);
// ###################### Start getiforumcache #######################
// pass $bbuserinfo[userid] into the function in order to return a value
// for which forums are subscribed ($arry[subscribeforumid])
function cache_ordered_forums($getcounters = 0, $getinvisibles = 0, $userid = 0)
{
global $DB_site, $iforumcache, $forumcache, $_FORUMOPTIONS, $bbuserinfo;
$forumfields = 'forum.forumid, lastpost, lastposter, lastthread, lastthreadid, lasticonid, threadcount, replycount';
// query forum table to get latest lastpost/lastthread info and counters
if ($getcounters)
{
// get subscribed forums too
if ($userid)
{
$query = "
SELECT subscribeforumid, $forumfields
FROM " . TABLE_PREFIX . "forum AS forum
LEFT JOIN " . TABLE_PREFIX . "subscribeforum AS subscribeforum ON (subscribeforum.forumid = forum.forumid AND subscribeforum.userid = $userid)
";
}
// just get counters
else
{
$query = "
SELECT $forumfields
FROM " . TABLE_PREFIX . "forum AS forum
";
}
}
// don't bother to query forum table, just use the cache
else
{
// get subscribed forums
if ($userid)
{
$query = "
SELECT subscribeforumid, forumid
FROM " . TABLE_PREFIX . "subscribeforum
WHERE userid = $userid
";
}
}
if ($query)
{
$getthings = $DB_site->query($query);
if ($DB_site->num_rows($getthings))
{
while ($getthing = $DB_site->fetch_array($getthings))
{
if (empty($forumcache["$getthing[forumid]"]))
{
$forumcache["$getthing[forumid]"] = array();
}
$forumcache["$getthing[forumid]"] = array_merge($forumcache["$getthing[forumid]"], $getthing);
}
}
}
$iforumcache = array();
if ($getinvisibles) // get all forums including invisibles
{
foreach($forumcache AS $forumid => $forum)
{
$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forumid"] = $forumid;
}
}
else // get all forums except invisibles
{
foreach($forumcache AS $forumid => $forum)
{
if ($forum['displayorder'] AND ($forum['options'] & $_FORUMOPTIONS['active']))
{
$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forumid"] = $forumid;
}
else
{
unset($forumcache["$forumid"]);
}
}
}
// do some sorting (instead of sorting with MySQL and causing a filesort)
foreach($iforumcache AS $parentid => $devnull)
{
ksort($iforumcache["$parentid"]); // sort by display order
}
ksort($iforumcache); // sort by parentid (not actually sure if this is necessary)
}
// ###################### Start getimodcache #######################
function cache_moderators()
{
global $DB_site, $imodcache, $mod;
$imodcache = array();
$mod = array();
$forummoderators = $DB_site->query("
SELECT moderator.*, user.username,
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid
FROM " . TABLE_PREFIX . "moderator AS moderator
INNER JOIN " . TABLE_PREFIX . "user AS user USING(userid)
");
while ($moderator = $DB_site->fetch_array($forummoderators))
{
$moderator['musername'] = fetch_musername($moderator);
$imodcache["$moderator[forumid]"]["$moderator[userid]"] = $moderator;
$mod["$moderator[userid]"] = 1;
}
$DB_site->free_result($forummoderators);
}
// ###################### Start getlastpostinfo #######################
// this function creates a lastpostinfo array that tells makeforumbit which forum
// each forum should grab its last post info from.
// it also tots up the thread/post totals for each forum. - PERMISSIONS are taken into account.
function fetch_last_post_array()
{
global $iforumcache, $forumcache, $lastpostarray, $bbuserinfo, $counters;
// loop through the iforumcache
foreach($iforumcache AS $moo)
{
foreach($moo AS $baa)
{
foreach ($baa AS $forumid)
{
$forum = $forumcache["$forumid"];
// if we have no permission to view the forum's parent
// set cannotView permissions cache for this forum and continue
if ($cannotView["$forum[parentid]"] == 1)
{
$cannotView["$forumid"] = 1;
}
else
{
$forumperms = $bbuserinfo['forumpermissions']["$forumid"];
// if we have no permissions for this forum, set the cannotView permissions cache
// so that we don't have to check its child forums
//if (!($forumperms & CANVIEW) OR !($forumperms & CANVIEWOTHERS))
if (!($forumperms & CANVIEW))
{
$cannotView["$forumid"] = 1;
}
else
{
if (!($forumperms & CANVIEWOTHERS))
{
continue;
}
//$lastpostarray["$forumid"] = $forumid;
if (!isset($lastpostarray["$forumid"]))
{
$lastpostarray["$forumid"] = $forumid;
}
$parents = explode(',', $forum['parentlist']);
foreach($parents AS $parentid)
{
// for each parent, set an array entry containing this forum's number of posts & threads
$children["$parentid"]["$forumid"] = array('threads' => $forum['threadcount'], 'posts' => $forum['replycount']);
if ($parentid == -1 OR !is_array($forumcache["$parentid"]))
{
continue;
}
// compare the date for the last post info with the last post date
// for the parent forum, and if it's greater, set the last post info
// array for this forum to point to that forum... (erm..)
if ((!$forum['password'] OR verify_forum_password($forum['forumid'], $forum['password'], false)) AND $forum['lastpost'] > $forumcache["$parentid"]['lastpost'])
{
$lastpostarray["$parentid"] = $forumid;
$forumcache["$parentid"]['lastpost'] = $forum['lastpost'];
}
} // end foreach($parents)
} // end can view
} // end can view parent
}
}
}
$counters = array();
if (is_array($forumcache))
{
foreach($forumcache AS $forum)
{
$counters["$forum[forumid]"]['threadcount'] = 0;
$counters["$forum[forumid]"]['replycount'] = 0;
if (is_array($children["$forum[forumid]"]))
{
foreach($children["$forum[forumid]"] AS $id => $info)
{
$counters["$forum[forumid]"]['threadcount'] += $info['threads'];
$counters["$forum[forumid]"]['replycount'] += $info['posts'];
}
}
}
}
return $i;
}
// ###################### Start makeforumbit #######################
// this function returns the properly-ordered and formatted forum lists for forumhome,
// forumdisplay and usercp. Of course, you could use it elsewhere too..
function construct_forum_bit($parentid, $depth = 0, $subsonly = 0)
{
global $vboptions, $DB_site, $session, $bbuserinfo, $stylevar, $_FORUMOPTIONS, $vbphrase, $show;
global $iforumcache, $forumcache, $imodcache, $lastpostarray, $counters, $inforum;
// this function takes the constant MAXFORUMDEPTH as its guide for how
// deep to recurse down forum lists. if MAXFORUMDEPTH is not defined,
// it will assume a depth of 2.
// call fetch_last_post_array() first to get last post info for forums
if (!is_array($lastpostarray))
{
fetch_last_post_array();
}
if (!isset($iforumcache["$parentid"]))
{
return;
}
if (!defined(MAXFORUMDEPTH))
{
define('MAXFORUMDEPTH', 1);
}
$forumbits = '';
$depth++;
foreach ($iforumcache["$parentid"] AS $baa)
{
foreach ($baa AS $forumid)
{
// grab the appropriate forum from the $forumcache
$forum = $forumcache["$forumid"];
if (!$forum['displayorder'] OR !($forum['options'] & $_FORUMOPTIONS['active']))
{
continue;
}
$forumperms = $bbuserinfo['forumpermissions']["$forumid"];
if (!($forumperms & CANVIEW) AND $vboptions['hideprivateforums'])
{ // no permission to view current forum
continue;
}
if ($subsonly)
{
$childforumbits = construct_forum_bit($forum['forumid'], 1, $subsonly);
}
else if ($depth < MAXFORUMDEPTH)
{
$childforumbits = construct_forum_bit($forum['forumid'], $depth, $subsonly);
}
else
{
$childforumbits = '';
}
// do stuff if we are not doing subscriptions only, or if we ARE doing subscriptions,
// and the forum has a subscribedforumid
if (!$subsonly OR ($subsonly AND !empty($forum['subscribeforumid'])))
{
$GLOBALS['forumshown'] = true; // say that we have shown at least one forum
if (($forum['options'] & $_FORUMOPTIONS['cancontainthreads']))
{ // get appropriate suffix for template name
$tempext = '_post';
}
else
{
$tempext = '_nopost';
}
if (!$vboptions['showforumdescription'])
{ // blank forum description if set to not show
$forum['description'] = '';
}
// dates & thread title
$lastpostinfo = $forumcache["$lastpostarray[$forumid]"];
// compare last post time for this forum with the last post time specified by
// the $lastpostarray, and if it's less, use the last post info from the forum
// specified by $lastpostarray
if ($forumcache["$lastpostarray[$forumid]"]['lastpost'] > 0)
{
$lastpostinfo['lastpostdate'] = vbdate($vboptions['dateformat'], $lastpostinfo['lastpost'], 1);
$lastpostinfo['lastposttime'] = vbdate($vboptions['timeformat'], $lastpostinfo['lastpost']);
$lastpostinfo['trimthread'] = fetch_trimmed_title($lastpostinfo['lastthread']);
if ($icon = fetch_iconinfo($lastpostinfo['lasticonid']))
{
$show['icon'] = true;
}
else
{
$show['icon'] = false;
}
$show['lastpostinfo'] = (!$forum['password'] OR verify_forum_password($forum['forumid'], $forum['password'], false));
eval('$forum[\'lastpostinfo\'] = "' . fetch_template('forumhome_lastpostby') . '";');
}
else if (!($forumperms & CANVIEW) AND $vboptions['hideprivateforums'] == 0)
{
$forum['lastpostinfo'] = $vbphrase['private'];
}
else
{
$forum['lastpostinfo'] = $vbphrase['never'];
}
// added by dani
$forum['url'] = strtolower(
str_replace(" ", "-",
str_replace("/", "-", $forum['title'])
)
);
// added by dani
// do light bulb
$forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
// added by dani
$forum['url'] = strtolower(str_replace(" ", "-",str_replace("/", "-", $forum['title'])));
// added by dani
// add lock to lightbulb if necessary
if ((!($forumperms & CANPOSTNEW) OR !($forum['options'] & $_FORUMOPTIONS['allowposting'])) AND $vboptions['showlocks'] AND !$forum['link'])
{
$forum['statusicon'] .= '_lock';
}
// get counters from the counters cache ( prepared by fetch_last_post_array() )
$forum['threadcount'] = $counters["$forum[forumid]"]['threadcount'];
$forum['replycount'] = $counters["$forum[forumid]"]['replycount'];
// get moderators ( this is why we needed cache_moderators() )
if ($vboptions['showmoderatorcolumn'])
{
$showmods = array();
$listexploded = explode(',', $forum['parentlist']);
foreach ($listexploded AS $parentforumid)
{
if (!isset($imodcache["$parentforumid"]))
{
continue;
}
foreach($imodcache["$parentforumid"] AS $moderator)
{
if ($showmods["$moderator[userid]"] === true)
{
continue;
}
$showmods["$moderator[userid]"] = true;
if (!isset($forum['moderators']))
{
eval('$forum[\'moderators\'] = "' . fetch_template('forumhome_moderator') . '";');
}
else
{
eval('$forum[\'moderators\'] .= ", ' . fetch_template('forumhome_moderator') . '";');
}
}
}
if (!isset($forum['moderators']))
{
$forum['moderators'] = '';
}
}
if ($forum['link'])
{
$forum['replycount'] = '-';
$forum['threadcount'] = '-';
$forum['lastpostinfo'] = '-';
}
else
{
$forum['replycount'] = vb_number_format($forum['replycount']);
$forum['threadcount'] = vb_number_format($forum['threadcount']);
}
if (($subsonly OR $depth == MAXFORUMDEPTH) AND $vboptions['subforumdepth'] > 0)
{
$forum['subforums'] = construct_subforum_bit($forumid, ($forum['options'] & $_FORUMOPTIONS['cancontainthreads'] ) );
}
else
{
$forum['subforums'] = '';
}
$children = explode(',', $forum['childlist']);
foreach($children AS $childid)
{
$forum['browsers'] += iif($inforum["$childid"], $inforum["$childid"], 0);
}
if ($depth == 1 AND $tempext == '_nopost')
{
global $vbcollapse;
$collapseobj_forumid = &$vbcollapse["collapseobj_forumbit_$forumid"];
$collapseimg_forumid = &$vbcollapse["collapseimg_forumbit_$forumid"];
$show['collapsebutton'] = true;
}
else
{
$show['collapsebutton'] = false;
}
$show['forumsubscription'] = iif ($subsonly, true, false);
$show['forumdescription'] = iif ($forum['description'] != '', true, false);
$show['subforums'] = iif ($forum['subforums'] != '', true, false);
$show['browsers'] = iif ($vboptions['displayloggedin'] AND !$forum['link'] AND $forum['browsers'], true, false);
// build the template for the current forum
eval('$forumbits .= "' . fetch_template("forumhome_forumbit_level$depth$tempext") . '";');
} // end if (!$subsonly OR ($subsonly AND !empty($forum['subscribeforumid'])))
else
{
$forumbits .= $childforumbits;
}
}
}
return $forumbits;
}
// ###################### Start getforumlightbulb #######################
// returns 'on' or 'off' depending on last post info for a forum
function fetch_forum_lightbulb(&$forumid, &$lastpostinfo, &$foruminfo)
{
global $bbuserinfo, $bb_view_cache, $DB_site;
if (is_array($foruminfo) AND !empty($foruminfo['link']))
{ // see if it is a redirect
return 'link';
}
else
{
if ($bbuserinfo['lastvisitdate'] == -1)
{
return 'new';
}
else
{
$forumview = fetch_bbarray_cookie('forum_view', $foruminfo['forumid']);
//use which one produces the highest value, most likely cookie
if ($forumview > $bbuserinfo['lastvisit'])
{
$userlastvisit = $forumview;
}
else
{
$userlastvisit = $bbuserinfo['lastvisit'];
}
if ($userlastvisit < $lastpostinfo['lastpost'])
{
return 'new';
}
else
{
return 'old';
}
}
}
}
// ###################### Start makesubforumbit #######################
// gets a list of a forum's children and returns it
// based on the forumhome_subforumbit template
function construct_subforum_bit($parentid, $cancontainthreads, $output = '', $depthmark = '--', $depth = 0)
{
global $vboptions, $stylevar, $vbphrase, $session;
global $iforumcache, $forumcache, $bbuserinfo, $lastpostinfo, $lastpostarray;
static $splitter;
if ($cancontainthreads)
{
$canpost = 'post';
}
else
{
$canpost = 'nopost';
}
// get the splitter template
if (!isset($splitter["$canpost"]))
{
eval('$splitter[$canpost] = "' . fetch_template("forumhome_subforumseparator_$canpost") . '";');
}
if (!isset($iforumcache["$parentid"]))
{
return $output;
}
foreach($iforumcache["$parentid"] AS $forums)
{
foreach($forums AS $forumid)
{
$forum = $forumcache["$forumid"];
$forumperms = $bbuserinfo['forumpermissions']["$forumid"];
if (!($forumperms & CANVIEW) AND $vboptions['hideprivateforums'])
{ // no permission to view current forum
continue;
}
else
{ // get on/off status
$lastpostinfo = $forumcache["$lastpostarray[$forumid]"];
$forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
$show['newposticon'] = iif($forum['statusicon'], true, false);
eval('$subforum = "' . fetch_template("forumhome_subforumbit_$canpost") . '";');
if (!empty($output))
{
$subforum = $splitter["$canpost"] . $subforum;
}
if ($depth < $vboptions['subforumdepth'])
{
$output .= construct_subforum_bit($forumid, $cancontainthreads, $subforum, $depthmark . '--', $depth + 1);
}
}
}
}
return $output;
}
// ###################### Start geticoninfo #######################
function fetch_iconinfo($iconid = 0)
{
global $DB_site, $vboptions, $stylevar, $vbphrase;
$iconid = intval($iconid);
switch($iconid)
{
case -1:
DEVDEBUG('returning poll icon');
return array('iconpath' => "$stylevar[imgdir_misc]/poll_posticon.gif", 'title' => $vbphrase['poll']);
case 0:
if (!empty($vboptions['showdeficon']))
{
DEVDEBUG("returning default icon");
return array('iconpath' => "$vboptions[showdeficon]", 'title' => '');
}
else
{
return false;
}
default:
global $datastore;
static $iconcache;
if (isset($datastore['iconcache']))
{ // we can get the icon info from the template cache
if (!isset($iconcache))
{
$iconcache = unserialize($datastore['iconcache']);
}
DEVDEBUG("returning iconid
iconid from the template cache");return $iconcache["$iconid"];
}
else
{ // we have to get the icon from a query
DEVDEBUG("QUERYING iconid
iconid)");return $DB_site->query_first("
SELECT title, iconpath
FROM " . TABLE_PREFIX . "icon
WHERE iconid = $iconid
");
}
}
}
/*======================================================================*\
|| ####################################################################
|| # Downloaded: 17:12, Sat Sep 18th 2004
|| # CVS: $RCSfile: functions_forumlist.php,v $ - $Revision: 1.13 $
|| ####################################################################
\*======================================================================*/
?>[/PHP]
•
•
Join Date: Oct 2004
Location: Townsville, Australia
Posts: 16
Reputation:
Rep Power: 5
Solved Threads: 0
Wow: I have linked to this thread from my vb related forum signatures but I have now implelemtned it on mobileforces.org:
One extra step I have gone to is to add the onepost[postid].html rewrite pointing to showpost.php from the postbit template ...
I've found that it falls down rendering the URI's to each forum correctly on forumhome - I'll be looking into why later on...
A couple of other places where it will need re-working as well is in the hardcoded bbcodes [thread] and [post]... an exercise for the reader
Massive work and well worth it - thanks again Dani!
[edit]
Addendum: the error I found was not in the eidts: it's complicated by the Forums in columns on forumhome: the template has been edited, but the $forum variable is not generated in the running of this hack...
I'll look into it further and return the results of my research here
[edit]
Ok - found it
Turns out Xenon constructed a second function to create the columnbit - so you need to add the [php]// added by dani
$forum['url'] = strtolower(str_replace(" ", "-",str_replace("/", "-", $forum['title'])));
// added by dani
[/php] in TWO places: just search for the light-bulb comment twice
Demo: [url="http://www.mobileforces.org/forums/"]http://www.mobileforces.org/forums/
Sorry about the triple-post: Dani, if you could please please merge
One extra step I have gone to is to add the onepost[postid].html rewrite pointing to showpost.php from the postbit template ...
I've found that it falls down rendering the URI's to each forum correctly on forumhome - I'll be looking into why later on...
A couple of other places where it will need re-working as well is in the hardcoded bbcodes [thread] and [post]... an exercise for the reader

Massive work and well worth it - thanks again Dani!
[edit]
Addendum: the error I found was not in the eidts: it's complicated by the Forums in columns on forumhome: the template has been edited, but the $forum variable is not generated in the running of this hack...
I'll look into it further and return the results of my research here

[edit]
Ok - found it

Turns out Xenon constructed a second function to create the columnbit - so you need to add the [php]// added by dani
$forum['url'] = strtolower(str_replace(" ", "-",str_replace("/", "-", $forum['title'])));
// added by dani
[/php] in TWO places: just search for the light-bulb comment twice

Demo: [url="http://www.mobileforces.org/forums/"]http://www.mobileforces.org/forums/
Sorry about the triple-post: Dani, if you could please please merge
Last edited by cscgal : Oct 1st, 2004 at 3:50 pm.
Natcher00 ... is the Admin @ MobileForces.org - Official Community for a cult Vehicle based FPS - the only place for support!
[vB.org] PNG24 transparency with IE * DaniWeb: mod_rewrite your vB
[vB.org] PNG24 transparency with IE * DaniWeb: mod_rewrite your vB
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,020
Reputation:
Rep Power: 33
Solved Threads: 117
No Trader. That's not correct. Notice that you have the line $forum[url]= twice. Once where it belongs, and then a second time a few lines underneath that. Get rid of the second occurrence.
•
•
•
•
Originally Posted by TraderX
Could someone double check this to make sure that I did this correct. I have messed with it soo many times.... I am not sure every thing is in the right place now.
This is my forum/includes/functions_forumlist.php
[PHP]<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 3.0.3 - Licence Number L44230c3
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000–2004 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/
error_reporting(E_ALL & ~E_NOTICE);
// ###################### Start getiforumcache #######################
// pass $bbuserinfo[userid] into the function in order to return a value
// for which forums are subscribed ($arry[subscribeforumid])
function cache_ordered_forums($getcounters = 0, $getinvisibles = 0, $userid = 0)
{
global $DB_site, $iforumcache, $forumcache, $_FORUMOPTIONS, $bbuserinfo;
$forumfields = 'forum.forumid, lastpost, lastposter, lastthread, lastthreadid, lasticonid, threadcount, replycount';
// query forum table to get latest lastpost/lastthread info and counters
if ($getcounters)
{
// get subscribed forums too
if ($userid)
{
$query = "
SELECT subscribeforumid, $forumfields
FROM " . TABLE_PREFIX . "forum AS forum
LEFT JOIN " . TABLE_PREFIX . "subscribeforum AS subscribeforum ON (subscribeforum.forumid = forum.forumid AND subscribeforum.userid = $userid)
";
}
// just get counters
else
{
$query = "
SELECT $forumfields
FROM " . TABLE_PREFIX . "forum AS forum
";
}
}
// don't bother to query forum table, just use the cache
else
{
// get subscribed forums
if ($userid)
{
$query = "
SELECT subscribeforumid, forumid
FROM " . TABLE_PREFIX . "subscribeforum
WHERE userid = $userid
";
}
}
if ($query)
{
$getthings = $DB_site->query($query);
if ($DB_site->num_rows($getthings))
{
while ($getthing = $DB_site->fetch_array($getthings))
{
if (empty($forumcache["$getthing[forumid]"]))
{
$forumcache["$getthing[forumid]"] = array();
}
$forumcache["$getthing[forumid]"] = array_merge($forumcache["$getthing[forumid]"], $getthing);
}
}
}
$iforumcache = array();
if ($getinvisibles) // get all forums including invisibles
{
foreach($forumcache AS $forumid => $forum)
{
$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forumid"] = $forumid;
}
}
else // get all forums except invisibles
{
foreach($forumcache AS $forumid => $forum)
{
if ($forum['displayorder'] AND ($forum['options'] & $_FORUMOPTIONS['active']))
{
$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forumid"] = $forumid;
}
else
{
unset($forumcache["$forumid"]);
}
}
}
// do some sorting (instead of sorting with MySQL and causing a filesort)
foreach($iforumcache AS $parentid => $devnull)
{
ksort($iforumcache["$parentid"]); // sort by display order
}
ksort($iforumcache); // sort by parentid (not actually sure if this is necessary)
}
// ###################### Start getimodcache #######################
function cache_moderators()
{
global $DB_site, $imodcache, $mod;
$imodcache = array();
$mod = array();
$forummoderators = $DB_site->query("
SELECT moderator.*, user.username,
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid
FROM " . TABLE_PREFIX . "moderator AS moderator
INNER JOIN " . TABLE_PREFIX . "user AS user USING(userid)
");
while ($moderator = $DB_site->fetch_array($forummoderators))
{
$moderator['musername'] = fetch_musername($moderator);
$imodcache["$moderator[forumid]"]["$moderator[userid]"] = $moderator;
$mod["$moderator[userid]"] = 1;
}
$DB_site->free_result($forummoderators);
}
// ###################### Start getlastpostinfo #######################
// this function creates a lastpostinfo array that tells makeforumbit which forum
// each forum should grab its last post info from.
// it also tots up the thread/post totals for each forum. - PERMISSIONS are taken into account.
function fetch_last_post_array()
{
global $iforumcache, $forumcache, $lastpostarray, $bbuserinfo, $counters;
// loop through the iforumcache
foreach($iforumcache AS $moo)
{
foreach($moo AS $baa)
{
foreach ($baa AS $forumid)
{
$forum = $forumcache["$forumid"];
// if we have no permission to view the forum's parent
// set cannotView permissions cache for this forum and continue
if ($cannotView["$forum[parentid]"] == 1)
{
$cannotView["$forumid"] = 1;
}
else
{
$forumperms = $bbuserinfo['forumpermissions']["$forumid"];
// if we have no permissions for this forum, set the cannotView permissions cache
// so that we don't have to check its child forums
//if (!($forumperms & CANVIEW) OR !($forumperms & CANVIEWOTHERS))
if (!($forumperms & CANVIEW))
{
$cannotView["$forumid"] = 1;
}
else
{
if (!($forumperms & CANVIEWOTHERS))
{
continue;
}
//$lastpostarray["$forumid"] = $forumid;
if (!isset($lastpostarray["$forumid"]))
{
$lastpostarray["$forumid"] = $forumid;
}
$parents = explode(',', $forum['parentlist']);
foreach($parents AS $parentid)
{
// for each parent, set an array entry containing this forum's number of posts & threads
$children["$parentid"]["$forumid"] = array('threads' => $forum['threadcount'], 'posts' => $forum['replycount']);
if ($parentid == -1 OR !is_array($forumcache["$parentid"]))
{
continue;
}
// compare the date for the last post info with the last post date
// for the parent forum, and if it's greater, set the last post info
// array for this forum to point to that forum... (erm..)
if ((!$forum['password'] OR verify_forum_password($forum['forumid'], $forum['password'], false)) AND $forum['lastpost'] > $forumcache["$parentid"]['lastpost'])
{
$lastpostarray["$parentid"] = $forumid;
$forumcache["$parentid"]['lastpost'] = $forum['lastpost'];
}
} // end foreach($parents)
} // end can view
} // end can view parent
}
}
}
$counters = array();
if (is_array($forumcache))
{
foreach($forumcache AS $forum)
{
$counters["$forum[forumid]"]['threadcount'] = 0;
$counters["$forum[forumid]"]['replycount'] = 0;
if (is_array($children["$forum[forumid]"]))
{
foreach($children["$forum[forumid]"] AS $id => $info)
{
$counters["$forum[forumid]"]['threadcount'] += $info['threads'];
$counters["$forum[forumid]"]['replycount'] += $info['posts'];
}
}
}
}
return $i;
}
// ###################### Start makeforumbit #######################
// this function returns the properly-ordered and formatted forum lists for forumhome,
// forumdisplay and usercp. Of course, you could use it elsewhere too..
function construct_forum_bit($parentid, $depth = 0, $subsonly = 0)
{
global $vboptions, $DB_site, $session, $bbuserinfo, $stylevar, $_FORUMOPTIONS, $vbphrase, $show;
global $iforumcache, $forumcache, $imodcache, $lastpostarray, $counters, $inforum;
// this function takes the constant MAXFORUMDEPTH as its guide for how
// deep to recurse down forum lists. if MAXFORUMDEPTH is not defined,
// it will assume a depth of 2.
// call fetch_last_post_array() first to get last post info for forums
if (!is_array($lastpostarray))
{
fetch_last_post_array();
}
if (!isset($iforumcache["$parentid"]))
{
return;
}
if (!defined(MAXFORUMDEPTH))
{
define('MAXFORUMDEPTH', 1);
}
$forumbits = '';
$depth++;
foreach ($iforumcache["$parentid"] AS $baa)
{
foreach ($baa AS $forumid)
{
// grab the appropriate forum from the $forumcache
$forum = $forumcache["$forumid"];
if (!$forum['displayorder'] OR !($forum['options'] & $_FORUMOPTIONS['active']))
{
continue;
}
$forumperms = $bbuserinfo['forumpermissions']["$forumid"];
if (!($forumperms & CANVIEW) AND $vboptions['hideprivateforums'])
{ // no permission to view current forum
continue;
}
if ($subsonly)
{
$childforumbits = construct_forum_bit($forum['forumid'], 1, $subsonly);
}
else if ($depth < MAXFORUMDEPTH)
{
$childforumbits = construct_forum_bit($forum['forumid'], $depth, $subsonly);
}
else
{
$childforumbits = '';
}
// do stuff if we are not doing subscriptions only, or if we ARE doing subscriptions,
// and the forum has a subscribedforumid
if (!$subsonly OR ($subsonly AND !empty($forum['subscribeforumid'])))
{
$GLOBALS['forumshown'] = true; // say that we have shown at least one forum
if (($forum['options'] & $_FORUMOPTIONS['cancontainthreads']))
{ // get appropriate suffix for template name
$tempext = '_post';
}
else
{
$tempext = '_nopost';
}
if (!$vboptions['showforumdescription'])
{ // blank forum description if set to not show
$forum['description'] = '';
}
// dates & thread title
$lastpostinfo = $forumcache["$lastpostarray[$forumid]"];
// compare last post time for this forum with the last post time specified by
// the $lastpostarray, and if it's less, use the last post info from the forum
// specified by $lastpostarray
if ($forumcache["$lastpostarray[$forumid]"]['lastpost'] > 0)
{
$lastpostinfo['lastpostdate'] = vbdate($vboptions['dateformat'], $lastpostinfo['lastpost'], 1);
$lastpostinfo['lastposttime'] = vbdate($vboptions['timeformat'], $lastpostinfo['lastpost']);
$lastpostinfo['trimthread'] = fetch_trimmed_title($lastpostinfo['lastthread']);
if ($icon = fetch_iconinfo($lastpostinfo['lasticonid']))
{
$show['icon'] = true;
}
else
{
$show['icon'] = false;
}
$show['lastpostinfo'] = (!$forum['password'] OR verify_forum_password($forum['forumid'], $forum['password'], false));
eval('$forum[\'lastpostinfo\'] = "' . fetch_template('forumhome_lastpostby') . '";');
}
else if (!($forumperms & CANVIEW) AND $vboptions['hideprivateforums'] == 0)
{
$forum['lastpostinfo'] = $vbphrase['private'];
}
else
{
$forum['lastpostinfo'] = $vbphrase['never'];
}
// added by dani
$forum['url'] = strtolower(
str_replace(" ", "-",
str_replace("/", "-", $forum['title'])
)
);
// added by dani
// do light bulb
$forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
// added by dani
$forum['url'] = strtolower(str_replace(" ", "-",str_replace("/", "-", $forum['title'])));
// added by dani
// add lock to lightbulb if necessary
if ((!($forumperms & CANPOSTNEW) OR !($forum['options'] & $_FORUMOPTIONS['allowposting'])) AND $vboptions['showlocks'] AND !$forum['link'])
{
$forum['statusicon'] .= '_lock';
}
// get counters from the counters cache ( prepared by fetch_last_post_array() )
$forum['threadcount'] = $counters["$forum[forumid]"]['threadcount'];
$forum['replycount'] = $counters["$forum[forumid]"]['replycount'];
// get moderators ( this is why we needed cache_moderators() )
if ($vboptions['showmoderatorcolumn'])
{
$showmods = array();
$listexploded = explode(',', $forum['parentlist']);
foreach ($listexploded AS $parentforumid)
{
if (!isset($imodcache["$parentforumid"]))
{
continue;
}
foreach($imodcache["$parentforumid"] AS $moderator)
{
if ($showmods["$moderator[userid]"] === true)
{
continue;
}
$showmods["$moderator[userid]"] = true;
if (!isset($forum['moderators']))
{
eval('$forum[\'moderators\'] = "' . fetch_template('forumhome_moderator') . '";');
}
else
{
eval('$forum[\'moderators\'] .= ", ' . fetch_template('forumhome_moderator') . '";');
}
}
}
if (!isset($forum['moderators']))
{
$forum['moderators'] = '';
}
}
if ($forum['link'])
{
$forum['replycount'] = '-';
$forum['threadcount'] = '-';
$forum['lastpostinfo'] = '-';
}
else
{
$forum['replycount'] = vb_number_format($forum['replycount']);
$forum['threadcount'] = vb_number_format($forum['threadcount']);
}
if (($subsonly OR $depth == MAXFORUMDEPTH) AND $vboptions['subforumdepth'] > 0)
{
$forum['subforums'] = construct_subforum_bit($forumid, ($forum['options'] & $_FORUMOPTIONS['cancontainthreads'] ) );
}
else
{
$forum['subforums'] = '';
}
$children = explode(',', $forum['childlist']);
foreach($children AS $childid)
{
$forum['browsers'] += iif($inforum["$childid"], $inforum["$childid"], 0);
}
if ($depth == 1 AND $tempext == '_nopost')
{
global $vbcollapse;
$collapseobj_forumid = &$vbcollapse["collapseobj_forumbit_$forumid"];
$collapseimg_forumid = &$vbcollapse["collapseimg_forumbit_$forumid"];
$show['collapsebutton'] = true;
}
else
{
$show['collapsebutton'] = false;
}
$show['forumsubscription'] = iif ($subsonly, true, false);
$show['forumdescription'] = iif ($forum['description'] != '', true, false);
$show['subforums'] = iif ($forum['subforums'] != '', true, false);
$show['browsers'] = iif ($vboptions['displayloggedin'] AND !$forum['link'] AND $forum['browsers'], true, false);
// build the template for the current forum
eval('$forumbits .= "' . fetch_template("forumhome_forumbit_level$depth$tempext") . '";');
} // end if (!$subsonly OR ($subsonly AND !empty($forum['subscribeforumid'])))
else
{
$forumbits .= $childforumbits;
}
}
}
return $forumbits;
}
// ###################### Start getforumlightbulb #######################
// returns 'on' or 'off' depending on last post info for a forum
function fetch_forum_lightbulb(&$forumid, &$lastpostinfo, &$foruminfo)
{
global $bbuserinfo, $bb_view_cache, $DB_site;
if (is_array($foruminfo) AND !empty($foruminfo['link']))
{ // see if it is a redirect
return 'link';
}
else
{
if ($bbuserinfo['lastvisitdate'] == -1)
{
return 'new';
}
else
{
$forumview = fetch_bbarray_cookie('forum_view', $foruminfo['forumid']);
//use which one produces the highest value, most likely cookie
if ($forumview > $bbuserinfo['lastvisit'])
{
$userlastvisit = $forumview;
}
else
{
$userlastvisit = $bbuserinfo['lastvisit'];
}
if ($userlastvisit < $lastpostinfo['lastpost'])
{
return 'new';
}
else
{
return 'old';
}
}
}
}
// ###################### Start makesubforumbit #######################
// gets a list of a forum's children and returns it
// based on the forumhome_subforumbit template
function construct_subforum_bit($parentid, $cancontainthreads, $output = '', $depthmark = '--', $depth = 0)
{
global $vboptions, $stylevar, $vbphrase, $session;
global $iforumcache, $forumcache, $bbuserinfo, $lastpostinfo, $lastpostarray;
static $splitter;
if ($cancontainthreads)
{
$canpost = 'post';
}
else
{
$canpost = 'nopost';
}
// get the splitter template
if (!isset($splitter["$canpost"]))
{
eval('$splitter[$canpost] = "' . fetch_template("forumhome_subforumseparator_$canpost") . '";');
}
if (!isset($iforumcache["$parentid"]))
{
return $output;
}
foreach($iforumcache["$parentid"] AS $forums)
{
foreach($forums AS $forumid)
{
$forum = $forumcache["$forumid"];
$forumperms = $bbuserinfo['forumpermissions']["$forumid"];
if (!($forumperms & CANVIEW) AND $vboptions['hideprivateforums'])
{ // no permission to view current forum
continue;
}
else
{ // get on/off status
$lastpostinfo = $forumcache["$lastpostarray[$forumid]"];
$forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
$show['newposticon'] = iif($forum['statusicon'], true, false);
eval('$subforum = "' . fetch_template("forumhome_subforumbit_$canpost") . '";');
if (!empty($output))
{
$subforum = $splitter["$canpost"] . $subforum;
}
if ($depth < $vboptions['subforumdepth'])
{
$output .= construct_subforum_bit($forumid, $cancontainthreads, $subforum, $depthmark . '--', $depth + 1);
}
}
}
}
return $output;
}
// ###################### Start geticoninfo #######################
function fetch_iconinfo($iconid = 0)
{
global $DB_site, $vboptions, $stylevar, $vbphrase;
$iconid = intval($iconid);
switch($iconid)
{
case -1:
DEVDEBUG('returning poll icon');
return array('iconpath' => "$stylevar[imgdir_misc]/poll_posticon.gif", 'title' => $vbphrase['poll']);
case 0:
if (!empty($vboptions['showdeficon']))
{
DEVDEBUG("returning default icon");
return array('iconpath' => "$vboptions[showdeficon]", 'title' => '');
}
else
{
return false;
}
default:
global $datastore;
static $iconcache;
if (isset($datastore['iconcache']))
{ // we can get the icon info from the template cache
if (!isset($iconcache))
{
$iconcache = unserialize($datastore['iconcache']);
}
DEVDEBUG("returning iconidiconid from the template cache");
return $iconcache["$iconid"];
}
else
{ // we have to get the icon from a query
DEVDEBUG("QUERYING iconidiconid)");
return $DB_site->query_first("
SELECT title, iconpath
FROM " . TABLE_PREFIX . "icon
WHERE iconid = $iconid
");
}
}
}
/*======================================================================*\
|| ####################################################################
|| # Downloaded: 17:12, Sat Sep 18th 2004
|| # CVS: $RCSfile: functions_forumlist.php,v $ - $Revision: 1.13 $
|| ####################################################################
\*======================================================================*/
?>[/PHP]
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
OK... I am still having problems with my Sub-Forum (FXME) at www.4xtraders.com/forum working. Below is what I have for my forumhome_subforumbit_nopost and forumhome_subforumbit_post with the changes.
forumhome_subforumbit_nopost
forumhome_subforumbit_post
This is what I have in my .htaccess file. And I have doubled checked with my forum manager for the correct forum ID for FXME. (should be be something different SINCE it is a SUB-FORUM?)
With all of the changes and if I am to hover over my FXME forum I get this:
forum/.html
which leads me to a (403) You are not authorized to view this page
Now if I revert my forumhome_subforumbit_post and hover I get this /forumdisplay.php?f=43 and it works just fine, but it isn't what the forum is called.
Any one have any suggestions?
Thanks in advance
Coll
forumhome_subforumbit_nopost
<img class="inlineimg" src="$stylevar[imgdir_statusicon]/subforum_$forum[statusicon].gif" alt="" /> <a href="$forum[url].html">$forum[title]</a>
forumhome_subforumbit_post
<img class="inlineimg" src="$stylevar[imgdir_statusicon]/subforum_$forum[statusicon].gif" alt="" /> <a href="$forum[url].html">$forum[title]</a>
This is what I have in my .htaccess file. And I have doubled checked with my forum manager for the correct forum ID for FXME. (should be be something different SINCE it is a SUB-FORUM?)
RewriteRule ^FXME.html$ forumdisplay.php?f=43 [L]
With all of the changes and if I am to hover over my FXME forum I get this:
forum/.html
which leads me to a (403) You are not authorized to view this page
Now if I revert my forumhome_subforumbit_post and hover I get this /forumdisplay.php?f=43 and it works just fine, but it isn't what the forum is called.
Any one have any suggestions?
Thanks in advance
Coll
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- [Revised] vBulletin Mod_rewrite Tutorial (PHP)
- vBulletin mod_rewrite for vB 3.0.7 (Existing Scripts)
- vBulletin mod_rewrite for vB 3.0.7 (Growing an Online Community)
- vBulletin mod_rewrite in phpBB mod format (Existing Scripts)
Other Threads in the PHP Forum
- Previous Thread: Help Needed
- Next Thread: mysql_num_rows warning



Linear Mode