Welcome Guest, Not a member yet? Register   Sign In
  using both uri segments and query strings in 1 app
Posted by: El Forum - 11-02-2008, 01:15 AM - Replies (9)

[eluser]skibum001[/eluser]
I am building a facebook app that has some of the functionality of my web app. As such, I want to re-use all my models and a number of views in the facebook version.

On my web app, I am using CI's lovely uri segs but as the facebook app will use a fair bit of JS, I need to use their iframes which meaning lots of facebook style query strings getting appended to the URI.

So my question is, how do I use both?

I have different controllers for my web app and facebook and tried using $this->config->set_item but this didn't work (I am guessing because CI determines uri types before getting to my contoller).

Next I tried to hack index.php and codeigniter.php but without luck. I created a new /facebook/ dir which had index.php, codeigniter.php, common.php and config.php and which changed the basepath and apppath to these locations but left the basepath and apppath to everything else the same. When I try mysite.com/facebook/index.php all I get is a blank screen (previously I got error messages until I fixed the errors). mysite.com/facebook/wrongurl loads my custom 404 page perfectly.

How do I make this work? I only want query strings to work in the /facebook/ directory.

Thanks for your help.


  Template Library Version 1.4.1
Posted by: El Forum - 11-01-2008, 10:13 PM - Replies (234)

[eluser]Colin Williams[/eluser]
Template Library Version 1.4.1 has been released.

-------------------------------------------------------------------------------------

Visit the Template Library Homepage

View the Change Log

Still using Template 1.4? See the Ignited Code thread covering Template 1.4

-------------------------------------------------------------------------------------

What's New in Version 1.4.1?

Version 1.4.1 is mostly a maintenance release, fixing comment and documentation typos. In addition, the 1.4.1 download now ships with its documentation. And finally, the Template class was renamed to work more like a core library so you can extend/overload/replace it in your application libraries folder, among other things.

-------------------------------------------------------------------------------------

The Template library, written for the CodeIgniter PHP-framework, is a wrapper for CI’s View implementation. Template is a reaction to the numerous questions from the CI community regarding how one would display multiple views for one controller, and how to embed “views within views” in a standardized fashion. In addition, Template provides extra Views loading capabilities and shortcuts for including CSS, JavaScript, and other common elements in your final rendered HTML.

Using Template looks like this:

Code:
$this->template->write('title', 'Introduction to Template');
$this->template->write_view('content', 'blog/posts', $this->blog->get_posts());
$this->template->render();

Look interesting? Head over to the Template Library Homepage to begin using Template in your next CodeIgniter application.


  Scaffolding
Posted by: El Forum - 11-01-2008, 09:15 PM - Replies (2)

[eluser]Praveen A P[/eluser]
Entry in \application\config\routes.php

Code:
$route['scaffolding_trigger'] = "jango";

Code in Controller class

Code:
$this->load->scaffolding('ts_register_user');

Entry in \application\config\config.php

Code:
$config['base_url'] = "http://localhost/ts/";

but when i try "http://localhost/ts/jango" I get
Quote:The requested URL /ts/jango was not found on this server.


What might be incorrect?


  DB Close and Free results question.
Posted by: El Forum - 11-01-2008, 07:33 PM - Replies (3)

[eluser]Lazos[/eluser]
My database is loading every time because of the autoload file.

Now, is it correct to use the free result function at the end of a query and close the database at the end of all of the queries or there is a function inside the database class that is doing all that automatically?


  Page Navigator Library
Posted by: El Forum - 11-01-2008, 07:03 PM - No Replies

[eluser]Lima[/eluser]
This library automatically generate page navigator when query some data from database.

But this library does not work for query having "LIMIT" like this

Code:
SELECT * FROM some_table LIMIT 10
I hope some can help for this problem

And this is the code
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Pagenavigator
{
  var $_init = FALSE;
  var $CI = null;
  var $_rowperpage = 10;
  var $_currentpage = 1;
  var $_lastpage = null;
  var $_numofpage = 10;
  var $_url = null;
  var $_islast = FALSE;
  var $_nodata = TRUE;
  
  function Pagenavigator()
  {
  }
  
  function init()
  {
    if ($this->_init) return TRUE;
    $this->CI =& get_instance();
    $this->_url = eregi_replace('/page/[^/]*', '', $this->CI->uri->uri_string());
    $this->_currentpage = eregi('/page/([^/]*)', $this->CI->uri->uri_string(), $regs) ? (is_numeric($regs[1]) ? intval($regs[1]) : 1) : 1;
    if ($this->_currentpage < 1) $this->_currentpage = 1;
    $this->_init = TRUE;
  }
  
  function query($sql, $binds=FALSE)
  {
    $this->init();
    $limit = $this->_rowperpage;
    $offset = ($this->_currentpage-1) * $this->_rowperpage;
    $query = $this->CI->db->query("SELECT * FROM ({$sql}) AS a LIMIT {$limit} OFFSET {$offset}", $binds);
    
    // count last page
    $qry = $this->CI->db->query("SELECT COUNT(*) AS row_count FROM ({$sql}) AS a", $binds);
    $row = $qry->row_array();
    $this->_nodata = $row['row_count']==0;
    $this->_lastpage = $this->_nodata ? 1 : ceil($row['row_count']/$this->_rowperpage);

    if ($this->_currentpage > $this->_lastpage) return FALSE;

    return $query;
  }
  
  function get_links()
  {
    $this->init();
    if ($this->_nodata) return 'No data found';
    $start_page = (floor(($this->_currentpage-1)/$this->_numofpage) * $this->_numofpage) + 1;
    $end_page = $start_page - 1 + $this->_numofpage;
    if ($end_page > $this->_lastpage) $end_page = $this->_lastpage;
    
    $links = ($this->_currentpage == 1) ? '&laquo;First ' : '<a >_url.'/page/1').'" title="First Page">'.'&laquo;First'.'</a> ';
    $links.= ($this->_currentpage == 1) ? '&lsaquo;Prev ' : '<a >_url.'/page/'.($this->_currentpage-1)).'" title="First Page">'.'&lsaquo;Prev'.'</a> ';
    
    if ($start_page > $this->_numofpage) $links .= '<a >_url.'/page/'.($this->_currentpage - $this->_numofpage)).'" title="More '.$this->_numofpage.' Previous Page">...</a> ';
    for ($i=$start_page; $i<=$end_page; $i++)
    {
      $links .= $this->_currentpage==$i ? '<strong>'.$i.'</strong> ' :'<a >_url.'/page/'.$i).'">'.$i.'</a> ';
    }
    
    if ($this->_lastpage != $end_page)
    {
      $more_next = $this->_currentpage + $this->_numofpage;
      if ($more_next > $this->_lastpage) $more_next = $this->_lastpage;
      $links .= '<a >_url.'/page/'.$more_next).'" title="More '.$this->_numofpage.' Next Page">...</a> ';
    }
    
    $links.= ($this->_currentpage == $this->_lastpage) ? 'Next&rsaquo; ' : '<a >_url.'/page/'.($this->_currentpage+1)).'" title="Next Page">'.'Next&rsaquo;'.'</a> ';
    $links.= ($this->_currentpage == $this->_lastpage) ? 'Last&raquo;' : '<a >_url.'/page/'.$this->_lastpage).'" title="Last Page">'.'Last&raquo;'.'</a>';

    return $links;
  }
  
}
?&gt;

