Rubin Shrestha

Experienced PHP Programmer in various open source applications...

Skype Me

Skype Me
CodeIgniter Forums

  • switching default lang in config.php

    hi all,

    i’m wondering how to switch language in my site…

    I’ve some different language packs in my /language directory.

    this is the scheme:

    -language
        
    -en
        
    ----en_lang.php
        
    -pt
        
    ----pt_lang.php
        
    -sp
        
    ----sp_lang.php 

    now i would like to switch the default language into config.php ($config[‘language’])
    by a session data that i use to set like this:

    $param $this->uri->segment(3);
     
    $this->session->set_userdata('site_lang',$param

    so where i can retrieve session->userdata(‘site_lang’); and put my new session site language for all helpers ,libraries and so on… ??
    thanks guys wink

  • Simple html helper change

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


    /**
     * Generates HTML P tag 
     *
     * @access      public
     * @param       integer
     * @return      string
     */
    if ( ! function_exists('p'))
    {
            
    function p($input,$class=null,$id=null)
            
    {
                    
    if( !is_null($class)){
                            
    if ( !is_null($id)){
                            
    return "<p class="$class" id="$id">$input</p>";}
                            
    return "<p class="$class">$input</p>";
                    
    }
                            
    return "<p>$input</p>";
            
    }
    }

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

    As well as adding for the P tag I added the use of style and Id to the html helper functions.Its simple
     
    and very usefull :) I know of course this isn't in your style

    Ps what a beautiful piece of coding. (minus your terrifying use of shorttags! ;) Thank you. 
  • Cross Reference Table

    Hey all. I’m just starting out with Codeigniter and so far I really like it.

    Anyways, here’s my question. I have three tables: athletes, guardians, and xref_athgrd.

    The athletes table hold athletes, the guardians table holds guardians and the xref tables holds the cross reference so that I can have a many to many relationship. Essentially one athlete can have many guardians, one guardian can have many athletes.

    So I want to create a view that will display the athlete in one row, followed by any guardians the athlete has directly below it in other rows. I’ve been racking my brain for at least two days now and I can’t seem to figure out how to do it. The best I’ve been able to come up with in my brain is that I need to somehow create in the controller an array or object that will hold all the possibilities prior to sending it to the view.

    This is how I’d like it to look:

    Id Name
    05 Ima Athlete01
        Athletes MomGuardian01   555-555-5555   emailmom@email.com
        Ahtletes DadGuardian02   555-553-5353   emaildad@emailcom
    06 Mee Athletealso
        Mees Momguaridan       444-444-4444   meesmomshot@email.com
        Mees Dadsimpotent       444-333-4343   dadneedsviagra@email.com


    Any help would be great.

  • My Request helper or library

    hi all i’m trying to build up my simple personal request_helper just to verify if requests
    isPost() or isGet() or isAjax()
    i named my helper as request_helper and i load it by default in the autoload class.

    i’m trying coding it so:

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



        function 
    isGet($_GET)
            
    {
                
    if($_GET)
                
    {
                    
    return isset($_GET);
                
    }
            }
            
    function isPost($_POST)
            
    {
                
    if($_POST)
                
    {
                    
    return isset($_POST);
                
    }
            }
            
    function isAjax($_SERVER)
            
    {
                
    if($_SERVER['HTTP_X_REQUESTED_WITH'])
                
    {
                    
    return isset($_SERVER['HTTP_X_REQUESTED_WITH']) == 'XMLHttpRequest';
                
    }
            } 

    when i make

    if($this->request->isPost())
                    
    {
                        
    echo 'yes is post';
                    

    the result is

    Call to a member function isPost() on a non-object 

    have you any suggestion guys :( ?

  • important question

    i do check in construct function

    function __construct(){
            
            parent 
    :: controller();    
    // check cookie and admin information        
            
    $this->load->database();
            
    $this->db->where('id','1');
            
    $query_admin $this->db->get('admin_info');
            foreach (
    $query_admin -> result_array() as $admin_info){
                
                
    if (isset($_COOKIE['admin_name']) && isset($_COOKIE['admin_password']) && $_COOKIE['admin_name'== $admin_info['admin_name'&& $_COOKIE['admin_password'== $admin_info['admin_password']){
                
    return true;
                
    }else{
                        $this
    ->load->view('admin/admin_login');
                        return 
    false;
                
    }   
            }
    // end check
        

    but it still execute other functions
    i want to stop executing the other functions

    i think return false; not working

 
Copyrights reserved 2010 | www.rubin.com.np | share this page