Not Solved Limited Bio
#1
Not Solved
Hi, I wanted to know is there is any way to limit Bio details to a certain word count after which a "Read More" link for a pop-up is created? Or at least something to limit the words amount.

Thanx
I may be wrong, but that\'s how I learn :~)
Reply
#2
Not Solved
something like this?
http://server4.goughy000.com/mybbdemo/me...file&uid=2

EDIT:
here it is anyway, make sure you name it 'goughy_shortbio.php' and place it in /inc/plugins. then activate it in plugin manager in ACP
<?php

//Goughy000 -> goughy_shortbio.php
//Byteforums.com
//Email: [email protected]

//Config:
//shorten bio to how many letters?
global $shortentothislength;
$shortentothislength = "50";


global $mybb;
//If the members on the profile page and the "showfullbio" is not yes
if($mybb->input['action'] == "profile" && $mybb->input['showfullbio'] != yes){
 	//run the plugin (shortens the bio)
	$plugins->add_hook("member_profile_end", "goughy_shortbio");
}else{
	//displays as normal
}

function goughy_shortbio_info(){
    return array(

        "name"        => "Short Bio",

        "description"   => "Shorten the bio if it goes over a certain word count",

        "website"    => "http://www.byteforums.com/",

        "author"     => "Goughy000",

        "authorsite"    => "http://www.goughy000.com/",

        "version"     => "0.1",

    );

}

function goughy_shortbio(){
 	//Globalise some variables
 	global $mybb;
 	global $db;
 	global $customfields;
 	global $profilefields;
 	global $uid;
 	global $templates;
 	global $shortentothislength;
 	global $lang;
 	
	//First we're going to scrap what mybb just did...
	$customfields = "";
	$profilefields = "";
	
	//now We're going to run it again with some added code to shorten the bio and add a link, how hard can it be??
	
	//NOTE: THIS IS NOT MY CODE//////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	$query = $db->simple_select(TABLE_PREFIX."userfields", "*", "ufid='$uid'");
	$userfields = $db->fetch_array($query);
	$customfields = '';
	$bgcolor = trow1;
	// If this user is an Administrator or a Moderator then we wish to show all profile fields
	if($mybb->usergroup['cancp'] == "yes" || $mybb->usergroup['issupermod'] == "yes" || $mybb->usergroup['gid'] == 6)
	{
		$field_hidden = '1=1';
	}
	else
	{
		$field_hidden = "hidden='no'";
	}
	$query = $db->simple_select(TABLE_PREFIX."profilefields", "*", "{$field_hidden}", array('order_by' => 'disporder'));
	while($customfield = $db->fetch_array($query))
	{
		$thing = explode("\n", $customfield['type'], "2");
		$type = trim($thing[0]);

		$field = "fid$customfield[fid]";
		$useropts = explode("\n", $userfields[$field]);
		$customfieldval = $comma = '';
		if(is_array($useropts) && ($type == "multiselect" || $type == "checkbox"))
		{
			foreach($useropts as $val)
			{
				if($val != '')
				{
					$customfieldval .= "<li style=\"margin-left: 0;\">{$val}</li>";
				}
			}
			if($customfieldval != '')
			{
				$customfieldval = "<ul style=\"margin: 0; padding-left: 15px;\">{$customfieldval}</ul>";
			}
		}
		else
		{
			if($customfield['type'] == "textarea")
			{
			 
//Back to my code for a few lines///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			 	if($customfield['name'] == "Bio" && strlen($userfields[$field]) > $shortentothislength){
					$shorten = substr($userfields[$field],0,$shortentothislength);
					$customfieldval = nl2br(htmlspecialchars_uni($shorten));
					$customfieldval = $customfieldval."(<a href=\"member.php?action=profile&uid=".$mybb->input['uid']."&showfullbio=yes\">More...</a>)";
				}else{
					$customfieldval = nl2br(htmlspecialchars_uni($userfields[$field]));
				}
//back to MyBB's code///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			}
			else
			{
				$customfieldval = htmlspecialchars_uni($userfields[$field]);
			}
		}
		eval("\$customfields .= \"".$templates->get("member_profile_customfields_field")."\";");
		$bgcolor = alt_trow();
	}
	if($customfields)
	{
		eval("\$profilefields = \"".$templates->get("member_profile_customfields")."\";");
	}
	
	//Ok, back to my code again now//////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
}
?>
Reply
#3
Not Solved
yes, surely, something like that. I have installed it on my test forum. It's working great. thanx a lot man Smile
I may be wrong, but that\'s how I learn :~)
Reply
#4
Not Solved
chiefsaab Wrote:yes, surely, something like that. I have installed it on my test forum. It's working great. thanx a lot man Smile

no problem, i'll post it up in the mybboard mods website so other people can get to it.

Update
http://mods.mybboard.net/view.php?did=677
available for all now =]
Reply
#5
Not Solved
Same here

[Image: image-2021-06-20-030756.png]

Nothing, Version MyBB 1.8.26
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)