bfncs Posted March 11, 2015 Share Posted March 11, 2015 Hi everyone, I want to use the core module PagePathHistory in a Processwire instance with multi-language URLs/page names activated through the core module LanguageSupportPageNames. From looking at that old Post by Ryan I was pretty sure that it should work without any problems and was surprised that actually it doesn't. PagePathHistory only saves entries to it's DB table when the page name in the main language changes, not when any of the other language names change. Looking at the code this is no suprise as PagePathHistory only hooks Pages::moved(), Pages::renamed() and Pages::deleted(), none of which would be triggered by a change in a language page name. Starry-eyed I started to implement the missing language-awareness in the module, how hard can it be, eh? ...pretty quickly it turned out that this isn't that simple, so I decided to first ask for some help and guidance. Does anyone maybe already work out a solution for this particular problem or something similiar? The problem with the implementation is that after saving a page with changes to language names, there still has to be a means of accessing the old names. For the default language name this is pretty simple because it's saved as $page->namePrevious. For language names the module would have to deposit the original names for later to build the PagePathHistory-URLs. I've been looking through all hookable functions in core classes/modules but haven't found the best place to hook into to implement this functionality. Does anyone have an idea where this would be done best? Any help is appreciated. Thanks a lot in advance Marc Link to comment Share on other sites More sharing options...
BitPoet Posted March 11, 2015 Share Posted March 11, 2015 Seeing that Page::set isn't hookable, my best bet would be to store the "name{$language->id}" values away in a hook after Page::loaded and compare them after Pages::save. 2 Link to comment Share on other sites More sharing options...
bfncs Posted March 12, 2015 Author Share Posted March 12, 2015 Hey BitPoet, thanks a lot for your answer. Probably you're right and this is the most-straightforward solution to the problem. I'll just go and and try to get it working. Will definitely publish my solution for the PagePathModule here, maybe it can be helpful for someone (or merged into core). With kind regards Marc 1 Link to comment Share on other sites More sharing options...
bfncs Posted March 21, 2015 Author Share Posted March 21, 2015 I forked the original module and use this fork for a project in development already. In my opinion it would be much more useful if merged into core, so I opened a pull request for it. You can assess the patch on Github, or you can test it using this temporary standalone module version (not to be used in conjunction with the core PagePathHistory module but as an alternative to it). The Page Path History manager module might be helpful in evaluating it. As always, I'd be grateful for any feedback. 2 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