Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2013, 11:46 AM
glennybee glennybee is offline
 
Join Date: Feb 2008
Location: Scotland
Posts: 329
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Adding a Miscellaneous Option on new thread post

Hi,

I am looking to add an option to the Miscellaneous Options part of a new thread post.

I have set up my forum so that members can claim authorship via their google plus profile of any threads they create.

I want to add an option to the Miscellaneous Options saying "Claim google authorship of this thread."

And all it needs to do if it is checked, is add a rel="author" tag to the username link on the first post of the thread.

Would i do this with a plugin or what?

Thanks so much in advance
Reply With Quote
  #2  
Old 02-05-2013, 12:53 PM
glennybee glennybee is offline
 
Join Date: Feb 2008
Location: Scotland
Posts: 329
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok so this is my first time working with any of this so here is what ive done so far, ive managed to add the checkbox to the additional options by adding this code to the newthread template...


PHP Code:
<div>

<
label for="cb_authorship"><input type="checkbox" name="authorship" value="1" id="cb_authorship" tabindex="1" $checked[authorship] />Claim google authorship</label>

</
div


I have then added this to the postbitlegacy template...

PHP Code:
<if condition="$show['authorship']">
                <
class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]rel="author">$post[musername]</a>
<else />
<
class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a></if> 
Again i have no idea if this is right because this is my very first time working with assigning variables and using IF statements etc in PHP

Anyway, is there anything else i need to do for this to work?
Its probably so far off the mark but i just kinda copied some code from the other options nearby and modified them to try and do what i want it to do...

Any help would be greatly appreciated.
Thanks

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

I take it im not assigning the variable right.

So i need to add some sort of...

if authorship is checked, then set $show[authorship] =true?

Someething along those lines? anyone?

im struggling hehe cheers

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

So im guessing i need to add a plugin with the code that will find out if cb_authorship was checked, if so, set $show[authorship] to true.

What would the code be for this, and what hook location should i add it to?
thanks in advance

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

Also i am running vb3.8
Reply With Quote
  #3  
Old 02-05-2013, 03:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Probably what you need to do is add a column to the thread table of the database to save the value of your "authorship" option. Then I think you can get the thread data manager to save that value for you, but you need a couple of plugins, one to tell the datamanager about that field, and another to call the datamanager "set()" function with your value when the thread is created.

If you look at file includes/class_threadpost.php, search for "class vB_DataManager_Thread_FirstPost" and then scroll down, you'll see an array $validfields which specifies the fields that can be set in this datamanager. If you scroll down more to "function vB_DataManager_Thread_FirstPost", you can see there's a hook when one of those objects is created (which is done when a thread needs to be created or modified). So if you create a plugin using that hook location, you can add your field to the array, like maybe:

Code:
$validfields['authorship'] = array(TYPE_UINT, REQ_NO);

then I think it will be set up to save your value for you, and it then it will also automatically be read in as thread info later. (remember, you still need to create the column in the database yourself).


But you still need your value to be set in the datamanager. I think if you look at includes/functions_newpost.php and search for function build_new_post(), there's probably a hook location there you can use to do that (that funciton is called for both new threads and replies, so you'd probably want to check for $type == 'thread' so you're only setting it for threads).

Anyway, I hope that helps enough for you to make progress.
Reply With Quote
  #4  
Old 02-05-2013, 03:41 PM
glennybee glennybee is offline
 
Join Date: Feb 2008
Location: Scotland
Posts: 329
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I really appreciate your help, ive tried to follow your guide but im totally lost. i think its just way over my head, ive never done any php stuff before so i think i'll need to hand it over to an expert to get it finished.

Really appreciate you taking the time to reply though

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

do you know where the cb_signature variable gets handled and i could check that out? ---- its cool forget it, im totally lost lol
Reply With Quote
  #5  
Old 02-05-2013, 04:01 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, sorry about that. I know that's hard to follow if this is your first mod.. If I get a chance, I'll try to put together the plugin parts so you can just make the template changes you talked about (unless you decide to go a different way, then let me know).
Reply With Quote
  #6  
Old 02-05-2013, 04:27 PM
glennybee glennybee is offline
 
Join Date: Feb 2008
Location: Scotland
Posts: 329
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think i've made the right changes to the class_dm_threadpost.php file so that it should be able to handle a 'authorship' variable, but didnt know wha tot do from there.

I dont know if im over complicating it, and maybe theres an easier way, not sure.
Reply With Quote
  #7  
Old 02-05-2013, 04:43 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, well, to answer your question about how the signature option gets handled: if you look at script newthread.php and look for this section (around line 97):

Code:
// ############################### start post thread ###############################
if ($_POST['do'] == 'postthread')
{

you can see below that there's a call to $vbulletin->input->clean_array_gpc), that gets the values from the form that was submitted and puts them in the $vbulletin->GPC[] array. So you'd want to add your authorship field to that list. Then if you look below that, what's happening in general is that the form values from $vbulletin->GPC[] are being transfered to the $newpost array, so you'd want to take your authorship value and do that (probably it would just be $newpost['authorship'] = $vbulletin->GPC['authorship']).

Now if you go back to looking at build_new_post() in functions_newpost.php, you can see the values from the $post parameter (which is just the $newpost from before) are being transfered to the datamanager. So you'd want to add something like:

Code:
if ($type == 'thread' AND isset($post['authorship']))
{
   $dataman->set('authorship', $post['authorship']);
}

I think that should do it. If you do all that then I think you should be able to check $threadinfo['authorship'] in an <if> tag in the template.

BTW, I don't think you're making it complicated - it's quite a bit to figure out from scratch. (And it's not the only way to do it, obviously). Also I'm assuming you're not trying to use plugins but are changing the files? That's OK, using plugins does sometimes make it harder to figure out how to get things done, and since vb3 isn't being updated any more (or at least rarely), it doesn't make much difference.
Reply With Quote
  #8  
Old 02-05-2013, 05:04 PM
glennybee glennybee is offline
 
Join Date: Feb 2008
Location: Scotland
Posts: 329
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

when i add... $newpost['authorship'] = $vbulletin->GPC['authorship']

to newthread.php, i get this error when tryingto submit a new thread

Parse error: syntax error, unexpected T_VARIABLE in /home/buckyuk/public_html/moneymakingexperts.org/newthread.php on line 195

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

am i adding it to the wrong section of newthread.php... line 192?
Reply With Quote
  #9  
Old 02-05-2013, 05:07 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That looks like a good place. You might just need a semicolon at the end of that line.
Reply With Quote
  #10  
Old 02-05-2013, 05:30 PM
glennybee glennybee is offline
 
Join Date: Feb 2008
Location: Scotland
Posts: 329
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok now im getting this error when i hit submit new thread.

Fatal error: Call to a member function set() on a non-object in /home/buckyuk/public_html/moneymakingexperts.org/includes/functions_newpost.php on line 321

I added the code you gave from line 319 to 322

Code:
if ($type == 'thread' AND isset($post['authorship']))
{
   $dataman->set('authorship', $post['authorship']);
}
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 01:55 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.04180 seconds
  • Memory Usage 2,269KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete