-
-
Notifications
You must be signed in to change notification settings - Fork 541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Taxonomize Entries #4098
Comments
any news on this one ? |
Taxonomizing entries is only available when the field matches the taxonomy. Maybe this will be changed in statamic/ideas#839 You could query using Entry::query()->where('collection', 'blog')->whereJsonContains('terms_field', ['one', 'two'])->get(); This will find entries where |
Just for the record, I have a case where a collection "term field" does not match the taxonomy : ie It was created directly from the collection blueprint and not from the taxonomy setting page. Why that ? A little bit of context would help I guess : I have a "cooking recipes" site dealing with "timing". I of course have a "recipe" collection with 2 fields: Because I have two of them, I can't define the "recipe" collection in the "timing" taxonomy (which ends in creating only one "timing" field)... As we can only set only one preparation_time and one cooking_time, I was lucky, because I could use the basic ->where('preparation_time', 'XXX') in my view model (like with basic fields) If multiple "time" values were allowed (like multiple "prepration_time"; just imagine for one sec ;) ), I would indeed be able to query them using whereJsonContains(), thanks for that because I never thought of using it for that. Just for my informattion : I guess it's less efficient than whereTaxonomy() (when the later can be used)? |
Hey there,
It looks like Entires can only be searched with whereTaxonomy(), if the taxonomy has been configured on the collection.
I would have expected this to also work for taxonomy terms that have come from a blueprint field.
I've tried to see how much effort it would be to get this working on https://github.com/michaelr0/statamic-cms/tree/feature/taxonomize-fields but I've hit a roadblock that I haven't been able to figure out.
So I guess the first question is, should blueprint taxonomy terms also be used to filter Entries that have X taxonomy term?
If so, then does anyone have any ideas on what might be up with my changes?
I've tried to create
taxonomies
,taxonomiesFromCollection
andtaxonomiesFromEntry
methods on the Entry class.The taxonomize method on the EntryRepository has been changed to reference $entry->taxonomies()
Where I was hoping to use
Tests work if I just return taxonomiesFromCollection, but If I return the merged one or just the entries one, then the tests fail. As far as I've been able to tell, the two methods return the same kind of data, in fact taxonomiesFromEntry() seems like it returns the taxonomies from the collection as well (if you disable the check I've put in place), however this doesn't seem to work.
The text was updated successfully, but these errors were encountered: