PDA

View Full Version : How would I modify latesttopics.php to display other forums?


Ras Masta
05-16-2004, 01:40 PM
I want to create a new module with CMPS. I want it to display from my reviews forum and I figured the easiest way to do this is to basically copy the latesttopics.php, modify the coding and then save it as latestreviews.php

My only problem is...how would I go about entering the forum ID number without doing it through the VBA Options.

if ($vba_options['portal_threads_maxthreads'])
{
if ($vba_options['portal_threads_forumids'])
{

if (!empty($forumperms))
{
$inforums = array();
$threadsforums = explode(',', $vba_options['portal_threads_forumids']);
foreach ($threadsforums AS $tforum)
{
if (!in_array($tforum, $forumperms))
{
$inforums[] = $tforum;
}
}
if (!empty($inforums))
{
$inforums = implode(',', $inforums);
}
}
else
{
$inforums = $vba_options['portal_threads_forumids'];
}
if ($inforums)
{
$inforum = 'AND thread.forumid IN (' . $inforums . ')';
}
}

$foruminfo['allowratings'] = $vba_options['portal_threads_showrating'];

$show['lastpost'] = $vba_options['portal_threads_lastpost'];

if ($vba_options['portal_threads_showsubscribed'] AND $bbuserinfo['userid'])
{
$subfields = ', NOT ISNULL(subscribethread.subscribethreadid) AS subscribed';
$subjoin = 'LEFT JOIN ' . TABLE_PREFIX . 'subscribethread AS subscribethread ON (subscribethread.threadid = thread.threadid AND subscribethread.userid = ' . $bbuserinfo['userid'] . ')';
}

if ($vba_options['portal_threads_showpreview'] AND $vboptions['threadpreview'])
{
$previewfields = ', post.pagetext AS preview';
$previewjoin = 'LEFT JOIN ' . TABLE_PREFIX . 'post AS post ON (post.postid = thread.firstpostid)';
}

if ($vba_options['portal_threads_showforum'])
{
$forumfields = ',thread.forumid, forum.title AS forumtitle';
$forumjoin = 'LEFT JOIN ' . TABLE_PREFIX . 'forum AS forum ON (thread.forumid = forum.forumid)';
}

if ($vba_options['portal_threads_showicon'])
{
$iconfields = ', thread.iconid AS threadiconid, iconpath AS threadiconpath';
$iconjoin = 'LEFT JOIN ' . TABLE_PREFIX . 'icon USING (iconid)';
}

$threads = $DB_site->query("
SELECT
" . iif($vba_options['portal_threads_showrating'], 'IF(votenum >= ' . $vboptions['showvotes'] . ', votenum, 0) AS votenum, IF(votenum >= ' . $vboptions['showvotes'] . ' AND votenum != 0, votetotal / votenum, 0) AS voteavg,') . "
thread.threadid, thread.title, thread.replycount, postusername, postuserid, thread.dateline AS postdateline, IF(views <= thread.replycount, thread.replycount+1, views) AS views, thread.lastposter, thread.lastpost, pollid
$iconfields
$forumfields
$previewfields
$subfields
FROM " . TABLE_PREFIX . "thread as thread
$iconjoin
$forumjoin
$previewjoin
$deljoin
$subjoin
WHERE open <> '10' AND thread.visible = 1 $iforumperms $inforum $notdeleted
ORDER BY lastpost DESC
LIMIT $vba_options[portal_threads_maxthreads]
");
while ($thread = $DB_site->fetch_array($threads))
{
if (strlen($thread['title']) > $vba_options['portal_threads_maxchars'] AND $vba_options['portal_threads_maxchars'])
{
$thread['title'] = fetch_trimmed_title($thread['title'], $vba_options['portal_threads_maxchars']);
}

$thread = process_thread_array($thread, '', $vba_options['portal_threads_showicon']);

$getbgrow = getrowcolor();

eval('$threadbits .= "' . fetch_template('adv_portal_latesttopicbits') . '";');
}

eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_latesttopics') . '";');

$DB_site->free_result($threads);
unset($thread, $foruminfo['allowratings']);
}

Brian
05-16-2004, 01:50 PM
Change this line:

WHERE open <> '10' AND thread.visible = 1 $iforumperms $inforum $notdeleted

To something like this:

WHERE open <> '10' AND thread.visible = 1 AND thread.forumid IN(X,Y,Z) $notdeleted

And replace X,Y,Z there with the forumid(s) you would like it to pull threads from. :)

Our Sponsors
 

r00t3d
05-16-2004, 03:40 PM
nice that worked great.

One other thing how can I change the block title from Latest Forum Topics to Latest Reviews?

r00t3d
05-16-2004, 03:56 PM
i just realised when i make that change, the orginal latest forum topics on the right will show the latest reviews first then show the other threads below, take a look at http://www.ut2k4.com/cmps_index.php

Our Sponsors
 

Ras Masta
05-17-2004, 12:09 AM
Yea I had that problem also.

Nice layout for your site. Did you create that or download it?

Brian
05-17-2004, 12:23 PM
To change the title of that module, first edit your Reviews module and change the "Identifier" option to "reviews" (or whatever you'd like). Then edit your "adv_portal_latesttopics" template and look for:

$vbphrase[latest_forum_topics]

Replace that with:

<if condition="$mod['identifier'] == 'reviews'">Reviews<else />$vbphrase[latest_forum_topics]</if>


As for the threads being displayed twice, try opening your forum/modules/latesttopics.php file & the new file you created and look for:

unset($thread, $foruminfo['allowratings']);

Replace that with:

unset($thread, $threadbits, $foruminfo['allowratings']);

And it should fix the problem.

r00t3d
05-17-2004, 01:44 PM
As for the threads being displayed twice, try opening your forum/modules/latesttopics.php file & the new file you created and look for:

unset($thread, $foruminfo['allowratings']);

Replace that with:

unset($thread, $threadbits, $foruminfo['allowratings']);

And it should fix the problem.

Do the i need to make the above changes to both files or just 1?

Brian
05-17-2004, 01:58 PM
Both. :)

