Skip to content

Instantly share code, notes, and snippets.

@iamphill

iamphill/head.phtml

Last active Sep 28, 2015
Embed
What would you like to do?
Magento head
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title><?php echo $this->getTitle(); ?></title>
<meta name="description" content="<?php echo htmlspecialchars( $this->getDescription() ); ?>">
<meta name="keywords" content="<?php echo $this->getKeywords(); ?>">
<?php $_currentProduct = Mage::registry('current_product'); ?>
<?php if ($_currentProduct) { ?>
<meta http-equiv="last-modified" content="<?php echo date("Y-m-d@H:i:s e", strtotime($_currentProduct->getUpdatedAt())); ?>" />
<?php } ?>
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="<?php echo Mage::getStoreConfig('yoma_socialmedia/general/twitter', Mage::app()->getStore()); ?>" />
<meta name="twitter:creator" content="<?php echo Mage::getStoreConfig('yoma_socialmedia/general/twitter', Mage::app()->getStore()); ?>" />
<meta name="twitter:title" content="<?php echo $this->getTitle(); ?>" />
<meta name="twitter:description" content="<?php echo htmlspecialchars($this->getDescription()); ?>" />
<?php if ($_currentProduct) { ?>
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:image:src" content="<?php echo $_currentProduct->getImageUrl(); ?>" />
<meta property="twitter:image:width" content="<?php echo $this->helper('catalog/image')->init($_currentProduct, 'image')->getOriginalWidth(); ?>">
<meta property="twitter:image:height" content="<?php echo $this->helper('catalog/image')->init($_currentProduct, 'image')->getOriginalHeight(); ?>">
<?php } ?>
<meta property="og:url" content="<?php echo Mage::getBaseUrl(); ?>" />
<meta property="og:site_name" content="<?php echo Mage::app()->getStore()->getName(); ?>" />
<meta property="og:title" content="<?php echo $this->getTitle(); ?>" />
<meta property="og:description" content="<?php echo htmlspecialchars($this->getDescription()); ?>" />
<meta property="og:locale" content="<?php echo Mage::app()->getLocale()->getLocaleCode(); ?>" />
<?php if ($_currentProduct) { ?>
<meta property="og:image" content="<?php echo $_currentProduct->getImageUrl(); ?>" />
<meta property="og:image:width" content="<?php echo $this->helper('catalog/image')->init($_currentProduct, 'image')->getOriginalWidth(); ?>" />
<meta property="og:image:height" content="<?php echo $this->helper('catalog/image')->init($_currentProduct, 'image')->getOriginalHeight(); ?>" />
<?php } ?>
<meta name="robots" content="<?php echo $this->getRobots(); ?>" />
<link rel="canonical" href="<?php echo Mage::helper('core/url')->getCurrentUrl(); ?>" />
<link rel="shortcut icon" href="<?php echo $this->getFaviconFile(); ?>" />
<meta content="form_key" name="csrf-param" />
<meta content="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" name="csrf-token" />
<?php
$_actionName = $this->getAction()->getFullActionName();
if ( $_actionName === 'catalog_category_view' ) {
$_category = Mage::registry( 'current_category' );
$_productCollection = $_category->getProductCollection()->addAttributeToFilter( 'status', 1 )->addAttributeToFilter( 'visibility', array( 'in' => array( Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH ) ) );
$_toolbar = $this->getLayout()->createBlock( 'page/html_pager' )->setLimit( $this->getLayout()->createBlock( 'catalog/product_list_toolbar' )->getLimit() )->setCollection( $_productCollection );
$_linkPrev = false;
$_linkNext = false;
if ( $_toolbar->getCollection()->getSelectCountSql() ) {
if ( $_toolbar->getLastPageNum() > 1 ) {
if ( ! $_toolbar->isFirstPage() ) {
$_linkPrev = true;
if ( $_toolbar->getCurrentPage() == 2 ) {
$_url = explode( '?', $_toolbar->getPreviousPageUrl() );
$_prevUrl = @$_url[0];
} else {
$_prevUrl = $_toolbar->getPreviousPageUrl();
}
}
if ( ! $_toolbar->isLastPage() ) {
$_linkNext = true;
$_nextUrl = $_toolbar->getNextPageUrl();
}
}
}
if ( $_linkPrev ) echo '<link rel="prev" href="' . $_prevUrl . '">';
if ( $_linkNext ) echo '<link rel="next" href="' . $_nextUrl . '">';
}
?>
<?php echo $this->getCssJsHtml(); ?>
<?php echo $this->getChildHtml() ?>
<?php echo $this->helper('core/js')->getTranslatorScript() ?>
<?php echo $this->getIncludes() ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.