Welcome Guest, Not a member yet? Register   Sign In
Problem using anchor tag (solved)
#11

[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...llers/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...
#12

[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');
#13

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

http://ellislab.com/codeigniter/user-gui...elper.html
#14

[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 ...............
#15

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

[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
#17

[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]
#18

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

Enjoy
InsiteFX
#19

[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]
#20

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




Theme © iAndrew 2016 - Forum software by © MyBB