AlainGau Posted October 7, 2014 Share Posted October 7, 2014 I have the below PHP file in my module folder that is call with an ajax post (jquery from UI). And I am getting the following error: Class 'Context' not found in ... when I trigger the POST I am running PS 1.6, how can I access the context from this file?? <?php define('_EXTERNAL_SCRIPT_', 'true'); include(dirname(__FILE__).'../../config/config.inc.php'); include(dirname(__FILE__).'../../init.php'); include(dirname(__FILE__).'../../classes/Cookie.php'); Context::getContext()->cookie->__set('myData', $_POST['data1']); ?> Link to comment Share on other sites More sharing options...
vekia Posted October 8, 2014 Share Posted October 8, 2014 you have to define context object first for example: $context = new Context(); $context->getContext()->cookie->__set('myData', $_POST['data1']); Link to comment Share on other sites More sharing options...
AlainGau Posted October 8, 2014 Author Share Posted October 8, 2014 thanks but it was my path accesses that were wrong: include(dirname(__FILE__).'../../config/config.inc.php'); include(dirname(__FILE__).'../../init.php'); include(dirname(__FILE__).'../../classes/Cookie.php'); should be as below to work, since I am in the modules/mymodule folders.. include('../../config/config.inc.php'); include('../../init.php'); include('../../classes/Cookie.php'); Link to comment Share on other sites More sharing options...
vekia Posted October 9, 2014 Share Posted October 9, 2014 so, with correct paths you can use Contentx object with static functions? Link to comment Share on other sites More sharing options...
cristic Posted October 9, 2014 Share Posted October 9, 2014 so, with correct paths you can use Contentx object with static functions? The way it is defined Context::getContext - you can use it with static functions. If the object is not defined yet, it will create one: /** * Get a singleton context * * @return Context */ public static function getContext() { if (!isset(self::$instance)) self::$instance = new Context(); return self::$instance; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now