Search the Community
Showing results for tags 'Field'.
-
I need to have working some specific structure of data I did not find anywhere on forums yet. For simplicity I will specify what I would like to have working: There is a page with child pages. I could name it for example "houses". All children pages are using same template (house) with page reference field to another page children(floors). Referenced page for example "floors" has children that all are using their same specific template (floor). On this template is page title or name, other fields and integer field of floor number (floor_number). When new child of this page is created I need to have that integer field automatically populated from 1, but only in context of referenced page. So when I create house named house1 and then in editing of house1 I create for example 3 floors I would like to have floor(title of page) 1(integer field), floor 2, floor 3 but only for that house1. Name of floor could be page title or name and it is text ("floor") and number is just integer field (1,2,3). When I add more houses I could have for example have NewHouse (name of page) with basement 1 and floor 2. I could add BigHouse also with basement 1, floor 2 and floor 3 .... etc.. When creating that floors I would like to use quick creating multiple new items which allows input page select multiple - so I just want to input floors on several rows and hit save. In that moment could be nice to have all that new floors automatically numbered from 1 on that integer field (floor_number) I want to use Page Reference field with input Page List Select Multiple. How could this be accomplished ? Is there some good way how to make that integer field to increase automatically but only for specific ref.page ? Thanks very much of any idea or help with this
- 11 replies
-
- page reference field
- field
-
(and 1 more)
Tagged with:
-
Thanks to @Macrura for the idea behind this module. Page Field Info Adds information about options in Page Reference fields. Supports InputfieldSelect and inputfields that extend InputfieldSelect: InputfieldSelect InputfieldRadios InputfieldSelectMultiple InputfieldCheckboxes InputfieldAsmSelect Requires ProcessWire >= 3.0.61 and AdminThemeUikit. Screenshots Field config Example of changes to inputfield Example of info field filled out in Page Edit Installation Install the Page Field Info module. Configuration In the Input tab of the settings for a Page Reference field... Tick the "Add info tooltips to options" checkbox to enable tooltips for the options in the field. Tooltips are not possible for Select or AsmSelect inputfield types so for those types you would want to tick the next option. Tick the "Append info about selected options" checkbox to append information about the selected options to the bottom of the inputfield. If the Page Reference field is a "multiple pages" field then the info for each selected option will be prefixed with the option label (so the user will know what option each line of info relates to). In the "Info field" dropdown select a text field that will contain information about the page, to be used in the tooltips and appended info. Of course this field should be in the template(s) of the selectable pages for the Page Reference field. Hook In most cases the "Info field" will supply the text for the tooltips and appended info, but for advanced usages you can hookPageFieldInfo::getPageInfo() to return the text. For example: $wire->addHookAfter('PageFieldInfo::getPageInfo', function(HookEvent $event) { $page = $event->arguments(0); // The page $inputfield = $event->arguments(1); // InputfieldPage $field = $event->arguments(2); // The Page Reference field $info = $event->return; // Text from the info field, if any // Set some custom text as the $event->return... }); https://github.com/Toutouwai/PageFieldInfo https://modules.processwire.com/modules/page-field-info/
- 11 replies
-
- 15
-
Field Initial Value For most field types, allows the definition of an initial value that is automatically set when pages are created. The initial value can be set in template context if you want a different initial value in different templates. Example for a "Countries" Page Reference field using AsmSelect: Example with explanatory notes in a CKEditor field: Differences from "Default value" The core allows setting a "Default value" for certain field types. The "Initial value" setting added by this module is different from the "Default value" setting in the following ways: The "Default value" is a setting that applies only to the inputfield, meaning that the value is shown in the inputfield by default but is not stored until you save the page. By contrast, the "Initial value" is automatically saved to the page when the page is first created. Related to point 1, when a page is created via the API rather than in the ProcessWire admin the "Initial value" is saved to the page but the "Default value" is not. The "Default value" has no effect when a field is not "required", but the "Initial value" is set for both required and not required fields. Related to point 3, a user can empty a field that had an "Initial value" applied but a field with a "Default value" set cannot be emptied. The "Initial value" setting is available for more field types than "Default value". Supported field types The following field types are supported, along with any types that extend them: FieldtypeText (includes types that extend it such as Textarea, CKEditor, URL, etc.) FieldtypeDatetime FieldtypeInteger FieldtypeDecimal FieldtypeFloat FieldtypePage (with all core inputfield types) FieldtypeCheckbox FieldtypeOptions (with all core inputfield types) FieldtypeToggle FieldtypeSelector FieldtypeMultiplier (ProField) FieldtypeCombo (ProField, only supported when File and Image subfields are not used) FieldtypeStars (third-party module) If you want to try field types beyond this you can define additional types in the module config, but your mileage may vary. Unsupported field types It's not possible to set an initial value for these field types, along with any types that extend them: FieldtypeFile (and FieldtypeImage) FieldtypeRepeater (includes types that extend it such as Repeater Matrix and Fieldset Page) FieldtypePageTable FieldtypeTable (ProField) Notes Seeing as the initial value is defined in the field config it has no idea of the current page - for the purposes of rendering the initial value inputfield the home page is supplied as a dummy page. This probably isn't an issue in most cases but it might have an effect for some Page Reference fields if they use the current page to limit the selectable pages. https://github.com/Toutouwai/FieldInitialValue https://processwire.com/modules/field-initial-value/
-
emplate Field Widths Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template. Since v0.2.0 the module also adds a similar field to the settings of Edit Field for Repeater, FieldsetPage and Repeater Matrix allowing you to quickly set the widths of inputfields within the Repeater/FieldsetPage field, or within each Repeater Matrix type. Note: widths are only saved if the edit form is submitted with the "Field widths" field in an open (non-collapsed) state. Edit template Edit Field: Repeater Edit Field: Repeater Matrix Why? When setting up a new template/repeater or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process. Config options You can set the default presentation of the "Field widths" field to collapsed or open. Widths entered into the "Field widths" field are only applied if the edit form is submitted with the field in an open (non-collapsed) state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width. https://github.com/Toutouwai/TemplateFieldWidths https://modules.processwire.com/modules/template-field-widths/
- 49 replies
-
- 27
-
Hi, I decided to put a dynamic background to some pages of my site. The background is controlled by a js script. I also decided to create a template and a field to choose from time to time which background to put. Unfortunately, the processwire condice to dynamically link scripts seems not to work as well as for images and simple links. Where am I going wrong? DON'T WORK: <script src="<?=$page->texturl_background?>"></script> DON'T WORK: <script src="<?php echo $config->urls->templates?><?=$page->texturl_background?>"></script> Instead, it works well: <link rel="icon" href="<?php echo $config->urls->templates?><?=$page->texturl_favicon?>" type="image/png">
-
I've spent way too much time trying to figure this out so now I just have to ask. I added an option to the save button when editing a page. What I want it to do is, when clicked, send an email out to the appropriate person, change a field on the page, then save. I have everything working up until the change a value on the page and save. I can't seem to figure out how to do this. I really don't understand what I'm doing. So far the email part works because I just smashed together various bits and pieces from the forums. Here is the hook that adds the button $wire->addHookAfter('ProcessPageEdit::getSubmitActions', function($event) { $actions = $event->return; // array of actions indexed by name $page = $event->object->getPage(); // page being edited // add a new action to process the Change of Address request if // this page uses the change of address template if ($page->template == 'Change_Of_Address' && $page->yes_no == false){ $actions['Process Form'] = [ 'value' => 'process', 'icon' => 'address-card', 'label' => '%s + Process', 'class' => '', ]; $event->return = $actions; } }); And here is the modified code that attempts to change a field value and save the page. I removed all the part that creates/sends the email. $wire->addHookAfter('ProcessPageEdit::processSubmitAction', function($event) { $action = $event->arguments(0); // action name, i.e. 'hello' $page = $event->object->getPage(); // Page that was edited/saved if($action === 'process') { $page->yes_no = true; $pages->saveField($page, 'yes_no'); $notice = new NoticeWarning("This address change has been sent to the appropriate crew."); $notice->icon = 'address-card'; $event->notices->add($notice); $event->object->setRedirectUrl('../'); } }); I get an error on the $pages->saveField line saying: Call to a member function saveField() on null Can anyone offer some help on this? If there is an easier way to do this other than using hooks and adding buttons I would welcome that as well.
-
Any field has visibility option (showif) that works perfect with field in current template. But i need to compare with the field in parent page template. Is it possible? The task is like that: I have multiselect field in parent page - it is "Page Refference" field. And i need field in children page compare that there is some page selected in parent multiselect field for it to show in editor.
-
How to check if each page reference checkbox is checked?
SwimToWin posted a topic in General Support
It's incredible what you can do with ProcessWire. I did hit a limitation on my side though... ? and would like to ask for some support: Problem: I'm using a Page Reference Checkboxes field that gets it's Options from a few Pages; Page field value type is set to "Multiple pages PageArray". Screenshot: What I want: to check if each checkbox is checked or not (without using a foreach loop). What I tried: var_dump( $page->config->has(1898)); var_dump( $page->config->getValues()); // (WireArray is output, I don't know how to use that.) var_dump( $page->config->getValues(1898)->id ); // Warning: Attempt to read property "id" on array var_dump( $page->config->get(1898) ); // NULL var_dump( $page->config->get(1898)->id ); // Warning: Attempt to read property "id" on null var_dump( $page->config->first()->id ); // int(1898) ... better, but how to get the next value? var_dump( $page->config[1898] ); // bool(false) var_dump( $page->config->find(1898) ); var_dump( $page->config->find(1898)->id ); var_dump( $page->config(1898) ); NULL (checkbox is set) var_dump( $page->config->1898 ); // unexpected integer "1898", expecting identifier or variable or "{" or "$" var_dump( $page->config->find(1898)->id ); // Fatal Error: Uncaught Error: Call to a member function find() on null var_dump( $page->config->has(1898)); // Fatal Error: Uncaught Error: Call to a member function has() on null $a = $page->config->getValues(); echo isset($a->1898->id) ? 1 : 0; $a = $page->config->getValues(); echo isset($a->1898->id) ? 1 : 0; // Parse Error: syntax error, unexpected integer "1898", expecting identifier or variable or "{" or "$" echo isset($a[1898]->id) ? 1 : 0; // 0 (but checkbox is set?) echo isset($a[1898]['id']) ? 1 : 0; // 0 (but checkbox is set?) var_dump( $page->config->eq('foo')->id ); // int(1898) var_dump( $page->config->eq('foo') ); // wirearray var_dump( $page->config->has('foo')); // bool(true) // Is this a bug? eq() returns same Page ID for two names. echo $page->config->eq('foo'); // 1898 (correct) echo $page->config->eq('bar'); // 1898 (incorrect, the ID is 1899. ... and thanks for always being a helpful, constructive, and knowledgeable community! Make a great day! ?- 3 replies
-
- checkboxes
- page reference
-
(and 2 more)
Tagged with:
-
I have a problem and I don't understand. I have a profield table with different fields and a select field. I did like it's instructed and put "value=label". But when I'm trying to output the select field with var_dump (to debug), it's indicated that the field is a string that contains the value. Why is it a string ? when I try myselectfield->value or label or title I have an error saying I'm trying to get a property on a non-object ... Anyone ?
-
Hey all, I have pages that can be created two ways, in the PW admin and via an endpoint where JSON data is sent. I have a hook that checks field data on page save and errors if it is not correct. I would like this to create an error in the PW admin using $this->errors, but if the page is created via the Page API in the script that handles JSON requests I want to throw an exception I can catch and handle accordingly for the JSON response. This also allows for setting a user friendly error message for the PW admin, and machine friendly data for API use. Trying to figure out how to detect which context that the page is being created in. A script, or in the PW admin and act accordingly. Is this possible?
-
Hello all! I am pretty new to PW and now trying to figure out how to build a filter that uses AND logic and includes many fields. With help I have figured out Page Reference fields and Repeaters, but simple Text Filed with dropdown text tags makes me confused. As I think of it, first I need to get the array of given fixed options of Text Tags here: And then I just need to print it out as checkbox form and circle through each page to see if they have the checked value in place of this field. Like what I have with page references: But for the life of me I cannot figure out how to get this list...So if you have suggestions, I would really appreciate it! Best, Kseniia
-
Hi there Short version of question Let's say I have a page in the admin that contains a field... Is it possible to output the content from that field on another page in the admin? Almost like a reference. Longer version of question (with example) A house builder with multiple (60+) developments. They want to be able to create notices/messages that can be added to one or many developments. Handy for things like regional covid lockdowns or temporary office closures due to bad weather. My approach for the admin editing options: Add each message to each development Pros: You edit the message on the development page in context Cons: Very time consuming and repetitive if the same message needs to be applied to 60+ developments Control all the messages from one admin page and say which development each message should be applied to Pros: Easier to add/remove messages to more than one development at a time. Control all messages from one place. Cons: Content is not added on development page, which is where typical admin users may expect to find it I went for option 2 due to flexibility, and created a page within the admin for global development notices. This contains a repeater with: Field for message to display Checkbox list of all developments. The user can select which ones to apply each message to It's working really well but the only thing is that if the user goes to a specific development in the admin, the relevant messages aren't displayed in context (as they aren't edited on that page and instead on the global development notices page)... which may cause confusion when a new staff member / content admin tries to edit the text but there is no field when they go to the development admin page where they expect to see it... Solution??? I don't require the message(s) to also be editable on the development page, but I wondered if there was a nice way to show it/them somehow. I feel like I am missing something really simple as I'm sure ProcessWire will have a nice way of achieving this, or maybe there are field settings that allow this kind of thing to happen? Any ideas on approaches or similar experiences would be much appreciated, even if it is just a much simpler example with the content from one field being shown on another admin page to get the ball rolling. Thanks in advance for any advice :)
-
This module is inspired by and similar to the Template Stubs module. The author of that module has not been active in the PW community for several years now and parts of the code for that module didn't make sense to me, so I decided to create my own module. Auto Template Stubs has only been tested with PhpStorm because that is the IDE that I use. Auto Template Stubs Automatically creates stub files for templates when fields or fieldgroups are saved. Stub files are useful if you are using an IDE (e.g. PhpStorm) that provides code assistance - the stub files let the IDE know what fields exist in each template and what data type each field returns. Depending on your IDE's features you get benefits such as code completion for field names as you type, type inference, inspection, documentation, etc. Installation Install the Auto Template Stubs module. Configuration You can change the class name prefix setting in the module config if you like. It's good to use a class name prefix because it reduces the chance that the class name will clash with an existing class name. The directory path used to store the stub files is configurable. There is a checkbox to manually trigger the regeneration of all stub files if needed. Usage Add a line near the top of each of your template files to tell your IDE what stub class name to associate with the $page variable within the template file. For example, with the default class name prefix you would add the following line at the top of the home.php template file: /** @var tpl_home $page */ Now enjoy code completion, etc, in your IDE. Adding data types for non-core Fieldtype modules The module includes the data types returned by all the core Fieldtype modules. If you want to add data types returned by one or more non-core Fieldtype modules then you can hook the AutoTemplateStubs::getReturnTypes() method. For example, in /site/ready.php: // Add data types for some non-core Fieldtype modules $wire->addHookAfter('AutoTemplateStubs::getReturnTypes', function(HookEvent $event) { $extra_types = [ 'FieldtypeDecimal' => 'string', 'FieldtypeLeafletMapMarker' => 'LeafletMapMarker', 'FieldtypeRepeaterMatrix' => 'RepeaterMatrixPageArray', 'FieldtypeTable' => 'TableRows', ]; $event->return = $event->return + $extra_types; }); Credits Inspired by and much credit to the Template Stubs module by mindplay.dk. https://github.com/Toutouwai/AutoTemplateStubs https://modules.processwire.com/modules/auto-template-stubs/
- 38 replies
-
- 16
-
Hi community, thanks for the great work you do ? I´m looking for a global field which can be used in the footer and has only one instance for all pages. So I´m kind of looking for "One field to rule them all". Reason for my question: The website I´m currently building has one footer for all pages. The content of the footer should be dynamic - therefore I made a global field which is automatically inserted into each page. Problem: if I want to change something in the footer, I have to do it for all fields, because each field has it´s own instance. Question: is it possible to have one global field in which changes the content for the footer of all pages? In most CMS Systems a simple solution to this is often impossible, I hope that processwire is different ? All the best, Daniel
- 3 replies
-
- field
- global field
-
(and 1 more)
Tagged with:
-
Here is my first processwire module (beta). https://github.com/theo222/ImagePickerField A lot of "first times". First time Github, Markdown and of course PW Modules. So be gentle please. I hope it works.
- 29 replies
-
- 18
-
Hi, Everyone! I'm currently working on a page reference field and set it for multiple pages (AsmSelect) for the input. Is there a way for me to add an image field (aka Avatar) and the title of page in the radio button? I used the field name enclosed in the { }. Didn't work. It appeared a text instead. Thanks in advance and hope to hear from you soon!
-
Hey all, hope you're feeling well these days! Short question: Under "Setup > Templates" it's possible to sort the templates by last modified. Is this possible for fields view to? Long explanation: Currently I am in the process of programming a reusable template and often have to copy several fields & templates from different PW installations into my "master version". Therefore it would be good to see already in the field list when the last modification has taken place. Stay healthy & don't forget to wash you hands - many greets!
-
Hello dear PW gurus. I have stumbled over a strange error that i all of sudden got when trying to upload an image to a images field on a page. There where images allready stored in the field that i wanted to keep, but during the upload the error apear and after that all images are gone from the field and i can´t upload any, i just get the error every time. I am running ProcessWire 3.0.153 dev. Update: After looking in the assets folder i find the folder for the page and the image files seems to be there including the ones i tried to upload when the error occured. But they don´t show up in the images field in the page editor. The error reported: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'ratio' at row 1 And here is a screenshot of the event: The TracyDebugger Error reporting: I hope you fine folks could point me in a direction. But it seems our old pal set_time_limit() is back. Regards, EyeDentify
-
I am trying too create a custom field where when user select to create a category 2 text area shows where one title of the category goes & another for some content. Like in a picture I want 2 text areas when I click on create new
-
short story: think of a radio button mechanic in the background, but ui-wise you present images with captions as "buttons". for instance i whant to be able to let admins change some visual themes of a single page, with different background and formating for each, i could place screenshots thumbs with a short caption. so the admins are able to se a preview image and know better what this setting does. therefore it would be needed to define images for an input field, during the field creation. maybe someone likes the idea and is able to do it?
-
Hi, I'm using this kind of setup (https://processwire.com/blog/posts/language-access-control-and-more-special-permissions/#language-page-edit-permissions) in order to control the page edit permissions. Now I'm wondering if it's possible to hide the "none-ediable" language-tabs instead of striking them through. Many greets...
-
- permissions
- visibility
-
(and 1 more)
Tagged with:
-
Hi there, I have two templates that should talk to each other. One is for events which should access a list of artists (eventually add a new artist) and their images related to that event; the second is the artist page, which the user should be able to add or remove events that they participated, also mentioning which images are related to each event. Some sort of feedback loop between the two. I have tried searching around the community and google, but maybe I'm not formulating the question properly. Thank you all for the amazing work with Processwire and the community support. I have made a few websites with PCW yet I'm still quite between beginner and intermediate.
-
Hi guys. I need to create a field (link field) that allows me to select the internal pages to use as links. Do you have any suggestions? Thank you.
-
How to use numeric values on page reference field selector?
Hubris posted a topic in General Support
Hi there! I'm using some page reference fields to create lists of tags, categories, years, etc.. I'm able to find the pages like so: $pages->find("template=project, {$filter}={$page->title}"); Which dynamically does something like: $pages->find("template=project, tags=Experimental"); Only if the value (the page name, like "Experimental") starts with letters. If it starts with numbers, find returns nothing. Why is this and how can I fix it? -
Hi everyone, I am new to ProcessWire and have an question about the methods get field values. First of all my page setup: I have a page as a child of the Admin page which is named Data. The idea is to create all my data objects as children of this page. So the data page and all of its children should never be seen on the front-end. Every page uses the same template. The template has one field named playername of type Text. Now I am looping through all pages which are children of the Data page in this way (The page id is 1011): //get the data-page $datapage = $pages->get(1011); //get all children from data-page $players = $datapage->children(); //loop through the children foreach($players as $player) { $field = $player->fields->get("playername"); echo $player->title . " " . $field . "<br> "; } The problem now is, that I don't get the value of the field playername. Instead the output of $field is "playername". Why am I getting the field name instead of the fieldvalue. I am expecting to get the string, which is entered in the playername-field and not the name. Hope anybody can help me and big thanks in advance!