View Full Version : want to have duplicate forumhome page
fxdigi-cash
01-11-2015, 02:00 PM
Hi,
I know this may sound strange, but I was trying to make a duplicate of ForumHome page/template so that I can use Forumhome to show specific forums on forum.php and Forumhome2 (for exampe) to show specific forums on say my custom page forum22.php.
I tried to use Tab forums mod here :https://vborg.vbsupport.ru/showthread.php?t=233135, but found it is not good for SEO.
now I want to know if there a way to have forumhome on many pages, not like having the same forumhome under different forum.php... Meaning I want for example to show specific forums on forum.php and then have another page say forum22.php with different forums.
so the idea is similar to forum tabs as shown in the mod above, but without using mods!!
I'm wondering is that possible?? :confused:
any idea??
Thanks,
Well, I'm not sure if I completely understand. But I don't see why you couldn't copy forum.php to another name, then modify it do display only certain forums. It looks like it uses $vbulletin->forumcache, so maybe near the beginning you could delete the forums you don't want to display from $vbulletin->forumcache. You said you don't want to use mods, but it might be possible to do that in a plugin using hook forumhome_start. You could check for a parameter and adjust forumcache accordingly.
But I haven't actually tried this and sometimes you run in to things that don't work like you hoped, as I'm sure you know.
nerbert
01-11-2015, 02:49 PM
It happens I'm working on an update to a mod that ignores a list of forums. Here's a little code snippet for not listing selected forums:
$ignore_array = array(11,12,23,24); //example of forum id's you don't want to show
$cache = array();
foreach($vbulletin->forumcache AS $forumcache)
{
$i = $forumcache['forumid'];
if(!in_array($i, $ignore_array))
{
$cache[$i] = $forumcache;
}
}
$vbulletin->forumcache = $cache;
fxdigi-cash
01-12-2015, 12:01 AM
Thanks nerbert (https://vborg.vbsupport.ru/member.php?u=257096) for sharing the code.
I will give it a try and see if it works.
Cheers :)
P.s: where and how do I use this code?? as a plugin? if yes, then what hook should I use with??
It happens I'm working on an update to a mod that ignores a list of forums. Here's a little code snippet for not listing selected forums:
$ignore_array = array(11,12,23,24); //example of forum id's you don't want to show
$cache = array();
foreach($vbulletin->forumcache AS $forumcache)
{
$i = $forumcache['forumid'];
if(!in_array($i, $ignore_array))
{
$cache[$i] = $forumcache;
}
}
$vbulletin->forumcache = $cache;
--------------- Added 1421029071 at 1421029071 ---------------
Well, I'm not sure if I completely understand. But I don't see why you couldn't copy forum.php to another name, then modify it do display only certain forums. It looks like it uses $vbulletin->forumcache, so maybe near the beginning you could delete the forums you don't want to display from $vbulletin->forumcache. You said you don't want to use mods, but it might be possible to do that in a plugin using hook forumhome_start. You could check for a parameter and adjust forumcache accordingly.
But I haven't actually tried this and sometimes you run in to things that don't work like you hoped, as I'm sure you know.
Thanks man, kh99
I wanted to make each forum in an independent page because my forums are a lot and each has many sub-forums. so if I made each set of forums in one page, it will be easier for readers and visitors to understand what's going easily.
ok, if copying forum.php is a lot easier, then what code do I have to change in the new .php file... is it this code:
foreach ($parentlist AS $forumID)
{
$forumTitle =& $vbulletin->forumcache["$forumID"]['title'];
$navbits[fetch_seo_url('forum', array('forumid' => $forumID, 'title' => $forumTitle))] = $forumTitle;
}
HOW?? I have no clue how to start...!!
any idea??
nerbert
01-12-2015, 12:47 AM
Well, you could try this:
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$show_array = array(11,12,23,24); //example of forum id's you want to show
$cache = array();
foreach($vbulletin->forumcache AS $forumcache)
{
$i = $forumcache['forumid'];
if(in_array($i, $show_array))
{
$cache[$i] = $forumcache;
}
}
$vbulletin->forumcache = $cache;
Notice I changed the code so it shows the forums you want instead of ignoring forums. (no "!" in front of in_array)
I have no idea how this is going to work. You could be in for a big complicated job. For starters every link has a base path like "http://www.my_forum.com/forum", I don't know how to get the correct path for the threads or forums in the new file/page.
fxdigi-cash
01-12-2015, 01:00 AM
I tried that, but didn't work...
The previous code however worked as plugin using forumhome_start hook as suggested by kh99.
$ignore_array = array(11,12,23,24); //example of forum id's you don't want to show
$cache = array();
foreach($vbulletin->forumcache AS $forumcache)
{
$i = $forumcache['forumid'];
if(!in_array($i, $ignore_array))
{
$cache[$i] = $forumcache;
}
}
$vbulletin->forumcache = $cache;
This one hide the undesired forums, but that happens in all forum.php and its duplicates. I want to avoid the delete or hide in other pages...
is there a way how to do that??
nerbert
01-12-2015, 01:18 AM
Edit the THIS_SCRIPT value on the new page and enclose the code in
if(THIS_SCRIPT == 'index22')
{
}
or something like that
fxdigi-cash
01-12-2015, 01:55 AM
Thanks, mate
I tried all that, but nothing worked...!!
I'm pretty sure to some level that it should work, yet no idea how
nerbert
01-12-2015, 02:00 AM
Never mind the stuff above.
First divide your forums up into categories in the forum manager (you probably already have). Forget the forum home page and use copies of forumdisplay.php to display each category separately.
So make copies of forumdisplay.php with names like forum1.php, forum2.php or whatever.
In each one edit in $_REQUEST['forumid'] = 10; $_REQUEST['forumid'] = 20;, etc, whatever your category forumid's are, right under the big START MAIN SCRIPT comment block (EDITED: should be forumid's NOT threadid's)
Now go to them and see if it's all working as planned.
If all that works all you need to do is duplicate the other stuff on forum home into these new files. So copy the FORUMDISPLAY template and call it CATEGORY and at the bottom of each new file, line 1210 change
$templater = vB_Template::create('FORUMDISPLAY');
to
$templater = vB_Template::create('CATEGORY');
Next look at the What's Going On box on forum home and see what php code is needed to get that, copy it over from forum.php and copy the html from FORUMHOME into CATEGORY
fxdigi-cash
01-12-2015, 02:28 AM
ok, great start, but quick question where to find this line as it is not shown in forumdisplay.php
$_REQUEST['forumid']
I have only this code:
$_REQUEST['pagenumber']
are you talking about vb4 or vb3? because I'm using vb4.2.2
nerbert
01-12-2015, 02:39 AM
Just edit it into your copied file and set it equal to one of your category forumid's. The point is there's no "f=10" in your url so you have to supply it in the code.
I'm not sure this will work though. Try and see.
Actually, come to think of it maybe it should go at the very top right after <?php
Try this
<?php $_REQUEST['f'] = 10;
whatever one of your categories is
fxdigi-cash
01-12-2015, 03:02 AM
Thanks for the great effort, but it didn't work.
I'm just wondering if forumhome can be duplicated and then used under different name and then replacing forum.php with also different name can do anything... I tried that though, but nothing worked...
I thought it is a lot easier than that. is there a conditional statement to use per forum.php or it is only per template?? because I can see it working only on a template not .php pages....
nerbert
01-12-2015, 03:51 AM
Yeah, I had to try it out myself. The best I could do is edit in "$_GET['f'] = 1;" into the new file and it redirected me to the original forumdisplay.php. But you could make links to the URLs for your main categories and they would more or less do what you want. Maybe then you could make a plugin that evaluates all the data for What's Going On and make a separate template for that and put it in forumdisplay.php with a conditional that does it only for categories.
Maybe there's already a product for putting What's Going On in other pages
fxdigi-cash
01-12-2015, 06:28 AM
Big apology to you mate, nerbert (https://vborg.vbsupport.ru/member.php?u=257096).... I found out that I was mistaken.... I didn't clear up the browser :ocache... as I use Zend Opcache php cacher...
now this code works beautifully on the custom page derived from forum.php
$ignore_array = array(20,21,24); //example of forum id's you don't want to show
$cache = array();
foreach($vbulletin->forumcache AS $forumcache)
{
$i = $forumcache['forumid'];
if(!in_array($i, $ignore_array))
{
$cache[$i] = $forumcache;
}
}
$vbulletin->forumcache = $cache;
Big Thanks man and sorry again about the troubles. :up::)
nerbert
01-12-2015, 04:21 PM
But now your problem is figuring out navbits. If you view a thread or forum that shows on forum22 the first link in your navbits should take you to forum22 instead of forum.
bridge2heyday
01-13-2015, 05:08 AM
But now your problem is figuring out navbits. If you view a thread or forum that shows on forum22 the first link in your navbits should take you to forum22 instead of forum.
You will have to do some file edits because no hooks for that
in forumdisplay.php .. directly under
$navbits[''] = $foruminfo['title'];
put
$forum2list = array(1,2,3); //id's of forums of forum2.php
if (in_array($forumid, $forum2list)) {
foreach ($navbits as $key => $value) {
if ($key == 'forum.php') {
$nav['forum2.php'] = $value;
} else {
$nav[$key] = $value;
}
}
$navbits = $nav;
}
and put the same code in showthread.php directly under
$navbits[''] = $thread['prefix_rich'] . ' ' . $thread['title'];
--------------- Added 1421133482 at 1421133482 ---------------
If you don't want to edit files you can use the next hook location and redo all navbar work
for example
showthread_complete in showthread.php
$navbits = array();
$navbits[fetch_seo_url('forumhome', array())] = $vbphrase['forum'];
$parentlist = array_reverse(explode(',', substr($forum['parentlist'], 0, -3)));
foreach ($parentlist AS $forumID)
{
$forumTitle = $vbulletin->forumcache["$forumID"]['title'];
$navbits[fetch_seo_url('forum', array('forumid' => $forumID, 'title' => $forumTitle))] = $forumTitle;
}
$navbits[''] = $thread['prefix_rich'] . ' ' . $thread['title'];
$forum2list = array(1,2,3); //id's of forums of forum2.php
if (in_array($forumid, $forum2list)) {
foreach ($navbits as $key => $value) {
if ($key == 'forum.php') {
$nav['forum2.php'] = $value;
} else {
$nav[$key] = $value;
}
}
$navbits = $nav;
}
$navbits = construct_navbits($navbits);
$navbar = render_navbar_template($navbits);
fxdigi-cash
01-15-2015, 02:55 AM
Thanks @bridge2heyday (https://vborg.vbsupport.ru/member.php?u=529886) for the great solution ... :up: :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.