Welcome Guest, Not a member yet? Register   Sign In
  Search function with CI
Posted by: El Forum - 01-04-2009, 10:03 AM - Replies (11)

[eluser]hykoh[/eluser]
Hello,

how did you make the search function in this forum with CI ?

http://ellislab.com/forums/search_result...d8eba10bd/

is "59e258a519db8daa508563fd8eba10bd" a special key in the DB that saves the results ? i dont know how i could code it in my project...

please help me (how to save results temporary anywhere / pagination must be possible) =)


  Upload module
Posted by: El Forum - 01-04-2009, 09:53 AM - Replies (2)

[eluser]sapid_guy[/eluser]
Hi to all

Am still new to CI but i love it,

Am trying to build a small module which will enable me to upload files,


When i say module i mean i need to code it in a way that it can be reused (Blog in Play)
of course with small modifications.

Features:

Can handle jpg|png|mpeg|mpg|avi

Dumb each file type to the proper folder (Img to img folder and vid to vid folder)

Now i did look at the some of the posts in the forum and most of them talk about the images
not videos or other files.

http://ellislab.com/forums/viewthread/79115/
http://ellislab.com/forums/viewthread/100421/
http://ellislab.com/forums/viewthread/94695/



Any help would be appreciated.

Thanks


  how to pass a multidimensional array to a view
Posted by: El Forum - 01-04-2009, 05:15 AM - Replies (4)

[eluser]atno[/eluser]
Hi,
Im trying to return a multidimensional array to a view but i dont know how to do it, i would appreciate any help

Controller

Code:
function index()
{
    function getFileList($dir, $recurse=false) {
        # array to hold return value
        $retval = array();

        # add trailing slash if missing
        if(substr($dir, -1) != "/") $dir .= "/";

        # open pointer to directory and read list of files
        $d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading");
        while(false !== ($entry = $d->read())) {
                # skip hidden files
                if($entry[0] == ".") continue;
                if(is_dir("$dir$entry")) {
                        $retval[] = array(
                        "path" => "$dir",
                        "name" => "$entry",
                        "type" => filetype("$dir$entry"),
                        "size" => 0,
                        "lastmod" => filemtime("$dir$entry")
                        );
                        if($recurse && is_readable("$dir$entry/")) {
                                $retval = array_merge($retval, getFileList("$dir$entry/", true));
                        }

                } elseif(is_readable("$dir$entry")) {
                        $retval[] = array(
                        "path" => "$dir",
                        "name" => "$entry",
                        "type" => mime_content_type("$dir$entry"),
                        "size" => filesize("$dir$entry"),
                        "lastmod" => filemtime("$dir$entry")
                        );
                }
        }
        $d->close();
        return $retval;
    }
    $data = getFileList('/home/atno/Movies',false);
    $this->load->view('dirlist_view',$data);
}

View
Code:
<table>
  <thead>
    <tr>
      <th>Directory</th>
      <th>Name</th>
      <th>Type</th>
      <th>Size</th>
      <th>Last Mod.</th>
    </tr>
  </thead>
  <tbody>
    &lt;?php foreach ($retval as $file):?&gt;
    <tr>
    <td>&lt;?= $file['path'].$file['name']?&gt;</td>
    <td>&lt;?= $file['name']?&gt;</td>
    <td>&lt;?= $file['type']?&gt;</td>
    <td>&lt;?= $file['size']?&gt;</td>
    <td>&lt;?= date("r", $file['lastmod']) ?&gt; </td>
    </tr>
    &lt;?php endforeach; ?&gt;
     </tbody>
</table>

Thanks,
atno


  CI and javascript
Posted by: El Forum - 01-04-2009, 04:56 AM - Replies (1)

[eluser]halwaraj[/eluser]
I have a piece of javascript code.

I have it in two view PHPs. Now, the issue is that the first view behaves as expected however, the second one behaves differently.

The only difference in code is that the control goes to first view from index function in controller while the control goes to second view from other function.

The flow is

index() in controller.php -> first_view.php(that has some javascript code)->A page is shown. Click a link on the page -> second() in controller.php -> second_view.php(that has some javascript code) -> should show the same page.

This does'nt happen.

INTERESTING THIS:

If I send the controll to second_view.php from index() in controller.php the JS works as expected.

Does it have something to do with URL?

Also I import the JS, css and images as follows:

Code:
[script type="text/javascript" src="js/tomato.js"][/script]

instead of

Code:
[script type="text/javascript" src="[?php base_url()?]./js/tomato.js"][/script]

Replaced square brackets for angular brackets

Which one is the correct way?


  "&lt;?=" is not work?
Posted by: El Forum - 01-04-2009, 04:41 AM - Replies (27)

[eluser]fRkSsK[/eluser]
hi
when i write;

&lt;?= anchor('application', 'The Application');?&gt;
or
&lt;?= base_url();?&gt;
or..

it does not work. php doesn't work. source code is shown same "&lt;?= base_url();?&gt;"

but when i write example &lt;?php echo 'hello' ?&gt; is work.

so What i must do for this problem?


  Rick Please improve the forum search
Posted by: El Forum - 01-04-2009, 02:31 AM - Replies (1)

[eluser]halwaraj[/eluser]
I tried to search one of my old searches, cause i got into same problem, the search tool said there are more than one results and wanted me to change the query.
It should actually display all the results and I would read and get the desired information.

A better approach:
Once I log on I should be able to see all the posts and threads that I was involved, else what is the fun of asking the user to register?


  Creating own library
