How to replace icons?

Dominik L Posted in Component Development 11 months ago

hello!

How can I replace the icons marked on the screenshot with my own symbols like "fa-home" or stuff from Font Awesome?

enter image description here

I tried following:

    ossn_register_menu_item('newsfeed', array(
        'name' => 'friends',
        'text' => ossn_print('friends'),
        'parent' => 'profile',
    'icon'   => 'fa-solid fa-user',
        'href' => $user->profileURL('/friends'),
    ));

thank you

Replies
German Michael Zülsdorff Replied 11 months ago

Your com file is missing a unique section name, add something like

        ossn_register_sections_menu('newsfeed', array(
            'name' => 'profile',
            'text' => ossn_print('meinprofil'),
            'href' => $user->profileURL(''),
            'section' => 'dominik',
        ));

And in newfeed.php change the code to if($name == 'dominik'){

German Dominik L Replied 11 months ago

Thanks so far, I copied the newsfeed.php to components/SidebarRearrange/plugins/default/menus/sections and just added

	if($name == 'profile'){
	$expend = 'show';
	$icon = "fa-user";

}

to the existing stuff

after refreshing my site, the menu is still collapsed

Do I have to add something like "ossn_extend_view" to my ossn_com.php?

here is a snippet of the top of my ossn_com.php

<?php
/**
 * Open Source Social Network
 *
 * @package   Dominik Lieger
 * @author    Dominik Lieger
 * @license   GPL v2 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @link      https://www.example.com
 */


function sidebar() {	
    ossn_extend_view('css/ossn.default', 'css/sidebar');
	
    $user = ossn_loggedin_user();
    
    if ($user) {
        ossn_register_menu_item('newsfeed', array(
            'name' => 'home',
            'text' => ossn_print('home'),
            'href' => ossn_site_url(),
            'parent' => 'profile',
            'priority' => 0,
        ));
		
        ossn_register_sections_menu('newsfeed', array(
            'name' => 'profile',
            'text' => ossn_print('meinprofil'),
            'href' => $user->profileURL(''),
			
        ));
		
        ossn_register_menu_item('newsfeed', array(
            'name' => 'friends',
            'text' => ossn_print('friends'),
            'parent' => 'profile',
            'href' => $user->profileURL('/friends'),
        ));
German Michael Zülsdorff Replied 11 months ago

Oh yes ... From what I know, there's no easy way to pass a 'expand/not expand' parameter to any of those ossn_register_menu.... functions.
The only workaround I see (in order not to collide with future core updates:
copy YourThemeInUse/plugins/default/menus/sections/newsfeed.php
to one of YourOwnCustomComponentsInUse/plugins/default/menus/sections/newsfeed.php

Edit that copied newsfeed.php and to get an idea as a first exercise:
replace $expend = ''; by $expend = 'show';
Refresh your page and you'll notice that all of the main menus appear expanded/uncollapsed now

Okay, but that's not what you wanted, so restore it back to $expend = '';
And in order to expand your own menu only, use the same code as already used for the menus named 'links' and 'groups'
and add it below like:

	if($name == 'YOUR OWN MENU NAME'){
	$expend = 'show';
	$icon = "fa-YOUR OWN FAVORITE ICON";
}

For a more in-depth understanding of Ossn's plugin mechanism take the time and follow https://www.opensource-socialnetwork.org/component/view/6044/goblue-registration-page?offset=3 step by step

German Dominik L Replied 11 months ago

The only thing I couldn't figure out is how to automatically expand the "profil" menu.

I could modify the "newsfeed.php" in goblue/plugins/default/menus/sections but I don't want to do that,

And I also don't want to use JS, to reduce the client side load

German Dominik L Replied 11 months ago

Guess i figured it out somehow

German Dominik L Replied 11 months ago

Sorry, it is really hard for me to understand the component, because I am doing everything with chatGPT, I can't really code, therefore I need simple instructions.

I tried to find a programmer many times, but couldn't find anyone to help me with OSSN

German Michael Zülsdorff Replied 11 months ago

Crazy: Just one day ago, I recommended to study the system-info component here, which indeed implements its own menu icons...!?!

German Dominik L Replied 11 months ago

what do you mean?

It doesn't matter which icon I try, the system always display this right angle and not my icon I want

Even if I try fa-solid fa-home

us Anna Ayva Replied 11 months ago

Hi Dominik.
You need to change 'fa-solid fa-user', to any other fa fa icon

Premium Version

Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.

$199 (Life Time)
Learn More

Other Questions