Welcome Guest, Not a member yet? Register   Sign In
  .htaccess for multiple controllers
Posted by: El Forum - 11-19-2008, 07:01 PM - Replies (10)

[eluser]VirtualDevel[/eluser]
Hey guys, I have two main controllers, the site controller and the admin controller. I want to setup the htaccess file to remove the index.php from the url string. However, when I do it, it works fine for site but redirects to site for admin requests.

Request: http://localhost/ => go to controllers/main
Request: http://localhost/admin => go to controllers/admin

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #This last condition enables access to the images and css folders, and the robots.txt file
    #Submitted by Michael Radlmaier (mradlmaier)
    RewriteCond $1 !^(index\.php|images|javascripts|robots\.txt|css)
    RewriteRule ^(.*)$ index.php/$1 [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>

config.php:
Code:
$config['index_page'] = "";


  Update a Select with onchange of other Select
Posted by: El Forum - 11-19-2008, 06:57 PM - Replies (6)

[eluser]Nuno Simões[/eluser]
I there, I'm a newbie on CI and I'm having a problem:

On my view page nammed init.php, I have two select boxes on a form and I want to update one select (modelo) with data from database after change selection on other select (fabricante). Does anyone tell me the better way to do this?

Thanks a lot!

There's the Code:

Code:
&lt;form name="detailsearch" action="#" method="get"&gt;
    &lt;input name="search_statement" type="text" /&gt;&lt;br />
        <div id="label">Fabricante: </div>
        <select name="fabricante">
            <option value="0">Indiferente</option>
            &lt;?php
        $i=0;
                foreach($fabricantes->result() as $row) {
            echo "<option value=\"".++$i."\">".$row->NOME."</option>\n";
        }    
            ?&gt;
        </select><br />
        <div id="label">Modelo: </div>
        <select name="modelo">
            <option value="0">Indiferente</option>
        </select><br />
&lt;/form&gt;


  the perfect image thumbs?
Posted by: El Forum - 11-19-2008, 06:19 PM - Replies (6)

[eluser]Asinox[/eluser]
Hi, i want to ask how ill make the perfect thumbs image?

im trying to control the $config['master_dim'] = 'width', but how ill make some control over height?

some tips?

thanks


  example add / edit / delete app
Posted by: El Forum - 11-19-2008, 05:05 PM - Replies (16)

[eluser]Future Webs[/eluser]
Hi Folks,

Been toying with CI for a few weeks and getting on fairly well. As an of how all the form side of things works I thought it best to build an example to test each option. As you may have guessed Ive come across a few issues.

Ive had a good look though the user guide, screen casts, example aps and the forums and although there are lots of good examples nothing quite covered where I came unstuck.

Heres my demo and an explanation of the issues i found.

Controller

Code:
&lt;?php

class Example extends Controller {

    function Example()
    {
        parent::Controller();    
        $this->load->model('Mdl_example');
        $this->load->library('form_validation');
        $this->load->helper('form');
    }
    
    function index()
    {
        $data['rs_examples'] = $this->Mdl_example->get_list() ;    
        $this->load->view('example_list', $data);
    }

    function form()
    {
        $example_id        = $this->uri->segment(3);

        $data['drop_menu_example_cats'] = $this->Mdl_example->drop_menu_example_cats() ;

        if ($example_id != "") { // edit so populate the form from database
        $data['rs_example']                = $this->Mdl_example->get_example_by_id($example_id) ;
        }
        
        if(isset($_POST) && count($_POST) > 0)    { // check if form has been submitted

        $this->form_validation->set_rules('example_text', 'Text Field', 'required');
        $this->form_validation->set_rules('example_radio', 'Radio Button', '');
        $this->form_validation->set_rules('example_checkbox', 'Checkbox', '');
        $this->form_validation->set_rules('example_dropmenu', 'Drop Menu', '');
        
        $this->form_validation->set_error_delimiters('<div class="Errors">', '</div>');
        
            if ($this->form_validation->run() == FALSE) // check if validation failed
            {
                // failed validation, back to form
            }
            else
            {
                // grab post info and add it to the database
                $form = array(
                        'example_text' =>             $this->input->post('example_text'),
                        'example_radio' =>            $this->input->post('example_radio'),
                        'example_checkbox' =>         $this->input->post('example_checkbox'),
                        'example_dropmenu' =>       $this->input->post('example_dropmenu')
                    );
                // set some form fields dependaing on insert or update
                if ($example_id == '' ) { // Insert
                    $form['example_date_added'] =        date("Y-m-d H:i:s") ;
                } else { // edit
                    $form['example_date_updated'] =        date("Y-m-d H:i:s") ;
                }
        
                        if ($example_id != '') {
                            // id passed so update
                            $this->db->where('example_id', $example_id);
                            $this->db->update('examples', $form);
                        } else {
                            // no id so insert
                            $this->db->insert('examples', $form);
                        }
    
                        // all went ok back to list
                        redirect('/example');                              
            
            } // check if validation failed
            
        } // check if form has been submitted

            // Not submitted load an empty view
            $this->load->view('example_form', $data);    
    }

    function delete_example()
    {
        $example_id        = $this->uri->segment(3);
        $this->db->where("example_id", $example_id);
        $this->db->delete("examples");
        redirect('example');    
    }
    
    
}

/* End of file example.php */
/* Location: ./system/application/controllers/example.php */

Continued in next post ....


  Useful utility: Comment Headings
Posted by: El Forum - 11-19-2008, 04:54 PM - Replies (2)

[eluser]Dave Stewart[/eluser]
Hi all,
Not strictly Code Igniter-related, but I updated one of my many projects the other day: Comment Headings.

It makes for easy navigation of ActionScript, PHP, or any other programming source code files, by allowing you to place dirty great LARGE headings in them:

Code:
//--------------------------------------------------------------------------------------------
//
//    ██████      ██              ██             ██   ██        ██   ██             ██      
//    ██  ██                      ██             ███ ███        ██   ██             ██    
//    ██  ██ ████ ██ ██ ██ █████ █████ █████     ███████ █████ █████ █████ █████ █████ █████
//    ██████ ██   ██ ██ ██    ██  ██   ██ ██     ██ █ ██ ██ ██  ██   ██ ██ ██ ██ ██ ██ ██    
//    ██     ██   ██ ██ ██ █████  ██   █████     ██   ██ █████  ██   ██ ██ ██ ██ ██ ██ █████
//    ██     ██   ██  ███  ██ ██  ██   ██        ██   ██ ██     ██   ██ ██ ██ ██ ██ ██    ██
//    ██     ██   ██  ███  █████  ████ █████     ██   ██ █████  ████ ██ ██ █████ █████ █████
//
//--------------------------------------------------------------------------------------------
// Private Methods

    // some method

    // another method

    // etc

Looks slightly spaced out in the forum, but compare navigating the two files below:
A Comment Heading commented file
A normally commented file

Or check out the live demo, and download link, here:
http://www.keyframesandcode.com/code/dev...-headings/

Just thought it might be useful to some of you - I know I find it invaluable now.

Cheers,
Dave


  SOLVED: Disallowed Key Characters: Problem On Ubuntu 8.04
Posted by: El Forum - 11-19-2008, 04:19 PM - Replies (4)

[eluser]Onur Özgür ÖZKAN[/eluser]
Hi CI Users,

Last week, i finished to use WAMP Technology and started to use LAMP Technology. I choiced Ubuntu 8.04 for operation system and i use XAMPP for Apache server, MySQL and PHP5. My main problem is our web applications, which were done by CI, started to give some error messages "Disallowed Key Characters".

I search on google, ci forms... but i find nothing... Sad

I overwrite the _clean_input_keys($str)methods with

Code:
function _clean_input_keys($str)
    {
        if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
        {
            //exit('Disallowed Key Characters.');
            exit('Disallowed Key Characters: '.$str);
        }
        return $str;
    }

Then the output is "Disallowed Key Characters: PHPSESSID"
The strange thing is ZF also doesn't work stablely on ubuntu?
Is there any idea over this problem?

.htaccess file is
Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ index.php [L]
    RewriteCond $1 !^(index\.php|themes|robots\.txt|sitemap\.xml)
    RewriteRule ^(.*)$ index.php/$1 [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.

    ErrorDocument 404 /index.php
</IfModule>

And i change Allowed URL Characters from config.php
Code:
$config['permitted_uri_chars'] = ' ';

Here is the solutions?
1. Don't use XAMPP on linux so we uninstall it!
Code:
rm -rf /opt/lampp
2. Install apache2
Code:
apt-get install apache2
3. Setup mod_rewrite
/etc/apache2/sites-available/default
Code:
<Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

Then you must install PHP5 thats all.


  Broken Site (worked fine locally)
Posted by: El Forum - 11-19-2008, 03:15 PM - Replies (3)

[eluser]Poccuo[/eluser]
I have been developing my first CI CMS and have run into a problem when trying to get it to run on my clients server. I have tried to contact the host but I think they're not going to be of much help as they have yet to respond to my emails or phone calls. Do these clues help anyone to understand what my problem is? I would greatly appreciate ANY help!

Here are some clues to the problem:

1) http://www.form-architects.com/cms/ does not work
2) http://www.form-architects.com/index.php/cms/ does not work
3) http://www.form-architects.com/index.php?cms/ does work but I need to get rid of the index.php? part. AND there is a php error that obviously shouldn't be there.
4) none of my .htaccess seem to be helping me remove the index.php?

Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]

