4/12/2012
magento get admin form key
Here is how you can get admin form key in your frontend form. I used the admin form key to login from frontend to admin dashboard.
step1: create object
<?php $adminobj= new Mage_Adminhtml_Block_Template(); ?>
step2: I used the value in hidden field like below:
<input name="form_key" type="hidden" value="<?php echo $adminobj->getFormKey() ?>" />
step1: create object
<?php $adminobj= new Mage_Adminhtml_Block_Template(); ?>
step2: I used the value in hidden field like below:
<input name="form_key" type="hidden" value="<?php echo $adminobj->getFormKey() ?>" />
magento login to admin from frontend error:404 error page not found
Hi,
I was trying to login to admin panel by using frontend login template.
Here is my form whose action post to admin login action.
<form action="http://www.mysite.com/bgsh/index.php/admin" method="post" id="customer-form">
I was trying to login to admin panel by using frontend login template.
Here is my form whose action post to admin login action.
<form action="http://www.mysite.com/bgsh/index.php/admin" method="post" id="customer-form">
I changed the action to :
action="http://www.mysite.com/bgsh/index.php/admin/admin"
and BINGO:
no error on login.(Did you noticed the double admin words in the action value?)
If you request, then i can explain and provide code in details how i manage to login from frontend using vendor credentials, and after logout redirected to the frontend in case the vendor is logged in from frontend.
4/05/2012
setting session variable in php file outside magento structure
Hi,
today i was working on a project and i had to redirect user('vendor') to frontend from where he has logged in to the system.I already created user registration from frontend. Now i had to maintain session variable so that i can check whether the particular vendor was logged in from frontend. If so, he will be redirected to the frontend.
To store session variable i sent an ajax hit to http://www.mywebsite.com/setSessionVar.php file. As you can see that file is situated in root directory.
setSessionVar.php
<?php
require 'app/Mage.php';
Mage::app();
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
Mage::getSingleton('core/session')->setMyloginvalue('vendor');
?>
To redirect to frontend i put a check when user click on "logout" link in the dashboard area.
i.e. in file IndexController.php under
/app/code/core/Mage/Adminhtml/controllers
public function logoutAction()
{
//GET LOGIN TYPE . if vendor loggedin from frontend then it's "vendor"
$loginvalue=Mage::getSingleton('core/session')->getMyloginvalue();
if($loginvalue=="vendor")
{
Mage::getSingleton('core/session')->unsMyloginvalue();
$location=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
header("location:$location");exit;
}
//END VENDOR LOGIN CHECK
//....rest of the code here
//....
}
today i was working on a project and i had to redirect user('vendor') to frontend from where he has logged in to the system.I already created user registration from frontend. Now i had to maintain session variable so that i can check whether the particular vendor was logged in from frontend. If so, he will be redirected to the frontend.
To store session variable i sent an ajax hit to http://www.mywebsite.com/setSessionVar.php file. As you can see that file is situated in root directory.
setSessionVar.php
<?php
require 'app/Mage.php';
Mage::app();
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
Mage::getSingleton('core/session')->setMyloginvalue('vendor');
?>
To redirect to frontend i put a check when user click on "logout" link in the dashboard area.
i.e. in file IndexController.php under
/app/code/core/Mage/Adminhtml/controllers
public function logoutAction()
{
//GET LOGIN TYPE . if vendor loggedin from frontend then it's "vendor"
$loginvalue=Mage::getSingleton('core/session')->getMyloginvalue();
if($loginvalue=="vendor")
{
Mage::getSingleton('core/session')->unsMyloginvalue();
$location=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
header("location:$location");exit;
}
//END VENDOR LOGIN CHECK
//....rest of the code here
//....
}
4/04/2012
get agent status in zopim using javascript
I implemented zopim in a site and had to change class of a div according to the current agent's status.
<script type="text/javascript">
//YOUR ZOPIM SCRIPT HERE
</script>
//updatestatus function
function updateStatus(s) //NOTICE "s" here it contains agent's current status
{
switch(s)
{
case 'online':
jQuery('.chatbox').addClass('online');
break;
case 'offline':
jQuery('.chatbox').removeClass('online');
break;
case 'away':
jQuery('.chatbox').removeClass('online').addClass('away');
break;
}
<div class="chatbox" onclick="$zopim.livechat.window.toggle();">sow chat</div>
<script type="text/javascript">
//YOUR ZOPIM SCRIPT HERE
</script>
$zopim(function() {
$zopim.livechat
.setOnStatus(updateStatus);
});
.setOnStatus(updateStatus);
});
//updatestatus function
function updateStatus(s) //NOTICE "s" here it contains agent's current status
{
switch(s)
{
case 'online':
jQuery('.chatbox').addClass('online');
break;
case 'offline':
jQuery('.chatbox').removeClass('online');
break;
case 'away':
jQuery('.chatbox').removeClass('online').addClass('away');
break;
}
4/02/2012
Calendar._MN is undefined magento
Today i was implementing caledar feature in frontend. I have included all the required js and css file for that.
Still it was showing this error."Calendar._MN is undefined"
After some R&D i found out that i missed to include some javascript that is necessary for calendar to work.
I just included following lined on the page and it begins to work smoothly.
<link rel="stylesheet" type="text/css" href="http://www.beds.sg/v2/ js/calendar/calendar-win2k-1. css" />
<script type="text/javascript" src="http://www.beds.sg/v2/js/ calendar/calendar.js"></ script>
<script type="text/javascript" src="http://www.beds.sg/v2/js/ calendar/calendar-setup.js"></ script>
Still it was showing this error."Calendar._MN is undefined"
After some R&D i found out that i missed to include some javascript that is necessary for calendar to work.
I just included following lined on the page and it begins to work smoothly.
<script type="text/javascript">
//<![CDATA[
enUS = {"m":{"wide":["January"," February","March","April"," May","June","July","August"," September","October"," November","December"],"abbr":[ "Jan","Feb","Mar","Apr","May", "Jun","Jul","Aug","Sep","Oct", "Nov","Dec"]}}; // en_US locale reference
Calendar._DN = ["Sunday","Monday","Tuesday"," Wednesday","Thursday","Friday" ,"Saturday"]; // full day names
Calendar._SDN = ["Sun","Mon","Tue","Wed","Thu" ,"Fri","Sat"]; // short day names
Calendar._FD = 0; // First day of the week. "0" means display Sunday first, "1" means display Monday first, etc.
Calendar._MN = ["January","February","March", "April","May","June","July"," August","September","October", "November","December"]; // full month names
Calendar._SMN = ["Jan","Feb","Mar","Apr","May" ,"Jun","Jul","Aug","Sep","Oct" ,"Nov","Dec"]; // short month names
Calendar._am = "AM"; // am/pm
Calendar._pm = "PM";
// tooltips
Calendar._TT = {};
Calendar._TT["INFO"] = "About the calendar";
Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"For latest version visit: http://www.dynarch.com/ projects/calendar/\n" +
"\n\n" +
"Date selection:\n" +
"- Use the \xab, \xbb buttons to select year\n" +
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
"- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Time selection:\n" +
"- Click on any of the time parts to increase it\n" +
"- or Shift-click to decrease it\n" +
"- or click and drag for faster selection.";
Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";
Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";
Calendar._TT["GO_TODAY"] = "Go Today";
Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";
Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";
Calendar._TT["SEL_DATE"] = "Select date";
Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";
Calendar._TT["PART_TODAY"] = ' (' + "Today" + ')';
// the following is to inform that "%s" is to be the first day of week
Calendar._TT["DAY_FIRST"] = "Display %s first";
// This may be locale-dependent. It specifies the week-end days, as an array
// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
// means Monday, etc.
Calendar._TT["WEEKEND"] = "0,6";
Calendar._TT["CLOSE"] = "Close";
Calendar._TT["TODAY"] = "Today";
Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
// date formats
Calendar._TT["DEF_DATE_FORMAT" ] = "%b %e, %Y";
Calendar._TT["TT_DATE_FORMAT"] = "%B %e, %Y";
Calendar._TT["WK"] = "Week";
Calendar._TT["TIME"] = "Time:";
CalendarDateObject._LOCAL_ TIMZEONE_OFFSET_SECONDS = -28800;
CalendarDateObject._SERVER_ TIMZEONE_SECONDS = 1333496531;
//]]>
</script>
Subscribe to:
Posts (Atom)