yesx

Banned
Feb 12, 2015
85
6
0
කඩ්ඩ බැරි එකා;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 එකක් හදාගන්නඕන.

;);)
bump
 

cnk_123

Well-known member
  • Jun 17, 2008
    1,152
    317
    83
    කඩ්ඩ බැරි එකා;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
     

    RCROCKS

    Well-known member
  • Sep 2, 2008
    2,076
    117
    63
    in my mobile
    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 :)
     
  • Oct 16, 2013
    3,326
    1,885
    113
    Nugegoda
    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 :)

    ඔව් මචං එහෙම පුලුවන් ඒත් අවුල තියෙන්නේ. මග‍ේ header එකේ <body> එකෙන් ඉවර වෙන්නේ. අන්න ඒකයි අවල. මේ වැඩේ කරන්න නම් header එක දෙකකට කඩල ඒ අතරට තමයි කෝල් කරන්න වෙන්‍නේ නමුත් ඒක නිකන් චාටර් වගේ. :dull:
     
  • Oct 16, 2013
    3,326
    1,885
    113
    Nugegoda
    Podi Silva - පොඩි සිල්වා;18049592 said:
    නොදනිමි බම්ප් මචන් දැන් කොහොමද වැඩේ නැගලා යනවද

    ඔව් මචං ඒකට අදාල සයිට් එකේ වැඩකට මේකත් දැම්මේ :)
     
  • Oct 16, 2013
    3,326
    1,885
    113
    Nugegoda
    Machan library ekak liya ganin, ita passe object ekak thule ona JS, CSS library ekata pass karanna view ekath ekkama

    මම මචං මේවට අලුත් මම මගේ සයිට් එක wp වලින් ගහන්න අරන් අතඇරිය මොකද ඒක ඕනවටත්වඩා වැඩියි. පස්‍ේස ඒක ci වලින් පටන්ගත්ත දැන් සයිට් එක ගොඩක් ඉවරයි. මේ අවුල තමයි කේස් එක. ඇත්තටම අවුලක් නෑ. සයිට් එක වැඩ. ඒ උනාට නිකන් හරි නෑ හරි නෑ වගේ. :sorry::sorry:
     

    vdilshan

    Well-known member
  • Apr 21, 2011
    1,653
    155
    63
    Colombo, LK
    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
            $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');
            
        }

    ita passe machan header eke JS, CSS tika loop karala daganin
     
    Last edited:
    • Like
    Reactions: shenic
  • Oct 16, 2013
    3,326
    1,885
    113
    Nugegoda
    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);
            }
        }

    ela... thanks machan
     

    shenic

    Member
    May 9, 2013
    13,213
    1,290
    0
    Bermuda ∆
    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
            $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');
            
        }
    ita passe machan header eke JS, CSS tika loop karala daganin

    11.gif
    11.gif
    11.gif
    11.gif
    11.gif
    (+7)