Limit Friends Shown in the User Channel in Clip-Bucket v2

Hello,

If you want to set a limit of how many friends are shown in each user channel, then keep reading this article. The question was originally posted at the Clip-Bucket forum and answered there by me, so I asked myself ‘why don’t you write an article about this?’ This article is tested to work in v2.6, but the essence is the same for any CB version or any Smarty powered template. See the following image to see the listing we are going to limit.

b1

1. Open channel_left.html, located inside ./styles/cbv2new/layout/*

2. Find

{foreach from=$userFriends item=friend}

3. Assign the foreach loop a name (in this case friendsloop). Replace it with:

{foreach from=$userFriends item=friend name=friendsloop}

4. We will use Smarty index to get the current iteration of the loop (read more here: http://www.smarty.net/docsv2/en/language.function.foreach). Create the if to check the current index, if it is less than our limit (10) keep showing friends:

{if $smarty.foreach.friendsloop.index < 10}

Replace 10 with your desired limit.

5. After that if check, add the include that was previously there, making our foreach loop look like this:

	{foreach from=$userFriends item=friend name=friendsloop}
		{if $smarty.foreach.friendsloop.index < 10}
			{include file="$style_dir/blocks/user.html" user=$friend block_type="friends"}
		{/if}
	{/foreach}

Remember to close the if with {/if}

b2

And that’s all. If you have any problem or question at any step, please do not hesitate to contact me and I’ll be more than glad to assist you.

Best Regards,

Richi

Looking for quality ClipBucket Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , , , , | Posted under ClipBucket | RSS 2.0

Author Spotlight

Richi González

Richi González

I started programming when I was 12. I'm a Developer and have been working with the Clip-Bucket script since it came out. I became a Liaison between Arvixe and Clip-Bucket, so I am here to assist you with anything you need regarding Clip-Bucket or any particular computer-related subject you need. Best Regards, Richi

Leave a Reply

Your email address will not be published. Required fields are marked *


− 1 = 6

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>