-
Posts
806 -
Joined
-
Last visited
-
Days Won
10
Everything posted by kixe
-
? Yet another runtime field. I can also provide one: slim and full PW-API provided. In addition, you can change everything in another field (Database) via hook into ProcessInput. https://github.com/kixe/FieldtypeMarkup
-
// example 1: modify page title (runtime) for a specific template in Page Edit Interface $this->addHookBefore('ProcessPageEdit::execute', function($e) { $id = wire('input')->get->id; if (!$id) return; $page = wire('pages')->get($id); if ($page->template != 'specific') return; $page->title = "I am a runtime title for pages using template 'specific'"; }); // example 2: modify fields in Profile $this->addHookBefore('ProcessProfile::execute', function($e) { // not for superuser if (wire('user')->isSuperuser()) return; // the user should check 2 checkboxes in its profile // after checking and saving the related checkbox disappears // if both are checked a markup field 'info' is shown $profileFields = $e->object->profileFields; if (wire('user')->checkbox && wire('user')->checkbox_2) $profileFields[] = 'info'; else { if (wire('user')->checkbox != 1) $profileFields[] = 'checkbox'; if (wire('user')->checkbox_2 != 1) $profileFields[] = 'checkbox_2'; } // update profile fields $e->object->profileFields = array_unique($profileFields); });
-
Page selector referencing template of pages in a page field
kixe replied to snck's topic in API & Templates
Please check status and/ or permission $events = $pages->find("template=event, related_pages.template.name=exhibition,include=all,check_access=0"); include=hidden include=unpublished include=all Check if your template is accessible via API if it is not viewable for the current user! -
[SOLVED] i cannot output anything from repeat field
kixe replied to picarica's topic in Getting Started
foreach ($page->produkt_repeat_field as $building) { $image = $building->r_galeria_image->first(); $thumbnail = $image->size(450, 250); echo "<article>"; echo "<a href='{$image->url}' class='fresco' data-fresco-caption='{$image->description}' data-fresco-group-options='preload: [1,2], effects: {spinner: {show:150, hide:150 } }' data-fresco-group='kolace'><img src='$thumbnail->url' alt='obrazok'></a>"; echo "</article>"; } -
Programatically setting selected=selected for Multi Select field
kixe replied to cosmicsafari's topic in General Support
It's not possible to set the following attributes via setOptionAttributes() function: value, checked, selected. https://github.com/processwire/processwire/blob/51629cdd5f381d3881133baf83e1bd2d9306f867/wire/modules/Inputfield/InputfieldSelect.module#L612 If you want to dynamically change a page field value: $page->selectfield = array(1030,1031);- 3 replies
-
- 2
-
- multiselect
- selected
-
(and 1 more)
Tagged with:
-
@bernhard https://all-inkl.com/ https://kasapi.kasserver.com/dokumentation/ I wrote a PHP class (SOAP API client wrapper) which is used by the ProcessWire module KasProcessEmail to connect with the API.
-
I recommend to sanitize the input $moduleFilter = $sanitizer->pageName($input->get('f'));
-
// find pages and sort $pages->find('sort=firstsortfield,sort=secondsortfield'); // Sort WireArray from newest to oldest $items->sort("-created"); // Sort WireArray by last_name then first_name $items->sort("last_name, first_name"); https://processwire.com/api/ref/wire-array/sort/
-
It's not the same situation, but maybe interesting in this context. I work for a professional association with around 2000 members. Until recently the association had rented a root server to host web content, member management and email accounts for the members. Now we have switched to shared hosting including all the e-mail accounts. The members now can independently activate and deactivate their e-mail accounts via a ProcessWire interface (API to hoster) and further administrate via the webmailer provided by the hoster. The member management was transferred to an external cloud based service. Result: lower costs. less work (administration and support). Outsourcing responsibility for security and administration. The members are satisfied.
-
// for editing $this->addHookBefore('ProcessPageEdit::execute', function($e) { /* ... */ }); // if page template = user $this->addHookBefore('ProcessProfile::execute', function($e) { /* ... */ });
-
tutorial Set ready-dev.php in addition to config-dev.php for local environment
kixe replied to Ivan Gretsky's topic in Tutorials
I am not a guru, but: When you access $object->property, a magic __get() method is called that returns a copy of the value of this property. If the value is an array and you try to add an item, only the copy is affected, not the original property value. For this reason, an error message is displayed that your attempt to change the value has no effect. The magic __set() method must be used to change the (whole) value of the property. Both ways (yours and @horst 's) are fine to set the value. -
As far I can see you handle only the array version of the get parameter 'level', but not the pipe separated version. I didn't tried it out, please check: if($input->get->level) { if (is_array($input->get->level)) { // Level is an array. Code adapted from Ryan's snippet here: // https://processwire.com/talk/topic/3472-enable-pagination-for-search-results/?tab=comments#comment-38042 $level = array(); foreach($input->get->level as $id) $level[] = (int) $id; // sanitize to INTs $level = implode('|', $level); // convert to 123|456|789 string, ready for selector } else $level = "$input->get->level"; } else { $level = ''; } @flydev ?? ... one second quicker ?
- 3 replies
-
- 2
-
- pagination
- checkboxes
-
(and 1 more)
Tagged with:
-
@ttttim I have added new Fieldtype Select Color Options to FieldtypeColor package. Read more here: Furthermore, as @elabx already mentioned, if you use Spectrum Color Picker as Inputfield in FieldtypeColor it is also possible to configure it to a select with predefined options: https://bgrins.github.io/spectrum/#options-togglePaletteOnly
-
I have added Fieldtype Select Color Options to the package. Read more here:
-
@Hurme This looks like you have choosen the wrong input type: For your needs please use SpectrumColorPicker as Input and add the following code showAlpha: true, showInput: true in the color picker options field. This setup will provide something like:
-
I have added a new field type to the FieldtypeColor package. It is still in beta, but is already working quite well. The module is an extension of the Core FieldtypeOptions module and offers colors as predefined selectable options via 4 different input field types (Select, SelectMultiple, Checkboxes and Radios). Please try it out and if you like it, recommend it in the modules directory ? 2 Screenshots
-
You need to enclose the api vars with curly brackets if there is more than one arrow in it. echo "<img src='$front_img_800->url'>"; // good echo "<h2>$item->front_productpage->title</h2>"; // bad echo "<h2>{$item->front_productpage->title}</h2>"; // good Read more: https://processwire.com/talk/topic/4439-when-do-we-need-curly-brackets/ https://www.php.net/manual/de/language.types.string.php#language.types.string.parsing.complex
-
... indeed ... For some other page reference inputfields like radio buttons or checkboxes the following hook example could be a first approach. I use it for a field to select a system user. Each label is preceded by a user icon. It should work for checkboxes as well. You need to hook in InputfieldCheckboxes then. $this->addHookBefore('InputfieldRadios::render', function($e) { $input = $e->object; // quick exit if ($input->name != 'clients') return; $options = $input->getOptions(); // $key = page ID foreach ($options as $key => &$label) $label = "<i class='fa fa-user'></i> $label"; $input->setOptions($options); }); $this->addHookAfter('InputfieldRadios::render', function($e) { // quick exit if ($e->object->name != 'clients') return; $e->return = wire('sanitizer')->unentities($e->return); });
-
$product->of(false); $product->title = $productTitle; $product->save(); in short: $product->setAndSave('title',$productTitle);
-
Steps to solve this: create .js file which sends your sort criteria via form and receives the updated page list. Reload page or update content (ajax) get the input (sort criteria) via PW API: $input->post sanitize your input select pages from DB $pages->find('template=xy, parent=xy,sort=criteria1,sort=criteria2, ... and so on); render updated list.
- 1 reply
-
- 1
-
This problem is still not solved. Strange results: // check if field is empty (NULL) $p = $pages->get("datetime="); // SQL Error $p = $pages->get("datetime=''"); // SQL Error $p = $pages->get("datetime=0000-00-00 00:00:00"); // SQL Error $p = $pages->get("datetime=0"); // expected result, will find a page with datetime = 1970-01-01 00:00:00 $p = $pages->get("datetime=null"); // will find a page with datetime = 1970-01-01 00:00:00 why? var_dump($p->getUnformatted('datetime')); // if a page exists result -3600 due to the locale I need to check if the field is not set via selector. Any ideas? Currently I exlude this from the selector and loop the results (bad solution) https://github.com/processwire/processwire-issues/issues/973#issuecomment-625678587
-
With FieldtypeColor https://modules.processwire.com/modules/fieldtype-color/ you have multiple options for the Inputfield: Text, HTML5 Color, any Javascript ... If you are able to create a custom SQL table for your colors FieldtypeSelectExtOption https://modules.processwire.com/modules/fieldtype-select-ext-option/ is a possible solution for your needs, since you can use the hex code as the value here.
-
If the target page (new parent) doesn't have already children you need to mark (click) it before moving the other page.
-
I use this 5 lines of code, placed in an access controlled folder under root, to run a cronjob at fixed time. Just set 'cycle' in module settings to 'none' to prevent database backups triggered by LazyCron as well. <?php namespace ProcessWire; $root = dirname(__DIR__); include_once("$root/index.php"); $cdb = $modules->CronjobDatabaseBackup; $cdb->cronBackup(); Thanks for the input. I thought about it. In the end, I'll leave it as it is, and the inclusion of manually created dumps in the cleaning routine remains the standard. When I manually create a dump, I usually move or download it immediately. I rarely (never?) leave it on the live server and I want the files removed automatically. The default name created by ProcessDatabaseBackups is the database name. Just use this as the 'stopword' and use a different name format in the setup of CronjobDatabaseBackup and voila it works exactly as you want it. Furthermore there is also the option to save the files in a user-defined directory. Manually created dumps are then never affected by the CDB's cleaning routine.