0

私はploneformgenを使用しています。[編集済み] ploneformgenのカスタム スクリプト アダプターを使用して、送信されたフォームからの情報を使用してページを作成しています。問題は、送信時に生成されたページに画像が表示されないことです。テキストと 1 つの画像を含むページ/ドキュメントを作成したいと考えています。これどうやってするの?

私はこのコードを試しました:

#Creating the folder in zope instance. I gave the name 'conteudo' to it.
targetdir = context.conteudo

#Here asking for the form,  so we can access its contents
form = request.form

#Creating an unique ID
from DateTime import DateTime
uid= str(DateTime().millis())

# Creating a new Page (Document)
targetdir.invokeFactory('Document',id=uid, title= 'Minha Página', image= form['foto-de-perfil_file'],text='<b>Nome Completo:</b><br>'+form
['nome-completo']+'<br><br>'+'<b>Formação:</b><br>'+form
['formacao']+'<br><br>'+'<b>Áreas de Atuação:</b><br>'+form['areas-de-    atuacao']+'<br><br>'+'<b>Links:</b><br>'+form['links'])

# Set the reference for our new Page
doc = targetdir.get('uid',targetdir)

# Reindexed the Page in the site
doc.reindexObject()

テキストのみ表示されますが、画像は表示されません。

「setImage」を使用してみましたが、属性エラーが表示されます。別のinvokefactoryを作成しようとしましたが、「ドキュメント」の代わりに「画像」を配置すると、画像のみが表示されます。

テキストと画像の両方を表示するには、コードの何を変更すればよいですか?

前もって感謝します。

4

2 に答える 2

2

標準の Plone Document コンテンツタイプでは、画像フィールドを所有していません。

Plone 4 で古い ATContentTypes を使用している場合は、collective.contentleadimageをインストールして構成する必要があります。Plone 5 または Dexterity ベースのコンテンツを使用している場合は、スキーマに新しい画像フィールドを追加する必要があります。

于 2016-10-13T07:18:42.313 に答える