示例#1
0
<?php

// Get categories
$categories = \Product\Model_Category::find(function ($query) {
    $query->order_by('sort', 'asc');
    $query->order_by('id', 'asc');
});
$category = isset($category) ? $category : false;
$link = isset($link) ? $link : 'update';
$selected = isset($selected) ? $selected : false;
?>

<?php 
if ($category) {
    ?>

<div class="side_tree_holder">
    <div class="tree_heading">
        <h4>Product Categories</h4>
        <div id="sidetreecontrol" class="sidetreecontrol"><a href="#">Collapse All</a><a href="#">Expand All</a></div>
    </div>
    <div class="tree_content">
        <div id="sidetree">
        
        	<?php 
    if (!$category && empty($categories)) {
        ?>
        		<div class="wide"><span class="req">Note: </span> There are no categories yet.</div>
        	<?php 
    } else {
        ?>
示例#2
0
 /**
  * Index page
  * 
  * @access  public
  * @param   $slug
  */
 public function action_index($slug = false, $gallery_id = null)
 {
     // Get home page
     $home_page = \Config::get('details.locked_items.home_page');
     $gallery_page = \Config::get('details.locked_items.gallery');
     $item = false;
     if ($slug == 'referrals' && strtolower(\Sentry::user()->groups()[0]['name']) != 'club members') {
         \Messages::error('Only club members can access this page.');
         \Response::redirect('/');
     }
     //var_dump($slug);die();
     // Find content by slug
     if ($slug !== false) {
         $item = \Page\Model_Page::get_by_slug($slug);
     } elseif ($slug === false) {
         $item = \Page\Model_Page::find_one_by_id($home_page);
     }
     if ($item) {
         // Home page is always without slug so we redirect if someone tries to access home page with slug
         if ($item->id == $home_page && $slug !== false) {
             \Response::redirect(\Uri::base(false));
         }
     } else {
         // Send to 404 page
         throw new \HttpNotFoundException();
     }
     $result = \Page\Model_Page::get_content_file($item->id);
     if ($result) {
         foreach ($result as $rs) {
             $item->content_file_pdf = $rs->file;
             //pdf file
             $item->content_file_title = $rs->title;
             //pdf title
         }
     }
     // Default view file
     $view_file = 'default';
     // Fill in home page slug if none is supplied
     if ($slug === false && $item->id == $home_page) {
         $slug = $item->seo->slug;
         // Home page has its standard template
         $view_file = 'home';
     } else {
         // Search for page specific template
         $files = \File::read_dir($this->theme_view_path);
         if (!empty($files)) {
             foreach ($files as $file) {
                 $path_parts = pathinfo($file);
                 if (strpos($path_parts['filename'], '_') === 0) {
                     $file_id = substr($path_parts['filename'], strripos($path_parts['filename'], '_') + 1);
                     if (is_numeric($file_id) && $item->id == $file_id) {
                         $view_file = $path_parts['filename'];
                     }
                 }
             }
         }
     }
     $stock_options = \Config::load('stock-option.db');
     // TODO delete this
     srand($item->id);
     $this->page_theme = \Theme::instance()->set_partial('content', $this->view_dir . $view_file);
     $this->page_theme->set('item', $item, false);
     $this->page_theme->set('manage_stock', $stock_options['manage_stock'], false);
     $this->page_theme->set('hide_out_of_stock', $stock_options['hide_out_of_stock'], false);
     $this->page_theme->set('allow_buy_out_of_stock', $stock_options['allow_buy_out_of_stock'], false);
     if ($item->id == $gallery_page) {
         if ($gallery_id && \Input::is_ajax()) {
             // This will return gallery images only if it is ajax call
             $this->returnGalleryImages($gallery_id);
         }
     }
     // Data for home page
     if ($view_file == 'home') {
         $featured_products = \Product\Model_Group::find_one_by_id(4);
         if ($featured_products) {
             $featured_products = $featured_products->products;
         }
         $this->page_theme->set('featured_products', $featured_products, false);
         $categories = \Product\Model_Category::find(array('where' => array('parent_id' => 0, 'status' => 1), 'order_by' => array('sort' => 'asc'), 'limit' => 8));
         $this->page_theme->set('categories', $categories, false);
         $applications = \Application\Model_Application::find(array('where' => array('parent_id' => 0, 'status' => 1), 'order_by' => array('sort' => 'asc'), 'limit' => 8));
         $this->page_theme->set('applications', $applications, false);
         // $this->page_theme->set('blog', $this->wp_blog(), false);
     }
     \View::set_global('title', $item->seo->meta_title ?: $item->title);
     \View::set_global('meta_description', $item->seo->meta_description ?: '');
     \View::set_global('meta_keywords', $item->seo->meta_keywords ?: '');
     $robots = array('meta_robots_index' => $item->seo->meta_robots_index == 1 ? 'index' : 'noindex', 'meta_robots_follow' => $item->seo->meta_robots_follow == 1 ? 'follow' : 'nofollow');
     \View::set_global('robots', $robots);
     \View::set_global('canonical', $item->seo->canonical_links);
     \View::set_global('h1_tag', $item->seo->h1_tag);
     if ($item->seo->redirect_301) {
         \Response::redirect($item->seo->redirect_301);
     }
 }
?>
<!-- EOF Image Banner with Title -->

<div class="app-content">
  <div class="container">
    <!-- Show Title if there is image, if none show intro description -->
    <h2 class="copy-title"><?php 
echo !empty($item->images) ? $item->description_intro : $item->title;
?>
</h2>
    <!-- EOF Show Title if there is image, if none show intro description -->
  <?php 
// get all active parent category
$categories = \Product\Model_Category::find(function ($query) {
    $query->where('parent_id', 0);
    $query->where('status', 1);
    $query->order_by('sort', 'asc');
});
?>
  <!-- check if it has category -->
  <?php 
if ($categories) {
    ?>
    <div class="category-products">
      <div class="row">
        <?php 
    foreach ($categories as $category) {
        ?>
          <div class="col-md-4 col-sm-6">
            <div class="product-item">
              <a href="<?php 
示例#4
0
 /**
  * Get additional content data selected
  * 
  * @param $result = Query result
  */
 public static function post_find($result)
 {
     $config = \Config::load('stock-option.db');
     if ($result !== null) {
         if (is_array($result)) {
             foreach ($result as $item) {
                 // It will first check if we already have result in temporary result,
                 // and only execute query if we dont. That way we dont have duplicate queries
                 // Get category products
                 $item->get_products = static::lazy_load(function () use($item, $config) {
                     $products = Model_Product_To_Categories::find(function ($query) use($item) {
                         return $query->where('category_id', $item->id);
                     }, 'product_id');
                     if (!empty($products)) {
                         $products = '(' . implode(',', array_keys($products)) . ')';
                         return Model_Product::find(function ($query) use($products, $item, $config) {
                             $query->select('product.*');
                             if ($config['hide_out_of_stock']) {
                                 $query->join('product_attributes');
                                 $query->on('product.id', '=', 'product_attributes.product_id');
                                 $query->where('product_attributes.stock_quantity', '>', 0);
                             }
                             $query->and_where('product.id', 'IN', \DB::expr($products));
                             $query->group_by('product.id');
                             $query->order_by('product.sort', 'asc');
                             // print_r((string)$query);
                             // die;
                             return $query;
                         }, 'id');
                     }
                     return array();
                 }, $item->id, 'products');
                 // Get all category products (including subcategory products)
                 $item->get_all_products = static::lazy_load(function () use($item) {
                     $categories_ids = \Product\Model_Category::get_all_children($item);
                     $products = Model_Product_To_Categories::find(function ($query) use($item, $categories_ids) {
                         return $query->where('category_id', 'in', $categories_ids);
                     }, 'product_id');
                     if (!empty($products)) {
                         $products = '(' . implode(',', array_keys($products)) . ')';
                         return Model_Product::find(function ($query) use($products, $item) {
                             $query->where('id', 'IN', \DB::expr($products));
                             $query->order_by('sort', 'asc');
                             return $query;
                         }, 'id');
                     }
                     return array();
                 }, $item->id, 'all_products');
                 // Get content images
                 $item->get_images = static::lazy_load(function () use($item) {
                     return Model_Category_Image::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'images');
                 // Get content children
                 $item->get_children = static::lazy_load(function () use($item) {
                     return \Product\Model_Category::find(array('where' => array('parent_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'children');
                 // Get content children
                 $item->get_seo = static::lazy_load(function () use($item) {
                     return Model_Category_Seo::find_one_by_content_id($item->id);
                 }, $item->id, 'seo', 'object');
             }
         }
     }
     // return the result
     return $result;
 }