Wednesday, June 28, 2017

Plone 5 custom views using Rapido 1.1.1

After you've created a custom content type through the web (TTW), you'll want a custom view to go with it. In this simple example we create a custom youtube page content type and a supporting view all TTW.

Step 1 - Create a new content type

Start by creating the content type through the Dexterity Types control panel.

Site Setup > Dexterity Types

Select and clone the "Page".

.. ..
Then add a "youtube_url" field.

After adding your first "Youtube page" you'll notice that the default view isn't showing us the "youtube_url" field that we added. We'll fix that in the next step.

Step 2 - Create a custom rapido view

To create a custom view (sometimes called an "extra view"), start by creating a rapido app, we'll call ours views and to this we'll add a youtube-page block.
See the structure in the gist below:
.. ..
The video below explores the building blocks of our custom view. After some tinkering we settle on the id youtube-page-view for our view.
.. ..

Gotchas with registering view ids

What was not recorded in the video was the fact that the view id youtube-page had been used in the context of a different rapdio block (I was practicing before the real recording). If you were paying careful attention to the demo video you may have noticed some unusual behaviour when trying to use the view named youtube-page. When you define a view id and then change it later on, the id expects to work with the originally registered block. I've found that restarting the instance resolves this issue.

No comments:

Sign up for my upcoming Plone 5 Book & Video tutorials

plone 5 for newbies book and videos