Welcome Guest, Not a member yet? Register   Sign In
  aplication names
Posted by: El Forum - 11-11-2007, 04:55 PM - Replies (1)

[eluser]plainas[/eluser]
I notice when i tried to access the scaffolding that the capitals were removed from the scaffolding links to the edit and add pages.

like, if my scaffold url is:

http://localhost/MyApp/index.php/control...secretword

The links to the add and edit links point to:

http://localhost/Myapp/index.php/control...secretword

Note the non-capital 'a' in the word "Myapp".

Is this a bug or am i breaking any development rule?


  Newbie question : can I load a model within a model ?
Posted by: El Forum - 11-11-2007, 03:08 PM - Replies (2)

[eluser]Unknown[/eluser]
Hi

I'm trying CodeIgniter on a small project.
I need to make an object by mixing datas from several tables. I've made a Model (ex : model1, model2, model3) for each table and I would like to use model2 and model3 in model1.
Is it possible ?
Is there another approach to do that ?

Thanks in advance,

Swdes


  Testing Codeigniter Application Locally
Posted by: El Forum - 11-11-2007, 11:13 AM - Replies (3)

[eluser]dgriffter[/eluser]
Hi,

I have a web app written in CodeIgniter which I have to alter. In order for the app to work on my local machine, would I first have to install CodeIgniter on my localhost? If this is the case, which folders/files would I have to import onto my local machine to perform testing? I assume I wouldn't have to re-write the entire app again.

Thank you all in advance for your help, I'm very new to all this.

Dgriffter


  Calling a public controller method from a view?
Posted by: El Forum - 11-11-2007, 10:00 AM - Replies (11)

[eluser]europe72[/eluser]
Still a newbie with CI...

I have a controller named A

In controller A I have a method named Foo

In a view, I want to call method Foo from controller A

How is this done?

If I try $A = new A();
$A->Foo();

PHP errors out on me

Thanks


  Select Menu to change Price on select
Posted by: El Forum - 11-11-2007, 08:46 AM - Replies (12)

[eluser]Brad Haynes[/eluser]
I have a product detail page with a select menu where you can choose different tire sizes. There are 12 different tires and 12 (maybe more) different tire sizes. Each tire has available different sizes that you can choose from a drop down menu.

http://stonetire.dreamhosters.com/store/xch4/

I need, when a size is selected, for the price to change. NO IDEA how to go about doing this.

I'm thinking of probably using category variable to add metadata to each category, but that would make EACH SIZE be a different price, which isn't necessarily the case, since different tires might have the same size in stock.

I'm suspecting some serverside php scripting or clientside javascript, perhaps even some ajax. This is a little over my head, so I was hoping some kind soul might help me out.

Thanks in advance,
Brad


  Will trade hugs for help with DOMPDF
Posted by: El Forum - 11-10-2007, 09:23 PM - Replies (5)

[eluser]stevefink[/eluser]
So I know it's a plugin that's not officially supported with CI, but if anyone has ever gotten it to successfully work with their project, I'd really appreciate some insight. I'm trying to generate an extremely simple PDF based on a simple table with HTML. For now I'm just having difficulty of creating the PDF itself. Ultimately I'd like to encrypt it and fire it off in an e-mail, but that comes later. The following code produces output buffering issues. I'm just trying to write the PDF to disk, not output anything to the client... is there a way to avoid having dompdf not do that?

Code:
function generate_cpt_report() {
        
          $this->load->plugin('to_pdf');
        $this->load->helper('file');
      
        $date = $this->input->post('cpt_date');
                
        /* we need to select all patients visited
           according to the date above
        */
        $patients_visited = $this->dbmodel->select_visited_patients($date);
        
        log_message('debug', "were patients visited that day? ".print_r($patients_visited, TRUE));
        
        /* generate and draw the report table */
        $html = '';
        $html = '<table>
                    <tr>
                        <th>Patient Name</th>
                        <th>CPT</th>
                    </tr>';
        
        if ( $patients_visited->num_rows() > 0 ) {
                        
            foreach ( $patients_visited->result() as $p ) {
        
                $html .=    '<tr>      
                                <td>' . $p->last_name . ', ' . $p->first_name . '</td>
                                <td>' . $p->code_name . '</td>
                            </tr>';
                
            }
    
                $html .= '</table>';        
    
        } else {
            
            $html = '<p>Patients were not visited on<br> ' . $date . '.';
            
        }
                
        echo $html;
        
        pdf_create($html, 'foo.pdf');
            
    }
}

Cheers,

- sf


  Form validation question
Posted by: El Forum - 11-10-2007, 03:18 PM - Replies (5)

[eluser]Unknown[/eluser]
Hello!

I would like to know how can I implement form validation without making another view for the form. My working code is the one shown in the video tutorial from CI's website (the blog). I would like to validate the comment adding form. Here is the code for comments_view.php and here is the one for blog.php

Any suggestions?

Thanks in advance.


  How to prevent CI from dumping SQL on screen when err occurs?
Posted by: El Forum - 11-10-2007, 12:31 PM - Replies (13)

[eluser]starenka[/eluser]
How to prevent CI from dumping SQL on screen when error occurs? These messages are pretty fancy while developing, but it's a hazard show such data on production servers.. anybody can put me into it? thanx


  What's the best way to include a dynamic header
Posted by: El Forum - 11-10-2007, 12:07 PM - Replies (4)

[eluser]MrTacoz[/eluser]
Hi,

I am re-implementing a site in CI.

In my existing site, I have a dynamic header that gets included into most of my other pages. This header is a dynamic page that loads some junk from a database (e.g. in the header is a field that shows how many friends you have).

I was thinking I'd use something like this in all the views that need to include the header:

Code:
&lt;?= $this->load->view('main/header');?&gt;
But I'd like a controller for the header that would grab the data out of the database and provide this data to the header view to create the dynamic content in the header.

One solution would be for each controller class that loads a view that would include the header could pull this data from the database and pass it to the main views which would in turn pass the data to the header view. This approach seems lame, 'cause I'd like to encapsulate the knowledge of grabbing the data for the header in a controller for the header. I just don't know how to use some sort of a load that will result in a controller being executed and displaying the header view.

Maybe this should be obvious, but I've spent quite a while looking in the docs and searching around on this forum and I can't find how to do this.

Would someone please point me to an example of something like this.

For example, in my main controller I have:
Code:
function index()
{
    $this->load->view('main/main_view');
}
Code:
function header()
{
    $data['user_count']=$this->db->count_all('members');
    $this->load->view('main/header', $data);
}

In main_view.php, I have:
Code:
<div >
            
            &lt;?= $this->load->view('main/header');?&gt;

</div>

