We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37126
    • 37 Posts
    Hi Been trying to figure out how to include wayfinder menu in Lime Survey. I can include chunks but the wayfinder snippet is not parsed. Been trying the following:

    require_once '/home/projects/public_html/config.core.php';
    require_once MODX_CORE_PATH.'model/modx/modx.class.php';
    $modx = new modX();
    $modx->initialize('web');
    $modx->getService('error','error.modError');
    
    $html= $modx->runSnippet('Wayfinder', array('startId' => '1', 'level'=>'0'));
    
    echo $html;
    

    But get this error:

    Fatal error: Call to a member function getOption() on a non-object

    Could anyone give me some pointers?

    Lime survey mentions enabling embedding which I have in its config file as follows:

    // Set $embedded to true and specify the header and footer functions if the survey is to be displayed embedded in a CMS
     $embedded = true;
     $embedded_inc = "http://www.example.com/index.php?id=62";               // path to the header to include if any
     $embedded_headerfunc = "";        // e.g. COM_siteHeader for geeklog
     $embedded_footerfunc = "";        // e.g. COM_siteFooter for geeklog
    


    Thanks in advance for any advice

    Running Modx Revo 2.1.3 on CPanel host

    Mat

    This question has been answered by multiple community members. See the first response.

    [ed. note: cprookie last edited this post 15 years ago.]
      • 37126
      • 37 Posts
      So for the moment, I'm just adding header and footer to Lime Survey from Modx as chunks and hard coding the menu.

      I'd love to be technically capable of embedding it into MODx but it's beyond me at the moment. Can anyone give me some links to embedding applications howtos?
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        Mark Hamstra Reply #3, 15 years ago
        That should work... is it giving any hints on where the error (file+line) is being generated?
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 37126
          • 37 Posts
          Thanks for the reply.

          Whenever I try to include snippets within Lime Survey I get:

          Fatal error: Call to a member function getOption() on a non-object

          which I think is something to do with having trouble finding the wayfinder id which I try to define in the replacements.php file for Lime Survey

          and when I try to embed Lime Survey on a modx page I get:

          Fatal error: Call to a member function MetaTables() on a non-object in /home/a/public_html/surveys/common_functions.php on line 5976
          • discuss.answer
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            And there's no line number or filename in which it's triggering the getOption error? Kind of hard to debug without that.

            Also check the MODX Error Log, depending on where the error occurs it may have been sent there.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 37126
              • 37 Posts
              So in the Lime Survey file named 'replacements.php', I've added the following:

              global $modx;
              require_once '/home/projects/public_html/config.core.php';
              require_once MODX_CORE_PATH.'model/modx/modx.class.php';
              $modx = new modX();
              $modx->initialize('web');
              $modx->getService('error','error.modError');
              
              $html = $modx->getChunk('header');
              
              $html .= $modx->runSnippet('Wayfinder', array('id' => $modx->resource->get('id'), 'startId'=>'1', "level"=>'0'));
              
              $psnavigation = $html;
              
              $coreReplacements['PSNAVIGATION'] = $psnavigation;




              Which returns the error:

              Fatal error: Call to a member function get() on a non-object in /home/projects/public_html/surveys/replacements.php on line 48


              which refers to this line:
              $html .= $modx->runSnippet('Wayfinder', array('id' => $modx->resource->get('id'), 'startId'=>1, "level"=>0));
              


              Can't see anything in the error log.
                • 18373 ☆ A M B ☆
                • 3,141 Posts
                Ah that explains it. You're using $modx->resource->get(), but you're not in a resource-related context so it doesn't have a resource there.

                Try hardcoding a resource ID or finding another way to retrieve it, for example from a system setting with $modx->getOption('keyname');
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 37126
                  • 37 Posts
                  Not sure what I'm doing wrong, I now get the following error:

                  Fatal error: Call to a member function get() on a non-object in /home/projects/public_html/core/components/wayfinder/wayfinder.class.php on line 40


                  Where I've hardcoded the following:
                  $html .= $modx->runSnippet('Wayfinder', array('id' => $modx->getOption('site_start'), 'startId'=>'1', "level"=>'1'));
                  
                  • discuss.answer
                    • 18373 ☆ A M B ☆
                    • 3,141 Posts
                    Hmm.. Wayfinder has $modx->resource hardcoded on that line (and others). So it really needs the resource context.

                    What if you do something like this before calling runSnippet? Essentially tricking Wayfinder into thinking we've got a resource loaded.

                    $modx->resource = $modx->getObject('modResource',$modx->getOption('site_start'));
                      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                    • discuss.answer
                      • 37126
                      • 37 Posts
                      Thanks that seems to have progressed it a little, I'm now getting the error:

                      Fatal error: Call to a member function get() on a non-object in /home/projects/public_html/core/components/wayfinder/wayfinder.class.php on line 160


                      and that line is:

                      $cacheKey = 'wf-'.$this->modx->user->get('id').'-'.base64_encode(serialize($this->_config));
                      


                      Not sure what to do with the $this variable. Tried adding:

                      $userID =  $modx->getLoginUserID();
                      $cacheKey = $userID;
                      


                      But get the same error