Coder Social home page Coder Social logo

Plugin inheritance about django-cms HOT 24 CLOSED

django-cms avatar django-cms commented on May 2, 2024
Plugin inheritance

from django-cms.

Comments (24)

heiho1 avatar heiho1 commented on May 2, 2024

I'd be interesting in helping out on this feature. What's the status? Has any discussion taken place?

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

nope... but there is some template inheritance but never tried out myself

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

yeah, i saw that in the admin interface. I'll take a look at the code and report back.

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

I was wondering if it might make more sense to implement the feature as a "master page" which sub pages could choose to extend on a per-placeholder basis?

What I'm evisioning is that a page can be set up in the nav tree. Another page, not necessarily a child page, can be created. In the admin interface for a page, each place holder could have, for example, a checkbox saying "use master page" which could enable a foreign key relation to another page. The sub page would then pull the plugins assigned to the indicated placeholder, if any, from the master page.

Make sense? Pros or cons?

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

a inherit-plugin would make more sense... where you could choose the page you want to inherit and then it pulls in all plugins from this page that are on the same placeholder as the inherit-plugin.

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

that's actually a much better approach. i'll start putting together such a plugin. thx!

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

i have a preliminary inherit plugins that working for my home grown plugins. I'm still testing it but it's ready for some review and commentary.

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

push to github and i will have a look

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

i published it

http://github.com/heiho1/django-cms-inherit-plugin

I'm still a github newb so let me know if I should publish it to a specific repo. I'll be testing and updating this tomorrow as I know of at least one bug that I ran into.

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

looks good. I would have forked the django-cms repository and put it in there directly so i can merge directly the changes in as soon as we have 2.0 final released.

the plugin render function can be used from the PlaceholderNode... so both should call the same function.

Maybe it should be possible to prefill the parent_page field with the parent?

Could you imagine a possibility to say... inherit all plugins except the Picture Plugins? Or something in the way of: only inherit all TextPlugins... but I think this feature can be implemented by someone who needs it.

But otherwise looks good

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

"""the plugin render function can be used from the PlaceholderNode... so both should call the same function."""

I'm not entirely sure what this means. I know there are PlaceholderNode objects being passed around. Is this related to cms_tags.py at all? I know that I ran into a bug testing inheritance of a menu implementation. I'll take a closer look today.

"""Maybe it should be possible to prefill the parent_page field with the parent?"""

I decided against this because they may want to, for example, have a separate set of CMS pages which are not in the nav tree and maintain those as "master template pages". I think this is a more likely scenario for usage.

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

PlaceholderNode in cms_tags.py renders the plugins. Maybe it would be wise to extract that portion of code and pack it in a function. Then the inherit plugin can call the same function and we don't have to worry that if someone changes it on one place the other does not get forgotten.

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

I see. I'll refactor the code along these lines.

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

OK, I created a local "inheritance" branch of cms trunk:

"""
(sf-env)[14:26][~/dev/django-cms-2.0(inheritance)]$ git branch

  • inheritance
    master
    """

I have coded the plugin, added a cms.utils.plugin.py with a "render_plugins_for_context()" function and refactored cms_tags.py to use that function. I ran into a problem in the inheritance plugin where calling the render_plugins_for_context() was causing output to be escaped somewhere down the line so I commented out the refactored inherit plugin to use the old way for now. Definitely a "TODO" item. I have a local branch but I'm not sure how to push that or if I should use a CMS fork on github.

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

Disregard the problem I was having with the output escaping, I was using the "safe" on list items but needed to use "safeseq" coupled with "join" instead. Plugin should be good for another review.

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

you can push with 'git push inheritance'

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

I think I got it:
"""
(sf-env)[17:39][~/dev/django-cms-2.0(inheritance)]$ git push [email protected]:heiho1/django-cms-2.0.git inheritance
Counting objects: 30, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (24/24), 3.37 KiB, done.
Total 24 (delta 11), reused 0 (delta 0)
To [email protected]:heiho1/django-cms-2.0.git

  • [new branch] inheritance -> inheritance
    """

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

btw pushing to digi604 failed:
"""
(sf-env)[17:39][~/dev/django-cms-2.0(inheritance)]$ git push [email protected]:digi604/django-cms-2.0.git inheritance
ERROR: Permission to digi604/django-cms-2.0 denied to heiho1.
fatal: The remote end hung up unexpectedly
"""

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

follow the instructions here:

http://www.django-cms.org/en/documentation/2.0/contribution/

you don't have to push to my repo... you have to push to your cloned repo

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

ah i see it now in the network... seams to be ok

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

could clean up the code a little bit and remove all unused comments?

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

i cleaned up the code and pushed. Plz take a look

from django-cms.

digi604 avatar digi604 commented on May 2, 2024

is integrated into new frontedit branch

from django-cms.

heiho1 avatar heiho1 commented on May 2, 2024

Awesome, I'll upgrade soon. Thanks for your time.

from django-cms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.