-
Posts
1,479 -
Joined
-
Last visited
-
Days Won
21
Everything posted by elabx
-
Add additional text input to existing options field.
elabx replied to elabx's topic in General Support
You understood correctly. Users will fill them as normal pages in the backend, this is a kind of private portal. I want to leverage ListerPro and it's export to CSV capabilities, basically this extra functionality is what discarded FormBuilder. It's around 50-60 fields per questionnaire, could scale to more. Doing the 50 extra fields felt like non-optimal solution, so instead of having extra 50 tables why not just an extra column in a custom Inputfield maybe, with a nice text input hidden and revealed with it's own javascript logic and i think it would be easier to add/remove question in case I want to change the questionnaire. But maybe I am overthinking it, since I am not very experienced into making Fieldtype/Inputfield modules. What I imagine is a combined Options field with just an extra input that can get toggled to be shown only if necessary. -
Hi everyone! I am working in an application for gathering information from customers. Basically it's a bunch of questions, each one a field and each new answered questionnaire is a page with template "questionnaire". 90% of the questions are yes/no (using SelectOptions field) and all must have an optional comments field. Since I don't want to add a comments field for every question I have, would it be possible to "mass add" this extra comments field through a hook? Or is making a new fieldtype/inputfield the way to go here? If the latter, would anyone point me to an existing example if there is one?
-
Just had this for breakfast! Brilliant work @bernhard ! Really shows the power of PW in a very pragmatic way.
-
I have some sites that have ssl certificates and I'm doing a redirect using the .htaccess file. I have noticed that processwire's httpUrl() fails to render the https:// schema in the Moda/Panel preview in the Page Edit screen and renders them as normal http, thus making them fail to load because of mixed origins. What I have noticed is that $config->https is always null on my site, and thus httpUrl() fails to set the schema as "https". I also tried setting the template to HTTPS only (to force true on $config->https, and as a result force the https schema on httpUrl()) but then I get into the trouble that all pages with that template get "too many redirects" error when trying to load them. Tried removing the htaccess redirect and leave the PW one with no success.
-
POST fields and database query columns seem to match, any other info you can give us? Getting any errors/exceptions? Check that the database connection succeeds Check that the POST info is going through, you can start by checking your browser Network tab to see what's going through the post.
-
I see on your AJAX calls you are trying to reach home.php, instead of "/", which I guess is the route you are trying to get too. You could try changing all urls that say home.php to "/" like: $.ajax({ url: '/', data: 'action=update&title='+event.title+'&start='+moment(event.start).format()+'&end='+moment(event.end).format()+'&id='+event.id, type: "POST", success: function(json) { //alert(json); } });
-
Search children but don't retrieve them (or exclude them)
elabx replied to elabx's topic in API & Templates
WOAHH children.field that's some awesome selector right there. $result = $pages->find("template=listing, (field1=data, field2=data), (pagefield.field1=data, pagefield.field2=data)"); -
Hi! I am working on a real estate site and I will create variations of each listing as child of each listing (with the exact same fields) and combine the information in the frontend. Question is, how I could leverage searching fields in the listing AND variations but, I wouldn't want to get Pages that are listing variations. How could I account for: Found "4 bathroom" option inside variation, but I only want to retrieve the parent which is the main listing posting page. What occurs to me is: $result = $pages->find(field1=data, field2=data, template=listing|listing_variation); $only_variations = $result->filter("template=listing_variation"); //import only parents, if already present, will not import foreach($only_variations as $variation){ $result->import($variation->parent); } //Remove the pages variations $final_results = $result->not("template=listing"); Think it will work? Would there be a more efficient way?
-
Page Reference Input fieldtype: Checkboxes - more advanced options
elabx replied to cst989's topic in Wishlist & Roadmap
Just to elaborate a bit more on @bernhard's suggestion, you could hook into the Inputfield::render method and draw some other stuff you need right there inside the inputfield (for the check all/none functionality). I think a good example is in HelperFieldLinks code. Here is also an example on how you could add also the necessary Javascript. @Robin S Pagination in Page Table would be awesome. -
Has anyone found a fix for this?
-
Could we get some more info on that nice looking search input you got there?
-
I learned with ProcessWire that the Internet could work just fine before single page applications I'd love some parts of PW to work as a SPA module, for example, a kind of template-field creator where you can create in a very agile way template-field relationships and the template context overrides. A kind of "template designer".
-
Great idea and execution!! I think this could turn into a very important piece of the PW ecosystem. Congrats!
-
Justin case someone looks for an answer, it is possible to dynamically set the selectable pages (instructions are in current PW page field options). And to dynamically change the parent of the "to be created pages" from the Create New textarea, it is possible to hook into InputfieldPage's method processInputAddPages, set "template_id" and "parent_id" configuration data on the fly with the information we have available such as the $page where the field instance is being called. If you take notice, later on the hooked method, this two options are read back to accomplish the page creation. $wire->addHookBefore('InputfieldPage::processInputAddPages', function($event) { $field = $event->object; $page = $field->hasPage; //Set the parent and template options, this are checked later to complete the task of adding pages $option_template = wire("templates")->get("template_name")->id; $parent_id = wire('pages')->get("name=options")->id; if($page->template == "some_template"){ //Example, change the parent depending on what template the field's currently in. $parent_id = $page->child('template=custom_options')->id; } $field->set("template_id", $option_template); $field->set("parent_id", $parent_id); });
-
Was about to ask about FiledtypeTable migrations but decided to try myself and it seems to work fine this way, dropping it here in case someone's in need: <?php class Migration_2017_10_23_12_24_20 extends FieldMigration { public static $description = "Add table field"; protected function getFieldName(){ return 'booking_advanced_fields'; } protected function getFieldType(){ return 'Table'; } protected function fieldSetup(Field $f){ $f->label = 'Booking Form Extra Fields'; $f->collapsed = Inputfield::collapsedNever; $this->insertIntoTemplate('home', $f, "booking_advanced", true); //Booking advanced is a checkbox in this case, hence the showIf setup to make the table appear if required $this->editInTemplateContext('home', $f, function(Field $f) { $f->set("showIf","booking_advanced=1"); }); $f->set("maxCols", 4); $f->set("col1name", "column1"); $f->set("maxCols", 4); $f->set("col1type", "text"); $f->set("col1sort", "1"); $f->set("col1label", "Column 1 Label"); $f->set("col1width", 50); $f->set("col1settings", "textformatters=TextformatterEntities\nplaceholder=\ndefault=\nmaxLength=2048" ); $f->set("col2name", "column2"); $f->set("col2type", "text"); $f->set("col2sort", "2"); $f->set("col2label", "Column 2 Label"); $f->set("col2width", 50); $f->set("col2settings", "textformatters=TextformatterEntities\nplaceholder=\ndefault=\nmaxLength=2048" ); $f->save(); $table_module = wire("modules")->get("FieldtypeTable"); $table_module->_checkSchema($f, true); } }
-
Didn't know this tool, seems much more equipped than Server Pilot, am I being fare in this comparison?
-
It's really amazing how much work can be done adding Hooks where needed and you can turn Process modules and Inputfields into powerful interfaces just understanding a bit of the source code, I now don't want to write app interfaces/data models anymore, just think how I can leverage ProcessWire to do anything I want, in a third of the time. Hope everyone keeps sharing their awesome work!
-
Admin search results link to view page instead of edit page.
elabx replied to elabx's topic in General Support
Works great! Just added: $match["template"] == "admin" Because I didn't want normal "content" pages being modified. Thanks a lot for the help! -
Is this a ProcessWire friday happiness guest blog post request I'm reading?! 'cause it would be awesome.
-
Admin search results link to view page instead of edit page.
elabx posted a topic in General Support
Hi people! Is there a way to hook into the way the results of the admin search results are rendered? I'd love to make the links to the pages in the list go to the "view" page instead of the "edit" page specially in modules rendering a Process module. For example, look for the Fields page, and it will link you to edit the Field page. I've looked into the ProcessPageSearch module but can't find any javascript that renders the actual list, any clue? Thanks for further help! -
I have used Repeater Matrix for this purpose, to create a type of page builder, each repeater type being a possible section, though you still have to have a predefined set of repeater types, most of this types have a checkbox or two for customization of behaviour (even repeaters inside, works wonderful)
-
I can't contain my happiness, thanks for this awesome update.
-
Download all files as ZIP from inputfield file?
elabx replied to dragan's topic in Wishlist & Roadmap
Have done this for image fields, it adds a button to the end of the inputfield, code below. Checks for ZipArchive class before installing. Now that I read the code it should work for files but haven't tested! It's got configuration options too, to enable per field basis, either way should it should be super quick to edit if something is not working. <?php class ExportFieldImages extends WireData implements Module, ConfigurableModule { static public function getDefaultConfig() { return array( "includeFields" => '' ); } public static function install(){ $session = wire("session"); if(!class_exists('\ZipArchive')){ throw new WireException("ZipArchive is required to create the zip file"); } } public static function getModuleInfo() { return array( 'title' => 'ExportFieldImages', 'version' => 0.1, 'summary' => "Adds a button bellow images field to download a zip containing files.", 'author' => 'Eduardo San Miguel Garcia', 'singular' => true, 'href' => '', 'autoload' => true ); } public function init() { $this->addHookAfter('InputfieldImage::render', $this, 'afterInputfieldImageRender'); $this->addHookAfter("ProcessPageEdit::execute", $this, "pageEditExecuteBefore"); } public function pageEditExecuteBefore(HookEvent $event){ $session = wire("session"); $input = wire("input"); $page = wire('pages')->get($input->get->id); $name = $page->name; $zip = $config->paths->cache . "${$name}.zip"; if($input->get->downloadImages == "true"){ wire("log")->save("custom", "excecuted page edit!"); $array = wire('files')->zip($zip, $page->get($input->get->field)->explode("filename"), array("overwrite" => true) ); if(!empty($array["errors"])){ foreach($array["errors"] as $error){ $this->error($error); } return; } else{ header('Content-Type: application/zip'); header("Content-Disposition: attachment; filename='{$name}.zip'"); echo readfile($zip); return $this->halt(); } } } public function afterInputfieldImageRender(HookEvent $event){ $field = $event->object; $input = wire("input"); $configData = wire('modules')->getModuleConfigData($this); $out = $event->return; if(in_array( $field->name, $configData['includeFields'])){ $button = wire('modules')->get('InputfieldButton'); $button->class = $button->class . " ExportFieldImages"; $button->icon = 'download'; $button->href = "./?downloadImages=true&field={$field->name}&id={$input->get->id}"; $button->value = "Download Files"; $btn .= "<span style='display:block; position:relative; float:right;' class='InputfieldPageTableButtons'>" . $button->render() . "</span>"; $out .= $btn; } $event->return = $out; } public function getModuleConfigInputfields(array $data){ $modules = wire("modules"); $fields = wire('fields'); $defaults = self::getDefaultConfig(); $data = array_merge($defaults, $data); $form = new InputfieldWrapper(); $field = $modules->get("InputfieldAsmSelect"); $field->name = "includeFields"; $field->label = __("Fields to enable download button"); $field->description = __("Choose the image fields where download button should appear"); foreach($fields as $f){ if($f->flags & Field::flagSystem) continue; if($f->type == "FieldtypeImage" || $f->type == "FieldtypeFile"){ $field->addOption($f->name); } } $field->value = $data['includeFields']; $form->add($field); return $form; } }- 4 replies
-
- 4
-
-
- files
- inputfield file
-
(and 2 more)
Tagged with:
-
How to add repeater items to repeater inside repeater matrix
elabx replied to Raymond Geerts's topic in API & Templates
@adrian Got this almost settled, do you have any information on how to save the fieldgroup conext settings for the repeater matrix field?? I see that they are saved through namespaces but I just can't seem to find a way to save them, this is what I am trying: EDIT: Found out, edited code below: $matrix_field_name = "content"; $matrix_type_namespace = "matrix12"; //Field inside repeater you want to edit it's property. $matrix_repeater_field_name = "feature_card_items"; $matrix_template = wire('templates')->get("repeater_$matrix_field_name"); $fieldId = wire("fields")->get("feature_card_items")->id; $matrix_fieldgroup = $matrix_template->fieldgroup; //Get the config data from the fieldgroup and the namespace which determines the field's settings based on the matrix repeater type. $matrix_field_data = $matrix_fieldgroup->getFieldContextArray($fieldId, $matrix_type_namespace); //Copy the data to edit it $matrix_field_data_new = $matrix_field_data; $matrix_field_data_new["description"] = "Bla bla bla"; //Reassign the data to the fieldgroup $matrix_fieldgroup->setFieldContextArray($fieldId, $matrix_field_data_new, $matrix_type_namespace); //Save fieldgroup context data, only unknwon wire("fields")->saveFieldGroupContext($matrix_fieldgroup->getField("feature_card_items", true), $matrix_fieldgroup);