Welcome Guest, Not a member yet? Register   Sign In
  AJAX troubleshoot if anyone is bored. :-)
Posted by: El Forum - 08-27-2007, 04:19 PM - No Replies

[eluser]stevefink[/eluser]
This isn't a CI issue. It's a user error. :-)

Anyhow. I have a URL that looks like this:

http://f1auto/console/addvehicle/photos/1

This URL is mangled with URI routing, so if clarification is needed after this post, I'll be sure to respond. I have a DIV within the main view that looks like this:

Code:
<div id="showPhotos">
                            
                                $('#showPhotos').load('get_photos', {vehicle_id: &lt;?=$this->uri->segment(4);?&gt;});
                            
                        </div>

get_photos resembles the following:

Code:
function get_photos()
    {
        $id = $this->input->post('vehicle_id');
        // sanitize it just in case
        $vehicle_id = $this->input->xss_clean($id);
        // get all photo filesystem locations.
        $photos = $this->autodb->get_photos($vehicle_id);
        //log_message('debug', "vehicle_id: " . print_r($vehicle_id, TRUE));
        //log_message('debug', "photos " . print_r($photos, TRUE));
        return $photos;
    }

and finally get_photos in the model resembles the following:

Code:
function get_photos($vehicle_id)
    {
        // return all available photos for vehicle
        $photos = $this->db->getwhere('photos', array('vehicle_id'=>$vehicle_id));
        return $photos;
    }

I'm trying to load a separate view depending on the 4th URI segment which is the $vehicle_id. For the sake of brevity and debug, the .load() is calling:

Code:
&lt;?php foreach($photos->result() as $photo): ?&gt;
    <br><br> <hr>
    
    &lt;!-- img src="&lt;?= //base_url() ?&gt;uploads/&lt;?= //$photo->photo_id ?&gt;_thumb.jpg" -- >
    <p> photo_id:         &lt;?=$photo->photo_id;?&gt;        </p>
    <p> vehicle_id:     &lt;?=$photo->vehicle_id;?&gt;    </p>
    <p> photoloc:         &lt;?=$photo->photoloc;?&gt;        </p>
    <p> caption:         &lt;?=$photo->caption;?&gt;        </p>
    
&lt;? endforeach; ?&gt;

However after debugging with Firebug, I seem to be getting zero data back from the server.

Can anyone be kind enough to help me recover my fumble?

Thanks!


  shared business logic is it a model or should i place in controller
Posted by: El Forum - 08-27-2007, 03:02 PM - No Replies

[eluser]Unknown[/eluser]
I have an application that has models for clients data invoices products etc
and the views etc

However there is also the business logic like get the client see if his invoice is overdue etc and do what it needs to do

I know I can do that in the controller however if I do that in one controller and if I have to do that
again in another controller I would have to repeat that code

so my question is should I have a model for those business rules or maybe a library

The same for say a payment gateway logic would I be best making that into a model as that may be called by more than one controller

thanks


  application/libraries
Posted by: El Forum - 08-27-2007, 01:23 PM - No Replies

[eluser]megabyte[/eluser]
has anyone tried putting a folder into the libraries directory?

This way it would be easier to organize things a bit better.


  problem with routes.php
Posted by: El Forum - 08-27-2007, 10:43 AM - No Replies

[eluser]miguelp[/eluser]
I've folowed a modular based development tutorial with CI, and everything have worked fine for me until now. I have in routes a list of installed modules from the app, is i ask for a module that is not on the installed modules array, the script goes to the database and search in the table pages for a page with the name in the 1st URI element, so far so good, it was doing everything i need until now.
I have a module installed called clients, the problem is that i need to pass an argument to that controller, the number of the client i wanna see the details. like this: http://www.domain.com/index.php/clients/233
the problem is that it allways give me a 404 Error.
I have modified the routes.php like this:

Code:
&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
$route['default_controller'] = "pages";
$route['scaffolding_trigger'] = "";

$instaled_modules = array(
"news",
"mulheres",
"homens",
"clients"

);
$exclude = array(
'.',
'..',
'index.html',
'pages.php'

);
$handle = opendir(APPPATH . '/Controllers/');
while(false !== ($file = readdir($handle))){
    if (!in_array($file , $exclude)){
        if(!is_dir(APPPATH . 'controllers/' . $file)){
            $file = substr($file, 0, strlen($file)-4);
        }
        $instaled_modules[] = $file;
    }
}

closedir($handle);

foreach($instaled_modules as $module){
    $route[$module] = $module;
    $route[$module .'/(.*)'] = $module . "/$1";
}

$route['(.*)'] = "pages/index/$1";


?&gt;

Can anyone help me out? i realy need to get the 2nd URI element... but i dont know how...


  Checkbox Help needed
Posted by: El Forum - 08-27-2007, 10:26 AM - No Replies

[eluser]K-Fella[/eluser]
Hi folks,

I need your help figuring this one out :ohh:

What I'm trying to do is have a checkbox ticked upon page load (before the form is submitted), but if the checkbox is unticked by the user and then the form is submitted, to show an unticked checkbox on the resulting page load.

My problem is, in order to tick the checkbox on the first page load I need to make sure no post data for that checkbox exists. If it doesn't I tell the form_checkbox() function to tick the box.

Code:
if (!isset($this->post->input['allow_email']))
{
echo form_checkbox('allow_email', 'on', TRUE);
}
But, if the box is unticked by the user and then they submit the form, no post data for the box exists on the resulting page load, so my if statement above kicks in and the checkbox is ticked again Undecided

What can I do?

The use of the set_checkbox() function won't help in this case. The only solution I can see working is to use javascript to set a hidden field containing a value of 'off' or 0 if the box is unticked, but if javascript is off in the browser I'm screwed!


  Question about MVC design patterns..
