Controller->responseMessage as Subview

xf_phantom

Well-known member
Can i cast the response from responseMessage to use it XenForo_ControllerResponse_View ?:D


I want to send a message inside the account pages(which are using using XenForo_ControllerHelper_Account->getWrapper which requires the 3. parameter to be XenForo_ControllerResponse_View )

that's why i'll get an error if i'll use only "$this->responseMessage('..');
 
I just don't think it's possible, unfortunately. (And I think you posted about this once before).

It would more than likely create less effort to simply create a template and render it as a view.

Or, if you are potentially going to have lots of these cases where you need to pass a message, you could create a template that accepts a single view param called {$errorMessage}

PHP:
$subView = $this->responseView('Your_AddOn_ViewPublic_Error', 'your_addon_error_message', array('errorMessage' => new XenForo_Phrase('an_error_message')));

You could then re-use that at your leisure, just changing the error each time.
 
(And I think you posted about this once before).
Possible:D

Current solution:
PHP:
<?php

class FAT_Core_Helper_Account extends XenForo_ControllerHelper_Account{

    public function responseMessageOnAccountPage($selectedGroup, $selectedLink, $message, $alternativeViewName = 'FOO', $altnativeMessageTemplate = 'fat_core_message'){
        $subView = $this->_controller->responseView($alternativeViewName, $altnativeMessageTemplate, array('msg' => $message));
        return $this->wrap($this->_controller, $selectedGroup,$selectedLink, $subView);
    }
}
 
And usage

PHP:
public function actionIndex()
    {
        $visitor = XenForo_Visitor::getInstance()->toArray();
        if ($this->_getModel()->isAlreadyVerified(XenForo_Visitor::getInstance()->toArray())) {
            return $this->getHelper('FAT_Core_Helper_Account')->responseMessageOnAccountPage('check', '','test1');
            //TODO http://xenforo.com/community/posts/678062/
        }
        else if ($this->_getModel()->isPending($visitor)){
            return $this->getHelper('FAT_Core_Helper_Account')->responseMessageOnAccountPage('check', '','test2');
        }

        $subView = $this->responseView('FAT_X', 'fat_uservalidation_form');


        return $this->getHelper('Account')->getWrapper('check', '', $subView);

    }
 
Back
Top Bottom