Welcome Guest, Not a member yet? Register   Sign In
  One method - many views
Posted by: El Forum - 10-21-2008, 07:26 AM - Replies (4)

[eluser]nws123[/eluser]
How to in one method add many views ?

Code:
public function active()
    {
        $this->load->model('survey_model');
        $this->load->library('auth');
        $this->data = array('survey' =>  $this->survey_model->loadPublished($this->auth->getUser()->userId));
        $this->load->library('design');
        $this->design->header('header_logged');
                //one view i need 4
        $this->load->view('/survey/active',$this->data);
        $this->design->footer('footer_logged');
        
    }


  Resetting class variables to defaults
Posted by: El Forum - 10-21-2008, 06:58 AM - Replies (2)

[eluser]Daniel H[/eluser]
I start my models with..

Code:
<?php

class x_model extends Model {
    
    // Table name
    var $table = '';
    
    // Order field name
    var $order_field = array();
    
    // Limit and offset
    var $limit = NULL;
    var $offset = NULL;
    
    // Field names in the database table
    var $id = NULL;
    var $name = NULL;
    // etc...

... and then I have a reset() function that looks like this...

Code:
function reset()
    {
        // Ensure all the variables are listed here
        $this->id = NULL;
        $this->name = NULL;
        // etc...
        
        $this->limit = NULL;
        $this->offset = NULL;
        
        $this->order_field = array();
    }

Instead of listing out all the variables again with their defaults, is there a shorthand which just sets the variables back to their original values?

Many thanks,

Dan.


  drop down menus
Posted by: El Forum - 10-21-2008, 06:58 AM - Replies (6)

[eluser]babu[/eluser]
hello experts,
i need help regarding drop down menus.In my dropdownmenu,options values should get from the database.

example for static dropdownmenus.

<tr>
<TD align="right" width="120" class="forrowcolr">
&lt;?php echo form_label('Category : ');?&gt;
</TD>
<TD align="left" class="forrowcolr">&lt;?php $options = array('Books'=>'Books','Calligraphy'=>'Calligraphy','Miniatures'=>'Miniatures','Prints'=>'Prints','Watercolours'=>'Watercolours','Photographs'=>'Photographs');?&gt;
&lt;?php echo form_dropdown('category', $options);?&gt;</TD>

</tr>

here the values are static.what i need is,options values should get from the database.if i change anything from the database.options values should get updated.very urgent pls..thanks in advance


  Active Record insert() multiple rows at once
Posted by: El Forum - 10-21-2008, 06:51 AM - Replies (7)

[eluser]meglio[/eluser]
Is it possible?


  meta() function not documented.
Posted by: El Forum - 10-21-2008, 06:03 AM - Replies (4)

[eluser]DooBie[/eluser]
Hi all, I have seen in html_helper that there is a new feature that is not documented, but it is very useful, at least for me, the function is this:

Code:
// ------------------------------------------------------------------------

/**
* Generates meta tags from an array of key/values
*
* @access    public
* @param    array
* @return    string
*/
if ( ! function_exists('meta'))
{
    function meta($meta = array(), $newline = "\n")
    {
        $str = '';
        foreach ($meta as $key => $val)
        {
            $str .= '&lt;meta http-equiv="'.$key.'" content="'.$val.'" /&gt;'.$newline;
        }

        return $str;
    }
}
Why not come out in the documentation?

Thanks, and sorry my poor english


  load second dropdown values based on the first (how to implement AJAX)
Posted by: El Forum - 10-21-2008, 05:01 AM - Replies (4)

[eluser]bhakti.thakkar[/eluser]
Hi,
i am new to CI.
View:

Code:
[removed]
function LoadSubprograms(Project_ID)
  {
//      alert(Project_ID);
    var ObjHttp= new CreateNewHttpObject();
    if(ObjHttp)
    {
      var dataSource = "&lt;?=base_url()?&gt;certificates/get_subprograms/"+Project_ID;

      ObjHttp.open("post", dataSource);
      ObjHttp.onreadystatechange = function()
      {
          alert('here');
        if (ObjHttp.readyState == 4 && ObjHttp.status == 200)
        {
          var returnVal=ObjHttp.responseText;
          alert(returnVal);
          document.getElementById(Subprogram_ID).value=returnVal;
        }
        ObjHttp.send(null);
      }
    }
  }

