trema-tech / moodle-theme_trema

Theme trema, a Moodle LMS plugin.
https://moodle.org/plugins/theme_trema
GNU General Public License v3.0
39 stars 19 forks source link

Undefined property: stdClass::$frontpagecardstitle and $frontpagecardssubtitle on front page #79

Closed michael-milette closed 2 years ago

michael-milette commented 3 years ago

Hi @rmady

When I got to the Frontpage, I get the following errors:

Notice: Undefined property: stdClass::$frontpagecardstitle in theme/trema/layout/frontpage.php on line 107 Notice: Undefined property: stdClass::$frontpagecardssubtitle in theme/trema/layout/frontpage.php on line 108

I am not sure how this happened however, I suspect that I chose to disable front page cards (frontpageenablecards setting) during installation of the theme. As a result, there are several settings whose which are not set set in content_settings.php including the two mentioned above. Here is the relevant code:

if (get_config('theme_trema', 'frontpageenablecards')) {
    // Title.
    $name = 'theme_trema/frontpagecardstitle';
    $title = get_string('title', 'theme_trema');
    $description = '';
    $page->add(new admin_setting_configtext($name, $title, $description, 'MAGNA ETIAM ADIPISCING'));

    // Subtitle.
    $name = 'theme_trema/frontpagecardssubtitle';
    $title = get_string('subtitle', 'theme_trema');
    $description = '';
    $page->add(
        new admin_setting_configtext($name, $title, $description,
            'Consequat sed ultricies rutrum. Sed adipiscing eu amet utem blandit vis ac commodo aliquet vulputate.'));

As a result, when the layout/frontpage.php tries to access these settings in order to display the home page, they don't exist and the above-mentionned notices occur.

'cardstitle' => format_text($pluginsettings->frontpagecardstitle, FORMAT_HTML),
'cardssubtitle' => format_text($pluginsettings->frontpagecardssubtitle, FORMAT_HTML),

The workaround is to enable the cards, save and then go disable the cards. However, this should not be necessary if you simply don't want the cards in the first place.

Let me know if you have any questions.

Best regards,

Michael Milette

rmady commented 2 years ago

Hello awesome @michael-milette,

I tested it and looks like everything is ok. I really want to make the cards generation better in settings but got no success. Today the generation of fields are made after we change the number of cards ans reload the settings page, I want to make that in real time, so as soon as we change the value of cards. Have you ever saw some settings doing things like this?

Kind regards, Rodrigo Mady

michael-milette commented 2 years ago

I haven't seen this level of dynamic display before in Moodle. I think it would be a first for a Moodle theme. However, what would the impact be for a site with 10,000 concurrent active users?