Hello, colleagues.
I try to run Wayfinder with modx->runSnippet from external file. But I get error: "Fatal error: Call to a member function get() on a non-object in /srv/www/relaxmenu.ru/public_html/core/components/wayfinder/wayfinder.class.php on line 40". Also I get error like this, when try to call getResources snippet;
here is my code:
<?php
require_once(’ru/rialaunch/model/vo/SectionInfo.php’);
require_once($_SERVER[’DOCUMENT_ROOT’].’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’,’2’));
echo $html;
?>
What could be wrong?
Line 40 is doing this :-
'id' => $this->modx->resource->get('id'),
So you have no resource object in your modx object, this will be the case as you are instantiating the modx object from an external script and not processing a
normal page request.
Use MODx, or the cat gets it!
-
☆ A M B ☆
- 3,141 Posts
Try using one resource as "controller" - putting either that external script there, or the actual snippet you are trying to invoke. So letting that resource return the actual content you need.
That will then handle the request stuff and make sure there is a resource object.