How do you reorder an entity reference revisions field during hook_node_presave?

I am trying to reorder some paragraphs based on a text field within them on node save so the author does not need to maintain the alphabetical order manually, but when I save the node all values are lost. I tried matching the array from $node->get(‘field_paragraphs’)->getValue(), but that does not seem to work. function mymodule_node_presave(NodeInterface…

Don’t repeat yourself: Natural place for clculations on the FieldItemList of a custom FieldType wanted

I have a custom field type that contains a number field, among others. class MyFieldItem extends FieldItemBase { public static function propertyDefinitions($field_definition) { $properties = []; $properties[‘some_number’] = DataReferenceTargetDefinition::create( ‘integer’ ); … } … } I need the sum of all values of the property some_number. A function adding the numbers would look like this:…

Is there a way to avoid content duplication on multi site setup?

I have just crated a multi site according to the instructions on Crafts page. Lets just say I have: siteone.com with template forlder templates/siteone sitetwo.com with template forlder templates/sittwo It all works fine however all pages from templates/siteone can also be accessed on sitetwo by simply going to sitetwo.com/siteone/site-one-only-page Is there a way to prevent…