how do I call an addon controller

I have a page I placed into my addon folder



/cscart/addons/ws/controllers/admin/ws.php



and placed some test code.


if ( !defined('AREA') ) { die('Access denied'); }
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($mode == 'add') {
file_put_contents("webservice/output/test.txt","Hello World");
}
}
?>




now if I try to load

[url]http://webserv01.gva-twn.com/cscart/admin.php?ws.add[/url]



I don’t get any file written out, so the page isn’t getting loaded. Can anyone tell me how to call my own controller?



Thanks



Scott

Well I have found that my page is getting called, the $AREA variable is empty, that’s why mode code isn’t running.

Yet I am logged in…very confusing…

The php code should start with something like:



```php define(‘AREA’, ‘C’);

define(‘AREA_NAME’ ,‘customer’);

require dirname(FILE) . ‘/…/prepare.php’;

require dirname(FILE) . ‘/…/init.php’; ```



Make sure the paths are correct for the required files…

I don’t see that code in any of the other add controllers. But i will try it. What do I put in for admin, ‘A’ & ‘Admin’ ?


[quote name=‘TexasGuy’]The php code should start with something like:



```php define(‘AREA’, ‘C’);

define(‘AREA_NAME’ ,‘customer’);

require dirname(FILE) . ‘/…/prepare.php’;

require dirname(FILE) . ‘/…/init.php’; ```Make sure the paths are correct for the required files…[/quote]

Sorry I just found it in admin.php


define('AREA', 'A');
define('AREA_NAME' ,'admin');

I’m no longer getting an error, but it doesn’t seem to be working either…

admin.php?ws.add



Here is the answer: there are no POST method

Thanks,



I did remove that test for post and it seemed to work. I just went to work on some other stuff and haven’t come back to my controller yet.



Scott

[quote name=‘crisdim’]admin.php?ws.add



Here is the answer: there are no POST method[/QUOTE]



The correct way to call an addon controller is [url]http://store.com/admin.php?dispatch=ws.add[/url]



This requires you to be previously logged in as a valid admin user.