CodeIgniter
more_horiz
close

on 02nd March 2016 / by magi.yv
Forms are probably essential part in websites. Because forms are creating the user interface to collect data from users. In CodeIgniter we can generate and handle data with the help of form helper. Form helper called by using the following code, $this->load->helper('form'); You can generate forms and handle form activities using available functions in form helper. echo form_open('user/add'); The above code would create a form form method="post" action="http://yoursite.com/index.php/user/add" For adding attributes to form you can pass it as the second parameter as array or string like, $attributes = array('class' => 'add', 'id' => 'myform'); echo form_open('user/add', $attributes); or echo form_open('user/add', 'class="add" id="myform"'); Adding fields Hidden fields function form_hidden() helps you to add fields on your form Eg: - $data = array( 'uid' = '0', 'page' = 'my_page', ); echo form_hidden('my_array', $data); Add input fields function form input will generate your input fields Eg: - echo form_input('user_name', 'testname'); or you can use it as array $data = array( 'name' = 'user_name', 'id' = 'user_name', 'value' = '', 'maxlength' = '100', 'size' = '50', 'style' = 'width:50% ); echo form_input($data); Submit form function form_submit() will generate a standard submit function echo form_submit('save', 'save user');Would produce: form_close() will close the form. If you need any support, please feel free to get in touch with us. CodeIgniter Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 31st August 2015 / by magi.yv
CodeIgniter URL's are search engine friendly and user friendly. CodeIgniter using segment based approach rather than query string. But it supports query strings, you can optionally enable it. URI segments: CodeIgniter follows the Model- view-Controller approach, so the segments of the URI also follows the same. For example -mywebsite.com/article/health/8. The first segment is the controller class. The second one is the method in that controller. The third one is the Id, the parameter which required for that function. By default, the index.php also part of the URL, but we can remove that by using .htaccess file. Before that, you should enable mode_rewrite in your Apache server. Then add the following rules in the .htaccess file. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]To know more about CodeIgniter URL's, contact us. For further help, check this out. CodeIgniter SEO Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 11th August 2015 / by magi.yv
Some times we need static pages on sites. In CodeIgniter, to show a static page in a site, you have to create a Controller for handling the page display. A Controller is a class which has methods to handle the HTTP request, that is Models and Views in a site. You need a view for a page to display the html content. For example, create a static page named about_us.php. For this, create a PHP file in [application/controller] folder, and the path will be 'application/controller/about_us.php'. <?php class About_us extends CI_Controller { public function view() { if ( ! file_exists(APPPATH.'/views/pages/about_us.php')) { //Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst('about us); $this->load->view('templates/header', $data); $this->load->view('pages/about_us.php', $data); $this->load->view('templates/footer', $data); } }Create the files such as header.php and footer.php for setting page header and footer, store the files inside the [application/view/templates/] folder. Now, create a view for this controller to show the contents, ie., application/views/pages/about_us.php. Also add the necessary contents for about us page using necessary HTML tags. Route this page in your router file, ie., edit the router file application/config/routes.php as, $route['about_us'] = 'about_us/view';Now, when you call www.mysite.com/about_us, it will display the about page with your added content. I think you have some doubts now, do you? Ping us now from here for support. CodeIgniter Leave a reply Your email address will not be published. Required fields are marker * Troy (not verified) access_time 19 Jun 2019 - 10:22 Hi, Is it possible to make just ONE Controller for all view and pass the path (ie. views/pages/about-us/organization.php) to it instead of creating controllers for each one (ie About, Contact, FAQs)? I am looking forward to your response. Add new comment