vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Creating Addons (https://vborg.vbsupport.ru/showthread.php?t=314198)

ozzy47 09-12-2014 11:52 AM

If you want, pm me a admin account and I can see if I can figure it out when I get home today.

Black Snow 09-17-2014 03:01 PM

Quote:

Originally Posted by ozzy47 (Post 2514507)
O create a new template, in each style, with the exact contents you want. Then create this plugin using the hook location, template_render_output

PHP Code:

    if ($this->template == 'OLD TEMPLATE NAME')
    {
        
$this->template 'NEW TEMPLATE NAME';
    } 


I eventually got this to work. Not sure why it won't work on my custom pages.

Anyway, is there any way to use the above code and have 10 different templates changed using an array or something like this?

PHP Code:

    if ($this->template == 'OLD TEMPLATE NAME 1')
    {
        
$this->template 'NEW TEMPLATE NAME 1';
    }
if (
$this->template == 'OLD TEMPLATE NAME 2')
    {
        
$this->template 'NEW TEMPLATE NAME 2';
    }
if (
$this->template == 'OLD TEMPLATE NAME 3')
    {
        
$this->template 'NEW TEMPLATE NAME 3';
    }
if (
$this->template == 'OLD TEMPLATE NAME 4')
    {
        
$this->template 'NEW TEMPLATE NAME 4';
    } 

So instead of a new plugin for each template I change something in, I can do it all in one plugin.

cellarius 09-17-2014 05:38 PM

Quote:

Originally Posted by Black Snow (Post 2515502)
I eventually got this to work. Not sure why it won't work on my custom pages.

Probably you did not cache your custom template. If it's not in the cache, there's nothing to replace. It will be queried directly from the database as is.

Quote:

Anyway, is there any way to use the above code and have 10 different templates changed using an array or something like this?

PHP Code:

    if ($this->template == 'OLD TEMPLATE NAME 1')
    {
        
$this->template 'NEW TEMPLATE NAME 1';
    }
if (
$this->template == 'OLD TEMPLATE NAME 2')
    {
        
$this->template 'NEW TEMPLATE NAME 2';
    }
if (
$this->template == 'OLD TEMPLATE NAME 3')
    {
        
$this->template 'NEW TEMPLATE NAME 3';
    }
if (
$this->template == 'OLD TEMPLATE NAME 4')
    {
        
$this->template 'NEW TEMPLATE NAME 4';
    } 

So instead of a new plugin for each template I change something in, I can do it all in one plugin.
You don't need more than one plugin. You can put that code as is into one plugin. Of course you could also do something like
PHP Code:

$replace = array(
        
'old1' => 'new1'
        
'old2' => 'new2',
        
'old3' => 'new3'
    
);

foreach (
$replace as $key => $value)
{
    if (
$this->template == $key)
    {
        
$this->template $value;
    }



Black Snow 09-17-2014 05:43 PM

Thanks for that. I will test it out.

Black Snow 09-18-2014 06:17 PM

I want to add something under the navbar. How do I add something to the end of the navbar temaplate OR include a template after the navbar? I'm not quite sure on using the pre-defined hooks or add new hooks into templates.

cellarius 09-18-2014 08:13 PM

See https://vborg.vbsupport.ru/showthread.php?t=228078

Black Snow 09-19-2014 07:27 AM

Quote:

Originally Posted by cellarius (Post 2515642)

I havd a look and not sure what I am doing wrong. This is my plugin:

Code:

$templater = vB_Template::create('custom_template');
    $templater->register('custom_template', $custom_template);
    $template_hook['postbit_userinfo_right_after_posts'] .= $templater->render();

It doesn't show the contents of custom_template after user posts using hook location postbit_display_complete.

--------------- Added [DATE]1411115460[/DATE] at [TIME]1411115460[/TIME] ---------------

Sorry, I never added the cache and it now shows. Does the code I used above look OK?

I have now added a new plugin for the forumhome using forumhome_complete hook location. I want it to show at the end of the navbar template. How do I insert my OWN custom template hook into the navbar template without having to manually edit the navbar template?

Black Snow 09-28-2014 02:32 PM

How do I add my own CSS to the additional.css template using a plugin?

ozzy47 09-28-2014 02:34 PM

You can't, you need to include your own css template, and call it in the script.

Black Snow 09-29-2014 12:26 PM

This is more for ozzy47 lol as I have used your mod [OzzModz] Change Forumrow Color On Mouseover as an example to make my own mod. I am making this plugin to change the background of moderated posts, does this look OK?

Code:

global $vbulletin;

if (THIS_SCRIPT == 'showthread') {
if ($vbulletin->options['mod_post_background_enable'])
{
    if ($vbulletin->options['storecssasfile'])
    {
        $template_hook['custom_css_links'] .= '<link type="text/css" rel="stylesheet" href="' . vB_Template::fetch_css_path() . 'mod_post_background_color.css' . '?d=' . $style['dateline'] . '" />';
    } else {
        $template_hook['custom_css_list'] .= 'mod_post_background_color.css';
    }

$find = '<div class=\"postbody\">';
$replace =  '<div class=\"postbody <vb:if condition="$show['moderated']">moderated</vb:if>\">';
$vbulletin->templatecache['postbit_legacy'] = str_replace($find, $replace, $vbulletin->templatecache['postbit_legacy']);
}
}

I am unsure if I escaped the quotes properly or if it is working. What's the quickest way to making a moderated post also?


All times are GMT. The time now is 05:56 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01196 seconds
  • Memory Usage 1,763KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete