View Full Version : How to write plugins replace temp
Easy5s.net
02-18-2015, 08:31 AM
How to create a new template instead of VBB templates are used.
For example, I've created a custom template to replace the template forumhome_forumbit_level2_post, and I need a plugins to do this automatically. Thank :)
I don't know if you'd want a product to replace that template, because some people might have custom styles (and there's also the issue of multiple styles and mobile styles). I'm not sure of the right way to handle that. But one thing you could do is name your new template something else, then arrange for your template to be used. The code that uses that template is in functions_forumlist and looks like this:
// build the template for the current forum
($hook = vBulletinHook::fetch_hook('forumbit_display')) ? eval($hook) : false;
$templater = vB_Template::create("forumhome_forumbit_level$depth$tempext");
$templater->register('childforumbits', $childforumbits);
$templater->register('collapseimg_forumid', $collapseimg_forumid);
so you could have a plugin using hook forumbit_display that changed $depth or $tempext so that it was using your new name.
I guess this still causes issues if someone has a custom style, so I'm not sure if this is really any better.
Easy5s.net
02-18-2015, 09:50 AM
i have add plugin
$templater = vB_Template::create("custom_forumhome_forumbit");
$templater->register('childforumbits', $childforumbits);
$templater->register('collapseimg_forumid', $collapseimg_forumid);
$templater->register('collapseobj_forumid', $collapseobj_forumid);
$templater->register('forum', $forum);
$templater->register('forumid', $forumid);
$templater->register('parent_is_category', $parent_is_category);
$forumbits .= $templater->render();
hook work good but show dup temp
Well, what I was thinking was that your plugin would not render a template but would change $tempext so that the template name was changed. Like maybe:
if ($depth == 2 && $tempext == '_post')
{
$tempext = '_post_custom';
}
Then your new template would be named forumhome_forumbit_level2_post_custom.
Zachery
02-18-2015, 10:25 AM
Why wouldn't you just update the contents of that template with your own template code..
Easy5s.net
02-18-2015, 10:44 AM
Dup temp ?
https://vborg.vbsupport.ru/external/2015/02/13.png
I want
if (in_array ($ forum ['forumid'], '5,6,7,8'))
forumids 5,6,7,8 then show it to the temp custom, while others still show forumid default temp vbb
What plugin code are you using now?
Easy5s.net
02-18-2015, 10:49 AM
What plugin code are you using now?
$forumids = explode(',', '5,6,7,8');// add vboption after
if (in_array($forum['forumid'], $forumids))
{
$templater = vB_Template::create("forumhome_forumbit_level2_custom");
$templater->register('childforumbits', $childforumbits);
$templater->register('collapseimg_forumid', $collapseimg_forumid);
$templater->register('collapseobj_forumid', $collapseobj_forumid);
$templater->register('forum', $forum);
$templater->register('forumid', $forumid);
$templater->register('parent_is_category', $parent_is_category);
$forumbits .= $templater->render();
}
Try using only this code:
$forumids = explode(',', '5,6,7,8');// add vboption after
if (in_array($forum['forumid'], $forumids))
{
if ($depth == 2 && $tempext == '_post')
{
$tempext = '_post_custom';
}
}
Easy5s.net
02-18-2015, 12:53 PM
And this plugin, i add
$vbphrase['last_post'] = '';
$vbphrase['threads_posts'] = '';
To remove Threads / Posts Last Post
but it remove all
https://vborg.vbsupport.ru/external/2015/02/12.png
Try adding:
global $vbphrase;
Easy5s.net
02-18-2015, 01:45 PM
Try adding:
global $vbphrase;
No, when i add
$vbphrase['last_post'] = '';
$vbphrase['threads_posts'] = '';
code it working, but I want it to just remove it from my forumids specified.
OK, maybe this:
if (!isset($vbphrase['save_last_post']))
{
$vbphrase['save_last_post'] = $vbphrase['last_post'];
$vbphrase['save_threads_posts'] = $vbphrase['threads_posts'];
}
$forumids = explode(',', '5,6,7,8');// add vboption after
if (in_array($forum['forumid'], $forumids))
{
$vbphrase['save_last_post'] = '';
$vbphrase['save_threads_posts'] = '';
$templater = vB_Template::create("forumhome_forumbit_level2_custom");
$templater->register('childforumbits', $childforumbits);
$templater->register('collapseimg_forumid', $collapseimg_forumid);
$templater->register('collapseobj_forumid', $collapseobj_forumid);
$templater->register('forum', $forum);
$templater->register('forumid', $forumid);
$templater->register('parent_is_category', $parent_is_category);
$forumbits .= $templater->render();
}
else
{
$vbphrase['last_post'] = $vbphrase['save_last_post'];
$vbphrase['threads_posts'] = $vbphrase['save_threads_posts'];
}
Easy5s.net
02-18-2015, 03:09 PM
Try using only this code:
$forumids = explode(',', '5,6,7,8');// add vboption after
if (in_array($forum['forumid'], $forumids))
{
if ($depth == 2 && $tempext == '_post')
{
$tempext = '_post_custom';
}
}
I am using this code and it works, creates custom temp as I want. But in this custom temp, I want to remove part Category vbphrase Threads / Posts Last Post and
two vbphrase located in forumhome_forumbit_level1_nopost.
How to remove.
Sorry, I used the wrong code in my previous post. Maybe this:
if (!isset($vbphrase['save_last_post']))
{
$vbphrase['save_last_post'] = $vbphrase['last_post'];
$vbphrase['save_threads_posts'] = $vbphrase['threads_posts'];
}
$forumids = explode(',', '5,6,7,8');// add vboption after
if (in_array($forum['forumid'], $forumids))
{
if ($depth == 2 && $tempext == '_post')
{
$tempext = '_post_custom';
}
else if ($depth == 1 && $tempext == '_nopost')
{
$vbphrase['last_post'] = '';
$vbphrase['threads_posts'] = '';
}
else
{
$vbphrase['last_post'] = $vbphrase['save_last_post'];
$vbphrase['threads_posts'] = $vbphrase['save_threads_posts'];
}
}
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.