XF 2.1 Rendering account_visitor_menu via templater throws error

Hi there,

here's my code, just want to display the visitor's menu somewhere else (external app):

PHP:
    // fileDir is correct, don't get confused
    $fileDir = "../";
    require $fileDir . '/src/XF.php';
    XF::start($fileDir);
    $app = XF::setupApp('XF\Pub\App');
    $app->start();
    $templater = $app->templater();
    $viewParams = [];
    $output = $templater->renderTemplate('public:account_visitor_menu', $viewParams);
    \XF::dump($output);
    
    /* This also won't work
        $widgetRenderer = $templater->renderWidget('widget_visitor_panel', []);
        \XF::dump($widgetRenderer->render());
    */

Error is always

An exception occurred: [Error] Call to a member function getProperty() on null in src/XF/Template/Templater.php on line 2010
  1. XF\Template\Templater->getFallbackAvatarHtml() in src/XF/Template/Templater.php at line 1903
  2. XF\Template\Templater->getDynamicAvatarHtml() in src/XF/Template/Templater.php at line 1854
  3. XF\Template\Templater->fnAvatar()
  4. call_user_func_array() in src/XF/Template/Templater.php at line 941
  5. XF\Template\Templater->func() in internal_data/code_cache/templates/l2/s0/public/account_visitor_menu.php at line 12
  6. XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 706
  7. XF\Template\Templater->callMacro() in internal_data/code_cache/templates/l2/s0/public/account_visitor_menu.php at line 178
  8. XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 1320
  9. XF\Template\Templater->renderTemplate() in /path/to/my.php at line 37
  10. myfunc() in /path/to/my.php at line 142

What am I doing wrong...?
 
Back
Top Bottom