Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 11-03-2008, 09:49 PM
mad@Max's Avatar
mad@Max mad@Max is offline
 
Join Date: Jul 2007
Location: Russia
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Add checkbox

I need add checkbox in newthread, newreply, editpost. If checkbox checked in new cell of table "post" adding value "1", unchecked - value "0".
So, how i may did that?
Reply With Quote
  #2  
Old 11-27-2008, 02:41 PM
mad@Max's Avatar
mad@Max mad@Max is offline
 
Join Date: Jul 2007
Location: Russia
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll try explain...
Im little rewrite news module (vbadvanced), for last posts:
PHP Code:
        $getnews $db->query_read("
            SELECT 
$ratingsql user.*, thread.threadid, post.title, thread.title, thread.replycount, post.username AS puname, post.userid AS puid, postusername, postuserid, post.dateline AS postdateline, sticky, thread.attach, thread.lastpostid, thread.lastposter, thread.lastpost, IF(views<=thread.replycount, thread.replycount+1, views) AS views, thread.forumid, post.postid, pagetext
            
$vba_news_fields
            FROM " 
TABLE_PREFIX "thread AS thread
            LEFT JOIN " 
TABLE_PREFIX "post AS post ON (post.postid = thread.lastpostid)
            LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid = post.userid)
            
$vba_news_join
            WHERE thread.threadid IN(" 
implode(','$newstids) . ")
            " 
iif(!$threadsqueried AND $mod_options['portal_news_cutoffdate'], 'AND thread.dateline > ' . (TIMENOW - ($mod_options['portal_news_cutoffdate'] * 86400))) . "
            " 
iif($ignusers'AND thread.postuserid NOT IN(' $ignusers ')') . "
            " 
iif($mod_options['portal_applypermissions'], $forumperms_query) . "
            AND rel_yn = 1
            ORDER BY " 
iif($mod_options['portal_news_sticky'], 'sticky DESC, ') . $mod_options['portal_news_orderby'] . $mod_options[portal_news_direction]
            " 
iif($limitapplied'LIMIT ' . ($mod_options['portal_news_maxposts'] + $mod_options['portal_news_enablearchive']), $newslimit) . "
        "
); 
Where "rel_yn" is custom added cell of "post" table, with values 0 and 1. So, if post have value = 1 message showing on main page, else not showing.
The case for small, add checkbox in posting form, where you can choose send message on main page or not (check or uncheck checkbox).
So, how did this?
Checkbox in template:
HTML Code:
<label for="cb_rel_yn"><input type="checkbox" name="rel_yn" value="1" id="cb_rel_yn" tabindex="1" $checked[rel_yn] />Send this message on main page?</label>
In attach screenshot how it will be look and product where i was trying realise this...
Pls help.
Attached Images
File Type: jpg 26.11.jpg (50.0 KB, 0 views)
File Type: jpg 26.111.jpg (47.9 KB, 0 views)
Attached Files
File Type: xml product-relyn.xml (2.0 KB, 4 views)
Reply With Quote
  #3  
Old 11-27-2008, 03:34 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you've done what you need to do, but you didn't say if you already added the column rel_lyn to your database. What is the result of what you have done so far?
Reply With Quote
  #4  
Old 11-27-2008, 04:42 PM
mad@Max's Avatar
mad@Max mad@Max is offline
 
Join Date: Jul 2007
Location: Russia
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I already added column rel_lyn, i want make work this checkbox.
It worked just on unchecked selection, in column add value 0 just in new post. But if you check it, rel_lyn column will be rewrited in all post as value 1...
Reply With Quote
  #5  
Old 11-30-2008, 03:57 PM
mad@Max's Avatar
mad@Max mad@Max is offline
 
Join Date: Jul 2007
Location: Russia
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump
Reply With Quote
  #6  
Old 11-30-2008, 04:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So, it is set to "0" unless someone checks the box, in which case it is set to "1". That is what you want, right? But, instead, what is happening?
Reply With Quote
  #7  
Old 11-30-2008, 04:22 PM
mad@Max's Avatar
mad@Max mad@Max is offline
 
Join Date: Jul 2007
Location: Russia
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Instead that, when you check the box, rewrited all values in column rel_yn...
Reply With Quote
  #8  
Old 11-30-2008, 04:35 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What does your write/update statement look like? It sounds like your script is written incorrect if it is changing every column instead of just the column for that post.
Reply With Quote
  #9  
Old 11-30-2008, 04:43 PM
mad@Max's Avatar
mad@Max mad@Max is offline
 
Join Date: Jul 2007
Location: Russia
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I attach plugins in second post, how i did this.
Changing just one column, rel_yn. So, if you leave box not checked - rel_yn vill be changed on 0, in the new post, if you check the box - rel_yn will be changed in all post.
Reply With Quote
  #10  
Old 11-30-2008, 04:50 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need a where statement in here:
PHP Code:
       if($post['rel_yn']) // true
       
{
                
$vbulletin->db->query_write("UPDATE " TABLE_PREFIX "post SET rel_yn = 1 WHERE postid=$postid
"
);
       }else{ 
// false
                
$vbulletin->db->query_write("UPDATE " TABLE_PREFIX "post SET rel_yn = 0 WHERE postid=$postid
"
);
       } 
I don't know that "WHERE postid=$postid" is the correct way to write it, but you need to update the table only where the postid is equal to the post you are submitting. If you added that to the post table, you should be able to just use the datamanager to set it. Something like:
PHP Code:
$threadman->set('rel_yn'$vbulletin->GPC['rel_yn']); 
First you need to clean the variable and then set it in the correct place (I didn't look to see if newpost_complete is the correct location). It just needs to be before there is a statement like this instead of what you are doing (adding a query):
PHP Code:
$threadman->save(); 
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:07 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.04566 seconds
  • Memory Usage 2,287KB
  • Queries Executed 12 (?)
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
  • (1)bbcode_html
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (3)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete