Publisher is EE6 compatible, but it does not support the Fluid field.

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: Ignore Categories

Status Resolved
Add-on / Version Publisher 3.1.5
Severity
EE Version 5.4.0

Hop Studios

Jan 26, 2021

Hello Brian,

Gil here at Hops. One client raised this issue and I wanted to ask to see if this is doable. Can we add Categories to the ignore settings so that only the default language’s categories are used?

I saw a similar issue reported #1479 but didn’t see further discussion about it. I’ve tested a few scenarios and found that the copying over of the categories only happens if the translation was not created before. So if today I decide to add a category to the default language to have the entry show up say in the homepage, I’ll have to do it for all the existing translations. For the client that can sometimes be difficult since they have translators who don’t really use the interface well. It’d be nice to just have a ignore settings. What do you think?

 

#1

BoldMinded (Brian)

Jan 27, 2021

I’ll have to think about this one a bit. Based on what I have going on now, and what a change like this entails, I probably won’t jump on this super quick… it may be awhile until I get to it.

#2

BoldMinded (Brian)

Jan 27, 2021

Actually, this might be a little easier than I thought. I’ll do some tests and maybe get something to you this week or early next week.

#3

BoldMinded (Brian)

Jan 27, 2021

Comment has been marked private.

#4

BoldMinded (Brian)

Jan 27, 2021

I haven’t actually tested that build on the front-end, just saving categories in the CP, but based on how it saves, I don’t expect any issues on the front-end. Similar to how the Persistent Grid and Relationships settings work, when you save an entry in a non-default language it still creates the database rows for those fields in those languages. Categories is doing the same, except now, if you enable the Persistent Categories setting, when you save the default language version of an entry, it deletes all categories assigned to the non-default language of the entry, and inserts the same database rows for all languages. When you edit an entry in the non-default language, the categories field is disabled, so the user can’t add or remove categories in the non-default language.

#5

BoldMinded (Brian)

Jan 27, 2021

Note this change will not automatically update existing data. You’ll still need to save the entries in the default language to update the non-default language category assignments for that entry.

#6

BoldMinded (Brian)

Feb 12, 2021

going to close this out since I added the Persistent Categories option, which will be included in the next release.

#7

Hop Studios

Mar 16, 2021

Hey Brian,

Gil here. I’m sorry I didn’t get back with more details from our test. The client was on vacation and I was waiting for him to confirm a few changes. I had installed 3.2.4 and noticed a small bug. When you have any categories checked for the default language, all translations’ categories also get the same set of categories (which is correct). However, if you then uncheck all categories from the default language, the translations’ categories remain with the earlier selections.

I think in the webhook you might need to check if $entry->Categories is empty and if so remove the categories from the translations, or if there are any more efficient ways to prompt the saving of the translations’ categories.

#8

BoldMinded (Brian)

Mar 16, 2021

Thanks, I’ll take a look.

#9

BoldMinded (Brian)

Mar 16, 2021

It should be doing that already… it deletes everything, regardless of the language. And if no categories are assigned, the insert statement does not run.

Line 196 of publisher_category.php

// First delete all category assignments for this entry.
        if ($persistentCategories) {
            $db->where('status', $saveStatus)
                ->where('entry_id', $entryId)
                ->delete('publisher_category_posts');
        } else {
            $db->where('status', $saveStatus)
                ->where('lang_id', $langId)
                ->where('entry_id', $entryId)
                ->delete('publisher_category_posts');
        }

        if (!empty($categories)) {
            foreach ($categories as $catId) {
                $data = [
                    'cat_id' => $catId,
                    'entry_id' => $entryId,
                    'status'  => $saveStatus,
                    'lang_id' => $langId
                ];

                $db->insert('publisher_category_posts', $data);

                if ($persistentCategories) {
                    foreach ($languages as $language) {
                        $data['lang_id'] = $language->getId();
                        $db->insert('publisher_category_posts', $data);
                    }
                }
            }
        }
#10

Hop Studios

Mar 16, 2021

I’ll inject some code to see what’s going on.

#11

Hop Studios

Mar 16, 2021

I found that in publisher_category.php function save_category_posts() starting line 113, the return at line 135 means the _save_category_posts() doesn’t get triggered when no categories.

#12

BoldMinded (Brian)

Mar 17, 2021

Ah, duh. Good catch. So the inside of that else should probably look like this:

$db = ee('db');
            $persistentCategories = $this->persistentCategories();

            // Delete all category assignments for this entry.
            if ($persistentCategories) {
                $db->where('status', $saveStatus)
                    ->where('entry_id', $entryId)
                    ->delete('publisher_category_posts');
            } else {
                $db->where('status', $saveStatus)
                    ->where('lang_id', $langId)
                    ->where('entry_id', $entryId)
                    ->delete('publisher_category_posts');
            }

            return;
#13

BoldMinded (Brian)

Mar 17, 2021

Comment has been marked private.

#14

Hop Studios

Mar 17, 2021

This one seems to be working for me!

#15

BoldMinded (Brian)

Mar 17, 2021

Huzzah!

Login to reply