using GetHelper inside of a model?

Jaxel

Well-known member
I am trying to use the following code:
Code:
$ftpHelper = $this->getHelper('ForumThreadPost');
$forum = $ftpHelper->assertForumValidAndViewable($options->EWRmedio_autoforum);
$forumId = $forum['node_id'];

However, it appears that getHelper is not a valid function in models; only in controllers. How would I do what I'm trying to do here inside of a model?
 
Okay... I decided to just use this:
Code:
if (!$forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumById('2'));
{
	print_r($forum); exit;
}

However, I'm having an issue with this... for some reason this code ALWAYS validates. It prints the $forum array info, and then exits. If $forum is getting retrieved properly, it shouldn't validate and the script should move on...
Code:
Array
(
    [node_id] => 2
    [title] => Main Forum
    [description] =>
    [node_name] =>
    [node_type_id] => Forum
    [parent_node_id] => 1
    [display_order] => 1
    [display_in_list] => 1
    [lft] => 2
    [rgt] => 3
    [depth] => 1
    [style_id] => 0
    [effective_style_id] => 0
    [discussion_count] => 3
    [message_count] => 4
    [last_post_id] => 4
    [last_post_date] => 1289528456
    [last_post_user_id] => 2
    [last_post_username] => Digital Doctor
    [last_thread_title] => Lorem ipsum dolor sit amet
)
 
Might be able to do something like;

PHP:
$frontController = XenForo_Application::get('fc');
$fakeController = new XenForo_ControllerPublic_Index($frontController->getRequest(), $frontController->getResponse(), $frontController->route());
$helper = $fakeController->getHelper('ForumThreadPost');

Completely untested.
 
Top Bottom