Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'api/custom-endpoint.json' => function() {
- $tagSlugs = array('tag-one', 'tag-two');
- $tagIds = Tag::find()->group('tagGroup')->slug($tagSlugs)->ids();
- $categoryId = Category::find()->group('categoryGroup')->slug('category-slug')->ids();
- $excludeIds = Entry::find()->relatedTo($tagIds)->ids();
- return [
- 'serializer' => 'jsonFeed',
- 'elementType' => craftelementsEntry::class,
- 'criteria' => [
- 'section' => 'blog',
- 'id' => 'not ' . implode($excludeIds),
- 'relatedTo' => [
- 'targetElement' => $categoryId,
- 'field' => 'categories'
- ],
- ],
- 'transformer' => function(craftelementsEntry $entry) {
- return [
- 'title' => $entry->title,
- 'url' => $entry->url,
- ];
- },
- 'pretty' => true,
- ];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement