Recent Topics

1 Jan 29, 2008 00:37    

My b2evolution Version: 2.x

[2.4.0 rc] file is _item_comment.inc.php
I'm trying to apply an IF/ELSE to this file that applies a specific comment style for the blog's Admin.

This code works, except when it comes to "previewing" a comment before posting. There is no effective anchor to the preview..
http://forums.b2evolution.net/viewtopic.php?p=67164#67164

<?php
	$Comment->anchor();
	if ($Comment->get_author_User())
	{//If the comment author is a registered User
	echo $params['comment_start'];
	echo '<div class="registered">';
	}else{//else the comment author is a visitor
	echo $params['comment_start'];
	}?>

I have been trying to add the if/else to the following so that the bComment class can have an aternative registered class. I get nothing but errors all over the joint :)

// Default params:
$params = array_merge( array(
    'comment_start'  => '<div class="bComment">',
    'comment_end'    => '</div>',
    'Comment'        => NULL, // This object MUST be passed as a param!
	), $params );

Any hints ?

2 Jan 29, 2008 14:39

Some progress... well the page doesn't break any more...
For Post Preview, I'm trying to apply $comment->anchor() to the registered user. As it is it works for a visitor only.

<?php
	$Comment->anchor();
	if ($Comment->get_author_User())
	{//If the comment author is a registered User
	echo $params['comment_start'] = '<div class="registered">';
	}else{//else the comment author is a visitor
	echo $params['comment_start'];
	}
?>

I've tried all sorts of stupid combinations but can't crack it.

3 Jan 29, 2008 15:21

I must be tilting over your problem? $Comment->anchor() points to the comment with #comment_preview ?

As to the rest of your code it looks like once it changes to "member" then it'll stay that way ?

echo ( $Comment->get_author_User() ? '<div class="registered">' : $params[ 'comment_start' ] );

¥

4 Jan 29, 2008 15:45

Well, a visitor drafts a post and hits preview and is taken to the Comment_preview

When I, the only Member, preview a post, I'm taken to the top of the page!!!

5 Jan 29, 2008 16:02

You allow your visitors to draft posts? :roll:

When I comment as a member I get this as a url
http://dev.innervisions.org.uk/blog1.php?blog=1&title=first-post&disp=single&more=1&c=1&tb=1&pb=1#comment_preview
and I'm taken to the previewed comment?

¥

6 Jan 29, 2008 16:07

When I comment as a Member I get this URL
/index.php?blog=2&title=my-very-bad-car-day&disp=single&more=1&c=1&tb=1&pb=1#comment_preview

and am not taken to the previewed comment

When I log out, make a post and hit preview, I am taken to the previewed comment!!!

7 Jan 29, 2008 16:08

Any chance of a link and a login?

¥

8 Jan 29, 2008 16:16

Thanks for the login, but I had a moment of inspiration and guessed 2 things :

1) this'd be your normal blog and not a dev backup :|
2) you're not the sort to change your password with any great haste ;)

change the code to

echo ( $Comment->get_author_User() ? str_replace( 'class="', ' class="registered ', $params['comment_start' ] ) : $params[ 'comment_start' ] );

Hit save and hope I didn't break anything important ;)

9 Jan 29, 2008 16:22

Thanks. :)
so, just clarifying and confirming..... the code is now

<?php
	$Comment->anchor();
	echo ( $Comment->get_author_User() ? str_replace( 'class="', ' class="registered ', $params['comment_start' ] ) : 
?>

??

10 Jan 29, 2008 16:22

Yeah, give that a blast and see if it melts your cpu ;)

¥

11 Jan 29, 2008 16:26

Seems to to be the cats whiskers

I'll crash test it more later.... and thanks mate.

12 Jan 29, 2008 16:26

*gets out crystal ball*

I foresee that your next question is going to be about lost styling :

echo ( $Comment->get_author_User() ? preg_replace( '~class="[^"]+?"~', ' class="registered"', $params['comment_start' ] ) : $params['comment_start'] );

¥

13 Jan 29, 2008 20:16

Methinks that sometimes you "foresee" a tad too much....

I would have got around to it sooner or later though :)


Form is loading...