Welcome Guest, Not a member yet? Register   Sign In
  CodeIgniter helpful hints
Posted by: El Forum - 02-07-2008, 08:03 PM - Replies (41)

[eluser]wiredesignz[/eluser]
I thought it might be a good idea to post some of our most helpful hints for using the CodeIgniter framework:

Hint 1
-------
I prefer to move the application directory out of the CI system directory for three reasons:

1. Upgrading the CI Core doesn't destroy my application configuration.
2. During development its easier to find my stuff and ignore the CI Core files.
3. CI works ok like this with no modifications.

(IMO Ellislab should take note here and change this!)
No other developers recommend you put application files in the system directory.

Hint 2
-------
Create an autoloaded application.php config file and use it to override the default CI config settings plus add your own custom settings.

This idea would work especially well if you create two config files using one for development server settings and the other for your production server settings.

The only file you need to change is the autoload.php config file setting, and again CI upgrades won't overwrite your custom files.


  ORACLE & Active Record :)
Posted by: El Forum - 02-07-2008, 07:30 PM - Replies (13)

[eluser]sikkle[/eluser]
Hi there,

Code:
function get_bla_2()
    {    
        
        $this->db->select('*');
      $this->db->from('TRAMP');
      $query = $this->db->get();    
        
        if($query->num_rows())
        {
            $ready = $query->result_array();
            $query->free_result();    
            return $ready;
        }
        
        else
        {
            return false;
        }
    }

Result ?

Code:
An Error Was Encountered
Error Number:

SELECT * FROM (`TRAMP`)

We all agree something is going on, someone have see some solution about that to let us use active record with ORACLE ?

Thanks !


  Accessing a library function/value from hook
Posted by: El Forum - 02-07-2008, 06:53 PM - No Replies

[eluser]naruto[/eluser]
Hi,

I am not sure if this is possible. I need to be able to read a value from a custom library from a hook in CodeIgniter 1.6.0

This is what my code do at the moment:

Custom library 'abc' is loaded and initialized by controller 'def'. The values that initialized by Controller 'def' need to be accessed by a 'post_controller' hook.

I have tried to use something like this in my hook:

Code:
$CI =& get_instance();
$CI->load->library('abc');    //NOTE: Will this create a new instance of 'abc' ??
$values = $CI->abc->get_values();

That doesn't work, and I keep getting 'undefined property error' from the line '$CI->abc->get_values()'.

Oh, the hook extends Controller:
Code:
class Thehook extends Controller

I am lost now, if someone can help me that would be great.

Cheers,
Naruto


  url problems , system/application/controllers/myindex.php
Posted by: El Forum - 02-07-2008, 05:26 PM - Replies (3)

[eluser]Peter74[/eluser]
Hi all,
i cant resolve this issue, i have 3 files
--controllers
-----front.php
-----inicio.php


--views
-----front_view.php

config.php

Code:
$config['base_url']= "http://www.ejemplo1.local/";
          $config['index_page'] = "";

routes.php
Code:
$route['default_controller'] = "front";

first its generate front.php call his view front_view.php, and print the page corrently
in that page are links like this

Code:
<?= anchor('inicio.php?lang=es', 'Idioma en Espanol');?>

but the browser give me this result
The requested URL /inicio.php was not found on this server.

if i write
Code:
<?= anchor('system/application/controllers/inicio.php?lang=es', 'Idioma en Espanol');?>

work

what iam doing wrong?

any comments helpme, txs


  CI Paging with searchresult
Posted by: El Forum - 02-07-2008, 05:26 PM - Replies (11)

[eluser]Unknown[/eluser]
Hi all,

I hope someone can point me in the right direction.

I have a searchform from which the result is send to the search-controller

I use a model to do a query and i also use paging to page the query result.

For page 1 all works fine (it uses the values of $this->input->post('field'))

When I click on page 2 in the paging, I got all the records of the table in the database, since my post-values from the original form are gone.

Is there an example i can use to find a solution ?

Controller:

$this->membermodel->sex = $this->input->post('sexsearch');
$this->membermodel->sexsearch = $this->input->post('sex');
$this->membermodel->relationtype = $this->input->post('relationtype');

$result = $this->membermodel->get($config[’per_page’],$this->uri->segment(4));

$this->load->library('pagination');

if($this->uri->segment(3) == '') $offset = 0;
else $offset = $this->uri->segment(3);

$limit = 4;
$offset*= $limit;

$this->load->library('pagination');

$config['uri_segment'] = $this->uri->segment(3);
$config['base_url'] = site_url('/search/result/');
$config['total_rows'] = $result['numrows'];
$config['per_page'] = $limit;
$config['num_links'] = 10;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';

$this->pagination->initialize($config);

$data['paging'] = $this->pagination->create_links();

Model:

function Membermodel()
{
// Call the Model constructor
parent::Model();
}


