Welcome Guest, Not a member yet? Register   Sign In
Helper functions not working
#1

[eluser]01010011[/eluser]
Hi,
I'm following the tutorial "Create a blog in 20 minutes" and I unsuccessful in creating the links on my HTML page using the helper and anchor functions.

I've put

Code:
$this->load->helper('url');
$this->load->helper('form');

in the constructor under
Code:
parent::Controller();

and

Code:
<p>&lt;?php anchor('blog/comments','Comments'); ?&gt;</p>

within the foreach loop as specified in the tutorial.

Any suggestions?
#2

[eluser]ciGR[/eluser]
You forget to "echo" the anchor
Code:
<p>&lt;?php echo anchor('blog/comments','Comments'); ?&gt;</p>
#3

[eluser]01010011[/eluser]
Thank you for your reply and observation ciGR.

I put in the echo, but Im getting the same problem.

However, when I viewed the source as instructed in the video, this line was missing (it was in in the video):

Quote:&lt;form method= "post" action = "http://www.example.com/CodeIgniter/index.php/blog/comment_insert"&gt;
#4

[eluser]ciGR[/eluser]
if you try a test controller
Code:
&lt;?php
class test extends Controller {
    
    function __construct()
    {
        parent::Controller();
        $this->load->helper('url');
    }
    
    function index()
    {
        
        echo anchor("test/page","link to a test page");    
    }
}
?&gt;

you get the link??
#5

[eluser]01010011[/eluser]
[quote author="ciGR" date="1269797139"]if you try a test controller
you get the link??[/quote]

Yes I got the links after putting the test code in the controller folder and typed
Quote:localhost/codeigniter/index.php/blog

but I don't understand how your code did it.

When I typed
Quote:localhost/codeigniter/index.php/blog/test

I get a 404 Page Not Found.

I'm new to PHP and CI so I'm trying to figure out what exactly went wrong. The only differences I noticed were that you had

Code:
function _construct()


and I had

Code:
function Blog()


named after the class, Blog
#6

[eluser]ciGR[/eluser]
when you have the link index.php/Blog/
CI call the Blog controller and the index() method for default.
so is like index.php/Blog/index

To call the index.php/blog/test you must have a method test() in the Blog controller.




Theme © iAndrew 2016 - Forum software by © MyBB