Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/10/2018 in all areas

  1. Here is how I did it: $wire->addHookAfter("Pages::save", function(HookEvent $event) { $page = $event->arguments[0]; if($page->template->name != 'my-template') return; $admin_page_name = wire("pages")->get(2)->name; $repeater_id = wire("fields")->get('my_repeater_field')->id; $empty_items = $pages->find("template=repeater_my_repeater_field, my_text_field='', parent=/{$admin_page_name}/repeaters/for-field-{$repeater_id}/for-page-{$page->id}/, include=all"); if(count($empty_items)) { foreach($empty_items as $empty_item) { $page->of(false); $page->my_repeater_field->remove($empty_item); $page->save(); } }
    3 points
  2. Could it be this problem? https://github.com/philipwalton/flexbugs/issues/160 https://github.com/philipwalton/flexbugs/issues/75
    2 points
  3. @Peter Knight What do you want to do with products that do not have images? In your foreach you define the $image variable only when there are images. Then you echo the images even if there are none. This will give you a PHP notice for $image is undefined. You'd need another if condition within your echo to check for isset($image) and only output the image if there is one. The way you setup your images field it should definitely return an empty array if there are no images so the if (count($prod->images)) should work as expected.
    2 points
  4. Ok, the culprit was that CKE needs some time on startup to dynamically create the iframes. Therefore all those tries running on document load failed. As a workaround I use setTimeout() with a delay of 1000 ms to start finding the iframes. Will look into CKE API, if there is something that can be queried that indicates ready loaded CKE and use this instead of my workaround. But for today I'm finished with work. ?
    2 points
  5. Not sure what you mean here. If you mean the id of "1234" in my demo code that is just to indicate that you need to use a page id on this line and not a Page object or some other page property. You can get that page id any way you like - it doesn't have to be hardcoded.
    2 points
  6. LogMaintenance A simple ProcessWire module to give some maintenance control over log files. I found myself often having lots of log files for different things that can grow more or less quickly to a size where they can be difficult to maintain. The built in Logger of PW does a good job of giving you the possibility to delete or prune logs. But it has to be done manually and sometimes a log grows into millions of lines, which makes it often impossible to even prune it as it's too large. LogMaintenance uses LazyCron to run the maintenance task and there's several settings you can setup on a global or per log basis. Archive: will create zip files for each log file in logs/archive/ folder and add the log each time the maintenance is run to a subfolder containing the datetime. Lines: keeps logs to a certain number of lines Days: keeps the log to a certain number of days Bytes: keeps the log to a certain amount of bytes Each setting is checked from top down, the first setting to contain something is used. So if you check the "Archive" option, all other settings are ignored and logs are archived everytime the LazyCron is executed. If you want to keep your logs to a certain amount of bytes just leave all other settings to 0 or blank. Per Log Settings There's a textarea that you can use to setup a config for a specific log file one per line. All the logs you define here ignore the global settings above. The syntax for the settings is: logname:[archive]:[lines]:[days]:[bytes] errors:1:0:0:0 // would archive the errors log messages:0:10000:0:0 // will prune the errors log to 10000 lines The module can be found on github for you to check out. It's still fresh and I'm currently testing. https://github.com/somatonic/LogMaintenance
    1 point
  7. Hi everyone, Here's a new module that lets you control whether multi-language support is enabled at the page / branch level, rather than only per template. http://modules.processwire.com/modules/restrict-multi-language-branch/ https://github.com/adrianbj/RestrictMultiLanguageBranch This is ideal for a site with repeated branches using the same templates where only some need to be multi-language. I think it is confusing to provide multiple language inputs for fields when they are not required - it just bloats the admin interface for site editors. I am hoping to expand this module to allow selection of which languages are supported per page/branch, but I am waiting on @ryan's response to this request: https://github.com/processwire/processwire-requests/issues/54 - to me this would be even more powerful if you have a situation where certain branches need some languages and other branches need different languages. The module config settings shows a summary of the restrictions you have implemented, eg: This shows that we have started with the home page which disables multi-language on itself and all its children/grandchildren (because "This Page Only" is "False". Next we have the /report-cards/ page multi-language enabled, but no inheritance (because "This Page Only" is "True"). The only branch below this to have multi-language enabled is Guanabara Bay and all it's children etc will also be enabled. All other report card branches will be disabled because they will inherit directly from the config settings default status. The Settings tab for each page gives you three options: Inherit, Enabled, Disabled. The screenshots give you an idea of how the Inherit option works and the information it provides based on the status it is inheriting and from where. My goal for this site was to just enable multi-language support for the Guanabara Bay report card branch of the tree, as well as the home page and the /report-cards/ parent. All other branches have multi-language support disabled which makes content entry much cleaner. Hope you guys find a good use for it and I'll be sure to update with the ability to define which languages are available on which pages/branches if Ryan comes up with a core solution for changing the returned $languages. Please let me know if you have any problems / suggestions.
    1 point
  8. you can also use ?field=yourtab to show only the fields of this tab. I'm using this sometimes combined with the pw side panel edit: this only works with custom fieldsettabs, but maybe you can list the fields one by one, like ?fields=yourfield1,yourfield2
    1 point
  9. When saving the admin remembers which tab was open (only on non-ajax tabs unfortunately). You can link directly to one tab by appending the id like this: .../page/edit/?id=123#ProcessPageEditSettings
    1 point
  10. I think you will find useful Admin Actions Module http://modules.processwire.com/modules/process-admin-actions/ It has a branch of predefined actions, but you can create own.
    1 point
  11. A short but good summary on isset() / empty() / is_null(): https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/
    1 point
  12. https://processwire.com/api/ref/wire-mail/ Use $m->bodyHTML('<html><body><h1>Message Body</h1></body></html>'); in addition to $m->body();
    1 point
  13. If you reduce the image max-width (or the div above with no class) to approx. 66%, it looks OK. But ONLY in IE ? Maybe use MS vendor prefixes for IE, or the old if-IE conditional tags
    1 point
  14. 1 point
  15. I believe you could achieve this by "Extra Allowed Content" under the input tab for the field itself. I have mine set up with : img[*] In your source code (after you have uploaded and image to the ckeditor field), you could then simply add in class="img-fluid" and it would then retain the class. Then in you actual code for the template, just use: <?= $page->your_field_here; ?> and the content/image will be output with the correct classes to make it responsive.
    1 point
  16. I was able to make it work now. Not sure if a hack, but... To my copy of PageFrontEdit.js, I've simply added: function ckeGetProcessWireConfig(editor) { return {pwAssetPageID:jQuery("#" + editor.name).closest('.pw-edit').attr('data-page')}; } Then it shows the right image field. Thank you for your help.
    1 point
  17. And does your connection come up when you use curl directly? Like: curl -H "Authorization: api_key=<insert api key here>" --data "title=Your%20Title&message=Your%20Message&icon=http://yourwebsite.com/icon.png&url=https://yourwebsite.com" https://api.pushalert.co/rest/v1/send
    1 point
  18. @Jules Vau Yes, thats correct. The setting in site/config.php overwrites the one in the wire directory.
    1 point
  19. It's all there. When I was starting with PW years ago, I very soon looked at modules and all the Process modules that make the admin. So I never really needed a tutorial, just look and learn copy and try. It was so simple and since it's all in the same fashion using the already familiar API and "normal" modules. So you have a ton of modules Ryan has already built that make ProcessWIre backend you can use as examples/learning. Isn't it nice?
    1 point
  20. I have done something similar before using: $pages->addHookAfter('saved', function($event) { $page = $event->arguments[0]; // if page template = specific template, then execute desired code if($page->template->name == 'mytemplatename') { # do something here } } I just put it in the ready.php file under the "site" folder.
    1 point
  21. To answer your first question: this seems possible. You can already set custom headers. See this part on the WireHTTP class or in API ref.
    1 point
  22. Hi Everyone, Today I am delighted to share my new product that we have created with Processwire. It's a verification system, that binds together a physical address with website. I’m using Processwire nearly from the beginning and I still believe that it is one of the greatest open-source platforms that exist. Being thankful I’m pleased to provide the service of Verikey verification to the Processwire community (and websites that you did) for free. Forever. Visit verikey.com Gift code: ###### (please, request by direct message) Feedback and questions are really appreciated. Many thanks my Mom, @ryan, @soma, @adrian and all Processwire contributors. Cheers, Alexander UPD: While subscription Stripe requires a valid bank card details. It’s a formality by Stripe for all subscriptions. The Verikey service remains 100% free and out of charge with the provided voucher code.
    1 point
  23. Try this in /site/ready.php: $wire->addHookAfter('InputfieldCKEditor::renderReadyHook', function(HookEvent $event) { $inputfield = $event->object; $page = $inputfield->hasPage; $field = $inputfield->hasField; // Whatever test you need to identify when the asset page should be changed if($field->name === 'body' && $page->template == 'basic_page') { $js_config = $this->config->js('InputfieldCKEditor_' . $inputfield->name); $js_config['pwAssetPageID'] = 1234; // The id of the asset page you want to use $this->config->js('InputfieldCKEditor_' . $inputfield->name, $js_config); } }); Seems to work well in the PW admin, but the code comment here suggests it won't work for front-end editing.
    1 point
  24. Yes, I think the module should do this (or offer an option for it). Because the name field is normally on the Settings tab, and if you are removing that tab for a role then you probably don't want the role seeing any of the fields normally on that tab. You probably know this but it was new to me... you can add styles to an inputfield without needing to include a CSS file with the module: $if = $wrapper->getChildByName('_pw_page_name'); $if->wrapAttr('style', 'display:none;');
    1 point
  25. <?php if($image->width > $image->height) { echo "Width : `{$image->width}px` bigger than height : {$image->height}px !"; } else { echo "Height : `{$image->height}px` bigger than width : {$image->width}px !"; }
    1 point
  26. That's really a strange way for the host to answer, because ssl is really not related to the cms (besides maybe generating https links and redirecting). But enabling ssl does need to be setup on the webserver. For redirection to https see the .htaccess file and urls in processwire are most often relative ones, so there's probably not much to do on the url generation side.
    1 point
  27. If anybody of you like me totally missed the markdown preview of vscode just click the preview icon on the top right:
    1 point
  28. Hi Soma, I know it's under development. I want to do some tests But I'll wait until it's usable.
    1 point
  29. Ryan, I ended up just moving the site over to our Rackspace server. It works perfectly well there. Without getting too technical, I think it was a combination of the PHP version, Magic Quotes, and an issue where the php.ini / htaccess methods of turning off Magic Quotes was somehow not allowed by the server. I don't think that you have to worry about this as being a bug that needs to be fixed, I think it was an unreasonable server configuration issue.
    1 point
×
×
  • Create New...