function get($limit, $offset) {

// BEGIN FILTER CRITERIA CHECK
// If any of the following properties are set before mdl_contacts->get() is called from the controller then we will include
// a where statement for each of the properties that have been set.
if ($this->id) {
$this->db->where("id", $this->id);
}

if ($this->pc) {
$this->db->where("pc", $this->pc);
}

if ($this->location) {
$this->db->where("location", $this->location);
}

if ($this->lang) {
$this->db->where("lang", $this->lang);
}

if ($this->burstaat) {
$this->db->where("burstaat", $this->burstaat);
}

if ($this->sexsearch) {
$this->db->where("sexsearch", $this->sexsearch);
}

if ($this->relationtype) {
$this->db->where("relationtype", $this->relationtype);
}

if ($this->hobbies) {
$this->db->where("hobbies", $this->hobbies);
}
// END FILTER CRITERIA CHECK

// We will display our results in order by last name and then first name.
$this->db->orderby("username");

// This will execute the query and collect the results and other properties of the query into an object.
$this->db->limit($limit,$offset);

$query = $this->db->get("member",$limit,$offset);

$result['numrows'] = $query->num_rows();
$result['query'] = $query->result;

return $result;
}

Thnx,

Peter


  Error sending email
Posted by: El Forum - 02-07-2008, 05:01 PM - Replies (3)

[eluser]Unknown[/eluser]
Hello guys,

I created a basic controller to test the email class, but it returns a time out error sending the email..

my code is above:

Code:
$this->load->library('Email');
        
        $config['protocol'] = 'smtp';
        $config['charset'] = 'iso-8859-1';
        $config['smtp_host']="mail.phpro.com.br";
        $config['smtp_user'] ="my_login";
        $config['smtp_pass']="my_pass";
        $config['mailtype']="text";
                
        $this->email->initialize($config);
        
        $this->email->from('sender_email', 'Rodrigo');
        $this->email->to('another_email');
        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');
        
        if ( ! $this->email->send())
        {
            // Generate error
            
        }
        else
        {
                        // Email sent
            echo $this->email->print_debugger();
        }

Anyone can see something wrong on my code ?

Thanks in advance


  Using Objects in Views
Posted by: El Forum - 02-07-2008, 04:36 PM - Replies (5)

[eluser]ChrisMcABZ[/eluser]
Hi there. Forgive me if this has been covered already; I tried searching, but couldn't find what I was looking for.

I'm starting to roll my first CI application using 1.6.0 - it's a simple CMS for my personal site. What I would like to do is this (code shortened for berevity):

(model)

Code:
public function GetBySlug($slug='')
{
    $entry['slug'] = $slug;
        
    return $this->db->get_where('entries', $entry)->result();
}

(controller)
Code:
$data['entry'] = $this->Entry->GetBySlug($slug);
$this->load->view('entry', $data['entry']);
(view)
Code:
<h1>&lt;?= $entry->title; ?&gt;</h1>

But with this code I just get an error. If I write this instead -

Code:
<h1>&lt;?= $entry[0]->title; ?&gt;</h1>

or use a loop, it works, but that seems a waste for what will always be a single result - and it's not as pretty Smile . Am I missing something (probably something very basic!)? Or do I have to give up my objects in views and start passing result_array() instead?

Thanks in advance, CI Bods!


  Looking for CodeExtinguisher Testers
Posted by: El Forum - 02-07-2008, 04:30 PM - Replies (2)

[eluser]Majd Taby[/eluser]
Hello everybody,
I am looking for around 5-10 people to test the new version of CodeExtinguisher and pick at it. I'm gonna be testing the system over the weekend and hopefully release before next friday.

If you are interested, please send me a private message with your email, and I'll email you the zip of gloriousness.


  CSS: background: transparent url(/images/menu_background.gif)
Posted by: El Forum - 02-07-2008, 04:19 PM - Replies (1)

[eluser]sawatdee[/eluser]
I am using css for my menu as such:

Code:
.horizontal_menubar
{
    background: #000000 url(/images/menu_background.gif) top left repeat-x;
}
However, my images directory is under my application directory. The following code works, but there is something about having my system directory in my css file that I don't like.
Code:
.horizontal_menubar
{
    background: #000000 url(/system/application/images/menu_background.gif) top left repeat-x;
}
I could also make my css file a php file and reference my images as URLs using site_url (), but that is a little bit of a hassle.

Has anyone else found a more graceful way to do this?


  Scaffolding does not work in "subfoldered" controller
Posted by: El Forum - 02-07-2008, 03:32 PM - Replies (8)

[eluser]Pierce[/eluser]
It would seem that the scaffolding system does not work when placed in a controller that resides in a subfolder within /controllers/

The scaffolding activation code is in the file:

e.g. /controllers/folder/session.php

You'll simply get a 404 error.

If anyone knows of a possible fix or solution, I'd be interested in using it!

Thanks


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

Username
  

Password
  





Latest Threads
codeigniter4/queue Not lo...
by mywebmanavgat
13 minutes ago
Array to HTML "Table"
by HarmW94
1 hour ago
shortcodes for ci4
by xsPurX
2 hours ago
TypeError when trying to ...
by b126
Today, 12:04 AM
Webhooks and WebSockets
by InsiteFX
Yesterday, 10:39 AM
Retaining search variable...
by pchriley
Yesterday, 05:46 AM
Reading a session variabl...
by xanabobana
Yesterday, 05:05 AM
Update to v4.5.1, same us...
by kenjis
04-17-2024, 07:47 PM
Codeigniter 4 extend core...
by Semsion
04-17-2024, 05:08 AM
v4.5.1 Bug Fix Released
by lokman
04-16-2024, 02:12 PM

Forum Statistics
» Members: 84,579
» Latest member: mu88bbcom
» Forum threads: 77,559
» Forum posts: 375,899

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB