Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Structure “hide from nav” doesn’t work for multiple Publisher languages if the other languages inher

Status Resolved
Add-on / Version Publisher 2.10.8
Severity
EE Version 5.1.2

Hop Studios

Apr 18, 2019

I have the following simple nav set up for a Site Map page:

{exp:structure:nav
start_from="/"
site_url="yes"
show_depth="999"
}

There are two languages set up - English and French.
I have “hide from nav” checked on the English version of the entry under the Structure tab. The French version is not filled in, and therefor inheriting data from English.
On the site, the entries are correctly hidden on the English version of the site, but are displayed on the French version.

I can fix this by filling in data for the French site, but I would expect that all fields would be inherited into multiple languages when not filled in.

- Mike

#1

BoldMinded (Brian)

I just used the exact template tag you provided to test locally and am unable to replicate this. I have the following pages:

Page A (en and fr translations, show in nav)
   Page B (en and fr translations, show in nav)
   Page C (en translation only,  hide in nav)

When I view Page A in English, only Page B show ups in the nav. When I switch to French, only Page B shows in the nav. Page C remains hidden in all cases as it should.

#2

Hop Studios

Thanks Brian,

Do you have any suggests on where to start with debugging this issue?

#3

BoldMinded (Brian)

Check out legacy/libraries/hooks/Publisher_structure_hooks.php line 105, structure_get_selective_data_results(). That is where it is determining what to do, so in there you can debug and see if it is returning the correct data.

#4

Hop Studios

I set this up using a new channel entry. I set the title and Structure’s “hide from nav” to True. Left everything else as defaults. English only, status set to published.

This is where I found the issue:

Publisher_structure_hooks.php:180 $entries = $entryResultService->getAllQuery($entry_ids, [], false); This returns an array of entries - excluding anything hidden. Directly below that, $results (all entries, including hidden) all have hidden set to false: $results[$key][‘hidden’] = ‘n’;

The code on line 202 that changes these entries back to hidden is checked against $entries, but the entries are not in that array, so they don’t get changed back. if (array_key_exists($page[‘entry_id’], $entries) {

#5

BoldMinded (Brian)

What is your Persistence setting set to?

#6

Hop Studios

All three Persistence settings are set to True. Persistent Grid fields Persistent Relationships Persistent Entries

I hadn’t looked into these settings before, but setting Persistent Entries to false looks to fix the issue. Is this expected?

#7

BoldMinded (Brian)

I wouldn’t just disable persistence if you don’t explicitly want to do that. I’m guessing when you do that it is unsetting items from the array in this conditional?

if ($page['entry_id'] != 0 &&
                (array_key_exists($page['entry_id'], $translations) && $translations[$page['entry_id']] === false) &&
                !$this->setting->get('persistent_entries')
            ){
                unset($results[$key]);
            }
#8

Hop Studios

Yes, that’s exactly right. The three problem items are being unset here.

#9

BoldMinded (Brian)

What happens if you completely remove that conditional so nothing is unset? I looked through my commit history and I can’t determine exactly why that conditional is even there :/

#10

BoldMinded (Brian)

Actually, try changing that last block of code to this:

/** @var EntryResult $entryResultService */
$entryResultService = ee(EntryResult::NAME);
$entries = $entryResultService->getAllQuery($entry_ids, [], false);
$defaultEntries = $entryResultService->getAllQuery($entry_ids, [
    't.lang_id' => $this->request->getDefaultLanguage()->getId()
], false);
$translations = $entryResultService->entriesHaveTranslations($entry_ids);

foreach ($results as $key => $page)
{
    if (array_key_exists($page['entry_id'], $entries) && isset($entries[$page['entry_id']]['hide_in_nav'])){
        $results[$key]['hidden'] = $entries[$page['entry_id']]['hide_in_nav'];
    } elseif (array_key_exists($page['entry_id'], $defaultEntries) && isset($entries[$page['entry_id']]['hide_in_nav'])){
        $results[$key]['hidden'] = $defaultEntries[$page['entry_id']]['hide_in_nav'];
    }

    if ($page['entry_id'] !== 0 &&
        (array_key_exists($page['entry_id'], $translations) && $translations[$page['entry_id']] === false) &&
        !$this->setting->get('persistent_entries')
    ){
        unset($results[$key]);
    }
}

return $results;
#11

Hop Studios

That does appear to fix the issue. Will this be included in a new version release?

#12

BoldMinded (Brian)

Yep, if it fixes the issue for you. I didn’t see any side affects on my environments either.

Login to reply