disable language facet

57 views
Skip to first unread message

Monica Wood

unread,
Apr 29, 2020, 1:47:53 AM4/29/20
to AtoM Users
Wondering if there is any way I can disable the language facets from showing on the browse/filter screens?  We only have a one language repository and this filter/facet never showed in earlier version (upgrading from 2.4.1 -> 2.5.3).  I have found the code that sets this facet, but hoping there is a way to turn a facet off without changing the core code and needing to make this change every upgrade.   I'm also curious why this facet didn't show for us in 2.4.1, but it does now in 2.5.3.

Thanks,
Monica Wood
Library Systems
University of Tasmania

Dan Gillean

unread,
Apr 29, 2020, 1:33:09 PM4/29/20
to ICA-AtoM Users
Hi Monica, 

Is the facet showing more than 1 language? Or is it just "Unique records" and your default culture (e.g. "English") that are being displayed?

If it's showing more than 1 culture, then AtoM thinks you have content in multiple languages. If your site is unilingual, it's possible someone flipped the user interface to a different culture (possibly accidentally) while entering data - this is how you add translations in AtoM, so if you were in the French user interface and entered data (even if it was in English), AtoM would count that as a French description. So - just something to check. 

As to why this was not showing up for you in 2.4.1 - I'm not sure, since as far as I can recall (and see in our issue tickets), nothing about this facet has changed in 2.5. The Language facet was introduced in its current form in AtoM 2.1 (ticket here), and there was a bug fix for it in 2.3.0 (ticket here) but otherwise it hasn't changed. 

Note however that we did upgrade the Elasticsearch version between 2.4 and 2.5 (from ES 1.7 to ES 5.6) so it's possible this has introduced changes, but like I said, as far as I can tell the intended functionality has not changed recently. 

In any case, you raise a good point for unilingual sites. Most facets in the search/browse page are made to automatically hide themselves if there are zero or only 1 results, since this is not useful for end users (as all current results would share the same characteristics, and applying this facet would not alter the result count). In the case of the Languages facet filter, there's always at least 2, since we are counting "Unique records" separately (since a single description might exist in multiple languages if there are translations). Consequently it never gets hidden. However, in a unilingual site, when the current culture count is the exact same as the unique records count, this still isn't useful. Consequently, I consider this a bug, and have filed a ticket for us to hopefully address this in a future release: 
As you may know, we try to address as many bugs as we can with each major release, but have a limited budget to do so (given that we release AtoM and all its accompanying resources for free), so we rely on our community to help support the project and prioritize issues where we can't, either via code contributions or by sponsoring development. If this is a priority fix for your institution and you might be interested in sponsoring the work to guarantee its inclusion in the 2.6 release we are preparing for later this year, please feel free to contact me off-list and we can provide you with an estimate. If you have developers at your institution who might want to submit a patch to address the issue, we have some Developer resources on our wiki. If you'd like to learn more about how we maintain and develop AtoM, see this page: 
There isn't any way of changing the current behavior without making code modifications, unfortunately. However, I did track down where the code for this facet is located: 
You could conceivably comment out these lines to prevent this facet from displaying, like so: 
language-facet-code.png

After doing so, you would need to restart PHP-FPM (and memcached if you are using it), and clear your application cache

In general, because we don't recommend making code modifications in a production environment without first testing them extensively, I recommend making sure you backup your data, and try this in a test instance before applying to a production site! Note as well that, next time you upgrade, this customization will be overwritten, so you would need to re-implement it after upgrading (ideally with further testing first, in case something in AtoM has changed!). 

Cheers, 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him


--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/963fa770-18da-497f-9764-28387f6a7e67%40googlegroups.com.

Monica Wood

unread,
Apr 29, 2020, 9:03:49 PM4/29/20
to ica-ato...@googlegroups.com
Hi Dan,

Thanks for the explanation.  
Our filters only show the unique records and the english.

I have found in the code base what has changed between 2.4.1 and 2.5.0.


points to a template file 'search/facetLanguage' with the top logic line:  
<?php if (isset($pager->facets[$facet]) && count($pager->facets[$facet]['terms']) > 2): ?>

where the other facets point to the template file 'search/facet' with the logic line:
<?php if (isset($pager->facets[$facet]) && (isset($filters[$facet]) || count($pager->facets[$facet]['terms']) > 1)): ?>


points to a new template file that covers all facets 'search/aggregation' which switches the logic the opposite way:
<?php if (!isset($aggs[$name]) || (!isset($filters[$name]) && count($aggs[$name]) < 2)) return ?>

So in the past version it would only show language facet if the count of terms was greater than 2 (3 or more), while the new one wont show the facet if the count is less than 2 (1 or less).

I will try putting in a new logic line that looks if the name is language and change it's count, then share that fix here.

Cheers,
Monica

Monica Wood

unread,
Apr 29, 2020, 11:07:28 PM4/29/20
to AtoM Users
I have replaced the top of file logic in https://github.com/artefactual/atom/blob/qa/2.6.x/apps/qubit/modules/search/templates/_aggregation.php#L1
to:
<?php if (!isset($aggs[$name]) || (!isset($filters[$name]) && count($aggs[$name]) < 2) || ($name == 'languages' && count($agg[$name]) < 3)) return

and this seems to have worked. It would obviously need more testing to ensure it wasn't upsetting any other facets.

Cheers,
Monica Wood

Dan Gillean

unread,
Apr 30, 2020, 10:07:36 AM4/30/20
to ICA-AtoM Users
Monica, thank you so much for sharing this solution! 

I will ask one of our developers to take a look at your code modification proposal. Depending on the feedback we receive, either I can open a pull request to add this to 2.6 or, if you are willing to fill out one of our contributor agreements, you could open the PR yourself - either way I will credit you in the PR comments and the release notes if I end up submitting something on your behalf. If we can hit on a solution that passes our team's code review, let me know your preference so we can include something in the 2.6 release. 

Thanks again! 

Cheers, 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him

--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.

Dan Gillean

unread,
Apr 30, 2020, 12:02:57 PM4/30/20
to ICA-AtoM Users
Hi again Monica, 

One of our developers has suggested a slight modification to your suggestion: 

<?php if (!isset($aggs[$name]) || (!isset($filters[$name]) && (count($aggs[$name]) < 2 || ($name == 'languages' && count($aggs[$name]) < 3)))) return ?>

I replaced the current first line in /apps/qubit/modules/search/templates/_aggregation.php with Radda's modification of your submission, and tested it briefly in both a monolingual and a multilingual site - and it seems to work well! 

Let me know if you'd like to submit a pull request, or if you'd like me to open one on your behalf. 

Thanks again for your great detective work! 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him

Monica Wood

unread,
May 1, 2020, 5:06:36 AM5/1/20
to ica-ato...@googlegroups.com
Hi Dan,

Happy for you to do the pull request, it's only a one liner. 

Thanks!
Monica
Library Systems
University of Tasmania

Dan Gillean

unread,
May 4, 2020, 10:41:23 AM5/4/20
to ICA-AtoM Users
Done!
Thank you again for reporting this and helping us to find a solution!

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him

Reply all
Reply to author
Forward
0 new messages