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


PHP Catalog::load_category方法代码示例

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


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

示例1: tag


//.........这里部分代码省略.........
                 foreach ($menuoptions as $value => $option) {
                     $label = $option;
                     $href = esc_url($link . '?' . $query . 'shopp_orderby=' . $value);
                     $string .= '<li><a href="' . $href . '">' . $label . '</a></li>';
                 }
             }
             return $string;
             break;
         case "breadcrumb":
             if (isset($Shopp->Category->controls)) {
                 return false;
             }
             if (empty($this->categories)) {
                 $this->load_categories();
             }
             $separator = "&nbsp;&raquo; ";
             if (isset($options['separator'])) {
                 $separator = $options['separator'];
             }
             $category = false;
             if (isset($Shopp->Cart->data->breadcrumb)) {
                 $category = $Shopp->Cart->data->breadcrumb;
             }
             $trail = false;
             $search = array();
             if (isset($Shopp->Cart->data->Search)) {
                 $search = array('search' => $Shopp->Cart->data->Search);
             }
             $path = explode("/", $category);
             if ($path[0] == "tag") {
                 $category = "tag";
                 $search = array('tag' => urldecode($path[1]));
             }
             $Category = Catalog::load_category($category, $search);
             if (!empty($Category->uri)) {
                 $type = "category";
                 if (isset($Category->tag)) {
                     $type = "tag";
                 }
                 if (SHOPP_PERMALINKS) {
                     $link = esc_url(add_query_arg($_GET, $Shopp->shopuri . $type . '/' . $Category->uri));
                 } else {
                     if (isset($Category->smart)) {
                         $link = esc_url(add_query_arg(array_merge($_GET, array('shopp_category' => $Category->slug, 'shopp_pid' => null)), $Shopp->shopuri));
                     } else {
                         $link = esc_url(add_query_arg(array_merge($_GET, array('shopp_category' => $Category->id, 'shopp_pid' => null)), $Shopp->shopuri));
                     }
                 }
                 $filters = false;
                 if (!empty($Shopp->Cart->data->Category[$Category->slug])) {
                     $filters = ' (<a href="?shopp_catfilters=cancel">' . __('Clear Filters', 'Shopp') . '</a>)';
                 }
                 if (!empty($Shopp->Product)) {
                     $trail .= '<li><a href="' . $link . '">' . $Category->name . (!$trail ? '' : $separator) . '</a></li>';
                 } elseif (!empty($Category->name)) {
                     $trail .= '<li>' . $Category->name . $filters . (!$trail ? '' : $separator) . '</li>';
                 }
                 // Build category names path by going from the target category up the parent chain
                 $parentkey = !empty($Category->id) ? $this->categories[$Category->id]->parent : 0;
                 while ($parentkey != 0) {
                     $tree_category = $this->categories[$parentkey];
                     if (SHOPP_PERMALINKS) {
                         $link = $Shopp->shopuri . 'category/' . $tree_category->uri;
                     } else {
                         $link = esc_url(add_query_arg(array_merge($_GET, array('shopp_category' => $tree_category->id, 'shopp_pid' => null)), $Shopp->shopuri));
                     }
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:67,代码来源:Catalog.php

示例2: tag


//.........这里部分代码省略.........
					foreach($menuoptions as $value => $option) {
						$label = $option;
						$href = esc_url($link.'?'.$query.'ecart_orderby='.$value);
						$string .= '<li><a href="'.$href.'">'.$label.'</a></li>';
					}

				}
				return $string;
				break;
			case "breadcrumb":

				$defaults = array(
					'separator' => '&nbsp;&raquo; ',
					'depth'		=> 7
				);
				$options = array_merge($defaults,$options);
				extract($options);

				if (isset($Ecart->Category->controls)) return false;
				if (empty($this->categories)) $this->load_categories(array('outofstock' => true));

				$category = false;
				if (isset($Ecart->Flow->Controller->breadcrumb))
					$category = $Ecart->Flow->Controller->breadcrumb;

				$trail = false;
				$search = array();
				if (isset($Ecart->Flow->Controller->search)) $search = array('search'=>$Ecart->Flow->Controller->search);
				$path = explode("/",$category);
				if ($path[0] == "tag") {
					$category = "tag";
					$search = array('tag'=>urldecode($path[1]));
				}
				$Category = Catalog::load_category($category,$search);

				if (!empty($Category->uri)) {
					$type = "category";
					if (isset($Category->tag)) $type = "tag";

					$category_uri = isset($Category->smart)?$Category->slug:$Category->id;

					$link = ECART_PRETTYURLS?
						ecarturl("$type/$Category->uri") :
						ecarturl(array_merge($_GET,array('ecart_category'=>$category_uri,'ecart_pid'=>null)));

					$filters = false;
					if (!empty($Ecart->Cart->data->Category[$Category->slug]))
						$filters = ' (<a href="?ecart_catfilters=cancel">'.__('Clear Filters','Ecart').'</a>)';

					if (!empty($Ecart->Product))
						$trail .= '<li><a href="'.$link.'">'.$Category->name.(!$trail?'':$separator).'</a></li>';
					elseif (!empty($Category->name))
						$trail .= '<li>'.$Category->name.$filters.(!$trail?'':$separator).'</li>';

					// Build category names path by going from the target category up the parent chain
					$parentkey = (!empty($Category->id)
						&& isset($this->categories['_'.$Category->id]->parent)?
							'_'.$this->categories['_'.$Category->id]->parent:'_0');

					while ($parentkey != '_0' && $depth-- > 0) {
						$tree_category = $this->categories[$parentkey];

						$link = ECART_PRETTYURLS?
							ecarturl("category/$tree_category->uri"):
							ecarturl(array_merge($_GET,array('ecart_category'=>$tree_category->id,'ecart_pid'=>null)));
开发者ID:robbiespire,项目名称:paQui,代码行数:66,代码来源:Catalog.php

示例3: catalog

	/**
	 * Parses catalog page requests
	 *	 
	 * @since 1.1
	 *
	 * @return void
	 **/
	function catalog () {
		global $Ecart,$wp;

		$options = array();

		add_filter('redirect_canonical', array(&$this,'canonical_home'));

		$type = "catalog";
		if (isset($wp->query_vars['ecart_category']) &&
			$category = urldecode($wp->query_vars['ecart_category'])) $type = "category";
		elseif (isset($wp->query_vars['ecart_pid']) &&
			$productid = $wp->query_vars['ecart_pid']) $type = "product";
		elseif (isset($wp->query_vars['ecart_product']) &&
			$productname = urldecode($wp->query_vars['ecart_product'])) $type = "product";

		if (isset($wp->query_vars['ecart_tag']) &&
			$tag = $wp->query_vars['ecart_tag']) {
			$type = "category";
			$category = "tag";
		}

		// If a search query is stored, and this request is a product or the
		// search results category repopulate the search box and set the
		// category for the breadcrumb
		if (!empty($this->search)
				&& ($type == "product"
				|| ($type == "category" && $category == "search-results"))) {
			add_action('wp_head', array(&$this, 'updatesearch'));
			$category = "search-results";
		} else $this->search = $this->searching = false;

		// If a search request is being made, set the type to category
		if ($this->searching) {
			if ($type != "product") $type = "category";
			$category = "search-results";
		}

		// Load a category/tag
		if (!empty($category) || !empty($tag)) {
			if (isset($this->search)) $options = array('search'=>$this->search);
			if (isset($tag)) $options = array('tag'=>$tag);

			// Split for encoding multi-byte slugs
			$slugs = explode("/",$category);
			$category = join("/",array_map('urlencode',$slugs));

			// Load the category
			$Ecart->Category = Catalog::load_category($category,$options);
			$this->breadcrumb = (isset($tag)?"tag/":"").$Ecart->Category->uri;

			if (!empty($this->searching)) {
				$Ecart->Category->load_products(array('load'=>array('images','prices')));
				if (count($Ecart->Category->products) == 1) {
					reset($Ecart->Category->products);
					$type = 'product';
					$BestBet = current($Ecart->Category->products);
					ecart_redirect($BestBet->tag('url',array('return'=>true)));
				}
			}
		}

		if (empty($category) && empty($tag) &&
			empty($productid) && empty($productname))
			$this->breadcrumb = "";

		// Category Filters
		if (!empty($Ecart->Category->slug)) {
			if (empty($this->browsing[$Ecart->Category->slug]))
				$this->browsing[$Ecart->Category->slug] = array();
			$CategoryFilters =& $this->browsing[$Ecart->Category->slug];

			// Add new filters
			if (isset($_GET['ecart_catfilters'])) {
				if (is_array($_GET['ecart_catfilters'])) {
					$CategoryFilters = array_filter(array_merge($CategoryFilters,$_GET['ecart_catfilters']));
					$CategoryFilters = stripslashes_deep($CategoryFilters);
					if (isset($wp->query_vars['paged'])) $wp->query_vars['paged'] = 1; // Force back to page 1
				} else unset($this->browsing[$Ecart->Category->slug]);
			}

		}

		// Catalog sort order setting
		if (isset($_GET['ecart_orderby']))
			$this->browsing['orderby'] = $_GET['ecart_orderby'];

		// Set the category context by following the breadcrumb
		if (empty($Ecart->Category->slug)) $Ecart->Category = Catalog::load_category($this->breadcrumb,$options);

		// No category context, use the CatalogProducts smart category
		if (empty($Ecart->Category->slug)) $Ecart->Category = Catalog::load_category('catalog',$options);

		// Find product by given ID
//.........这里部分代码省略.........
开发者ID:robbiespire,项目名称:paQui,代码行数:101,代码来源:Storefront.php

示例4: catalog

 function catalog($wp)
 {
     $pages = $this->Settings->get('pages');
     $options = array();
     $type = "catalog";
     if (isset($wp->query_vars['shopp_category']) && ($category = $wp->query_vars['shopp_category'])) {
         $type = "category";
     }
     if (isset($wp->query_vars['shopp_pid']) && ($productid = $wp->query_vars['shopp_pid'])) {
         $type = "product";
     }
     if (isset($wp->query_vars['shopp_product']) && ($productname = $wp->query_vars['shopp_product'])) {
         $type = "product";
     }
     if (isset($wp->query_vars['shopp_tag']) && ($tag = $wp->query_vars['shopp_tag'])) {
         $type = "category";
         $category = "tag";
     }
     $referer = wp_get_referer();
     $target = "blog";
     if (isset($wp->query_vars['st'])) {
         $target = $wp->query_vars['st'];
     }
     if (!empty($wp->query_vars['s']) && ($target == "shopp" || strpos($referer, $this->link('catalog')) !== false || strpos($referer, 'page_id=' . $pages['catalog']['id']) !== false || substr($referer, -1 * strlen($this->Cart->data->Search)) == $this->Cart->data->Search || trailingslashit(get_bloginfo('url')) == $this->link('catalog') || $referer == $this->link('cart') || $referer == $this->link('checkout') || $referer == $this->link('account'))) {
         $this->Cart->data->Search = $wp->query_vars['s'];
         $wp->query_vars['s'] = "";
         $wp->query_vars['pagename'] = $pages['catalog']['name'];
         add_action('wp_head', array(&$this, 'updatesearch'));
         if ($type != "product") {
             $type = "category";
         }
         $category = "search-results";
     }
     // Load a category/tag
     if (!empty($category) || !empty($tag)) {
         if (isset($this->Cart->data->Search)) {
             $options = array('search' => $this->Cart->data->Search);
         }
         if (isset($tag)) {
             $options = array('tag' => $tag);
         }
         // Split for encoding multi-byte slugs
         $slugs = explode("/", $category);
         $category = join("/", array_map('urlencode', $slugs));
         // Load the category
         $this->Category = Catalog::load_category($category, $options);
         $this->Cart->data->breadcrumb = (isset($tag) ? "tag/" : "") . $this->Category->uri;
     }
     if (empty($category) && empty($tag) && empty($productid) && empty($productname)) {
         $this->Cart->data->breadcrumb = "";
     }
     // Category Filters
     if (!empty($this->Category->slug)) {
         if (empty($this->Cart->data->Category[$this->Category->slug])) {
             $this->Cart->data->Category[$this->Category->slug] = array();
         }
         $CategoryFilters =& $this->Cart->data->Category[$this->Category->slug];
         // Add new filters
         if (isset($_GET['shopp_catfilters'])) {
             if (is_array($_GET['shopp_catfilters'])) {
                 $CategoryFilters = array_filter(array_merge($CategoryFilters, $_GET['shopp_catfilters']));
                 $CategoryFilters = stripslashes_deep($CategoryFilters);
                 if (isset($wp->query_vars['paged'])) {
                     $wp->query_vars['paged'] = 1;
                 }
                 // Force back to page 1
             } else {
                 unset($this->Cart->data->Category[$this->Category->slug]);
             }
         }
     }
     // Catalog sort order setting
     if (isset($_GET['shopp_orderby'])) {
         $this->Cart->data->Category['orderby'] = $_GET['shopp_orderby'];
     }
     if (empty($this->Category)) {
         $this->Category = Catalog::load_category($this->Cart->data->breadcrumb, $options);
     }
     // Find product by given ID
     if (!empty($productid) && empty($this->Product->id)) {
         $this->Product = new Product($productid);
     }
     // Find product by product slug
     if (!empty($productname) && empty($this->Product->id)) {
         $this->Product = new Product(urlencode($productname), "slug");
     }
     // Product must be published
     if (!empty($this->Product->id) && $this->Product->published == "off" || empty($this->Product->id)) {
         $this->Product = false;
     }
     // No product found, try to load a page instead
     if ($type == "product" && !$this->Product) {
         $wp->query_vars['pagename'] = $wp->request;
     }
     $this->Catalog = new Catalog($type);
     add_filter('wp_title', array(&$this, 'titles'), 10, 3);
     add_action('wp_head', array(&$this, 'metadata'));
     add_action('wp_head', array(&$this, 'feeds'));
 }
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:99,代码来源:Shopp.php


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