Jump to content


  • Posts

  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

baronmunchowsen's Achievements

Jr. Member

Jr. Member (3/6)



  1. I'm trying to get the rendered output of a page in a custom module. In my custom Process module, I have the following: public function ___execute() { $page = $this->pages->get(1); $page->of(true); $op = $page->render(); return "Hello World"; } An exception is thrown: The srcset functionality is used liberally to generate the desired output of a page. Any suggestions on what I can do to avoid the srcset error? Edit 1: using MarkupSrcSet module: https://processwire.com/modules/markup-src-set/ - which adds the srcset method in it's ready() function. Is it possible to boostrap this prior to calling the render() function? Edit 2: bypassed the issue specific to the srcset above, it further appears that rendering output is problematic when using MarkupRegions. Title updated and tagged accordingly. Can anyone provide insight into how to retrieve the output of a page using markup regions in the template layer?
  2. @James Morris - reasonably, this would impact any implementations using the ~= selector with terms that contained non-alphanumeric characters (or strictly speaking those that would get removed by words array sanitizer).
  3. OK - pretty sure this is broken since processwire 3.0.160 when a "Major refactor/rewrite of ProcessWire's Database classes" was implemented: https://github.com/processwire/processwire/commit/06acbe57a32e18625248382499bb31527484c315#diff-83091c78a3273da557616affcb670296, specifically, the use of $sanitizer->wordsArray was used to clean the BOOLEAN query value (https://github.com/processwire/processwire/commit/1f293cc4f4092883b4eaf915950ba3c7c5430a7a#diff-83091c78a3273da557616affcb670296R633). The use of this words array function means that "Jul/2021" in the underlying DB query changes to: MATCH(field_event_dates.data) AGAINST('+Jul/2021' IN BOOLEAN MODE)) ) )) (which previously return results) to: MATCH(field_event_dates.data) AGAINST('+Jul* +2021' IN BOOLEAN MODE)) ) )) (which does not find any matches). I'm not sure if the issue of stripping out "\" from ~= searches (and other sanitization via the wordsArray) is a cause for concern generally - or a good thing from a security standpoint? Looking at the use of "~=" in the recurrme module, I'm somewhat convinced that this can be switched to %= without loss of functionality or unwanted side effects (also, performance?) but need to do more testing to tell if this is the case or not.
  4. R.E. 3.0.165 - The issue seems to be with the selectors Recurme uses to find matching events. Currently, all selectors string-match dates using ~= selector. If this is replaced with the %= selector in the recurme module, then I start getting results again. Example - in the ___find method in MarkupRecurme, change ~= with %= When I read about selectors: https://processwire.com/docs/selectors/operators/#contains-words it seems that ~= should be the selector to use - but I'm not sure why it's not working. Not sure if anyone can shed light on that at all. Edit: here's an example of a failing and working selector: doesn't work (no results found - should return results, was returning results prior to 3.0.165): event_dates~=Sep/2020|Sep/2020|Oct/2020,template=event works (get results): event_dates%=Sep/2020|Sep/2020|Oct/2020,template=event
  5. I have a repeater matrix that is used on multiple pages. The repeater matrix contains the following repeater matrix types: quote, hero, text, ... 'quote' is made up of 3 fields: quote_text, quote_source, quote_link I would like to return all instances of the matrix repeater type 'quote' used on any pages. Ideally I would have an array of objects that I could then access the 3 quote fields from. Is this possible within the processwire field/page api? Many thanks for any insights.
  6. Thanks @MoritzLost I implemented similar to as follows, which itself could be abstracted to a function or method: $cache_key = '...some cache key...'; $response = $response = $this->cache->getRaw($cache_key, 120); if(!$response) { $response = '{...some json response...}'; $this->cache->saveRaw($cache_key, $response, 120); } return $response;
  7. @MoritzLost Do you have an example of using your getRaw hook with a function as a fallback (see last example: https://processwire.com/api/ref/wire-cache/get/) In this scenario, the returned value of the function is set as the cache value, but this falls back to the $cache->save where, ideally, it would use the saveRaw. Would you recommend not using the function fallback and instead using getRaw and saveRaw (based on the value returned from getRaw). Thanks!
  8. Awesome - thanks for the notes @MoritzLost and for the direction @BitPoet - will take a look at that and upvote. Cheers,
  9. Thanks for confirming what I had suspected. For anyone interested here's the method https://github.com/processwire/processwire/blob/master/wire/core/WireCache.php#L1229 which is implemented in various places in the WireCache module. For what it's worth (not much likely!) I'd agree that this is indeed being too clever, and suggest that ideally you'd get out of the cache exactly what you put into it, not an interpretation of that data. Cheers,
  10. I have found that if I store a JSON string in wirecache https://processwire.com/api/ref/wire-cache/, I get an array, not a string back... $response = $this->cache->get('mycache', 60, function() { return '{ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } }'; }); First call, when the cache is set, returns a string (expected). Subsequent calls to retrieve cached data do not return a string, but an array (unexpected). Any thoughts? Am I missing something? Thanks
  11. Thanks @Mike Rockett for the help ~ I'll take a look at the mapping collections and use the existing solution for query strings.
  12. Hi there - looking for some support help: Ordering/Prioritization of Jumplinks Is there any way to ensure one or more jumplinks get processed before another: e.g. blog/old-url => new-blog/new-url gets run before - blog/{all} => new-blog/{all} Query Strings Is there any way to ensure that any query string is attached to the destination without having to write a specific redirect e.g. old-page-url?foo=bar => new-page-url?foo=bar I have this in place with the following 2 jumplinks: old-page-url => new-page-url and old-page-url?{all} => new-page-url?{all} but it seems like this should be feasible in one jumplink? Sorry these questions are fairly simple - I feel like I'm missing something staring me right in the face. Thanks
  13. Hi, Wondering if anyone can advise on the following 2 use cases for site running at https://example.com (so $config->httpHosts array in config.php contains example.com) Want to create link to https://subdomain.example.com however cannot do this as example.com is present and so looks for an internal link Want to create a mailto link such as mailto:user@example.com however cannot do this. Changing the site to run at www.example.com solves (1) but does not solve (2). Thanks in advance for any advice.
  • Create New...