I created a custom module to fix a problem in search that sees a search for "Y05-4" fail to produce any results - the problem apparently being it ignores the leading 0 when searching? However before I can even test the module I need to get it to show in the list of modules under Functionality and it won't show up despite a number of checks of syntax and so on - originally named search_zero_fix I renamed it fix_zero_search thinking thast might help but it doesn't. Its even got AI stumped!

Bet it is something simple though... can anyone point me in a way forward?

 

Comments

indigoxela's picture

Hi ian,

to let a module show up, you'd put it in a directory under the /modules directory and create a yourname.info and yourname.module file in there. The name doesn't actually matter, but be consistent with it. The directory name, the .info file name and the .module name should match.

Important: that .info file has to contain at least:

type = module
name = Foobar
backdrop = 1.x

More about those info files can be found in the docs.

Yes that much I know :) 

Thanks for the quick reply...

My info file contains:

name = Fix Zero Search
description = Fixes leading zeros in search.
type = module
backdrop = 1.x
package = Custom

The module file is called fix_zero_search.module

These files reside in modules/custom/fix_zero_search

The module has clearly been found by Backdrop as the db shows an entry for fix_zero_search in the system table, which initially had a status of '0' that I changed to '1' directly in th edb, in line with other custom modules. I also noted it had a '-1' schema_version that I also changed to '0' in line with other active modules.

However no matter what I've tried the module (nor the 'Custom' section) show up in the list of modules at admin/modules.

indigoxela's picture

... had a status of '0' that I changed to '1' directly in th edb, in line with other custom modules

Awful idea! That's not how modules get installed! The number in db indicates the installed state and schema version. You're not supposed to fiddle in the database directly. There's an admin UI for that.

However no matter what I've tried the module (nor the 'Custom' section) show up in the list of modules at admin/modules.

I have no idea, what went wrong there. Never had that problem. 🤷

Awful idea! That's not how modules get installed! The number in db indicates the installed state and schema version. You're not supposed to fiddle in the database directly. There's an admin UI for that.

I know that too :) (Ive mucked up enough sites and dbs in my early years of computing to have learned to be very careful if ever considering working on live data in a db)

My initial steps were to create the info file, then the module. After that didn't work I fed the module code to an AI to check my syntax etc - it didn't find anything wrong... but that's not to say there isn't. I know Backdrop somehow checks the validity of modules and marks them as either '0' or '1' in the status field which is why I tried manually forcing this - but the module still didn't appear in the modules list. I added 'package = Custom' to the info file as this appears in my other active custom module.

If you haven't already, flush all the caches.

If it is in the modules folder whether directly or in a custom folder it will show up. If not, something else is wrong with your site; check the logs, make sure all errors are set to display.

One thing you haven't explicitly mentioned is the filename of the .info file; it should be the same as the folder and module name: fix_zero_search.info

The module file only has to exist to show up (that is how recipes work in Backdrop); so there is no checking of the module code for validity in order for it to show up.

As I work through things I flush the caches after every change I make.

As far as I can tell I have the custom module in the correct place (/modules/custom/fix_zero_search) and the file names are fix_zero_search.info and fix_zero_search.module.

My basic problem was that all my node/page titles for a particular section start with Y01, Y02... Y10, Y11...Y20 and so on (those are just the first three characters). If I search for Y01 I get nothing, if I search for Y01-4 I still get nothing returned by the search. This is not only frustrating for me, it frustrates other people trying to search the site for particular information.

Interestingly I've just discovered the search will work if I put in '05-4' without the 'Y'