Repository navigation
Replies: 2 comments 2 replies
0 replies
|
|
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
While building a Bootstrap 5 front-end theme I went through the search page end to
end — the form template, the shortcodes, the result rendering and the plugin
e_search.phphandlers. Along the way I collected a number of issues. Some areone-line fixes, some are design questions.
I am posting them here as a single write-up rather than opening separate issues,
so you can decide which are worth tracking and how to split them. Please treat
this as raw material: open issues for anything you find worth pursuing, in
whatever grouping suits you, and ignore the rest. No need to check back with me.
All file and line references are against
masterat the time of writing.A note on authorship: this write-up was drafted by Claude (Anthropic) from a reading of the current master source. I deliberately gave it no context about template work that is already done or planned, so it reflects the code as it stands and nothing more. Please read it with that in mind — some of these may already be known or in progress.
1. There is no Bootstrap 5 core template for search
e107_core/templates/hasbootstrap4/andbootstrap5/subfolders, but neithercontains a
search_template.php.coreTemplatePath()therefore falls through toe107_core/templates/search_template.phpfor every theme.That file is commented
// Bootstrap, but it is written for Bootstrap 3:form-horizontal,form-group,control-label— all removed in Bootstrap 5col-sm-3/col-sm-8without a.rowparent, so the columns never form a rowand every label ends up on its own line
input-group-btnandpull-right— Bootstrap 3 only<span class="caret">— Bootstrap 5 draws the caret with.dropdown-toggle::afterThe result is that any Bootstrap 5 theme gets a visibly broken search form until
it ships its own override. That is easy enough to do, but it means every BS5 theme
has to solve the same problem independently.
Adding
e107_core/templates/bootstrap5/search_template.phpwould fix this for allof them at once.
2. Missing spaces in the result detail line
e107_plugins/news/e_search.php:79LAN_SEARCH_3is"Posted on"with no trailing space(
e107_languages/English/lan_search.php:25), so the rendered output readsPosted on29 Jan 2023 : 12:35.The same pattern is in
e107_plugins/page/e_search.php:119.e107_plugins/forum/e_search.php:101is worse — three joins, no separators:For contrast,
e107_plugins/download/e_search.php:109builds the same kind ofstring correctly, with explicit spaces.
The fix belongs in the concatenation rather than in the language files — trailing
spaces inside translatable strings tend to get lost by translators and by
translation tooling.
3. Path constants and bbcode content leak into result summaries
Searching for a term that appears in a news item containing an image produces
summaries like:
The cause is in
e107_handlers/search_class.php:363-371:Two things go wrong here.
First, rewriting
[and]into<and>turns[img]path[/img]into<img>path</img>.strip_tags()then removes the tags but keeps everythingbetween them, so the image path survives as visible text. The same applies to any
bbcode whose payload is an attribute-like value rather than prose.
Second,
$tp->searchand$tp->replaceare not what the variable names suggest inthis context. In
e107_handlers/e_parse_class.php:44-46they are HTML entitycleanup arrays:
They do not expand
{e_MEDIA_IMAGE}or any other path constant, so those comethrough untouched.
Running the summary through
$tp->toText()— or at minimumreplaceConstants()plus proper bbcode stripping — would produce readable excerpts.
4.
<label for="t">in the advanced form points at a different controle107_core/templates/search_template.php, theform.advancedkey:{SEARCH_ADV_B}renders the matching control atsearch.php:432:There is no
id, so the label cannot be associated with it. Worse,id="t"doesexist on the page — it is the category selector built in
selectElement()— soevery advanced label is programmatically bound to an unrelated control. A screen
reader user tabbing into an advanced dropdown hears the wrong label.
form.enhancedgets this right:for="{ENHANCED_DISPLAY_FIELDNAME}"matches theidemitted bysc_search_enhanced(), so the fix is to follow the same approachin
{SEARCH_ADV_B}.5. Zero results is rendered as an error
search.php:829sets the fallback:alert-dangermeans something went wrong. A search that legitimately returns nomatches is not an error, and rendering it in red reads as one.
alert-info, a mutednote, or an empty state would fit better.
Plugins can override this through
no_resultsin theire_search.php, but thecore default is what most installs will actually see.
6.
<select>elements are hardcoded toform-controlBootstrap 4 introduced
form-select(custom-selectin BS4,form-selectin BS5)for
<select>elements. Without it the dropdown loses its chevron and its paddingis wrong.
Two places hardcode
form-controlon a<select>:search.php:269—sc_search_dropdown()viaselectElement()search.php:432— the advanced dropdownThemes can only patch this with CSS that duplicates the framework's own rules,
which is fragile.
e107_core/shortcodes/batch/search_shortcodes.phpalready shows the pattern thatwould solve this —
sc_search_input()andsc_search_button()both accept aclassparm and only fall back to a default when none is given. Extending the sameconvention to these shortcodes would let themes pass the right class.
7. Result markup cannot be templated
The search form is fully templatable, but the results are not. Each row is built
as a fixed string in
search_class.php:416and:428:with the list wrapper in
search.php:845:A theme can restyle this with CSS, but it cannot change the element structure —
no way to use a definition list, a card per result, a different heading level, or
to surface the URL the way most search engines do.
A
$SEARCH_TEMPLATE['result']key with placeholders along the lines of{SEARCH_TITLE},{SEARCH_LINK},{SEARCH_DETAIL}and{SEARCH_SUMMARY}, plusresult_start/result_endfor the wrapper, would bring results in line with howthe rest of e107 handles output. Existing themes could keep the current markup as
the default so nothing breaks.
This is the largest item here and probably worth discussing before anyone writes
code.
8. Smaller things
Dead code in the bullet setup.
search_class.php:46-57picks a bullet fromGLYPH,BULLETorbullet2.gifacross three branches, and then line 57unconditionally discards all of it:
The three branches above it have no effect.
A template key that is never parsed.
formTemplate()maps the legacySEARCH_TYPEkey totype(search.php:71), and the core template definesform.type— but the line that would parse it is commented out atsearch.php:1176.Both the mapping and the template key are dead.
Double space in the results caption.
search.php:894builds the caption byconcatenation:
$res_displayis set to an empty string when there are no results(
search.php:891), leavingResults in Newswith two spaces. HTML collapses it,so it is only visible in the source, but it also means the caption reads oddly —
"Results in News" when there are none.
Thanks for reading through all of that. For what it is worth, item 1 has the widest
reach since it affects every Bootstrap 5 theme, and items 2 and 3 are the ones an
end user actually sees — but you are far better placed than I am to judge where this
sits against everything else on the list.
All reactions