Bootstrap integration with Codeigniter. |
This lesson will help you to understand how to integrate bootstap with Codeigniter.
First remember this is just a skelton example. Ok..Lets go. Step 01 : Download Bootstrap form it's official website. Step 02 : Create a folder called 'assets' in /wamp/www/CodeIgniter directory[In WAMP server]. N.B CodeIgniter in above directory is the name of my project. Unzip the above downloaded folder and copy all(css,js,fonts folders) the folders inside that folder. Paste them inside the assets folder. Please check that the path is correct to bootstap. \wamp\www\CodeIgniter\assets\css \wamp\www\CodeIgniter\assets\fonts \wamp\www\CodeIgniter\assets\js Step 03 : Open the config.php in /CodeIgniter/application/config directory, And edit it as $config['base_url'] = 'http://localhost/codeigniter/'; Step 04 : Create the controller as boots.php and save belows in it. <?php class boots extends CI_Controller { public function getBoots() { $this->load->view('samplebootstrap'); } } ?> Step 05 : Create the view file as samplebootstrap.css and save beloes in it. <link href="<?php echo base_url('assets/css/bootstrap.css');?>" rel="stylesheet"> <link href="<?php echo base_url('assets/css/bootstrap.min.css'); ?>" rel="stylesheet"> <div class="container"> <?php echo form_open("boots/getBoots",'class="form-inline"'); ?> </br> <legend>Enter the data </legend> </br> <div style="margin-left:30%;margin-top:20px;" > <div class="form-group"> <label for="employeeno" class="control-label">Employee No :</label> <input type="text" name="name" class="form-control" /> </div> </br> </br> <div class="form-group"> <label for="age" class="control-label">Age :</label> <input type="text" name="age" class="form-control" /> </div> </br> </br> <input type="submit" name="name" class="btn btn-primary"/> </div> <?php echo form_close(); ?> </div> Step 06 : Now That is all go to the web browser and type http://localhost/codeigniter/index.php/boots/getBoots You will see a form which has applied the bootstrap.
That is my style with Codeigniter
![]()
Thank you for appreciating my post and for your advice....
That is my style with Codeigniter
![]()
you should put your code in a [ php ][ /php ] tag
like this example: PHP Code: <?php
You forgot to load jQuery at the bottom of your template. Bootstrap requires jQuery.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Maybe a futile issue, but don't use the html-tag </br>. Although most browsers are very forgiving when they meet old-style tags, it's better to follow the current html conventions. Html-tags that are not a pair, but stand alone, must get the closing slash before the closing angle bracket.
So, <br /> is better than </br>, because </br> presumes that there's also a <br> starting tag. Same goes for <input [options] />, <hr /> and <link />
The "for" attribute in a label is a reference to an "id" attribute on an input (or other form control), so none of the values used in the "for" attributes of your form's labels are valid.
Also, you have: PHP Code: $this->load->view('samplebootstrap'); Then you state Quote:Create the view file as samplebootstrap.css Passing 'samplebootstrap' to $this->load->view() isn't going to load 'samplebootstrap.css', and since servers often only run PHP on files ending in '.php', it's likely that some people would never be able to load a .css file as a view anyway. Honestly, when writing a tutorial, I would recommend a few key points:
(08-14-2015, 08:49 AM)mwhitney Wrote: ... Thanks for taking the time out to write a detailed response with constructive criticism. While OP has the exact "walk-through" I was looking for it is lacking in parts. I think entry/beginner level tutorials should contain the content you suggested to keep in mind that some of us have only started our programming/development careers. TLDR: Your insight is appreciated - Interested in me hiring you for a few hours as a PHP tutor? (08-29-2015, 01:35 PM)swaylay Wrote: TLDR: Your insight is appreciated - Interested in me hiring you for a few hours as a PHP tutor? I appreciate the appreciation. You could buy a copy of Practical CodeIgniter 3 for about half of what I'd charge for an hour. I would get a lot less money, but you would get a lot more than I could really help you with in an hour (granted, it still might not be what you're looking for). One of the reasons I'm willing to help people out on the forums (and work on a book for what is likely to be a lot less than I would normally charge per hour) is that whatever I put out there is likely to help more people than anything I do in private. (02-14-2015, 01:33 AM)Ujitha Wrote: This lesson will help you to understand how to integrate bootstap with Codeigniter.Dear sir , I am getting error . I have tried your code with the exact file path as you mentioned in your code. How to solve this php error A PHP Error was encountered Severity: Error Message: Call to undefined function base_url() Filename: views/samplebootstrap.php Line Number: 1 Backtrace: |
Welcome Guest, Not a member yet? Register Sign In |