The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled PHP Code
Posted by: sdfsd | February 5, 2010 @ 9:04am
PHP Code
[
Download
]
<div id="product-navigation"> <?php /** * Determine the previous/next link and link to current category */ if ($this->helper('catalog/data')->getCategory()) { $_ccat = $this->helper('catalog/data')->getCategory(); } else { $_ccats = $this->helper('catalog/data')->getProduct()->getCategoryIds(); $_ccat = Mage::getModel('catalog/category')->load($_ccats[0]); } $ppos = $_ccat->getProductsPosition(); $current_pid = $this->helper('catalog/data')->getProduct()->getId(); // build array from products positions $plist = array(); foreach ($ppos as $pid => $pos) { $plist[] = $pid; } $curpos = array_search($current_pid, $plist); // get link for prev product $previd = isset($plist[$curpos+1])? $plist[$curpos+1] : $current_pid; $product = Mage::getModel('catalog/product')->load($previd); $prevpos = $curpos; while (!$product->isVisibleInCatalog()) { $prevpos += 1; $nextid = isset($plist[$prevpos])? $plist[$prevpos] : $current_pid; $product = Mage::getModel('catalog/product')->load($nextid); } $prev_url = $product->getProductUrl(); // get link for next product $nextid = isset($plist[$curpos-1])? $plist[$curpos-1] : $current_pid; $product = Mage::getModel('catalog/product')->load($nextid); $nextpos = $curpos; while (!$product->isVisibleInCatalog()) { $nextpos -= 1; $nextid = isset($plist[$nextpos])? $plist[$nextpos] : $current_pid; $product = Mage::getModel('catalog/product')->load($nextid); } $next_url = $product->getProductUrl(); // get link for current category $more_url = $_ccat->getUrl(); $current_cid = $_ccat->getId(); ?> <p><a href="<?= $more_url; ?>" class="product_category"><?php echo $_ccat->getName() ?></a></p> <p><a href="<?= $next_url; ?>" class="product_prev">Nazaj</a> <a href="<?= $prev_url; ?>" class="product_next">Naprej</a></p> </div>
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.61 / 8
62 Votes
http://codebin.yi.org/487
page generated in 0.00 seconds