Skip to content

Issues-652: tweaks for a group page when it's embedded #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 57 additions & 50 deletions vanilla/applications/vanilla/controllers/class.vanillacontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,72 +102,79 @@ protected function buildBreadcrumbs($CategoryID) {
$this->fireEvent('BeforeBuildBreadcrumbs');
// getIncomingValue('embed_type') == 'mfe'
if(!$showFullBreadcrumbs) {
$temp = [];
if(val('GroupID', $Category) > 0) {
$temp = [];
$GroupCategoryID = $this->data('Breadcrumbs.Options.GroupCategoryID');
foreach ($ancestors as $id => $ancestor) {
if ($ancestor['GroupID'] > 0) {
$temp[$ancestor['CategoryID']] = $ancestor;
if($GroupCategoryID == $ancestor['CategoryID']) {// root category for a group
array_push($temp, ['Name' => $ancestor['Name'], 'Url'=>'/group/'.$ancestor['GroupID']]);
} else if($ancestor['GroupID'] > 0){
$temp[$ancestor['CategoryID']] = $ancestor;
}
}
return $temp;
}
}
if(count($temp) == 1) {
return [];
}
return $temp;
} else {

if(val('GroupID', $Category) > 0) {
$challenge = $this->data('Challenge');
$track = $challenge ? $challenge['Track']: false;
$temp = [];
$GroupCategoryID = $this->data('Breadcrumbs.Options.GroupCategoryID');
foreach ($ancestors as $id => $ancestor) {
if($ancestor['GroupID'] > 0) {
if($GroupCategoryID == $ancestor['CategoryID']) {// root category for a group
array_push($temp, ['Name' => $ancestor['Name'], 'Url'=>'/group/'.$ancestor['GroupID']]);
} else {
$temp[$ancestor['CategoryID']] = $ancestor;
}
} else {
if($ancestor['UrlCode'] == self::CHALLENGE_FORUMS_URLCODE) {
array_push($temp, ['Name' => 'Challenge Forums', 'Url'=>'/groups/mine?filter=challenge']);
}else if($ancestor['UrlCode'] == 'groups') {
array_push($temp, ['Name' => 'Group Forums', 'Url'=>'/groups/mine?filter=regular']);
if (val('GroupID', $Category) > 0) {
$challenge = $this->data('Challenge');
$track = $challenge ? $challenge['Track'] : false;
$temp = [];
$GroupCategoryID = $this->data('Breadcrumbs.Options.GroupCategoryID');
foreach ($ancestors as $id => $ancestor) {
if ($ancestor['GroupID'] > 0) {
if ($GroupCategoryID == $ancestor['CategoryID']) {// root category for a group
array_push($temp, ['Name' => $ancestor['Name'], 'Url' => '/group/' . $ancestor['GroupID']]);
} else {
$temp[$ancestor['CategoryID']] = $ancestor;
}
} else {
if($track) {
switch ($ancestor['UrlCode']) {
case 'development-forums':
case 'data-science-forums':
case 'design-forums':
array_push($temp, ['Name' => $track, 'Url'=>'/groups/mine?filter=challenge']);
break;
default:
$temp[$ancestor['CategoryID']] = $ancestor;
if ($ancestor['UrlCode'] == self::CHALLENGE_FORUMS_URLCODE) {
array_push($temp, ['Name' => 'Challenge Forums', 'Url' => '/groups/mine?filter=challenge']);
} else if ($ancestor['UrlCode'] == 'groups') {
array_push($temp, ['Name' => 'Group Forums', 'Url' => '/groups/mine?filter=regular']);
} else {
if ($track) {
switch ($ancestor['UrlCode']) {
case 'development-forums':
case 'data-science-forums':
case 'design-forums':
array_push($temp, ['Name' => $track, 'Url' => '/groups/mine?filter=challenge']);
break;
default:
$temp[$ancestor['CategoryID']] = $ancestor;
}
}
}
}
}
}
return $temp;
} else {
$urlCode = val('UrlCode', $Category);
if($urlCode == self::CHALLENGE_FORUMS_URLCODE) {
return $ancestors;
}

// Check if ancestors contains 'challenges-forums'
foreach ($ancestors as $id => $ancestor) {
if($ancestor['UrlCode'] == self::CHALLENGE_FORUMS_URLCODE) {
return $temp;
} else {
$urlCode = val('UrlCode', $Category);
if ($urlCode == self::CHALLENGE_FORUMS_URLCODE) {
return $ancestors;
}
}

// FIX https://github.com/topcoder-platform/forums/issues/487
// Go to a parent category at a home page
foreach ($ancestors as $id => $ancestor) {
if ($ancestor['ParentCategoryID'] == -1) {
$ancestors[$id]['Url'] = url('/categories/#Category_'.$parentCategoryID, true);
// Check if ancestors contains 'challenges-forums'
foreach ($ancestors as $id => $ancestor) {
if ($ancestor['UrlCode'] == self::CHALLENGE_FORUMS_URLCODE) {
return $ancestors;
}
}

// FIX https://github.com/topcoder-platform/forums/issues/487
// Go to a parent category at a home page
foreach ($ancestors as $id => $ancestor) {
if ($ancestor['ParentCategoryID'] == -1) {
$ancestors[$id]['Url'] = url('/categories/#Category_' . $parentCategoryID, true);
}
}
}

return $ancestors;
return $ancestors;
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion vanilla/js/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,13 @@ window.vanilla.embed = function(host) {
embed_type_result = '&embed_type=mfe';
}
if (typeof (vanilla_category_id) != 'undefined') {
var default_page = '/group/';
if(typeof(vanilla_embed_page) != 'undefined' && (vanilla_embed_page == 'group' || vanilla_embed_page == 'categories') ) {
default_page = '/' + vanilla_embed_page + '/';
}
result = '//'
+ host
+ '/categories/' + encodeURIComponent(vanilla_category_id) + '/?'
+ default_page + encodeURIComponent(vanilla_category_id) + '/?'
+ 'remote='
+ encodeURIComponent(embedUrl)
+ '&locale='
Expand Down