szabesz Posted July 30, 2017 Share Posted July 30, 2017 Hi @kixe or others who might be able to help me out, I cannot seem to figure out something, I hope you can help. The children Pages – which need auto generated page names – have a Page Reference field called set_part_image. I would like its Title to be part of the name, like this (contrary to its name, it is NOT an image field!): date(Y-m-d_H-i-s) set_part_image.title Meaning I need a time stamp like string followed by the title of that Page field. While this one works:date(Y-m-d_H-i-s) set_part_image generating something like: 2017-07-30_11-24-35-1053 where 1053 is the ID of the Page referenced by the field (of course), when using set_part_image.title the name is set to be untitled. I also get the warning message: SetupPageName expects value in field 'set_part_image.title' to autogenerate Pagename set_part_image.title DOES have a value filled in, so it should not be a problem for the module to get it. I am using ProcessSetupPageName 2.0.8, BTW. What am I doing wrong? Any Ideas? Thanks in advance! Link to comment Share on other sites More sharing options...
PWaddict Posted July 30, 2017 Share Posted July 30, 2017 @szabesz I'm using a page reference field "countries.title"on name format for children without problem. What is your page field value type? I have it on "Single page Page or boolean false when none selected". Have you tried with ONLY set_part_image.title on the name format to see if it works? Make sure that you're using the template's Name format for children and NOT the Automatic Page Name Format of a Page Table. 3 Link to comment Share on other sites More sharing options...
szabesz Posted July 30, 2017 Share Posted July 30, 2017 (edited) 1 hour ago, PWaddict said: What is your page field value type? I have it on "Single page Page or boolean false when none selected". Bingo! Thanks a lot @PWaddict. Of course it does make a difference whether it is a PageArray or a Page. In my case I need to stick to a PageArray but obviously set_part_image.title is not what I need. "Luckily" set_part_image.first.title does work, meaning the issue is solved! On a side note, I need a PageArray because the InputField Type is Visual Page Selector which currently supports PageArrays only. Cheers, Edited July 30, 2017 by szabesz typo 2 Link to comment Share on other sites More sharing options...
szabesz Posted July 30, 2017 Share Posted July 30, 2017 One more question regarding generated page names: currently different values referenced in "Name format children" are concatenated by a dash character separating them. Can I somehow use underscore instead? That way I could easily tell the various values apart even in the generated name. Link to comment Share on other sites More sharing options...
szabesz Posted July 31, 2017 Share Posted July 31, 2017 21 hours ago, szabesz said: That way I could easily tell the various values apart even in the generated name. Since I am dealing with children of PageTables which do not need any public names/urls I use the title instead which is much more meaningful anyway. I realized that I do not even need this module for what I want to achieve. It just seemed convenient at first sight to use it, instead I switched to using my own hook in order to do whatever I need. Link to comment Share on other sites More sharing options...
PWaddict Posted July 20, 2018 Share Posted July 20, 2018 @kixe I want to use an Options field as part of the pagename but I don't get anything. On the Name format for children I tried with: title my_options_field and with title my_options_field.title but I only get the pagename from the title field. 1 Link to comment Share on other sites More sharing options...
PWaddict Posted July 21, 2018 Share Posted July 21, 2018 @kixe The 175 line of the module is causing the issue: if (wire('fields')->get($format) && wire('fields')->get($format)->type instanceof FieldtypeOptions) $value = $page->get($format)->get('value|title'); I had to change this to this in order to get the title of the options field: if (wire('fields')->get($format) && wire('fields')->get($format)->type instanceof FieldtypeOptions) $value = $page->get($format)->title; Additional languages for the options field are ignored cause I'm only getting the default one for all page names. Please check it out and update the module. Thanks. Link to comment Share on other sites More sharing options...
PWaddict Posted October 30, 2018 Share Posted October 30, 2018 @kixe I've updated the module to 2.1.1 and now I can't even save the page. I'm getting the following error: Method SelectableOptionArray::getLanguageValue does not exist or is not callable in this context 1 Link to comment Share on other sites More sharing options...
kixe Posted October 31, 2018 Author Share Posted October 31, 2018 @PWaddict Sorry. I fixed the bug. Please update to 2.1.2 Link to comment Share on other sites More sharing options...
PWaddict Posted October 31, 2018 Share Posted October 31, 2018 12 minutes ago, kixe said: @PWaddict Sorry. I fixed the bug. Please update to 2.1.2 With the 2.1.2 the page is getting saved but when I'm editing the related fields the page names for alternate languages are not getting updated. Link to comment Share on other sites More sharing options...
PWaddict Posted October 31, 2018 Share Posted October 31, 2018 @kixe I've added on the options field all the options in all languages and now the page names for alternate languages are getting updated. The problem is that the option value is getting injected on the page names instead of the option title. Link to comment Share on other sites More sharing options...
PWaddict Posted October 31, 2018 Share Posted October 31, 2018 @kixe I replaced value$langID|title$langID with title$langID and now it works properly. Link to comment Share on other sites More sharing options...
kixe Posted November 1, 2018 Author Share Posted November 1, 2018 The idea is to generate the page name from field values and not from labels. I will not change this. But I added support for dot syntax for the options fieldtype which should feed your needs. // no fallback to default language if not set. Options should be populated in each language my_options_field.title my_options_field.value my_options_field.id // always fallback to default language. If values are set pagename is pulled from the value, otherwise from title my_options_field 1 Link to comment Share on other sites More sharing options...
Macrura Posted January 29, 2019 Share Posted January 29, 2019 i'm getting errors when this module is installed, using the latest version of PW. Had to uninstall it to remove the error; this is ok in my situation as i wasn't doing anything complex; but would be good to see if this can be fixed somehow.. TIA Link to comment Share on other sites More sharing options...
Tyssen Posted February 8, 2019 Share Posted February 8, 2019 I'm getting the same error with PW 3.0.62. I installed it, updated my parent template with the format I wanted to use and then went to create a child page. I got the error, uninstalled the module as suggested by Macrura and refreshed the page I was trying to create and got redirected to page/edit/?id=XXXX&new=1 and it had created the name/title in the format I'd specified. Now I can create more child pages which automatically skip the add new page and have the expected name/title format, even though the module is no longer installed. Link to comment Share on other sites More sharing options...
PWaddict Posted May 2, 2019 Share Posted May 2, 2019 @kixe can you please update the module to display the warning "SetupPageName expects value in field 'my_field' to autogenerate Pagename" ONLY on debug mode? It's not user friendly and it can confuse site editors who have no idea about these stuff as it displayed instantly when adding a new page. Replacing the 236 line with this would do the trick: if ($warning === true) $this->warning(sprintf($format_warning, $format), Notice::debug); Link to comment Share on other sites More sharing options...
pwfans Posted May 6, 2019 Share Posted May 6, 2019 On 1/29/2019 at 11:58 PM, Macrura said: i'm getting errors when this module is installed, using the latest version of PW. Had to uninstall it to remove the error; this is ok in my situation as i wasn't doing anything complex; but would be good to see if this can be fixed somehow.. TIA Confirmed, same error using PW 3.0.123 and 2.1.3 module version, in my case still doesn't work even after uninstalled the module. Fatal Error: Uncaught Error: Call to a member function get() on null in ...\site\assets\cache\FileCompiler\site\modules\ProcessSetupPageName\ProcessSetupPageName.module:129 Stack trace: #0 ...\site\assets\cache\FileCompiler\site\modules\ProcessSetupPageName\ProcessSetupPageName.module(298): ProcessSetupPageName->createFromFormat(Object(ProcessWire\Page), 'parent.title') #1 ...\wire\core\Wire.php(386): ProcessSetupPageName->___SetupPageName(Object(ProcessWire\Page), Array) #2 ...\wire\core\WireHooks.php(723): ProcessWire\Wire->_callMethod('___SetupPageNam...', Array) #3 ...\wire\core\Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessSetupPageName), 'SetupPageName', Array) #4 ...\site\assets\cache\FileCompiler\site\modules\ProcessSetupPageName\ProcessSetupPageName.module(93): ProcessWire\Wire->__call('SetupPageName', Array) #5 ...\wire\core\WireHooks.php(813): ProcessSetupPageName->{closure}(Object(ProcessWire\HookEv (line 129 of ...\site\assets\cache\FileCompiler\site\modules\ProcessSetupPageName\ProcessSetupPageName.module) Link to comment Share on other sites More sharing options...
jonassalen Posted July 1, 2019 Share Posted July 1, 2019 Any updates on this? I really need this module and am not technical enough to fix this myself. Link to comment Share on other sites More sharing options...
Robin S Posted July 1, 2019 Share Posted July 1, 2019 @jonassalen, open the ProcessSetupPageName.module file in your code editor and try replacing this section at the top of the createFromFormat() method... if ($languageID == null && $this->languageSupport == true) $languageID = $this->wire('languages')->getDefault()->id; $langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID; if ($this->languageSupport) { $userLang = $this->wire('user')->language; $this->wire('user')->language = $this->wire('languages')->get($languageID); } ...with... $langID = null; if ($this->languageSupport) { if ($languageID == null) $languageID = $this->wire('languages')->getDefault()->id; $langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID; $userLang = $this->wire('user')->language; $this->wire('user')->language = $this->wire('languages')->get($languageID); } 3 Link to comment Share on other sites More sharing options...
thistimj Posted July 5, 2019 Share Posted July 5, 2019 @Robin S thanks for that! That got the basic functions of the module to work for me. I may be missing something, but is part of the function of this module to give the child pages titles as well as names? The names are working, but the page titles are not being constructed according to the naming convention I'm assigning via the module. Link to comment Share on other sites More sharing options...
Robin S Posted July 7, 2019 Share Posted July 7, 2019 On 7/6/2019 at 5:47 AM, thistimj said: I may be missing something, but is part of the function of this module to give the child pages titles as well as names? No, I don't think the module sets page titles. I was expecting something similar using the core "Name format for children" feature, but if you want to automatically set a title you have to use a hook. It's discussed in the topic below: Link to comment Share on other sites More sharing options...
thistimj Posted July 8, 2019 Share Posted July 8, 2019 Thanks again, @Robin S. I appreciate it! 1 Link to comment Share on other sites More sharing options...
kixe Posted March 21, 2020 Author Share Posted March 21, 2020 On 7/2/2019 at 12:27 AM, Robin S said: @jonassalen, open the ProcessSetupPageName.module file in your code editor and try replacing this section at the top of the createFromFormat() method... if ($languageID == null && $this->languageSupport == true) $languageID = $this->wire('languages')->getDefault()->id; $langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID; if ($this->languageSupport) { $userLang = $this->wire('user')->language; $this->wire('user')->language = $this->wire('languages')->get($languageID); } ...with... $langID = null; if ($this->languageSupport) { if ($languageID == null) $languageID = $this->wire('languages')->getDefault()->id; $langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID; $userLang = $this->wire('user')->language; $this->wire('user')->language = $this->wire('languages')->get($languageID); } Sorry for not looking in here. I replaced the code as recommended by @Robin S without further testing and hope it works well now. I didn't use the module by myself for a long time. Stay healthy! 1 Link to comment Share on other sites More sharing options...
Andi Posted April 12, 2020 Share Posted April 12, 2020 Very cool module @kixe. Would it be hard to implement date formatting for custom datetime fields instead of just PW's built in "date" field? Setting up an event planner over here, where every event has a event_date field (datetime) that I'm trying to prepend to the event's url slug (or name in PW's terminology ?). If i use "event_date title" as the name format it works, if i try "event_date(Y-m-d) title" I get an error: Quote Error: 'Name Format Children' in settings of template 'location'. Unknown property, field or subfield: 'event_date(Y-m-d)' Currently working around the issue by changing the field's output formatting directly, but I was wondering if that would be a feature that might come in handy in the future. Cheers and happy easter! Link to comment Share on other sites More sharing options...
Pete Posted February 13, 2021 Share Posted February 13, 2021 Thanks for the module - I had to change this COLLATE utf8_general_ci to this though COLLATE utf8mb4_general_ci because it errored when I created pages due to my database setup. Not sure if there's a way to check the character set of the DB or something and set that bit accordingly? 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