Welcome Guest, Not a member yet? Register   Sign In
echo doctype(); == Fatal error: Call to undefined function doctype()
#1

[eluser]kdmp[/eluser]
Now I would assume I loaded this helper correctly in the controller:

Code:
function index()
{
    $this->load->helper('html');
    $this->load->view('search');
}

The first line in search.php is:
Code:
<?php
echo doctype();
?>

Now I am still new to CodeIgniter - please be gentle....lol
#2

[eluser]Thorpe Obazee[/eluser]
did you load the helper?

Code:
$this->load->helper('html');
#3

[eluser]kdmp[/eluser]
That's where I may be confused - in the first quote of my OP you can see I loaded the helper....is that where you would load it? (I would assume so because the img(), meta() and link_tag() are all working fine - it is just the doctype() Sad
#4

[eluser]Thorpe Obazee[/eluser]
are you sure you are on the index method? Try moving the loading to the constructor.
#5

[eluser]kdmp[/eluser]
Yes, what you see above is where I placed it first. I have also tried:

Code:
class Search extends Controller {

    function Search()
    {
        parent::Controller();
        $this->load->helper('html');
    }

    function index()
    {
        
        $this->load->view('search');
        
    }
    
}

I don't think that is right - because that didn't work either. Then again I may not be looking at this right - this is the first time I have tried to call in a helper. Could you show me an example, if you have a simple one handy, to make sure I am on the same page? Smile
#6

[eluser]madeks[/eluser]
You may want to try put it in the auto load config.

I think this way we can ensure the helper is already loaded.
#7

[eluser]srisa[/eluser]
Which version of CI are you using? I am on 1.7.0 and I cannot see the doctype() function in the html_helper.
#8

[eluser]madeks[/eluser]
It is in 1.7.1.

Here Smile
#9

[eluser]jdfwarrior[/eluser]
#1. Have you tried and of the other functions associated with the HTML Helper to ensure that the HTML Helper is in fact loaded?

#2. I know it's supposed to default to XHTML 1.0 Strict but have you tried specifying a doctype to see if that made a difference? Perhaps trying: echo doctype('xhtml1-strict'); instead?
#10

[eluser]John_Betong[/eluser]
[quote author="jdfwarrior" date="1244054901"]#1. Have you tried and of the other functions associated with the HTML Helper to ensure that the HTML Helper is in fact loaded?

#2. I know it's supposed to default to XHTML 1.0 Strict but have you tried specifying a doctype to see if that made a difference? Perhaps trying: echo doctype('xhtml1-strict'); instead?[/quote]
 
I have just stumbled across this problem and discovered that when nothing is passed the default type assumes a missing array value.

You have three choices:
1. change the default in the './system/helpers/html_helper.php'
2. add your own 'xhtml-strict' default to '/sytem/application/config/doctype.php'
3. pass one of the following parameters to doctype(...)
 
Valid doctype parameters (nicked from: '/sytem/application/config/doctype.php'
Code:
'xhtml11',
   'xhtml1-strict',
   'xhtml1-trans'
   'xhtml1-frame',
   'html5',
   'html4-strict',
   'html4-trans'
   'html4-frame'
 
 
 
175




Theme © iAndrew 2016 - Forum software by © MyBB