Posted by: El Forum - 01-03-2009, 08:04 PM - Replies (3)

[eluser]fuksito[/eluser]
Tell me where am I going wrong:

I`ve created file
<b><i>application/libraries/Comment.php</i></b>
with content:

Code:
&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Comment {

  var $config;
  var $CI;


  function Comment()
  {
      $this->CI =& get_instance();
      $this->CI->load->model('Comment_model');
  }
  
  public function comments()
  {
      return 'ok';
  }
  
}

In my controller I load library and call it`s method
Code:
function index($id)
{
    $this->load->library('Comment');        
    $comments = $this->Comment->comments();
    parse_page('artist/page_tpl', array('comments'=>$comments));            
}

But I get an error:
Call to a member function comments() on a non-object


  Is there a page caching solution for me?
Posted by: El Forum - 01-03-2009, 07:17 PM - Replies (3)

[eluser]little brittle[/eluser]
The included CI caching is extremely limited, and I was reading that a combination of APC, Memcache or eAccelerator would substantially improve performace. I was wondering if there was a single caching solution, or a combination of libraries for my CI app that requires the following:

- Expire a specific cached page on demand.

- Granular caching.

- Serve 2 versions of the same page. Non-registered users would receive a generic full page cache, and registered users would receive a granular cache where sections of the page would be populated with their unique user info.

- I would love something that cached HTTP headers, but I don't think that is possible since I need to determine whether the person is logged in or not before serving the page.


  How to load selective JS and CSS in individual views
Posted by: El Forum - 01-03-2009, 05:08 PM - Replies (8)

[eluser]jaswinder_rana[/eluser]
Hi:

I have a view where I want to put a JS slideshow. I found a good one which uses MooTools and other files.

However, I only need it in one view. My views selectively load header and footer.

Code:
&lt;?php echo $this->load->view('header');?&gt; //Includes from &lt;html&gt; to <div> OPENING content tag
BODY
&lt;?php echo $this->load->view('footer');?&gt;from CLOSTING </div> content tag to &lt;/html&gt;

Now I may have misunderstood but I am assuming that all those &lt;head&gt; tags etc. should be views.

I could probably set an optional $tags variable and in my header check for it's existence. If it exists then output it.

As for the value of that tag, I can just supply the &lt;link&gt; and [removed] tag.

Am I doing this the wrong way?

Is there another way to do it in CI which I missed in the manual? Or something obvious which I am missing?

Thanks


  Search Error keeps appearing
Posted by: El Forum - 01-03-2009, 04:15 PM - Replies (2)

[eluser]clintonbeattie[/eluser]
Hi,

I am working through the Wrox Codeigniter book and keep getting this error when searching(I'm on page 126)...

A PHP Error was encountered

Severity: Notice
Message: Undefined variable: results
Filename: views/search.php
Line Number: 5

This is my search.php file contents...

Code:
<div id='pleft'>
<h2>Search Results</h2>
      
&lt;?php
if (count($results)) {
    foreach ($results as $key => $list){
        echo "<img src='".$list[' border='0' align='left' />\n";
        echo "<h4>";
        echo anchor('welcome/product/'.$list['id'],$list['name']);
        echo "</h4>\n";
        echo"<p>".$list['shortdesc']."</p><br style='clear:both'/>";    
    }
}else{
    echo "<p>Sorry, no records were found to match your search term.</p>";
}
?&gt;
</div>

All others files are as written in the book and have been double checked with the downloaded files.

Can anyone shed any light on this?

Thanks,
C

PS Here are my model view code and controller code...

Code:
function search($term){
        $data = array();
        $this->db->select('id,name,shortdesc,thumbnail');
        $this->db->like('name',$term);
        $this->db->orlike('shortdesc',$term);
        $this->db->orlike('longdesc',$term);
        $this->db->orderby('name','asc');
        $this->db->where('status','active');
        $this->db->limit(50);
        $Q = $this->db->get('products');
        if ($Q->num_rows() > 0){
           foreach ($Q->result_array() as $row){
             $data[] = $row;
           }
        }
        $Q->free_result();    
        return $data;
    }



Code:
function search() {
        if ($this->input->post('term')) {
            $search['results'] = $this->MProducts->search($this->input->post('term'));
        } else {
            redirect('welcome/index', refresh);
        }
        $data['main'] = 'search';
        $data['title'] = "Claudia's Kids | Search Results";
        $data['navlist'] = $this->MCats->getCategoriesNav();
        $this->load->vars($data);
        $this->load->view('template', $data);
    }


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

Username
  

Password
  





Latest Threads
AssetConnect - a powerful...
by maniaba
7 hours ago
twig and view cell
by foxbille
9 hours ago
Best Way to Implement Aff...
by InsiteFX
Yesterday, 09:58 PM
The pipe operator in PHP ...
by InsiteFX
Yesterday, 04:18 PM
Heads up for users using ...
by FlavioSuar
Yesterday, 11:33 AM
Table (view class) Row ID
by grimpirate
07-03-2025, 11:22 PM
curl + response body
by michalsn
07-03-2025, 10:10 PM
Happy 4th Everyone
by InsiteFX
07-03-2025, 09:31 PM
AbuseIPDB Module
by InsiteFX
07-03-2025, 09:27 PM
tool bar not showing
by Luiz Marin
07-03-2025, 04:46 AM

Forum Statistics
» Members: 154,884
» Latest member: sv388rucom
» Forum threads: 78,441
» Forum posts: 379,731

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB