I am working on a Plone 5.0 setup and I want to modify it in a way, so that users, who wants to create a new page, have a default text in their TinyMCE editor.
I am quite new to Plone and a bit overwhelmed by the amount of different languages and how they interconnect with each other. So instead of working on some files quick and dirty, I would like to have some suggestions how to start working on the problem properly and efficient.
Any suggestions, how to work on that are welcome.
The front-end (in this case TinyMCE) is not responsible for the default value, it's the form beneath.
Plone 5 uses Dexterity types with z3c forms.
EDIT: This is how your doing this the old school way - I mean the plone directives way -
Sry for misleading you. I still use plone.directives, which supports this kind of default value adapter.
The default content type Document of plone.app.contenttypes is using plone.supermodel. This has a different concept.
If you are still willing to create your own Richtext behavior you may follow those instructions: http://docs.plone.org/external/plone.app.dexterity/docs/advanced/defaults.html
In your case:
def richtext_default_value(**kwargs):
return RichTextValue('<p>Some text</p>')
#provider(IFormFieldProvider)
class IRichText(model.Schema):
text = RichTextField(
title=_(u'Text'),
description=u"",
required=False,
defaultFactory=richtext_default_value,
)
model.primary('text')
You can add a defaultFactory to the text field.
If you hack those lines on your egg, it will work.
Here's some information about setting a default value programmatically:
https://pypi.python.org/pypi/plone.directives.form#id8
How do you override the default value of a field in a dexterity behavior in Plone?
So in your case this may look something like this:
from plone.directives.form import default_value
from plone.app.contenttypes.behaviors.richtext import IRichText
from plone.app.textfield.value import RichTextValue
#default_value(field = IRichText['text'])
def richtext_default_value(data):
return RichTextValue('<p>Some text</p>')
You may extend the default_value decorator by context parameter to be more specific: #default_value(field = IRichText['text'], context=my.package.content.interfaces.IMyType)
BUT since we have the concept of behaviors it's may be better to implement your own Richtext behavior with a default value:
Creating a behavior --> http://docs.plone.org/external/plone.app.dexterity/docs/behaviors/creating-and-registering-behaviors.html AND the plone default richtext behavior as template for your own -> https://github.com/plone/plone.app.contenttypes/blob/1.2.16/plone/app/contenttypes/behaviors/richtext.py
Remove the ´plone.app.contenttypes.behaviors.richtext.IRichText` Behavior from your content type (Document) thru ZMI (portal_types -> Document)
Add your own Richtext behavior, this may be something like my.package.behaviors.richtext.IRichtextWithDefaultValue.
Related
Is it possible, for a specific plugin (e.g. newspage_pi1), to configure its TCA, i.e. its back-end form display? Just for that specific plugin, because when changing tt_content's TCA for the list type (i.e. plugins) like this:
$GLOBALS['TCA']['tt_content']['types']["list"] = [
'showitem' => "
(tabs..palettes..columns..etc...)"];
It changes it for all plugins, and I only want to change it for the newspage_pi1 list_type.
Yes, I know that I can use 'subtype_value_field' => 'list_type' and then subtypes_excludelist and subtypes_addlist to add or remove fields for specific plugins. But this is not nearly as powerful as setting showitem directly, since it allows to define new tabs, palettes, position the fields how you want to, etc.
I also know about FlexForms, but these only control the Plugin Options field, not all the other ones.
Is there a way to change the showitem for a specific plugin?
Thanks a lot in advance!
Frankly said, what you actually want is not a subtype but another type, since it needs to change fields other than the usual plugin / pi_flexform configurations.
So instead of adding that subtype as a plugin you should add it as another CType to get the full power of showitem.
Basically, this is how we add any kind of plugin too, since it makes more sense to have real database fields at hand instead of faking them with XML data structures.
As mentioned in the description here https://api.typo3.org/master/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_utility_1_1_extension_management_utility.html#ab4f6c66990aca246eac5390a76f0c83c
... - or more generally use this function to add an entry to any
selectorbox/radio-button set in the FormEngine
Silverstripe Display Logic works perfectly on forms in the CMS but I cannot get it to work on forms in the front end, specifically Bootstrap forms.
It will hide the element but won't display it when logic is applied.
//If the wetsuit dropdown is equal to custom then show the fins numerical field.
DisplayLogicWrapper::create(NumericField::create("Fins","Fins"))->displayIf("Wetsuit")->isEqualTo('Custom')->end(),
I see it just needs display to change from none to block.
Is there a way to do this so that it will keep the state on page reload as well? The drop down value will be saved as a DB entry.
EDIT: This works in the CMS but doesn't work in the front end - Custom is part of the enum values.
DropdownField::create("Wetsuit","Wetsuit")
->setSource(singleton('DiveEquipment')->dbObject('Wetsuit')->enumValues())
->setEmptyString('Select one'),
NumericField::create('Fins','Fins')
->displayIf('Wetsuit')
->isEqualTo('Custom')
->end(),
EDIT2: Working with SilversTripe 3.5, Bootstrap Forms 1.20 and Display Logic 1.0.8
1.0.8 is very outdated though.
I don't think you need the DisplayLogicWrapper for most fields… It's meant for fields like UploadField.
Have you tried this?
NumericField::create('Fins','Fins')
->displayIf('Wetsuit')
->isEqualTo('Custom')
->end(),
Not the issue here, but it's worth noting that a bug exists in Display Logic 1.3 and lower where the custom templates exist in /templates/ not /templates/forms/, causing precedence issues.
If you're experiencing problems with a FieldGroup not rendering the correct template or whatnot. Upgrading to Display Logic 1.4 will resolve this.
You'll need to include jQuery and jQuery Entwine for this to work on the frontend. This is untested but should resolve your issue.
class Page_Controller extends ContentController {
public function init() {
parent::init();
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
}
}
In TYPO3 (7.2.0) using the standard template engine, is there a way to add a placeholder attribute to the standard mail form text input?
At the moment I am using JavaScript to convert the labels into placeholders, but I am open to suggestions on a better way to do this...
The suggested solution of #biesior does only work for EXT:form 7.4 and higher (see changelog). The supplied picture shows the form wizard of TYPO3 7.5 or 7.6. In 7.2 you won't find any placeholder attribute in the wizard.
I recommend updating to TYPO3 7.6 since this version includes a major rewrite of EXT:form. You will be able to use fluid templates to customize your forms. Furthermore HTML5 attributes are possible. Before the rewrite the set of allowed attributes was quite limited. Now you are able to add all attributes you can think of (for example "data-"). See changelog.
If you have any questions regarding EXT:form join the channel on Slack. If you don't know Slack yet, check out the invite function.
During form fields editing you have many properties, also Placeholder
in text version it will be:
10 = TEXTLINE
10 {
type = text
class = foo-class
id = foo-id
name = foo
placeholder = Hmmm?
required = required
label {
value = My Field
}
}
I am wondering if there is a way to add a HTML5 Custom Data Attribute to any Content Element like Text or Text w/ images.
Anyone tried / did this before or is there a good reason not to do this?
You can either add a new field (own extension) or use any of the existing (e.g. layout to define own values. Then you can change the TypoScript rendering based on the value of this field.
... or in addition to #pgampe's answer, which is fine for programmers you can use ie. DCE extension, which allows you to create any HTML structure with usage pure Fluid syntax
Thank's for the answers. I didn't know DCE, looks very interesting.
As I needed a quick solution for just a few elements on one page I did something really quick and dirty. But as it worked for me, I would like to post it in addition to the two other excellent answers.
I used the field Description field to add the content of my custom field. I know it's not intended for this, but as alreay mentioned: quick & dirty. :-)
tt_content.stdWrap.innerWrap.cObject {
50 =< tt_content.stdWrap.innerWrap.cObject.default
50.20.10.value = csc-default layout-{field:layout}" data-filter="{field:rowDescription}
50.20.10.insertData = 1
}
We are looking at Umbraco as a possible alternative to our current CMS which was developed in house and which although powerful, is dated now and becoming more difficult to maintain.
One really good feature which we would be loth to lose is the widget feature. Using this, we can build a widget by defining a number of inputs (eg text fields, media picker, links etc) together with the html required to output the results (using placeholders to substitute in the content entered by the web content editors).
On the page, content editors can select which (if any) widget(s) to use, enter content into the inputs defined in the widget, and the page outputs this accordingly.
In other words, without resorting to programming, we can create widgets just by defining inputs and the output html in minutes.
Users can select widgets and their input is controlled and formatted.
Simple and effective.
Is anything like this available in Umbraco without having to develop new C# code for each widget? I have looked into using macros in a rich text field, but I can't see how they can be made editable using complex data entry as described above.
Beside the Macro in richtext,
In Umbraco you can use a picker/list view data type to select some "component/widget items" and for rendering it requires some code if more than one document type is allowed, if document type is x1 do code a1.
Use (Partial view) Macro Files for reuse.
This is the closest to the "widget" function you want.
A other relatively new datatype in Umbraco is the Grid layouts, allow editors to create a Complex data, column structure with multiple data types. I suspect not comparable/useful for your "widget" function.