bumpකඩ්ඩ බැරි එකා;18049466 said:කොල්ලනේ මම codeigniter ගැන දෙයක් දැන ගන්න ඕන.
මගේ සයිට් එකට header.php and footer.php කියල දෙකක් තියෙනව. මේ දෙක තමයි හැම controller එකටම මම ලෝක් කරන්නේ. එතකොට ලේසිනේ. මොකද එකම ෆයිල් හැම එකටම ලෝඩ් වෙනකොට එකක වෙනසක් කරාම හැම එකටම බලපානවනේ..
ඒත් දැන් මට මේකම අවුලක් වෙලා තියෙන්නේ.
මට ඕන එක එක controllers වලට විවිද files ඒ කිව්වේ css, js files කෝල් කරන්න. ඒත් අර common footer and header දෙකත් ඒ විදියට කෝල් වෙන්න ඕන..
උදාහරණයක් විදියට.
contact කියන controller එක කෝල් කරාම එ්කට අදාල js, css ෆයිල්ස් විතරක් එන්න ඕන.
අපි about කියන controller එක කෝල් කරාම ඒව එන්න බෑ. එතකොට ලෝඩ් වෙන්න ඕන ඒකද අදාල ඒව විතරයි. ඒත් මේ හැම කොන්ට්රෝල එකටම පොදුවේ ලෝඩ් වෙන්න ඕන සමහර ෆයිල්ස්.
සරලව කියනව නම් dynamic header and footer එකක් හදාගන්නඕන.
![]()
Machan mokada wena wena pages walata wena wena CSS and JS call karanne? Poddak eeka gana mata pahadili karanna eeta passe man oyata honda wisadumak denna try karannamකඩ්ඩ බැරි එකා;18049466 said:කොල්ලනේ මම codeigniter ගැන දෙයක් දැන ගන්න ඕන.
මගේ සයිට් එකට header.php and footer.php කියල දෙකක් තියෙනව. මේ දෙක තමයි හැම controller එකටම මම ලෝක් කරන්නේ. එතකොට ලේසිනේ. මොකද එකම ෆයිල් හැම එකටම ලෝඩ් වෙනකොට එකක වෙනසක් කරාම හැම එකටම බලපානවනේ..
ඒත් දැන් මට මේකම අවුලක් වෙලා තියෙන්නේ.
මට ඕන එක එක controllers වලට විවිද files ඒ කිව්වේ css, js files කෝල් කරන්න. ඒත් අර common footer and header දෙකත් ඒ විදියට කෝල් වෙන්න ඕන..
උදාහරණයක් විදියට.
contact කියන controller එක කෝල් කරාම එ්කට අදාල js, css ෆයිල්ස් විතරක් එන්න ඕන.
අපි about කියන controller එක කෝල් කරාම ඒව එන්න බෑ. එතකොට ලෝඩ් වෙන්න ඕන ඒකද අදාල ඒව විතරයි. ඒත් මේ හැම කොන්ට්රෝල එකටම පොදුවේ ලෝඩ් වෙන්න ඕන සමහර ෆයිල්ස්.
සරලව කියනව නම් dynamic header and footer එකක් හදාගන්නඕන.
![]()

easy.
lets say you have about page
1). divide its unique JS/CSS to a separate view. lets call it about_page_includes.php
2). use it like this
$this->load->view('header');
$this->load->view('about_page_includes');
$this->load->view('aboutPage');
$this->load->view('footer');
Of course you can create some smart helper function with it and use it. I'm showing here the basic idea![]()

Podi Silva - පොඩි සිල්වා;18049592 said:නොදනිමි බම්ප් මචන් දැන් කොහොමද වැඩේ නැගලා යනවද

Machan library ekak liya ganin, ita passe object ekak thule ona JS, CSS library ekata pass karanna view ekath ekkama


කඩ්ඩ බැරි එකා;18049619 said:ඔව් මචං ඒකට අදාල සයිට් එකේ වැඩකට මේකත් දැම්මේ![]()
public function view($viewname,$header_info)
{
$CI =& get_instance();
$header = (object) NULL;
//title
if (isset($header_info->title))
{
$header->title = $header_info->title;
}
else
{
$header->title = 'Default Page Title Here';
}
// Adding CSS External Source
$header->css = array(
'http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css',
'assets/css/style.css','assets/css/reveal.css','assets/css/carouFredSel.css','assets/css/layout.css');
if (isset($header_info->css))
{
$header->css = array_merge((array)$header->css, (array)$header_info->css);
}
// Adding Javascript External Source
$header->js = array(
'assets/js/jquery-1.7.1.min.js',
'assets/js/jquery-ui.js',);
if (isset($header_info->js))
{
$header->js = array_merge((array)$header->js, (array)$header_info->js);
}
//display header
$CI->load->view('layout/header',$header);
// Unsetting all other links
unset($header_info->title);
unset($header_info->css);
unset($header_info->js);
// Mid Contaner Layout
$midfilepath = $viewname.'.php';
$CI->load->view($midfilepath,$header_info);
// Load Footer file
$CI->load->view('layout/footer');
}
machan aluthin library ekak liyanna menna magen podi help ekak
PHP:public function view($viewname,$header_info) { $CI =& get_instance(); $header = (object) NULL; //title if (isset($header_info->title)) { $header->title = $header_info->title; } else { $header->title = 'Default Page Title Here'; } // Adding CSS External Source $header->css = array( 'http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css', 'assets/css/style.css','assets/css/reveal.css','assets/css/carouFredSel.css','assets/css/layout.css'); if (isset($header_info->css)) { $header->css = array_merge((array)$header->css, (array)$header_info->css); } // Adding Javascript External Source $header->js = array( 'assets/js/jquery-1.7.1.min.js', 'assets/js/jquery-ui.js',); if (isset($header_info->js)) { $header->js = array_merge((array)$header->js, (array)$header_info->js); } //display header $headerpath = 'layout/header.php'; if(file_exists(APPPATH.'views/'.$headerpath)) { $CI->load->view($headerpath,$header); } else { $CI->load->view('layout/header',$header); } // Unsetting all other links unset($header_info->title); unset($header_info->css); unset($header_info->js); // Mid Contaner Layout $midfilepath = $viewname.'.php'; $CI->load->view($midfilepath,$header_info); // Load Footer file $footer = (object) NULL; $footerpath = 'layout/footer.php'; if(file_exists(APPPATH.'views/'.$footerpath)) { $CI->load->view($footerpath,$footer); } else { $CI->load->view('layout/footer',$footer); } }
Machan edit kara eka ganin

machan aluthin library ekak liyanna menna magen podi help ekak
ita passe machan header eke JS, CSS tika loop karala daganinPHP:public function view($viewname,$header_info) { $CI =& get_instance(); $header = (object) NULL; //title if (isset($header_info->title)) { $header->title = $header_info->title; } else { $header->title = 'Default Page Title Here'; } // Adding CSS External Source $header->css = array( 'http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css', 'assets/css/style.css','assets/css/reveal.css','assets/css/carouFredSel.css','assets/css/layout.css'); if (isset($header_info->css)) { $header->css = array_merge((array)$header->css, (array)$header_info->css); } // Adding Javascript External Source $header->js = array( 'assets/js/jquery-1.7.1.min.js', 'assets/js/jquery-ui.js',); if (isset($header_info->js)) { $header->js = array_merge((array)$header->js, (array)$header_info->js); } //display header $CI->load->view('layout/header',$header); // Unsetting all other links unset($header_info->title); unset($header_info->css); unset($header_info->js); // Mid Contaner Layout $midfilepath = $viewname.'.php'; $CI->load->view($midfilepath,$header_info); // Load Footer file $CI->load->view('layout/footer'); }