Referencing a template for Thread Creation process?

Discussion in 'XenForo' started by Igneous, Aug 4, 2018.

  1. Igneous

    Igneous Participant

    I'd like to call a template as I would like to be able to modify the output and it doesn't sit right with me to hard-code it in the script.

    I've tried the following snippet of code below but it can't find anything named 'template'. I've checked and I don't think it can be referenced like phrases can? But there has to be a way.. :/

    $message = \XF::template('application_author_thread');
    • Error: Call to undefined method XF::template()
    • src/addons/Custom/Applications/Pub/Controller/Applications.php:85
    • Generated by: Igneous
    • Aug 4, 2018 at 7:00 PM
    Stack trace
    #0 src/XF/Mvc/Dispatcher.php(249): Custom\Applications\Pub\Controller\Applications->actionSave(Object(XF\Mvc\ParameterBag))
    #1 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('Custom\\Applicat...', 'Save', 'json', Object(XF\Mvc\ParameterBag), '', Object(Custom\Applications\Pub\Controller\Applications), NULL)
    #2 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
    #3 src/XF/App.php(1931): XF\Mvc\Dispatcher->run()
    #4 src/XF.php(328): XF\App->run()
    #5 index.php(13): XF::runApp('XF\\Pub\\App')
    #6 {main}
    Request state
    array(4) {
    ["url"] => string(17) "/application/save"
    ["referrer"] => string(43) ""
    ["_GET"] => array(1) {
    ["/application/save"] => string(0) ""
    ["_POST"] => array(7) {
    ["game_ids"] => array(2) {
    [0] => string(1) "6"
    [1] => string(1) "1"
    ["country"] => string(11) "United States"
    ["comments"] => string(0) ""
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(13) "/application/"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"

    $forumId '4'// This is the application forum
    $userId $application['user_id']; // Grab the user ID from the table
    $title "Application - ".$application['username']; // Hardcoded title
    $message 'Example contents'// Should reference the username, comments and country.
    $forum = \XF::em()->find('XF:Forum'$forumId);
    $user = \XF::em()->find('XF:User'$userId);
    XF::asVisitor($user, function() use ($forum$title$message)
    $creator = \XF::service('XF:Thread\Creator'$forum);
    $creator->setPrefix('4'); // sets prefix to 'Pending'.
    I've also been trying to capture the thread ID upon creation (so that it can be stored in the database and can be used for a response at a later date!) but that is a whole other issue, unfortunately.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.