<![CDATA[ modx php object is not defined? - My Forums]]> https://forums.modx.com/thread/?thread=100306 <![CDATA[modx php object is not defined?]]> https://forums.modx.com/thread/100306/modx-php-object-is-not-defined#dis-post-542188
  $modx->getChunk('LinkedMenuItem');


and I get the error:

Fatal error: Call to a member function getChunk() on a non-object in C:\wamp\www\test-modx\modx\core\cache\includes\elements\modsnippet\1.include.cache.php on line 84


What exactly has gone wrong?]]>
tothconnor Jun 05, 2016, 07:36 PM https://forums.modx.com/thread/100306/modx-php-object-is-not-defined#dis-post-542188
<![CDATA[Re: modx php object is not defined?]]> https://forums.modx.com/thread/100306/modx-php-object-is-not-defined#dis-post-542281
global $modx;



If not, you can pass $modx to the function as an argument.]]>
BobRay Jun 08, 2016, 05:59 PM https://forums.modx.com/thread/100306/modx-php-object-is-not-defined#dis-post-542281
<![CDATA[Re: modx php object is not defined? (Best Answer)]]> https://forums.modx.com/thread/100306/modx-php-object-is-not-defined#dis-post-542260 Quote from: BobRay at Jun 06, 2016, 03:46 AM
Are you running the snippet outside of MODX somehow?

If so, see this: http://bobsguides.com/blog.html/2013/07/13/using-modx-outside-of-modx/.

If you're in MODX (iow, the snippet tag is in a resource or chunk), you'll have to post the code of the snippet with the ID of 1 before we can help you.

Thank you for your reply, I solved the issue. I was using the $modx variable in a function that was not properly written for MODX in that it didn't have the if (function_exists)]]>
tothconnor Jun 07, 2016, 05:01 PM https://forums.modx.com/thread/100306/modx-php-object-is-not-defined#dis-post-542260
<![CDATA[Re: modx php object is not defined?]]> https://forums.modx.com/thread/100306/modx-php-object-is-not-defined#dis-post-542189
If so, see this: http://bobsguides.com/blog.html/2013/07/13/using-modx-outside-of-modx/.

If you're in MODX (iow, the snippet tag is in a resource or chunk), you'll have to post the code of the snippet with the ID of 1 before we can help you.]]>
BobRay Jun 05, 2016, 10:46 PM https://forums.modx.com/thread/100306/modx-php-object-is-not-defined#dis-post-542189