vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How do I update a custom thread field on editpost? (https://vborg.vbsupport.ru/showthread.php?t=159557)

AreaZeroOne 10-05-2007 09:19 PM

How do I update a custom thread field on editpost?
 
Hi.

I created a custom field, i'll call it, Field1, that a user fills out when creating a new thread. Now i've written some plugin code so that when the new thread is created, the field1 options (option1,2,3,etc;) are sucessfully posted to the db (along with everything else).

However, i'm having trouble understanding the rest. On editpost, I can populate the field with the current selection, but I cannot update the field (one because there's nothing handling it). I'm pretty much stuck here!

So to avoid further insanity, how would I go about finishing this up?

Thanks for any help.

:edit: The fields have nothing to do with the fields one can create via the AdminCP.

Jelmertjee 11-23-2007 09:10 AM

I know you posted this a while ago, but did you find a solution after all? I'm trying to figure this out as well... I have custom fields when creating threads, but what's the use when you can't edit them right?

I didn't get as far as you did though, could you explain (or post the code) you used to populate the fields again when editing the threads?

WhaLberg 11-23-2007 09:15 AM

Add a plugin to editpost_update_complete hook and paste these codes:

PHP Code:

$db->query_write("UPDATE " TABLE_PREFIX "post SET fieldname = " $_POST['fieldname'] . " WHERE postid = " $postinfo['postid'] . ""); 

Let me know the result.

Jelmertjee 11-23-2007 10:36 AM

Thanks! I've got it working right now, I needed to add some quotes around the variable but that was all.

So, now I can edit the custom post fields, but they aren't automatically filled with the 'old' content yet, which had been set when creating the thread, I know how the template part works, just need the php/mysql to do it...

WhaLberg 11-23-2007 10:43 AM

Hmmm...

This will give you what you need. Add to editpost_start.
PHP Code:

$getinfo $db->query_read("SELECT fieldname FROM " TABLE_PREFIX "post WHERE postid = " $postinfo['postid'] . "");
$fieldinfo $db->fetch_array($getinfo);
$fieldname $fieldinfo['fieldname']; 

To have this working, you must set your field in your edit post template as <input type="text" value="$fieldname" name="fieldname" *>

Jelmertjee 11-23-2007 06:54 PM

Thanks again, it works like a dream now ;), is there anything I can do for you in return??

WhaLberg 11-25-2007 03:03 PM

Just thanking is enough. :)


All times are GMT. The time now is 09:14 AM.

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.01018 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete