We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19369
    • 1,098 Posts
    Hi,

    I am trying to get the menutitle of the parent of a resource with @EVAL inside a Template Variable. My set up is as follow:

    Input Type: DropDown List Menu
    Input Option Values:
    @EVAL return $modx->getTemplateVarOutput('menutitle',$modx->runSnippet('UltimateParent', array('id' => $_GET['id'],'topLevel' => '4')));


    This does work if the resource is already created, however, if I try to create a new resource I get an error because the id of the resource hasn't been created yet:
    
    Warning: Cannot modify header information - headers already sent by (output started at /sitename/manager/includes/header.inc.php:11) in /sitename/manager/includes/document.parser.class.inc.php on line 2793
    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 »
          SQL: SELECT tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value FROM `database_name`.`modx_site_tmplvars` tv INNER JOIN `database_name`.`modx_site_tmplvar_templates` tvtpl ON tvtpl.tmplvarid = tv.id LEFT JOIN `database_name`.`modx_site_tmplvar_contentvalues` tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '' WHERE tv.name IN ('menutitle') AND tvtpl.templateid = 
    
    


    Does anyone know how to fix this?
    Thanks in advance.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Why use getTemplateVarOutput for the menutitle? That's a regular resource variable, not a template variable. I should think that a getField snippet would be more appropriate.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org