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)

Black Snow 09-09-2014 07:15 AM

Creating Addons
 
Hi,

I have a few different themes on my board and when ever I install a new theme, I have to make manual edits to make everything fit the way I want it to.

For example: I have the post thanks mod installed and I have changed the look of the "thanks box". So I uploaded a new theme, and I have to go into it and edit the thanks box to look the same as the other themes.

I'm looking for someone who can help me create (more to the point, learn) an addon so I can make my own in the future for this kind of situation.

Thanks

cellarius 09-09-2014 07:39 AM

You want to recreate an existing addon from scratch just because you have to make some style edits? How often do you install new styles :eek:

ozzy47 09-09-2014 08:58 AM

Some mods are going to be that way, if they use their own classes, vs using built in classes.

Even if you were to us built in classes, it would be using a stylevar, which you would have to change to suit your needs. Or create your own class, assign it a stylevar, and change it for each style.

For most mods, it is much easier just to edit the template, or the CSS for the mod in that style.

Black Snow 09-09-2014 09:35 AM

Quote:

Originally Posted by cellarius (Post 2514327)
You want to recreate an existing addon from scratch just because you have to make some style edits? How often do you install new styles :eek:

I am always changing the layout of the forum, adding new things, removing other things. When I do it to one style, I need to do it to the other styles. I want to make an addon so I can make the edit once, and install it so I don't need to manually edit each style. It will use stylevars eventually to fit with each style but for now I want to make a basic addon to do what I'm asking.

ozzy47 09-09-2014 09:38 AM

There is no tutorial, basically you have to know, php, html, css, and have a understanding of how vBulletin works. Then take it and put it all together.

PHP, basic guide: PHP 5 Tutorial

HTML basic guide: HTML Tutorial - (HTML5 Compliant)

CSS basic guide: CSS Tutorial

vBulletin basic mod guide: Creating a Product

Black Snow 09-09-2014 09:48 AM

Quote:

Originally Posted by ozzy47 (Post 2514349)
There is no tutorial, basically you have to know, php, html, css, and have a understanding of how vBulletin works. Then take it and put it all together.

PHP, basic guide: PHP 5 Tutorial

HTML basic guide: HTML Tutorial - (HTML5 Compliant)

CSS basic guide: CSS Tutorial

vBulletin basic mod guide: Creating a Product

Hi ozzy47,

I understand PHP, HTML & CSS to a degree. I was looking at your recent mod: https://vborg.vbsupport.ru/showthread.php?t=314177

What I don't understand yet is, if I create an addon (say to replace the post thanks box look) and include my code, will it automatically overwrite the default thanks box code from the post thanks mod? Or do I need to do something to overwrite the default code?/

Scanu 09-09-2014 10:24 AM

Well actually if you only need to keep changes in templates of a mod, you need to turn on debug mode and edit the template on the master style. This way when you add a new style you won't need to change templates again. However if you still want to know how to make an addon and you already have php and html knowledge you can look for a tutorial ppsted on vb.com on how to make a vb5 extension, it's almost the same

Black Snow 09-09-2014 10:30 AM

Quote:

Originally Posted by Scanu (Post 2514365)
Well actually if you only need to keep changes in templates of a mod, you need to turn on debug mode and edit the template on the master style. This way when you add a new style you won't need to change templates again. However if you still want to know how to make an addon and you already have php and html knowledge you can look for a tutorial ppsted on vb.com on how to make a vb5 extension, it's almost the same

I thought that you could only edit the master theme with child themes if they were the same theme? I have 6 completely different themes. I will have a look for the article you mentioned.

TheLastSuperman 09-09-2014 08:49 PM

Quote:

Originally Posted by Black Snow (Post 2514346)
I am always changing the layout of the forum, adding new things, removing other things. When I do it to one style, I need to do it to the other styles. I want to make an addon so I can make the edit once, and install it so I don't need to manually edit each style. It will use stylevars eventually to fit with each style but for now I want to make a basic addon to do what I'm asking.

Try doing it this way then:
https://vborg.vbsupport.ru/showthread.php?t=307739

One plugin could seemingly manipulate all styles to suit, you can define differences there as well.

Edit: Do not turn on debug mode and edit your master style, no!

