
Migration | Referenz Pattern ersetzen
ACHTUNG: Nur neue Einträge werden diese Einstellung benutzen, bis sie entweder per Job oder von Hand einmal neu abgespeichert wurden.
Snippet options
Download: Download snippet as migration-referenz-pattern-ersetzen.php.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!
<?php /** * This migration can be used to change the displayed pattern for a reference field in a module. * @author Oskar Stark - oskar.stark@exozet.com */ class Migration0001 extends Exo_CMS_Migration { /** * If you want to make a line break, just fill a "<br />" to the position in the "*_PATTERN" */ const NEW_PATTERN = '[*image_source*][*title*]'; /* needed for "down"-migration */ const OLD_PATTERN = '[*title*]'; const TARGET_MODULE = 'gallery'; const TARGET_ELEMENT = 'images'; /* This is the module, where the TARGET_ELEMENT refers to */ const REFERENCED_MODULE = 'image_assets'; public function getDescription() { if ($this->getTaskDirection() === 'down') { return 'Changes old pattern ("' . self::NEW_PATTERN . '") to new pattern ("' . self::OLD_PATTERN . '") for "' . self::TARGET_ELEMENT . '" in "' . self::TARGET_MODULE . '"-Module.'; } else { return 'Changes old pattern ("' . self::OLD_PATTERN . '") to new pattern ("' . self::NEW_PATTERN . '") for "' . self::TARGET_ELEMENT . '" in "' . self::TARGET_MODULE . '"-Module.'; } } public function up() { /** @var $module Exo_CMS_Module */ $module = self::loadModule(self::TARGET_MODULE); /** @var $element Exo_CMS_InputElement */ $element = self::loadField($module, self::TARGET_ELEMENT); $references = $element->getExo_CMS_InputFieldReferences(); /** @var $reference Exo_CMS_InputFieldReference */ foreach ($references as $reference) { if ($reference->getTargetModule() === self::REFERENCED_MODULE) { $reference->setPattern(self::NEW_PATTERN); $reference->save(); } } } public function down() { /** @var $module Exo_CMS_Module */ $module = self::loadModule(self::TARGET_MODULE); /** @var $element Exo_CMS_InputElement */ $element = self::loadField($module, self::TARGET_ELEMENT); $references = $element->getExo_CMS_InputFieldReferences(); /** @var $reference Exo_CMS_InputFieldReference */ foreach ($references as $reference) { if ($reference->getTargetModule() === self::REFERENCED_MODULE) { $reference->setPattern(self::OLD_PATTERN); $reference->save(); } } } public function isDestructive() { return false; } }
Create a free my code stock.com account now.
my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!
Find out more and register nowYou can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.