mardi 30 juin 2015

Codeigniter Controller View table->add_row "if else statement"

Its been a few days I am stuck with this. I am trying to add different views in add_row function in my Codeigniter Controller.

What we have done recently is; adding new type of memberships to Business Directory. So one is called gold membership one is normal membership. Gold Membership to show more info of different info than normal members.

Here is existing code for my controller:

$checkAllData = array("name"=>"action_to_all","id"=>"action_to_all","onclick"=>"toggleChecked(this.checked)" );

    // table  headder
    $this->table->set_heading("Logo",
          "Company Name",
          "Membership Type",
          "Address - Phone Number"
        );

    $i = 0 + $offset;

    foreach ( $companies_list as $dataList) {
    $checkBox = array("name"=>"action_to[]","id"=>"action_to[]", "class"=>"checkbox", "value"=>$dataList->id );
    $this->table->add_row(
    anchor(base_url()."business/view/".$dataList->id."/".$this->MCommon->seo_url($dataList->business_name),
    '<img src="'.base_url().$this->image_path.$dataList->image.'" />' ,array("class"=>"list_action_view")),

    anchor(base_url()."business/view/".$dataList->id."/".$this->MCommon->seo_url($dataList->business_name),$dataList->business_name, array("class"=>"list_action_view")).$this->commonlib->setValue($this->business_type_list, $dataList->business_type_id),

    $dataList->membership_type,

    $dataList->address.$dataList->tel_no
        );
    }

What I want to do is to display a basic Logo and no address to display for normal members. Something like this:

// table  headder
    $this->table->set_heading("Fotoğraf",
          "Company Name - Sector",
          "Membership Type",
          "Address - Phone Number"
        );

    $i = 0 + $offset;

    foreach ( $companies_list as $dataList) {
    $checkBox = array("name"=>"action_to[]","id"=>"action_to[]", "class"=>"checkbox", "value"=>$dataList->id );
    $this->table->add_row(

    **if($datalist->membership_type==gold_member) {**

    anchor(base_url()."business/view/".$dataList->id."/".$this->MCommon->seo_url($dataList->business_name),
    '<img src="'.base_url().$this->image_path.$dataList->image.'" />' ,array("class"=>"list_action_view")),

    anchor(base_url()."business/view/".$dataList->id."/".$this->MCommon->seo_url($dataList->business_name),$dataList->business_name, array("class"=>"list_action_view")).$this->commonlib->setValue($this->business_type_list, $dataList->business_type_id),

    $dataList->membership_type,

    $dataList->address.$dataList->tel_no

    **}
    else    
    {
    'Set New View'
    }**
        );
    }

We called Membership Types as "membership_type" which are gold_member and normal_member.

Thank you for any clue that you can give me

Aucun commentaire:

Enregistrer un commentaire