public function plgVmAddToSearch(&$where, &$PluginJoinTables, $custom_id) { if ($keyword = vmRequest::uword('custom_specification_name1', null, ' ')) { $db = JFactory::getDBO(); if ($this->_name != $this->GetNameByCustomId($custom_id)) { return; } $keyword = '"%' . $db->getEscaped($keyword, true) . '%"'; $where[] = $this->_name . '.`custom_specification_default1` LIKE ' . $keyword; $PluginJoinTables[] = $this->_name; } return true; }
/** * This functions updates the variables of the model which are used in the sortSearchListQuery * with the variables from the Request * * @author Max Milbers */ function updateRequests() { //hmm how to trigger that in the module or so? $this->keyword = vmRequest::uword('keyword', "0", ' '); if ($this->keyword == "0") { $this->keyword = vmRequest::uword('filter_product', "0", ' '); } $app = JFactory::getApplication(); $option = 'com_virtuemart'; $view = 'product'; //Filter order and dir This is unecessary complex and maybe even wrong, but atm it seems to work if ($app->isSite()) { $filter_order = JRequest::getString('orderby', VmConfig::get('browse_orderby_field', 'p.virtuemart_product_id')); $filter_order = $this->checkFilterOrder($filter_order); $filter_order_Dir = strtoupper(JRequest::getWord('order', 'ASC')); $valid_search_fields = VmConfig::get('browse_search_fields'); } else { $filter_order = strtolower($app->getUserStateFromRequest('com_virtuemart.' . $view . '.filter_order', 'filter_order', $this->_selectedOrdering, 'cmd')); $filter_order = $this->checkFilterOrder($filter_order); $filter_order_Dir = strtoupper($app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word')); $valid_search_fields = array('product_name'); } $filter_order_Dir = $this->checkFilterDir($filter_order_Dir); $this->filter_order = $filter_order; $this->filter_order_Dir = $filter_order_Dir; $this->valid_search_fields = $valid_search_fields; $this->product_parent_id = JRequest::getInt('product_parent_id', false); $this->virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', false); $this->search_type = JRequest::getVar('search_type', ''); $this->searchcustoms = JRequest::getVar('customfields', array(), 'default', 'array'); $this->searchplugin = JRequest::getInt('custom_parent_id', 0); }
<th><?php echo $this->sort('product_weight', 'COM_VIRTUEMART_PRODUCT_INVENTORY_WEIGHT'); ?> </th> <th><?php echo $this->sort('published'); ?> </th> </tr> </thead> <tbody> <?php if (count($this->inventorylist) > 0) { $i = 0; $k = 0; $keyword = vmRequest::uword('keyword', "", ' ,-,+,.,_,#,/'); foreach ($this->inventorylist as $key => $product) { $checked = JHTML::_('grid.id', $i, $product->virtuemart_product_id); $published = JHTML::_('grid.published', $product, $i); //<!-- low_stock_notification --> if ($product->product_in_stock - $product->product_ordered < 1) { $stockstatut = "out"; } elseif ($product->product_in_stock - $product->product_ordered < $product->low_stock_notification) { $stockstatut = "low"; } else { $stockstatut = "normal"; } $stockstatut = 'class="stock-' . $stockstatut . '" title="' . jText::_('COM_VIRTUEMART_STOCK_LEVEL_' . $stockstatut) . '"'; ?> <tr class="row<?php echo $k;
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); $document = JFactory::getDocument(); // add javascript for price and cart vmJsApi::jPrice(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); /* Set the helper path */ $this->addHelperPath(JPATH_VM_ADMINISTRATOR . DS . 'helpers'); //Load helpers $this->loadHelper('image'); $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); $categoryId = JRequest::getInt('virtuemart_category_id', false); $vendorId = 1; $category = $categoryModel->getCategory($categoryId); $categoryModel->addImages($category, 1); $perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; // $categoryModel->setPerRow($perRow); $this->assignRef('perRow', $perRow); //No redirect here, category id = 0 means show ALL categories! note by Max Milbers /* if(empty($category->virtuemart_vendor_id) && $search == null ) { $app -> enqueueMessage(JText::_('COM_VIRTUEMART_CATEGORY_NOT_FOUND')); $app -> redirect( 'index.php'); }*/ // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id)); } } // static $counter = 0; // static $counter2 = 0; //if($category->children) $categoryModel->addImages($category->children); $categoryModel->addImages($category, 1); $cache = JFactory::getCache('com_virtuemart', 'callback'); $category->children = $cache->call(array('VirtueMartModelCategory', 'getChildCategoryList'), $vendorId, $categoryId); // self::$categoryTree = self::categoryListTreeLoop($selectedCategories, $cid, $level, $disabledFields); // vmTime('end loop categoryListTree '.$counter); $categoryModel->addImages($category->children, 1); if (VmConfig::get('enable_content_plugin', 0)) { // add content plugin // $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $category->text = $category->category_description; if (!class_exists('JParameter')) { require JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'parameter.php'; } $params = new JParameter(''); if (JVM_VERSION === 2) { $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.category', &$category, &$params, 0)); // More events for 3rd party content plugins // This do not disturb actual plugins, because we don't modify $product->text $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->afterDisplayTitle = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->beforeDisplayContent = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->afterDisplayContent = trim(implode("\n", $res)); } else { $results = $dispatcher->trigger('onPrepareContent', array(&$category, &$params, 0)); } $category->category_description = $category->text; } $this->assignRef('category', $category); // Set Canonic link if (!empty($tpl)) { $format = $tpl; } else { $format = JRequest::getWord('format', 'html'); } if ($format == 'html') { $document->addHeadLink(JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $categoryId), 'canonical', 'rel', ''); } // Set the titles if ($category->customtitle) { $title = strip_tags($category->customtitle); } elseif ($category->category_name) { $title = strip_tags($category->category_name); } else { $menus = $app->getMenu(); $menu = $menus->getActive(); if ($menu) { $title = $menu->title; } // $title = $this->params->get('page_title', ''); // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } } if (JRequest::getInt('error')) { $title .= ' ' . JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } // set search and keyword if ($keyword = vmRequest::uword('keyword', '', ' ')) { $pathway->addItem($keyword); $title .= ' (' . $keyword . ')'; } $search = JRequest::getvar('keyword', null); if ($search !== null) { $searchcustom = $this->getSearchCustom(); } $this->assignRef('keyword', $keyword); $this->assignRef('search', $search); // Load the products in the given category $products = $productModel->getProductsInCategory($categoryId); $productModel->addImages($products, 1); $this->assignRef('products', $products); foreach ($products as $product) { $product->stock = $productModel->getStockIndicator($product); } $ratingModel = VmModel::getModel('ratings'); $showRating = $ratingModel->showRating(); $this->assignRef('showRating', $showRating); $virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', 0); if ($virtuemart_manufacturer_id and !empty($products[0])) { $title .= ' ' . $products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if (JRequest::getInt('virtuemart_manufacturer_id') and !empty($products[0])) { $category->category_name = $products[0]->mf_name; } $pagination = $productModel->getPagination($perRow); $this->assignRef('vmPagination', $pagination); $orderByList = $productModel->getOrderByList($categoryId); $this->assignRef('orderByList', $orderByList); // $productRelatedManufacturerList = $productModel->getProductRelatedManufacturerList($categoryId); // $this->assignRef('productRelatedManufacturerList', $productRelatedManufacturerList); //$sortOrderButton = $productModel->getsortOrderButton(); //$this->assignRef('sortOrder', $sortOrderButton); if ($category->metadesc) { $document->setDescription($category->metadesc); } if ($category->metakey) { $document->setMetaData('keywords', $category->metakey); } if ($category->metarobot) { $document->setMetaData('robots', $category->metarobot); } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $category->metaauthor); } if ($products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); } if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); //set this after the $categoryId definition $paginationAction = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $categoryId); $this->assignRef('paginationAction', $paginationAction); shopFunctionsF::setLastVisitedCategoryId($categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); parent::display($tpl); }
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); // set search and keyword if ($keyword = vmRequest::uword('keyword', false, ' ,-,+,.,_')) { $pathway->addItem($keyword); //$title .=' ('.$keyword.')'; } //$search = VmRequest::uword('keyword', null); $this->searchcustom = ''; $this->searchcustomvalues = ''; if (!empty($keyword)) { $this->searchcustom = $this->getSearchCustom(); $search = $keyword; } else { $keyword = ''; $search = NULL; } $this->assignRef('search', $search); $this->assignRef('keyword', $keyword); $categoryId = JRequest::getInt('virtuemart_category_id', false); $virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', false); if ($categoryId === false and $virtuemart_manufacturer_id === false) { $categoryId = ShopFunctionsF::getLastVisitedCategoryId(); $catType = 'category'; $this->setCanonicalLink($tpl, $document, $categoryId, $catType); } else { if ($categoryId === false and $virtuemart_manufacturer_id) { $catType = 'manufacturer'; $this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType); } else { $catType = 'category'; $this->setCanonicalLink($tpl, $document, $categoryId, $catType); } } if ($categoryId !== -1) { $vendorId = 1; $category = $categoryModel->getCategory($categoryId); } if (!empty($category)) { if (empty($category->category_layout) or $category->category_layout != 'category') { // Load the products in the given category $ids = $productModel->sortSearchListQuery(TRUE, $categoryId); $perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; $this->assignRef('perRow', $perRow); $pagination = $productModel->getPagination($perRow); $this->assignRef('vmPagination', $pagination); $products = $productModel->getProducts($ids); //$products = $productModel->getProductsInCategory($categoryId); $productModel->addImages($products, 1); $this->assignRef('products', $products); if ($products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); foreach ($products as $product) { $product->stock = $productModel->getStockIndicator($product); } } $ratingModel = VmModel::getModel('ratings'); $showRating = $ratingModel->showRating(); $this->assignRef('showRating', $showRating); $orderByList = $productModel->getOrderByList($categoryId); $this->assignRef('orderByList', $orderByList); // Add feed links if ($products && VmConfig::get('feed_cat_published', 0) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); } //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers if (!empty($categoryId) and $categoryId !== -1 and (empty($category->slug) or !$category->published)) { if (empty($category->slug)) { vmInfo(JText::_('COM_VIRTUEMART_CAT_NOT_FOUND')); } else { if ($category->virtuemart_id !== 0 and !$category->published) { vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $categoryId); } } //Fallback $categoryLink = ''; if ($category->category_parent_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id; } else { $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (!$last_category_id or $categoryId == $last_category_id) { $last_category_id = JRequest::getInt('virtuemart_category_id', false); } if ($last_category_id and $categoryId != $last_category_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id; } } $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE)); return; } shopFunctionsF::setLastVisitedCategoryId($categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } } $categoryModel->addImages($category, 1); $cache = JFactory::getCache('com_virtuemart', 'callback'); $category->children = $cache->call(array('VirtueMartModelCategory', 'getChildCategoryList'), $vendorId, $categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir); $categoryModel->addImages($category->children, 1); if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description'); } if ($category->metadesc) { $document->setDescription($category->metadesc); } if ($category->metakey) { $document->setMetaData('keywords', $category->metakey); } if ($category->metarobot) { $document->setMetaData('robots', $category->metarobot); } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $category->metaauthor); } if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); } else { //Backward compatibility if (!isset($category)) { $category = new stdClass(); $category->category_name = ''; $category->category_description = ''; $category->haschildren = false; } } $this->assignRef('category', $category); // Set the titles if (!empty($category->customtitle)) { $title = strip_tags($category->customtitle); } elseif (!empty($category->category_name)) { $title = strip_tags($category->category_name); } else { $title = $this->setTitleByJMenu($app); } if (JRequest::getInt('error')) { $title .= ' ' . JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } if (!empty($keyword)) { $title .= ' (' . $keyword . ')'; } if ($virtuemart_manufacturer_id and !empty($products[0])) { $title .= ' ' . $products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if (JRequest::getInt('virtuemart_manufacturer_id') and !empty($products[0]) and isset($category->category_name)) { $category->category_name = $products[0]->mf_name; } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } parent::display($tpl); }
/** * This functions updates the variables of the model which are used in the sortSearchListQuery * with the variables from the Request * * @author Max Milbers */ function updateRequests() { //hmm how to trigger that in the module or so? $this->keyword = vmRequest::uword('keyword', "", ' ,-,+,.,_,#,/'); if ($this->keyword == "") { $this->keyword = vmRequest::uword('filter_product', "", ' ,-,+,.,_,#,/'); JRequest::setVar('filter_product', $this->keyword); JRequest::setVar('keyword', $this->keyword); } else { JRequest::setVar('keyword', $this->keyword); } $app = JFactory::getApplication(); $option = 'com_virtuemart'; $view = 'product'; if ($app->isSite()) { $filter_order = JRequest::getString('orderby', "0"); if ($filter_order == "0") { $filter_order_raw = $this->getLastProductOrdering($this->_selectedOrdering); $filter_order = $this->checkFilterOrder($filter_order_raw); } else { vmdebug('my $filter_order ', $filter_order); $filter_order = $this->checkFilterOrder($filter_order); vmdebug('my $filter_order after check', $filter_order); $this->setLastProductOrdering($filter_order); } $filter_order_Dir = strtoupper(JRequest::getWord('order', VmConfig::get('prd_brws_orderby_dir', 'ASC'))); $valid_search_fields = VmConfig::get('browse_search_fields'); } else { $filter_order = strtolower($app->getUserStateFromRequest('com_virtuemart.' . $view . '.filter_order', 'filter_order', $this->_selectedOrdering, 'cmd')); $filter_order = $this->checkFilterOrder($filter_order); $filter_order_Dir = strtoupper($app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word')); $valid_search_fields = $this->valid_BE_search_fields; } $filter_order_Dir = $this->checkFilterDir($filter_order_Dir); $this->filter_order = $filter_order; $this->filter_order_Dir = $filter_order_Dir; $this->valid_search_fields = $valid_search_fields; $this->product_parent_id = JRequest::getInt('product_parent_id', FALSE); $this->virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', FALSE); $this->search_type = JRequest::getVar('search_type', ''); $this->searchcustoms = JRequest::getVar('customfields', array(), 'default', 'array'); $this->searchplugin = JRequest::getInt('custom_parent_id', 0); }
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { JLoader::register('calculationHelper', JPATH_VM_ADMINISTRATOR . '/helpers/calculationh.php'); } $this->assignRef('show_prices', $show_prices); // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); JLoader::register('VmImage', JPATH_VM_ADMINISTRATOR . '/helpers/image.php'); $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); $search = JRequest::getvar('keyword', null); if ($search !== null) { $searchcustom = $this->getSearchCustom(); } $this->assignRef('keyword', $keyword); $this->assignRef('search', $search); $categoryId = JRequest::getInt('virtuemart_category_id', ShopFunctionsF::getLastVisitedCategoryId()); $virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', 0); $this->setCanonicalLink($tpl, $document, $categoryId); // $vendorId = JRequest::getInt('virtuemart_vendor_id', 1); $vendorId = JRequest::getInt('virtuemart_vendor_id', null); // Load the products in the given category $products = $productModel->getProductsInCategory($categoryId, $vendorId); $productModel->addImages($products, 1); $this->assignRef('products', $products); if ($products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); foreach ($products as $product) { $product->stock = $productModel->getStockIndicator($product); } } $ratingModel = VmModel::getModel('ratings'); $showRating = $ratingModel->showRating(); $this->assignRef('showRating', $showRating); $orderByList = $productModel->getOrderByList($categoryId); $this->assignRef('orderByList', $orderByList); // Add feed links if ($products && VmConfig::get('feed_cat_published', 0) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php'); $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); //set this after the $categoryId definition $paginationAction = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $categoryId, FALSE); $this->assignRef('paginationAction', $paginationAction); shopFunctionsF::setLastVisitedCategoryId($categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); if ($categoryId !== -1) { $vendorId = JRequest::getInt('virtuemart_vendor_id', 1); $category = $categoryModel->getCategory($categoryId); } $perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; $this->assignRef('perRow', $perRow); $pagination = $productModel->getPagination($perRow); $this->assignRef('vmPagination', $pagination); if (!empty($category)) { if (!empty($categoryId) and $categoryId !== -1 and (empty($category->slug) or !$category->published)) { if (empty($category->slug)) { vmInfo(JText::_('COM_VIRTUEMART_CAT_NOT_FOUND')); } else { if ($category->virtuemart_id !== 0 and !$category->published) { vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $categoryId); //return false; } } $categoryLink = ''; if ($category->category_parent_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id; } else { $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (!$last_category_id or $categoryId == $last_category_id) { $last_category_id = JRequest::getInt('virtuemart_category_id', false); } if ($last_category_id and $categoryId != $last_category_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id; } } $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE)); return; } //No redirect here, category id = 0 means show ALL categories! note by Max Milbers /* if(empty($category->virtuemart_vendor_id) && $search == null ) { $app -> enqueueMessage(JText::_('COM_VIRTUEMART_CATEGORY_NOT_FOUND')); $app -> redirect( 'index.php'); }*/ // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } } $categoryModel->addImages($category, 1); $cache = JFactory::getCache('com_virtuemart', 'callback'); $category->children = $cache->call(array('VirtueMartModelCategory', 'getChildCategoryList'), $vendorId, $categoryId); $categoryModel->addImages($category->children, 1); if (VmConfig::get('enable_content_plugin', 0)) { // add content plugin // $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $params = new JRegistry(); $category->event = new stdClass(); $category->catid = $category->virtuemart_category_id; $category->id = null; $category->title = $category->category_name; $category->text = $category->category_description; $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.category', &$category, &$params, 0)); // More events for 3rd party content plugins // This do not disturb actual plugins, because we don't modify $product->text $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->afterDisplayTitle = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->beforeDisplayContent = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->afterDisplayContent = trim(implode("\n", $res)); $category->category_description = $category->text; $category->category_name = $category->title; } if ($category->metadesc) { $document->setDescription($category->metadesc); } if ($category->metakey) { $document->setMetaData('keywords', $category->metakey); } if ($category->metarobot) { $document->setMetaData('robots', $category->metarobot); } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $category->metaauthor); } if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); } else { //Backward compatibility if (!isset($category)) { $category = new stdClass(); $category->category_name = ''; $category->category_description = ''; $category->haschildren = false; } } $this->assignRef('category', $category); // Set the titles if (!empty($category->customtitle)) { $title = strip_tags($category->customtitle); } elseif (!empty($category->category_name)) { $title = strip_tags($category->category_name); } else { $title = $this->setTitleByJMenu($app); } if (JRequest::getInt('error')) { $title .= ' ' . JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } if (!empty($keyword)) { $title .= ' (' . $keyword . ')'; } if ($virtuemart_manufacturer_id and !empty($products[0])) { $title .= ' ' . $products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if (JRequest::getInt('virtuemart_manufacturer_id') and !empty($products[0]) and isset($category->category_name)) { $category->category_name = $products[0]->mf_name; } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } // set search and keyword if ($keyword = vmRequest::uword('keyword', '0', ' ,-,+,.,_')) { $pathway->addItem($keyword); //$title .=' ('.$keyword.')'; } parent::display($tpl); }
/** * This functions updates the variables of the model which are used in the sortSearchListQuery * with the variables from the Request * * @author Max Milbers */ function updateRequests() { //hmm how to trigger that in the module or so? $this->keyword = vmRequest::uword('keyword', "0", ' ,-,+,.,_,#,/'); if ($this->keyword == "0") { $this->keyword = vmRequest::uword('filter_product', "0", ' ,-,+,.,_,#,/'); } $app = JFactory::getApplication(); $view = JRequest::getVar('view', 'virtuemart'); $isSite = JFactory::getApplication()->isSite() && $view !== 'product'; $option = 'com_virtuemart'; if ($isSite) { // This is bugged, orderby must be from session userfromrequest, because you cannot reset to default filter /* $filter_order = JRequest::getString ('orderby', null); if( !$filter_order){ $filter_order_raw = $this->getLastProductOrdering($this->_selectedOrdering); $filter_order = $this->checkFilterOrder ($filter_order_raw); } else { $filter_order = $this->checkFilterOrder ($filter_order); $this->setLastProductOrdering($filter_order); } */ // fix patrick Kohl, Studio42 $filter_order_Dir = strtoupper(JRequest::getWord('order', JRequest::getWord('filter_order_Dir', 'ASC'))); $filter_order = strtolower($app->getUserStateFromRequest('com_virtuemart.' . $view . '.order', 'order', $this->_selectedOrdering, 'cmd')); $filter_order = $this->checkFilterOrder($filter_order); $valid_search_fields = VmConfig::get('browse_search_fields'); } else { $filter_order = strtolower($app->getUserStateFromRequest('com_virtuemart.' . $view . '.filter_order', 'filter_order', $this->_selectedOrdering, 'cmd')); $filter_order = $this->checkFilterOrder($filter_order); $filter_order_Dir = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word'); $valid_search_fields = $this->valid_BE_search_fields; } $filter_order_Dir = $this->checkFilterDir($filter_order_Dir); $this->filter_order = $filter_order; $this->filter_order_Dir = $filter_order_Dir; $this->valid_search_fields = $valid_search_fields; $this->product_parent_id = JRequest::getInt('product_parent_id', FALSE); $this->virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', FALSE); $this->search_type = JRequest::getVar('search_type', ''); $this->searchcustoms = JRequest::getVar('customfields', array(), 'default', 'array'); $this->searchplugin = JRequest::getInt('custom_parent_id', 0); }