Skip to content

Commit

Permalink
enhacing
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidpeywasti committed Jan 2, 2015
1 parent 81a2b03 commit 6629950
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 53 deletions.
7 changes: 6 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@
)
));


/**
* Hooks
* Register hook to add carpets items to the indexer
*/
$GLOBALS['TL_HOOKS']['getSearchablePages'][] = array('Catalog', 'getSearchablePages');

/**
* Hooks
*/
$GLOBALS['TL_HOOKS']['translateUrlParameters'][] = array('Catalog', 'translateUrlParameters');

14 changes: 7 additions & 7 deletions dca/tl_catalog_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@
'palettes' => array
(
'__selector__' => array('addEnclosure','published'),
'default' => '{title_legend},title,alias,model;
{config_legend},date,featured;
{meta_legend},description,keywords;
'default' => '{title_legend},title,alias,model,date,featured;
{image_legend},singleSRC;
{meta_legend},keywords,description;
{feature_legend},features;
{spec_legend},spec;
{image_legend},singleSRC;
{enclosure_legend:hide},addEnclosure;
{publish_legend},published'
),
Expand Down Expand Up @@ -224,7 +224,7 @@
'exclude' => true,
'inputType' => 'textarea',
'search' => true,
'eval' => array('style'=>'height:60px', 'decodeEntities'=>true),
'eval' => array('decodeEntities'=>true),
'sql' => "text NULL"
),
'description' => array
Expand All @@ -233,7 +233,7 @@
'exclude' => true,
'inputType' => 'textarea',
'search' => true,
'eval' => array('style'=>'height:60px', 'decodeEntities'=>true, 'tl_class'=>'clr'),
'eval' => array('rte'=>'tinyMCE','tl_class'=>'clr'),
'sql' => "text NULL"
),
'features' => array
Expand All @@ -242,7 +242,7 @@
'exclude' => true,
'sorting' => true,
'inputType' => 'listWizard',
'eval' => array('tl_class'=>'w50 m12'),
'eval' => array(),
'sql' => "blob NULL",
),
'spec' => array
Expand Down
38 changes: 24 additions & 14 deletions dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/

