Short Bio Download 2.1

German Michael Zülsdorff 1 month ago

Short Bio

step-by-step developing a component to display a short bio on every member's profile page as suggested by Dominik here:
i-need-help-with-implementing-a-feature

Step 1 (v1.0dev1) provides just a basic skeleton to get that bio box in place - no bio data yet

Step 2 (v1.0dev2) comes included with an almost complete shortbio-box.php plus shortbio.input.php allowing to enter some bio text. The necessary CSS to style the box has been added as default-css.php

Step 3 (v1.0dev3) comes included with the necessary action to save and update short bios

Step 4 (v2.0) shows an alternate way of entering the short bio text: the input form is part of the account-settings page now and has been removed from the timeline. This version is stripped from any custom CSS and this way working flawlessly with all currently available themes (White theme's darkmode included). And If you get bored by viewing your own short bio again and again you may uncheck the checkbox below the input. This way it gets hidden from your own view but remains visible to other members.

v2.1 added 'Edit' -pencil as suggested by Dominik (see comment below)


figure 1 showing the shortbio editor on the account-settings page (release 2.x)
enter image description here


figure 2 showing the visitors view of that shortbio (release 2.x)
enter image description here


figure 3 showing the view of my own shortbio-box (release 1.x)
enter image description here


figure 4 same bio viewed by a different member (release 1.x)
enter image description here

Comments
German Michael Zülsdorff Replied 2 weeks ago

Thanks Dominik!
Your suggestion comes implemented with release 2.1 - the displaying logic a little changed, though.

Rule of thumb: Whenever it seems necessary to code the same condition again a few lines later - have a break and check your construct again. Most of the times it can be optimized some way. ;)

German Dominik L Replied 2 weeks ago

Thanks for providing the newest version

I added

    ossn_extend_view('css/ossn.default', 'css/shortbio');   

to function com_shortbio_init() {

and changed ShortBio/plugins/default/ShortBio/shortbio-box.php to

<?php
// check if there's a shortbio at all?
if (isset($params['user']->ShortBio) && !empty($params['user']->ShortBio)) {
    // yes!
    if ((ossn_loggedin_user() && ossn_loggedin_user()->guid == $params['user']->guid && $params['user']->ShortBioViewOwn != 'checked')) {
        // if it is our own short bio, but ViewOwn is unchecked
        // then do nothing
        ;
    } else {
        // in any other case display the shortbio
        ?>
        <div class="ossn-wall-container">
            <div class="tabs-input">
                <div class="wall-tabs">
                    <li class="item">
                        <i class="fa fa-info-circle"><span><?php echo ossn_print('com:shortbio:label'); ?></span></i>
                        <?php
                        // Add edit icon if the logged-in user is viewing their own profile
                        if (ossn_loggedin_user() && ossn_loggedin_user()->guid == $params['user']->guid) {
                            // Generate the correct URL
                            $edit_url = ossn_site_url("u/{$params['user']->username}/edit?section=com_shortbio");
                            ?>
                            <a href="<?php echo $edit_url; ?>" class="shortbio-edit-icon">
                                <i class="fa fa-pencil-alt" title="<?php echo ossn_print('edit'); ?>"></i>
                            </a>
                            <?php
                        }
                        ?>
                    </li>
                </div>
            </div>
            <div class="ossn-wall-container-data">
                <?php 
                // using nl2br() for output here
                // because saved textarea newlines need to be converted to html <br>
                echo nl2br($params['user']->ShortBio); ?>
            </div>
        </div>
    <?php
    }
}
?>

Now you have a pencil directly on profil page which leads to edit page:

enter image description here

German Michael Zülsdorff Replied 4 weeks ago

Correct.
And yes, I intentionally used the PHP error_log function to get an idea of what comes included with a member's record. And if we open our Ossn database with PHPMyAdmin and compare this logged member's record to the ossn_users table we notice that it includes a lot more elements than the table can store!

Then, where else are these extra elements get stored instead? The answer will be found in the beginning of classes/OssnUser : It's an extension of classes/OssnEntities. So if we have a look into the ossn_entities table we can in fact find all these extra member attributes like birthdate, gender, stored here.

Just the extra attribut ShortBio seems to be missing in your ossn_entities table. Thus your next task will be:

Locate the file and line-number where ShortBio gets saved.

German Dominik L Replied 4 weeks ago

errorlog('shortbio-input $params ' . ossndump($params));

in file

ShortBio/plugins/default/forms/ShortBio/shortbio-input.php

German Michael Zülsdorff Replied 4 weeks ago

Really?
Then, can you try to locate the file name and line number of the logging code and provide it please?

German Dominik L Replied 4 weeks ago

hello, I tested newest release on a complete clean install with paid OSSN but bio is not saved, instead the whole user informations are stored in logfile

[09-Dec-2024 21:15:46 UTC] shortbio-input $params <pre>Array (
[user] => OssnUser Object
(
[guid] => 1
[type] => admin
[username] => MrCrossii
[email] => XXX
[password] => XXX
[salt] => XXX
[firstname] => Dom
[last
name] => Lieger
[lastlogin] => 1733778734
[last
activity] => 1733778946
[activation] =>
[timecreated] => 1724939451
[fullname] => Dom Lieger
[birthdate] => 04/01/1985
[gender] => male
[password
algorithm] => bcrypt
[cover_time] => 1724939545
[language] => en
[data] => stdClass Object
(
)

        [cover_guid] => 0
        [iconURLS] => stdClass Object
            (
                [topbar] => https://XXX.de/clean/avatar/MrCrossii/topbar/eb5e6c9b5ca00aa3161aae39605d8378.jpeg?ossn_cache=13b35b4e
                [small] => https://XXX.de/clean/avatar/MrCrossii/small/d9263a91f1afd55f9d4854055df01885.jpeg?ossn_cache=13b35b4e
                [smaller] => https://XXX.de/clean/avatar/MrCrossii/smaller/9fdfcf68b128d6cb4b8ca260111b383d.jpeg?ossn_cache=13b35b4e
                [large] => https://XXX.de/clean/avatar/MrCrossii/large/6e149ee5056fa24f68239f161db5db58.jpeg?ossn_cache=13b35b4e
                [larger] => https://XXX.de/clean/avatar/MrCrossii/larger/1b2b8692065bc7f2bbc407e7fd1c3613.jpeg?ossn_cache=13b35b4e
            )

        [icon_guid] => 
        [icon_time] => 
        [database] => PDO Object
            (
            )

        [exe] => PDOStatement Object
            (
                [queryString] => SELECT DISTINCT  u.guid, u.* FROM ossn_users as u JOIN ossn_relationships AS r1 ON r1.relation_to =

u.guid AND r1.type = "friend:request" JOIN ossnrelationships AS r2 ON
r2.relation
from = r1.relationto AND r2.type = "friend:request"
WHERE(u.time
created IS NOT NULL AND (r1.relationfrom = '1' AND
r2.relation
to = '1')) ORDER by u.guid ASC LIMIT 9;
)

    )

) </pre>

Component

Developer: Michael
License GPL v2
Type: Uncategorized
Requires Ossn Version : 7.2
Latest Version: 2.1
Last Updated 2 weeks ago
Repository Url View Repository

Versions