Add bio of users/authors?

Post Reply
User avatar
Renaud
Sr. Bludit
Posts: 48
Joined: Tue Feb 19, 2019 9:08 pm
Has thanked: 1 time

Hello,
How can I add a little bio for each user? :
Image
It it diffucult to code? I can try to do it muself if you just tell me where is the code.
It's to add here :
Image
Image

Thanks
User avatar
Jay
Master Bludit
Posts: 144
Joined: Mon Feb 11, 2019 8:41 pm
Has thanked: 6 times
Been thanked: 4 times

Check this thread on githbub: https://github.com/bludit/bludit/issues/963

tldr; use firstName field for a short description, and then just show field's content in theme using below snippet:

Code: Select all

<?php echo $page->user('firstName'); ?>
I don't remember if you can format text in this field using html tags, but I'd give a shot.
User avatar
Renaud
Sr. Bludit
Posts: 48
Joined: Tue Feb 19, 2019 9:08 pm
Has thanked: 1 time

Jay wrote: Wed Jun 12, 2019 4:28 pm tldr; use firstName field for a short description, and then just show field's content in theme using below snippet:

Code: Select all

<?php echo $page->user('firstName'); ?>
Nice workaround, I like it! I will try to find a nice design with it.
User avatar
Misteric
Ssr. Bludit
Posts: 18
Joined: Mon Aug 08, 2022 2:55 pm
Location: Brussels, Belgium
Has thanked: 14 times
Been thanked: 9 times

To add a bio for the users:

bl-kernel -> user.class.php

public function profilePicture() { ... }

Code: Select all

public function bio()
	{
		return $this->getValue('bio');
	}

Code: Select all

$tmp['bio'] = $this->bio();
public function json($returnsArray = false) { ... }


bl-kernel -> users.class.php

Code: Select all

protected $dbFields = array(
	'firstName'=>'',
	'lastName'=>'',
	...
	...
	...
	'bio' =>''
);

bl-kernel -> admin -> views -> edit-user.php

Code: Select all

<!-- TABS -->
<nav class="mb-3">
<div class="nav nav-tabs" id="nav-tab" role="tablist">
	<a class="nav-item nav-link active" id="nav-profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="nav-profile" aria-selected="false"><?php $L->p('Profile') ?></a>
	<a class="nav-item nav-link" id="nav-picture-tab" data-toggle="tab" href="#picture" role="tab" aria-controls="nav-picture" aria-selected="false"><?php $L->p('Profile picture') ?></a>
	...
	...
	...
	<a class="nav-item nav-link" id="nav-social-tab" data-toggle="tab" href="#bio" role="tab" aria-controls="nav-bio" aria-selected="false"><?php echo "Bio" ?></a>
</div>
</nav>

bl-kernel -> admin -> views -> edit-user.php

after the <!-- Social Networks tab --> ...

Code: Select all

<!-- Social Bio tab -->
<div class="tab-pane fade" id="bio" role="tabpanel" aria-labelledby="nav-bio-tab">
<?php
echo Bootstrap::formTextarea(array(
'name' => 'bio',
'label' => 'Bio',
'value' => $user->bio(),
'class' => '',
'placeholder' => 'Fill in some information about you',
'tip' => '',
'rows' => 10
));
?>
</div>

Echo the user bio:

Code: Select all

$allUsers = $users->keys();
foreach ($allUsers as $username) {
$user = new User($username);
if ($user->enabled()) {
echo '<p>'. $user->bio() . '</p>';
}
}
echo '</div>';
In the (bl-kernel -> admin -> views -> edit-user.php) bio-tab it just echo 'Bio'. :

Code: Select all

<?php $L->p('bio') ?>
The languages must first be updated.

Misteric
Post Reply