Need ViewPublic Help

Discussion in 'XenForo' started by vOlLvEriNe, Jun 3, 2015.

  1. #1
    Hello Everybody,
    I'm Trying to Create a plugin, And stuck in ViewPublic :(
    How Can I Show List Of Posts Via ViewPublic ?
    Please Fix My Code
    class Custom_ViewPublic_Index extends XenForo_ViewPublic_Base
    {
        public function renderHtml()
        {
            $db = XenForo_Application::get('db');
            $sql = $db->fetchAll("SELECT * FROM custom_item");
            foreach ($sql as $item) {
    
                //What to Do
    
            }
        }
    }
    PHP:
    I Have to Show Like This
    <ul>
    <li>Title Num 1</li>
    <li>Title Num 2</li>
    <li>Title Num 3</li>
    </ul>
     
    vOlLvEriNe, Jun 3, 2015 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Well first of all, you shouldn't be doing queries within a view... rather you should be doing queries within your model and passing the results to your view.
     
    digitalpoint, Jun 7, 2015 IP