Peter Falkenberg Brown Posted November 16, 2014 Share Posted November 16, 2014 This is exactly what I was looking for! Thank you I'm using it to create a custom "Label Field". However, it shows the ID, versus the title. Is there something I need to do to get it working when concatenating fields of the Page fieldtype? Or does it only support certain fieldtypes, like Text? Dear Ryan, I'm having the same issue as Lauren. I'd like it to concatenate the select value of a page type field. The field is 'ip_type' and what shows up is the id of the page (e.g. 197), rather than the text value of the page (e.g. 'dedicated'), which I've placed in a field called 'select_value'. I also tried changing the ip_type field to use the 'title' field instead of select_value, but there was no change. Thanks, Peter Link to comment Share on other sites More sharing options...
arjen Posted November 16, 2014 Share Posted November 16, 2014 How about ip_type.title? 3 Link to comment Share on other sites More sharing options...
Peter Falkenberg Brown Posted November 16, 2014 Share Posted November 16, 2014 How about ip_type.title? Dear Arjen, Zowie! Works perfectly! Thanks! Note that with the concat syntax 'ip_type.title', the exclamation mark for formatting doesn't work. But I don't think it's needed anyway. Ryan, this would be good to add to the module notes. Thanks again, Arjen. Peter Link to comment Share on other sites More sharing options...
arjen Posted November 16, 2014 Share Posted November 16, 2014 Thanks Peter, you may want to file an issue on GitHub since that's easier to manage for Ryan. Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted February 8, 2015 Share Posted February 8, 2015 (edited) I get an error SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_snimi-sebe-sam.field_ad_header' doesn't exist after adding a concat field to a template and trying to edit the field. The field is editable prior to adding it to the template. Running PW 2.5.18 on local xampp on windows. Am I doing something wrong or is it a bug? Edit: Cannot even remove the field from the template (and cannot remove the field as I can't edit it) Edited February 8, 2015 by Ivan Gretsky Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted February 9, 2015 Share Posted February 9, 2015 Tried it on 2.5.2 - no bug there. Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 26, 2015 Share Posted February 26, 2015 I get an error SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_snimi-sebe-sam.field_ad_header' doesn't exist I get the same error for 2.5.18. Link to comment Share on other sites More sharing options...
awebcreature Posted March 3, 2015 Share Posted March 3, 2015 Same error on 2.5.20 Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 3, 2015 Share Posted March 3, 2015 Same error on 2.5.20 For me it's working after the update to 2.5.20, so maybe the update clear the cause of the issue. Can't say for sure as the installation is not managed by me. Link to comment Share on other sites More sharing options...
awebcreature Posted March 3, 2015 Share Posted March 3, 2015 Very strange ... After update to 2.5.21 the field is OK. Thanks LostKobrakai. Link to comment Share on other sites More sharing options...
adrian Posted March 23, 2015 Share Posted March 23, 2015 I am still seeing the "Base table or view not found" error. The field still works as expected because of course this fieldtype doesn't need a DB table, but the error should be dealt with. I'll post a Github issue. Link to comment Share on other sites More sharing options...
ryan Posted March 24, 2015 Author Share Posted March 24, 2015 I saw Adrian's GitHub issue report and just pushed a fix to dev (core) for this. It was attempting to count the number of populated rows, and of course there can't be any. Now it checks to see if the Fieldtype lacks a table definition (schema) before attempting to count rows. I suppose this only affects FieldtypeConcat, but it's possible other Fieldtypes in the future may not need their own table for one reason or another. 1 Link to comment Share on other sites More sharing options...
valan Posted July 26, 2015 Share Posted July 26, 2015 @Ryan: wire()->fields does not return id, name, path, url, template Fields. I think these "system" fields should be checked separately. See also https://github.com/ryancramerdesign/FieldtypeConcat/issues/6 So far I've added the following piece of code that works. $sys_fields = ['id', 'name', 'path', 'url', 'template']; foreach($sys_fields as $fname) { if(strpos($str, $fname) === false) continue; $s = $str . ' '; while(preg_match('/\b(' . $fname . '(\.[-_.a-zA-Z0-9]+)?)\b(!?)/', $s, $matches)) { $fieldName = $matches[1] . $matches[3]; $lengths[$fieldName] = strlen($fieldName); $s = str_replace($fieldName, str_repeat('#', strlen($fieldName)), $s); if(strpos($s, $fname) === false) break; } } 1 Link to comment Share on other sites More sharing options...
regesh Posted July 28, 2015 Share Posted July 28, 2015 Done all that described but it's not showing when editing page. Link to comment Share on other sites More sharing options...
Mackski Posted September 18, 2015 Share Posted September 18, 2015 @Ryan: wire()->fields does not return id, name, path, url, template Fields. I think these "system" fields should be checked separately. See also https://github.com/ryancramerdesign/FieldtypeConcat/issues/6 So far I've added the following piece of code that works. $sys_fields = ['id', 'name', 'path', 'url', 'template']; foreach($sys_fields as $fname) { if(strpos($str, $fname) === false) continue; $s = $str . ' '; while(preg_match('/\b(' . $fname . '(\.[-_.a-zA-Z0-9]+)?)\b(!?)/', $s, $matches)) { $fieldName = $matches[1] . $matches[3]; $lengths[$fieldName] = strlen($fieldName); $s = str_replace($fieldName, str_repeat('#', strlen($fieldName)), $s); if(strpos($s, $fname) === false) break; } } Thanks Valan, This also worked for me when adding a concatenate field to the user template. I presume the field is actually hidden on the page? Unless this is another bug within the user template only? Link to comment Share on other sites More sharing options...
OllieMackJames Posted March 12, 2018 Share Posted March 12, 2018 I am trying this out in a json-ld setting and running into some trouble. For json-ld I need the content of the whole article om any give page. On this particular site we build pages with different fields, including matrix repeater fields. 2 problems, I see lots of markup like h2, span etc in the output, and the matrix repeater fields are not taken into consideration at all. What I need is the unformatted output of all the individual fields, including from the repeater matrix to show up in a concatenated field. Thanks! Link to comment Share on other sites More sharing options...
Robin S Posted March 14, 2018 Share Posted March 14, 2018 On 13/03/2018 at 5:07 AM, OllieMackJames said: 2 problems, I see lots of markup like h2, span etc in the output, and the matrix repeater fields are not taken into consideration at all. What I need is the unformatted output of all the individual fields, including from the repeater matrix to show up in a concatenated field. This fieldtype wont be suitable for what you want. Instead, add a hidden textarea field to your templates, then in a saveReady hook loop over the template fields and add markup-free text (use strip_tags) to the textarea. You'll need an if/else structure to handle all the different field types you want to support. 2 Link to comment Share on other sites More sharing options...
OllieMackJames Posted March 24, 2018 Share Posted March 24, 2018 On 3/14/2018 at 7:30 AM, Robin S said: This fieldtype wont be suitable for what you want. Instead, add a hidden textarea field to your templates, then in a saveReady hook loop over the template fields and add markup-free text (use strip_tags) to the textarea. You'll need an if/else structure to handle all the different field types you want to support. @Robin S thanks, much appreciated! Link to comment Share on other sites More sharing options...
kater Posted July 2, 2018 Share Posted July 2, 2018 is there any way to easily concatenate the id and other hidden fields? parent.child.id will output the id but i'm using it in a "multichild" context. thanks! Link to comment Share on other sites More sharing options...
loukote Posted November 11, 2019 Share Posted November 11, 2019 In a template i need to find all pages with a full name but the stored data is first name and surname. So from the doc it seams this module will not help (" you cannot directly query a Concat field from $pages->find(), for example."). As i don't know where to ask, i dare to ask here: is there a way to achieve the above by some PW magic, something like concatenation of fields $pages->find('concat("firstname surname")='.$fullname), where $fullname could be for example "Paul van Ripper" so guessing where the surname starts would inevitably lead to mistakes. Link to comment Share on other sites More sharing options...
Robin S Posted November 11, 2019 Share Posted November 11, 2019 49 minutes ago, loukote said: In a template i need to find all pages with a full name but the stored data is first name and surname. The simple solution is to create a new text field "full_name" and add it to your template. Set the visibility to "Hidden (not shown in the editor)". In /site/ready.php: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'your_template') { $page->full_name = $page->first_name . ' ' . $page->last_name; } }); You'll need to save all the pages once to populate the full_name field - if there are a lot then use the API to loop over the pages and save them. Now you can search the full_name field. 3 Link to comment Share on other sites More sharing options...
loukote Posted November 12, 2019 Share Posted November 12, 2019 12 hours ago, Robin S said: addHookAfter() This sounds like a solution that would work. I still wonder whether it is the way to go as i creates a dependency elsewhere, thus a need for a proper documentation. And also because the impacted template is a system template... Anyway, thank you @Robin S. Link to comment Share on other sites More sharing options...
ErikMH Posted June 1, 2022 Share Posted June 1, 2022 Fantastic little module, and I especially like the “magic” that happens when certain interpolated punctuation marks (“,”, “|”) are used between concatenated strings and one of the concatenated strings is blank: they’re left out! ? Would it be simple to add an ellipsis (“…”) to the list of characters so treated? My use case involves long paragraphs where I keep track of opening- and closing-words separately (in text fields), but I’d like to be able to represent the whole paragraph with Starting words … concluding words. Occasionally, there’s a very short paragraph, and I don’t want to imply that something has been left out (which an ellipsis, of course, does) — and in those unusual cases I include all of the text in the “starting words” field, leaving the “ending words” field empty. But (unlike with , and with |) the ellipsis shows up regardless. 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