当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::link方法代码示例

本文整理汇总了PHP中Collection::link方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::link方法的具体用法?PHP Collection::link怎么用?PHP Collection::link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collection的用法示例。


在下文中一共展示了Collection::link方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionDefault

 protected static function actionDefault()
 {
     // Получение списка товаров
     $products = new Collection('Product', 1);
     $products->link('category');
     $products->link('brand');
     $products->link('cover');
     $products->order('`add` DESC');
     $list = new TemplateList();
     $list->fields = array('id' => array('type' => 'id', 'title' => 'Номер'), 'cover->file' => array('type' => 'image', 'title' => 'Изображение', 'directory' => 'products', 'size' => '85x84'), 'name' => array('type' => 'text', 'title' => 'Название'), 'category->name' => array('type' => 'text', 'title' => 'Категория'), 'brand->name' => array('type' => 'text', 'title' => 'Производитель'), 'price' => array('type' => 'text', 'title' => 'Цена'), 'active' => array('type' => 'active', 'title' => 'Вкл/Выкл', 'action' => 'active', 'controller' => 'admin-products'));
     $list->itemActions = array('edit' => array('hint' => 'Изменить', 'icon' => 'edit', 'controller' => 'admin-products'), 'delete' => array('hint' => 'Удалить', 'icon' => 'delete', 'controller' => 'admin-products'));
     $list->actions = array('new' => array('hint' => 'Добавить', 'icon' => 'add', 'controller' => 'AdminProducts'));
     $list->items = Model::setModelsAutoload($products->items(), false, true);
     $list->classes = 'center-list';
     self::templateVar('title', App::t('Товары'));
     self::templateVar('content', $list);
     return self::displayPage('admin');
 }
开发者ID:swash13,项目名称:shop,代码行数:18,代码来源:AdminProducts.php

示例2: actionDefault

 protected static function actionDefault()
 {
     $products = new Collection('Product', App::currentLang()->getId());
     $products->link('cover');
     $products->where("`id` IN (" . implode(',', array_keys($_SESSION['cart'])) . ")");
     $products = $products->items();
     foreach ($products as $product) {
         $product->quantity = $_SESSION['cart'][$product->getId()];
     }
     self::templateVar('cart_items', $products);
     return self::displayPage('cart');
 }
开发者ID:swash13,项目名称:shop,代码行数:12,代码来源:Cart.php

示例3: actionDefault

 protected static function actionDefault()
 {
     /*
      * Если выводиться вся страница то списко товаров передается шаблону products-list таким образом
      * Controller -> index -> products-list
      * Если запрос аяксовый то переменные передаются напрямую шаблону products-list
      * Controller -> products-list
      * Но при создании этих переменных мы не думаем о том какой шаблон будет выводиться.
      */
     // Заголовок списка товаров
     self::templateVar('product_list_title', 'Последние товары');
     // товары в списке (6 последних добавленных в соотвествии с фильтром цен)
     $collection = new Collection('Product', App::currentLang()->getId());
     $collection->link('cover');
     $collection->order("`add` DESC");
     $where = "`active` = 1";
     if (isset($_POST['submitPriceRange'])) {
         $where .= " AND `price` >= {$_POST['min']} AND `price` <= {$_POST['max']}";
     }
     $collection->where($where);
     $collection->limit(6);
     self::templateVar('product_list_items', $collection->items());
     if (App::isAjax()) {
         // Если это ajax выводим чанк списка товаров
         return self::displayPage('chunks/product-list');
     }
     // Привязка категорий для табов под списком товаров
     // Получаем две категории из базы
     $collection = new Collection('Category', App::currentLang()->getId());
     $collection->where("`active` = 1");
     $collection->limit(2);
     $categories = $collection->items();
     foreach ($categories as $category) {
         $collection = new Collection('Product', App::currentLang()->getId());
         $collection->where("`id_category` = " . $category->getId() . " AND `active` = 1");
         $collection->limit(4);
         $category->setLink('products', $collection->items());
     }
     foreach ($categories as $index => $category) {
         if (empty($category->products)) {
             unset($categories[$index]);
         }
     }
     // Привязываем к шаблону
     static::templateVar('tab_categories', $categories);
     return self::displayPage('index');
 }
开发者ID:swash13,项目名称:shop,代码行数:47,代码来源:Index.php

示例4: actionSearch

 protected static function actionSearch()
 {
     // Заголовок над списком твоаров
     self::templateVar('product_list_title', 'Результаты поиска');
     // Товары
     $products = new Collection('Product', App::currentLang()->getId());
     $products->link('cover');
     $products->where("`active` = 1 AND `name` LIKE '%{$_GET['q']}%'" . (isset($_POST['submitPriceRange']) ? " AND `price` >= {$_POST['min']} AND `price` <= {$_POST['max']}" : ''));
     $products->order("`add` DESC");
     $products->limit(12);
     self::templateVar('product_list_items', $products->items());
     // Если это ajax выводим только чанк product-list
     if (App::isAjax()) {
         return self::displayPage('chunks/product-list');
     }
     return self::displayPage('catalog');
 }
开发者ID:swash13,项目名称:shop,代码行数:17,代码来源:Catalog.php

示例5: Collection

foreach ($books as $book) {
    $info = $book->attribs();
    dbm_debug('info', "written about {$info['title']} by {$info['author']}.");
}
dbm_debug('heading', 'Beginning testing for relational linking.');
$collection = new Collection(1);
$mhi = new Book(1);
$aotr = new Book(2);
$tram = new Book(3);
dbm_debug('info', 'Loaded a collection and three books:');
$collection->dumpview(true);
$mhi->dumpview(true);
$aotr->dumpview(true);
$tram->dumpview(true);
dbm_debug('info', 'Creating a relational link "Sci-Fi" from collection 1 to book 1');
$collection->link($mhi, "Sci-Fi");
dbm_debug('info', 'Creating a relational link "guns" from collection 1 to book 1');
$collection->link($mhi, "guns");
dbm_debug('info', 'Creating a relational link "guns" from collection 1 to book 2');
$collection->link($aotr, "guns");
dbm_debug('info', 'Creating a blank link from collection 1 to book 3');
$collection->link($tram);
dbm_debug('info', 'Attempting to find all books labeled "Sci-Fi" (should just be Monster Hunter International)');
$books = $collection->getLinks('Book', 'Sci-Fi');
foreach ($books as $book) {
    $book->dumpview(true);
}
dbm_debug('info', 'Attempting to find all books labeled "guns" (should just be Monster Hunter International and Art of the Rifle)');
$books = $collection->getLinks('Book', 'guns');
foreach ($books as $book) {
    $book->dumpview(true);
开发者ID:rmbwebs,项目名称:amortize,代码行数:31,代码来源:test_generic.php


注:本文中的Collection::link方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。