TheLastSuperman 09-09-2014 08:50 PM

Quote:

Originally Posted by Scanu (Post 2514365)
Well actually if you only need to keep changes in templates of a mod, you need to turn on debug mode and edit the template on the master style.

That is not advised.

Scanu 09-10-2014 04:32 AM

Quote:

Originally Posted by TheLastSuperman (Post 2514452)
That is not advised.

Why? If that is a public board you mean?

cellarius 09-10-2014 05:32 AM

Because the master style will be overwritten when he next upgrades. And I don't imagine he fancies redoing all his styling after every upgrade :)

Black Snow 09-10-2014 08:52 AM

Quote:

Originally Posted by TheLastSuperman (Post 2514451)
Try doing it this way then:
https://vborg.vbsupport.ru/showthread.php?t=307739

One plugin could seemingly manipulate all styles to suit, you can define differences there as well.

Edit: Do not turn on debug mode and edit your master style, no!

Thanks for the link and info. It's not simply just the CSS I want to change, it's the template I want to change too. I have edited the Post Thanks box template and renamed certain <DIV> classes and added new div's also. So I want to make a plugin OR addon which will overwrite the default code/template.

ozzy47 09-10-2014 09:02 AM

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';
    } 


ozzy47 09-10-2014 09:23 PM

Ohhh, I should also add you will need to cache that new template, using the hook location, cache_templates like so.

PHP Code:

$cache array_merge($cache, array
        (
            
'NEW TEMPLATE NAME',
        )
    ); 


tbworld 09-11-2014 12:20 AM

For a single template, just append to the end of the existing array. Use:

Code:

  cache[] = 'NEW_TEMPLATE_NAME';

ozzy47 09-11-2014 12:26 AM

Yeah that's true. :)

Black Snow 09-12-2014 08:49 AM

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';
    } 


It didn't work. It doesnt do anything.

ozzy47 09-12-2014 09:11 AM

Sure it does, I have used this for a couple of years now. Did you make sure to add the correct template names?

Black Snow 09-12-2014 11:11 AM

Quote:

Originally Posted by ozzy47 (Post 2514817)
Sure it does, I have used this for a couple of years now. Did you make sure to add the correct template names?

Yup. I made the plugin:
Code:

    if ($this->template == 'post_thanks_box')
    {
        $this->template = 'custom_post_thanks_box';
    }

Made a new template called "custom_post_thanks_box" and put my code in it.

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?

ozzy47 09-29-2014 12:54 PM

Looks ok, but I on my mobile, so hard to tell.

Just moderate the post with the moderation tools menu when viewing a post.

Black Snow 09-29-2014 01:04 PM

I have spent the last 2 hours trying to get it to work. Im not sure if I'm using the wrong hook location (it's parse_templates at the moment) or theres something else wrong.

ozzy47 09-29-2014 01:12 PM

I can check when I get off work. Where exactly is the color change supposed to show?

Black Snow 09-29-2014 01:13 PM

The background of the post should change. I'm trying to get this edit to be a mod.

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

ozzy47 09-29-2014 01:16 PM

All right, I'll look when I get home later today.

Black Snow 09-29-2014 01:21 PM

Quote:

Originally Posted by ozzy47 (Post 2516865)
All right, I'll look when I get home later today.

Thanks mate. Heres the addon im trying to make so you can test it.

ozzy47 09-29-2014 01:54 PM

There might be a easier way to do it, I'll look into it later.

Black Snow 09-29-2014 01:55 PM

OK cool. I want it to be an addon so I can add options to it later.

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

Spend another 3 hours researching the issue and can't find the problem

ozzy47 09-29-2014 08:39 PM

1 Attachment(s)
Ok here it is. I also added the missing settings for the mod, and set the product URL and the version check URL.

I would suggest creating a stylevar for the background color, instead of having it hardcoded or as a option in the settings. This way the end user can have different colors for different styles.

I would uninstall your version, then load this one up. :)

Black Snow 09-29-2014 08:44 PM

Thanks. Can you tell me what you added so I know for next time?


All times are GMT. The time now is 06:27 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.01514 seconds
  • Memory Usage 1,864KB
  • 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
  • (4)bbcode_code_printable
  • (7)bbcode_php_printable
  • (14)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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