r00t3d
05-17-2004, 03:02 PM
To change the title of that module, first edit your Reviews module and change the "Identifier" option to "reviews" (or whatever you'd like). Then edit your "adv_portal_latesttopics" template and look for:

$vbphrase[latest_forum_topics]

Replace that with:

<if condition="$mod['identifier'] == 'reviews'">Reviews<else />$vbphrase[latest_forum_topics]</if>


I have edited the above as advised, but the block is still showing Latest Forum Topics....

Brian
05-17-2004, 03:05 PM
*Edit*
Sorry, I think I misread the problem the first time. Did you enter "reviews" for the module identifier, or something else? If you entered something else then you'll need to make sure that you have the same thing in the if condition.

<if condition="$mod['identifier'] == 'reviews'">

SmasherMaster
05-17-2004, 09:09 PM
This works wonderfully! :D

tomshawk
07-25-2004, 02:18 AM
Hello Brian,

I have done everything in this thread and can not get the second thread module to show a different name.

I realize this is an old thread, so maybe something has changed in the newer version of the portal.

Could you give me a hand?

The only difference is the name. It's not reviews, On my site, I called it "Latest QOTW"

So in the adv_portal_latesttopics i Typed it up like this

<if condition="$mod['identifier'] == 'Latest_QOTW' ">Latest_QOTW<else />$vbphrase[latest_forum_topics]</if>

and I named the Module "Latest_QOTW" as well
I typed "Latest_QOTW" in the Identifier

but it still comes up with "Latest Forum Topics"

The module file name is latestqotw.php if that makes a difference

Like I said, I realize this is an old thread, so I'm hoping something simple was changed. but...

Any help would be greatly appriciated.

Brian
07-25-2004, 10:31 PM
Gotta love it when you forget what you named your own variables. Try $mods['identifier'] instead. :)

tomshawk
07-25-2004, 11:40 PM
That worked perfectly, That you.

One other question, for when you get a chance.

If I want to create multiple blocks like this.

1 for QOTW, 1 for Articles, 1 for Reviews and so forth.

How would I change this line?

I assume it is just multiple if conditions, I've just never done it before

Thank you again for the help and excellent product. ;)

Brian
07-26-2004, 01:08 PM
If you have more than two, multipe <if> conditions may be the best... Or you could just put a variable there and then assign the title to that variable in the php scripts. ;)

tomshawk
07-26-2004, 08:26 PM
WOW :o

Umm, I'll come back and ask how when the time comes, as what you just said went so far over my head. :p

I'm not a coder, so, well, I haven't got a clue how to do either :D :p

Thank you

TCB
09-27-2004, 07:17 AM
I don't understand...

I copied the latesttopics.php file and renamed it to latestartwork.php, changed it according to the above rules. Then I copied and renamed the templates adv_portal_latesttopics and adv_portal_latesttopicsbits to adv_portal_latestartwork and adv_portal_latestartworkbits.

I added a new module that uses latestartwork.php and the new templates. In the adv_portal_latestartwork template I changed the title to <strong>$vba_options[portal_blockbullet] Latest Artwork topics</strong>.

Now I have a new module with the latest topics pulled from the selected forum. But the title still is 'Latest Forum Topics'. How is that possible? Since I hardcoded the title, it shouldn't be able to use any other title than the one I've given it?

I prefer to use a different template for this module, and don't use the portal_latesttopics template, because I'd like to edit it later on.

TCB
09-27-2004, 07:32 AM
O well.... I figured it out: the new latestartwork.php file fetches the results to the adv_portal_latesttopics template. Once I've changed that to adv_portal_latestartwork it showed the right title.

Fantastic :D

ttnb
09-27-2004, 10:16 AM
To change the title of that module, first edit your Reviews module and change the "Identifier" option to "reviews" (or whatever you'd like). Then edit your "adv_portal_latesttopics" template and look for:

$vbphrase[latest_forum_topics]

Replace that with:

<if condition="$mod['identifier'] == 'reviews'">Reviews<else />$vbphrase[latest_forum_topics]</if>


As for the threads being displayed twice, try opening your forum/modules/latesttopics.php file & the new file you created and look for:

unset($thread, $foruminfo['allowratings']);

Replace that with:

unset($thread, $threadbits, $foruminfo['allowratings']);

And it should fix the problem.

I do not find "unset($thread, $foruminfo['allowratings']);" in the lattesttopic.php . I just find "unset($thread, $threadbits, $foruminfo, $query, $inforums);" Is it ok for me to replace "unset($thread, $threadbits, $foruminfo, $query, $inforums);" with the line you said above ?

Onother problem, Some of my forum thread still display twice. And i realize that the thread of the forum which i have put the id in the news modules will display twice. (Beside the "latest topic" modules, I made a module called " latest new" which display the threads in forums i am using for news )I am newbie and can not fix this problem . Can you tell me how to fix it ?

ttnb
09-29-2004, 12:59 AM
humn ! it seems that no one anwswere me free!

04screamer
12-02-2004, 11:15 PM
Anybody have a problem with this working in other browsers than IE?