Sort doesn't work if not logged in

Hello again.

On my site, if the user is logged in, the sort works for the shortcode-generated list of items. However, if the user is not logged in, it does not work. How do I fix it?

This is my site:

This is my code:

<div class="preview-block clearfix">[items item_set=8 num=0 sort=foaf:lastName]</div>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', async () => {
    const items = document.querySelectorAll('.resource.item');
    for(let item of items) {
        const itemThumb = item.querySelector('.resource.item a').firstChild;

        // Extract the item ID from the title link
        const idMatch = item.querySelector('h4 a').getAttribute('href').match(/\/item\/(\d+)/);
        if (idMatch) {
            const itemID = idMatch[1];
            // Fetch Media-IDs for audio-visual documents asynchronously
            let mediaID;
            try {
                const response = await fetch(`/api/media?item=${itemID}`);
                const mediaItems = await response.json();
                for(let mediaItem of mediaItems) {
                    if (mediaItem['o:ingester'] === 'youtube') {
                        mediaID = mediaItem['o:id'];
            } catch (error) {
                console.error('Failed to fetch media items:', error);
                // Handle error appropriately
            if (mediaID) {
                // Create Button See the Interview
                const buttonSee = document.createElement('a');
                buttonSee.setAttribute('href', '/media/' + mediaID);
                buttonSee.innerHTML = '<img src="" alt="Button See the Interview">';
                // If a media item with a YouTube ingester was found, append the See the Interview button
                const itemButtons = item.querySelector('.item-buttons') || document.createElement('div');

            // Create Button Learn More
            const buttonLearn = document.createElement('a');
            buttonLearn.setAttribute('href', '/item/' + itemID);
            buttonLearn.innerHTML = '<img src="" alt="Button Learn More">';

            // Append Learn More button regardless of the mediaID existence
            const itemButtons = item.querySelector('.item-buttons') || document.createElement('div');
1 Like

I don’t see a “last name” field on those items when I look at them (not logged in, of course).

Do you have those values marked as private, maybe? If they’re private they aren’t available for sorting either, to avoid revealing information about the values even when they aren’t directly displayed.

If that’s the case you may want to make those values public and instead use something like the Hide Properties module to just hide them from the public pages. That way they’ll be usable for sorting but still not visible to public visitors.

Thanks. I didn’t realize the “Hide Properties” module was different than just making them private. On a previous project, having the “lastName” private still let me sort them within a Faceted Browse page, so I thought it would work for this too.