Transfer admin data to front end

Matthew Hawley

Well-known member
So an addon I'm making has an admin page that lets you create categories. How can I put those categories in a page (not a page node) on the forums?
 
The same process you used to create the page and fetch the data will apply to the front end.
 
No. DataWriters are for what their name implies they are for. If you have the data displayed in the backend, you have all the necessary components for it to be displayed on the front end.
 
So it would be this?

Code:
<xen:foreach loop="$addedLinks" value="$link">
	<li><a href="{$link.href}" class="{xen:if "{$selected} == {$link.route}", 'secondaryContent', 'primaryContent'}">{$link.title}</a></li>
</xen:foreach>
 
@Jeremy how did you get this to work?

Code:
<xen:foreach loop="$addedLinks" value="$link">
                    <li><a href="{$link.href}" class="{xen:if "{$selected} == {$link.route}", 'secondaryContent', 'primaryContent'}">{$link.title}</a></li>
</xen:foreach>

When I try it, I get this:

Template Errors: cf_directory_index
  1. Invalid argument supplied for foreach() in /home3/mcwh/public_html/xxx/library/XenForo/Template/Abstract.php(265) : eval()'d code, line 26:
    25: ';
    26: foreach ($addedLinks AS $link)
    27: {
 
@Jeremy how did you get this to work?

Code:
<xen:foreach loop="$addedLinks" value="$link">
                    <li><a href="{$link.href}" class="{xen:if "{$selected} == {$link.route}", 'secondaryContent', 'primaryContent'}">{$link.title}</a></li>
</xen:foreach>

When I try it, I get this:

Template Errors: cf_directory_index
  1. Invalid argument supplied for foreach() in /home3/mcwh/public_html/xxx/library/XenForo/Template/Abstract.php(265) : eval()'d code, line 26:
    25: ';
    26: foreach ($addedLinks AS $link)
    27: {

I assume you never passed the $addedLinks to the template.

For instance when you do this:

PHP:
$addedLinks = array();
return $this->responseView('XX_ViewPublic_Forum', 'xx', array('addedLinks' => $addedLinks));

If you'll do the above you won't see the error you see right now. but you'll have to do what ever you need to do in order to get $addedLinks populated with data.
 
I assume you never passed the $addedLinks to the template.

For instance when you do this:

PHP:
$addedLinks = array();
return $this->responseView('XX_ViewPublic_Forum', 'xx', array('addedLinks' => $addedLinks));

If you'll do the above you won't see the error you see right now. but you'll have to do what ever you need to do in order to get $addedLinks populated with data.

Which file do I do this on?
 
Nevermind I would do it in the controllerpublic file. I found this in Jeremy's help manager addon.

Code:
protected function _getWrapper($selected, XenForo_ControllerResponse_View $subView) {
        $wrapper = parent::_getWrapper($selected, $subView);

      $links = array();
    $helpModel = XenForo_Model::create('XI_HelpManager_Model_Page');
    $pages = $helpModel->getAllPagesForDisplay();

    $wrapper->params['addedLinks'] = $pages;

        return $wrapper;
    }

But that would help me with my addon as its for the help section...How would I change this to suit my addon?
 
Back
Top Bottom