I want to develop a membership plugin under wordpress and for this I want to use zend framework 2.
Does anyone managed to create a wordpress plugin using zend framework 2?
I'm new to zf and I do not know how and where to start from.
I tried to start from zend skeleton application but got stuck at add_menu_pages and displaying a simple dashboard.
Can anyone give me some ideas or links.
Thanks!
Updated!
I managed to get this working! I just needed to use a PhpRenderer. For those who need a little more help here is how I did:
I created a class that manages all admin area. On class init I called a method that created menu pages( in this method simply add_menu_pages() and instead of callback_function I called a new method, manage_pages, that, wel... manages pages, but you can do it as you desire) and then I initiated the view, like this:
$this->view = new PhpRenderer();
$this->map = new Resolver\TemplateMapResolver(array(
'template_name' => 'template_path',
'template2_name'=> 'template2_path')); //this is for handling view templates a little easier
$this->resolver = new Resolver\TemplateMapResolver($this->map);
$this->view->setResolver($this->resolver);
$this->model = new ViewModel();
Further, in manage_pages method, for each page I have, I added its own template and variables I needed
$this->model->setTemplate('template_name');
$this->model->setVariable('variable_name', value);
As for displaying template, you just have to write this piece of code:
echo $this->view->render($this->model);
In the template files you can access variables using $this->variable_name
Also you can insert another template using $this->partial( 'template2_name', assoc_arrray_of_variables_to_be_passed_to_template )
.
And this is it! If you have any questions, please let me know!
There is a wordpress plugin you can use, search "wopzen2" or "wordpress and zend framework 2 integration" on Google, with this solution, you can use the following code inside the php wordpress code:
global $wpzf2plugin; $render=$wpzf2plugin->render('/application/index/contactform'); echo $render;
This code calls the contactform action, if you are familiar with zendframework I think you are going to understand it.
This plugin is dedicated to developers.
You can get a free version of the plugin via support center.
I hope this answer can be helpful for you
reference link: Example codes