Welcome Guest, Not a member yet? Register   Sign In
TIPS in including your DOCUMENT TYPE, FAVICON, META, CSS, JAVASCRIPT, in your web page.
#1

[eluser]rm_beginner[/eluser]
In reviewing the core and some libraries... I want to share some of my modification made in "HTML helpers" and /application/config/doctypes.php.


NOTE: make sure you have css and js folder in your base_url() apply only in your VIEW files..


#USAGE OF YOUR DOCUMENT HEADING without CONSTANT VALUE:

<?php
echo doctype('xhtml1-frame-xmlns');
?>
<head>
<?php
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
echo link_tag('favicon.ico', 'icon', 'image/x-icon');
echo link_tag('css/login.css');
echo link_java('js/jquery-1.5.2.min.js');
?>
<title>MY LOGIN <?php echo lang('login_now'); ?></title>
</head>


OUTPUT IN YOUR "VIEW" FILE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-type" c charset=utf-8" /&gt;
&lt;link href="http://localhost/favicon.ico" rel="icon" type="image/x-icon" /&gt;
&lt;link href="http://localhost/css/login.css" rel="stylesheet" type="text/css" /&gt;
[removed][removed]
&lt;title&gt;MY LOGIN .. &lt;/title&gt;
&lt;/head&gt;


#USAGE OF YOUR DOCUMENT HEADING WITH CONSTANT VALUE e.g. APPLICATION VERSION

&lt;?php
echo doctype('xhtml1-frame-xmlns');
?&gt;
&lt;head&gt;
&lt;?php
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
echo link_tag('favicon.ico', 'icon', 'image/x-icon');
echo link_tag('css/login.css?.'.APPLICATION_VERSION);
echo link_java('js/jquery-1.5.2.min.js?'.APPLICATION_VERSION);
?&gt;
&lt;title&gt;MY LOGIN &lt;?php echo lang('login_now'); ?&gt;&lt;/title&gt;
&lt;/head&gt;


OUTPUT IN YOUR "VIEW" FILE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-type" c charset=utf-8" /&gt;
&lt;link href="http://localhost/favicon.ico" rel="icon" type="image/x-icon" /&gt;
&lt;link href="http://localhost/css/login.css?.1.0" rel="stylesheet" type="text/css" /&gt;
[removed][removed]
&lt;title&gt;MY LOGIN .. &lt;/title&gt;
&lt;/head&gt;



MODIFICATION #1: In system/helpers/html_helper.php add this to include JAVASCRIPT FILE in your PAGE.


// ------------------------------------------------------------------------

/**
* Link
*
* Generates link to a JAVASCRIPT file
*
* @access public
* @param mixed stylesheet hrefs or an array
* @param string type
* @param string language
* @param string charset
* @param boolean should index_page be added to the javascript path
* @return string
* Author: [email protected]
*/
if ( ! function_exists('link_java'))
{
function link_java($href = '', $type = 'text/javascript', $language = 'javascript', $charset = 'UTF-8', $index_page = FALSE)
{
$CI =& get_instance();

$link = '[removed]$v)
{
if ($k == 'src' AND strpos($v, '://') === FALSE)
{
if ($index_page === TRUE)
{
$link .= 'src="'.$CI-&gt;config-&gt;site_url($v).'" ';
}
else
{
$link .= 'src="'.$CI-&gt;config-&gt;slash_item('base_url').$v.'" ';
}
}
else
{
$link .= "$k=\"$v\" ";
}
}

$link .= '>[removed]'."\n"; //arman put enter
}
else
{
if ( strpos($href, '://') !== FALSE)
{
$link .= 'src="'.$href.'" ';
}
elseif ($index_page === TRUE)
{
$link .= 'src="'.$CI-&gt;config-&gt;site_url($href).'" ';
}
else
{
$link .= 'src="'.$CI-&gt;config-&gt;slash_item('base_url').$href.'" ';
}

$link .= 'type="'.$type.'" ';

if ($charset != '')
{
$link .= 'charset="'.$charset.'" ';
}

if ($language != '')
{
$link .= 'language="'.$language.'"';
}

$link .= '>[removed]'."\n"; //arman put enter
}


return $link;
}
}



MODIFICATION #2: insert this array element in /config/doctype.php

'xhtml1-frame-xmlns' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'."\n".'&lt;html &gt;'."\n\r",




You can autoload your helper in /application/config/autoload.php

$autoload['helper'] = array('html')





Theme © iAndrew 2016 - Forum software by © MyBB