View Full Version : How to add button next to post new thread button
Kevlar
03-26-2013, 04:50 PM
How do I add a button next to the "post new thread" button on the forumdisplay template? Also, how do I add a conditional to only show it on certain forums?
--------------- Added 1364339041 at 1364339041 ---------------
For whoever wants to know... on template forumdisplay, add this
<a href="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newurl.php?{vb:raw session.sessionurl}do=newthread&f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newselllink_top" style="margin-left:160px"><span>+</span> New Button</a>
after this
<a href="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newthread.php?{vb:raw session.sessionurl}do=newthread&f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newthreadlink_top"><span>+</span> {vb:rawphrase post_new_thread}</a>
You may have to change margin-left:160px based on your setup, but that's the general idea.
msmayz
06-16-2014, 05:35 AM
I'd like to bump this. I have a similar question, but I don't understand the solution posted above.
What I'd like to do is this: We have a marketplace with forum IDs 50-54. We want the buttons at the top of these forums to say this:
+ Post New 'For Sale' / + Post New 'For Trade' / + Post New 'Want to Buy'
We want each of these buttons to link to custom forms we've created (through Easy Forms (https://vborg.vbsupport.ru/showthread.php?t=234385), of course).
Also, we don't need the existing "+ Post New Thread" button to display in the marketplace because we're replacing it with these three new buttons. So, we need to make the existing Post New Thread button disappear, but only in forums 50-54.
To create the three new buttons, I've followed the directions in this mod (https://vborg.vbsupport.ru/showthread.php?t=284005) and added the code below to my additional.css template:
.custom_button_fs {
background: {vb:stylevar control_content_background};
_background-image: none;
-moz-border-radius: {vb:stylevar control_content_radius};
-webkit-border-radius: {vb:stylevar control_content_radius};
-moz-box-shadow: 0 3px 8px {vb:stylevar control_content_shadow_color};
-webkit-box-shadow: 0 3px 8px {vb:stylevar control_content_shadow_color};
font: {vb:stylevar control_content_font};
color: {vb:stylevar control_content_color};
padding: {vb:stylevar control_content_padding};
border: {vb:stylevar control_content_border};
display:inline-block;
}
.custom_button_ft {
background: {vb:stylevar control_content_background};
_background-image: none;
-moz-border-radius: {vb:stylevar control_content_radius};
-webkit-border-radius: {vb:stylevar control_content_radius};
-moz-box-shadow: 0 3px 8px {vb:stylevar control_content_shadow_color};
-webkit-box-shadow: 0 3px 8px {vb:stylevar control_content_shadow_color};
font: {vb:stylevar control_content_font};
color: {vb:stylevar control_content_color};
padding: {vb:stylevar control_content_padding};
border: {vb:stylevar control_content_border};
display:inline-block;
}
.custom_button_wtb {
background: {vb:stylevar control_content_background};
_background-image: none;
-moz-border-radius: {vb:stylevar control_content_radius};
-webkit-border-radius: {vb:stylevar control_content_radius};
-moz-box-shadow: 0 3px 8px {vb:stylevar control_content_shadow_color};
-webkit-box-shadow: 0 3px 8px {vb:stylevar control_content_shadow_color};
font: {vb:stylevar control_content_font};
color: {vb:stylevar control_content_color};
padding: {vb:stylevar control_content_padding};
border: {vb:stylevar control_content_border};
display:inline-block;
}
To get these buttons to display and link correctly, here is the code I am planning on using:
<a href="http://mysite.com/forms.php?do=form&fid=2" rel="nofollow" class="newcontent_textcontrol" id="custom_button_fs"><span>+</span> Post New 'For Sale'</a>
<a href="http://mysite.com/forms.php?do=form&fid=4" rel="nofollow" class="newcontent_textcontrol" id="custom_button_ft" style="margin-left:175px"><span>+</span> Post New 'For Trade'</a>
<a href="http://mysite.com/forms.php?do=form&fid=3" rel="nofollow" class="newcontent_textcontrol" id="custom_button_wtb" style="margin-left:360px"><span>+</span> Post New 'Want to Buy'</a>
...except I don't know which template to put it in.
So, my question has two parts:
How do I get these three buttons to appear where the existing "+ Post New Thread" button is located, but only in forums 50-54?
How do I make the existing Post New Thread button disappear in forums 50-54?
Thank you for your help! :)
The template should be FORUMDISPLAY.
I believe the id of the new thread button is called newthreadlink_top and newthreadlink_bottom. Search for that in the FORUMDISPLAY template to locate the new thread button.
You can use an if-else statement as follows:
<vb:if condition="in_array($foruminfo['forumid'], array(50,51,52,53,54))">
show special buttons
<vb:else />
show normal button
</vb:if>
tpearl5
06-16-2014, 01:22 PM
Yep, what Dave said is correct.
msmayz
06-16-2014, 11:01 PM
Thanks, guys. Where in the FORUMDISPLAY template should I enter the if-else statement?
msmayz
06-18-2014, 07:01 AM
Bump for additional assistance! I can't seem to get this to work, and I'm fairly certain it's because I'm doing something wrong with the if-else statement.
What do I need to do with the text in red to make it so that my custom buttons only show up in subforums 50-54? (Sorry; I don't know a lot about PHP!)
<vb:if condition="in_array($foruminfo['forumid'], array(50,51,52,53,54))">
show special buttons
<vb:else />
show normal button
</vb:if>
msmayz
06-20-2014, 04:43 AM
So, knowing 0.1% about PHP, I just played around until I got the result I wanted. In the event that this ever helps anyone else, here's the code I used to get three custom buttons (all linking to customized forms I created in Easy Forms) to show in certain subforums and to get the "Post New Thread" button to disappear in those subforums.
Note that I used a vb:if command (as Dave suggested a few posts up) and incorporated vb:elseif for another set of subforums where we wanted the same three buttons to appear but link to different forms.
In template FORUMDISPLAY, at line 45, immediately below <vb:if condition="$show['newthreadlink']">, I found this code:
<a href="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newthread.php?{vb:raw session.sessionurl}do=newthread&f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newthreadlink_top"><span>+</span> {vb:rawphrase post_new_thread}</a></vb:if>
... and replaced it with the following to control how the top buttons are displayed:
<vb:if condition="in_array($foruminfo['forumid'], array(50,51,52,53,54))">
<a href="http://mysite.com/forms.php?do=form&fid=2" rel="nofollow" class="newcontent_textcontrol" id="custom_button_fs"><span>+</span> Post New 'For Sale'</a>
<a href="http://mysite.com/forms.php?do=form&fid=4" rel="nofollow" class="newcontent_textcontrol" id="custom_button_ft" style="margin-left:10px"><span>+</span> Post New 'For Trade'</a>
<a href="http://mysite.com/forms.php?do=form&fid=3" rel="nofollow" class="newcontent_textcontrol" id="custom_button_wtb" style="margin-left:10px"><span>+</span> Post New 'Want to Buy'</a>
<vb:elseif condition="in_array($foruminfo['forumid'], array(56,57,58,59,60,61))" />
<a href="http://mysite.com/forms.php?do=form&fid=5" rel="nofollow" class="newcontent_textcontrol" id="custom_button_fs"><span>+</span> Post New 'For Sale'</a>
<a href="http://mysite.com/forms.php?do=form&fid=4" rel="nofollow" class="newcontent_textcontrol" id="custom_button_ft" style="margin-left:10px"><span>+</span> Post New 'For Trade'</a>
<a href="http://mysite.com/forms.php?do=form&fid=3" rel="nofollow" class="newcontent_textcontrol" id="custom_button_wtb" style="margin-left:10px"><span>+</span> Post New 'Want to Buy'</a>
<vb:else />
<a href="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newthread.php?{vb:raw session.sessionurl}do=newthread&f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newthreadlink_top"><span>+</span> {vb:rawphrase post_new_thread}</a>
</vb:if>
And around line 271, immediately below <vb:if condition="$show['newthreadlink']">, I found this code:
<a href="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newthread.php?{vb:raw session.sessionurl}do=newthread&f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newthreadlink_bottom"><span>+</span> {vb:rawphrase post_new_thread}</a>
... and replaced it with the following to control how the bottom buttons are displayed:
<vb:if condition="in_array($foruminfo['forumid'], array(50,51,52,53,54))">
<a href="http://mysite.com/forms.php?do=form&fid=2" rel="nofollow" class="newcontent_textcontrol" id="custom_button_fs"><span>+</span> Post New 'For Sale'</a>
<a href="http://mysite.com/forms.php?do=form&fid=4" rel="nofollow" class="newcontent_textcontrol" id="custom_button_ft" style="margin-left:175px"><span>+</span> Post New 'For Trade'</a>
<a href="http://mysite.com/forms.php?do=form&fid=3" rel="nofollow" class="newcontent_textcontrol" id="custom_button_wtb" style="margin-left:358px"><span>+</span> Post New 'Want to Buy'</a>
<vb:elseif condition="in_array($foruminfo['forumid'], array(56,57,58,59,60,61))" />
<a href="http://mysite.com/forms.php?do=form&fid=5" rel="nofollow" class="newcontent_textcontrol" id="custom_button_fs"><span>+</span> Post New 'For Sale'</a>
<a href="http://mysite.com/forms.php?do=form&fid=4" rel="nofollow" class="newcontent_textcontrol" id="custom_button_ft" style="margin-left:175px"><span>+</span> Post New 'For Trade'</a>
<a href="http://mysite.com/forms.php?do=form&fid=3" rel="nofollow" class="newcontent_textcontrol" id="custom_button_wtb" style="margin-left:358px"><span>+</span> Post New 'Want to Buy'</a>
<vb:else />
<a href="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newthread.php?{vb:raw session.sessionurl}do=newthread&f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newthreadlink_bottom"><span>+</span> {vb:rawphrase post_new_thread}</a>
</vb:if>
One oddity is that I had to use different pixel widths for spacing the bottom buttons than I did for spacing the top buttons.
Anyway, I hope that helps someone!
tbworld
06-20-2014, 04:59 AM
So, knowing 0.1% about PHP
I am glad you have it working the way you want, and thanks for sharing. Good job. :)
msmayz
06-20-2014, 05:29 AM
Ha! Thanks. I just hope it will help someone else down the line. ;)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.