vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Help with pagetext in forumdisplay.php (https://vborg.vbsupport.ru/showthread.php?t=33012)

Parker Clack 12-07-2001 02:36 PM

I am wanting to call up the first post in a thread using the pagetext information in the post table. What would I use as a database query so that I get the pagetext associated with the first post in a thread?

I am wanting to use this in the forumdisplay.php file right before the call to the forumdisplaybit template.

I have tried using:

$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid]");
$page=post[pagetext];

But I get varied results and it is is not the first post associated with the threadid.

Any ideas?

Thanks,
Parker

Admin 12-07-2001 02:43 PM

Code:

$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");

Parker Clack 12-07-2001 10:16 PM

Chen:

Thanks. That worked like a champ.

Now what would I use to keep the pagetext information limted to the first 30 characters followed by a ....? Is there a code to strip the vbcode and HTML code in the pagetext information? I would prefer to keep the vB code and HTML out of the information that is displayed.

Thanks,
Parker

Admin 12-08-2001 07:57 AM

Replace:
Code:

$page=$post[pagetext];
With:
Code:

$page=iif(strlen($url)>30,substr($post[pagetext],0,30)."..."),$post[pagetext]);
to only show first 30 chars followed by '...'.

Don't know about the vB code stripping though.

Parker Clack 12-08-2001 08:27 AM

Instead of striping the vBcode would you use the bbcodeparse2 or bbcodeparse?

So you could have:

Code:

$page=iif(strlen($url)>30,substr($post[pagetext],0,30)."..."),$post[pagetext]);
followed by

$page2=bbcodeparse[$page];

or

$page2=bbcodeparse2[$page];

Do you think that would work ok?

What would you have to use if you wanted to parse the html in the pagetext then?

Parker

Admin 12-08-2001 08:47 AM

If you parse vB code, the output will simply have the equal HTML code.
For example, [color=red]text[/color] will be converted to <font color="red">text</font>.

Up to you.
To convert the text, use this:
Code:

$page=bbcodeparse2($page,1,1,1,1);
The 1 numbers are in this order:
Code:

$page=bbcodeparse2($codetoparse, $html, $imgcode, $smilies, $vbcode);

Parker Clack 12-08-2001 12:03 PM

Chen:

Ok, bare with me a little more.

I put in:

Code:

$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($url)>30,substr($post[pagetext],0,30)."..."),$post[pagetext]);
$page=bbcodeparse2($page,1,1,1,1);

and got a parse error:

Then I put in just:

Code:

$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($url)>30,substr($post[pagetext],0,30)."..."),$post[pagetext]);

and also got a parse error.

So is $url supposed to be that or something else like $thread[threadid]. I mean where do the $url come from?

Also, is the bbcodeparse2 suppsed to have the numbers or
the $html, $vbcode, etc.?

Thanks again,
Parker

Admin 12-08-2001 12:11 PM

Sorry, my bad, use this code:
Code:

$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($post[pagetext])>30,substr($post[pagetext],0,30)."...",$post[pagetext]);
$page=bbcodeparse2($page,1,1,1,1);

(misplaced a parenthesis)

And in the bbcodeparse2() call you use 1 or 0 - 1 means it's parsed and 0 means it's not. :)

Parker Clack 12-08-2001 01:08 PM

Sorry Chen it is still giving me a parse code error.

In forumdisplay.php I am putting:


Code:

$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($post[pagetext])>30,substr($post[pagetext],0,30)."...",$post[pagetext]);
$page=bbcodeparse2($page,1,1,1,1);

right above:


Code:

eval("\$forumdisplaybits .= \"".gettemplate('forumdisplaybit')."\";");

}

and getting a parse code error at line 527.

Also should that be

Code:

,30),"...", instead of ,30)."...",  ?
Parker


If I put a right bracket before the eval line I get a parce code error at line 520.

Thanks,
Parker

Admin 12-08-2001 01:35 PM

This code in forumdisplay.php is working great for me, no errors or anything:
Code:

    } else {
            $backcolor = '{firstaltcolor}';
                $bgclass = "alt1";
    }
    $post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
    $page=iif(strlen($post[pagetext])>30,substr($post[pagetext],0,30)."...",$post[pagetext]);
    $page=bbcodeparse2($page,1,1,1,1);

    eval("\$forumdisplaybits .= \"".gettemplate('forumdisplaybit')."\";");

  }
  $DB_site->free_result($threads);



All times are GMT. The time now is 03:29 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.01019 seconds
  • Memory Usage 1,737KB
  • 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
  • (13)bbcode_code_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