vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Code to change button link in one forum (https://vborg.vbsupport.ru/showthread.php?t=321789)

HM666 02-12-2016 07:28 AM

Code to change button link in one forum
 
I need to know what plugin code I would use to change the "+Post New Thread" button to say "+Submit Ticket" in just one forum only.

MarkFL 02-12-2016 08:27 AM

You could use the following PHP Plugin Code (Hook Location: forumdisplay_complete):

PHP Code:

if ($foruminfo['forumid'] == XX)
{
    
$vbphrase['post_new_thread'] = 'Submit Ticket';


where "XX" is the forumid of the forum in which you want to make the change. :)

HM666 02-12-2016 09:48 AM

Perfect! Worked great, thanks.

Stratis 02-14-2016 01:24 PM

Good idea Len, thanks Mark for this, I will use it some how.

Edit: How include more forum id?

RichieBoy67 02-14-2016 01:38 PM

Quote:

Originally Posted by Stratis (Post 2564857)
Good idea Len, thanks Mark for this, I will use it some how.

Edit: How include more forum id?

With an array. Like this I believe:

PHP Code:

if ($foruminfo['forumid'] = array(##,##,##))
{
    
$vbphrase['post_new_thread'] = 'Submit Ticket';



Stratis 02-14-2016 01:47 PM

Thanks Richie, I will try this.

mokujin 02-14-2016 02:00 PM

Quote:

Originally Posted by RichieBoy67 (Post 2564858)
With an array. Like this I believe:

PHP Code:

if ($foruminfo['forumid'] = array(##,##,##))
{
    
$vbphrase['post_new_thread'] = 'Submit Ticket';



Should it be?
PHP Code:

if (in_array($foruminfo['forumid'], array(##,##,##)))
{
    
$vbphrase['post_new_thread'] = 'Submit Ticket';



Stratis 02-14-2016 02:03 PM

Ok I found it how

This
PHP Code:

if (in_array($foruminfo['forumid'], array(xx,xxx,xx,xxx)))

{
    
$vbphrase['post_new_thread'] = 'Submit Ticket';



And this is opposite
PHP Code:

 if (!in_array($foruminfo['forumid'], array(xx,xxx,xx,xxx)))

{
    
$vbphrase['post_new_thread'] = 'Submit Ticket';


EDIT: Thanks Đạt, I did not make a refresh, and did not see your answer.

RichieBoy67 02-14-2016 02:14 PM

Quote:

Originally Posted by mokujin (Post 2564863)
Should it be?
PHP Code:

if (in_array($foruminfo['forumid'], array(##,##,##)))
{
    
$vbphrase['post_new_thread'] = 'Submit Ticket';




Thanks for the correction. I should not have missed that!:erm:

Stratis 02-14-2016 02:22 PM

Ok now, how make this more complicated :)

Make 2 or 3 buttons.

1st 'Submit Ticket' as it is.
2nd 'New Help Thread' or what else.

Do I have to make another plugin or I can include it in the first one
If so include, how?

Thanks...

MarkFL 02-14-2016 03:13 PM

You could use something like:

PHP Code:

switch ($foruminfo['forumid'])
{
    case 
XX:
        
$vbphrase['post_new_thread'] = 'text for forum XX';
        break;
    case 
YY:
        
$vbphrase['post_new_thread'] = 'text for forum YY';
        break;
    case 
ZZ:
        
$vbphrase['post_new_thread'] = 'text for forum ZZ';
        break;



Stratis 02-14-2016 03:37 PM

Yes Mark, this works as I asked.
But I cannot include more than one forum ID in each case.

Suppose this needs to have an array or how?

Thanks

MarkFL 02-14-2016 04:20 PM

Then you could use something like:

PHP Code:

switch ($foruminfo['forumid'])
{
    case 
XX:
        
$vbphrase['post_new_thread'] = 'text for forum XX';
        break;
    case 
YY1:
    case 
YY2:
        
$vbphrase['post_new_thread'] = 'text for forum YY1 and YY2';
        break;
    case 
ZZ1:
    case 
ZZ2:
    case 
ZZ3:
        
$vbphrase['post_new_thread'] = 'text for forum ZZ1 and ZZ2 and ZZ3';
        break;


:)

Stratis 02-14-2016 04:53 PM

I am confused. Sorry for not understanding easily.

That's take the first code in post #11
PHP Code:

switch ($foruminfo['forumid'])
{
    case 
XX:
        
$vbphrase['post_new_thread'] = 'Submit Ticket';
        break;
    case 
YY:
        
$vbphrase['post_new_thread'] = 'New Help Thread';
        break;
    case 
ZZ:
        
$vbphrase['post_new_thread'] = 'New Question Thread';
        break;


How I put more than 1 forum id? in
case XX:
case YY:
case ZZ:

Thanks

MarkFL 02-14-2016 05:24 PM

To better understand posts #11 and #13, I suggest reading:

PHP: switch - Manual

HM666 02-14-2016 06:56 PM

Quote:

Originally Posted by Stratis (Post 2564878)
I am confused. Sorry for not understanding easily.

That's take the first code in post #11
PHP Code:

switch ($foruminfo['forumid'])
{
    case 
XX:
        
$vbphrase['post_new_thread'] = 'Submit Ticket';
        break;
    case 
YY:
        
$vbphrase['post_new_thread'] = 'New Help Thread';
        break;
    case 
ZZ:
        
$vbphrase['post_new_thread'] = 'New Question Thread';
        break;


How I put more than 1 forum id? in
case XX:
case YY:
case ZZ:

Thanks

I think what you would need to dois replace the XX, YY, ZZ with the actual forum ids for those particular buttons. So you would put....

PHP Code:

switch ($foruminfo['forumid'])
{
    case 
1:
        
$vbphrase['post_new_thread'] = 'Submit Ticket';
        break;
    case 
2:
        
$vbphrase['post_new_thread'] = 'New Help Thread';
        break;
    case 
3:
        
$vbphrase['post_new_thread'] = 'New Question Thread';
        break;


where the numbers after the word case are the actual numbers of the forums corresponding to the buttons you want.

Stratis 02-14-2016 06:57 PM

Sorry Mark I could not understand at start, that I can put as many case χχχ: i want.
I have read PHP Manual, but unfortunately i don't understand. You see many things that are easy for some people are very difficult for others. I try very hard but how forward can some one can go.

Thanks for your help, and by making a lot of tests-combinations than I realized.
Yes now its easy when is there a way to understand.

For some dummies like me.
PHP Code:

switch ($foruminfo['forumid'])
{
    case 
xxx:
    case 
xxx:
    case 
xxx:
    case 
xxx:
    case 
xxx:
    case 
xxx:
        
$vbphrase['post_new_thread'] = 'Submit Ticket';
        break;
    case 
xxx:
    case 
xxx:
        
$vbphrase['post_new_thread'] = 'New Help Thread';
        break;
    case 
xxx:
        
$vbphrase['post_new_thread'] = 'What else name;
        break;


Where xxx is forum id

Hope if we put many forums id there is no problem to forum or else?

:)

EDIT: Len, we posted same time, did not see it first :)

HM666 02-14-2016 07:01 PM

LOL that is ok at least the info is there now for someone else if they get lost. :)

MarkFL 02-14-2016 07:04 PM

Suppose I have a forum with forumid 2 and I wish for the button to read "Submit Ticket", and I have 2 forums with forumids 3 and 4, and I wish for the button to read "Add to Tutorial" and I have 3 forums with forumids 5, 6 and 7 and I wish for the button to read "Ask the Expert."

Then my PHP Code should be:

PHP Code:

switch ($foruminfo['forumid'])
{
    case 
2:
        
$vbphrase['post_new_thread'] = 'Submit Ticket';
        break;
    case 
3:
    case 
4:
        
$vbphrase['post_new_thread'] = 'Add to Tutorial';
        break;
    case 
5:
    case 
6:
    case 
7:
        
$vbphrase['post_new_thread'] = 'Ask the Expert';
        break;


Does that make sense? :)

edit: If not, then I will be glad to whip up a simple mod that will let you define the text for the button based on forumid, and use phrasing so you can translate them.

Stratis 02-17-2016 07:17 AM

Its ok for me as it is, the only thing, if there is a problem when we put many forum ids.
As i see no problem with it to.
Thanks guys for help.


All times are GMT. The time now is 10:22 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.01268 seconds
  • Memory Usage 1,804KB
  • 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
  • (14)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (20)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