We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6910
    • 1 Posts
    Have a pre-existing blog done in wordpress, not integrating modx for the main site (but keeping the blog in wordpress).

    For the template i’m trying to include 2 chunks frommodx (a masthead with a simple search form [simlpleSearchForm] snippet call and the sites main navigation [wayfinder] ) the modx navigation within wordpress.

    Now with the following code i can get a shunk with a snippet within it, but it hasn’t processed the snippet just displays the raw text snippet call to the search form.

    [[!SimpleSearchForm? &tpl=myISearchForm` &method=`POST` &landing=`106`]]


    The same happens when i call the navigation chunk with the wayfinder snippet call within

    //MODx API
    define('MODX_CORE_PATH', '../core/');
    define('MODX_CONFIG_KEY', 'config');
    define('MODX_API_MODE', true);
    define(’MODX_SITE_URL’, (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'off' ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].MODX_SITE_BASE_URL);
    require_once '../config.core.php';
    require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
    require_once MODX_CORE_PATH.'model/modx/modx.class.php';
    $modx = new modX();
    $modx->initialize('web');
    
    // Set the base URL for any MODx snippets
    $modx->config['base_url'] = MODX_SITE_BASE_URL;
    
    $test = $modx->getObject('modChunk',array('name' => 'header_masthead' ));
    if ($test) {
      $content = $test->getContent();
    }
    var_dump($content);
    



    is it possible to call a chunk externally and have it display as it would within modx? or am i tring to do some thing that isn’t possible
      • 3749
      • 24,544 Posts
      Try using $modx->getChunk(’header_masthead’).
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 6910
        • 1 Posts
        yeah i’ve tried that, the problem being there is also a call to a snippet in the chunk, and it just pulls this out as text rather than rendering it as the relevant html

        [[!SimpleSearchForm? &tpl=`SearchForm` &method=`POST` &landing=`106`]]
          • 6910
          • 1 Posts
          Effectively what i’m trying to do is get the process output of an object (http://bobsguides.com/revolution-objects.html)

          Now my chunks done’t have any placeholder to be replaced. but both of them have a snippet call... one to wayfinder, the other to the simple search form. Both use their own templates.

          Now when i call getChunk, it’s not processing the snippet, just pulling it out as the raw text call..

          <div class="searchform">
          [[!SimpleSearchForm? &tpl=myISearchForm` &method=`POST` &landing=`106`]]
          </div>
          



          do is it possible to process a chunk that contains calls to snippets.?
            • 33968
            • 863 Posts
            In that case you might need to run the SimpleSearch snippet from within your current snippet, like this:
            $searchForm = $modx->runSnippet('SimpleSearchForm',array(
               'tpl' => 'mySearchForm'
               'method' => 'POST'
               'landing' => '106'
            ));
            

            See http://rtfm.modx.com/display/revolution20/modX.runSnippet

            If you wanted you could still use getChunk to pull in your header_masthead chunk, and set a placeholder to receive your search form:
            $modx->setPlaceholder('searchForm', $searchForm);
            
              • 6910
              • 1 Posts
              getting a fatal error when i call runSnippet...

              Fatal error: Call to a member function getOption() on a non-object in /var/www/vhosts/<my_domain>/httpdocs/core/cache/includes/elements/modsnippet/34.include.cache.php on line 37


              $searchForm = $modx->runSnippet('SimpleSearchForm',array(
                 'tpl' => 'mySearchForm',
                 'method' => 'POST',
                 'landing' => '106'
              ));
                • 33968
                • 863 Posts
                Try:
                ’tpl’ => ’myISearchForm’,

                I missed that when I read your snippet call.
                  • 6910
                  • 1 Posts
                  nah that’s not the problem, i’ve tried passing in an empty array - same error.

                  Tried with wayfinder and it’s setting, and again the exact same error.
                    • 33968
                    • 863 Posts
                    Could you try calling runSnippet from inside modx? Then at least you’ll know if the problem is from trying to run it externally...
                      • 6910
                      • 1 Posts
                      put it into a snippet (minus all the define and includes)

                      global $modx;
                      
                      $searchForm = $modx->runSnippet('SimpleSearchForm',array(
                         'tpl' => 'IMISearchForm',
                      'method' => 'post'
                      ));
                      
                      echo $searchForm;


                      Showed the form.
                      I’ve hada look at the cache file it’s referring to.. when loaded externally..
                      the first error seems to be stemming from:
                      require_once $modx->getOption('sisea.core_path',null,$modx->getOption('core_path').'components/simplesearch/').'model/simplesearch/simplesearch.class.php';