Are there anyway to use <xen:form> and <xen:listitem> out of admin-cp?

timothy259856

Active member
Hello guys, I wish to create a table which allow user manage their information, just like the table of admin-cp, for example: http://localhost/test/admin.php?add-ons/ this table very easy to use, it's contain filter...

But when I try to use that style for normal template, it's said that:

Code:
Unknown tag: listitem
or
Code:
Unknown tag: form


Thank guys!
 
Actually, yes you can. I had the same need and came up with a quick work around that allows me to use admin tags in public templates.

What you need to do is just create a temporary admin view renderer, and then you can render any admin template. Here is my code snippet:

PHP:
$viewRenderer = new XenForo_ViewRenderer_HtmlAdmin(
    new XenForo_Dependencies_Admin(),
    XenForo_Application::getFc()->getResponse(),
    XenForo_Application::getFc()->getRequest()
);

$adminView = new XenForo_ViewAdmin_Base($viewRenderer, XenForo_Application::getFc()->getResponse());

$rendererOptions = $this->getRendererOptions();
$rendererOptions = XenForo_Model::create('XenForo_Model_Option')->prepareOptions($rendererOptions);

$this->_element['renderedOptions'] = XenForo_ViewAdmin_Helper_Option::renderPreparedOptionsHtml($adminView, $rendererOptions, false);

This snippet allows me to use <xen:spinbox, <xen:textbox, <xen:radio, etc. outside of the admin panel. I'm not sure of your coding experience, but this probably takes some thorough understanding of how it works to get it to do what you want, but it can certainly be done. Don't ever accept no as an answer :) With PHP, anything you want to do is possible.
 
Actually, yes you can. I had the same need and came up with a quick work around that allows me to use admin tags in public templates.

What you need to do is just create a temporary admin view renderer, and then you can render any admin template. Here is my code snippet:

PHP:
$viewRenderer = new XenForo_ViewRenderer_HtmlAdmin(
    new XenForo_Dependencies_Admin(),
    XenForo_Application::getFc()->getResponse(),
    XenForo_Application::getFc()->getRequest()
);

$adminView = new XenForo_ViewAdmin_Base($viewRenderer, XenForo_Application::getFc()->getResponse());

$rendererOptions = $this->getRendererOptions();
$rendererOptions = XenForo_Model::create('XenForo_Model_Option')->prepareOptions($rendererOptions);

$this->_element['renderedOptions'] = XenForo_ViewAdmin_Helper_Option::renderPreparedOptionsHtml($adminView, $rendererOptions, false);

This snippet allows me to use <xen:spinbox, <xen:textbox, <xen:radio, etc. outside of the admin panel. I'm not sure of your coding experience, but this probably takes some thorough understanding of how it works to get it to do what you want, but it can certainly be done. Don't ever accept no as an answer :) With PHP, anything you want to do is possible.

Thank for your solution, very good idea with render template, don't think about that ago :) I'll do a try in a other addon, at now, I'm just use simple layout. Thanks anyway :)
 
Actually, yes you can. I had the same need and came up with a quick work around that allows me to use admin tags in public templates.

What you need to do is just create a temporary admin view renderer, and then you can render any admin template. Here is my code snippet:

PHP:
$viewRenderer = new XenForo_ViewRenderer_HtmlAdmin(
    new XenForo_Dependencies_Admin(),
    XenForo_Application::getFc()->getResponse(),
    XenForo_Application::getFc()->getRequest()
);

$adminView = new XenForo_ViewAdmin_Base($viewRenderer, XenForo_Application::getFc()->getResponse());

$rendererOptions = $this->getRendererOptions();
$rendererOptions = XenForo_Model::create('XenForo_Model_Option')->prepareOptions($rendererOptions);

$this->_element['renderedOptions'] = XenForo_ViewAdmin_Helper_Option::renderPreparedOptionsHtml($adminView, $rendererOptions, false);

This snippet allows me to use <xen:spinbox, <xen:textbox, <xen:radio, etc. outside of the admin panel. I'm not sure of your coding experience, but this probably takes some thorough understanding of how it works to get it to do what you want, but it can certainly be done. Don't ever accept no as an answer :) With PHP, anything you want to do is possible.

Hello Jeff, can you help me take a look at https://xenforo.com/community/threa...fter-receive-a-post-type-in-controller.82838/ ?

Thank you!
 
Back
Top Bottom