12

If you re-save the section(s) that your entries are in, it should re-trigger a save of all of the entries. Hope that helps!


4

You can change the value in the DB directly instead of using the Elements service $entry = $event->element; $elementId = $entry->id; $siteId = $entry->siteId; Craft::$app->getDb()->createCommand() ->update( '{{%elements_sites}}', ['slug' => ElementHelper::createSlug('new-slug')], [ 'elementId' =&...


4

$timeslot isn't formatted correctly to be used as the postDate. I'd create a field that takes a date and a time and then use DateTimeHelper::formatTimeForDb() to format for use as postDate. You can't modify the postDate until after the entry has been saved - so will need to resave the entry with the newly set postDate. More info as to why you have to do ...


2

My mistake... I had {parent.ui} as the nested entry slug for the section. {parent.uri} is correct.


2

I have written a plugin for this exact use case. You can configure what time is set as the postDate or expiryDate via a Twig template. https://github.com/carlcs/craft-autoexpire


2

Thanks to @LukePearce I managed to re-write the code to work as follows: craft()->on( 'entries.onSaveEntry', function( Event $event ){ // Grab the entry from post request $entry = $event->params['entry']; // Get logged in user $user = craft()->userSession->getUser(); // Set the timeslot $timeSlot = $entry->getContent()->...


2

Steps to fix: Change the radio button default to an alternative option. Go to entry and remove the matrix block. Save entry Readd the matrix block. You should be able to correctly save the block, a long process but I couldn’t figure out what was going on.


2

Sprout SEO is a conjunction of different fields when you save an entry it will send the values from the Sprout SEO field (title, description, ogImage, etc..) in the 'metadata' namespace. So, in order to override this value, you can follow the next example: craft()->on('entries.onBeforeSaveEntry', function(Event $event) { $entry = $event->params['...


2

Another shorter and probably slightly more performant solution, using EVENT_BEFORE_SAVE: /* * Automatically update Element slugs to match the title if updated. */ Event::on( Element::class, Element::EVENT_BEFORE_SAVE, function(craft\events\ModelEvent $event) { $entry = $event->sender; $entry->slug = ElementHelper::...


1

I finally use this simple solution, which works pretty fine: Event::on( Element::class, Element::EVENT_BEFORE_SAVE, function(craft\events\ModelEvent $event) { $entry = $event->sender; if (!\craft\helpers\ElementHelper::isDraftOrRevision($entry)) { if (!empty($entry->id)) { $entry->slug = $...


1

Looks like this was a ModSecurity tripping up the contents of the particular Redactor field in the POST request. The nuclear option for a fix is to disable ModSecurity. The more nuanced fix is to find the particular rule that is tripping up the request and either disable it or to modify it so it allows that content through.


1

You can include a custom Behavior like the ContentBehavior/ FieldLayoutBehavior in Craft 3 and handle those by yourself. This way you'll be able to handle permissions by yourself. There are certain Control Panel Hooks to include custom HTML. Create a custom Behavior that's kind of a wrapper for the usual ContentBehavior Store "special/extra" fields for ...


1

Try setting your seo-field like so: $entry->getContent()->seo = ... instead of $event->params['entry']->seo = ...


1

After taking a look again, it turned out to simply be an issue with the scope of the array and a therefore empty array as a result. Works as expected now.


Only top voted, non community-wiki answers of a minimum length are eligible