Description
The task I'm working on naturally leads me to desire to have nested content items.
It is not difficult to change base class for
class ContentItemMetaClass(PolymorphicMPTTModelBase)
and
class ContentItem(with_metaclass(ContentItemMetaClass, CachedModelMixin, PolymorphicMPTTModel))
but then there is a problem to set relationship between page's contentitems in admin
also, MPTTModel adds it's own 'parent' field so there is either need to completely replace ContentItem placeholder parent field or to combine this field with mpttmodel parent field so that
mptt parent field is used to track tree relations of ContentItems for output for real world page and placeholder parent field is used to keep admin page presentation of ContentItem blocks )
after combining placeholder field mptt parent field also appears in ContentItemForm in admin page, but apparently without additional efforts is non-funtional such that mptt works as usual linear container for ContainerItems
And I have a question to the author, if he considers viable addition of tree relationships to ContentItems and how he would approach setting root node for the page and setting specific relations between ContenItems via setting parents for ContenItems using 'mptt parent' drop down which appears in admin blocks ( maybe providing queryset to dropdown which consists of all objects in given placeholder )
As a first attempt
I tried to add children to 'root' tree content Items via form ModelMultipleChoiceField by adding to derived Form from ContentItemForm
with lines like
localchildren = forms.ModelMultipleChoiceField(widget=FilteredSelectMultiple("Children", is_stacked=False),queryset= ...)
but failed to find a way to pass to Form required queryset which could consist of ContentItems in current placeholder and which could allow to build trees manually from selected data
(edit: one afterthought here is that the solution would be easier if there was way to connect model and form directly in content plugin code )
But still seems setting mptt parent to ContentItem via autogenerated ContentItemForm field might provide a relatively easy way to build a tree of ContentItems -
the question is - how better to approach this task.