CodeIgniter Forums
Problem using anchor tag (solved) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Problem using anchor tag (solved) (/showthread.php?tid=23930)

Pages: 1 2 3


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]stormlead[/eluser]
the anchor line is
Code:
echo  anchor('system/application/controllers/next.php','click here');
now as it was giving the link like
http://localhost/CodeIgniter_1.7.2/index.php/system/application/controllers/next

i chaged the
Code:
$config[index_page]="index.php" to
$config[index_page]=""

so now the next.php which is controller is getting called but giving the error

Fatal error: Class 'Controller' not found in C:\wamp\www\CodeIgniter_1.7.2\system\application\controllers\next.php on line 3
my code for next.php is
Code:
<?php

class Next extends Controller {
function Next()
{
     parent::Controller();    
}
    
function index()
{
    $this->load->view('welcome_message');
    }

}

?>
plese help me out of this...


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]jedd[/eluser]
[quote author="stormlead" date="1256578925"]the anchor line is
Code:
echo  anchor('system/application/controllers/next.php','click here');
[/quote]

Use this instead
Code:
echo  anchor('/next','click here');



Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]praveens[/eluser]
check this it will help for you

http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]stormlead[/eluser]
i tried doing
Code:
echo  anchor('/next','click here');
but this links to

http://localhost/CodeIgniter_1.7.2/next

which wrong
So above thing is not working.
Any other ways do find the solution ...............


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]jedd[/eluser]
What is your base_url set to in your config.php? It sounds like that's pointing to the wrong place.


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]rogierb[/eluser]
Code:
echo  anchor('/next','click here');

Is perfect. It should point to http://localhost/CodeIgniter_1.7.2/next.

This means it is going to the next.php controller. From reading your well structured code, that is what you are trying to achieve


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]bananamuffin[/eluser]
Hi
I think I'm having this exact same problem, hope someone has a solution.

Using CI 1.7.2, have autoloaded the url helper and created my controller and view. Now trying to create a link like the OP.

thanks


[quote author="rogierb" date="1256580352"]
Code:
echo  anchor('/next','click here');

Is perfect. It should point to http://localhost/CodeIgniter_1.7.2/next.

This means it is going to the next.php controller. From reading your well structured code, that is what you are trying to achieve[/quote]


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]InsiteFX[/eluser]
Make sure that you edit your index.php file and point system and application directories to the right paths!

Enjoy
InsiteFX


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]bananamuffin[/eluser]
Thanks. I did that already. I've even added a template and everything's working fine and loading the welcome page into the template, so not too sure why the anchor tag isn't working.

I replicated the site setup using version 1.7.1 and didn't change any of the default settings except the base_url. So I still have index.php in the url (in the main site I'm working on I've added a htaccess rules and removed index.php from config). This time, with index.php, the link works and the posts page loads but without the CSS. Weird.

Maybe I'm missing something about how to use the anchor tag without the index.php? The way I'm using it is

echo anchor('controllername','text I want on the link');

in my case this is

echo anchor('posts', 'Posts').

This appears in my url as http://localhost/CI/posts but it just gives a 404 page not found error.

I've already created the posts controller (controller/posts.php) which loads the posts view.



[quote author="InsiteFX" date="1256598454"]Make sure that you edit your index.php file and point system and application directories to the right paths!

Enjoy
InsiteFX[/quote]


Problem using anchor tag (solved) - El Forum - 10-26-2009

[eluser]jedd[/eluser]
Wow - top-posting in forums - that's a new one. You don't have to quote messages unless there's something specific you're responding to.

Quote:This appears in my url as http://localhost/CI/posts but it just gives a 404 page not found error.

Unless http://localhost/CI/posts resolves on your computer, it's not an anchor issue but a controller/method or pathing issue. Does that URL resolve normally?

If it doesn't, then you just need to work out why and then fix that. Then your anchor will work like a charm.

Assuming your base_url is configured properly in config.php, then you should be able to anchor('/controllername/methodname', 'String I want to appear as a link') to your heart's content.

Remember - page/view-source within your browser is your friend with this kind of problem.