View Full Version : Mod request
tomshawk
07-29-2004, 10:37 AM
When you subscribe to a forum, you see the forum name and last post in the UserCP.
I'd like to be able have a block in the homepage, that shows your subscribed forums. (Just the name of the forum) That the user can click on to go straight to that forum.
Obviously it would be dynamic and change as you subscribe and unsuscribe.
Is that possible?
tomshawk
07-30-2004, 06:43 PM
Anybody?
This is the code for the Subscribed Forums section of the UserCP
Hopefully it will help someone get started with this
<!-- ############## SUBSCRIBED FORUMS ############## -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="54%" align="right"><tr><td>
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<tr>
<td class="tcat" colspan="<if condition="$vboptions['showmoderatorcolumn']">6<else />5</if>">Subscribed Forums
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('usercp_forums')"><img id="collapseimg_usercp_forums" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_usercp_forums].gif" alt="" border="0" /></a>
$vbphrase[subscribed_forums]
</td>
</tr>
</thead>
<tbody id="collapseobj_usercp_forums" style="$vbcollapse[collapseobj_usercp_forums]">
<tr align="center" valign="bottom">
<td class="thead" width="2%"> </td>
<td class="thead" align="$stylevar[left]" width="80%">$vbphrase[forum]</td>
<td class="thead">$vbphrase[last_post]</td>
<td class="thead">$vbphrase[replies]</td>
<td class="thead">$vbphrase[views]</td>
<if condition="$vboptions['showmoderatorcolumn']">
<td class="thead" width="20%">$vbphrase[moderator]</td>
</if>
</tr>
$forumbits
</tbody>
</table>
<br />
</table>
<!-- ############## END SUBSCRIBED FORUMS ############## -->
Any help with this would be greatly appriciated
tomshawk
08-01-2004, 08:03 PM
Well, Just for giggles, I posted the above into a template and made a module and a page. For testing purposes, I made it a center block, but I want it to be a side block in the end.
http://www.tomshawk.com/index.php?page=subscribed
As you can see, it doesnt work
I know from the forums usercp.php file that this is needed somewhere
// ############################### start subscribed forums ###############################
// get only subscribed forums
cache_ordered_forums(1, 0, $bbuserinfo['userid']);
$show['forums'] = false;
foreach ($forumcache AS $forumid => $forum)
{
if ($forum['subscribeforumid'] != '')
{
$show['forums'] = true;
}
}
if ($show['forums'])
{
if ($vboptions['showmoderatorcolumn'])
{
cache_moderators();
}
else
{
$imodcache = array();
$mod = array();
}
fetch_last_post_array();
$forumbits = construct_forum_bit(-1, 0, 1);
if ($forumshown == 1)
{
$show['forums'] = true;
}
else
{
$show['forums'] = false;
}
}
I wonder if putting this into the cmdp_index.php file would work.
Actually only parts of it, the parts to create only the forum name
tomshawk
08-03-2004, 12:39 AM
OK, As you can see, I have it working now, meaning I have it showing exactely the same thing that would show in UserCP Subscribed Forums
http://www.tomshawk.com/index.php?page=subscribed
Nothing if your not logged in, and forums if you are logged in, but it shows everything, forums, threadbits, Everything.
Could I please get some help narrowing it down to just what I need, Only the forum name
Here is the code for the Template I have
<!-- ############## SUBSCRIBED FORUMS ############## -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<tr>
<td class="tcat" colspan="<if condition="$vboptions['showmoderatorcolumn']">6<else />5</if>">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('usercp_forums')"><img id="collapseimg_usercp_forums" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_usercp_forums].gif" alt="" border="0" /></a>
$vbphrase[subscribed_forums]
</td>
</tr>
</thead>
<tbody id="collapseobj_usercp_forums" style="$vbcollapse[collapseobj_usercp_forums]">
<tr align="center" valign="bottom">
<td class="thead" width="2%"> </td>
<td class="thead" align="$stylevar[left]" width="80%">$vbphrase[forum]</td>
<td class="thead">$vbphrase[last_post]</td>
<td class="thead">$vbphrase[replies]</td>
<td class="thead">$vbphrase[views]</td>
<if condition="$vboptions['showmoderatorcolumn']">
<td class="thead" width="20%">$vbphrase[moderator]</td>
</if>
</tr>
$forumbits
</tbody>
</table>
<br />
<!-- ############## END SUBSCRIBED FORUMS ############## -->
Attached is the Module subscribe.php and a picture of what it looks like now when logged in.
I have it set up as a center block on it's own page for now, but when done, I want it as a Left or Right block.
Please, Brian or someone, Please help me.
I'm willing to pay for this
mholtum
08-03-2004, 02:33 AM
When you get it ironed out, I am interested..
tomshawk
08-03-2004, 09:08 AM
Will do ;)
I think I know what needs to be done now.
the $forumbits code is being pulled from the includes\functions_forumlist.php
Its just going to be a matter of figuring out which section it is using then copting that, modifying it and making the new call.
boey, I dont see how you coders can do this all the time, this is frustrating stuff :p
Thank you mholtum, Your interest is encouraging ;)
Brian
08-03-2004, 09:13 AM
In the file you created, somewhere above the construct_forum_bit() function, try adding:
$show['hideextra'] = true;
Then in the templates (I'm assuming that uses forumhome_forumbit_levelX_) you could use this if condition to hide the other stuff:
<if condition="!$show['hideextra']">
tomshawk
08-03-2004, 09:35 AM
Thanks Brian
It's probably just the placement of this
<if condition="!$show['hideextra']"> then again I'm not positive, because it did nothing
I have to get off to work, so I'll continue playing with it tonight
This is the code from the functions_forumlist.php
// ###################### 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'];
}
// do light bulb
$forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
// 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;
If anybody gets a winfall of an idea :p
Brian
08-03-2004, 09:42 AM
So you put the "$show['hideextra'] = true;" in your subscribed.php file and that if condition doesn't work to hide the other stuff afterwards?
tomshawk
08-03-2004, 12:00 PM
So you put the "$show['hideextra'] = true;" in your subscribed.php file and that if condition doesn't work to hide the other stuff afterwards?
Yes, I tryed puttng this "$show['hideextra'] = true;" in the subscribed.php and this "<if condition="!$show['hideextra']">" in the template.
but, I pressume it is the placement within the file and template or both.
I'll play with it some more tonight ;)
Thanks again
tomshawk
08-03-2004, 11:39 PM
Well, I tryed moving these all over the template as well as the file, the only thing I got was nothing, meaning everything disappeared, or everything stayed where it was.
Any more ideas Brian?
Brian
08-03-2004, 11:46 PM
So when you added that to the template then everything disappeared? If so, then that's pretty much what should have happened. You can use that variable in the template to remove the other table cells with the info you don't want in that module.
tomshawk
08-04-2004, 12:06 AM
The problem is,
one line was all,
the next was nothing,
Kind of hard to move around :p I ran out of ideas :(
tomshawk
08-04-2004, 12:11 AM
The problem is,
one line was all,
the next was nothing,
Kind of hard to move around :p I ran out of ideas :(OK, I have it narrowed down, it is the $forumbits line for the functions_forumlist.php file.
:( I was affraid of that.
So, does anybody know how to modify the code above in that post that talks about functions_forumlist.php.
Bascially making another call
Brian
08-04-2004, 12:38 PM
The problem is,
one line was all,
the next was nothing,
Kind of hard to move around :p I ran out of ideas :(
I'm not entirely sure what you mean by that... I threw a copy on my localhost real quick and it seems to be working fine for me. The only thing I really had to change were my 'forumhome_forumbit_levelX_post' templates. Here's what I've got for mine:
forumhome_forumbit_level1_post
<tbody>
<tr align="center">
<td class="alt1Active" colspan="2" align="$stylevar[left]" id="f$forum[forumid]">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<if condition="!$show['hideextra']"><td><img src="$stylevar[imgdir_statusicon]/forum_$forum[statusicon].gif" alt="" border="0" /></td>
<td><img src="$vboptions[cleargifurl]" alt="" width="9" height="1" border="0" /></td></if>
<td>
<div>
<a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]"><strong>$forum[title]</strong></a>
<if condition="$show['browsers']"><span class="smallfont">(<phrase 1="$forum[browsers]">$vbphrase[x_viewing]</phrase>)</span></if>
</div>
<if condition="$show['forumdescription']"><div class="smallfont">$forum[description]</div></if>
<if condition="$show['forumsubscription']"><div class="smallfont"><strong><a href="subscription.php?$session[sessionurl]do=removesubscription&f=$forum[forumid]">$vbphrase[unsubscribe_from_this_forum]</a></strong></div></if>
<if condition="$show['subforums']"><div class="smallfont" style="margin-top:$stylevar[cellpadding]px"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
</td>
</tr>
</table>
</td>
<if condition="!$show['hideextra']"><td class="alt2" nowrap="nowrap">$forum[lastpostinfo]</td>
<td class="alt1">$forum[threadcount]</td>
<td class="alt2">$forum[replycount]</td>
<if condition="$vboptions['showmoderatorcolumn']">
<td class="alt1"><div class="smallfont">$forum[moderators] </div></td>
</if></if>
</tr>
</tbody>
<if condition="$childforumbits">
<tbody>
$childforumbits
</tbody>
</if>
forumhome_forumbit_level2_post
<tr align="center">
<if condition="!$show['hideextra']"><td class="alt2"><img src="$stylevar[imgdir_statusicon]/forum_$forum[statusicon].gif" alt="" border="0" /></td></if>
<td class="alt1Active" align="$stylevar[left]" id="f$forum[forumid]">
<div>
<a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]"><strong>$forum[title]</strong></a>
<if condition="$show['browsers']"><span class="smallfont">(<phrase 1="$forum[browsers]">$vbphrase[x_viewing]</phrase>)</span></if>
</div>
<if condition="$show['forumdescription']"><div class="smallfont">$forum[description]</div></if>
<if condition="$show['forumsubscription']"><div class="smallfont"><strong><a href="subscription.php?$session[sessionurl]do=removesubscription&f=$forum[forumid]">$vbphrase[unsubscribe_from_this_forum]</a></strong></div></if>
<if condition="$show['subforums']"><div class="smallfont" style="margin-top:$stylevar[cellpadding]px"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
</td>
<if condition="!$show['hideextra']"> <td class="alt2" nowrap="nowrap">$forum[lastpostinfo]</td>
<td class="alt1">$forum[threadcount]</td>
<td class="alt2">$forum[replycount]</td>
<if condition="$vboptions['showmoderatorcolumn']">
<td class="alt1"><div class="smallfont">$forum[moderators] </div></td></if>
</if>
</tr>
$childforumbits
Does that help any, or am I missing something?
tomshawk
08-04-2004, 03:31 PM
That was it, I miss read your original post, I was adding it to the template I made adv_portal_subscribed. My Fault Thank you very much.
I will write this up and release it sometime tonight.
Thank you very Brian ;) Excellent Product and excellent help as always ;)
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.