So if I load http://mysite/index.php/main/header, the controller does the db query and gets the data.
If I load the main_view via index.php, the header has no data (because I'm not passing data into the header view from main_view).

Is there a way to call a controller from inside the main_view -- essentially performing the equiv of loading "http://mysite/index.php/main/header" inside my main_view.php ( i.e. some other call instead of &lt;?= $this->load->view('main/header');?&gt; )?

I could have the controller for every page (like the index()) perform the query and pass the data to the main_view, which would in turn pass the data to the header, but this means that I can't encapsulate the info into a header control & view which is what I'd like to be able to do.

Please let me know if you'd like more info, but I'm hoping this provides enough information about what I am trying to do for someone to suggest a solution.

Thanks!!!


  Pagination using per_page to increment page numbers fix
Posted by: El Forum - 11-10-2007, 11:43 AM - Replies (8)

[eluser]Frank Wong[/eluser]
Problem: Pagination uses per_page attribute to increment page numbers.

Example:
per_page = 5;
Page 1 - /seg1/seg2/
Page 2 - /seg1/seg2/5
Page 3 - /seg1/seg2/10
etc

System:
CI 1.5.4
Windows XP Pro
Apache2
php5

Fixed Pagination.php->create_links():
I left the original code commented out where I made changes.
Hope this helps some people.

----------Begin----------
function create_links()
{
// If our item count or per-page total is zero there is no need to continue.
if ($this->total_rows == 0 OR $this->per_page == 0)
{
return '';
}

// Calculate the total number of pages
$num_pages = ceil($this->total_rows / $this->per_page);
// echo $num_pages;
// Is there only one page? Hm... nothing more to do here then.
if ($num_pages == 1)
{
return '';
}

// Determine the current page number.
$CI =& get_instance();
if ($CI->uri->segment($this->uri_segment) != 0)
{
$this->cur_page = $CI->uri->segment($this->uri_segment);

// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}

if ( ! is_numeric($this->cur_page))
{
$this->cur_page = 0;
}

if ($this->cur_page==0)
{
$this->cur_page = 1;
}

// Is the page number beyond the result range?
// If so we show the last page
if ($this->cur_page > $this->total_rows)
{
$this->cur_page = ($num_pages - 1) * $this->per_page;
}

$uri_page_number = $this->cur_page;
// $this->cur_page = floor(($this->cur_page/$this->per_page) + 1);

// Calculate the start and end numbers. These determine
// which number to start and end the digit links with
$start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
$end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
//echo $start." ";
//echo $end;
// Add a trailing slash to the base URL if needed
$this->base_url = rtrim($this->base_url, '/') .'/';

// And here we go...
$output = '';

// Render the "First" link
if ($this->cur_page > $this->num_links)
{
$output .= $this->first_tag_open.'<a href="'.$this->base_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
}

// Render the "previous" link
// echo $this->num_links;
if (($this->cur_page - $this->num_links) >= 0)
{
// $i = $uri_page_number - $this->per_page;
$i = $this->cur_page - 1;
// echo $i;
if ($i == 0) $i = '';
$output .= $this->prev_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}

// Write the digit links
for ($loop = $start -1; $loop <= $end; $loop++)
{
$i = ($loop * $this->per_page) - $this->per_page;
// $i = $loop;

if ($i >= 0)
{
if ($this->cur_page == $loop)
{
$output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
}
else
{
// $n = ($i == 0) ? '' : $i;
$n = ($i == 0) ? '' : $loop;
$output .= $this->num_tag_open.'<a href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
}
}
}

// Render the "next" link
if ($this->cur_page < $num_pages)
{
// $output .= $this->next_tag_open.'<a href="'.$this->base_url.($this->cur_page * $this->per_page).'">'.$this->next_link.'</a>'.$this->next_tag_close;
$output .= $this->next_tag_open.'<a href="'.$this->base_url.($this->cur_page + 1).'">'.$this->next_link.'</a>'.$this->next_tag_close;
}

// Render the "Last" link
if (($this->cur_page + $this->num_links) < $num_pages)
{
// $i = (($num_pages * $this->per_page) - $this->per_page);
$i = $num_pages;
$output .= $this->last_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->last_link.'</a>'.$this->last_tag_close;
}

// Kill double slashes. Note: Sometimes we can end up with a double slash
// in the penultimate link so we'll kill all double slashes.
$output = preg_replace("#([^:])//+#", "\\1/", $output);

// Add the wrapper HTML if exists
$output = $this->full_tag_open.$output.$this->full_tag_close;

return $output;
}
----------End----------


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

Username
  

Password
  





Latest Threads
CVE-2022-40834 SQL Inject...
by reactionstudio
13 minutes ago
SQL server connection not...
by falagar2k
25 minutes ago
How to use Codeigniter wi...
by sr13579
25 minutes ago
Disable debug output in v...
by groovebird
34 minutes ago
CI 4.5.1 CSRF - The actio...
by kenjis
2 hours ago
CodeIgniter v4.5.0 Releas...
by kenjis
2 hours ago
Cache best practice?
by BhambriRohunu
3 hours ago
Bug with sessions CI 4.5....
by InsiteFX
4 hours ago
Codeigniter Shield Bannin...
by kenjis
8 hours ago
Best way to create micros...
by kenjis
11 hours ago

Forum Statistics
» Members: 85,310
» Latest member: rapidsilkscreenprinting
» Forum threads: 77,578
» Forum posts: 375,989

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB