Welcome Guest, Not a member yet? Register   Sign In
  Pagination on a search page
Posted by: El Forum - 08-24-2007, 12:21 PM - No Replies

[eluser]Amenthes[/eluser]
Hi guys, I'm confronted with the following problem. I have a search page that will return large result sets, so a pagination is needed. My question is where should I store the keyword of the search and what should I set "base_url" to in the pagination config array. At a first glance I thought the keyword should be a simple URI segment, but...

1. How do I pass that segment from my search from, which cannot have a POST method as the pagination won't work anymore;
2. What if a user enters a keyword containing a "/"(forward slash)? Basically it will split my segment into two.

I think this is a case where $_GET would do the job but even so, the pagination class won't work because it will append the pagination segment after the GET params. The only solution I can think of is: first, POST the keyword from the form, build the query with that keyword, then generate the base_url of the pagination including an aditional segement - the POST-ed keyword (with any forward slashes replaced by underscores). Then, on any other hit I check if $this->input->post('keyword') returns false, if it does I look for the specific keyword segment and rebuild the query and the pagination. Not very elegant though.

Any suggestions greatly appreciated.


  Server Side Debugging
Posted by: El Forum - 08-24-2007, 11:25 AM - No Replies

[eluser]jgberg[/eluser]
I am trying to successfully do server side debugging with a full-blown debugger; that is, with breakpoints etc. What I want is to be able to do is debug my code whenever it is exercised on the server. At this point, I've installed a number of remote debugging packages, and so far I've not been able to do what I want. Hopefully, on this thread I can find out if anyone is successfully doing this with CI, and just how it's done.

I have a development machine with apache 2.2.x and CI installed. I have tried these debugger/IDEs: dev-php, eclipse with PDT+plugins, and Zend. I've gotten farthest with Zend as far as enabling remote debugging. Installing this stuff has been hell, just to say it, but eventually I've installed ZendCore, Zend Studio, Zend Debugger, and Zend Platform.

What I would expect, technically speaking is to setup my apache/php environment so that I can connect to it remotely with my debugger, then breakpoint PHP code on the server side such that whenever that code is excercised by some browser hitting the server, when that server runs the breakpointed code it will halt and notify my debugger and allow me to control the code flow from my debugger. There might be an issue with timing out the server response to the browser, but that would be patched.

What I've found is that I cannot make this happen. To be precise, I can run code from the debugger directly, which works fine, but isn't what I need. And I can run from the debugger a URL, which causes CI to choke with "The URI you submitted has disallowed characters." because the debugger is throwing extra crap on the URL and I can't stop it from doing so. And I cannot get it to breakpoint if I hit the proper URL from an external browsers.

So has anyone got this working right? How?

thanks!,
jeffrey


  Modular separation - how to now call a helper?
Posted by: El Forum - 08-24-2007, 10:16 AM - No Replies

[eluser]tinawina[/eluser]
I can't find an answer for this in other posts re: modular separation. I just implemented modular separation which is great but now my application can't find a helper file I created. Where do I put helper files? I tried saving it to these folders -- no luck:

system/helpers

system/application/helpers

system/applications/modules/module-name/helpers

I get this error: "Unable to load the requested file: myfile.php". One thing about this is I labeled the helper I created as "myfile_helper.php" per CI's instructions but the error message only shows myfile.php. As though it doesn't know that this is a helper file. I call it into my controller's constructor like so:

$this->load->helper('myfile');

This worked pre-modular separation implementation. Any help is appreciated!

I also have a config file I created for this app. I didn't move that file at all -- just kept it in it's original place which was in a sub-folder in the config folder: system/application/config/myfolder/myconfig.php. That still works but wondering if this is the best way to go about calling this file. I call it in the constructor like this:

$this->load->config('myfolder/myconfig');

Thanks for your help!


  include main app controller only once
Posted by: El Forum - 08-24-2007, 09:15 AM - No Replies

[eluser]gerben[/eluser]
Coming from the Cake framework, I find it convenient to create an app-controller for system-wide settings that extends the main CI controller. All my other controllers extend the app controller, rather than the CI controller.

Right now I include my app-controller in every controller that extends it, like so:

Code:
<?php
include("application/app_controller.php");

class SomeController extends AppController {

// etc.

?>

But isn't there an easier way to include this controller in every controller that extends it?


  Looping through error_string with JS
Posted by: El Forum - 08-24-2007, 09:06 AM - No Replies

[eluser]BrandonDurham[/eluser]
I know it sounds crazy, but hear me out.

I'm building a site for a client in CI that used to exist in HTML with JS form validation. They're very happy with the way it's working except they prefer the old-school javascript alert boxes letting the user know they've done something wrong in the form. I want to be able to tie it in directly with CI's validation class. I'm currently doing this in my view:

Code:
<?if ($this->validation->error_string) { ?>
    
        msg = '<?=$this->validation->first_name_error; ?>';
        ShowErrors(msg);
    
<? } ?>

... and this JS function is in the head:
Code:
function ShowErrors(str)
{
    msg  = "______________________________________________________\n\n";
    msg += "The form was not submitted because of the following error(s).\n";
    msg += "Please correct these error(s) and re-submit.\n";
    msg += "______________________________________________________\n\n";
    msg += str;
    alert(msg);
}

This works fine, however the form is approximately 20 fields long and I don't really want to add each field's error individually. Is there a way I can pass the "ShowErrors" JS function the $this->validation->error_string and have it cycle through all errors?

I appreciate any help.

Thanks!


  Shopping Cart, eCommerce Code Igniter Site???
Posted by: El Forum - 08-24-2007, 08:10 AM - No Replies

[eluser]CI_[/eluser]
can you give me some site that was develop using CI framework... thanks


  UTF-8 Latin 1 etc... I moved to linux and nothing seems to work properly
Posted by: El Forum - 08-24-2007, 04:34 AM - No Replies

[eluser]snaggy[/eluser]
This is a problem I hadn't encountered in windows, in my pages written in italian with italian special characters such as òàùèì that show up as question marks...

I don't know if I should use UTF-8 or Latin 1, can you suggest me which one should I use (easiest one)?

I have a database in MySQL in which I can choose the collation... what to pick?

In codeigniter my php files are encoded as UTF-8 I think, this is what Zend creates when I make a new file.

In my view files charset can be set to either UTF-8 or ISO-8859-1

The point is that with every possible combination it doesn't seem to work. If I use Latin 1 as I did on windows firefox reads it as utf all the same, dunno why:

Code:
<html>

<head>
<title>My Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Language" content="it">
</head>

<body>

<p>questa � la home page</p>

&lt;/body&gt;

&lt;/html&gt;


even if the php files is encoded in latin 1 (does this matter?)

I'm really confused, can anyone help or at least tell me what he/she does so that I can copy?

thanks!
Bye


  Image resizing patch for image_lib
Posted by: El Forum - 08-24-2007, 04:33 AM - No Replies

[eluser]#1313[/eluser]
If you want your image_lib only resize your image if it is bigger than your 'width' and 'height' parameters and do not resize if image is smaller then you may find this piece of code useful:

Code:
if ($this->orig_width >= $this->orig_height && $this->orig_width > $this->width) {
            $quotient = $this->orig_width / $this->width;
            $this->height = ceil($this->orig_height / $quotient);
        } else if ($this->orig_height > $this->orig_width && $this->orig_height > $this->height) {
            $quotient = $this->orig_height / $this->height;
            $this->width = ceil($this->orig_width / $quotient);
        } else {
            $this->width = $this->orig_width;
            $this->height = $this->orig_height;
        }

Insert it into your libraries/Image_lib.php in image_reproportion() function at line 1266 after these lines:
Code:
if ( ! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0)
            return;
And delete or comment everything below inserted code in this function. Now it will behave as expected.

PS. Disclaimer: use at your own risk. This is a 'quick and dirty' patch which worked fine with my app (CI 1.5.4) but can possibly kill something in yours. Don't forget to backup your library if you're not sure what are you doing.
PPS. I personally think that this behavior must be the default behavior of any image resizing functuon. I was deeply shocked when i discovered that such great framework lacks this important (and very often used) functionality.


  drag and drop and one query
Posted by: El Forum - 08-24-2007, 04:29 AM - No Replies

[eluser]wojtekk[/eluser]
hi
im using script.aculo.us to sort list with drag and drop
In my controller i got method

Code:
function sort()
{
        $ranking = 1;
        foreach ($_POST['tasks_list'] as $id) {    
        $dane = array('ranking' => $ranking);
        $this->Task->update($id,$dane);
            $ranking++;
        }
}
It works but i dont like it because it make a lot of queres(with 100 items in list - 100 updatesSad )
so i made this to made only one

Code:
function sort()
{
        $ranking = 1;
     $querry='';
        foreach ($_POST['tasks_list'] as $id) {
        $querry.=" UPDATE tasks SET ranking = '".$ranking."' WHERE tasks.id ='".$id."';";
            
            $ranking++;
        }
    $this->Task->updateranking($querry);
}


but its dont work
Any suggesttions?


  text helper
Posted by: El Forum - 08-24-2007, 01:43 AM - No Replies

[eluser]abbe01[/eluser]
Hi,
I am using text helper of CI. I have load the helper in my controllers.
But, once I use it for word wrap the row data form my database, it will come to this error message.

Quote:
Fatal error: Using $this when not in object context in C:\Inetpub\wwwroot\voxcms\system\helpers\text_helper.php on line 395
How to use the text_helper instead? I found that i m not able to use the text_helper while loading my db row data set.
below is my code, which I would like to word_wrap my $row->postcontent:
Code:
$post_count = $query->num_rows();
            $i = 0;
            if ($post_count > 0){
                foreach($query->result() as $row){
                    $postcontent = $row->postcontent;
                    //extract($posts[$i]);
                    $postcontent = word_wrap($postcontent, 6);
                    echo "<tr>\n";
                    echo "    <td>&lt;input type=\"checkbox\" name=\"tick$i\" value=\"$row-&gt;postid\" /></td>\n";
                    echo "    <td>$row->posttitle</td>\n";
                    echo "    <td>$postcontent</td>\n";
                    echo "    <td>&nbsp;</td>\n";
                    echo "    <td>$row->createdate</td>\n";
                    echo "    <td>$row->createdby</td>\n";
                    echo "    <td><a href=\"post.php?id=$row->postid\" id=\"imghref\"><img src=\"images/edit.gif\" title=\"edit\" /></a></td>";
                    echo "</tr>\n";
                    $i++;
                }
Hope anyone can point it out, how I am going to implete this.
Thanks.


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

Username
  

Password
  





Latest Threads
hot-reload side effects s...
by PaulC
2 hours ago
Changing Session cookie -...
by codeus
4 hours ago
using app/Config/App.php ...
by sam547
Yesterday, 03:04 PM
Setting baseURL in Regist...
by grimpirate
05-15-2025, 02:20 PM
CRUD Code Generator
by DeanE10
05-15-2025, 05:31 AM
CodeIgniter.com - Report ...
by Harry Lyre
05-14-2025, 04:26 AM
Missing closing bracket w...
by abf
05-13-2025, 07:27 PM
Update from 4.6.0 to 4.6....
by FlavioSuar
05-13-2025, 04:17 AM
Sessions old files are de...
by InsiteFX
05-12-2025, 10:30 PM
Ajax post failing with Ty...
by PaulC
05-12-2025, 12:23 AM

Forum Statistics
» Members: 146,520
» Latest member: 1gomsocial
» Forum threads: 78,392
» Forum posts: 379,463

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB