Redirect to Magento admin dashboard - magento

I've scoured the internet looking for an answer to this, but have found nothing. I have a custom extension. One of the functions will redirect the user to the admin dashboard. How can this be done?
I've tried things like
$this->_redirect("/")
$this->_redirect("*")
$this->_redirect("*/*")
but nothing works.

If you're in a controller action, you can use the following:
<?php $this->_redirect('adminhtml/dashboard') ?>
If you're in an Adminhtml controller action, you can use:
<?php echo $this->_redirect('*/dashboard') ?>
This works as Adminhtml is the current module.

at the end of your controller do:
Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl('/'));
But this is just what runs through my mind...there are for sure several other ways to achieve this. Like always...

Related

Magento one page login not working

currently i am working with a magento shopping site.I am newbie to magento. When i tried to login via one page both login and create button are disabled.
Default login and create account working fine.I have added
<?php echo $this->getBlockHtml('formkey'); ?>
please help me to solve the problem.Thanks in advance.
please check this link
http://qwertykart.com/checkout/onepage/
Check your one page checkout setting if register is not enabled.
if there is no setting for this, then Install this Extension to see exact .phtml file, where you need to edit.
https://www.magentocommerce.com/magento-connect/easy-template-path-hints.html
After setup, you can get your template path by adding tp=1&code=1 in the url.
(You have to save code value in magento backend)
I see your Register button having "disabled"=disabled attribute. Try to remove that. After removing that you will be able to register.
Do it for other buttons as well.

How to disable link with #?

I am trying to disable a link by putting a # for the URI. But when its clicked it goes go the index page of my appication.
Does anyone know how to go around this??
Below is the code I am using.
<?= anchor("#", "Set my own payment option", "id='set_payment_option'")?>
Since you are using url helper already you can use current_url() function as well.
<?= anchor(current_url().'/#', 'Set my own payment option', 'id="set_payment_option"') ?>
Replace # with
javascript://
I don't try in codeigniter
You should avoid doing any server request at all to save resources. Use javascript instead
My disabled link

Disabling redirecting after customer login magento

All I want is to let a customer stay on his current page when he logs in to his Magento account.
Yes I know about the Magento backend option (found in: System > Configuration > Customers >
Customer Configuration > Login Options) but when I turn this setting to NO it still redirects a customer to his account dashboard after loggin in.
Is there really no simple way to let a customer stay on the same page from where he is logging in?
I know about the Magento connect Psycho extension or something :) but I just need a code to implement.
Tia
Can add follow code in login form phtml file
$refererUrl = $this->getRequest()->getServer('HTTP_REFERER');
Mage::getSingleton('customer/session')->setBeforeAuthUrl($refererUrl);
You should set to NO on System > Configuration > Customers > Customer Configuration > Login Options
and in your login.phtml files (both, persistent/customer/form and customer/form on your template folder) you must change the action of your <form> to:
action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>"
OR
Try this FREE extension
http://www.magentocommerce.com/magento-connect/customer-redirect-after-login-5446.html
I'm guessing this will somewhat depend on the Magento version. In 1.7, if you check the function mentioned by #Rajat (loginPostRedirect), you'll see that the option you mention will only prevent the customer ending up on the dashboard if there is a referer param in the query string. If you add that query parameter to the action of the login form, you should be good to go.
For redirection you will have have to make changes to your Customer Controller.For making changes in your controller better option would be to override your controller.
You will have to make change in loginPostRedirect() function in controller.Make your changes to this line$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());

Codeigniter anchor can't find link

I am using CodeIgniter to design a website, and I am having trouble getting anchor to work correctly.
Here is how I am using it. It is used in a file in views folder of application in codeigniter.
<?php echo anchor('/profile', 'PROFILE'); ?>
My intention is to have anchor load the profile controller, which is in the controllers of application in codeigniter. However, when I clink on the link, it says that the the file is not found.
I autoload the url helper functions alreader, and other functions from that file are working, like site_url() .
I don't know what I could have missed? Do you ave any suggestions? This is my second project with codeigniter, so I am still learning.
EDIT: Yes, I am following the naming convention in codeigniter, and the file has an index function. I tried without the forward slash and it still gives the same result.
The HTML link that this produces is localhost/profile. This is what I Should get right? Since for codeigniter, it's url/controller/function. I did a mod rewrite to remove index.php from the url, but that shouldn't be a problem, should it? I'll try and check the base url again.
Are you sure you need the leading forward slash?
Have you tried:
<?php echo anchor('profile', 'PROFILE'); ?>
You would only be using the slash if you are trying to get into the "profile" sub folder inside your controllers folder.
What helps me when urls get confusing is to type into the browser the full url to the path I want to get to (to make sure I'm not getting a 404, etc). From there you can start from the end and go back to see what you are missing.
But you generally want to start with a controller name and add the function you are calling like:
anchor(controllerName/functionName)
See CodeIgniter URL Helper for examples.
EDIT: also - you may need to check what your config base_url is set to. if there's fancy .htaccess stuff happening, your base_url needs to be set properly.
There is a very simple solution go to config/constants and define SITE_URL there and set its value to
http://localhost/myprojectname/index.php.
Then use it here like this.
<?php echo anchor(SITE_URL.'/profile', 'PROFILE'); ?>

Codeigniter redirection

Hi I created a codeigniter project but when I click on a link to one of my functions, example add user, I get redirected to the main page of my local host XAMPP installation instead of being taken to the correct application url. What can be the problem? Thanks
Have you set the base URL in the CI configuration? file projectname/application/config/config.php? This might be the problem... I guess your project isn't on the webroot, but your base URL is missing the /projectname/ part.
$config['base_url'] = 'http://example.com/projectname/';
How do you create the link (can you show us the code)? If you are not using the URLHelper take a look at urlHelper.
I am just guessing, but maybe you are missing the Controller name (you have to load the UrlHelper), e.g.:
Link to the controllers method
or (see Jordan Arsenault's comment below on the usage of the site_url call for better performance):
<?= anchor('/name_of_the_controller/method_to_invoke', 'Link to the controllers method'); ?>
I hope this helps.

Resources