  function CreateNewHttpObject()    //Create an Instance of HTTP request.
{
    var xmlHttp=null;
    try{      // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
    }
    catch (e){          // Internet Explorer
      try{
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e){
       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     }
     return xmlHttp;
  }

[removed]
<TABLE width="100%" class="table" cellpadding=3 cellspacing=1>
&lt;form name="mainform" method=post&gt;
<TR>
    <TD width="20%" class="tdheader">Projects</TD>
    <TD class="datatd"><select name="Project_ID" id="Project_ID">
        &lt;? foreach($query->result() as $row) { ?&gt;
            <option name="Project_ID" value="&lt;?=$row->Project_ID?&gt;">&lt;?=$row->Project_ID?&gt;</option>
        &lt;? } ?&gt;
    </select></TD>
</TR>
<TR>
    <TD class="tdheader">Subprogram</TD>
    <TD class="datatd">
<select name="Subprogram_ID" id="Subprogram_ID">
        &lt;? foreach($subprog_query ->result() as $row2) { ?&gt;
            <option value="&lt;?=$row2->Subprogram_ID?&gt;">&lt;?=$row2->Subprogram_ID?&gt;</option>
        &lt;? } ?&gt;
    </select> </TD>
</TR>
<TR>
    <TD class="tdheader">Certificate type</TD>
    <TD class="datatd">
    <select name="CertificateType">
        <option value="1">Transaction certificate</option>
        <option value="2">Import / Transaction certificate</option>
    </select></TD>
</TR>


Controller :
Code:
function get_subprograms($Project_ID)
{
        $this->load->library('ajax');
        $this->load->model('projects_model');

        $subprog_query = $this->projects_model->getSubprograms($Project_ID);
//        print_r($subprog_query);
        return $subprog_query;
        
    }

}

Nothing happens. can anyone please help me in this


  Developing models quickly? Any tips...
Posted by: El Forum - 10-21-2008, 04:32 AM - Replies (6)

[eluser]Daniel H[/eluser]
My new projects data model design comprises 66 db tables. Developing models for each table is terrifying me! The thing is every model is practically the same - class variables the same as the field names, and reset(), save(), delete() methods.

Does anyone have a neat method for auto-generating their models or should I just get on with it and stop complaining?!


  help
Posted by: El Forum - 10-21-2008, 04:07 AM - No Replies

[eluser]babu[/eluser]
pls help me to sort my problem...

1) how can upload multiple images.just like in the mail.
(In mail,while composing.we can upload multiple images or doc.
here i want to upload only images)

2)i am having two tabs,inventory and definitions.
In the definitions tab page, i am having one inputbox(size).In that inputbox,i am adding size.That will added to the database.after adding in the database.it should available in the inventory section's size dropdown list.both tabs using different controllers and models.i dont know how to do it..if anybody know it.pls help me with the examples to do this..

thank you in advance


  1 error message at the time, custom regexp check on field
Posted by: El Forum - 10-21-2008, 03:41 AM - Replies (4)

[eluser]CrustyDOD[/eluser]
Before i write my own 'addon' to the core, i'm just double checking that i haven't missed this somewhere in the guides and code..

1 error message at the time
Right now as far as i know (just started using CI) you have two options:
- Show ALL error messages at once
- Show error message per field (still shows more then just one error message)

I would like to show only one error message at the time by calling just one function. Is there a functions in the CI core right now that does this?

For example look at youtube sign up. If you miss one field, it shows just one error message for field you missed, and not ALL like CI is doing it right now.

custom regexp check on field
Is there a rule for custom regexp on a field?
Let's say i have drop down with values 1 and 2. I want to check that what someone submitted really is a value 1 or 2, and not 0, 3,4,5,... (faking form in this case).

Does this rule exist in the CI core?

Like i said, i'm just double checking cause i'm new to CI and i really like it.. and don't want to write something that already exist Smile


  Using objects without instantiating them by default
Posted by: El Forum - 10-21-2008, 02:47 AM - No Replies

[eluser]mddd[/eluser]
I am building some applications which use lists of items. I want to use a structure where the list itself is represented by an object, and each item is also an object. So I would make a new list with $list = new List; and that would have a property $list->items containing an array of objects, each created by $item = new Item;

My question is, what is the best way to do this in the CI framework. Making 'list' and 'item' models, they would always be loaded if I declare them in a contructor in my controller. So I would have an 'extra' list object and item object 'hanging around'.

What would be the cleanest way to do something like this?


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Version number stays un-u...
by trunky
1 hour ago
codeigniter4/queue Not lo...
by mywebmanavgat
6 hours ago
Array to HTML "Table"
by HarmW94
7 hours ago
shortcodes for ci4
by xsPurX
8 hours ago
TypeError when trying to ...
by b126
Today, 12:04 AM
Webhooks and WebSockets
by InsiteFX
Yesterday, 10:39 AM
Retaining search variable...
by pchriley
Yesterday, 05:46 AM
Reading a session variabl...
by xanabobana
Yesterday, 05:05 AM
Update to v4.5.1, same us...
by kenjis
04-17-2024, 07:47 PM
Codeigniter 4 extend core...
by Semsion
04-17-2024, 05:08 AM

Forum Statistics
» Members: 84,586
» Latest member: f8betcasino
» Forum threads: 77,560
» Forum posts: 375,900

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB