Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 03-26-2013, 04:50 PM
Kevlar's Avatar
Kevlar Kevlar is offline
 
Join Date: Nov 2001
Location: Ft. Lauderdale, FL.
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to add button next to post new thread button

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 [DATE]1364339041[/DATE] at [TIME]1364339041[/TIME] ---------------

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&amp;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&amp;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.
Reply With Quote
  #2  
Old 06-16-2014, 05:35 AM
msmayz msmayz is offline
 
Join Date: May 2014
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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, 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 and added the code below to my additional.css template:

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

Code:
<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!
Reply With Quote
  #3  
Old 06-16-2014, 10:09 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
HTML Code:
<vb:if condition="in_array($foruminfo['forumid'], array(50,51,52,53,54))">
 show special buttons
<vb:else />
  show normal button
</vb:if>
Reply With Quote
  #4  
Old 06-16-2014, 01:22 PM
tpearl5's Avatar
tpearl5 tpearl5 is offline
 
Join Date: Nov 2001
Location: PA
Posts: 1,014
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep, what Dave said is correct.
Reply With Quote
  #5  
Old 06-16-2014, 11:01 PM
msmayz msmayz is offline
 
Join Date: May 2014
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, guys. Where in the FORUMDISPLAY template should I enter the if-else statement?
Reply With Quote
  #6  
Old 06-18-2014, 07:01 AM
msmayz msmayz is offline
 
Join Date: May 2014
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!)

Code:
<vb:if condition="in_array($foruminfo['forumid'], array(50,51,52,53,54))">
 show special buttons
<vb:else />
 show normal button
</vb:if>
Reply With Quote
  #7  
Old 06-20-2014, 04:43 AM
msmayz msmayz is offline
 
Join Date: May 2014
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

Code:
	<a href="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newthread.php?{vb:raw session.sessionurl}do=newthread&amp;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:

Code:
<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&amp;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:

Code:
	<a href="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newthread.php?{vb:raw session.sessionurl}do=newthread&amp;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:

Code:
<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&amp;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!
Reply With Quote
  #8  
Old 06-20-2014, 04:59 AM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by msmayz View Post
So, knowing 0.1% about PHP
I am glad you have it working the way you want, and thanks for sharing. Good job.
Reply With Quote
  #9  
Old 06-20-2014, 05:29 AM
msmayz msmayz is offline
 
Join Date: May 2014
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ha! Thanks. I just hope it will help someone else down the line.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:18 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.04120 seconds
  • Memory Usage 2,254KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete