-
Posts
5,009 -
Joined
-
Days Won
333
Everything posted by Robin S
-
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>';
- 12 replies
-
- 1
-
-
- field type options
- options
-
(and 1 more)
Tagged with:
-
Can ProcessWire do this? (User Management, Profiles, Search)
Robin S replied to Kai's topic in Getting Started
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.- 23 replies
-
- search
- user-management
-
(and 1 more)
Tagged with:
-
CKEditor Shortcode/HannaCode instead of <img>
Robin S replied to Andreas Augustin's topic in General Support
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. -
Ryan said as much in the blog post:
-
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?
-
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
-
CKEditor Shortcode/HannaCode instead of <img>
Robin S replied to Andreas Augustin's topic in General Support
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/ -
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:
-
$page->url(true) and $page->image_field->url(true)
Robin S replied to Zeka's topic in API & Templates
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. -
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 { }
- 7 replies
-
- 1
-
-
- styling
- pagination
-
(and 3 more)
Tagged with:
-
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.
-
I think renderReady() is the right place to load any JS dependencies.
-
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.
-
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.
-
@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)?
-
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.
-
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... } }
-
Yes! I had forgotten about your thread there. That is still a work in progress and not released yet, right, or did I miss it? I think AOS and Tracy are the main modules where I find myself wanting a quick way to sync settings, but would definitely be cool to have that available for any module.
-
Okay, thanks for the info. It would be neat if there was a feature allowing to export/import (copy/paste) the settings JSON without needing to uninstall/reinstall. As new AOS features are rolled out quite regularly (which is awesome) I often want to synchronise my new settings across many sites.
-
I have tracked the issue down to the "Tooltips" submodule - when this submodule is disabled the Configure anchor links scroll to the wrong place (in the default Admin theme anyway). BTW, have been meaning to ask this for a while: is it possible to use the "Restore settings on next install" feature to copy AOS settings from one site to another? Or some other way to quickly replicate AOS settings on another site?
-
This syntax works fine for me with plain Repeater fields, so it should work for Repeater Matrix fields too: $results = $pages->find("my_repeater.my_nested_repeater.my_textarea%=foo"); So maybe typos are slipping in somewhere else... Testing this did expose a bug where pages are matched when the repeater fields are empty - will file this at GitHub shortly. Done: https://github.com/processwire/processwire-issues/issues/205 There is another way you could do this, but I think the selector with subfields is more elegant... // returns the root container page for any repeater item no matter how deeply nested function getRootContainer($page) { if($page instanceof RepeaterPage) { return getRootContainer($page->getForPage()); } else { return $page; } } $results = new PageArray(); $repeater_pages = $pages->find("my_textarea%=foo, has_parent=2, include=all"); foreach($repeater_pages as $repeater_page) { $results->add(getRootContainer($repeater_page)); }
-
Hi @tpr, would it be possible to get the field edit links that show on hovering a field label to work on fields that are inside repeater items? Ooh, and another idea re: field edit links. What if Ctrl-click brought up the settings for the field in the template context? (i.e. the template overrides) Edit: one more thing... The "Configure" anchor links in the Submodules panel do not scroll me to the right options panel, but scroll down quite a bit further. Tested in Firefox and Chrome on Windows.
-
I think @ryan is unlikely to switch from region attributes in tags to a different system where regions are defined using HTML comments, considering that the Markup Regions feature is already published and currently being used in its existing form. But I do agree with your request to support a region tag that is stripped out of the final output. As you noted, that would be particularly useful for defining multiple regions inside the <head> element. There is a GitHub feature request that covers some of this stuff: https://github.com/processwire/processwire-requests/issues/78
-
I think you need to set output formatting false before you start setting values to fields: $payment = $pages->get('template=payment,id='.$payment_id); $payment->of(false); if($payment->id) $payment->payment_status = P_PAID; $payment->save();