Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. In Soma's tutorial he covers the $options array - does setting 'forceDownload' to false achieve what you want?
  2. I think your time would have been better spent persisting with FieldtypeRate, which seems to be exactly what you are looking for. I installed it to test it and it works straight out of the box, so not sure how you have been going wrong. Just echo the field as per the documentation: echo $page->my_rating_field; // of course change this to the name of your ratings field There is a small error in the module code that will generate a PHP notice but it is an easy fix - delete line 66 as it looks like it is an accidental leftover from the FieldtypePoll that the module is based on.
  3. I think the error is down to the Windows directory separator thing that reared its head a while ago. If I json_encode and log $segments I see results like this: Not sure why there would be double slashes there instead of single slashes. If I change line 110 to be... $segments = explode(DIRECTORY_SEPARATOR, $path); ...then the panel error is fixed, although I notice that the 'wire' segment still looks a bit funky: Maybe there are other places where a hardcoded forward slash should be replaced with the DIRECTORY_SEPARATOR constant? I don't mean to get OT here, but I'm curious how you like to handle front-end forms if you don't use Form Builder. Do you use the forms API, or a third-party forms library like Nette Forms, or some other approach?
  4. Thanks for implementing this so quickly. The template restriction works if I select a template such as "home" or "basic-page", but it doesn't work for the "form-builder" template for some reason. The debug bar still appears on the Form Builder page when it is loaded in an iframe and when the page is loaded directly. I'm also seeing an error in the Captain Hook panel which may or may not be related: ErrorException: Undefined offset: 2 in D:\Websites\__www\1testing\site\assets\cache\FileCompiler\site\modules\TracyDebugger\panels\CaptainHookPanel.php:111 Stack trace: #0 D:\Websites\__www\1testing\site\assets\cache\FileCompiler\site\modules\TracyDebugger\panels\CaptainHookPanel.php(111): Tracy\Bar->Tracy\{closure}(8, 'Undefined offse...', 'D:\\Websites\\__w...', 111, Array) #1 D:\Websites\__www\1testing\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-master\src\Tracy\Bar.php(153): CaptainHookPanel->getPanel() #2 D:\Websites\__www\1testing\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-master\src\Tracy\Bar.php(108): Tracy\Bar->renderPanels() #3 D:\Websites\__www\1testing\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-master\src\Tracy\Debugger.php(266): Tracy\Bar->render() #4 [internal function]: Tracy\Debugger::shutdownHandler() #5 {main}
  5. Hi @adrian, Is there a way to tell the debug bar not to appear on pages with a particular template? The situation is that I'd like to be able to turn off the debug bar for the Form Builder template that is used when the form is rendered inside an iframe. I know there is an option to disable the debug bar in modals, but not for iframes I think? And it's often useful to have the debug bar in iframes so it would be great to be able to target templates rather than all iframes. Any thoughts on this?
  6. This is true. It starts to get a little more complex but with a few more steps you can filter out the non-public pages: $field = $fields->get('my_options_field'); $table = $field->getTable(); $query = $database->query("SELECT data, pages_id FROM $table"); $results = $query->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP); // get multidimensional array of results $results_page_ids = array_unique(call_user_func_array('array_merge', $results)); // get all the unique page IDs in the results $public_ids = $pages->find(['id' => $results_page_ids])->explode('id'); // find out which ones are public $filtered_results = []; foreach($results as $option_id => $page_ids) { // remove any page IDs that are not public $filtered_value = array_filter($page_ids, function($value) use ($public_ids) { return in_array($value, $public_ids); }); // for each option, count the public pages it is selected on if($filtered_value) $filtered_results[$option_id] = count($filtered_value); } arsort($filtered_results); // sort highest to lowest $all_options = $field->type->getOptions($field); echo '<ul>'; foreach($filtered_results as $option_id => $count) { $option = $all_options->get($option_id); echo "<li>{$option->title} ({$count})</li>"; } echo '</ul>';
  7. v0.0.4 released. Adds config option to remove clone button.
  8. The thing about this approach where you foreach the selectable options (for an Options or a Page field) is that if you have 196 countries (for example) then that is 196 database queries. Not the end of the world or anything but also not very efficient. I like this code from Ryan that requires only a single DB query, and which can be adapted for an Options fieldtype: $field = $fields->get('my_options_field'); $table = $field->getTable(); $query = $database->query("SELECT data FROM $table"); $ids = $query->fetchAll(PDO::FETCH_COLUMN); $count_values = array_count_values($ids); // count the frequency of values in the array arsort($count_values); // sort highest to lowest // use the option IDs and counts as needed, for example: $all_options = $field->type->getOptions($field); echo '<ul>'; foreach($count_values as $option_id => $count) { $option = $all_options->get($option_id); echo "<li>{$option->title} ({$count})</li>"; } echo '</ul>';
  9. Quite the contrary - the lister can handle virtually any number of users with ease. Click column headers to sort, add new columns on the "Columns" tab.
  10. The idea is not to need a Hanna tag - just let your editors insert images into the CKEditor field and then do any manipulation of the images (whatever it is you are currently doing in your Hanna tag) in your textformatter module. Not sure exactly what you are doing in your tag but the Image Interceptor module is pretty comprehensive so there's a good chance it already covers what you need. Or you can build your own simple textformatter to parse images from the HTML and manipulate the markup as needed.
  11. Hi and welcome @Cole. Could you please provide some more information... Is the 403 error occurring in your local environment or online? Are those rewrite rules the source of the error - that is, does the error disappear if you remove those lines from htaccess? Does the error occur when you access the website via all three of the below? dev.example.com www.example.com example.com And I take it that you are routing dev.example.com to 127.0.0.1 by editing whatever the MacOS equivalent is to the Windows 'hosts' file and have configured that domain as an Apache virtual host in your local environment?
  12. You can get the array of entries and then do a usort(): $entries = $forms->get('reserveren')->entries()->find(''); // sort entries newest to oldest by field 'datum' usort($entries, function($a, $b) { return $b['datum'] - $a['datum']; }); // OR, sort entries oldest to newest by field 'datum' usort($entries, function($a, $b) { return $a['datum'] - $b['datum']; }); // do what you want with $entries array
  13. For manipulating images embedded in a CKEditor field I use a textformatter, following the same general principles as this module: http://modules.processwire.com/modules/textformatter-image-interceptor/
  14. Moving a page via the admin interface so it is placed under a user page works okay for me. But regarding the idea of placing pages under a user page, this post sounds like sensible advice:
  15. I think you could say it is expected, as these are completely separate methods. The method $page->url() takes an options argument - when you pass 'true' as an argument you are actually setting the 'http' option: $page->url(['http' => true]); The method Pageimage::url() takes no options so passing 'true' or any other argument isn't going to modify the way the method works.
  16. Interesting, but quite a long way to go... Supports PHP (or anything but Python): No Supports Windows or Linux: No Supports JetBrains IDEs: No
  17. The Pager includes prev and next links with identifying classes in the markup when there is a prev and next page to the results. Use CSS to position those links where you want them to be. .MarkupPagerNavPrevious { } .MarkupPagerNavNext { }
  18. It is normal to be logged out after the browser session is closed. You can use the LoginPersist module if you want to stay logged in across sessions.
  19. I think renderReady() is the right place to load any JS dependencies.
  20. Not sure I understand, but you can just enter the options into the field config exactly like that and then there is no need for a hook.
  21. In a single-language site the description is just a plain string, so a user would want to modify the hook accordingly. I like this new feature allowing the select option label to be determined in a hook, but I wonder if choosing a single column in the field config makes the hookable method too limited. For example, in the case of using the description column as a label for an images select, having the label fall back to the sort integer if an image has no description is worse than having the image filename. Is there a way to conditionally grab a different column value from the row inside the label hook? So you could for example get the "data" (filename) column if the description column is empty. Not sure if it's practical but I think it would be cool if there was a hookable method that receives an argument of all the row columns as an array lets you return both the option value and label.
  22. @kixe, when I try this (or use a hook to dynamically select a pages_id) there is always an option preselected in the inputfield. My SelectExternalOption field is not set to 'required'. Is it possible to have the first option in the inputfield blank (no selection)?
  23. If Language Support is installed but no additional languages created then there is a PHP error: PHP Warning: Division by zero in ...\FieldtypeSelectExtOption.module:504 Probably not something that happens very often.
  24. Not only "the processwire way", but also the way that is demonstrated in the documentation: foreach($page->test_matrix as $item) { if($item->type == 'blockquote') { echo " <blockquote> <p>$item->quote</p> <cite>$item->quote_cite</cite> </blockquote> "; } else if($item->type == 'bodycopy') { echo " <h2>$item->title</h2> $item->body "; } else if($item->type == 'gallery') { // and so on... } }
×
×
  • Create New...