I want to change the behaviour of Advanced Search so that the search result list titles are shown via a modified template. (Basically, each title should have a little button next to it).
What’s the best way to do this? I see two strategies but both seem to have rather costly downsides. Which of these is the least bad:
First idea
Modify the original template, i.e the shadow tiddler, $:/core/ui/ListItemTemplate that TW uses to display each search result list item.
Original: <div class="tc-menu-list-item"><$link /></div>
Modification: <div class="tc-menu-list-item"><$link />{{||mod}}</div>
This works well but:
- other core title lists also use this template, e.g the sidebar lists! So, I’m using CSS
display:none
to hide the mod in everything that is not the AdvancedSearch lists.
- Is this bad? It does behave as desired but the inspector tool shows that each listed sidebar title still brings the modification with it albeit hidden. (I guess this means that it exists in the DOM) - on the plus side, I think this shadow tiddler is unlikely to be updated in future TW releases.
Second idea
In AdvancedSearch, modify all four tab tiddlers (Standard, System, Shadow, Filter) to not call for the native $:/core/ui/ListItemTemplate but instead simply call for a custom template (with the contents as shown here above). Might seem to be the proper way but:
- Four overwritten core tids
- The chances of these being updated in future TW releases is quite big
Other thoughts
I know there is talk about “hooks” in the core (even if I only vaguely know what that means). Would it make sense to request a such in the $:/core/ui/ListItemTemplate ? I can’t be the only one who wants to manipulate the display of native list items?
Is there a “code alternative” to css hide:none
that conditionally prevents stuff from showing in the DOM, and that doesn’t require user interaction? (RevealWidget? But how can it be made to sense if it is inside an AdvancedSearch tab vs elsewhere?)
Again, it is for a plugin so the consequences will affect anyone installing the plugin.
Thank you.