Skip to content
G31 Zone
  • About
  • Contact

Javascript – addslashes and stripslashes

Posted on: June 24, 2011 /
Categories: JavaScript

A Javascript function for add slashes: function addslashes(str) { str=str.replace(/\\/g,’\\\\’); str=str.replace(/\’/g,’\\\”); str=str.replace(/\”/g,’\\”‘); str=str.replace(/\0/g,’\\0’); return str; } A Javascript function for strip slashes: function stripslashes(str) { str=str.replace(/\\’/g,’\”); str=str.replace(/\\”/g,'”‘); str=str.replace(/\\0/g,’\0′); str=str.replace(/\\\\/g,’\\’); return str; }

Magento get child products for a configurable product

Posted on: June 8, 2011 /
Categories: Magento

Magento get products childs for a configurable product // $currentProduct = $this->getProduct(); $configurable_products = Mage::getModel(‘catalog/product_type_configurable’)->setProduct($currentProduct); $products_collection = $configurable_products->getUsedProductCollection()->addAttributeToSelect(‘*’)->addFilterByRequiredOptions(); foreach($products_collection as $_product){ echo $_product->getId() . “: ” . $_product->getName(); }

Magento – Show Quantity Box in Products List

Posted on: June 3, 2011 /
Categories: Magento

In file ‘list.phtml’ file change the <button> line near line 108 from this: <?php if($_product->isSaleable()): ?> <button class=”form-button” onclick=”setLocation(‘<?php echo $this->getAddToCartUrl($_product) ?<‘)”>>span> <?php echo $this->__(‘Add to Cart’) ?></span></button> with: <form action=” <?php echo $this->getAddToCartUrl($_product) ?>” method=”post” id=”product_addtocart_form_<?php echo $_product->getId(); ?>”> <input name=”qty” type=”text” class=”input-text qty” id=”qty” maxlength=”12″ value=” <?php echo $this->getMinimalQty($_product) ?>” /> <button class=form-button”

Read More →

JavaScript redirect a page after 5 seconds

Posted on: May 22, 2011 /
Categories: JavaScript

Javascript function to redirect to another page after 5 seconds: function redirect_after_5_seconds() { setTimeout(“location.href=’index.php/new_url_for_redirection'”, 5000); }

Magento – include a static block into phtml file

Posted on: April 18, 2011 /
Categories: Magento

Include a static block into a phtml file: echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘block_identifier’)->toHtml();

Magento – use singleton database connection

Posted on: February 21, 2011 /
Categories: Magento

Magento database connection write mode: $db = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’); Magento database connection read mode: $db = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’); Query model $result = $db->query(“SELECT * FROM tablename”); if ($result) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) { // Use $row } }

Javascript – go back to last page

Posted on: January 19, 2011 /
Categories: JavaScript

Create a link to go back to the last page opened: <a href=”javascript: history.go(-1);” >Back </a>

Magento – custom block

Posted on: January 19, 2011 /
Categories: Magento

Custom block (for CMS pages): {{block type=”core/template” name=”template_name” template=”mydir/mytemplate.phtml” }}

Magento – save and get data from cache

Posted on: December 23, 2010 /
Categories: Magento

Just a method to save and get data from magento cache $mydataforcache = “My data for cache”; $cache_name = “maycachename”; $CACHEDATA = MAGE::app()->loadCache($cache_name); if (isset($CACHEDATA) && ($CACHEDATA != “”)) { // Use data echo $CACHEDATA; } else { // Save data to cache Mage::app()->saveCache($mydataforcache, $cache_name, array(), 10800); }

Javascript – compare two dates

Posted on: December 21, 2010 /
Categories: JavaScript

Compare two dates in Javascript: <html> <head> <title>JavaScript – compare two dates</title> </head> <body> <script language=”Javascript” type=”text/javascript”> var date1 = new Date(“22/12/2010”); var date2 = new Date(“25/12/2010”); if (date1 <= date2) { alert(“Date 1 lower or equal than date 2!”); } else { alert(“Date 2 lower than date 1!”); } </script> </body> </html>

« 1 … 3 4 5 6 7 … 9 »

Categories

  • Apache
  • CentOS
  • Git
  • HTML
  • HTTP
  • JavaScript
  • JQuery
  • Linux
  • Magento
  • MySQL
  • PHP
  • Regular expression (Regex)
  • Smarty
  • Symfony 2 / Doctrine
  • Twig
  • Ubuntu
  • Uncategorized
  • Zend

Archives

  • June 2015
  • May 2015
  • March 2015
  • September 2014
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • January 2013
  • October 2012
  • August 2012
  • May 2012
  • April 2012
  • January 2012
  • December 2011
  • November 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010

Recent Posts

  • Connect to VPN from Linux
  • Enable slow query log on MySQL server
  • Doctrine Console Commands
  • Symfony2 Doctrine debug query
  • Mysqldump only tables with certain prefix

Tags

ajax all post data apache asynchronously bookmark categories images category category thumbnail create subdomain create virtualhost git git basics git force overwrite git pull htaccess html html codes HTTP status codes JavaScript javascript getcookie javascript get url javascript setcookie javascript strip tags javascript strip_tags jquery jquery.validator jquery ajax jquery bookmark jquery validator rule Lorem ipsum Magento mysql php preview button preview target blank print array products redirect www soap soap client soap sample soap server status codes zend framework 1 zend trace mysql errors

Copyright G31 Zone 2026 | Theme by Theme in Progress | Proudly powered by WordPress