Eighteen Male Download 1.0dev4

German Michael Zülsdorff 4 weeks ago

Eighteen Male

Sound crazy? Yes, actually this is just a showcase for aspiring Ossn developers of how to extend the profile page to display a member's age and gender in response to Dominik's post https://www.opensource-socialnetwork.org/discussion/view/6431/can-someone-help-me-edit-the-profile-and-search-of-ossn

Okay, so: Where is the code we need to alter? The way to find it is thoroughly documented in https://www.opensource-socialnetwork.org/wiki/view/1137/how-to-find-something-a-word-pattern-in-the-source-code

This time we do a right-click->inspect on the profile page just below the member name and get something like


enter image description here


And since Dominik wants to add (18) after the class 'user-fullname' it makes sense to use this pattern for searching. On a Linux command-line you would execute a

grep -Rn 'class="user-fullname"' .

which gives

./components/OssnProfile/plugins/default/profile/pages/profile.php:77

That is: We need to edit line #77 of profile.php?

NO - remember: https://www.opensource-socialnetwork.org/wiki/view/704/should-i-modify-core-files
In fact, we can leave profile.php completely untouched and add our extras by means of the Ossn function

ossn_extend_view('file_to_extend', 'by_file_with_extensions');

And right that's where 1.0dev1 of this component starts ...

Have fun!

Comments
Indonesian Arsalan Shah Replied 2 weeks ago

@Domnik no interests here?

German Michael Zülsdorff Replied 3 weeks ago

Okay, now that the code of the profile page comes structured like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profile.php
display cover
display member name
display menu
display bottom part

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
ExtendProfile.php
display age and gender
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and our code obviously gets executed at the end - and not at the intended position - we need to find a workaround. And dev4 is implementing right that: Same code structure, but instead of using PHP to add the age and gender, javascript is used for inserting these extras.

German Michael Zülsdorff Replied 3 weeks ago

Fine!
That is: Extending the code of the default profile page like

ossn_extend_view('profile/pages/profile', 'EighteenMale/ExtendProfile');

is basically working. We successfully managed to execute some additional code whenever visiting a profile page - WITHOUT editing the code of profile.php. And if we have a little closer look, we notice that our echo '(18) MALE'; indeed results in getting that additional line at the bottom of every profile page now:


enter image description here

German Dominik L Replied 3 weeks ago

ErrorLog shows

[29-Mar-2024 10:55:50 UTC] He, we are inside of ExtendProfile.php
[29-Mar-2024 10:55:58 UTC] He, we are inside of ExtendProfile.php

German Michael Zülsdorff Replied 3 weeks ago

I installed the component but nothing happens:

Oh yes: a very typical feedback a developer often gets confronted with.

Fortunately, there's a lot of debugging capabilities to investigate what's going wrong.
And release dev3 is making use of it.

So please enable Ossn's Error reporting via Site Settings -> Basic -> Error Reporting -> On
from your administrator page.

Then visit a profile page and check your error_log file.

I'm sure you'll get some results ...

German Dominik L Replied 3 weeks ago

But one question:

I don't want "18" beside the name, I want the real user age and Gender from profile 😅

In component is a file "ExtendProfile" with

<?php
echo '(18) MALE';
?>
German Dominik L Replied 3 weeks ago

I installed the component but nothing happens:

enter image description here

It should be right beside the username, right?

German Dominik L Replied 3 weeks ago

Sorry I am on vacation, I test the component in a few minutes

Indonesian Arsalan Shah Replied 3 weeks ago

Dear @Dominik, did you setup test environment? you asked for this many times and now when someone wants to create it, there seems delay from your side.

German Michael Zülsdorff Replied 4 weeks ago

Hmm yes, not really comfortable admittedly...
That's why release 1.0dev2 is making us of

if (ossn_isAdminLoggedin()) {
        ossn_register_callback('ossn', 'init', 'eighteenmale_init');
}

This way the component only gets initialized if the administrator is logged in and we can prevent regular members from getting strange results while the component is still ongoing development.

Component

Developer: Michael
License ossnv4
Type: Tools
Requires Ossn Version : 7.2
Latest Version: 1.0dev4
Last Updated 3 weeks ago
Repository Url View Repository

Versions