Ejemplo n.º 1
0
    /**
     * Return slider complete HTML
     * @return string
     */
    public function loadSlider()
    {
        $template = <<<SLIDER
        <ul id="slider">
            {{CONTENT}}
\t\t</ul>
SLIDER;
        $banners = $this->model->getAllActive();
        $content = '';
        foreach ($banners as $banner) {
            $content .= '<li>';
            if ($banner->getUrl()) {
                $content .= "<a href=\"{$banner->getUrl()}\">";
            }
            $content .= "<img src=\"/uploads/slider/{$banner->getImage()}\">";
            if ($banner->getUrl()) {
                $content .= "</a>";
            }
            $content .= '</li>' . PHP_EOL;
        }
        return str_replace('{{CONTENT}}', $content, $template);
    }
Ejemplo n.º 2
0
 /**
  * Reorganize banners using column (position)
  */
 public function reorderAction()
 {
     header("Content-Type: Application/JSON");
     $result = array('success' => false, 'message' => 'Invalid request');
     if ($this->isPost()) {
         if ($this->getPost('banners')) {
             $banners = $this->getPost('banners');
             if ($this->model->reorder($banners)) {
                 $result['success'] = true;
                 $result['message'] = 'OK';
             }
         }
     }
     print_r(json_encode($result));
 }