[PYTHON] Launch docker.plone and add a custom template

It is a procedure that started clone with docker and tried the tag of the template.

Start docker

The plone docker is officially available. I downloaded it and used it as it is. https://github.com/plone/plone.docker

Start clone with options

% docker run --rm --name plone -v $PWD/plone-data:/data -p 8080:8080 -e SITE=plone plone

If you access http: // localhost: 8080 / plone with a browser, the top page will be displayed. スクリーンショット 2020-09-04 17.35.06.png

Template adjustment

You can preview it by creating a new one in the custom directory.

Add template

  1. Go to the list of custom templates http://localhost:8080/plone/portal_skins/custom/manage_main

  2. From the Select type to add pull-down at the top right of the navigation menu スクリーンショット 2020-09-04 14.34.52.png

  3. Select Page Template スクリーンショット 2020-09-04 14.35.15.png

  4. Enter the Id in the pop-up window and press the Add and Edit button. スクリーンショット 2020-09-04 14.40.37.png

  5. The edit screen is displayed http://localhost:8080/plone/portal_skins/custom/abc/pt_editForm スクリーンショット 2020-09-04 14.42.28.png

Added template

I've added a template to see the contents of REQUEST and added the following line:

    <h2>container/REQUEST</h2>
    <p tal:replace="structure container/REQUEST">container/REQUEST</p>

http://localhost:8080/plone/portal_skins/custom/abc/pt_editForm


<!DOCTYPE html>
<html>
  <head>
    <title tal:content="template/title">The title</title>
    <meta charset="utf-8" />
  </head>
  <body>
    
    <h2><span tal:replace="context/title_or_id">content title or id</span>
        <span tal:condition="template/title"
              tal:replace="template/title">optional template title</span></h2>

    This is Page Template <em tal:content="template/id">template id</em>.

    <h2>context/def</h2>
    <p tal:define="def context/def" tal:content="def">context/def</p>
    
    <h2>container/REQUEST</h2>
    <p tal:replace="structure container/REQUEST">container/REQUEST</p>

  </body>
</html>

python script

You can write the script in python and call it from the template.

http://localhost:8080/plone/portal_skins/custom/def/ZPythonScriptHTML_editForm

# Example code:

# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
response =  request.response

# Return a string identifying this script.
text = 'This is the %s %s in %s' % (script.meta_type,
                                    html_quote(script.title_and_id()),
                                    container.absolute_url())

print(text)
#print(container.REQUEST.BASE1)
#print(container.REQUEST)
return printed

The following is added to the template added earlier.


    <h2>context/def</h2>
    <p tal:define="def context/def" tal:content="def">context/def</p>

display

You can check the result by accessing the following URL http://localhost:8080/plone/portal_skins/custom/abc スクリーンショット 2020-09-04 18.06.59.png

reference

Recommended Posts

Launch docker.plone and add a custom template
[Raspberry Pi] Add a thermometer and a hygrometer
Launch a web server with Python and Flask