Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/09/2018 in all areas

  1. I've converted the js here (the original was renamed to CookieManagementBanner.jquery.js): https://github.com/rolandtoth/CookieManagementBanner I found some js parts was not used at all, eg. cookieMonster.cfg.block seems redundant (renamed to blockClass in my version), and the whole updateUi method also because there is no "theme" that uses the ".pwcmb--top_push" class (but correct me if I'm wrong). I removed the latter entirely. I have also made some minor CSS updates, eg. pointer cursor on labels and buttons. Hopefully I haven't break anything but a proper checking is needed (I don't use the module anywhere atm to test).
    8 points
  2. Hello, I have something similar I hope you can adapt it to your needs. Mine is for user templates: <?php //adds a button to the end of the user edit page: $this->addHook('ProcessPageEdit::buildForm', function (HookEvent $event) { $current_page = $event->object->getPage(); if ($current_page->template->name != 'user') return; // this button is for the user edit page only if (empty($current_page->user_family_name)) return; // custom field is not yet filled in, which means the new User has not been saved but still being edited in the admin $id = (int) $current_page->id; if ($id != 0) { if ($current_page->hasRole('mycustomrole')) { $href = createLink($current_page); // this is a custom function to be implemented, it must generate and return the required URL $field = $this->modules->get('InputfieldButton'); $field->attr('class', $field->class . " my-custom-css-class-if-needed"); // this is just opitional, I left it here as an example $field->attr('value', 'Copy URL to clipboard...'); $field->attr('data-clipboard-text', $href); // data-clipboard-text is needed by https://clipboardjs.com/ $field->attr('href', ''); // $href $event->return = $event->return->append($field); } } }); The copy to clipboard action is performed by https://clipboardjs.com/ which can be loaded by the admin using various techniques or free modules (such as AdminOnSteroids or Admin Custom Files) or one can simply put this line into config.php: $config->scripts->add($config->urls->templates . "clipboard.min.js"); where clipboard.min.js is in the templates directory, for example. EDIT: I forgot to note that the hook goes into init.php
    5 points
  3. Thanks for all your answers!!! This was really fast and seems like a very active community! I'm sure the code snippet by @szabesz and the fieldtype by @kixe will work as well and are definitely more lightweight. I went with the RuntimeMarkup fieldtype suggested by @elabx as it was the fastest and easiest one to apply. Here is my php snippet for the runtime field: return " <a id='custom-action-button' href='#' onclick='copyUrlToClipboard(event);'>Copy URL to clipboard</a> <input type='text' value='" . $page->httpUrl() . "' id='target-page-url'> <p id='action-executed-hint'>Successfully copied URL to clipboard!</p> <style> #custom-action-button { color: #FFF; background: #93BF0D; font-weight: bold; padding: 0.6em 1.1em; font-size: 1em !important; border-radius: 5px; } #custom-action-button:hover { color: #FFF; background-color: #DB1174; } #custom-action-button:active { color: #FFF; background-color: #860A47; } #custom-action-button:visited { color: #FFF; } #target-page-url { position: absolute; left: -9999px; top: -9999px; opacity: 0; pointer-events: none; } #action-executed-hint { display: none; } #action-executed-hint.show { display: inline; } </style> <script> function copyUrlToClipboard(event) { event.preventDefault(); var urlText = document.getElementById('target-page-url'); urlText.select(); document.execCommand('copy'); var hint = document.getElementById('action-executed-hint'); hint.className += ' show'; } </script> "; It creates an a-tag which is styled like a backend button. Hope its useful for someone else!
    4 points
  4. I could reproduce it. Just am on a new project and isntalled blank 3.0.98. It doesn't happen always. Can you open an issue on github please. Thx.
    3 points
  5. Just the things that Ryan says in the blog post mentioned above: But I don't think it's anything to worry about for most websites. Besides this topic I haven't heard of anyone having any problems with large numbers of fields.
    3 points
  6. Hello @DarsVaeda, the commercial module ProCache does this very well, even for assets. Every time you make changes to your styles or scripts, the merged and minified styles or scripts get updated with a new hash. I can really recommend this module. ? Regards, Andreas
    3 points
  7. You are in search for a Single Sign On (SSO) solution. You might want to check out this SAML SSO ProcessWire module. Or you might want to check out other PHP SSO of SAML solutions.
    3 points
  8. @louisstephens I really like the answer @horst posted about this but want to ask if you intend using Lazycron for doing this? If so, please be aware of the potentially long processing times associated with doing things this way, especially on the initial read of the feed. Also; there is no facility above for removal of items that no longer appear in the feed but that are stored in PW pages. You might not need to do this though, it all depends on your application. If anyone's interested, the way I've tackled this before, in outline, is to pre-process the feed and essentially do what horst posted about calculating a hash of the content (personally I don't like crc32 which returns an int but prefer the fixed length strings returned by md5 (which is fine for this - and fast)). Do filter out any feed fields that you don't intend to store before you calculate the hash so that insignificant changes in the feed don't trigger un-needed updates. Anyway, this gives a feed_id => hash_value map for each feed item. If we do this for the feed, we end up with a PHP array of these maps. This array can be stored persistently between each read of the feed. Let's call the previously created map, $prev_map, and the map for this read of the feed, $new_map. You simply use PHP's built-in array methods to quickly find the records that have... Been added: $to_be_added = array_diff_key($new_map, $prev_map); Been deleted: $to_be_deleted = array_diff_key($prev_map, $new_map); Been updated: $to_be_updated = array_uintersect_assoc($new_map, $prev_map, 'strcasecmp'); ...all without having to go to the DB layer with selectors. On the first run, when the $prev_map is an empty array, you'll be facing a full import of the feed - potentially a LOT of work for PW to do adding pages. Even reads of the feed that add a lot of new pages or update a lot of pages could require mucho processing, so you'll need to think about how you could handle that - especially if all this is triggered using LazyCron and takes place in the context of a web server process or thread - having that go unresponsive while it adds 100,000 pages to your site may not be considered good. Finally, don't forget to overwrite $prev_map with $new_map and persist it. * NB: I've not done item 3 exactly this way before (I used array_intersect_key()), but I don't see why array_uintersect_assoc() shouldn't work.
    3 points
  9. Take a look at this post (https://processwire.com/talk/topic/19024-selector-arrays-with-page-reference-fields-with-and-not-or/?do=findComment&amp;comment=165462) and the rest of the thread. I really like the concept of selector arrays and they can make things much more readable and avoid concatenation stuff, but currently they can be a little tricky to get things how you want. Hope that helps.
    2 points
  10. https://modules.processwire.com/modules/limit-repeater/
    2 points
  11. It was a z-index issue and should be fixed in v2.0.2, thanks for reporting.
    2 points
  12. Will do. With no other confirmed replications yet, I'm wondering if it's a server config issue, although I've no idea what that may be. Thanks Edit: just seen Soma has replicated.
    2 points
  13. It's replicated on two servers, one running PHP 5 and the other PHP 7. It's also replicated in Chrome on a Windows machine, so it doesn't seem to be a Linux browser issue. The only other thing to try is a different internet connection. Thanks
    2 points
  14. @modifiedcontent Maybe this is similar to and this issue https://github.com/processwire/processwire-issues/issues/650 which was recently fixed at https://github.com/processwire/processwire/commit/a1676b0adb3bb7877d0602e1ab1929fd5aff73d4 You might need to download and update Processwire to the latest dev commit? Hope that helps
    2 points
  15. Thanks! I will probably do minor cosmetic changes to the code if I can get ESLint work with VSCode, but feel free to modify it if you find something.
    2 points
  16. Thanks @tpr - very generous of you to spend your time doing this! The ".pwcmb--top_push" class is no longer used - it was an option but it never seemed to work, so I removed the config option but never got around to cleaning up the other parts - thanks. Agreed, I don't see that cookieMonster.cfg.block being used anywhere. I have tasked someone else with testing this version - making sure all the GTM events fire as expected, along with the basic functionality, but if anyone here also wants to check, that would be awesome. Once we're sure everything is working, I'll incorporate into my repo (I'll get you to do a PR). Thanks again for this - I am sure many folks will be very appreciative of this new version!
    2 points
  17. In this example, if you already know that you need one field type multiple times, you could just use a repeater field. Inside this repeater field you could repeat a textarea field and maybe a page title field for better labeling the repeater items. That would be three fields in total instead of maybe 50. ? I know it is not always that easy but repeaters and the repeater matrix is one possibility to reuse fields on the same template. You could shorten this to: <?php if ($page->texarea_number_3): ?>
    2 points
  18. Hi @ren If this is a repeatable problem, please consider opening an issue for it over at processwire/processwire-issues. Thank you.
    2 points
  19. $mostRecent = $pages->find("parent=123, template=news, sort=-modified, limit=3"); foreach($mostRecent as $teaser) { echo "<h3><a href='{$teaser->url}'>{$teaser->title}</a></h3>"; } 123 is simply the id of the parent page, under which your news/blog pages live Read more about selectors: https://processwire.com/api/selectors/ And keep this bookmarked: http://cheatsheet.processwire.com/
    2 points
  20. Thanks @netcarver for the detailed line. Horst's approach worked really well with a very small feed, and I was learning how to make a module to potentially handle this. I was hopping to tap into a cron job to handle the updating/adding at a specific time, like midnight every night, but maybe lazycron might work inside the module. I havent done much research into actually hooking into lazy cron within a module and getting the module to perform the functions similiar to horst's example above. However, you make a good point regarding page size. I believe max I will be dealing with maybe 500 to 600 max (though could be as low as 200). I would say I am getting a lot better with php as my background is in front-end, but I am enjoying the learning process. Since the items will have a status (new, used, or sold), I was thinking that I could potentially write a function to trash the items marked as sold after a 24 hour period and empty the trash. Well, this was my thought earlier in my pre-planning stages.
    2 points
  21. You haven't heard but it's there, we've been there. It's some weak point of PW. A template with 50 fields and you output the data you end up having 50+ queries just for one page. Every echo $page->yourfield does a DB query. If you list or render other data from other pages etc, you can easily have 200+ queries just for one page. It doesn't all scale well especially with lots of fields and stuff going on. Add with heavy traffic and you end up in performance problems very fast for a complex site (PHP & mySQL not being the fastest). Caching is one thing, but sometimes you can't cache everything, because you have logged in users etc. Edit: Just because you haven't heard, doesn't mean it's not there. Ryan also sometimes has this misconception, that if he doesn't know/hear about it, it's not existent. Most people don't always tell, they just move on. ?
    2 points
  22. Hello @DarsVaeda, I always try to reuse as many fields as possible so I don't end up with too many fields. I usually make one field for a textarea, a text, one image, multiple images etc. Tagging them as mentioned helps you to keep them organized. If you ever need multiple fields of the same type in one template, you can always make specific fields, but most of the time you can avoid this by using general fields. I know this is just an example, but why would make fields for a form in the first place? Will the titles or placeholders of the inputs change and therefore should be dynamic? For this you could try the commercial module FormBuilder. But I think it is unlikely that the form will change much and therefore I would define everything inside the template. ? Regards, Andreas
    2 points
  23. With PW this is only possible for subdomains. $this->config->sessionCookieDomain = '.example.org'; This setting includes: example.org subdomain.example.org
    2 points
  24. Just to clarify: Usually there is only one instance/ object of ProcessWire which is the ProcessWire boot object represented by the variable $wire. ProcessWire is a child class of Wire. Assuming you are talking about all Wire objects the answer is YES and more: // Access to a wire object from inside a wire derived class: $pages = $this->wire('pages'); // Access to the current ProcessWire instance: $wire = $this->wire(); // Create new wire object inside your ready.php $this->wire('ferry', '/site/translations.php'); Read more: https://processwire.com/api/ref/wire/wire/
    2 points
  25. I saw somewhere on Twitter that someone mentioned they were doing something similar with Drupal and http://editor.ory.am/
    2 points
  26. Thanks ? It's a decent start, but I am kinda hoping for some contributions from the community for improving it. It's all available in the docs folder (markdown files) in the repo and anyone can edit and submit PRs. I think a nice Tips & Tricks section would be beneficial, as would improvements to the rest of the docs.
    2 points
  27. Wow, @adrian! I had no idea that you have taken time to create some nice documentation for your module. Great work!
    2 points
  28. Hi all, Introducing a new GDPR Cookie Management Banner module. https://github.com/adrianbj/CookieManagementBanner https://modules.processwire.com/modules/cookie-management-banner/ This module was sponsored by VentureWeb in Squamish, BC, Canada. I converted a Drupal module written by Oliver Walker from VentureWeb into what you see here. The Drupal module requires jQuery so at the moment, this module also requires jQuery. I will probably remove this sometime soon. This module certainly has similarities to MarkupCookieConsent but provides the user with the following features: The user can accept all cookies or they can choose to not accept tracking/marketing cookies. Module config options allow you to: define all text and button labels (multi-language support) manually increment the cookie policy version which forces the user to review their consent again select whether users can manage their cookies, or just accept all option to limit display of banner to users only in European Union (by IP address) position selection (top or bottom overlay, or content pushed down from the top) It comes with basic default styling which is easily overwritten by site CSS The module sets various values to the dataLayer array which works together with Google Tag Manager - please read through the code in /assets/js/CookieManagementBanner.js to get a better idea of how this works and what is made available for GTM. You can wrap your tracking/marketing cookie code in a check for the localstorage key of: pwcmbAllowCookies if(localStorage.getItem('pwcmbAllowCookies') == 'y') You can also provide a link on your site (probably in the footer) like this that will allow the user to show the banner even after they have saved their preferences / accepted. <a href="#cookies" class="js-pwcmb-notice-toggle">Manage Your Cookies</a> Would love to hear feedback from anyone who gives this a go.
    1 point
  29. Don't know about the selector arrays version but here is a selector string version: $selector = "template=facility"; foreach($arr_words as $str_word) { $selector .= ", title|facility_jobs.facility_job_title|facility_jobs.facility_job.job_title%=$str_word"; } BTW, when I have a load of fields I need to search across I often find it preferable to use a Pages::saveReady hook to populate a hidden "index" textarea field with the merged text of the other fields in that template and then just search that index field.
    1 point
  30. Or Bitbucket Snippets if you have an account there. ?
    1 point
  31. I can also reproduce, but not always... Chrome on windows, PW 3.0.108, default admin theme and uikit . Also, when you restore a page from trash, the count of the children is not updated.
    1 point
  32. Once I made a nice Fieldtype for this. Please try out http://modules.processwire.com/modules/fieldtype-button/
    1 point
  33. @adrian I've jshinted and formatted the code, you can update the test module if you wish.
    1 point
  34. Sounds to me like a good option is the RuntimeMarkup module, so you can basically render whatever you want in the inputfield, and add the necessary javascript to do the whole copy-paste to clipboard.
    1 point
  35. Awesome thanks - this has been a useful lesson ? I think my inital confusion on this stemmed from my hook function being my own code and not part of PW, but I guess as it is an extension of an existing class then it makes sense the other variables should be accessible. (I may be rambling here... but I know what I mean!).
    1 point
  36. Concretely, what is the downside to have a lot of fields ? In a setup I have 12 templates and 56 fields (not optimized) and reading the link given by @bernhard I fear your answer now ?
    1 point
  37. By the way there is template context for fields. By default, there are not many options that you can override, but by setting advanced=true you would be able to override all options. https://processwire.com/blog/posts/pw-3.0.87/#new-field-template-context-settings
    1 point
  38. That does sound like a lot of fields. Why is it that the fields can't be reused? You do realise that you can set things like label and description (and loads more since this update) in template context? So you can have a field "text_1" and label it "First name" in one template and "City" in another template, etc.
    1 point
  39. So I don't really get your question. For a customized input in general you need a customized field. You can tag them, then they are grouped in the fields list. You can also use https://processwire.com/api/modules/profields/textareas/ and you can read the blog post here: https://processwire.com/blog/posts/making-efficient-use-of-fields-in-processwire/
    1 point
  40. TracyDebugger's Console Panel - https://adrianbj.github.io/TracyDebugger/#/debug-bar?id=console
    1 point
  41. That should work just fine:
    1 point
  42. From the API side it is still valid and working code. I don't think there is one best way to go. This tutorial shows one possible approach. There are many different other approaches possible. But at least it shows the basics of implementing a REST API. You can also have a look at https://modules.processwire.com/modules/rest-api-profile/ which is the most recent approach I'm aware of.
    1 point
  43. Tough question ? Have you seen this module? Edit: or this one as another related alternative:
    1 point
  44. Not new, but a website I've worked on for a year or so in continous development. http://supercarownerscircle.com/ I originally inherited the site from another web design company - upgraded PW and over the year added ecommerce using the Stripe module and a custom integration, revamped the frontend and added lots of new templates. Also did some frontend work on the shopify shop.
    1 point
  45. thx, that's a perfect solution i didn't know about ? Of course that would be the best option, but I don't think many people will need it anyway... I prefer the array syntax nowadays.
    1 point
  46. Just to follow up on this - if you still feel like converting it to pure JS, I'd been keen to maintain that new version. I don't have the need or motivation to do it right now, but I can imagine that I may want it in the not too distant future. It doesn't sound like the Drupal version will end up being converted, but at this point in the development of the module, I think that's ok. If it receives any new killer features I'd be happy to port them over myself. Let me know if you're still on board. Thanks!
    1 point
  47. If I enable "Disable filename truncation for File fields", the download icon is missing. I also have enabled Asset download button and Move to first/last buttons).
    1 point
  48. This does work: $tmpls = $templates->find("tags=myTag"); $result = $pages->find(template=$tmpls");
    1 point
  49. Also, you can remove the current page from the array to avoid the IF check inside the loop $results = $pages->find("tags={$page->tags}")->remove($page)->shuffle(); Or, do the same as above with one less method: $results = $pages->find("id!={$page},tags={$page->tags}")->shuffle();
    1 point
×
×
  • Create New...