Forums | Mahara Community
    
        
            Developers
         /
    
    
    submenu_items()
16 March 2017, 8:56
Hello everyone
I'm doing a mahara plugin that adds an item to the main menu.
I need that page to have a submenu with two elements (personal and professional) and to do so modify the submenu_items () function of artefact \ deduko \ lib.php as follows:
public static function submenu_items() {
        $tabs = array(
            'subnav' => array(
                'class' => 'deduko'
            ),
            'personal' => array(
                'page'  => 'personal',
                'url'   => 'artefact/deduko/personal.php',
                'title' => get_string('personal', 'artefact.deduko'),
            ),
            'profesional' => array(
                'page'  => 'profesional',
                'url'   => 'artefact/deduko/profesional.php',
                'title' => get_string('profesional', 'artefact.deduko'),
            ),
        );
        if (!get_config('licensemetadata')) {
            unset($tabs['license']);
        }
        if (defined('DEDUKO_SUBPAGE') && isset($tabs[DEDUKO_SUBPAGE])) {
            $tabs[DEDUKO_SUBPAGE]['selected'] = true;
        }
        return $tabs;
    }
Then in the pages artefact \ deduko \ personal.php and artefact \ deduko \ professional.php create a forms and I showed them as follows:
$Smarty-> assign ('personalform', $personalform);
$smarty->assign('SUBPAGENAV', PluginArtefactDeduko::submenu_items());
$Smarty-> display ('artefact:deduko:personal.tpl');
Fatal error: Call to a member function assign() on a non-object in htdocs\artefact\deduko\personal.php on line xx
If anyone knows that could be causing this error please help me.
Thanks in advance.
16 March 2017, 9:07
Hopefully you have initialized smarty first, like:
$smarty = smarty();
$smarty->assign('personalform', $personalform);
$smarty->assign('SUBPAGENAV', PluginArtefactDeduko::submenu_items());
$smarty->display('artefact:deduko:personal.tpl');
Further I think $smarty should be lowercase and there should not be any spaces before and after arrows (->),
like $smarty->assign etc.
HTH, Gregor
16 March 2017, 13:40
Thank you very much
The mistake was a simple change of upper and lower case