1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Return a Xenforo template

Discussion in 'XenForo Development Discussions' started by Zephyr, Sep 30, 2012.

  1. Zephyr

    Zephyr Well-Known Member

    Hi, i have a .php.
    I would like returned a xenforo template and passing variables.

    My code :

        // Secret BBcode (Display a message if the user has a specific id)
    public static function parseSecret(array $tag, array $rendererStates, &$parentClass)
            if (!empty(
    $tag['option']) && $parentClass->parseMultipleOptions($tag['option']))
    $attributes $parentClass->parseMultipleOptions($tag['option']); // Id's
    $userSecretMessage $tag['children'][0]; // Message
    foreach($attributes as $usersId)
    $usersIdString $usersId ',';
    // Variables to pass: $usersIdString and $userSecretMessage
    How can I do that please ? :)
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Example code from one of my addons:

    				$template = new XenForo_Template_Public('nat_childlinks', array(
    					'firstChildNodes' => $firstChildNodes,
    					'selected' => $selectedTabId == 'nodetab' . $nodeTab['node_id'],
    					'nodeTypes' => $nodeModel->getAllNodeTypes()
    				$childLinks = $template->render();
    The template name is nat_childlinks. And it passes an array of template params. Then it renders the template and stores it in $childLinks.
    cclaerhout likes this.

Share This Page