codeigniter

How can integrate html template in codeigniter

佐手、 提交于 2019-12-22 09:06:14
问题 I'm new to codeigniter. please tell me how can I integrate or install a html theme/template in codeigniter ? (my css folder path=news/css and application folder path=news/application where news is my main folder) -thanks. 回答1: This is a very simple, very powerful way to do templates in codeigniter that is also very flexible. http://news.dice.com/2013/02/18/how-to-build-a-to-do-app-with-codeigniter/ ignore the title, most of the lesson is about setting up templates in CI. Note that i was first

Restrict the url_suffix in codeigniter

无人久伴 提交于 2019-12-22 08:48:58
问题 I am using codeigniter 2.1.4 and I have set $config['url_suffix'] = ".html"; It's working fine with out any trouble. But I found out that if I use redirect(); function will always add url_suffix on the landing page url. eg: site.com/login/success.html . My question is there anyway to exclude the url_suffix while using the redirect() function? or is there anyway to add .html without setting url_suffix in codeigniter, may be some hack in .htaccess?? I tried to add RewriteEngine On RewriteCond %

Mobile version of site using CodeIgniter

倾然丶 夕夏残阳落幕 提交于 2019-12-22 08:31:13
问题 What I want to do is to create a mobile version of my web site in CodeIgniter. I want to redirect my complete web site to m.example.com There will be no change in controllers, neither in views and models. Both will be the same. I don't want to change my .htaccess file. Any possible solutions for this? 回答1: The user agent class has a function; $this->agent->is_mobile(); You could use this in the construct of your base controller(s) to test if mobile. 回答2: Instead of rewriting your code all

ImageMagick Convert PDF to low resolution JPG file

你。 提交于 2019-12-22 08:19:48
问题 I have been trying to convert PDF to JPG images using ImageMagick on CodeIgniter, but the produced image is in low quality and always having black background for some reason (while PDF isn't). The code I'm using public function converter($pdf){ $this->load->library('image_lib'); $config = array( 'image_library' => 'imagemagick', 'library_path' => '/usr/bin/convert', 'source_image' => "./pdf/".$pdf, 'new_image' => "./images/a.jpg", 'maintain_ratio' => true, 'width' => 980, 'quality' => '90%',

How can I use a database and PHP sessions to store a user's shopping cart?

眉间皱痕 提交于 2019-12-22 08:03:38
问题 How can I use a database and PHP sessions to store a user's shopping cart? I am using CodeIgniter, if that helps. Example code would also be nice. 回答1: I would recommend that you look at the CodeIgnitor Session Class. Additionally, you could look at Chris Shiflett's discussion on this topic. 回答2: how about this ; - when guest add one item product in the cart function addCartItem($item_id, $qty) { $basket = $this->session->userdata('basket'); if(!$basket) { $this->session->set_userdata('basket

How to get form_dropdown() show the selected value in Codeigniter?

女生的网名这么多〃 提交于 2019-12-22 07:56:27
问题 I am trying to populate a dropdown list from database. In my view file I have the following code $batch= $query ['batch']; // I pull this data from a separate model echo form_dropdown('shirts', $options, $batch); Now the drop down list is populating data fine but the problem is I don't get the value-"$batch" automatically selected when the page loads. Interestingly if I echo $batch, elsewhere in the page it shows the correct data, which means $batch is okay. Here is my Controller function

Codeigniter: dropdown validation set_rules

怎甘沉沦 提交于 2019-12-22 07:08:55
问题 may i know how do i ensure that the user have selected, Dr, Mr, Ms, Mdm and when they submit the form if the salutation is given as blank it will return an error message for the set_rules(). Code: echo "<p>Salutation: "; $salutationOptions = array( '' => '', 'Dr' => 'Dr', 'Mr' => 'Mr', 'Ms' => 'Ms', 'Mdm' => 'Mdm', ); echo form_dropdown('salutation', $salutationOptions, ''); echo "</p>"; 回答1: In the view file, you can do a client side validation using this: echo "<p>Salutation: ";

Get files from amazon s3 buckets sub folder

只愿长相守 提交于 2019-12-22 07:05:07
问题 I am trying to get all the files from a amazon S3 buckets sub folder and make them downloadable in a web page. I have a bucket called images. Inside that bucket I have some other folders. Now I am trying to get all the files inside that subfolder and show it in a page. S3 Buckets: /images /images/test1/ /images/test2/ /images/test1/1 /images/test1/2 /images/test1/1/item I have tried like this, but couldn't get the expected result. // Target files full path : images/test1/1/item $bucketName =

Codeigniter- cache view into a view

落花浮王杯 提交于 2019-12-22 06:47:39
问题 i'm wondering if it's possible to cache a view which is loaded inside another view. I do: view.php: <div> <?php echo $this->load->view('modules/new_view'); ?> </div> so view.php requires a new view inside himself, can i cache the views/modules/new_view.php content? 回答1: Codeigniter has Web Page Caching CodeIgniter lets you cache your pages in order to achieve maximum performance. Although CodeIgniter is quite fast, the amount of dynamic information you display in your pages will correlate

Multi-Conditional WHERE Clause In CodeIgniter

浪尽此生 提交于 2019-12-22 06:44:02
问题 I want to delete some data like this query that is in core PHP WHERE user_id=$id AND sender_id=$send_id OR user_id=$send_id AND sender_id=$id So I tried it in CodeIgniter using Active Record like this : $this->db->where('user_id ', $id); $this->db->or_where('user_id ', $send_id); $this->db->where('sender_id ', $send_id); $this->db->or_where('sender_id ', $id); But it gives me the wrong result. What am I doing wrong? 回答1: $this->db->where(array('user_id' => $id, 'sender_id' => $send_id));