How to disable link with #? - codeigniter

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

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.

magento add item and redirect to one page checkout in url

I have seen answers that are close to what I am looking for. I want to add a product to the cart and also redirect to one page checkout in one single link tag from an email.
So far i have:
http://www.example.com/checkout/cart/add/product/20759/qty/1/
This successfully adds item to the cart, but does not re-direct to one page checkout. Is there any easy solution to add something to the url?
Ideally something like this?
http://www.example.com/checkout/cart/add/product/20759/qty/1/"one-page-checkout-link"
Thanks everyone!
If you add the parameter 'return_url' then this will work:
?return_url=http://magento.localhost/checkout/onepage/
It will need to be url encoded and also will be checked with the function _isUrlInternal as you cannot redirect to external urls.
Thanks David! You pointed me in the right direction. here is what did the trick:
http://www.example.com/checkout/cart/add/product/20759/qty/1/?return_url=http://www.example.com/checkout/onepage/
If I had a higher rep I would vote you up.....
Thanks again.
Please use the form_key for latest versions of magento.
For eg., http://www.example.com/checkout/cart/add/product/20759/qty/1/form_key/Nf9kXuUu89DLTeT7/?return_url=http://www.example.com/checkout/onepage/
Now the product will be add to cart in magento.
Note: Note the form_key in url
You can get the form key by using the below code:
Mage::getSingleton('core/session')->getFormKey();

Redirect to Magento admin dashboard

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...

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