0


I'm working on a project called Mijn Paneel. Its in dutch and its a sort of socializing backend of a themepark minecraft server. The first version was written in pure php. This time I am doing a rewrite. (And my first time with composer)

My question currently is. How can I show a list of urls to news articles that has been pulled of a database. I am using mustache as my Template Engine and I got it to work pretty well. This is the code to get the news list from the database: (class name is news)

  public function NewsList() {
    $database = new Medoo([
    'database_type' => $GLOBALS['config']['database']['type'],
    'database_name' => $GLOBALS['config']['database']['name'],
    'server' => $GLOBALS['config']['database']['host'],
    'username' => $GLOBALS['config']['database']['user'],
    'password' => $GLOBALS['config']['database']['password'],
    'charset' => 'utf8'
]);
$test = $database->get("news", ["id","title"]);
return $test;
}

And this is my template code [I use the file based template option, so this is just a small part]

<div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">Nieuwsberichten</h3>
            </div>
            <div class="panel-body">
      {{#NewsList}}
      <a href="/news/{{id}}" class="list-group-item">{{title}}</a>
      {{/NewsList}}

            </div>
        </div>

But currently I can't get it to get all news (It only shows the latest!) How could I fix this. If you need any more information just ask!

0 Answers0