bingiman wrote:

...and what about my last post sad

In what regard? If you say what you're wanting the script to do, overall, we can skip the piecemeal approach and see if the script is workable for what you actually *want* it to do, rather than adding bits which don't. Make a list. (A specifically defined and explanatory one). smile smile

bingiman wrote:

hmm..Maybe MattF can look into that. I also found a problem. If I set for example 2 forums to display then the max setting which is (5) really has no effect. It displays way more than that. If however I remove the second forum, then it displays the correct amount of posts. Any solution for this issue and the one Connorhd mentioned.

Cheers!

Right. We'll start afresh. What do you want the script to do? Rather than adding bits that you want to the script you had, what exactly do you want the script to achieve, working from a blank start? Btw, the max setting is per forum, not overall.

Connorhd wrote:

Won't that order posts by the forum they are in rather than the order they were posted though?

The order they were posted per forum, in forum chunks, yes. Ordering them by creation time irrelevant of forum would be a bit of a rewrite, though. big_smile Besides, unless it's just me with an unusual way of thinking, per forum creation order does seem more logical than per creation order overall for the list ordering. The script could then accomodate some type of division to split the table layout between forum sections. (Btw, the above does make perfect sense in my head, but may appear a bit rambling, by the looks of this post). big_smile big_smile

bingiman wrote:

I see a slight problem in the script. If I set it to 350 characters and my text is below that it still displays the read more link.

Dots appended: http://outgoing.bauchan.org/unix/multi-index1.php.txt

Have you set both $trunc_chars settings to the same number? If so, the read more link should just become '- -' if the message is below the character limit.

bingiman wrote:

Don't mean to be a pain soonotes but is there a way for this to display more than one forum?

Try this one. The lines near the top:

$newsid[] = '1';
$newsid[] = '2';

Just add extra lines with each forum id, i.e:

$newsid[] = '3';
$newsid[] = '4';

Untested but should work.

http://outgoing.bauchan.org/unix/multi-index.php.txt

soonotes wrote:

Try this

Bugger. Just posted the one I'd done before I noticed you'd already posted one. big_smile big_smile

You need to set $trunc_chars, in both places it occurs, to the character truncation limit. It occurs once near the top of the file, and again in the second function, near the top of the file. Set both to the same number. Here's the file:

http://outgoing.bauchan.org/unix/index.php.txt

Edit: Btw, hope you don't mind me neatening the code up a tad whilst I had it? big_smile big_smile

1,708

(114 replies, posted in Programming)

eric235u wrote:
MattF wrote:

And just incase that page tickled your fancy, big_smile the full vi manpage on the FreeBSD site:

http://www.freebsd.org/cgi/man.cgi?quer … ormat=html

i've used vi for working with HUGE text files.  it can handle what other editors choke on.

It is a fine piece of kit. big_smile Plus, it's like haveing ed, sed and grep at your fingertips without ever exiting the editor itself. I've tried a few editors, and I always end up back with vi on a terminal session for scripting. big_smile big_smile

1,709

(114 replies, posted in Programming)

pogenwurst wrote:
MattF wrote:

And just incase that page tickled your fancy, big_smile the full vi manpage on the FreeBSD site:

http://www.freebsd.org/cgi/man.cgi?quer … ormat=html

Yup, manpages are always fun. wink

big_smile big_smile big_smile big_smile

bingiman wrote:

I know that MattF. The problem is that I can't do it. I''ve tried along with quaker and we can't get it at all.

Apologies. smile So you're actually referring to getting the script working generally within that script then, and not specifically to the truncate not working, so to speak? (If that makes any sense). big_smile big_smile

Edit: Integrating the truncate into that index script is what I was meaning by the above. big_smile I'll have an attempt at it later.

soonotes wrote:

Thank you MattF. Nice job, regex gives me headaches.

I should be thanking you for posting the script, not vice versa. smile Cheers.

The truncate script that soonotes posted works perfectly if you make that slight change to the regex. It just needs adapting for your script.

Re-compile php with support for the database type you require.

Well, the penny finally dropped about the regex. big_smile

if (preg_match_all('/<\/>([a-z]+)>/', $string, $end_tags))

The first '>' is totally irrelevant and useless. It can't match anything other than </>. That's the beastie that causes the problem. So that regex should be:

/<\/([a-z]+)>/

1,715

(10 replies, posted in Programming)

My sole three points of reference upto just have been that online manual, this section of the forum and some severe banging of head on desk whilst rewriting test scripts. big_smile big_smile

Edit: Might add, though, that fortunately php does have a lot of similiarities to my scripting method of choice, (which is shell), so I wasn't starting completely from scratch, so to speak. The one thing I have found really unusual to get to grips with in php is it's one command per very specific use type implementation, if that makes sense. Or, to put it another way, each command has, generally, a narrow usage point.

Quaker, look in the programming section. There's some info on the sessions bit in there. big_smile

http://punbb.org/forums/viewtopic.php?id=16090

quaker wrote:

mattf me and fsx worked on the issue with that code.. and got all kind of issue..
so i went and got a simpler javascript to do the function of truncate.

Q

Just edited my original reply to ask that question. smile What type of method does it use, though? From what little I know of java, that would seem that it makes a popup type text view? Or does it just link back to the thread?

bingiman wrote:

MattF - Why not use the last script we posted. It works and truncates..

Because I haven't seen it yet. big_smile Only just come back online. big_smile

Edit: Is that a Javascript truncation method? (I'm not quite back on the ball yet). big_smile

soonotes wrote:

Now that I think about it I had the exact same issue. I don't know what caused it but what I did was start again with the unmodified function and make the changes I needed.

In other words, try it with the code I posted and you shouldn't have the issue. Then make your changes one at a time and see when the issue occurs.

It is a very slightly altered, (just so it gets the relevant variables and no append), version of your code that I'm using, but I'll start afresh and see if it makes any difference. smile It works fine on every other type of tagging. It's just that one situation where you have '<tag color:', (and one assumes similar layout tags might cause it), where the problem lies. Like I say, I'll start afresh and see if that makes a difference though. smile Thanks again soonotes.

FSX wrote:

Here's a text truncate function:

<?php
function text_chop($text, $length) {
    if(strlen($text) > $length) {
        $text = substr($text, 0, $length)."...";  // instead of the ... you set an other ending message
    }
    return $text;
}
?>

How to use:

<?php
echo text_chop("here the message.",40); // message ends after 40 characters
?>

That code will just chop regardless, with no care or thought about tags, which is the problem I'm trying to get rid of. big_smile

Bingiman, you have a completely empty else statement at the bottom of that script:

else
 {
    }

You may as well remove it 'cos it's doing nowt. smile If I can get that niggle with the truncation script sorted, I'll merge it into your script.

I ain't much better on that bit. big_smile The mix of pcre and multi key arrays ain't exactly the easiest to figure. big_smile

soonotes wrote:

Are those spans in the $append? If so leave them open.

Have removed the append. smile Already have the read more setup where I'm trying to jemmy it, so that bit's unneeded. smile It's purely between the <p> </p> tags that it's adding the extras. I think it's the following where the problem is initially occuring:

if (preg_match_all ('/<([a-z\:\-]+)[ >]/', $string, $start_tags))

That tag closer almost..... works perfectly. big_smile The following makes it throw an extra couple of closing tags in though, and I ain't figured out where/why yet:

<span style="color: #FF0000">Red</span> <span style="color: #008000">Green</span></span></span>

The last two spans are purely gratuitous. big_smile

Cheers for that soonotes. smile I've had the truncation bugbear with the portal ever since I made it W3C strict, so I should be able to sort that now. Thanks again for posting the code. smile

'Bling', big_smile I'll have a diddle when I've a moment if you like? That don't mean it'll work though. big_smile