$GLOBALS['TL_DCA']['tl_module']['palettes']['catalog_list'] = '{title_legend},name,headline,type;
{catalog_legend},catalog_categories;
{config_legend},catalog_featured,catalog_detailModule,numberOfItems,perPage,skipFirst;
{catalog_legend},catalog_categories,catalog_featured,catalog_detailModule,catalog_sortBy,numberOfItems,perPage,skipFirst;
{template_legend},catalog_metaFields,product_template,customTpl;
{product_legend},product_Class,imgSize;
{protected_legend:hide},protected;
Expand Down Expand Up @@ -50,33 +49,35 @@
'eval' => array('multiple'=>true, 'mandatory'=>true),
'sql' => "blob NULL"
);
$GLOBALS['TL_DCA']['tl_module']['fields']['product_template'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['product_template'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => array('tl_module_catalog', 'getProductTemplates'),
'eval' => array('tl_class'=>'w50'),
'sql' => "varchar(64) NOT NULL default ''"
);
$GLOBALS['TL_DCA']['tl_module']['fields']['catalog_featured'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['catalog_featured'],
'default' => 'all',
'default' => 'all_product',
'exclude' => true,
'inputType' => 'select',
'options' => array('all', 'featured', 'unfeatured'),
'options' => array('all_product', 'featured_product', 'unfeatured_product'),
'reference' => &$GLOBALS['TL_LANG']['tl_module'],
'eval' => array('tl_class'=>'w50'),
'sql' => "varchar(20) NOT NULL default ''"
);
$GLOBALS['TL_DCA']['tl_module']['fields']['catalog_sortBy'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['catalog_sortBy'],
'default' => 'custom',
'exclude' => true,
'inputType' => 'select',
'options' => array('custom','title_asc', 'title_desc', 'date_asc', 'date_desc'),
'reference' => &$GLOBALS['TL_LANG']['tl_module'],
'eval' => array('tl_class'=>'w50'),
'sql' => "varchar(16) NOT NULL default ''"
);
$GLOBALS['TL_DCA']['tl_module']['fields']['catalog_metaFields'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['catalog_metaFields'],
'default' => array('date'),
'exclude' => true,
'inputType' => 'checkbox',
'options' => array('date'),
'options' => array('date','price','rating'),
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('multiple'=>true),
'sql' => "varchar(255) NOT NULL default ''"
Expand All @@ -91,6 +92,15 @@
'eval' => array('includeBlankOption'=>true, 'tl_class'=>'w50'),
'sql' => "int(10) unsigned NOT NULL default '0'"
);
$GLOBALS['TL_DCA']['tl_module']['fields']['product_template'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['product_template'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => array('tl_module_catalog', 'getProductTemplates'),
'eval' => array('tl_class'=>'w50'),
'sql' => "varchar(64) NOT NULL default ''"
);
$GLOBALS['TL_DCA']['tl_module']['fields']['product_Class'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['product_Class'],
Expand Down
3 changes: 3 additions & 0 deletions languages/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
* Miscellaneous
*/
$GLOBALS['TL_LANG']['MSC']['emptyCatalog']='There is no product items!';

$GLOBALS['TL_LANG']['MSC']['price'] = 'Price';
$GLOBALS['TL_LANG']['MSC']['rating'] = 'Rating';
4 changes: 4 additions & 0 deletions languages/en/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@
$GLOBALS['TL_LANG']['FMD']['catalog_list'] = array('Product list', '');
$GLOBALS['TL_LANG']['FMD']['catalog_detail'] = array('Product detail', '');
$GLOBALS['TL_LANG']['FMD']['catalog_related'] = array('Related product', '');

$GLOBALS['TL_LANG']['tl_module']['all_product'] = 'All products';
$GLOBALS['TL_LANG']['tl_module']['featured_product'] = 'Featured products';
$GLOBALS['TL_LANG']['tl_module']['unfeatured_product'] = 'Unfeatured products';
2 changes: 1 addition & 1 deletion languages/en/tl_catalog_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$GLOBALS['TL_LANG']['tl_catalog_category']['jumpTo'] = array('Redirect page', 'Please choose the list page to which visitors will be redirected when clicking a menu.');
$GLOBALS['TL_LANG']['tl_catalog_category']['protected'] = array('Protect category', 'Show category items to certain member groups only.');
$GLOBALS['TL_LANG']['tl_catalog_category']['groups'] = array('Allowed member groups', 'These groups will be able to see the menu items in this catalog.');
$GLOBALS['TL_LANG']['tl_catalog_category']['master'] = array('Master archive', 'Please define the master category to allow language switching.');
$GLOBALS['TL_LANG']['tl_catalog_category']['master'] = array('Master category', 'Please define the master category to allow language switching.');
$GLOBALS['TL_LANG']['tl_catalog_category']['language'] = array('Language', 'Please enter the language according to the RFC3066 format (e.g. en, en-us or en-cockney).');


Expand Down
10 changes: 1 addition & 9 deletions languages/en/tl_catalog_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@
$GLOBALS['TL_LANG']['tl_catalog_product']['date'] = array('Date', 'Please enter date.');
$GLOBALS['TL_LANG']['tl_catalog_product']['description'] = array('Description','Please enter description.');
$GLOBALS['TL_LANG']['tl_catalog_product']['keywords'] = array('Meta keywords','Here you can enter a list of comma separated keywords. Keywords, however, are no longer relevant to most search engines (including Google).');
$GLOBALS['TL_LANG']['tl_catalog_product']['tableitems'] = array('Table items', 'If JavaScript is disabled, make sure to save your changes before modifying the order.');
$GLOBALS['TL_LANG']['tl_catalog_product']['summary'] = array('Table summary', 'Please enter a short summary of the table and describe its purpose or structure.');
$GLOBALS['TL_LANG']['tl_catalog_product']['thead'] = array('Add table header', 'Make the first row of the table the table header.');
$GLOBALS['TL_LANG']['tl_catalog_product']['tfoot'] = array('Add table footer', 'Make the last row of the table the table footer.');
$GLOBALS['TL_LANG']['tl_catalog_product']['tleft'] = array('Use row headers', 'Define the left column as row header.');
$GLOBALS['TL_LANG']['tl_catalog_product']['spec'] = array('Specifications','Please eneter the product specifications.');
$GLOBALS['TL_LANG']['tl_catalog_product']['features'] = array('Features','Please eneter the product features.');
$GLOBALS['TL_LANG']['tl_catalog_product']['spectitle'] = array('Title','Specifications title');
$GLOBALS['TL_LANG']['tl_catalog_product']['specvalue'] = array('Value','Specifications value');
$GLOBALS['TL_LANG']['tl_catalog_product']['addImage'] = array('Add an image', 'Add an image to the category item.');
$GLOBALS['TL_LANG']['tl_catalog_product']['singleSRC'] = array('Source file','Please select an image.');
$GLOBALS['TL_LANG']['tl_catalog_product']['addEnclosure']= array('Add enclosures', 'Add one or more downloadable files to the news item.');
$GLOBALS['TL_LANG']['tl_catalog_product'][ 'enclosure'] = array('Enclosures', 'Please choose the files you want to attach.');
$GLOBALS['TL_LANG']['tl_catalog_product']['protected'] = array('Protect product','Show product items to certain member groups only.');
$GLOBALS['TL_LANG']['tl_catalog_product']['groups'] = array('Allowed member groups','');
$GLOBALS['TL_LANG']['tl_catalog_product']['enclosure'] = array('Enclosures', 'Please choose the files you want to attach.');
$GLOBALS['TL_LANG']['tl_catalog_product']['published'] = array('Publish product','Make the product item publicly visible on the website.');
$GLOBALS['TL_LANG']['tl_catalog_product']['featured'] = array('Feature product','Show the product item in a featured list.');
$GLOBALS['TL_LANG']['tl_catalog_product']['start'] = array('Show from','Do not show the product item on the website before this day.');
Expand Down
13 changes: 10 additions & 3 deletions languages/en/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
$GLOBALS['TL_LANG']['tl_module']['catalog_featured'] = array('Featured product', 'Here you can choose how featured items are handled.');
$GLOBALS['TL_LANG']['tl_module']['catalog_detailModule'] = array('Product detail module', 'Automatically switch to the product module if an item has been selected.');
$GLOBALS['TL_LANG']['tl_module']['catalog_metaFields'] = array('Meta fields', 'Here you can select the meta fields.');
$GLOBALS['TL_LANG']['tl_module']['catalog_sortBy'] = array('Sort by', 'Here you can select the sorting fields.');
$GLOBALS['TL_LANG']['tl_module']['product_template'] = array('Catalog template', 'Here you can select the catalog template.');
$GLOBALS['TL_LANG']['tl_module']['product_Class'] = array('Product CSS class', 'Here you can set one or more classes for products.');
$GLOBALS['TL_LANG']['tl_module']['type_Class'] = array('Type CSS class', 'Here you can set one or more classes for types.');
$GLOBALS['TL_LANG']['tl_module']['type_ImageSize'] = array('Type image width and height', 'Here you can set the image dimensions and the resize mode.');
$GLOBALS['TL_LANG']['tl_module']['product_Class'] = array('Product CSS class', 'Here you can set one or more classes for products.');
$GLOBALS['TL_LANG']['tl_module']['type_Class'] = array('Type CSS class', 'Here you can set one or more classes for types.');
$GLOBALS['TL_LANG']['tl_module']['type_ImageSize'] = array('Type image width and height', 'Here you can set the image dimensions and the resize mode.');


/**
Expand All @@ -41,3 +42,9 @@
$GLOBALS['TL_LANG']['tl_module']['all_customers'] = 'All customers';
$GLOBALS['TL_LANG']['tl_module']['feature_customers'] = 'Only feature customers';
$GLOBALS['TL_LANG']['tl_module']['unfeature_customers'] = 'Unfeature customers';

$GLOBALS['TL_LANG']['tl_module']['custom'] = 'Custom order';
$GLOBALS['TL_LANG']['tl_module']['title_asc'] = 'Title (A-Z)';
$GLOBALS['TL_LANG']['tl_module']['title_desc'] = 'Title (Z-A)';
$GLOBALS['TL_LANG']['tl_module']['date_asc'] = 'Date (Newer)';
$GLOBALS['TL_LANG']['tl_module']['date_desc'] = 'Date (Older)';
8 changes: 0 additions & 8 deletions modules/ModuleCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,12 @@ protected function parseProduct($objProduct, $blnAddCategory=false, $strClass=''
$objTemplate->class = (($this->product_Class != '') ? ' ' . $this->product_Class : '') . $strClass;
$objTemplate->type_Class = $this->type_Class;

$objTemplate->title = $objProduct->title;
$objTemplate->alias = $objProduct->alias;
$objTemplate->model = $objProduct->model;

if (!empty($objProduct->features))
{
$objTemplate->features = deserialize($objProduct->features);
}
$objTemplate->specs = deserialize($objProduct->spec);

$objTemplate->description = $objProduct->description;
$objTemplate->keywords = $objProduct->keywords;

$objTemplate->link = $this->generateSetUrl($objProduct, $blnAddCategory);
$objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['moredetail'], $objProduct, $blnAddCategory, true);

Expand All @@ -119,7 +112,6 @@ protected function parseProduct($objProduct, $blnAddCategory=false, $strClass=''
$objTemplate->category = $objProduct->getRelated('pid');

$objTemplate->count = $intCount; // see #5708
$objTemplate->text = '';

$arrMeta = $this->getMetaFields($objProduct);

Expand Down
7 changes: 3 additions & 4 deletions modules/ModuleCatalogDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ public function generate()

// Set the item from the auto_item parameter
if (!isset($_GET['items']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item']))
{
{
\Input::setGet('items', \Input::get('auto_item'));
}

$this->catalog_categories = $this->sortOutProtected(deserialize($this->catalog_categories));
}

$this->catalog_categories = $this->sortOutProtected(deserialize($this->catalog_categories));

return parent::generate();
}
Expand Down
35 changes: 29 additions & 6 deletions modules/ModuleCatalogList.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ protected function compile()
}

// Handle featured news
if ($this->catalog_featured == 'featured')
if ($this->catalog_featured == 'featured_product')
{
$blnFeatured = true;
}
elseif ($this->catalog_featured == 'unfeatured')
elseif ($this->catalog_featured == 'unfeatured_product')
{
$blnFeatured = false;
}
Expand All @@ -103,7 +103,7 @@ protected function compile()
$this->Template->products = array();
$this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyCatalog'];

$intTotal = \CatalogProductModel::countPublishedByPids($this->catalog_categories);
$intTotal = \CatalogProductModel::countPublishedByPids($this->catalog_categories,$blnFeatured);

if ($intTotal < 1)
{
Expand Down Expand Up @@ -154,14 +154,37 @@ protected function compile()
$this->Template->pagination = $objPagination->generate("\n ");
}

$arrOptions = array();
if ($this->catalog_sortBy)
{
switch ($this->catalog_sortBy)
{
case 'title_asc':
$arrOptions['order'] = "title ASC";
break;
case 'title_desc':
$arrOptions['order'] = "title DESC";
break;
case 'date_asc':
$arrOptions['order'] = "date ASC";
break;
case 'date_desc':
$arrOptions['order'] = "date DESC";
break;
case 'custom':
$arrOptions['order'] = "sorting ASC";
break;
}
}

// Get the items
if (isset($limit))
{
$objProducts = \CatalogProductModel::findPublishedByPids($this->catalog_categories, $blnFeatured, $limit, $offset);
$objProducts = \CatalogProductModel::findPublishedByPids($this->catalog_categories, $blnFeatured, $limit, $offset, $arrOptions);
}
else
{
$objProducts = \CatalogProductModel::findPublishedByPids($this->catalog_categories, $blnFeatured, 0, $offset);
$objProducts = \CatalogProductModel::findPublishedByPids($this->catalog_categories, $blnFeatured, 0, $offset, $arrOptions);
}


Expand All @@ -171,7 +194,7 @@ protected function compile()
$this->Template->products = $this->parseProducts($objProducts);
}

$this->Template->gategories = $this->catalog_categories;
$this->Template->categories = $this->catalog_categories;

}
}

0 comments on commit 6629950

Please sign in to comment.