This repository has been archived by the owner on Oct 29, 2019. It is now read-only.
Adds a category filter for NewsBlogFeaturedArticlesPlugin and NewsBlogLatestArticlesPlugin #498
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows the configuration of a filter on categories for the plugins based on NewsBlogCMSPlugin.
This filter is either :
If the dynamic determination is specified, the list of categories will be ignored.
If no category is selected, it will not use any filter on categories ; so you won't have to go through your existing NewsBlogCMSPlugins on your website to update the configuration.
Dynamic configuration
This functionality is based on a new setting,
ALDRYN_NEWSBLOG_CATEGORIES_FROM_REQUEST
.For example, if you map some categories in your page (page model has a
categories
multiple choice field) ; you will be able to use this mapping in your NewsBlogLatestArticlePlugin.In this example, just set in your
settings.py
:Basically, it will
getattr(request, ALDRYN_NEWSBLOG_CATEGORIES_FROM_REQUEST)
.So, in this example, it will filter using
request.current_page.categories
.If the setting ALDRYN_NEWSBLOG_CATEGORIES_FROM_REQUEST is left empty, it will be ignored by the plugin and it will fallback using the defined list of categories.
The same goes if
request.current_page.categories
is set to an empty list of categories.