vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Add And Use Custom Phrase Type. (https://vborg.vbsupport.ru/showthread.php?t=117132)

deathemperor 05-29-2006 10:00 PM

Add And Use Custom Phrase Type.
 
How to add

Simple, just use these 2 lines in your install code, it will add a new phrase type with phrasegroup_name = tm_phrase, phrasegroup_title = trademanager and productid as trademanager.

PHP Code:

    require_once(DIR '/includes/adminfunctions_language.php');
    
add_phrase_type('tm_phrase''Trade Manager''trademanager'); 

The function reads

PHP Code:

/**
* Allows plugins etc. to add a phrasetype easily
*
* @param    string    Phrasetype name
* @param    string    Phrasetype title
* @param    string    Product ID
*
* @return    mixed    If insert succeeds, returns inserted phrasetypeid
*/
function add_phrase_type($phrasegroup_name$phrasegroup_title$productid 'vbulletin'


How to use

In your script, after:

PHP Code:

// ################### PRE-CACHE TEMPLATES AND DATA ###################### 

include this this line
PHP Code:

// get special phrase groups
$phrasegroups = array('tm_phrase'); 

tm_phrase is the phrasegroup_name that you added as above.

Now you can use the phrases from "Trade Manager" phrase group to your script.

How this helps ?
I can think of these for now:
- Prevent spamming the global phrases, make it getting bigger and bigger.
- Easier to manage. Because it's your own custom phrases ;)
- Make your product more like a product :P.

Notice
- These phrases can only use to replace global phrase. Meaning, instead of create all of them and put to Global phrase, you put it in your own group. So if you want to use them for Permissions, Error Messages, etc. you simply can't.

Correct me if I missed something.

Have fun.

wiritten by deathemperor @ www.holvn.org

lightwave 07-20-2006 04:30 PM

really great modification. i used it myself.

FractalizeR 11-14-2006 10:21 AM

I have some questions:

1. How to completely delete all phrases of my plugin on uninstallation? Is this done automatically?
2.
Quote:

So if you want to use them for Permissions, Error Messages, etc. you simply can't.
Could you please explain, what this means? What do you mean under "Permissions, Error messages"?

BTW, isn't add_phrase_type deprecated yet? As I can see, for example psiStats addon for VB does not use this function, but still uses custom phrases

deathemperor 11-14-2006 06:19 PM

1. Yes when: for example when you add a phrase, you choose a product it belongs to then when the product uninstalled the phrases belong to that product will be removed too.

2. I haven't found a way to add custom phrases for Permission, Error Messages, etc (which are some phrase types). So currently it's only possible to add global phrases. The psiStats may use queries in its product installation files (xml for example). add_phrase_type just do the same, it also runs queries but it's written by vbulletin development staves so what would you choose ?

FractalizeR 11-19-2006 10:23 AM

Thanks :) Now I understand.

steadicamop 11-25-2006 11:51 PM

Quote:

Originally Posted by deathemperor (Post 992910)
include this this line
PHP Code:

// get special phrase groups
$phrasegroups = array('tm_phrase'); 


I'm not sure if I'm missing something really simple here - but this lot doesn't seem to work for me - where can you add the $phrasegroups to? I have tried the php file I have and inside the plugin - but just not working, none of my phrases show ... would love to be able to separate them out.

Thanks

Jason

deathemperor 11-26-2006 10:45 PM

actually I only tried it for new files. you can see it on vbulletin files, it's placed before everything (almost).

I think it will work on plugin if you use array_merge, I will try it myself.

testbot 10-24-2009 06:32 PM

is there away to add a translation? i want to append some txt to an existing phrase.


All times are GMT. The time now is 06:30 PM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01456 seconds
  • Memory Usage 1,734KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete