highlight letters from advanced search

peppe10

Member
I need to search from a list. selecting a field containing the letters "alpha" I would like to highlight the words "alpha" in the records of the list. Is there any solution? Thanks to everyone in advance
 
Perhaps use a Javascript plugin to search the web page for the filtered text and wrap it in HTML which will highlight it?
 
Research on the Wiki.

But you will need some Javascript skills - or to find someone with the skills who program it for you (perhaps for a fee esp. if your site is a commercial one).

Fabrik is a technical tool - if you are prepared to keep things simple and stick within its limitations, then it is a lot less technical that programming it from scratch, but it is still technical. If your requirement is VERY straight forward, you can achieve it without any PHP / Javascript programming just by reading the Wiki and experimenting until you work out how to do it, asking for help if you have exhausted every other avenue and cannot work out how to do something. If you want to do anything other than basic Lists and Forms with basic elements, then you start to need php and / or Javascript skills, and sometimes SQL skills too.

To take this requirement for start and end dates and an elapsed period between them as an example:

Fabrik does have the ability to put in start and end dates without needing to add php or javascript. But...

If you want to constrain the date fields to e.g. not allow selection of a date before today or more than a year in advance then you will need basic Javascript (to tell the date picker what dates to disable).
If you want to calculate the difference between two dates, then you will need to write some simple php code.

So you might be better off, stepping back for a bit and ask for advice on the best way to approach your overall requirement. We can probably advise you on whether Fabrik is the right tool for you given your own level of technical skills, and how easy / hard you will find it to do using Fabrik and perhaps steer you away from the harder things to do.
 
Joomla has an Advanced Search function and Fabrik has an Advanced Search plugin but I have never used them myself and I doubt that they will give you what you want.

A paid subscription (Standard) will definitely get you better support. If you can afford it, go for it.
 
This is not an entirely trivial thing to do. For a discussion on the pitfalls of dynamic highlightingof text on a page, see this Stack Exchange thread:

https://stackoverflow.com/questions/8644428/how-to-highlight-text-using-javascript

The simple solution, of just searching for the text with a regex and wrapping it, is very error prone. For example, if the characters are part of an HTML markup ('href' or 'div'), or are in a script tag, etc. The first answer on that page would basically break things. The second answer shows you what has to be done - traversing the DOM container, find all the text nodes, etc. The third answer shows the best way of doing it, avoiding re-inventing the wheel by using an existing plugin like mark.js ... the author gives a Fiddle to show it in action:

https://jsfiddle.net/julmot/vpav6tL1/

Then of course you need to be able to include that plugin on the page, and fire off some custom code that runs after a filter is applied / the page is loaded, gets the value of the filter, and calls mark() on the list's container.

All of which is do-able, but probably not within the scope of subscription support. We can provide small amounts of coding assistance on a subscription - typically stuff I/we can write off the top of our heads without implementing test cases - but this would require an hour or two of work.

-- hugh
 
What Hugh didn't say was that whilst subscription support doesn't cover writing and testing the code, it would probably cover that sort of research for future issues and also provide more detailed advice on e.g. how to include mark.js in the list page and how to trigger the mark.js functionality.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top