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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 12,642
» Latest member: smtjunior
» Forum threads: 68,806
» Forum posts: 428,553

Full Statistics

Latest Threads
is this migration bug?
Forum: CodeIgniter 4 Support
32 minutes ago
» Replies: 2   » Views: 49
Custom Validation doesn't...
Forum: CodeIgniter 4 Support
1 hour ago
» Replies: 3   » Views: 78
Chronological order of da...
Forum: Best Practices
1 hour ago
» Replies: 12   » Views: 223
Alpha.4 coming Dec 15th
Forum: CodeIgniter 4 Roadmap
10 hours ago
» Replies: 2   » Views: 182
Redirect
Forum: CodeIgniter 4 Support
11 hours ago
» Replies: 3   » Views: 107
CI 3.1.9 session timeout ...
Forum: General Help
Today, 05:29 AM
» Replies: 8   » Views: 244
Once the model is loaded ...
Forum: Best Practices
Yesterday, 08:37 PM
» Replies: 1   » Views: 78
How to create sitemap XML...
Forum: Lounge
Yesterday, 04:29 AM
» Replies: 2   » Views: 162
CI4 Supporters
Forum: CodeIgniter 4 Development
12-07-2018, 03:00 PM
» Replies: 10   » Views: 2,734
Upgrade CI2x to CI3 (USA ...
Forum: Jobs
12-07-2018, 12:15 PM
» Replies: 1   » Views: 111

 
  Smarty Plugin access to database
Posted by: El Forum - 10-06-2007, 02:00 AM - Forum: Archived Development & Programming - No Replies

[eluser]Unknown[/eluser]
Hello Code Igniters,

I've been following the progress of CI, for a while, and now I've decided to use CI and Smarty on a real project.

I have Smarty wired-in just dandy, and I can push data to a Smarty template from a controller with template->assign. Caching is working great too.

Now I'm starting to build smarty plugins to pull data from smarty "tags", sorta like expression engine does it (but with it's own template engine). I have that part working too on non-db data , as described in the Smarty manual under "componetized templates".

Just one piece is missing: I need to be able to access the database in these Smarty plugin functions, but it seems you have to be an instance of a controller or a view to load the database and use these features. I really don't want to use another db library or the built-in php functions for mysql. I like the CI database layer.

Maybe one way would be to get a handle on the current controller from within the Smarty plug-in function. Perhaps this would be similar to getting a handle on the CI instance, as discussed in this wiki entry: http://www.codeigniter.com/wiki/Use_URL_...om_Smarty/.

I've read most of the forum entries on Smarty. I tried several things and nothing yet has worked. I think I just don't have a deep enough understanding of PHP OO to get this working.

Does anyone have any suggestions?

Thanks,

Greg


  validating unkown number of related fields
Posted by: El Forum - 10-05-2007, 09:28 PM - Forum: Archived General Discussion - Replies (6)

[eluser]RMoygy[/eluser]
Hi. I have a set of related fields that can be created dynamically, via javascript, by the user. I'm not sure how to use CI's validation facilities without knowing the number of fields ahead of time.


  Pros and Cons: Requiring Separate Login for Forum?
Posted by: El Forum - 10-05-2007, 06:53 PM - Forum: Archived General Discussion - Replies (15)

[eluser]Vik[/eluser]
I may want my site to have a forum where people can discuss the site. At first glance, it seems like the right thing to do, is to find a way so that the same username/password works on the main site, and on the forum as well.

OTOH, the biggest problem with forums, is spam. I've got a forum where people discuss general blogging subjects unrelated to any particular CMS (forum4bloggers.com), and it was almost destroyed by spammers, even though only registered users can post, and the registration system uses captcha. It got so inundated with spam that I had to shut it down for a while. I only got it working again by requiring every new registrant, to email me personally, requesting registration approval.

So there need to be anti-spam measures on a forum, that don't need to be on my main site. And of course, there's also the hassle of integrating the login for the site, with the login for the forum.

Would it be a big mistake to require users to have a username/password on the forum, that is different from the username/password they have on the main site?

Thanks in advance to all for any opinions/thoughts/info.


  Pagination inquiry for this n00b!
Posted by: El Forum - 10-05-2007, 05:31 PM - Forum: Archived Development & Programming - Replies (5)

