ocr_b Posted November 12, 2018 Share Posted November 12, 2018 Hi, i changed one line in the JS code of the InputfieldRepeater.js in /wire/modules/Fieldtype/FiletypeRepeater to have this field behave like i want: instead of appending the new items to the container it should prepend them, so every new item is on top instead of at the bottom. $inputfields.prepend($addItem); // $inputfields.append($addItem); how would i make this change update proof? can i just copy the file to /site/modules/(...)? or is there any smooth way to hook into this javascript function? best, ocr_b Link to comment Share on other sites More sharing options...
dragan Posted November 12, 2018 Share Posted November 12, 2018 I would rather check if there's a hookable method, or if you can do something with an admin.js/.css instead. 1 Link to comment Share on other sites More sharing options...
arjen Posted November 12, 2018 Share Posted November 12, 2018 If there is no hook you can copy the file to the site directory and in the setting of the module you can select which version you want to use. I usually store them in /site/wire/ so I know which modules I've overwritten. I have to say I haven't used this much lately. 2 Link to comment Share on other sites More sharing options...
BitPoet Posted November 12, 2018 Share Posted November 12, 2018 Here's a little snippet for site/ready.php that lets you store your modified copy of the js file in question under site/modules/FieldtypeRepeater/ and replaces the URL in a renderReadyHook on InputfieldRepeater: <?php namespace ProcessWire; wire()->addHookAfter("InputfieldRepeater::renderReadyHook", null, "useRepeaterSiteJS"); function useRepeaterSiteJS(HookEvent $event) { $config = $event->object->config; $modules = $event->object->modules; foreach($config->scripts as $script) { if(strpos($script, $config->urls->InputfieldRepeater . "InputfieldRepeater") !== false) { $altName = "InputfieldRepeater.js"; $altPath = $config->paths->siteModules . "FieldtypeRepeater" . DIRECTORY_SEPARATOR . $altName; if(file_exists($altPath)) { $altUrl = $config->urls->siteModules . "FieldtypeRepeater/" . $altName; $info = $modules->getModuleInfo("InputfieldRepeater", array('verbose' => false)); $version = $info["version"] ?: 0; $modified = filemtime($altPath); $config->scripts->remove($script); $config->scripts->add($altUrl . "?v=$version-$modified"); break; } } } } Edit: amended the text to make it clear that this approach is only about the js file in question, differing from other suggestions that duplicate the complete module. Of course, incorporating changes in the original js file on every update has to be done anyway. 1 Link to comment Share on other sites More sharing options...
adrian Posted November 13, 2018 Share Posted November 13, 2018 Is this what you are looking for? https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-copies-of-the-same-module This is what @arjen is referring to above. That said, I still think a hook approach is better if you can. 1 Link to comment Share on other sites More sharing options...
arjen Posted November 13, 2018 Share Posted November 13, 2018 Thanks @adrian, couldn't find the blog post. If a hook is present it is always more preferrable I would say. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now