Need the ability to return a view from an action hook like a short code or ajax call. I discovered a couple hacks that did return a view. Seems like there needs to be a documented way to do this from the core. My hacks haven't been tested with variables being passed to the form however.
add_action( "wp_ajax_nopriv_mytest", 'mytest' );
add_action( "wp_ajaxmytest", 'mytest' );
// Would like to return a view from a function call
function mytest()
{
/
This hack seemed to work for me to return a view from
$control = new JobsController();
$control->test();
$control->main_view='jobs/test';
$control->render_main_view();
/_
_/* This hack didn't work for me until I added the layout attribute which doesn't work untill you add mv_layout to MvcLoader
$this->query_vars = array('mvc_controller','mvc_action','mvc_id','mvc_extra','mvc_layout');
*/_
MvcDispatcher::dispatch(array(
'controller' => 'jobs',
'action' => 'test',
'layout' =>'mylayout'));
Yep, that can work. I also sometimes just instantiate the model and include the view as a file from the action hook function. Works fine too. You can also use output buffering if needed.
Need the ability to return a view from an action hook like a short code or ajax call. I discovered a couple hacks that did return a view. Seems like there needs to be a documented way to do this from the core. My hacks haven't been tested with variables being passed to the form however.
add_action( "wp_ajax_nopriv_mytest", 'mytest' ); add_action( "wp_ajaxmytest", 'mytest' ); // Would like to return a view from a function call function mytest() { / This hack seemed to work for me to return a view from $control = new JobsController(); $control->test(); $control->main_view='jobs/test'; $control->render_main_view(); /_
} Thanks! --Mike Clark