Creating a frontend search module

I recently adopted to use fuelCMS for our university website, was able to integrate with MDB(Material design), but I want to build a search module that can search the Website content from the frontEnd just like you have in other CMS, I have followed the Search module instructions but i got an empty string => ( 0 Results for “” No search results found). I really need to get this to work so as to convince them that the flexibility and control you have with fuelCMS can not be gotten form others that boxed you in corner. Please advice.

Comments

  • if you want to demo fuel based search in action take a look at marlin.ac.uk
    It's pretty certain that something in your setup isn't right. Have you initialised the search table within the Fuel dashboard with data? Have you set up a div container in your layout view for the search engine to look within?

  • Thank you @almostcompletely there is no div tag in my layout, and I have installed the search module and the search table has been created but it is empty, I thought the search will be done against the table that contains the pages. I know for sure there are things that I am no doing correctly. Please I have also gone through some tutorials yet I am still not getting it right even after following step by step. Please i need some guide.
    Thank you.

  • edited January 2020

    In your layout view, add a <div id="searchable">...</div> around the content you want to be searchable
    In your search config file, edit the line:
    $config['search']['delimiters'] = array('<div id="searchable">','//meta[@name="keywords"]/@content',);

    Then go to the search section in Fuel and click the re-index button. New pages created in Fuel after these changes should automatically start appearing in the search table as they are prepared for searching on saving.

  • Sorry I never got back, still have not tried this though been caught up with a lot of supports issues in my place of work. Will get back to you on this @almostcompletely

  • @almostcompletely does it it mean that all the pages I have created can not be searchable?

  • edited June 2020

    The Search module works by using CURL to scan the pages using the delimiters specified in the config and parsing the HTML of the page to extract the text to be searched. As @almostcompletely said, for that to work, you'll need to make sure that the HTML contains one or more of the delimiters. The format of the delimiters can be a single tag (e.g. <div id="searchable">) or it can be an xpath (https://devhints.io/xpath).

  • Thanks @admin, got it working.

  • Hello @All, I discovered that my search module does not index my pages, even when I tried to re-index from my browser or from the command line, now all my previous indexed pages are all gone about 200+ pages really frustrating, a website with out a search feature.

    Also, how do I make my search results to use my costumed theme, I used MDB. I have been promoting fuelCMS over other CMSes, getting stuck here is really frustrating, most especially when people think you have a the answers.

    Any suggestion will really help me.

  • What do you have set as your delimiters in your search.php config and do they match your a portion of your HTML that you want to be indexed?

  • I used the default delimiters in the search.php config and yes they match the portion of the HTML i want to search. Sorry for the late response have been on an intensive training. Thank you @admin for your efforts

  • To troubleshoot, you may need to venture into the code a bit and do some debugging. In particular, the Fuel_search::crawl_pages() and Fuel_search::index_page() methods to see what is being returned when you try to reindex the site. For example, you could simply put the following on line 475 of the Fuel_search page in the index_page() method:

    exit($content);
    

    If it doesn't make it there then it may not be finding the page to be indexable.

  • Thank you @admin, i did that nothing was return, so i typed var_dump($content);die(); it returned string(0)"", so when I removed the die(); it returns all these
    string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) ""

    What should i do now, i could re-index both from the browser and from the cli before , now non is working.

    Thank you for your help!

  • I think the next step would be to dive into the find_indexable_content() method and determine why there is no content being returned. You can test it out by perhaps changing the delimiters to something else that's in your HTML.

  • I have done that it return an empty string also.

  • Now on re-indexing it gives me this.

    Page Error: HTTP Code 404 for https://uniabuja.edu.ng/education/index.php/about-dean
    Index removed: education/index.php/about-dean

  • That page doesn't exist and so that would be correct in that the page would be removed. Also, if your search config (fuel/application/config/search.php) is using the sitemap.xml file, you may want to check that to make sure that it's outputting correct URLs:
    https://uniabuja.edu.ng/sitemap.xml

    Lastly, it looks like you can change the /fuel/application/config/config.php $config['index_page'] = 'index.php'; to just be empty `$config['index_page'] = '';

Sign In or Register to comment.