Hello everyone!
Magento 内置的网站地图(sitemap)老实说非常古怪,基本上有两个版本,但它们都需要分页。那么您一定知道分页 sitemap 对 SEO 意味着什么。
Canyon 的建议是由网页构建一个简单的地图,首先第一件事就是创建一个新的 Magento CMS 页面,并命名 Sitemap,然后为其写些简短的说明文字。
然后,我们将创建一个静态块来保存我们的动态的站点导航数据,将下面的代码贴到说明文字的下面。
{{block type="catalog/product_list" name="product.list.sitemap" alias="product_list_sitemap" template="page/html/sitemap.phtml"}}在这个块中我们看到了我们需要包含一个 sitemap.phtml 的页面,那么我们要创建它在:app>design>frontend>package(default)>theme(default/modern)>page>html>sitemap.phtml
以下页面代码,你会看到,在这个 sitemap.phtml 中我们给出了一个类别的树形结构, CMS 的一个列表页,某一个分类。您也可以根据自己网店的需求排列。
<?php /* Creare Sitemap - gets CMS Pages - TLC's and SC's - and 10 best products per category */ function getCreareCMSPages(){ $cms = Mage::getModel('cms/page')->getCollection(); $html = ""; foreach($cms as $cmspage): $page = $cmspage->getData(); if($page['identifier'] == "no-route" || $page['identifier'] == "enable-cookies" || $page['identifier'] == "empty"){ /* do nothing or something here */ } else { if($page['identifier'] == "home"){ $html .= "<li><a href="/" mce_href="/""//" title=/"".$page['title']."/">".$page['title']."</a></li>/n"; // this is for a nice local link to home } else { $html .= "<li><a href="/" mce_href="/""".$page['identifier']."/" title=/"".$page['title']."/">".$page['title']."</a></li>/n"; } } endforeach; return $html; } function getCrearePopularProducts(){ /* get the product id's from VCMS here */ $products = array('4138','4137','4136','4132','4131','4125','4124','4120','3938','3932'); $html = ""; foreach($products as $productId): $product = Mage::getModel('catalog/product')->load($productId); $html .= "<li><a href="/" mce_href="/""".$product->getUrlPath()."/" title=/"".$product->getName()."/">".$product->getName()."</a></li>/n"; endforeach; return $html; } ?> <mce:style type="text/css"><!-- .siteul { margin: 5px; padding: 0 0 0 10px; } .siteul li { list-style:inside; font-size:1em!important; } .sitecatul { margin: 0 5px; padding: 0 0 0 10px; } .sitecatul li { list-style:none; font-size:1em!important; } .sitecatul li ul { margin: 0 5px; padding: 0 0 0 10px; } .sitecatul li ul li { list-style:inside; } .two-column { width: 50%; float: left; display: block; } --></mce:style><style type="text/css" mce_bogus="1">.siteul { margin: 5px; padding: 0 0 0 10px; } .siteul li { list-style:inside; font-size:1em!important; } .sitecatul { margin: 0 5px; padding: 0 0 0 10px; } .sitecatul li { list-style:none; font-size:1em!important; } .sitecatul li ul { margin: 0 5px; padding: 0 0 0 10px; } .sitecatul li ul li { list-style:inside; } .two-column { width: 50%; float: left; display: block; }</style> <div> <h2>Our Main Pages</h2> <ul> <?php echo getCreareCMSPages(); // prints out our cms pages ?> <li><a href="/sitemap.xml" mce_href="sitemap.xml" title="XML Sitemap">XML Sitemap</a></li> </ul> <h2>Our Most Popular ProductsgetStoreCategories() ?> <?php if (count($_categories) > 0): ?> <ul> <?php foreach($_categories as $_category): ?> <li> <strong><?php echo $_category->getName() ?></strong> <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?> <?php $_subcategories = $_category->getChildrenCategories() ?> <?php if (count($_subcategories) > 0): ?> <ul> <?php foreach($_subcategories as $_subcategory): ?> <?php $_nextcategory = Mage::getModel('catalog/category')->load($_subcategory->getId()) ?> <?php $_nextsubcategories = $_nextcategory->getChildrenCategories() ?> <li> <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>" title="<?php echo $_subcategory->getName() ?>"> <?php echo $_subcategory->getName() ?> </a> <?php if (count($_nextsubcategories) > 0): ?> <ul> <?php foreach($_nextsubcategories as $_nextsubcat): ?> <li> <a href="<?php echo $_helper->getCategoryUrl($_nextsubcat) ?>" title="<?php echo $_subcategory->getName() ?> - <?php echo $_nextsubcat->getName() ?>"> <?php echo $_nextsubcat->getName() ?> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> </ul> <?php endif; ?> </div>下图是一个该页面生成的 sitemap,嗯,基本就是这个样子,要声明的是它只是个示例,如果你希望它变得漂亮些,那么 styles 需要您自行添加修改。