Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 07-19-2013, 06:22 AM
warlord0 warlord0 is offline
 
Join Date: Apr 2012
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom Fields in newthread

I've been banging my head on the table trying to get my head around plugins and templates.

So far I have an installable product with plugins that hook the newthread_start and I've added a variable into the newthread template to place the fields. But I'm not sure I'm doing things the right way.

Template variable added:
PHP Code:
{vb:raw addedfields
Plugin newthread_start:
PHP Code:
$flds'<fieldset><label>  Random checkbox <input type="checkbox" name="chkrandom" /></label></fieldset>';

vB_Template::preRegister('newthread', array('addedfields' => $flds)); 
Which works and I get my checkbox. The problem I have is if I try to make use of variables/phrases in the plugin variable.

eg.

PHP Code:
$flds'<fieldset><label>  {vb:raw title} <input type="checkbox" name="chkrandom" /></label></fieldset>'
This doesn't do any variable substitution and I end up with the {} variable as visible html.

I used this article as a reference (https://vborg.vbsupport.ru/showthread.php?t=237982) - and I am struggling to understand it to be fair, but I do get it sort of working.

Eventually I want to be able to store the custom field values in with the thread, but haven't found any guidance to point me to how to do that. Any one got any good guideas for doing this?

Many thanks.

--------------- Added [DATE]1374234105[/DATE] at [TIME]1374234105[/TIME] ---------------

Ok, I'm really struggling with this. I'm getting no where fast and the documentation is like trying to do a jigsaw in the dark with no picture to to do it with.

How do people get started with developing a product and plugins? All the articles seem to assume you know enough about vb development - which I plainly don't. I have a fair understanding of php, but don't have the knowledge of applying it to the way vb works.

I thought I'd got a simple plan for what I wanted to achieve. There is an existing plugin that does close to what I'm after I just wanted to go a little different.

Basically I'd like to use a "Sticky Post" so that it remains at the top of every page.

To do that I'd like the user or admin to choose if it is sticky or not. Simple checkbox added to newthread and value stored in the thread table as "stickyfirstpost"

Then as postbit is processed check is $thread['stickyfirstpost'] is true and GPC['pagenumber'] > 1 - if so repeat the $thread['firstpost']

I can figure the logic of the existing plugin and can make it check the $thread['stickyfirstpost'] value and it works. But what I can't do is modify the newthread template and have it save the data into the table. The field exists, but nothing gets written into it ever.

https://vborg.vbsupport.ru/showthread.php?t=239282

I guess I'm missing the understanding of handling the vbulletin objects. So where do I learn this?
Reply With Quote
  #2  
Old 07-21-2013, 12:57 PM
warlord0 warlord0 is offline
 
Join Date: Apr 2012
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Some one please put me out of my misery. I've been reading so much my head spins and I'm still not getting it.

I've taken out the template code and resorted to hard coding it into there for now - just to get things moving, if I can.

So please what am I missing?

newthread_post_start
PHP Code:
$vbulletin->input->clean_gpc('p','stickyfirstpost'TYPE_BOOL);

$newpost['stickyfirstpost'] =& $vbulletin->GPC['stickyfirstpost']; 
threaddata_start & threadfpdata_start
PHP Code:
$this->validfields['stickyfirstpost'] = array(TYPE_BOOLREQ_NO); 
threadmanage_update
PHP Code:
$vbulletin->input->clean('p''stickyfirstpost'TYPE_BOOL);
$threadman->setr('stickyfirstpost'$vbulletin->GPC['stickyfirstpost']); 
newthread template additions
PHP Code:
<!-- Sticky Posts -->
<
div style="padding:{vb:stylevar formspacer}px">
<
div class="blockrow">
<
label>{vb:rawphrase stickyfirstpost_options}:</label>
<
ul class="checkradio group rightcol">
  <
li>
    <
label for="stickyfirstpost"><input type="checkbox" class="bginput" name="stickyfirstpost" value="{vb:var threadinfo['stickyfirstpost']}" tabindex="1" /> {vb:phrase stickyfirstpost_name}</label>
    <
class="description">{vb:phrase stickyfirstpost_desc}</p>
  </
li>
</
ul>
</
div>
<!-- 
end Stick Posts --> 
--------------- Added [DATE]1374489104[/DATE] at [TIME]1374489104[/TIME] ---------------

Well as it was all quiet in here, no one replying I thought I'd fix the darned thing myself

Turns out it was so simple and relates to the template additions. I'm using a check box, but in order for it to work it must have a value of "1".

I found this by using the HttpFox plugin and watching the post variables. It was sending 'stickyfirstpost' but it was always empty. So setting the value to "1" meant once it was ticked the value passed was then "1". I imagine I should really be checking to see if 'stickyfirstpost' is checked - not the value, as the value is meaningless.

but here it is fixed.
PHP Code:
<!-- Sticky Posts -->
<
div style="padding:{vb:stylevar formspacer}px">
<
div class="blockrow">
<
label>{vb:rawphrase stickyfirstpost_options}:</label>
<
ul class="checkradio group rightcol">
  <
li>
    <
label for="stickyfirstpost"><input type="checkbox" class="bginput" name="stickyfirstpost" value="1" tabindex="1" /> {vb:phrase stickyfirstpost_name}</label>
    <
class="description">{vb:phrase stickyfirstpost_desc}</p>
  </
li>
</
ul>
</
div>
<!-- 
end Sticky Posts --> 
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:49 AM.


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.05255 seconds
  • Memory Usage 2,192KB
  • 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
  • (8)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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