Welcome Guest, Not a member yet? Register   Sign In
Doctype Plugin
#7

[eluser]Adam Griffiths[/eluser]
Ok, so I made another version, it's more like yours but you don't need to echo the function.

doctype_pi.php

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
* Doctype
*
* Generates a doctype based on the strings passed to the function.
* Defaults to xHTML Strict
*
* @access    public
* @param    string
* @return    string
*/

function doctype($doctype)
{
    $CI =& get_instance();
    $CI->config->load('doctypes');
    
    echo $CI->config->item($doctype);
    
} // doctype

/* End of file doctype_i.php */
/* Location: application/helpers/doctype_pi.php */

config/doctypes.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['xhtml-strict'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";

$config['xhtml-transitional'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";

$config['xhtml-frameset'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";

$config['html-strict'] = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n";

$config['html-transitional'] = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";

$config['html-frameset'] = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">\n";

/* End of file doctypes.php */
/* Location: application/config/doctypes.php */

Usage
Code:
&lt;?php doctype('xhtml-strict'); ?&gt;

or

Code:
&lt;?=doctype('xhtml-strict');?&gt;

As before, xHTML and HTML Strict, Tranisitional and Frameset are supported.

Oh and @my error messages, there is no way on earth that they would be shown to the user in the file I gave, it was just a bit of fun. I used it in a project with another developer and it made us both laugh. It was just a quick knockup of a function we needed to have.


Messages In This Thread
Doctype Plugin - by El Forum - 09-02-2008, 02:45 PM
Doctype Plugin - by El Forum - 09-02-2008, 03:19 PM
Doctype Plugin - by El Forum - 09-02-2008, 03:36 PM
Doctype Plugin - by El Forum - 09-03-2008, 02:28 AM
Doctype Plugin - by El Forum - 09-03-2008, 03:14 AM
Doctype Plugin - by El Forum - 09-03-2008, 03:42 AM
Doctype Plugin - by El Forum - 09-03-2008, 04:02 AM
Doctype Plugin - by El Forum - 09-13-2008, 04:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB