Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/22/2019 in all areas

  1. Mystique Module for ProcessWire CMS/CMF Github repo : https://github.com/trk/Mystique Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file. Requirements ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation Install the module from the modules directory: Via Composer: composer require trk/mystique Via git clone: cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video. Using Mystique with your module or use different configs path, autoload need to be true for modules Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension. Adding custom path not supporting anymore ! // Add your custom path inside your module class`init` function, didn't tested outside public function init() { $path = __DIR__ . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; Mystique::add($path); } Mystique module will search site/modules/**/configs/Mystique.*.php and site/templates/Mystique.*.php paths for Mystique config files. All config files need to return a PHP ARRAY like examples. Usage almost same with ProcessWire Inputfield Api, only difference is set and showIf usage like on example. <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example: site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator. Search example $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
    2 points
  2. I was using one of the demos from the UIKit site and didn't really change much, apart from inserting text instead of images, and the a.m. CSS bit. PW doesn't care about any of your frontend code. It will render anything you want. There's plenty of ready-made sliders that support auto-height, here are just two random examples: https://owlcarousel2.github.io/OwlCarousel2/demos/autoheight.html https://codepen.io/simonmshirley/pen/remoXb
    2 points
  3. Hello Milo and welcome to the forums. $config->userAuthSalt For security reasons this should be different for every page. This value is used to hash your passwords to add an extra layer of security. That means when you change it you won't be able to log in anymore without regenerating the password. $config->httpHosts This should be just the host, without the protocol. So without http/https site/assets/files As far as I know there is no better way to do this, so you would have to delete files that are not needed on the new site manually. I could be wrong tho. As for the title of the topic: try to add a couple more words so people with the same questions will have it easier to find your topic in the future ? Best regards and again, welcome to the community
    2 points
  4. Whenever you need something think "Where is it done in the core" and grab ideas from there ? You can see how it is done in ProcessModuleInstall.php I've done it that way recently: $tmpDir = $this->files->tempDir('upload_csv'); /** @var InputfieldFile $f */ $f = $this->modules->get('InputfieldFile'); $f->attr('id+name', "upload_csv"); $f->label = 'foo'; $f->icon = 'download'; $f->extensions = "csv"; $f->maxFiles = 1; $f->descriptionRows = 0; $f->destinationPath = $tmpDir; // when the form is submitted: /** @var WireUpload $ul */ $ul = $this->wire(new WireUpload($f->name)); $ul->setValidExtensions(explode(" ", $f->extensions)); $ul->setMaxFiles($f->maxFiles); $ul->setOverwrite($f->overwrite); $ul->setDestinationPath($f->destinationPath); $ul->setExtractArchives(false); $ul->setLowercase(false); $files = $ul->execute(); if(count($files)) { $file = $f->destinationPath . reset($files); // do something with your file } else { $this->error('No uploads found'); } There is an issue with ajax loaded fields: https://github.com/processwire/processwire-issues/issues/885 And it seems that ZIP is always added to the allowed file endings... Can anybody confirm that? PS: Don't you use TracyDebugger? It's a lot better than using print_r() ?
    2 points
  5. You're creating an infinite loop. You hook into "after save" change something and save again, which again triggers your "after save" hook and so on. Either look for another hook to do your work (potentially change things last minute before the actual save) or add some way for your hook to only run once and not for the saves it initiated on it's own.
    2 points
  6. Nice to hear that. Processing input field there is not special check for input field. https://github.com/trk/Mystique/blob/master/InputfieldMystique.module.php#L135 Little bit worked on a base field type (basically this field type will get entered field type's database schemas and will create 1 database table for all entered fields), if i success about this field type, i will try to use input field based checks. For the moment getting and setting directly posted data.
    2 points
  7. Inspired by this thread with a little nugget based on AOS by @benbyf to visually distinguish development systems from production ones, I wrote a small module that does the same and lets you adapt colors and text. Link to the github repo: AdminDevModeColors Version 0.0.1 is still very alpha and only tested on PW 3.0.124. Description This module lets you change the color for the top toolbar and add a small piece of text for development systems, so you are immediately you aren't working on production (and vice versa). The adaptions are made through pure CSS and applied if either the "Enable DEV mode" checkbox in the module's configuration is checked or the property $config->devMode is set to true in site/config.php. Works with Default, Reno and Uikit admin themes (though probably needs a lot of testing with different versions still). Since a screenshot says more than thousand words... Production system (unchanged): Dev system (Default admin theme): Dev system (Reno admin theme): Dev system (Uikit admin theme): Feel free to leave any feedback here and report any problems either in this thread or the github issue tracker.
    1 point
  8. WIP module (90% done) following this request expression of interest ? by @szabesz. A (Process) module that allows the posting of Notes in the ProcessWire admin. Inspired by WP Dashboard Notes (see video in link above). The module is almost complete. As usual, I hit a snag with the CSS! PRs highly welcome, please! (see below). Setting note sizes and display was a bit tricky. Module is now available for alpha testing here. https://github.com/kongondo/DashboardNotes Contributing I should have mentioned this earlier and done it properly but I am lazy, so this is the rough guide. I know we all have our preferences but please note: No heredoc syntax No alternative syntax for control structures (i.e. endif, etc) Indent using tabs (4) Doesn't matter in this case, but no PHP short tags For methods, opening curly bracket on same line as the method name (there's a technical wording for this, I can't remember now) Features Set Notes priority (low/normal/high) Note text and background colours Enable/disable replies to Notes Lock Notes for editing Viewing of Notes can be controlled using users IDs, roles or permissions. Default is all Notes can be viewed by all who have access to the module Edit Note after posting Global note settings (accessible only to those with dashboard-notes-settings permission) - default colours, date format, if users can delete notes they did not create, if users can edit notes they did not create, note display dimensions, maximum depth of (nested) replies, maximum characters of note preview before truncate, etc.) Sort notes by date, title or priority Pending Bulk actions (delete, lock, change priority, etc) Reply/commenting on notes More testing on visibility Requests/Ideas Mine is: PRs are welcome! Especially with the CSS and/or Design (Use the Dev Branch please) Display Note author title (if present, or any other named author title field) rather than their (user)name? Other? Screenshots Thanks!
    1 point
  9. 180 I'm too tired right now to look at each and every single query, but I'm puzzled by a few randomly spotted queries such as SELECT false AS isLoaded, pages.templates_id AS templates_id, pages.*, pages_sortfields.sortfield, (SELECT COUNT(*) FROM pages AS children WHERE children.parent_id=pages.id) AS numChildren,field_email.data AS `email__data` FROM `pages` LEFT JOIN pages_sortfields ON pages_sortfields.pages_id=pages.id LEFT JOIN field_email ON field_email.pages_id=pages.id WHERE pages.templates_id=3 AND pages.id IN(40) GROUP BY pages.id I don't need any email field in this page / template. So I wonder why is something like this even queried? I'm sure (or I hope) there's a good reason why this query is listed, but I'm just not sure why. (by Tracy, or PW core? or just PW core-while-in-debug-mode?) Still - to me, those timings are quite acceptable. And yes, if debug is off, it's even faster. (though I haven't set up a script to measure that - I just look at Google Chrome's performance audit results or similar for TTFB).
    1 point
  10. More info on this threads : Welcome ?
    1 point
  11. Ah, silly me ? Of course I didn't think the obvious. It now works and I'm using this module: https://modules.processwire.com/modules/page-rename-options/ for all the pages at the moment! Thanks anyway! Ah I see! Good to know, might be handy someday for preventing those pesty infinite loops ? Thanks horst
    1 point
  12. @VeiJari maybe hook after pages::saveReady is better for this. But also it is possible in a pages::saved hook to save the page again without running into an infinite loop with, for example, using a temporary property: wire()->addHookBefore("Pages::saved(template=tapahtuma|artikkeli)", function($hook) { $page = $hook->arguments(0); if($page->skipMyHook) { // if the page already has our temporary property, we skip further processing return; } $newUrl = wire()->sanitizer->pageName($page->title); // give it a name used in the url for the page wire()->log->message($page->name); $page->skipMyHook = true; // add a temporary property to the page (it is only in memory) $page->setAndSave('name', $newUrl); });
    1 point
  13. I was struggling with that recently too. It doesn't seem to be too well documented. If I remember correctly you could do the following <?php .... $form->add($f); if($this->input->requestMethod('POST')) { // validate and upload the file to /site/assets/files $form->processInput($this->input->post); // access file $uploadedFile = $form->get('prop_pix_1')->value; }
    1 point
  14. Ok thx, now I get it ? I've planned that feature, but can't remember that I've ever used it, so I don't know if that still works (see option 2, InputfieldRockGrid.module.php): If you are talking about excel export: yes. I don't have any sample code, see /plugins/buttons/excel.js
    1 point
  15. @flydev could you please share some screenshots or screencasts? @NorbertH did you try my module? It's exactly built for such backend modifications without having to build a whole new admin theme (and I'd be happy to have a more condensed version as well, but CSS is not my strongest skill):
    1 point
  16. I think there is a feature request for this at the moment. https://github.com/uikit/uikit/issues/3812
    1 point
  17. Not stated on each product page but this seems to apply to each product of Ryan: "7 days of purchase and we will refund your money in full." see: https://processwire.com/store/pro-drafts/#warranty-support-refunds I'd recommend purchasing it on Thursday, and spending the weekend on evaluating it. Also note that usually Ryan has time to promptly reply to support questions around weekends (form Friday to Sunday), which is worth taking into account if you also want to ask questions while evaluating.
    1 point
  18. Imagine you have a nice conversation with someone and only a few hours afterwards you are knee-deep into a module and possibilities you never thought of. Thank you @bernhard for hijacking my plans for the weekend. ?
    1 point
  19. @Gadgetto There is nothing special in using preloadFor method. All you have to do is to call it before any calls of get method $cache->preloadFor($this->className()); As you can see I have a lot of chunks of cache namespaced with TestsDashboard. Instead of multiple select queries 67 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2725, null) 68 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2726, null) 69 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2727, null) 70 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2728, null) 71 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2729, null) 72 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2730, null) 73 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2731, null) 74 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2732, null) 75 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2733, null) 76 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2734, null) 77 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2735, null) 78 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2736, null) 79 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2737, null) 80 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2738, null) 81 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2739, null) 82 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2740, null) 83 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2741, null) 84 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2742, null) 85 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2743, null) 86 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2744, null) using preloadFor I will load them to memory from DB only with one query and then all next calls of get will load them not from DB, but from memery SELECT name, data FROM caches WHERE (name LIKE :name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__*, null)
    1 point
  20. @Macrura I just stumbled across this interesting older post. Since I'm currently working on a module that accesses an external REST API, the topic of caching is very interesting. I use WireCache to cache the REST queries and am currently working on improving performance. I stumbled across preloadFor. Does anybody have a code example which shows how preloadFor can/should be used to improve performance? This is a sample how I'm currently using WireCache: public function getSettings($key = '', $expires = WireCache::expireNever, $forceRefresh = false) { if (!$this->getHeaders()) { $this->error($this->noticesText['error_no_headers']); return false; } if ($forceRefresh) $this->wire('cache')->deleteFor('SnipWire', self::cacheNameSettings); // Try to get settings array from cache first $response = $this->wire('cache')->getFor('SnipWire', self::cacheNameSettings, $expires, function() { return $this->getJSON(self::apiEndpoint . self::resourcePathSettingsGeneral); }); return ($key && isset($response[$key])) ? $response[$key] : $response; }
    1 point
  21. I am using this module for SEO, LANGUAGE and ELEMENTS (uikit components) USAGE EXAMPLE : LANGUAGE On my private module, i added my custom configs path to Mystique module by using : Mystique::add('my-module-configs-path'); - Create config file <?php namespace ProcessWire; // Filename: MyModule/configs/Mystique.language.php // This options normally coming from a file array, i added 2 options for example $options = [ 'tr' => 'Türkçe', 'en' => 'English' ]; $defaultValue = 'en'; /** * Resource : MyModule => Language */ return [ 'title' => __('MyModule: Language'), 'fields' => [ 'title' => [ 'label' => __('Language title'), 'description' => __('Title of language'), 'type' => Mystique::TEXT, 'columnWidth' => 50 ], 'code' => [ 'label' => __('Code'), 'description' => __('Language short code'), 'type' => Mystique::SELECT, 'options' => $options, 'defaultValue' => $defaultValue, 'required' => true, 'columnWidth' => 50 ], 'flag' => [ 'label' => __('Flag'), 'description' => __('Language flag code'), 'type' => Mystique::TEXT, 'columnWidth' => 50 ], 'direction' => [ 'label' => __('Direction'), 'checkboxLabel' => __('Right to left'), 'description' => __('Direction of language'), 'type' => Mystique::TOGGLE_CHECKBOX, 'type_fallback' => Mystique::CHECKBOX, 'columnWidth' => 50 ], 'currency' => [ 'label' => __('Currency'), 'description' => __('Code of currency'), 'type' => Mystique::TEXT, 'columnWidth' => 50 ], 'symbol' => [ 'label' => __('Symbol'), 'description' => __('Symbol of currency'), 'type' => Mystique::TEXT, 'columnWidth' => 50 ], 'grouping_separator' => [ 'label' => __('Grouping separator'), 'description' => __('Thousand separator for amount'), 'type' => Mystique::TEXT, 'columnWidth' => 50 ], 'decimal_separator' => [ 'label' => __('Decimal separator'), 'description' => __('Decimal separator for amount'), 'type' => Mystique::TEXT, 'columnWidth' => 50 ], 'separator' => [ 'label' => __('Use separator'), 'checkboxLabel' => __('YES'), 'description' => __('Apply space between amount and currency symbol ?'), 'type' => Mystique::TOGGLE_CHECKBOX, 'type_fallback' => Mystique::CHECKBOX, 'columnWidth' => 33 ], 'show_decimal' => [ 'label' => __('Decimal'), 'checkboxLabel' => __('YES'), 'description' => __('Show amount decimals ?'), 'type' => Mystique::TOGGLE_CHECKBOX, 'type_fallback' => Mystique::CHECKBOX, 'columnWidth' => 33 ], 'symbol_after' => [ 'label' => __('Symbol after'), 'checkboxLabel' => __('YES'), 'description' => __('Display symbol after amount ?'), 'type' => Mystique::TOGGLE_CHECKBOX, 'type_fallback' => Mystique::CHECKBOX, 'columnWidth' => 33 ], ] ]; - Select config file from Mystique field settings - Add Mystique field to language template Access data via api (in this example mystique field name is : lang) <?php $language = $user->language; // lang is Mystique field echo 'Title : ' . $language->lang->title . '<br>'; echo 'Code : ' . $language->lang->code . '<br>'; echo 'Flag : ' . $language->lang->flag . '<br>'; echo 'Direction : ' . $language->lang->direction . '<br>'; echo 'Currency : ' . $language->lang->currency . '<br>'; echo 'Symbol : ' . $language->lang->symbol . '<br>'; echo 'Grouping separator : ' . $language->lang->grouping_separator . '<br>'; echo 'Decimal separator : ' . $language->lang->decimal_separator . '<br>'; echo 'Separator between amount and symbol : ' . $language->lang->separator . '<br>'; echo 'Show decimal : ' . $language->lang->show_decimal . '<br>'; echo 'Show symbol after amount : ' . $language->lang->symbol_after . '<br>'; Output: Title : English Code : en Flag : gb Direction : 0 Currency : GBP Symbol : £ Grouping separator : , Decimal separator : . Separator between amount and symbol : 1 Show decimal : 1 Show symbol after amount : 0
    1 point
  22. i use that technique from Raymond and i gotta say, it's pure gold!; saved me many times and helped along a project that i thought would be a nightmare to work on (requirement to work on site while it was in use)..
    1 point
×
×
  • Create New...