98 |
98 |
99 |
99 |
100 Paragraph in the ZMI |
100 Paragraph in the ZMI |
101 """""""""""""""""""" |
101 """""""""""""""""""" |
102 |
102 |
103 |
103 1) Container Paragraph |
104 To display and manage the new paragraph in the ZMI, you should create this associated forms |
104 ---------------------- |
105 |
105 |
106 1) Paragraph factory |
106 For example :py:class:`IParagraphContainerTarget`, it's a marker interface for paragraph containers. |
107 -------------------- |
|
108 |
107 |
109 To create a new element instance inside the zodb, we need a container to this object. PyAMS provide |
108 To create a new element instance inside the zodb, we need a container to this object. PyAMS provide |
110 `IParagraphContainerTarget`, it's the default container for all paragraphs. We could use this container interface |
109 `IParagraphContainerTarget`, it's the default marker interface container for all paragraphs. |
111 as context to create a new paragraph. |
110 We could use this interface as context to declare a new pagelet. |
112 |
111 |
113 |
112 Definition of a Contact Phone form to create a new ContactPhone object |
114 Declaration of the **factory** of `ContactPhoneParagraph` |
|
115 |
|
116 .. code-block:: python |
|
117 |
|
118 @utility_config(name=CONTACT_PHONE_PARAGRAPH_TYPE, provides=IParagraphFactory) |
|
119 class ContactPhoneParagraphFactory(BaseParagraphFactory): |
|
120 """Contact paragraph factory""" |
|
121 |
|
122 name = _("Contact Phone card") |
|
123 content_type = ContactPhoneParagraph |
|
124 secondary_menu = True |
|
125 |
|
126 |
|
127 Definition of a form to create a new ContactPhone instance |
|
128 |
113 |
129 .. code-block:: python |
114 .. code-block:: python |
130 |
115 |
131 from pyams_form.form import ajax_config |
116 from pyams_form.form import ajax_config |
132 |
117 |
149 return ContactPhoneParagraph() |
134 return ContactPhoneParagraph() |
150 |
135 |
151 def add(self, object): |
136 def add(self, object): |
152 IParagraphContainer(self.context).append(object) |
137 IParagraphContainer(self.context).append(object) |
153 |
138 |
|
139 |
|
140 To display and manage the new paragraph in the ZMI, you should create this associated forms |
154 |
141 |
155 2) Create the Paragraph addform button in the menu |
142 2) Create the Paragraph addform button in the menu |
156 -------------------------------------------------- |
143 -------------------------------------------------- |
157 |
144 |
158 We have created a new form and we want add a quick access button to create a new paragraph |
145 We have created a new form and we want add a quick access button to create a new paragraph |
237 .. note:: |
224 .. note:: |
238 |
225 |
239 Select the new content block types in ZMI to make it available in tools |
226 Select the new content block types in ZMI to make it available in tools |
240 |
227 |
241 .. image:: ../_static/select_paragraph.png |
228 .. image:: ../_static/select_paragraph.png |
|
229 |
|
230 |
|
231 5) Paragraph Factory |
|
232 -------------------- |
|
233 |
|
234 If you want to create automatically a paragraph object for a shared content you must define a factory |
|
235 |
|
236 Declaration of the **factory** of `ContactPhoneParagraph` |
|
237 |
|
238 .. code-block:: python |
|
239 |
|
240 @utility_config(name=CONTACT_PHONE_PARAGRAPH_TYPE, provides=IParagraphFactory) |
|
241 class ContactPhoneParagraphFactory(BaseParagraphFactory): |
|
242 """Contact paragraph factory""" |
|
243 |
|
244 name = _("Contact Phone card") |
|
245 content_type = ContactPhoneParagraph |
|
246 secondary_menu = True |
|
247 |
|
248 When the contributors will create new shared content with predefined paragraphs, |
|
249 it's the container factory class that will be used to create the paragraph object. |
242 |
250 |
243 |
251 |
244 How to associate links or Illustrations to a Paragraph ? |
252 How to associate links or Illustrations to a Paragraph ? |
245 ======================================================== |
253 ======================================================== |
246 |
254 |