CI GREAT!!!! Thanks Derek Smile


  Separation of namespaces..
Posted by: El Forum - 11-01-2008, 06:16 PM - Replies (3)

[eluser]Hannes Nevalainen[/eluser]
When I have a URI like 'user/edit/23' I want this to call the 'edit' method in User_Controller.php

I know that routes exists, but i doesn't cut it for me. (don't want a custom route for EVERY controller).

I have this problem because some of my model classes have the same name as some of my controller classes. I want a model named 'User' and a controller named 'User_Controller' and I want my URI just to contain 'user'.

Any suggestions?


  Codeigniter and PHPSpeedy tuning up your website's performance
Posted by: El Forum - 11-01-2008, 05:40 PM - Replies (9)

[eluser]manilodisan[/eluser]
Hi everyone, we recently released Speedy which is a small module for Webber and also wrote a small tutorial for everyone else interested in optimizing their Codeignitered websites by reducing the HTTP requests.

The module uses PHPspeedy to make everything possible and I really hope the tutorial will walk you through the process of implementing it in any other project based on codeigniter.

Here's the link:
http://www.drsoft.com/b/Webber_blog_modu..._tuning-72


  My own classes and the code used everytime
Posted by: El Forum - 11-01-2008, 05:34 PM - Replies (2)

[eluser]Rvnikita[/eluser]
Hi!
First off all thanks you very much because ofCodeigniter.
I use it and i like it, but I have 2 questions:

1) I have some code, that I used everytime on site, for example some initial code, that i must call in every controller in every function (before the execution)
Now I made a init model and in every controller first off all i call it

Code:
$this->load->model('init_m');
$this->init_m->make_init();

How can I wrote init code, that will be automaticly call before any controller?

2) I need some class, for example user class with different params and functions.
Code:
$user->name, $user->surname, $user->is_18_year_old()
How can i do it right?

Thank's you very much and sorry for my english .(


  Why CI?
Posted by: El Forum - 11-01-2008, 03:37 PM - Replies (13)

[eluser]ambf[/eluser]
Hi folks,

I'm trying to understand the logic of CI but can't figure it out!
I develop PHP applications for 8 years and never had to use frameworks.

I have to develop until tomorrow.. a small application in CI but I'm not having luck!
404 warnings and all type of errors that I never had problems with when I used PHP!

I was reading that CI was created to simplify programing but I can't see how!


  howto upload two files with different allowed_types
Posted by: El Forum - 11-01-2008, 02:56 PM - Replies (2)

[eluser]Mitja[/eluser]
howto upload two files with different allowed_types. i need to upload two files, where first one must be an image (jpg, gif or png), the second file must be pdf.

How to check all two uploads?

If i use

Code:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']    = '1000';
$config['max_width']  = '1024';
$config['max_height']  = '768';

$this->load->library('upload', $config);
$this->upload->initialize($config);

$config2['upload_path'] = './uploads/';
$config2['allowed_types'] = 'pdf';

$this->load->library('upload', $config2);
$this->upload->initialize($config2);

What to do now?

$uploads = $this->upload->data() can not be used for boath files or i am wrong?

Thx for help


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

Username
  

Password
  





Latest Threads
Display a custom error if...
by b126
2 hours ago
Type error in SYSTEMPATH\...
by DXArc
2 hours ago
v4.5.1 Bug Fix Released
by LP_bnss
3 hours ago
Retaining search variable...
by Bosborne
5 hours ago
Getting supportedLocales ...
by InsiteFX
8 hours ago
composer didn't update to...
by Sarog
Yesterday, 03:56 PM
Pipe on url modified in %
by kenjis
Yesterday, 02:52 PM
Best way to create micros...
by kenjis
Yesterday, 02:50 PM
How to use Codeigniter wi...
by kenjis
Yesterday, 02:39 PM
extend url_to helper
by kenjis
Yesterday, 02:33 PM

Forum Statistics
» Members: 85,053
» Latest member: nvl
» Forum threads: 77,571
» Forum posts: 375,951

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB