PDA

View Full Version : Code to change button link in one forum


HM666
02-12-2016, 07:28 AM
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):

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
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:


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
With an array. Like this I believe:


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

Should it be?

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
if (in_array($foruminfo['forumid'], array(xx,xxx,xx,xxx)))

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


And this is opposite
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
Should it be?

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:

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:

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
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 (http://php.net/manual/en/control-structures.switch.php)

HM666
02-14-2016, 06:56 PM
I am confused. Sorry for not understanding easily.

That's take the first code in post #11
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....

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.
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:

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.