Producing a dynamic banner without Python

So I'm building a site that will have regular updates to a banner that looks like the attached image.

I've worked out the CSS styling, now I'm trying to do the "dynamic" part. I'd like our users to be able to update the images and text in the images without having to dig through the HTML editor and change things individually.

Is there a way to do that with an existing addon, or would I have to write a new one? Would a viewlet work?

Try this:

https://github.com/collective/collective.behavior.banner

Not sure why it is so important to do it without python, but still there are lots of ways.

The simplest, lazy approach is probably to just use tal:replace structure and point to 'where the content is' .... 'without any programming', you could do the following:

  1. Make a new content type (banner) with the fields (image 1, title 1, Title 2, text 2, image 3, title 3 (and maybe the urls)
  2. make a browser view or a rapido or themefragments template/block
  3. Insert it with diazo or plone.app.mosaic

I'd like the customers to be able to update this by themselves rather than having to learn Python to update the content. If I can figure out how to set up my development environment, then I can certainly write an add-on to do the same thing.

My understanding from the documentation was that browser views required an addon to be built... is there a way to write them without having to go through the whole buildout again?

Thanks for the tip!

Depending on how you want to let the user integrate the slider you have various possibilities:

  • mosaic: collective.tiles.sliders
  • Page template: create a viewlet in your theme package which reads documents either from a collection or a coded catalog search and generates the markup. I‘d recommend using leadimage behaviour on the docs to get the image for your slider item.

Note: in a project we‘ve enabled lead Image behaviour on the „Link“ article to get slideritems pointing to external urls.

Maybe this helps to get an idea ...

Cheers

I'd definitely go for doing this from a collection. Unfortunately, I can't seem to get a theme package working. I keep getting errors in mr.developer or mr.bob (see previous post)

Maybe check out plonecli https://pypi.org/project/plonecli/
Its a cli for bobtemplates ...

plonecli looks like a good tool. Unfortunately, although interactively it works, when building inside of a docker container, I can't seem to specify the -c switch that takes an autoanswer file. Is there an easy way to do that?

Also, plonecli doesn't seem to solve the problem with missing the setup.py file. I must be doing something wrong in the buildout, if I could only figure out what...

see my comment here Creating an addon results in errors

1 Like

@LeaderOne I wouldn't use a collection or a plugin. I explain in a lot of depth here why and what we now use - https://www.youtube.com/watch?v=HXwvXf0SW1Q

@djay, I thank you. That talk was very good, and it absolutely fits the problem I'm trying to solve.

I have a ton of questions, but I'll start with just a couple for now...

Am I understanding that when someone edits the markup for the page through Plone's editor, it goes back through Diazo before being output to the client? I thought that only happened with index.html and other theme resources, but from the talk, I think I misunderstood that.

I noticed you put Python code into the theme with the themefragments folder. How does that run? Is there something in the theme that tells Diazo to run the correct Python file, or was that the acquisition trick you mentioned earlier?

Diazo is a transform applied to every page generated by plone. That rendered page includes the content from the visual editor, headers footer etc. The transform can then use parts of index.html to merge with the plone rendered page.

The python works only with the plugin called collective.themefragments which has the documenation.