5) Being suspicious that this is on a godaddy server I have unsuccessfully tried this thinking it might help: http://codeigniter.com/wiki/Godaddy_Installaton_Tips/

Here is my phpinfo() incase that is of use.
http://www.form-architects.com/test.php


  How to stop CI from continuing?
Posted by: El Forum - 11-19-2008, 01:52 PM - Replies (12)

[eluser]louis w[/eluser]
Is there a way in my constructor to tell CI to stop further execution and not call the requested method?

Using end() causes CI not to output to the page because the output library would not get called.


  $this->load->vars()
Posted by: El Forum - 11-19-2008, 12:44 PM - Replies (7)

[eluser]kidego32[/eluser]
Hello,

I have the following code:

Code:
Class MY_Controller extends Controller {
    
    function MY_Controller() {

        parent::Controller();
        
        // setup default navigation data
        $data['uri_segment_one'] = $this->uri->segment(1);
        $data['uri_segment_two'] = $this->uri->segment(2);
        
        $data['nav1'] = $this->Navigation_model->getNavItems(0);
        $data['nav2'] = $this->Navigation_model->getNavItems($data['uri_segment_one']);
        $data['nav3'] = false;
        $data['nav_active'] = $data['uri_segment_two'];
        $data['title'] = "Door Application";
        
        $this->load->vars($data);
    }
}

