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

Transfer admin data to front end

Discussion in 'XenForo Development Discussions' started by Matthew Hawley, Jan 14, 2014.

  1. Matthew Hawley

    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?
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    The same process you used to create the page and fetch the data will apply to the front end.
     
  3. Matthew Hawley

    Matthew Hawley Well-Known Member

    But I haven't fetched the data yet. How do I fetch the data? Could you give me some code? :)
     
  4. Matthew Hawley

    Matthew Hawley Well-Known Member

    OH is it the datawriter file you used in your xi help manager?
     
  5. Jeremy

    Jeremy XenForo Moderator Staff Member

    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.
     
  6. Matthew Hawley

    Matthew Hawley Well-Known Member

    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>
    
     
  7. Matthew Hawley

    Matthew Hawley Well-Known Member

    @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: {
     
  8. Vincent Gabriel

    Vincent Gabriel Active Member

    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.
     
  9. Matthew Hawley

    Matthew Hawley Well-Known Member

    Which file do I do this on?
     
  10. Matthew Hawley

    Matthew Hawley Well-Known Member

    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?
     
  11. Matthew Hawley

    Matthew Hawley Well-Known Member

    I'm sorry if I am asking a lot of questions, I just really want to get this addon done.
     
  12. Matthew Hawley

    Matthew Hawley Well-Known Member

    I really need to know how to do this... Could some please give me a tutorial?
     
  13. Matthew Hawley

    Matthew Hawley Well-Known Member

    This has gotten fixed.
     

Share This Page