To change default index page of magento any cms page or any page like login page is quite easy .To do so you need to login to the admin panel then goto System -> Configuration , then click on web tab from the right side tab.Now click on Default Pages tab and change the Default web url as per your required Url.Here is one example where I have changed my Homepage url to Login page Url
Magento Tutorial, Magneto modules, Magento Banckend, Magento admin, Magento Frontend, Magento Interview Question, Jquery, CSS, Javascript, PHP, XHTML
8/28/2010
8/26/2010
How to find third highest salary from a database table by sql or mysql
By this query you can find all possible(nth) highest salary starting from 2nd to nth.Just palace your find number salary in the place of `n` and you can get result. Here I have wrote the `n`th highest salary.
Select salary
from `tablename`
order by `columnname` desc
limit n-1,1;
Write 2 instead of n-1 to find the 3rd highest salary.Write 1 instead of n-1 to find the 2nd Highest salary.
How to Count all li elements in an ul tag by javascript
<script type="text/javascript">
var ulId = document.getElementById("ulid");
var totalLi = ulId.children.length;
alert(totalLi);
</script>
The list of the li in ul tag example is
<ul id="ulid">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
- Item1
- Item2
- Item3
- Item4
How to get parent category Id in Magento
<?php
$_cat = new Mage_Catalog_Block_Navigation();
$curent_cat = $_cat->getCurrentCategory();
$curent_cat_id = $curent_cat->getId();?>
Now you can get Parent Category Id.
write the code given below to get the Id
<?php
$parentId=Mage::getModel('catalog/category')->load($curent_cat_id)->getParentId();
echo
$parentId; // $parentId will print your current category's parent Id
?>
How to change logo and alter logo text in Magento
1) From Admin panel
2) From core file
To change logo of magento from admin panel you need to login to admin panel . Then go to System -> Configuration -> Design
Then click on Header tab to change the logo src (source ) to your respective filename or path. There also you can change logo alt (alternet) text
TO change logo from core file you need to go app/code/core/Mage/Page/config.xml. There you can change <logo_src> to your respective file name/path. There you can change logo alt text from <logo_alt> tag.
7/27/2010
How to see all category and subcategory menu in Magento
For that we will write the code in top.phtml file
<?php foreach ($this->getStoreCategories() as $_category): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a>
<?php
$_catid=$_category->getId();
$category = Mage::getModel('catalog/category')->load($_catid);
$subcategory = $category->getAllChildren(true);
array_shift($subcategory);
if($subcategory!=null)
{
echo '<ul>';
foreach ($subcategory as $sub)
{
$sub1 = Mage::getModel('catalog/category')->load( $sub);?>
<li><a href="<?php echo $sub1->getUrl();?>"><span>
<?php echo $sub1->getName();
echo '</span></a></li>';
}?>
</ul>
<?php }?>
</li>
<?php endforeach ?>
7/20/2010
Get Add to cart button url in Magento
6/21/2010
Refresh page Using Javascript
By Meta tag
<meta http-equiv="refresh" content="600">
By Javascript<a href="javascript:location.reload(true)">Refresh this page</a>
Click here to Refresh this page
How to Get Current Category in Magento
I am showing here two way
If you wish to check the current category in everypage(including Homepage as default category is 2) then you can write these code $_cat = new Mage_Catalog_Block_Navigation();
$curent_cat = $_cat->getCurrentCategory();
$curent_cat_id = $curent_cat->getId();
$category = Mage::registry('current_category')->getName();
By the Help of registry()function of magento we can get the Current category ,For get name of that category we can use getName() function .If you need the Id then write getId() instead of getName();
6/07/2010
How to Use Custom Font By CSS
First paste the font into your website with proper location/path. e.g :- I have paste "OCR A Extended.ttf" file into a font folder then I wrote my css like the example given below.
@font-face {
font-family: OCR;
src: url(../fonts/OCR A Extended.ttf); /* For IE */
src: url(../fonts/OCR A Extended.ttf) format("opentype");
/* For non-IE */
}
body{font-family:OCR;}
You can change URL/path according to your website . Now you can see the effect in every Operating System