Thursday 5 June 2014

Magento Restricted CMS Pages:

Step1
First goto   “app\design\frontend\default\[your theme directory]\template\page”
make a copy of your template page it can be “1column.phtml” or “2columns-right.phtml”…. whatever you are using.
rename it to “restricted.phtml”  and paste the below code just after body tag starts.


&lt;?php <code>$login</code> <code>= Mage::getSingleton( </code><code>'customer/session'</code> <code>)-&gt;isLoggedIn(); </code><code>//Check if User is Logged In</code>
<div><code> </code><code>if</code><code>(!</code><code>$login</code><code>)</code></div>
<div><code> </code><code>{</code></div>
<div><code> </code><code>$msg</code> <code>= Mage::getSingleton(</code><code>'core/session'</code><code>)-&gt;addError(</code><code>$this</code><code>-&gt;__(</code><code>'Please Sign in / Register first to access this page.'</code><code>));</code></div>
<div><code> </code><code>header(</code><code>'Location: '</code><code>. Mage::getUrl(</code><code>'customer/account/login'</code><code>));</code></div>
<div><code> </code><code>exit</code><code>;</code></div>
<div><code> </code><code>}</code></div>
<div>?&gt;</div>
<div>
 
 
goto “\app\code\core\Mage\Page\etc”  and open “config.xml”
add this code just befor “</layouts>” tag


<div>
<div><code>&lt;</code><code>allowed_user</code> <code>module</code><code>=</code><code>"page"</code> <code>translate</code><code>=</code><code>"label"</code><code>&gt;</code></div>
<div><code> </code><code>&lt;</code><code>label</code><code>&gt;Only Registerd / Sign in users&lt;/</code><code>label</code><code>&gt;</code></div>
<div><code> </code><code>&lt;</code><code>template</code><code>&gt;page/restricted.phtml&lt;/</code><code>template</code><code>&gt;</code></div>
<div><code> </code><code>&lt;</code><code>layout_handle</code><code>&gt;page_allowed_user&lt;/</code><code>layout_handle</code><code>&gt;</code></div>
<div><code> </code><code>&lt;/</code><code>allowed_user</code><code>&gt;</code></div>
<div></div>
</div>
 
 
Now open you “admin” ,” cms”  and “add new page”
and you will find new select option under “design” tab in “Layout” option.
just select “Only Restricted/ sign in user”. Rest will be handelled by the code icon smile Magento Restricted CMS Pages
magento restricted page Magento Restricted CMS Pages
 
 


 
 

No comments:

Post a Comment