Leaderboard
Popular Content
Showing content with the highest reputation on 05/09/2022 in all areas
-
@DrQuincy Is this from a template file? You could do this: echo "<p>An error occurred!</p>"; return $this->halt(); That halts the rendering of output but lets PW finish everything else in the request. Another option is to throw a WireException. This will also halt the request but allow PW to still shutdown. The response is an http 500 error. The error message will be displayed if in debug mode or if the user is logged in and a superuser. throw new WireException("An error occurred!"); Often times on the front end a fatal error is about a resource not available, and a 404 is the appropriate response. So you can do this: throw new Wire404Exception(); or this does the same thing (I prefer this shorter version): wire404(); Lastly, while the above are preferable, it's also okay to do an exit() or a die(), is shouldn't break anything at least.3 points
-
Like caniuse.com but for PHP, eg: https://caniphp.com/?s=null It is possible to support the project: https://ko-fi.com/magicroundabout https://github.com/rosswintle/can-i-php Happy coding! :)3 points
-
@fuzenco - new version just committed that also supports integer & decimal field types as well as float.2 points
-
Hi @Matzn <?php namespace ProcessWire; class ParentModule extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return [ 'title' => 'Parent Module', 'version' => 1, ]; } const defaultValue = '12345'; public function __construct() { $this->set('api_user', self::defaultValue); // set default value in construct } public function getApiUser() { return $this->api_user; } public static function getModuleConfigInputfields(array $data) { if(!isset($data['api_user'])) $data['api_user'] = self::defaultValue; $form = new InputfieldWrapper(); $f = wire('modules')->get('InputfieldText'); $f->name = 'api_user'; $f->label = 'API USER'; $f->value = $data['api_user']; $form->add($f); return $form; } } <?php namespace ProcessWire; class ChildModule extends ParentModule { public static function getModuleInfo() { return [ 'title' => 'ChildModule', 'version' => 1 ]; } public function __construct() { parent::__construct(); bd($this->getApiUser()); bd($this->wire()->modules->getModuleConfigData('ParentModule')); } } Take a look at the construct method of ChildModule. Without calling parent::__construct you will not be able to get what you want. Also you can use $this->wire()->modules->getModuleConfigData('ParentModule') to get config data of module.2 points
-
It's been a quiet week on the dev branch (mostly), and so this post will also be short. That's a good thing, as it means we are at a stage where there's no new major things to immediately fix or add. Assuming that remains the case, by next week at this time we should have 3.0.200 released on the main/master branch. In next week's post I plan to outline all that's changed since our last master version, 3.0.184, stay tuned and have a great weekend!2 points
-
Hey everybody, I just uploaded a small textformatter module for wrapping tables with a div container in order to display responsive HTML tables in the frontend. TextformatterWrapTable Processwire wrap table module is a textformatter module for processwire CMS/CMF. It is wrapping markup tables with a div container. wrapping tables with div container simplifies the process of displaying responsive tables in the frontend. The css classes for the wrapper and the table are configurable. .table-responsive / .table by default the module produces the following markup: <div class="table-responsive"> <table class="table"> ... </table> </div> Link to Repository https://github.com/pmichaelis/TextformatterWrapTable1 point
-
If that's of any help... I haven't tested newer versions since then. Also https://github.com/processwire/processwire-issues/issues/7691 point
-
@Matzn ProcessWire classes are just PHP classes, so there would be no difference. Note that I don't think you can have a class named "Parent" as I think that might be a reserved word in PHP. I wouldn't bother trying to do an external configuration class. Start with an internal getModuleConfigInputfields() method, and when all works, then consider moving it to an external one if needed. Make sure your module implements the ConfigurableModule interface, indicated at the top of the class. I also think maybe you shouldn't try to extend your Parent module/class and instead should just write another module that pulls from the Parent module what it needs. Module inheritance is useful in many situations but it's not clear to met that this is one of those situations, though I could be wrong. This is fine the way you are doing it, but note that your class "Child" need not extend "Parent" given the approach you are using. Your "Child" module could just extend WireData instead, and the code in your myMethode() would do exactly the same thing.1 point
-
I've been playing with CloudFlare's cache everything feature to serve a site that's hardly ever updated from the edge. It works amazingly well on non-PW sites, speed is so fast it seems you're serving the site locally. But I'm having the same issue as @chcs with that PW site, all assets are fully cached but the page. You can easily check this using Dr Flare's extension on Chrome. Anyone knows why the response header is set to no-cache for HTML pages served by ProcessWire, and how we can bypass this?1 point
-
@adrian Amazing. That worked perfectly. The fields were selectable and I was able to update my entries as a result. Thanks much!1 point
-
Hi @fuzenco - can you please do me a favor and try changing this line: https://github.com/adrianbj/ProcessAdminActions/blob/331e210404b7f883aec04c4342185c04be24d57d/actions/FieldSetOrSearchAndReplace.action.php#L23 to: if (!$field->type instanceof FieldtypeText && !$field->type instanceof FieldtypeFloat) continue; That should work, but please test and let me know and then I'll update the action.1 point
-
Hi @csaggo.com, Work on price fields to accommodate international currencies is now complete. Decimal styles are now handled correctly. In addition, thousands are also separated correctly (automatically). To help with this, we now have a new setting in Shop / General Settings -> Standards Tab -> Currency Format (please see screenshots below). Price fields will be formatted based on this new setting. Price fields also display the currency symbol if one exists or the currency's abbreviated name. Currently, this is not configurable but I can add this in future if there is demand for it. This also works for variants price fields. Update summary: Automatic formatting of price fields based on the General Settings 'Currency Format' (currency locale). This means, e.g. Canada French versus Canada English is possible; France - thousand separator is space; Germany - thousand separator is period and comma is decimal character, etc. Thousands are automatically formatted as you type. Thousands separator is based on the 'Currency Format'. Decimal style is based on the 'Currency Format'. Currency value validation is also enforced client-side. For instance, if 'Currency Format' is 'de-DE', one cannot use a period as a decimal. Other invalid entries are also prevented, e.g. cannot enter text in this field. Automatic currency symbol placement. Currently, there are no in/decrement elements on the price field. Works with both products and variants (include variant creation modal). Not yet implemented in manual order editing (e.g. fixed discount amount, etc). Download Please use your download link to get the updated Padloper. If you don't have this in your email, please send me an email to resend it to you. Once downloaded, use the files to overwrite the ones in your present install. You might need to refresh your browser cache to clear the older JavaScript files. Version The Padloper version stays the same until #8 is resolved. Screenshots Currency Format (locale) Example: Canada currency formats Example: Germany currency format Edit Product (German Euro is currency) Edit Product Variant (German Euro is currency) Create Product Variant (German Euro is currency) Please test and let me know how it goes. Thanks.1 point
-
Upgrading the secondary site to the same version as the "mothersite" fixed the issue. As explained here: 'Ideally all instances should be running the same exact version of ProcessWire if possible. At minimum, the versions must be close.'1 point
-
@fruid I'm sorry for providing only small bits of help only but you can also consider using URL hooks instead of putting both "normal page rendering" and AJAX responses into the same template file. See: https://processwire.com/blog/posts/pw-3.0.173/ In one way it is cleaner and more flexible than putting both responses into the very same file, but of course, you have to "manage" the two different responses in different files in this way. Another way of separating AJAX request/responses from the page request is to use URL segments, but with URL hooks available since PW 3.0.173, I would not use that technique anymore.1 point
-
1 point
-
Your code can't work because interpolation for double quoted strings allows only variables or some variable expressions (like methods calls or object property access), see the documentation on string parsing. foreach loops are language constructs and can't be used inside strings. For this to work, move your foreach loop outside the echo statement and only echo the actual HTML code. Then it should work: foreach($item->repeater_logos_links as $logo) { echo "<img src='{$logo->single_image->url}' alt='{$logo->single_image->description}' width='400'>"; }1 point
-
Perhaps something like this? $session->history = is_array($session->history) ? array_slice(array_unique(array_merge([$page->id], $session->history)), 0, 4) : [$page->id]; And when you're displaying the history, just skip over current page: foreach ($session->history as $page_id) { if ($page_id == $page->id) continue; $p = $pages->get($page_id); echo "<a href='{$p->url}'>{$p->title}</a><br />"; }1 point
-
All fields are assumed to have at least a "data" field, so you can also query it just by specifying the field name without "data", i.e. $p = $pages->get("images%=mode");1 point