-
Posts
1,559 -
Joined
-
Last visited
-
Days Won
49
Everything posted by gebeer
-
Select from a list of existing pieces of content
gebeer replied to Jim Bailie's topic in Getting Started
@Gideon So you posted just seconds before me ? -
Select from a list of existing pieces of content
gebeer replied to Jim Bailie's topic in Getting Started
For the select dropdown you can use a Page Reference field (e.g. named "content_pieces") with Input field type AsmSelect. This will give you a sortable list of pages: As for grouping the pages that hold the pieces of content, you have multiple different options to go about. Here just 2 examples: put them under one parent: in content_pieces field settings, under setting "Selectable pages" choose that parent give all pages a checkbox field, named e.g. "content_piece", under setting "Selectable pages" choose "Selector string" and enter (without quotes) "content_piece=1" Now in your template PHP you can loop through and output the desired content. Assuming content is in field named "content": foreach ($page->content_pieces as $p) echo $p->content; -
Don't think this is DB related then. Umlauts in sanitized selector value are not breaking the selector in my case $val = $sanitizer->selectorValue("äöü"); db($pages->find("title=$val")); // results in: // ProcessWire\PageArray // count: 0 // items: array (0) // selectors: 'title="äöü"'
-
You can set the collation per database. See here: https://dev.mysql.com/doc/refman/8.0/en/charset-database.html You can run this query for a database to see current charset and collation: USE db_name; SELECT @@character_set_database, @@collation_database; You can run this query for a database to change charset and collation: ALTER DATABASE db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
-
Then it should have utf8mb4 charset. Is it in the list of charsets when you run the query "SHOW CHARACTER SET;" like described above?
-
To see the MySQL version, run this query: "SHOW VARIABLES LIKE 'version';"
-
In phpMyAdmin click on the Home icon. Now click on the tab "SQL" and insert "SHOW CHARACTER SET;" into the query editor. Now click GO in the bottom right. This should give you a list of available charsets like
-
I am assuming the template for those users is named 'member'. What is the setting in template member "URLs" tab, particularly the "Should page URLs end with a slash?" setting. If this is set to Yes (default), you need to append a trailing slash to the redirect URL, e.g. mydomain.com/medlemmar/username/ to avoid unnecessary redirects. if ($sanitizer->pageName($userloggedinname) !== $pagename) { $session->redirect($pages->get('/')->url . "medlemmar/{$userloggedinname}/"); }
-
What is your MySQL version? utf8mb4 support started with version 5.5. This query will list all available charsets: SHOW CHARACTER SET;
-
Without seeing the code for your redirection there is not much to suggest.
-
@kongondoIn my install (PW 3.0.200), Media Manager pages for images and documents get saved under Admin->Media Manager->Media Manager:Audio instead of Media Manager:Image and Media Manager:Document. They have the correct template media-manager-image and media-manager-document, but are under the wrong parent. What could be the reason?
-
@kongondo Media Manager fields always return a MediaManagerArray, even if Maximum Media Allowed is set to 1. This is not bad at all but it would be great if the logic would follow PageFiles or Page Reference field conventions. There we can choose whether to return an Array or a single object. So for Media Manager fields it would be nice to have that option, too. Or a default behaviour where fields with max allowed 1 return a single MediaManager object because returning an array doesn't really make sense in that context.
-
Try clearing the cache table in the DB. Just a guess but won't do any harm and maybe it helps.
-
Thanks for sharing this. Looking at the implementation of parentPrevious inside wire/core/Page.php I thnk your solution is perfectly viable and the parentPrevious property was implemented so we can use it in circumstances like these. At which point in your logic are you using the bypassSaveHook session variable to prevent loops, is it inside a different hook to Pages::save? And since you are inside a Pages::saveReady hook, I think you do not need to set $page->of(false) because output formatting is already turned off at that stage. Also you do not need to do $page->save() because this is happening after the hook was executed and the page is saved with the values that you assigned inside the saveReady hook. So the loop most likely is being caused by the redundant $page->save(). Try removing that line and see if you need the bypassSaveHook session variable at all.
-
When you tested in the fresh PW install, did you also copy all the code in site/templates, site/ready.php, site/init.php from the affected install to the fresh install? Or in other words, can you rule out with certainty that template or hook code might be responsible, especially hooks? I once stumbled over a similar or at least related problem, where all PW queries in the page tree, that are done via ajax returned an error and pages tree stopped working. Then I discovered that an addHookBefore('ProcessHome::execute', $this, 'rootPage') was responsible. In my hook function 'rootPage', I had to do an if($this->config->ajax) return; This is just what came to my mind when reading about your problem. Did you follow the "Optimize" link and which table is this warning referring to? How many entries are there in the DB table "pages"? I can totally understand your frustration and think we all have been there at some point. But, at least for me, all those situations were resolvable in the end. Even if we cannot charge our clients for the effort we put in resolving those issues, these situations can help us to learn and get better at what we are doing.
-
Why did you create a new user account to ask the same question like again? This could be considered spam. You should better ask follow up questions in your first thread. Did you read @millipedia's answer? It pretty much explains how you would go about. For rendering your "pagination" links you can use something like this simplified sample code: foreach ($mygallery as $gallery) { echo "<a href='{$mygallery->url}{$gallery->title}'>{$gallery->title}</a>"; }
-
@horstwould be awesome if you could add a doc block to https://github.com/horst-n/WireMailSmtp/blob/bc2432096704b3ffeab8176d558e211a544f9837/WireMailSmtp.module#L808 so we get some intellisense of what the array actually looks like.
-
Taken from getResult () - returns a dump (array) with all recipients (to, cc, bcc) and settings you have selected with the message, the message subject and body, and lists of successfull addresses and failed addresses, So you can check with the 'recipientsFailed' entry of the array if anything went wrong. $result = $mail->getResult(); if(count($result['recipientsSuccess']) { // logic for successful mails } if(count($result['recipientsFailed']) { // logic for failed mails } Or you can use return value of ->send() which returns the count of successfully sent mails or 0 on fail: $numberSentMails = $mail->send(); Log these numbers somewhere and add some logic to your send script that counts how many mails have been sent on the current day, adds them to a mail queue or whatever you need.
-
Multiple problems with your code. in the last code sample you used InputfieldSelect. Now you are using InputfieldText. The latter will give you a text input and has no method setOptions() you set the options before you define $location $fields->location->$label needs to read $fields->location->label Here is working sample code for a form with location select as only field: // define form /** @var InputfieldForm $form */ $form = $modules->get('InputfieldForm'); // define location first before you can use setOptions() /** @var InputfieldSelect $location */ // you need to use InputfieldSelect here, InputfieldText has no setOptions() method $location = $modules->get('InputfieldSelect'); $location->attr('id+name', 'location'); $location->label = $this->_($fields->location->label); $location->required = 1; $location->attr('required', 'required'); // build options array $optionsArray = $pages->findRaw('template=location', 'title'); // set options to the select field $location->setOptions($optionsArray); // add field to your form $form->add($location); echo $form->render(); // will print out the markup for the whole form I left out the whole fhSanitzer stuff and the hook. Let's go step by step and first make the inputfield work. You need to adjust this to the rest of your code. If you want to have a standalone field, not inside a form you would do something like this: $location = $modules->get('InputfieldSelect'); $location->attr('id+name', 'location'); $location->label = $this->_($fields->location->label); $location->required = 1; $location->attr('required', 'required'); // build options array $optionsArray = $pages->findRaw('template=location', 'title'); // set options to the select field $location->setOptions($optionsArray); // print markup echo $location->render(); This will give you markup like: <select id="location" class="required" name="location" required="required"> <option value=""> </option> <option value="1001">Location 1</option> <option value="1002">Location 2</option> <option value="1004">Location 3</option> </select>
-
FieldTypeOptions gives you different UI and stores data in a different way. If you just need a checkbox, I'd go with InputfieldCheckbox. Less overhead.
-
You would use $county->setOptions($optionsArray) to populate the select options. Example: /** @var array $optionsArray */ $optionsArray = $pages->findRaw('template=basic-page', 'title'); // returns an array with page ids as keys and page titles as value $county->setOptions($optionsArray); // each option will have value="{pageID}" and label page title You need to adjust the selector to your needs.
-
Yes it can, but not via the field settings in the GUI. You can put this hook code in site/templates/admin.php above the require($config->paths->core . "admin.php"); line: // sets field checkbox to checked on new pages with template basic-page $wire->addHookAfter('Pages::saveReady', function (HookEvent $event) { /** @var Page $page */ $page = $event->arguments(0); if ($page->isNew() && $page->template->name == 'basic-page') { $page->checkbox = 1; } }); You just need to adjust template and field name. Everytime a new page with that template is created the checkbox will be checked by default. If you have TracyDebugger installed, you can do this with a one-liner in the Tracy console in the backend: $pages->find('template=basic-page, include=all')->each(function($p) { $p->setAndSave('checkbox', 1); });
-
@Heinzregarding communication via http-requests with the PW backend for retrieving, storing, patching etc with a Rest-ful approach you could use this module: https://processwire.com/modules/app-api/ For building custom frontend forms there is an excellent thread: It is a long thread but a nice read for bored people ?
-
I personally can live with this behaviour but still would consider it a bug since it is unexpected. Inputfields should open/close independently whether they are in the same row or not.