vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   first post (https://vborg.vbsupport.ru/showthread.php?t=222073)

testbot 08-30-2009 01:24 AM

first post
 
is there away to pull the first post from using a plugin hook?

Brandon Sheley 08-30-2009 03:07 AM

the first post on the whole forum? or from one particular user? or from one section

Lynne 08-30-2009 03:18 AM

And to use where? Which hook location? Just the post id or the actual text or ?? Your question is waaaaay too general unless you just want an answer like "yes, probably".

testbot 08-30-2009 04:10 AM

oh sorry... i want to get the text from the first post in a thread and store it to a value.

$first_post =

not sure if i can use showthread_start

or if there's already something like $threadinfo[title] i could use that.

thanks for your replies!

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

Quote:

Originally Posted by Loco.M (Post 1876644)
the first post on the whole forum? or from one particular user? or from one section


just the first post of every thread regardless of user or forum.

Lynne 08-30-2009 03:49 PM

So, you want to grab the text of the first post in every thread and put it where? We need to know where you are going to display it in order to figure out the variable name. (You know the first text (a set amount of it) is already displayed if you hover over the thread title in the forumdisplay.php page, right?)

testbot 08-30-2009 04:29 PM

i know if i tell you where i'm going to put it you're just going to tell me to buy vbseo. i don't want that junk. lol

i'm putting it in the head description.

Lynne 08-30-2009 04:59 PM

Since I am barely familiar with vbseo (I know what it is, but that's all), I would never suggest to someone to buy it.

The $header is evaled before the SHOWTHREAD template is. You will have to write a query in the global_start location (perhaps) to grab the text from the first post of the thread and then do something with it.

testbot 08-31-2009 11:38 AM

thanks as always Lynne. that makes sense. time to brush up on proper vbulletin queries. :)

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

of course i'm back. :(

not only does my code suck but i also don't know the db structure. i don't have phpmyadmin installed or anything so digging through tables and stuff via command line seems like a lot of work.

what jumps out at you when you look at the following.

i know this is wrong but this is what i have so far:

Code:

$thread_id_inj = $_GET['t'];
if ($thread_id_inj != '' && $_GET['styleid']==9){
        //global $db $vbulletin;
        //$get_first_post_inj = $db->query_read();

        $get_first_post_inj = $vbulletin->db->query_read("SELECT pagetext FROM " . TABLE_PREFIX . "post WHERE threadid = $thread_id_inj LIMIT 1");
}
echo $get_first_post_inj;

i get the following:

Code:


Database error in vBulletin 3.8.4:

Invalid SQL:
;

MySQL Error  :
Error Number  : 0


James Birkett 08-31-2009 01:36 PM

Quote:

Originally Posted by testbot (Post 1876891)
i know if i tell you where i'm going to put it you're just going to tell me to buy vbseo. i don't want that junk. lol

i'm putting it in the head description.

You mean similar to what RaGEZONE has (or had)? where it shows the beginning of a thread in the description of that forum?

Lynne 08-31-2009 03:09 PM

So you are passing both the threadid and styleid in the url? If so, you need to clean them prior to using them. example:
PHP Code:

$vbulletin->input->clean_array_gpc('r', array(
    
'threadid'   => TYPE_UINT,
    
'styleid'    => TYPE_UINT,
)); 

Then you can use $vbulletin->GPC['threadid'] or assign another variable to that value. example:

PHP Code:

$thread_id_inj $vbulletin->GPC['threadid']; 

Then, use query_first instead of query_readsince you are only expecting one result. Then you don't have to do a fetch_array (which you didn't do which is why it isn't working).

And don't echo. Assign the result to a variable and then insert the variable into the template where you want it.

You may have issues just using the pagetext as is (I can't remember). Perhaps use stripslashes or similar after you get it from the database.


All times are GMT. The time now is 08:22 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.01028 seconds
  • Memory Usage 1,739KB
  • 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_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete