Magento Coding Solutions

Magento get url with or without parameters

Magento lets you get url with or without parameters as below:
// get base url
Mage::getUrl()
// http://dltr.org/

// get base url and index.html page
Mage::getUrl('index.html')
// http://dltr.org/index.html

// get brands page with id parameter
Mage::getUrl('brands/brand', array('id' => 1));
// http://dltr.org/brands/brand/id/1

// get secure url
Mage::getUrl('brands/brand', array('id' => 1,'_secure' => true));
// https://dltr.org/brands/brand/id/1

// or get secure url based on current page. good for ajax urls.
Mage::getUrl('brands/brand', array('id' => 1,'_secure' => Mage::app()->getStore()->isCurrentlySecure()));
// http(s)?://dltr.org/brands/brand/id/1



 But i used this code not working 
when add magento "rewrite" then working propely

You can use Below code 

$store_id=1;
$request_path = 'designeruser/id/2/' ;
$target_path='designeruser/index/index/id/2';
$oUrlRewriteCollection = Mage::getModel('core/url_rewrite')->getCollection()->addFieldToFilter('target_path', $target_path);
if(count($oUrlRewriteCollection)==0){
    echo "target path does exist";
 $rewriteModel = Mage::getModel('core/url_rewrite');
 $id_path ='designeruser/index/index/id/2';
 $rewriteModel->setData('request_path', $request_path);
 $rewriteModel->setData('target_path', $target_path);
 $rewriteModel->setData('id_path',$id_path);
 $rewriteModel->setOptions('RP');
 $rewriteModel->setData('store_id', $store_id);
 $rewriteModel->setData('is_system', 0);
 $rewriteModel->save(); 
} 


how to call phtml file in static block in magento


 /*****File Location :
  /public_html/new/app/design/frontend/default/default/template/easytabs/catalogproductrelatedright.phtml
*****/
call in STATIC BLOCK
{{block type="core/template" name="catalogproductrelatedright" template="easytabs/catalogproductrelatedright.phtml"}}

{{block type="core/template"  template="easytabs/catalogproductrelatedright.phtml"}}

RELATED PRODUCT CALL IN STATIC BLOCK

{{block type="catalog/product_list_related" name="catalog.product.related" before="-"  template="catalog/product/list/related.phtml" }}


IN CATALOG XML
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>