Michael Zülsdorff
2 years ago
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][ATTACHMENT:7008]
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!
[ATTACHMENT:7008]: https://www.opensource-socialnetwork.org/photoattachment/7008/18m-1-1.jpg
Michael Zülsdorff
Replied 1 year ago
Release 1.1
finalized, ready to use
logs disabled
displaying true age and gender now + green border with online members

Arsalan Shah
Replied 2 years ago
@Domnik no interests here?
Michael Zülsdorff
Replied 2 years 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.
Michael Zülsdorff
Replied 2 years 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:

Dominik L
Replied 2 years 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
Michael Zülsdorff
Replied 2 years 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 ...
Dominik L
Replied 2 years 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';
?>
Dominik L
Replied 2 years ago
I installed the component but nothing happens:

It should be right beside the username, right?
Dominik L
Replied 2 years ago
Sorry I am on vacation, I test the component in a few minutes
Arsalan Shah
Replied 2 years 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.