Welcome Guest, Not a member yet? Register   Sign In
  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


  Emergency need with URI
Posted by: El Forum - 11-01-2008, 02:34 PM - Replies (5)

[eluser]mousavi[/eluser]
hi, I’m just starting to use CodeIgniter and I have a problem with segment based URLs.
It doesn’t work when I type my URI. Actually I get HTTP 404 error, even if my $config[‘enable_query_strings’] is set to FALSE in config.php. But when I set it to TRUE the URL works in query string manner.
what can I do? If anybody help, I will be thankful.


  Best ways to do stuff (several questions)
Posted by: El Forum - 11-01-2008, 01:54 PM - Replies (5)

[eluser]Bramme[/eluser]
Hey all

I'm starting on a new app (website for a non-profit organisation) but before I get to it, I'd like some feedback first. I've made a website or three, four now with CI and with every app, I feel I learn something. This has a down and upside. The upside offcourse being: aha! I've learned something. The downside is that I think "damn, if only I knew about this when I was making my previous app!"

Anyhoo, there's a few things that this site will need that I haven't done before, I'd like to ask if anyone has done smth like this before, or anybody has some tips.

1) So far I've always used one controller for the content and multiple for the backend. Though the amount of pages was always fixed and known. Now a serious amount of the pages will be stored in the database with the ability of deleting/adding new ones. There will also be some static pages that won't be stored in the db, like the home page will be a collection of latest news, events and a welcome message and the contact page won't be editable either.

2) This one concerns number 1. I guess I'll have to make a controller for the database pages and maybe a controller for the static pages (every static page being a method simply calling a view). Or I could make one controller for the content and use a _remap function...

3) Every main page will have a sidebar. The sidebar could have a subnavigation, some text or an image gallery, widgets if you like. How would I best manage these, store them in the db etc... I'm thinking of having a database table for each widget type and then a table that stores which pages has which widgets. Sounds good?

Thanks for bothering to read this!


  Blogmer Beta 2 Documentation
Posted by: El Forum - 11-01-2008, 01:47 PM - No Replies

[eluser]Yash[/eluser]
Soon I'm releasing beta 2 meanwhile have a look at documentation.

Here is link for [url="http://www.speedovation.org/doc']blogmer documentation[/url]

Working on documentation. Still you find any error let me know that.


  New to CI - help and opinions for social project please?
Posted by: El Forum - 11-01-2008, 01:43 PM - Replies (2)

[eluser]Unknown[/eluser]
Hi everyone. I'm new to CI buthave been an EE developer for a while.

I have a nice website I need to build that has some social features (membership, profiles, friends, groups, recent activity) as well as Google/yahoo map integration and XML/RSS feeds for widgets etc. I have been looking at white label solutions like Kickapps but find they are over the top for what i'm looking for.

So back to CI. I have been looking around the forums for a while trying to collate all the plugins or libraries I will need. This is where I would like your help and opinions please. I'm trying to keep my actual coding to a minimum on this project, using as many community sources as possible.

This is what I have so far:

Membership creation & management
?

Authentication
- Redux Authentication library (http://code.google.com/p/reduxauth/)
?

Member groups
?

Templating
- Template CVI library (http://ellislab.com/forums/viewthread/88452/)
?

External asset storage
- Amazon S3 CI port library (http://www.haughin.com/code/s3/)
?

Mapping
- Google maps library (http://codeigniter.com/wiki/Google_Maps/)
?

External feeds (RSS/ATOM/XML)
- Simplepie library (http://www.haughin.com/code/simplepie/)

Assets upload (images/videos)
?

This list is only a start.

I know there are no opensource CI social network libraries which is a real shame. I would love a CI version of BuddyPress to be available as this would form 70% of what I need. I'm not using BP as it is still very much beta and produced lots of errors when I tried it a few weeks ago.

Any help on the above would be great. I can;t wait to see how we can add EE 2.0 into a project like this.


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

Username
  

Password
  





Latest Threads
Update to v4.5.1, same us...
by xsPurX
5 hours ago
SQL server connection not...
by falagar2k
8 hours ago
How to use Codeigniter wi...
by kenjis
8 hours ago
CVE-2022-40834 SQL Inject...
by kenjis
9 hours ago
Retaining search variable...
by pchriley
10 hours ago
Disable debug output in v...
by groovebird
11 hours ago
CI 4.5.1 CSRF - The actio...
by kenjis
Today, 12:39 AM
CodeIgniter v4.5.0 Releas...
by kenjis
Today, 12:35 AM
Cache best practice?
by BhambriRohunu
Yesterday, 11:10 PM
Bug with sessions CI 4.5....
by InsiteFX
Yesterday, 10:42 PM

Forum Statistics
» Members: 85,372
» Latest member: xshomnaycomvn
» Forum threads: 77,578
» Forum posts: 375,998

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB