Fuel search module

edited July 2014 in Modules
I am new guy for Fuel cms and I want to add search module in my php project. But I don't know how to add search module by command line and how to open that project in terminal window?
«1

Comments

  • edited 12:30AM
    Try renaming the folder to "search" and add it to the fuel/modules/ folder (e.g. fuel/modules/search). Then go to fuel/application/config/MY_fuel.php and add "search" under the $config['modules_allowed"] array(). Lastly, you may want to add a permission of "search" in the admin if you want others to be able to manage the module.

    The last 2 steps can be removed if you do the install via command line like so:
    >php index.php fuel/installer/install search
    http://docs.getfuelcms.com/modules
  • edited 12:30AM
    thanks
    Now, It is working.
    How I can use this search module in front end for website search.
    Please give me some solution.
  • edited 12:30AM
    I was wondering the same, how can I use this module for the front end?
  • edited 12:30AM
    The search module comes with a "search" view file, which you can copy from fuel/modules/search/views/search.php to fuel/application/views/search.php and edit. It gets passed a few variables including $count and a $results array.
  • edited July 2014
    can you have some sample blog from where I will do editing in search.php and implement for the front end.

    From Dashboard when I am using search tool for index. It given me error Page Error: HTTP Code 404 for http:/______/users/ecvonew/index.php/robots.txt
  • edited 12:30AM
    The 404 error should be OK. It first looks for the robots.txt file to determine what files should be ignored/included and if you don't have one, it will return the 404 code. It should still continue to index.

    Regarding the search.php view file, are you able to see that view file at /search?
  • edited 12:30AM
    the view at /search is blank in the browser.
  • edited July 2014
    Can you confirm that the fuel/modules/search/controllers/search.php is being run by adding a debug echo statement in the search.php view file? That is the controller and method used to create the /search page.
  • edited 12:30AM
    by adding echo statement in the index.php it show me error


    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: result

    Filename: controllers/search.php

    Line Number: 33
  • edited 12:30AM
    Does the fuel/application/config/MY_fuel.php have "search" in the $config['modules_allowed'] array?
  • edited 12:30AM
    yes
  • edited 12:30AM
    I actually meant to say add the debug statement to the "search.php" view file.
  • edited 12:30AM
    I try same thing but it showing me.

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: result

    Filename: controllers/search.php

    Line Number: 33
  • edited 12:30AM
    controllers/search.php

    <?php
    class Search extends CI_Controller {

    function __construct()
    {
    parent::__construct();
    if (!defined('SEARCH_FOLDER')) show_404();
    }

    function index()
    {
    $this->load->helper('text');
    $this->load->library('pagination');

    $q = $this->input->get('q', TRUE);

    $pagination = $this->fuel->search->config('pagination');

    $per_page = $pagination['per_page'];
    $offset = $this->input->get('per_page', TRUE);

    if (strlen($q) < $this->fuel->search->config('min_length_search'))
    {
    $results = array();
    $count = 0;
    }
    else
    {
    $results = $this->fuel->search->query($q, $per_page, $offset);
    $count = $this->fuel->search->count();
    }
    echo $results;
    print_r($result);
    $config = $pagination;

    $config['base_url'] = current_url().'?q='.$q;
    $config['total_rows'] = $count;
    $config['page_query_string'] = TRUE;
    $config['per_page'] = $per_page;
    $this->pagination->initialize($config);


    // set variables for view
    $vars['results'] = $results;
    $vars['count'] = $count;
    $vars['q'] = $q;
    $vars['pagination'] = $this->pagination->create_links();

    $view = $this->fuel->search->config('view');
    $params = array();
    if (is_array($view))
    {
    $module = key($view);
    $params['views_path'] = MODULES_PATH.$module.'/views/';
    $params['view_module'] = $module;
    $view = current($view);
    }

    $this->fuel->pages->render($view, $vars, $params);
    }

    function sitemap()
    {
    $pages = $this->fuel->search->model()->find_all_array_assoc('location');

    // change homepage to just '/'
    $pages[''] = '';
    unset($pages['home']);

    $pages = array_keys($pages);
    sort($pages);
    $vars['pages'] = $pages;

    $this->load->module_view(SEARCH_FOLDER, 'sitemap_xml', $vars);
    }

    }
    /* End of file backup.php */
    /* Location: ./fuel/modules/backup/controllers/backup.php */
  • edited 12:30AM
    view/search.php

    <?php echo "test"; ?>

    Search Results

    <?=$count?> <?=pluralize($count, 'Result')?> for “<?=$q?>”

    <?=$pagination?>
  • edited 12:30AM
    config/MY_fuel.php

    // specifies which modules are allowed to be used in the fuel admin
    $config['modules_allowed'] = array(
    'user_guide',
    'blog',
    'organizations',
    'event',
    'membership',
    'search'
    );
  • edited 12:30AM
    The variable is "results" with an "s" at the end. Try doing a print_r(count($result)); on that (doing just a print_r will put it in an infinite loop because the record objects have a reference to the main CI object.
  • edited 12:30AM
    hi sorry to add comments in this post. php index.php fuel/installer/install search how to do this command, i dont see installer folder under fuel but install folder only. I also went to repository here https://github.com/daylightstudio but dont think i found the search module
  • edited 12:30AM
    You run that command in the command line and must be at root of your fuel installation where your index.php file resides. There is no folder for fuel/installer/install because it is using a CodeIgniter controller which is found under fuel/modules/fuel/controllers.

    The repository can be found here:
    https://github.com/daylightstudio/FUEL-CMS-Search

    A list of all the module repositories can be found here:
    https://github.com/daylightstudio?tab=repositories
  • edited 12:30AM
    Thanks
  • edited 12:30AM
    I just tried implementing this as well. I added the hook from the docs...
    Indexing an entire site can be a time consuming process especially for bigger sites. To help with this issue, there is is a search module hook that will run on any module that has specified a preview_path after editing or creating a new module record. This will help keep your index up to date incrementally. To incorporate, add the following to the fuel/application/config/hooks.php: include(SEARCH_PATH.'config/search_hooks.php');
    Then today, I added several articles and tried doing a search with their titles, but I only got results from the articles I did previously when I indexed the entire site. Maybe I'm misunderstanding, but shouldn't it be indexing the new articles automatically? $config['modules']['articles'] = array('default_col' => 'post_date', 'default_order' => 'desc', 'preview_path' => 'articles/article/{slug}');
  • edited 12:30AM
    It should be. One way to check is in the javascript console, there should be a subsequent ajax request that gets made right after a save to index the page with the given preview_path value and should look something like the following:
    http://localhost/fuel/tools/search/index_site?pages=articles/article/my_slug_value&format=raw
  • edited 12:30AM
    Thanks for the tips. Here's what it says...

    GET http://www.lloydminstersource.com/fuel/tools/search/index_site?pages=articles/article/2014-08-05-benoit-talks-2015-election&format=raw 500 (Internal Server Error) jquery.js?c=-62169956768:4 send jquery.js?c=-62169956768:4 f.extend.ajax jquery.js?c=-62169956768:4 f.(anonymous function) jquery.js?c=-62169956768:4 (anonymous function) 105:224 n jquery.js?c=-62169956768:2 o.fireWith jquery.js?c=-62169956768:2 e.extend.ready jquery.js?c=-62169956768:2 c.addEventListener.B jquery.js?c=-62169956768:2
  • edited 12:30AM
    It looks like the page is reporting back a 500 error. If you click on that URL and are logged in, do you see an additional error message as to what may be causing the 500 error?
  • edited August 2014
    An Error Was Encountered: You do not have access to this page.
    Articles are posted from a user account. I just tried giving them permissions for tools/search, but they still can't go into Search from the backend (same error). Suggestions?
  • edited 12:30AM
    Do you need to be logged in to view that page? If so, the crawl won't work for that page unless the page provides a backdoor access for the crawler. The crawler just does a CURL request and essentially acts as an unprivileged user.
  • edited August 2014
    To view the article (http://www.lloydminstersource.com/articles/article/2014-08-05-benoit-talks-2015-election) you mean? You don't need to be logged in to view that. If I click on the entire link (http://www.lloydminstersource.com/fuel/tools/search/index_site?pages=articles/article/2014-08-05-benoit-talks-2015-election&format=raw) when logged into superadmin, it loads: Indexed: articles/article/2014-08-05-benoit-talks-2015-election. And it does index the page. How do I add permissions for the other user?

    Edit: I had to add permissions for search and tools/search, and now it's working for the other user. Thanks!
  • edited 12:30AM
    Hi admin how can we use this search module as others uses like having search field in header and user can search something in the site by typing and clicking on search .....this module has its own view i have put in views folder and when i go the that page on front end it gives 'No search results found'...but i want to use this module or any other if u suggest will use in header like text field having search button and gives results after clicking please help and suggest in this regard
    kind regards and bundle of thanks
  • edited 12:30AM
    The search page just needs a "q" query string parameter attached to it.
    search?q=test
    You can create a form with a "GET" action and an input name of "q" to submit to that page.

    To get results though, you must first build your index up which requires indexing in the CMS and potentially some configuration to make sure things get indexed correctly. In particular the "delimiters" configuration which is what's used to find areas of a page to put in the index:
    http://docs.getfuelcms.com/modules/search
  • edited 12:30AM
    hello admin, please help me
    how to add pdf link button in ckeditor toolbar
Sign In or Register to comment.