Replies: 4 comments
-
The easiest way to call php code is to create a new controller in your plugin.
namespace Vvveb\Plugins\TestPlugin\Controller;
use Vvveb\Controller\Base;
class Index extends Base {
function index() {
// this will try to render /plugins/test-plugin/public/index.html
// using the /plugins/test-plugin/app/template/index.tpl template
}
function json() {
$this->response->setType('json');
return ['key' => 'value'];
// or
//$this->response->output(['key' => 'value']);
}
} You can then call the method with localhost/?module=plugins/test-plugin/index&action=json Or you can register a new route with use Vvveb\System\Routes;
class TestPlugin {
function app() {
//add new route for plugin page
Routes::addRoute('/test-plugin', ['module' => 'plugins/test-plugin/index/json']);
}
} and then you can call localhost/test-plugin You can quickly check the example from the included test plugin |
Beta Was this translation helpful? Give feedback.
-
Thank You so much Givanz!
I have 15 websites currently on Shopify that I eventually want to transition over to your solution. I also want to become a big promoter of your system too. I think what you’re doing is AMAZING! I just need to understand the workings so I know how to customize for the needs of my clients.
Thank You for your work! I really appreciate what you’re doing!
Ferdie Eugenio
From: Givan ***@***.***>
Reply-To: givanz/Vvveb ***@***.***>
Date: Monday, October 28, 2024 at 1:41 PM
To: givanz/Vvveb ***@***.***>
Cc: ferdware ***@***.***>, Author ***@***.***>
Subject: Re: [givanz/Vvveb] How to make an Ajax call to a php function in my plugin (Discussion #208)
The easiest way to call php code is to create a new controller in your plugin.
plugins/test-plugin/app/controller/index.php
namespace Vvveb\Plugins\TestPlugin\Controller;
use Vvveb\Controller\Base;
class Index extends Base {
function index() {
// this will try to render /plugins/test-plugin/public/index.html
// using the /plugins/test-plugin/app/template/index.tpl template
}
function json() {
$this->response->setType('json');
return ['key' => 'value'];
// or
//$this->response->output(['key' => 'value']);
}
}
You can then call the method with localhost/?module=plugins/test-plugin/index&action=json
Or you can register a new route with addRoute
use Vvveb\System\Routes;
class TestPlugin {
function app() {
//add new route for plugin page
Routes::addRoute('/test-plugin', ['module' => 'plugins/test-plugin/index/json']);
}
}
and then you can call localhost/test-plugin
You can quickly check the example from the included test plugin /plugins/test-plugin
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I noticed there is two folders for “Plugins”
/plugins/
/public/plugins
Which one do I edit to make changes?
Ferdie Eugenio
619-857-8098
***@***.***
https://kreativeportals.com
|
Beta Was this translation helpful? Give feedback.
-
Thank you for using and promoting Vvveb. In Vvveb if securely installed only Plugins are stored in To overcome this issue for plugin files that need to be publicly accessible, when activating a plugin for the first time all files inside Plugin files inside For an active plugin static files are loaded from After finishing development you should copy the changes from |
Beta Was this translation helpful? Give feedback.
-
I created and added a Plugin. Then I added a test button on the Product.html page with an Onclick event to a function in app.js. What I'd like to do is to make an Ajax call to a php function that I have in my plugin?
Beta Was this translation helpful? Give feedback.
All reactions