Posted by: El Forum - 08-27-2007, 09:47 AM - No Replies

[eluser]Essobi[/eluser]
I have a question regarding standard practices in MVC... Is it generally better to represent all your data from multiple controller with a single view if it's possible to do so? It would make sense to me, to consolidate all your views into one, if possible then customize the view with a switch statement on data provided from the controller..


Essobi


  Captcha Gotcha: Locale
Posted by: El Forum - 08-27-2007, 08:56 AM - No Replies

[eluser]Crimp[/eluser]
Briefly for the forum record:

captcha, plugin, locale, sql insert, comma, period, floating point, delimiter

The captcha plugin uses a floating point number from microtime() to set the time and file name.

If you change the locale with, for example, LC_ALL and end up with a different floating point delimiter, usually period to comma, your SQL inserts of the captcha data etc. will obviously fail.


  What's wrong with my model?
Posted by: El Forum - 08-27-2007, 08:18 AM - No Replies

[eluser]Kemik[/eluser]
Hello all,

I'm pulling a list of fixtures from my database using a model.

Here's a simple version of my view file:

Code:
&lt;?php $this->load->model('Menu_model', 'menu'); ?&gt;

        <div id="rightbar">
            &lt;?php $query = $this->menu->get_fixtures(); ?&gt;
            <div class="boxheader">UPCOMING MATCHES</div>
            <div class="boxtext">
            &lt;?php if ($query->num_rows() < 1): ?&gt;
            <a href="#" class="boxlink">- No upcoming matches</a>
            &lt;?php else: ?&gt;
            &lt;?php foreach ($query->result_array() as $row): ?&gt;
            <a href="&lt;?php echo site_url("challenge/info/$row->challenge_id"); ?&gt;"><img src="&lt;?php echo base_url(); ?&gt;images/icons/zoom.png" width="16" height="16" border="0" alt="Challenge Info" /></a> <a href="&lt;?php echo site_url("clan/profile/$clana_id"); ?&gt;">[&lt;?php echo $clana; ?&gt;]</a> vs <a href="&lt;?php echo site_url("clan/profile/$clanb_id"); ?&gt;">[&lt;?php echo $clanb; ?&gt;]</a>
            &lt;?php endforeach;
            endif; ?&gt;
            
            
            </div>
</div>

Now from my menu_model.php
Code:
&lt;?php
class Menu_model extends Model {

    function Menu_model()
    {
        // Call the Model constructor
        parent::Model();
    }
    
    function get_fixtures()
    {
        $query = "SELECT lc.challenge_id, lc.datetime, lc.clan_id_a, lc.clan_id_b, ca.clan_id as clanid_a, ca.tag as clana, cb.clan_id as clanid_b, cb.tag as clanb
               FROM ladder_challenges AS lc
               LEFT JOIN clans AS ca ON lc.clan_id_a = c.clan_id
               LEFT JOIN clans AS cb ON lc.clan_id_b = c.clan_id
               WHERE accepted = '1'
               ORDER BY datetime
               LIMIT 0, 4";
        return $query = $this->db->query($query);
    }
}
?&gt;

I keep getting Fatal error: Call to a member function on a non-object in menus.php

Anyone have any idea where I'm going wrong?

Thanks.


  Borrowing CI's database library?
Posted by: El Forum - 08-27-2007, 08:02 AM - No Replies

[eluser]jonath4n[/eluser]
I have made my own framework, using CI's database library. Is it OK to use it? I don't have a clue about Licences and copyright stuff.
The rest of it is different, for example it allows you to do $post = posts::getid(1); rather than $post = $this->db->getwhere('posts', array('id' => 1));, and uses django style URLs, where you use regex manually for all URLs. It also generates the controllers, models, and views from a web based interface. And it has built in authentication. The performance seems to be better too, I ran ab with the CI welcome page with the database library autoloaded, it got about 80 requests/s and a page that runs 2 queries with my framework (a select count(*) and a select *) got 170 requests/s.


  Another mod_rewrite Problem (this time, intranet)
Posted by: El Forum - 08-27-2007, 04:26 AM - No Replies

[eluser]n8m[/eluser]
Hi,

i'm trying to setup a CodeIgniter Site on my Intranet. To shorten
the uri's i tryed to use the .htaccess configuration that is shown on
the Tutorial/Getting started Page. My Configuration looks like this:

Code:
<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>


<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

I'm shure the Mod Rewrite module has been loaded by my Apache2, but for
some reason he won't use my .htaccess file.

The File Structure on my Server looks like this:

/var/www/html/
/somedir/
/codeignitersite/ <- thats where the .htaccess is placed

i'm using Fedora Core 6 with Apache2 on this Server. Am i doing something
wrong, or is it just a Typo? I would appreciate some Help on this Problem.

Thnx in advance
n8m


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

Username
  

Password
  





Latest Threads
Codeigniter4 version 4.5....
by kenjis
6 hours ago
SQL server connection not...
by kenjis
6 hours ago
Problem with session hand...
by kenjis
6 hours ago
Is it possible to go back...
by kenjis
6 hours ago
Cannot access protected p...
by xsPurX
8 hours ago
Update to v4.5.1, same us...
by xsPurX
Today, 08:31 AM
How to use Codeigniter wi...
by kenjis
Today, 05:06 AM
CVE-2022-40834 SQL Inject...
by kenjis
Today, 03:44 AM
Retaining search variable...
by pchriley
Today, 03:15 AM
Disable debug output in v...
by groovebird
Today, 02:26 AM

Forum Statistics
» Members: 85,394
» Latest member: bangaloreescorts01
» Forum threads: 77,581
» Forum posts: 376,007

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB