function index() { $group_category = (int) @$_GET['cat_group_category']; $input = Input::Instance(); $category = new Category(); $db = Database::Instance(); $return = array(); $msgerror = null; $searchtxt = $input->get($this->inputtext); $liked = array("name_product" => $searchtxt, 'description_product' => $searchtxt); $likedstr = " (\n name_product LIKE '%{$searchtxt}%' OR description_product LIKE '%{$searchtxt}%' OR\n name_product_en LIKE '%{$searchtxt}%' OR description_product_en LIKE '%{$searchtxt}%'\n ) "; /* Count of Rows */ $result = $db->select("count(*) as total")->from("product")->where($likedstr); if ($group_category > 0) { $result = $result->from("product_has_category")->where(array('category_id_category' => $group_category))->where("product_id_product = id_product"); } $result = $result->get(); foreach ($result as $row) { $total = $row->total; } /* Class Pagination */ $this->pages = new Pagination(array('base_url' => "" . $this->__("search") . "/items/" . $this->__("page") . "/", 'uri_segment' => 'pagina', 'total_items' => $total, 'items_per_page' => $category->max_items_per_category, 'style' => $category->getstyle_pagination())); /* List of Products */ $result = $db->select("*")->from("product")->orderby(array("update_product" => "DESC"))->where("{$likedstr}")->limit($category->max_items_per_category)->offset($this->pages->sql_offset); /*Condition Category group*/ if ($group_category > 0) { $result = $result->from("product_has_category")->where(array('category_id_category' => $group_category))->where("product_id_product = id_product"); } /* Build The Result */ $result = $result->get(); foreach ($result as $row) { Basic::currency($row->price_product); if ($row->price_offer_product > 0) { Basic::currency($row->price_offer_product); $row->price_product = "<strike>" . $row->price_product . "</strike> {$this->separator_price} " . $row->price_offer_product; } $row->href_add_product = url::base() . $this->__("cart") . "/" . $this->__("add") . "/id/{$row->id_product}"; $row->href_detail_product = url::base() . $this->__("product") . "/" . $this->__("detail") . "/" . Basic::urlizar($row->name_product) . "/id/{$row->id_product}"; $return[] = $row; } /* Error Detecting */ if (count($return) < 1 or $searchtxt == null) { $return = array(); $msgerror = __("No se encontraron resultados", false); $this->pages = null; } // $this->content = View::factory("main/search_list_products") $this->title = __('Resultados de la búsqueda', false); $this->content = View::factory("main/list_products")->set('product', $return)->set('title', __('Resultados de la búsqueda', false))->set('msgerror', $msgerror)->set('pages', $this->pages)->render(); }
public static function getUrlById($id, $view_name = true) { $cache = Cache::instance(); $tprefix = Basic::TransVar('t'); $uid = $tprefix . 'page__getUrlById__' . $id; $url = $cache->get($uid); if (!$url) { $id = (int) $id; $orm = new stdClass(); $table = new fpp_page_Model(); $orm = $table->db2cls($id); $tr_title_page = Basic::TransVar("title_page"); $tr_content_page = Basic::TransVar("content_page"); $title = $orm->{$tr_title_page}; $titleurl = Basic::urlizar($orm->{$tr_title_page}); $url = html::anchor(url::base() . "page/{$id}/{$titleurl}", $view_name ? $title : ""); $cache->set($uid, $url, array(), 3600); } return $url; }
function listnews() { // $this->_NoTemplate(); $orm = new fpp_news_Model(); $orm = $orm->db2cls(); $total = $orm->count_all(); $baseurl = 'webserv/listnews/pagina'; /* Class Pagination */ $pages = new Pagination(array('base_url' => $baseurl, 'uri_segment' => 'pagina', 'total_items' => $total, 'items_per_page' => $this->items['news'], 'style' => "apoyodigital")); // echo $pages->sql_offset; $q = $orm->limit($this->items['news'], $pages->sql_offset)->fetch_all('id_news', 'DESC'); $this->title = "NOTICIAS"; $html = null; foreach ($q as $new) { $nu = Basic::urlizar($new->title_news); $html .= "<li class='newsmodule'> " . html::anchor(url::base() . "noticia/{$new->id_news}/{$nu}", $new->title_news) . "</li>"; } $html .= "<br/>" . $pages; $this->content = View::factory("main/page")->set("title", "Noticias")->set("content", $html)->render(); // $html View::factory("webservices/news_list") // ->set("news",$q) // ->set("pages",$pages) // ->render(); }
<!-- <ul> --> <?php foreach ($news as $new) { $title_news = Basic::TransVar("title_news"); $nu = Basic::urlizar($new->{$title_news}); ?> <h6> <?php echo html::anchor(url::base() . "news/{$new->id_news}/{$nu}", $new->{$title_news}); ?> </h6> <?php } ?> <!-- </ul> -->
public static function getUrlById($id) { $cache = Cache::instance(); $tprefix = Basic::TransVar('t'); $uid = $tprefix . 'Category__getUrlById__' . $id; $url = $cache->get($uid); if (!$url) { $id = (int) $id; $orm = new stdClass(); $table = new fpp_category_Model(); $orm = $table->db2cls($id); $name_category = Basic::TransVar("name_category"); $tr_content_page = Basic::TransVar("content_page"); $name = $orm->{$name_category}; $titleurl = Basic::urlizar($name); $url = html::anchor("category/items/" . $id . '/' . $titleurl, $name); // $url = html::anchor(url::base()."category/{$id}/{$titleurl}",(($view_name) ? $title : "")); $cache->set($uid, $url, array(), 3600); } return $url; }