1

Having changed the format of a Dynamic Entry Title, how do I get Craft to re-generate them all? I thought a background task would take care of it but nothing happens.

2

My understanding is that dynamic titles only get updated whenever an entry is saved — so without using a plugin you would have to re-save them each manually. If you wanted to automate this process in a plugin, you would use something like this.

public function updateMySectionTitles()
{
    $criteria = craft()->elements->getCriteria(ElementType::Entry);
    $criteria->section = 'mySection';
    $entries = craft()->elements->findElements($criteria);
    foreach ($entries as $entry) {
        craft()->entries->saveEntry($entry);
    }
}

Untested (if anyone sees an error please comment). Also, keep in mind, this might only update the current locale — I'm not sure. You'll need to test, and modify if needed. You could also potentially add this is as a custom command to the amcommand plugin for easy access.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.