I'm extending my application controllers from this MY_Controller. The problem is that I can't access this data in the index() function. Shouldn't this data be available, or am I going about this the wrong way?

Julio


  Calling a controller from javascript?
Posted by: El Forum - 11-19-2008, 12:44 PM - Replies (4)

[eluser]Alexander Obenauer[/eluser]
I am trying to submit a form via ajax using prototype )the ajax libraries were just too much for so little).

Right now I've got this:

Code:
var url = '/CIDIRECTORY/CONTROLLERNAME/saveOrder/';
    new Ajax.Request(url, {
        parameters: { hiddenNodeIds: thestring },
        method: 'post',
        onComplete: function(truck) {
            alert(url);
        }
    });

But it doesn't seem to be calling the function in the controller. How do I get it to do that?


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

Username
  

Password
  





Latest Threads
Block IP addresses of bad...
by luckmoshy
4 hours ago
The Hidden Cost of “Innov...
by LordKaos
7 hours ago
Validation does not appea...
by grimpirate
06-29-2025, 09:01 PM
Best Way to Implement Aff...
by InsiteFX
06-28-2025, 09:35 PM
Unable to scroll left nav...
by Crenel
06-28-2025, 07:58 PM
After GIT Clone: Call to ...
by paulbalandan
06-28-2025, 02:49 AM
I want to install the CI ...
by InsiteFX
06-27-2025, 03:12 AM
HTML6 and CSS5: What's ne...
by HarryKDowns
06-26-2025, 09:08 PM
Installation & Setup on W...
by mohamedtg
06-26-2025, 04:18 AM
Server Push/preloading?
by sanjay210
06-25-2025, 09:38 PM

Forum Statistics
» Members: 154,087
» Latest member: supremegreendiamond
» Forum threads: 78,433
» Forum posts: 379,682

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB