getSectionTitle() returns null

Hi
For OJS version 3.3.0.7
I want to use getSectionTitle() function in article_summary.tpl to show the current article section Title along with each article but it does not return any value.
{$article->getSectionTitle()}

But if I use {$article->getSectionId()}, I am getting the section ID.
I found the following thread on this topic where the user has a similar issue but there is no solution.

I have also searched the database with the following query suggested by @Vitaliy

SELECT setting_value FROM section_settings WHERE section_id = '25' AND locale = 'en_US' AND setting_name = 'title'

and it returns the value. So section name is stored in the database.
I noticed that it was reported in GitHub here and is showing that the issue is successfully merged.

Does anyone have a suggestion here on how to pull the section name?
Thanks

Hi @seisense,

That method was removed. You can use the same approach as in the Old Gregg theme to retrieve it in the back-end part of the theme: oldGregg/OldGreggThemePlugin.inc.php at 05db1148519c61d8a838a934b4a74082189493c4 · Vitaliy-1/oldGregg · GitHub

1 Like

Thanks @Vitaliy,
I’ll try and see if it works…

Hi,

I am experiencing the same problem and have looked at the OldGregg code example, however I am using OJS 3.3.0.10 and this no longer appears to work.

Is there an alternative/new way of getting the section titles nowadays?

Many thanks in advance.

Anthony

Can you check where it fails, is it the method getLocalizedData('title') or section object retrival from DAO class $section = $sectionDao->getById($sectionId);?

It was failing at the $sectionDao->getById($sectionId); line because $sectionId was null.

I was able to get it to work but was not able to do so in the main theme class so couldn’t assign the values to Smarty for display in the template. In the article_card_horizontal.tpl file I used Smarty “assign” commands to grab the section titles by ID and that seems to work OK. I realise it’s probably not the recommended way of doing it but I wasn’t able to get it to work any other way.

I basically just inserted this code before the call to article_card_horizontal:

{assign var=sectionId value=$submission->getSectionId()}
{assign var=sectionDao  value=DAORegistry::getDAO("SectionDAO")}
{assign var=sectionType value=$sectionDao->getById($sectionId)}
{assign var=sectionTitle value=$sectionType->getLocalizedData('title')}
.
.
{include file="frontend/objects/article_card_horizontal.tpl" article=$submission}

Have I missed something obvious here? I feel there must be a better way to show the section title in an article!

Many thanks,

Anthony

What page are you trying to customize? Issue page or another one?

It’s just for a list of most recent articles in the home page. The section title was always blank (even in the array of articles). Prior to 3.3 this used to just work but it no longer does.

Looking at the default templates, it’s $article variable assigned to the frontend/objects/article_summary.tpl template but not $submission. See ojs/issue_toc.tpl at 4fb96c93e149b538eb92bf0224aa1c220e84d193 · pkp/ojs · GitHub and ojs/article_summary.tpl at 4fb96c93e149b538eb92bf0224aa1c220e84d193 · pkp/ojs · GitHub

Can you confirm that this is the case?

Otherwise your example looks good to me.