本文整理汇总了PHP中Meta::getMetaTags方法的典型用法代码示例。如果您正苦于以下问题:PHP Meta::getMetaTags方法的具体用法?PHP Meta::getMetaTags怎么用?PHP Meta::getMetaTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Meta
的用法示例。
在下文中一共展示了Meta::getMetaTags方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
//.........这里部分代码省略.........
$cart->id_shop = $this->context->shop->id;
if ($this->context->cookie->id_customer) {
$cart->id_customer = (int) $this->context->cookie->id_customer;
$cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
$cart->id_address_invoice = $cart->id_address_delivery;
} else {
$cart->id_address_delivery = 0;
$cart->id_address_invoice = 0;
}
// Needed if the merchant want to give a free product to every visitors
$this->context->cart = $cart;
CartRule::autoAddToCart($this->context);
} else {
$this->context->cart = $cart;
}
/* get page name to display it in body id */
// Are we in a payment module
$module_name = '';
if (Validate::isModuleName(Tools::getValue('module'))) {
$module_name = Tools::getValue('module');
}
if (!empty($this->page_name)) {
$page_name = $this->page_name;
} elseif (!empty($this->php_self)) {
$page_name = $this->php_self;
} elseif (Tools::getValue('fc') == 'module' && $module_name != '' && Module::getInstanceByName($module_name) instanceof PaymentModule) {
$page_name = 'module-payment-submit';
} elseif (preg_match('#^' . preg_quote($this->context->shop->physical_uri, '#') . 'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) {
$page_name = 'module-' . $m[1] . '-' . str_replace(array('.php', '/'), array('', '-'), $m[2]);
} else {
$page_name = Dispatcher::getInstance()->getController();
$page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name;
}
$this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name));
$this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
/* Breadcrumb */
$navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>';
$this->context->smarty->assign('navigationPipe', $navigationPipe);
// Automatically redirect to the canonical URL if needed
if (!empty($this->php_self) && !Tools::getValue('ajax')) {
$this->canonicalRedirection($this->context->link->getPageLink($this->php_self, $this->ssl, $this->context->language->id));
}
Product::initPricesComputation();
$display_tax_label = $this->context->country->display_tax_label;
if (isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) {
$infos = Address::getCountryAndState((int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$country = new Country((int) $infos['id_country']);
$this->context->country = $country;
if (Validate::isLoadedObject($country)) {
$display_tax_label = $country->display_tax_label;
}
}
$languages = Language::getLanguages(true, $this->context->shop->id);
$meta_language = array();
foreach ($languages as $lang) {
$meta_language[] = $lang['iso_code'];
}
$compared_products = array();
if (Configuration::get('PS_COMPARATOR_MAX_ITEM') && isset($this->context->cookie->id_compare)) {
$compared_products = CompareProduct::getCompareProducts($this->context->cookie->id_compare);
}
$this->context->smarty->assign(array('mobile_device' => $this->context->getMobileDevice(), 'link' => $link, 'cart' => $cart, 'currency' => $currency, 'cookie' => $this->context->cookie, 'page_name' => $page_name, 'hide_left_column' => !$this->display_column_left, 'hide_right_column' => !$this->display_column_right, 'base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__, 'content_dir' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__, 'base_uri' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__ . (!Configuration::get('PS_REWRITING_SETTINGS') ? 'index.php' : ''), 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'lang_iso' => $this->context->language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace(array('\'', '\\'), '', urldecode($_SERVER['REQUEST_URI']))), 'cart_qties' => (int) $cart->nbProducts(), 'currencies' => Currency::getCurrencies(), 'languages' => $languages, 'meta_language' => implode(',', $meta_language), 'priceDisplay' => Product::getTaxCalculationMethod((int) $this->context->cookie->id_customer), 'is_logged' => (bool) $this->context->customer->isLogged(), 'is_guest' => (bool) $this->context->customer->isGuest(), 'add_prod_display' => (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'roundMode' => (int) Configuration::get('PS_PRICE_ROUND_MODE'), 'use_taxes' => (int) Configuration::get('PS_TAX'), 'show_taxes' => (int) (Configuration::get('PS_TAX_DISPLAY') == 1 && (int) Configuration::get('PS_TAX')), 'display_tax_label' => (bool) $display_tax_label, 'vat_management' => (int) Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool) Configuration::get('PS_CATALOG_MODE') || !(bool) Group::getCurrent()->show_prices, 'b2b_enable' => (bool) Configuration::get('PS_B2B_ENABLE'), 'request' => $link->getPaginationLink(false, false, false, true), 'PS_STOCK_MANAGEMENT' => Configuration::get('PS_STOCK_MANAGEMENT'), 'quick_view' => (bool) Configuration::get('PS_QUICK_VIEW'), 'shop_phone' => Configuration::get('PS_SHOP_PHONE'), 'compared_products' => is_array($compared_products) ? $compared_products : array(), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM')));
// Add the tpl files directory for mobile
if ($this->useMobileTheme()) {
$this->context->smarty->assign(array('tpl_mobile_uri' => _PS_THEME_MOBILE_DIR_));
}
示例2: getMetaTags
/**
* @deprecated 1.5.0
*/
public static function getMetaTags($id_lang, $page_name, $title = '')
{
Tools::displayAsDeprecated();
return Meta::getMetaTags($id_lang, $page_name, $title);
}
示例3: ajaxCall
public function ajaxCall()
{
global $smarty, $cookie;
$selected_filters = $this->getSelectedFilters();
$filter_block = $this->getFilterBlock($selected_filters);
$this->getProducts($selected_filters, $products, $nb_products, $p, $n, $pages_nb, $start, $stop, $range, $combinations);
// Add pagination variable
$nArray = (int) Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50);
// Clean duplicate values
$nArray = array_unique($nArray);
asort($nArray);
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
$this->context->controller->addColorsToProductList($products);
}
$category = new Category(Tools::getValue('id_category_layered', Configuration::get('PS_HOME_CATEGORY')), (int) $cookie->id_lang);
// Generate meta title and meta description
$category_title = empty($category->meta_title) ? $category->name : $category->meta_title;
$category_metas = Meta::getMetaTags((int) $cookie->id_lang, 'category');
$title = '';
$keywords = '';
if (is_array($filter_block['title_values'])) {
foreach ($filter_block['title_values'] as $key => $val) {
$title .= ' > ' . $key . ' ' . implode('/', $val);
$keywords .= $key . ' ' . implode('/', $val) . ', ';
}
}
$title = $category_title . $title;
if (!empty($title)) {
$meta_title = $title;
} else {
$meta_title = $category_metas['meta_title'];
}
$meta_description = $category_metas['meta_description'];
$keywords = substr(strtolower($keywords), 0, 1000);
if (!empty($keywords)) {
$meta_keywords = rtrim($category_title . ', ' . $keywords . ', ' . $category_metas['meta_keywords'], ', ');
}
$smarty->assign(array('homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'nb_products' => $nb_products, 'category' => $category, 'pages_nb' => (int) $pages_nb, 'p' => (int) $p, 'n' => (int) $n, 'range' => (int) $range, 'start' => (int) $start, 'stop' => (int) $stop, 'n_array' => (int) Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'products' => $products, 'products_per_page' => (int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 'static_token' => Tools::getToken(false), 'page_name' => 'category', 'nArray' => $nArray, 'compareProducts' => CompareProduct::getCompareProducts((int) $this->context->cookie->id_compare), 'combinations' => $combinations));
// Prevent bug with old template where category.tpl contain the title of the category and category-count.tpl do not exists
if (file_exists(_PS_THEME_DIR_ . 'category-count.tpl')) {
$category_count = $smarty->fetch(_PS_THEME_DIR_ . 'category-count.tpl');
} else {
$category_count = '';
}
if ($nb_products == 0) {
$product_list = $this->display(__FILE__, 'blocklayered-no-products.tpl');
} else {
$product_list = $smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
}
$vars = array('filtersBlock' => utf8_encode($this->generateFiltersBlock($selected_filters)), 'productList' => utf8_encode($product_list), 'pagination' => $smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl'), 'categoryCount' => $category_count, 'meta_title' => $meta_title . ' - ' . Configuration::get('PS_SHOP_NAME'), 'heading' => $meta_title, 'meta_keywords' => isset($meta_keywords) ? $meta_keywords : null, 'meta_description' => $meta_description, 'current_friendly_url' => (int) $n == (int) $nb_products ? '#/show-all' : '#' . $filter_block['current_friendly_url'], 'filters' => $filter_block['filters'], 'nbRenderedProducts' => (int) $nb_products, 'nbAskedProducts' => (int) $n, 'combinations' => $combinations);
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
$vars = array_merge($vars, array('pagination_bottom' => $smarty->assign('paginationId', 'bottom')->fetch(_PS_THEME_DIR_ . 'pagination.tpl')));
}
/* We are sending an array in jSon to the .js controller, it will update both the filters and the products zones */
return Tools::jsonEncode($vars);
}
示例4: hookHeader
public function hookHeader($params)
{
global $smarty, $cookie;
// No filters => module disable
if ($filter_block = $this->getFilterBlock($this->getSelectedFilters())) {
if ($filter_block['nbr_filterBlocks'] == 0) {
return false;
}
}
if (Tools::getValue('id_category', Tools::getValue('id_category_layered', 1)) == 1) {
return;
}
$id_lang = (int) $cookie->id_lang;
$category = new Category((int) Tools::getValue('id_category'));
// Generate meta title and meta description
$category_title = empty($category->meta_title[$id_lang]) ? $category->name[$id_lang] : $category->meta_title[$id_lang];
$title = '';
$description = '';
$keywords = '';
if (is_array($filter_block['meta_values'])) {
foreach ($filter_block['meta_values'] as $key => $val) {
if (!empty($val['title'])) {
$val['title'] = $val['title'] . ' ';
}
foreach ($val['values'] as $value) {
$title .= $category_title . ' ' . $val['title'] . $value . ' - ';
$description .= $category_title . ' ' . $val['title'] . $value . ', ';
$keywords .= $val['title'] . $value . ', ';
}
}
}
// Title attributes (ex: <attr1> <value1>/<value2> - <attr2> <value1>)
$title = strtolower(rtrim(substr($title, 0, -3)));
// Title attributes (ex: <attr1> <value1>/<value2>, <attr2> <value1>)
$description = strtolower(rtrim(substr($description, 0, -2)));
// kewords attributes (ex: <attr1> <value1>, <attr1> <value2>, <attr2> <value1>)
$category_metas = Meta::getMetaTags($id_lang, 'category', $title);
if (!empty($title)) {
$smarty->assign('meta_title', ucfirst(substr($category_metas['meta_title'], 3)));
$smarty->assign('meta_description', $description . '. ' . $category_metas['meta_description']);
} else {
$smarty->assign('meta_title', $category_metas['meta_title']);
}
$keywords = substr(strtolower($keywords), 0, 1000);
if (!empty($keywords)) {
$smarty->assign('meta_keywords', rtrim($category_title . ', ' . $keywords . ', ' . $category_metas['meta_keywords'], ', '));
}
$this->context->controller->addJS($this->_path . 'blocklayered.js');
$this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/jquery-ui-1.8.10.custom.min.js');
$this->context->controller->addJQueryUI('ui.slider');
$this->context->controller->addCSS($this->_path . 'blocklayered-15.css', 'all');
$this->context->controller->addJQueryPlugin('scrollTo');
$filters = $this->getSelectedFilters();
// Get non indexable attributes
$attribute_group_list = Db::getInstance()->executeS('SELECT id_attribute_group FROM ' . _DB_PREFIX_ . 'layered_indexable_attribute_group WHERE indexable = 0');
// Get non indexable features
$feature_list = Db::getInstance()->executeS('SELECT id_feature FROM ' . _DB_PREFIX_ . 'layered_indexable_feature WHERE indexable = 0');
$attributes = array();
$features = array();
$blacklist = array('weight', 'price');
if (!Configuration::get('PS_LAYERED_FILTER_INDEX_CDT')) {
$blacklist[] = 'condition';
}
if (!Configuration::get('PS_LAYERED_FILTER_INDEX_QTY')) {
$blacklist[] = 'quantity';
}
if (!Configuration::get('PS_LAYERED_FILTER_INDEX_MNF')) {
$blacklist[] = 'manufacturer';
}
if (!Configuration::get('PS_LAYERED_FILTER_INDEX_CAT')) {
$blacklist[] = 'category';
}
foreach ($filters as $type => $val) {
switch ($type) {
case 'id_attribute_group':
foreach ($val as $attr) {
$attr_id = preg_replace('/_\\d+$/', '', $attr);
if (in_array($attr_id, $attributes) || in_array(array('id_attribute_group' => $attr_id), $attribute_group_list)) {
$smarty->assign('nobots', true);
$smarty->assign('nofollow', true);
return;
}
$attributes[] = $attr_id;
}
break;
case 'id_feature':
foreach ($val as $feat) {
$feat_id = preg_replace('/_\\d+$/', '', $feat);
if (in_array($feat_id, $features) || in_array(array('id_feature' => $feat_id), $feature_list)) {
$smarty->assign('nobots', true);
$smarty->assign('nofollow', true);
return;
}
$features[] = $feat_id;
}
break;
default:
if (in_array($type, $blacklist)) {
if (count($val)) {
$smarty->assign('nobots', true);
//.........这里部分代码省略.........
示例5: getTemplateVarPage
public function getTemplateVarPage()
{
$page_name = $this->getPageName();
$meta_tags = Meta::getMetaTags($this->context->language->id, $page_name);
$my_account_controllers = array('address', 'authentication', 'discount', 'history', 'identity', 'order-follow', 'order-slip', 'password', 'guest-tracking');
$body_classes = array('lang-' . $this->context->language->iso_code => true, 'lang-rtl' => (bool) $this->context->language->is_rtl, 'country-' . $this->context->country->iso_code => true, 'currency-' . $this->context->currency->iso_code => true, $this->context->shop->theme->getLayoutNameForPage($this->php_self) => true, 'page-' . $this->php_self => true, 'tax-display-' . ($this->getDisplayTaxesLabel() ? 'enabled' : 'disabled') => true);
if (in_array($this->php_self, $my_account_controllers)) {
$body_classes['page-customer-account'] = true;
}
$page = array('title' => '', 'canonical' => $this->getCanonicalURL(), 'meta' => array('title' => $meta_tags['meta_title'], 'description' => $meta_tags['meta_description'], 'keywords' => $meta_tags['meta_keywords'], 'robots' => 'index'), 'page_name' => $page_name, 'body_classes' => $body_classes, 'admin_notifications' => array());
return $page;
}