Url alias for groups to display url with group name instead of numbers such as group/1 group/2 ...

Michael Bayrakeri Posted in Technical Support 6 years ago

Current default group url is: /group/1 or group/2 ... which is not SEO friendly. Is there any
configuration to display groups with names instead of number ? Such as group/cats group/dogs ...

Thank you

Replies
us Mick Dawlings Replied 1 year ago

I asked about this here also;
https://www.opensource-socialnetwork.org/discussion/view/6739/pretty-group-and-page-urls

I cannot delete the post however.

Anyhow, I'm looking for the same and have premium already. I'm not a developer, just a designer and need to set everything up before finding an ongoing developer. I'm looking to do these things without having to edit page code so that updates/upgrades never break.

Is there a solution for Pages and Groups to have pretty URL's?

us Michael Bayrakeri Replied 6 years ago

Hi @Z - Man,

SEO friendly, I meant, search engines index url names and give credit to "text" in url. Group names would be better hit than group numbers. I will open up groups to public. If you log out, you should still be able to see the group content, which is what I wanted.

Hi @Arsalan,

Thanks for you reply. This evening, I will order the Premium version and then try your solution for url aliases.

Great work, thank you

Michael

German Michael Zülsdorff Replied 6 years ago

Michael,
could you explain in a more detailed way what you're trying to achieve?
SEO friendly ... what do mean with SEO friendly ?

If it comes to indexing we should have in mind that - as long as you're not using a special theme with those group titles explicitely listed on the front page - no crawling bot would find them because they are visible to logged in members only. Hence, the suggested changes to the left hand menu won't really help here.

A solution may be to create a sitemap file from within Google's webmaster console and provide the group titles there. In that case it would need just a simple redirection rule in your .htaccess file like

RewriteRule ^group/Ongolito\sVille /group/198 [R=301,L]

This way you may enter my group "Ongolito Ville" like

https://newblue.ongolito.net/group/Ongolito%20Ville
now, and the crawling bot will be redirected accordingly, too.


Please note that the %20 is in fact just a space, but this editor is not capable handling links like that

Indonesian Arsalan Shah Replied 6 years ago

If you see https://github.com/opensource-socialnetwork/opensource-socialnetwork/blob/v5.x/components/OssnGroups/ossn_com.php#L228-L257

It seems the group-name appeared to be subpage , ossn groups seems thinking its a subpage

https://github.com/opensource-socialnetwork/opensource-socialnetwork/blob/v5.x/components/OssnGroups/ossn_com.php#L239-L241

You should try :

if(!ossn_is_group_subapge($params['subpage']) && !empty($params['subpage'])) {
            $params['subpage'] = '';
}

But again this will endup to some broken pages because in some files its defined group-name is actually group subpage name.


Suggestion
What i suggest is instead of changing the function, only append the group name in group listing only.
Change the URL for groups in the user sidebar menu : OssnGroups/ossn_com.php [line 75]

Change to :

'url' => ossn_group_url($group->guid) . OssnTranslit::urlize($group->title);,

You will also need to change group search page to add group name in the list

OssnGroups\plugins\default\groups\search.php line [23]

 <a class="group-name" href="<?php echo ossn_site_url(); ?>group/<?php echo $group->guid; ?>/<?php echo OssnTranslit::urlize($group->title); ?>"><?php echo $group->title; ?></a>

So if you follow the suggestion you have to revert changes back, further i suggest you to rollup new component by forking the groups (don't modify core files)

us Michael Bayrakeri Replied 6 years ago

Hi Arsalan,

I have tried above solution, group url is appended with "group name" correctly, however, as other user mentioned, I also get "empty page" under that group. Can you please check to see if you have a way to correct this issue ?

Thanks

Michael

us Michael Bayrakeri Replied 6 years ago

Hi Arsalan,

Thanks for your answer.

I will start developing my community idea using the free version. And, upgrade to premium
in the future. Would the premium upgrade delete the postings/content already created in
free version ?

Thanks

Michael

us Randy Jung Replied 6 years ago

This what groups.php looks like...but fails

<?php
/**
 * Open Source Social Network
 *
 * @package Open Source Social Network
 * @author    Open Social Website Core Team <[email protected]>
 * @copyright 2014-2017 SOFTLAB24 LIMITED
 * @license   Open Source Social Network License (OSSN LICENSE)  http://www.opensource-socialnetwork.org/licence
 * @link      https://www.opensource-socialnetwork.org/
 */

/**
 * Get group by guid
 *
 * @param int $guid Group guid
 * @return object
 */
function ossn_get_group_by_guid($guid) {
    $group = new OssnGroup;
    return $group->getGroup($guid);
}
/**
 * Get group layout
 *
 * @param html $contents Content of page (html, php)
 * @return mixed data
 */
function ossn_group_layout($contents) {
    $content['content'] = $contents;
    return ossn_plugin_view('groups/page/group', $content);
}
/**
 * Get user groups (owned/member of)
 *
 * @param object $user User entity
 * @return object
 */
function ossn_get_user_groups($user) {
    if ($user) {
        $groups = new OssnGroup;
        //get user owned/member of groups #155
        return $groups->getMyGroups($user);
    }
}
/**
 * Group subpage set
 *
 * @param string $page Page name
 * @return void
 */
function ossn_group_subpage($page) {
    global $VIEW;
    $VIEW->pagePush[] = $page;
}
/**
 * Check if page is instace of group subpage
 *
 * @param string $page Page name
 * @return bool
 */
function ossn_is_group_subapge($page) {
    global $VIEW;
    if (in_array($page, $VIEW->pagePush)) {
        return true;
    }
    return false;
}
/**
 * Get group url
 *
 * @param object $group Group entity
 * @return string
 */
function ossn_group_url($group) {
    $group_meta = ossn_get_group_by_guid($group);
    $title =  OssnTranslit::urlize($group_meta->title);
    return ossn_site_url("group/{$group}/{$title}");
}
us Randy Jung Replied 6 years ago

Well lets see I tried that but when you go to the list in left hand side, where it has the lists of groups and try to go to group i get a blank white page. Ii I go to left side and go to bottom where it says groups in the menu. It will take me to groups, there i can get to group. Something not right?

Indonesian Arsalan Shah Replied 6 years ago

Yes you can achieve this by editing the group_url function

https://github.com/opensource-socialnetwork/opensource-socialnetwork/blob/v5.x/components/OssnGroups/libraries/groups.php

function ossn_group_url($group) {
    $group_meta = ossn_get_group_by_guid($group);
    $title =  OssnTranslit::urlize($group_meta->title);
    return ossn_site_url("group/{$group}/{$title}");
}