Monthly Archives: March 2010

Solution of “Error: element.dispatchEvent is not a function Source” Error

When u r facing this type of error “Error: element.dispatchEvent is not a function Source”. It means a problem of conflict of the jQuery . It can easy to over come to reduce the error

<html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();
     
     // Put all your code in your document ready area
     jQuery(document).ready(function($){
       // Do jQuery stuff using $
       $("div").hide();
     });
     
     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>
 </html>

Use URL in footer.phtml

It is quit impossible to use the store or skin or other url in footer. so we can use this

<a href="<?php echo $this->getUrl('')?>catalog/seo_sitemap/category">Site Map</a>
<a href="<?php echo $this->getUrl('')?>catalogsearch/term/popular">Popular search</a>
<a href="<?php echo $this->getUrl('')?>catalogsearch/advanced">Advanced search</a>

for skin 
/*$this->getSkinUrl('give the name which url u want');
exam.*/
<img src="<?php echo $this->getSkinUrl('images/pictos/panier.gif') ?>" alt="Mon panier">

Show all category under a category named “Product”

Go to your template folder and open Catalog/navigation/top.phtml
and add this


<?php $URL= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
	  // echo $URL;
?>
<div class="header-nav-container">
    <div class="header-nav">
        <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
        <ul id="nav">
		<li><a href="<?php echo $this->getUrl() ?>"><?php echo $this->__('Home') ?></a></li>
        <?php /*?><?php foreach ($this->getStoreCategories() as $_category): ?>
            <?php echo $this->drawItem($_category) ?>
        <?php endforeach ?><?php */?>
		<li onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)">
            <a href="<?php echo $this->getUrl('') ?>"><?php echo $this->__('Products') ?></a>
			<ul>
				<?php foreach ($this->getStoreCategories() as $_category): ?>
				    <?php echo $this->drawItem($_category) ?>
				<?php endforeach ?>
			</ul>
		</li>
		<li><a href="<?php echo $URL?>customer/account/login/" >Log in</a></li>
        <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu')->toHtml(); ?>
        </ul>
    </div>
    <?php echo $this->getChildHtml('topLeftLinks') ?>
</div>

Retrieving URL paths in magento

Magento comes with built in function for retrieving URL paths. Function is called getBaseUrl() and its located under Mage class. However, function is not documented as it should be. Documentation only states that function retrieves $type parametar which is by default equal to “base”.

Here is the list of all the available parameters I found. As you can see, they all come from Mage_Core_Model_Store.

 Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
/**Output**//
      http://magesite.extension/js/
 Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
/**Output**//
      http://magesite.extension/index.php/
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
/**Output**//
      http://magesite.extension/media/
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
/**Output**//
      http://magesite.extension/skin/
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
/**Output**//
      http://magesite.extension/ 

Where http://magesite.extension/ is the url of your site. If you don’t provide any parameters to getBaseUrl() function you would retrieve the same path as with URL_TYPE_LINK parametar.

Remember, you need to echo out these statements to the browser, because they each return a string, so you need to output that string like

<?php
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
?>
%d bloggers like this: