PDA

View Full Version : Help with pagetext in forumdisplay.php


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
$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:
$page=$post[pagetext];
With:
$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:

$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, [/i]=red]text will be converted to <font color="red">text</font>.

Up to you.
To convert the text, use this:
$page=bbcodeparse2($page,1,1,1,1);
The 1 numbers are in this order:
$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:

$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:


$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:
$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:



$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:


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

}

and getting a parse code error at line 527.

Also should that be

,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:
} 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);

Parker Clack
12-08-2001, 11:29 PM
Chen:

I got that code to work too. Thanks so much.

Here is what I am trying to do and maybe you have some thoughts on this.

First off. The "title" tag can be used in a hyperlink so that it is a mouseover pop up box. So whatever you put in that title="your tex here" will get put in a little box when a person puts their mouse on the hyperlink.

The HMTL code would look like
< a href="http://www.yourplace.com" title="This is a test to show you what I am talking about" >Testing< /a >

and you just put that in the forumdisplaybit template as

<a href="showthread.php?s=$session[sessionhash]&threadid=$thread[threadid]" title="$page">$thread[title]</a>

At any rate I am wanting to put the $page output from the code used here but a lot of cases when a member posts a large font or they use some kind of extra html code or vB code that code shows up in the actual hyperlink itself. So instead of just the title of the thread the pagetext code shows up in the hyperlink text too. The majority of the time this works great. It is just those cases where the code is off. So, play around with this for a bit and see what you can come up with if you want.

Some members of mine have seen this used on another site, using a cold fusion type BB, and it works fine there.

Thanks for all the help with everything.

Parker

Parker Clack
12-09-2001, 12:19 AM
Chen:

I was noticing in the functions.php file using the bbcodeparse2 there are a bunch of replacement variables that are set up.

What I was thinking was you could write a bbcodeparse3 and have the script look at anything that had a [ ] or < > and replace it and everything that is in those brackets with "" instead.

This would make me think that it would strip out anything that is within any of those types of brackets, whether vB code or HTML.
All you would be left with is the text. Which is what you want anyway.

Any ideas on how to write that code for the bbcodeparse3?

Thanks,
Parker

Parker Clack
12-09-2001, 07:36 AM
I tried using:

$page=wordsonly($page)

and that worked to some degree but it still stripped out some of the hyperlink text itself and then butchered the actual text taking out the I's, Its, on, any, etc. but left other words alone. Very strange.

Any ideas on what I could use in the functions.php that would only put text and nothing between the [ ] and < >?

Parker

bira
12-09-2001, 07:50 AM
Parker, do this:

after

$page=bbcodeparse2($page,1,1,1,1);
(this will give you the text with the bbcodes turned html)

Do

$page=strip_tags($page);
(This will give you the text without the html codes).

Cheers,

Bira

Parker Clack
12-09-2001, 10:00 AM
Thanks Bira:

That worked great.

Parker