diff --git a/src/addon/block/sitemainmenu/components/sitemainmenu/sitemainmenu.ts b/src/addon/block/sitemainmenu/components/sitemainmenu/sitemainmenu.ts index 02c044771..0f3355219 100644 --- a/src/addon/block/sitemainmenu/components/sitemainmenu/sitemainmenu.ts +++ b/src/addon/block/sitemainmenu/components/sitemainmenu/sitemainmenu.ts @@ -75,7 +75,7 @@ export class AddonBlockSiteMainMenuComponent extends CoreBlockBaseComponent impl */ protected fetchContent(): Promise { return this.courseProvider.getSections(this.siteHomeId, false, true).then((sections) => { - this.block = sections[0]; + this.block = sections.find((section) => section.section == 0); if (this.block) { this.block.hasContent = this.courseHelper.sectionHasContent(this.block); diff --git a/src/core/sitehome/components/index/index.ts b/src/core/sitehome/components/index/index.ts index 354881d3b..c21f2b1d9 100644 --- a/src/core/sitehome/components/index/index.ts +++ b/src/core/sitehome/components/index/index.ts @@ -137,7 +137,7 @@ export class CoreSiteHomeIndexComponent implements OnInit { return this.courseProvider.getSections(this.siteHomeId, false, true).then((sections) => { // Check "Include a topic section" setting from numsections. - this.section = config.numsections ? sections[1] : false; + this.section = config.numsections ? sections.find((section) => section.section == 1) : false; if (this.section) { this.section.hasContent = this.courseHelper.sectionHasContent(this.section); this.hasContent = this.courseHelper.addHandlerDataForModules([this.section], this.siteHomeId) || this.hasContent; @@ -164,7 +164,8 @@ export class CoreSiteHomeIndexComponent implements OnInit { this.blocks = []; // Cannot get the blocks, just show site main menu if needed. - if (sections[0] && this.courseHelper.sectionHasContent(sections[0])) { + const section = sections.find((section) => section.section == 0); + if (section && this.courseHelper.sectionHasContent(section)) { this.blocks.push({ name: 'site_main_menu' });