Recent Topics

1 Jun 06, 2009 20:16    

My b2evolution Version: 2.x

Hello people.
A question re. the list of recent comments in my side bar...is there a way to limit the post title length?

Ie. Currently:

Author on Dads got all these plans...
Author on Still RocknRolling!
Paul on Still RocknRolling!
Matt on Growing up in New Zealand

Would become:

Author on Dads got...
Author on Still RocknRolling!
Paul on Still RocknRolling!
Matt on Growing up...

Im talking about setting it to just including the first X number of letters or words on the post title. Id like this so it stops the longer titles "wrapping" onto the second line and looking messy. Yes, Im anal retentive.

2 Jun 10, 2009 05:03

this is not possible at the time... would be a nice plugin...

3 Jun 10, 2009 05:07

Thanks for the response esanchez.
Yes, it really would.

4 Jun 10, 2009 13:10

Sounds like fun to do as well. I'll "watch" this topic as a reminder from me to me that there is something here I'm interested in tinkering on. If someone smart beats me to it then so be it: I'll save my 'sledge hammering ugly code' for some other neato thing :)

5 Jun 10, 2009 13:19

Excellent :).

Will look forward to it.

6 Jun 10, 2009 15:42

/inc/widgets/widgets/_coll_comment_list.widget.php approx 157

			$title = ( !empty( $this->disp_params['comment_maxchars'] )
 && strlen( $Comment->Item->title > $this->disp_params['comment_maxchars'] ) ?
substr( $Comment->Item->title, 0, $this->disp_params['comment_maxchars'] )
 : 
$Comment->Item->title );
			$Comment->permanent_link( array(
				'text'        => $title,
				'title'       => $this->disp_params[ 'hover_text' ],
				) );

Then, in your skins container just add

'comment_maxchars' => ###, // change ### to the number of chars huh? ;)

So it'd look summat like :

<div id="sidebar">

	<ul>
	<?php
		// ------------------------- "Sidebar" CONTAINER EMBEDDED HERE --------------------------
		// Display container contents:
		skin_container( NT_('Sidebar'), array(
				// The following (optional) params will be used as defaults for widgets included in this container:
				// This will enclose each widget in a block:
				'block_start' => '<li class="$wi_class$">',
				'block_end' => '</li>',
				// This will enclose the title of each widget:
				'block_title_start' => '<h2>',
				'block_title_end' => '</h2>',
				// If a widget displays a list, this will enclose that list:
				'list_start' => '<ul>',
				'list_end' => '</ul>',
				// This will enclose each item in a list:
				'item_start' => '<li>',
				'item_end' => '</li>',
				// This will enclose sub-lists in a list:
				'group_start' => '<ul>',
				'group_end' => '</ul>',
				// This will enclose (foot)notes:
				'notes_start' => '<div class="notes">',
				'notes_end' => '</div>',
				'comment_maxchars' => 6, // change ### to the number of chars huh? ;)
			) );
		// ----------------------------- END OF "Sidebar" CONTAINER -----------------------------
	?>
	</ul>

You can get funkier and add "after cutoff" text and limits for content for those who want to show an excerpt as well ;)

¥

*edit*
added linebreaks to avoid killing forum layout :roll:

7 Jun 10, 2009 16:06

This is awesome, thank you B)

And please ignore everything I previously had written in the post because I was wrong 8| .

Thanks again Yabba.

8 Jun 10, 2009 16:15

It may not look it but I'm awesome at coding .... when I test stuff :roll:

			$title = ( !empty( $this->disp_params['comment_maxchars'] ) && strlen( $Comment->Item->title ) > $this->disp_params['comment_maxchars'] ? substr( $Comment->Item->title, 0, $this->disp_params['comment_maxchars'] ) : $Comment->Item->title );

;)

¥

9 Jun 10, 2009 16:31

:) I was about to come back looking basful for jumping the gun...twice.

Working!

The "after cutoff" text you mentioned, would that be " ... " or similiar? B)

10 Jun 10, 2009 16:57

it'd be another setting, but you could default it to "..."

¥

11 Jun 10, 2009 17:02

Ive just added a:

echo T_( '...' );


under the code. Seems to work. Touch wood.

12 Jun 10, 2009 17:03

$title = ( !empty( $this->disp_params['comment_maxchars'] ) && strlen( $Comment->Item->title ) > $this->disp_params['comment_maxchars'] ? substr( $Comment->Item->title, 0, $this->disp_params['comment_maxchars'] ).'...' : $Comment->Item->title ); 

tad hard coded, but it'll work better ;)

¥

13 Jun 10, 2009 17:11

:D Oh nice. Knight in shining armour. Every girl loves them (regardless of what they say ;) ).

14 Jun 10, 2009 17:17

alrighty then! unwatching commences in 5 ... 4 ... 3 ... 2 ... ONE!

15 Jun 10, 2009 17:31

/bb|[^b]{2}/ || /b{2}?/i ?

¥

16 Jun 11, 2009 04:50

People might still be keen on a plugin version Ed.


Form is loading...