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?
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
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.
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?
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.
// specifies which modules are allowed to be used in the fuel admin $config['modules_allowed'] = array( 'user_guide', 'blog', 'organizations', 'event', 'membership', 'search' );
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.
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
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.
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}');
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?
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?
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.
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
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
Comments
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
Now, It is working.
How I can use this search module in front end for website search.
Please give me some solution.
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
Regarding the search.php view file, are you able to see that view file at /search?
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: result
Filename: controllers/search.php
Line Number: 33
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: result
Filename: controllers/search.php
Line Number: 33
<?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 */
<?php echo "test"; ?>
Search Results
<?=$count?> <?=pluralize($count, 'Result')?> for “<?=$q?>”
-
<?php endforeach; ?>
-
<?php endif; ?>
<?=$pagination?><?php if (!empty($results)) : ?>
<?php foreach($results as $result): ?>
url?>"><?=highlight_phrase($result->title, $q, '', '')?>
<?=highlight_phrase($result->excerpt, $q, '', '')?>
url?>" class="page_link"><?=$result->url?><?php else : ?>
No search results found.
// specifies which modules are allowed to be used in the fuel admin
$config['modules_allowed'] = array(
'user_guide',
'blog',
'organizations',
'event',
'membership',
'search'
);
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
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}');
http://localhost/fuel/tools/search/index_site?pages=articles/article/my_slug_value&format=raw
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
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?
Edit: I had to add permissions for search and tools/search, and now it's working for the other user. Thanks!
kind regards and bundle of thanks
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
how to add pdf link button in ckeditor toolbar