[eluser]stevefink[/eluser]
Yay, I'm officially labeling myself a n00b. :-)

I appreciate the time anyone who enters a thread with 'paginatin' in the topic as well. :-)

Either way, here it is plain and simple. My controller's constructor looks like this:

Code:
function inventory()
    {
        parent::Controller();
        $this->load->model('Autodb_model', 'autodb');
        $this->load->library('session','pagination');
    }

and within the controller, is my method for displaying an inventory:

Code:
function client_side()
    {        
        // client side inventory view.
        // This is VERY similar to the live() method
        // which retrieves the data we need for current
        // live vehicles. Let's grab this data.
        $data['opts'] = $this->autodb->get_vehicle_options();
        
        // config params for pagination
        $config['base_url'] = 'http://'.base_url().'/inventory/client_side';
        $config['total_rows'] = count($data['opts']);
        $config['per_page'] = '10';
        $config['uri_segment'] = 2;
        
        $this->pagination->initialize($config);
        
        $this->load->view('client/inventory_view', $data);
    }

[/code

Then within my view I execute the following code:

[code]

                &lt;!--<h5><a href="#">1</a> <a href="#">2</a> <a href="#">3</a> <a href="#">Next</a> <a href="#">>></a></h5>--&gt;
                &lt;?= $this->pagination->create_links() ?&gt;

Any idea why the pagination class isn't properly being loaded?
---

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Inventory::$pagination

Filename: controllers/inventory.php

Line Number: 67

Thanks for looking, folks!

- sf


  Rick made me buy a MacBook Pro :p
Posted by: El Forum - 10-05-2007, 02:24 PM - Forum: Archived Development & Programming - Replies (7)

[eluser]a.somervell[/eluser]
So i've spent what a year and a half at least developing in CI, am travelling and decided to go Mac (Ok so the personal tour through cupertino helped), so I could have decent, native, local development on my laptop.

Have installed macports, port installed php5, mysql5... set up hosts etc. etc etc.

I can connect to the mysql server in navicat, 104% sure I have the connection details right in CI/php.

Problem: Cant seem to connect, and in my 'nix experience that's because PHP/MySQL arent playing nicely.

I've searched previous threads looking for your very helpful install instructions but something ain't giving.

Who's got a "Oh you just do this and it'll all work" for me? Tongue


A


  Stupid php question
Posted by: El Forum - 10-05-2007, 01:22 PM - Forum: Archived Development & Programming - Replies (6)

[eluser]Aaron L.[/eluser]
Hi guys,

I am trying to write an IF statement which redirects users to the login if they are not one of two types of users (based on session info).

Here is what I have:

Code:
$user_type = $this->session->userdata('user_type');

if($user_type != "teacher" || $user_type != "school_admin")
{
    redirect('login');
}

Why is it that this doesn't work? If the user is a teacher, it skips the redirect but if the user is a school_admin, it sends them to login again.

A little help?


  Multiple file upload not working...
Posted by: El Forum - 10-05-2007, 11:06 AM - Forum: Archived Development & Programming - Replies (5)

[eluser]Jamongkad[/eluser]
Hey guys I'm having trouble uploading multiple files. I use the examples given by other CI gurus here but it doesn't seem to work. Here's my code...

View

Code:
<p>&lt;input type="file" name="userfile[]" SIZE="70" class='inputProjBox'/&gt;&lt;?php echo anchor('','Add',array('class'=>'addInputFields')); ?&gt;</p>

Model
I run a foreach loop cuz I don't know how many files the user is going to upload. Fortunately it runs if I upload the first file. But the subsequent files no banana..
Code:
function attachSprocketFile()
  {
   $config['upload_path'] = './sprocket_files/';
   $config['allowed_types'] = 'gif|jpg|png';
   $config['max_size'] = '2048';
   $config['max_width'] = '1024';
   $config['max_height'] = '768';
  
   $this->load->library('upload',$config);
  
    $build = array();
    for ($i=0; $i < count($_FILES['userfile']['name']); $i++) {
     $build['part' . $i]['type']   = $_FILES['userfile']['type'][$i];
     $build['part' . $i]['name']   = $_FILES['userfile']['name'][$i];
     $build['part' . $i]['type']   = $_FILES['userfile']['type'][$i];
     $build['part' . $i]['tmp_name']  = $_FILES['userfile']['tmp_name'][$i];
     $build['part' . $i]['error']   = $_FILES['userfile']['error'][$i];
     $build['part' . $i]['size']   = $_FILES['userfile']['size'][$i];
    }
    unset($_FILES['userfile']);
    $_FILES = $build;
  
  foreach($_FILES as $key=>$value){
    if(!$this->upload->do_upload($key))
    {
     $datas['error'] = $this->upload->display_errors();
     $datas['listings'] = $this->db->get('tag_listings');
     /*redirect('/sprocket/uploadFileForm/');*/
     $data['title'] = "Sprocket Fish: Upload Files";
     $data['header'] = $this->load->view('snippets/header.php','',TRUE);
     $data['content'] = $this->load->view('app/sprocket/upload_form.php',$datas,TRUE);
     $data['footer'] = $this->load->view('snippets/footer.php','',TRUE);
     $this->load->view('layout.php',$data);

    } else {
     $file = $this->upload->data();
     $this->load->library('image_lib');
    
     $config['image_library'] = 'GD';
     $config['source_image'] = './sprocket_files/'.$file['file_name'];
     $config['new_image'] = './sprocket_files_thumbs/'.$file['file_name'];
     $config['create_thumb'] = FALSE;
     $config['maintain_ratio'] = TRUE;
     $config['width'] = 75;
     $config['height'] = 50;
     $this->image_lib->initialize($config);
     $this->image_lib->resize();
    
     $config2['image_library'] = 'GD';
     $config2['source_image'] = './sprocket_files/'.$file['file_name'];
     $config2['new_image'] = './sprocket_files_resized/'.$file['file_name'];
     $config2['create_thumb'] = FALSE;
     $config2['maintain_ratio'] = TRUE;
     $config2['width'] = 367;
     $config2['height'] = 287;
    
     $this->image_lib->clear();
     $this->image_lib->initialize($config2);
     $this->image_lib->resize();
    
     $this->insertSprocketData();
    }
   }
  }

Thanks!


  create my own library with php 4 and get_instance
Posted by: El Forum - 10-05-2007, 09:18 AM - Forum: Archived Development & Programming - Replies (1)

[eluser]ariok[/eluser]
Hi all!
I read up on creating library in user documentation
and about the get_instance() function i founded this :

Quote:Also, please note: If you are running PHP 4 it's usually best to avoid calling get_instance() from within your class constructors. PHP 4 has trouble referencing the CI super object within application constructors since objects do not exist until the class is fully instantiated.

so.. if i need to use helper in my library what i have to do?? where i have to define the CI object reference ??

Thank you for your help


  ODBC connection Access
Posted by: El Forum - 10-05-2007, 07:22 AM - Forum: Archived Development & Programming - No Replies

[eluser]Unknown[/eluser]
Help!

Can somebody tell me whats going wrong here? Apart from the usage off Access Smile

I'm trying to connect to a Access database, but CI only comes with this error: Unable to connect to your database server using the provided settings.

Database setting I'm using at the moment:
$db['default']['hostname'] = "DRIVER=Microsoft Access Driver (*.mdb);SYSTEM=127.0.0.1;DBQ=/folder/db.mdb";
$db['default']['username'] = "xx";
$db['default']['password'] = "xx";
$db['default']['database'] = "db.mdb";
$db['default']['dbdriver'] = "odbc";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";

Many thanks in advance!


  DB insert error
Posted by: El Forum - 10-05-2007, 02:23 AM - Forum: Archived Development & Programming - Replies (3)

[eluser]feri_soft[/eluser]
I have the following simple code:

Code:
$data1 = array(
                    'product_id' => $product_id,
                      'image' => $img,
                    'thumb' => $thumb,
                    'order' => $i);  
                    $this->db->insert('images', $data1);

which is put in a loop and $i is the number. But when i run it it produces:

Quote:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order) VALUES ('95', '95_0.jpg', '95_0_thumb.jpg', 0)' at line 1

INSERT INTO images (product_id, image, thumb, order) VALUES ('95', '95_0.jpg', '95_0_thumb.jpg', 0)

Why is that? I can run other insert queries on the server but why this one fails as all seems to be normal. BTW i also tried putting unset($data1) at the end of the loop but its not helping. Thanks!



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.