Jump to content

Jan Romero

  • Content Count

  • Joined

  • Last visited

  • Days Won


Jan Romero last won the day on February 22

Jan Romero had the most liked content!

Community Reputation

461 Excellent

About Jan Romero

  • Rank
    Sr. Member

Profile Information

  • Gender
    Not Telling
  • Location

Recent Profile Visitors

13,893 profile views
  1. If you have the Apache module, I suppose the most efficient way is X-Sendfile. IIRC it would look something like this, but I’ve never done it because it’s not available on my shared hosting: header('X-Sendfile: ' . realpath($file->url);
  2. This thread isn’t my place at all, but Gadgetto’s post you quoted tells me you need to copy the file _uikit.php from the regular site profile and somewhere at the top of your own template call include_once('./_uikit.php');. Should be a safe fix for that specific error.
  3. Agreed. Reading the last page of this thread I was surprised this wasn’t already the case. Could be as simple as just taking a custom selector string instead of the current current single page dropdown. I suppose the idea was to have something very robust for users, since it can show up in individual page settings.
  4. From cursory googling it seems jquery doesn’t support modifying the headers sent by load() specifically. This answer on SO has a somewhat messy solution that is discouraged by the jquery docs: https://stackoverflow.com/a/20067394/. Probably best to just use ajax() and select the elements yourself.
  5. I think it might help to know what exactly you’re requesting. Some admin pages respond to ajax-requests with JSON and some with partial HTML. I just tested /processwire/access/users/edit/?id=40, which gives the full HTML page without ajax and a partial with ajax. As you said, PW detects ajax requests by the X-Requested-With header, so if you don’t send it or set it to something other than XMLHttpRequest, it should give you the same response you would get when navigating to the url in your browser. So, for example on the url I mentioned this works for me: $.ajax(window.location.href, { headers: {'X-Requested-With': 'justgivemethedanghtml'}, success: function (result) { console.log(result); } }) I suspect commenting out the line in ProcessWire.php didn’t help because the header is checked again in other places. The culprit is probably ProcessController.php: https://github.com/processwire/processwire/search?l=PHP&q=XMLHttpRequest. But obviously you can’t just comment that stuff out in production anyway. Just make your request pretend it isn’t ajax.
  6. In general, page urls following the page tree is The ProcessWire Way™, and it’s a pretty good idea, so I’m not exactly advising you to deviate from that, but if you want to do it, it might be worth considering the other way around: /home/ /books/ /the-hobbit/ /the-very-hungry-caterpillar/ /the-luzhin-defence/ /categories/ /non-fiction/ /graphic-novels/ /really-graphic-novels/ To make your life easier you could even hook Page::path to change the urls of categories to what you want, but you don’t have that from me. (Actually, fooling around with that I just discovered a bug in a urlSegment validation regex, thanks!)
  7. uh dunno, config.php worked for me, sorry. where did you put it?
  8. try putting this somewhere like config.php or something. setlocale(LC_ALL, 'de_DE.utf8');
  9. I’m not certain I correctly understood the problem, but in general it will save you some headaches if you set up the page tree according to the canonical urls you want. What should be the canonical urls for specific books and specific categories? If you want a The Hobbit’s $page->url to be /books/the-hobbit and the fantasy section’s to be /books/fantasy, go with the mixing! If you want every book to have sort of a primary category, put each book under a category. Then it’ll be /books/fantasy/the-hobbit. You can still have /books/the-hobbit by using urlSegments, but you’ll obviously have to watch out for books that have the same page name as a category. And you will have to generate those links yourself somehow. I suppose you should also ask yourself if you really need the same page to be accessible by different urls?
  10. You might be interested in the new “preload module“ feature: https://github.com/processwire/processwire/commit/c4d301a40530cfa3b00ce559a14757684625a5ce But you still won’t get around what Zeka said, I guess. Can’t you just take the time in your module’s init()/__construct()? That should be the earliest opportunity for a module to do anything anyway.
  11. put this in your head tag <meta http-equiv="content-type" content="text/html; charset=utf-8" /> and make sure your PHP files are UTF8. VS Code tells you in the status bar. Notepad++ has “Encoding” in the menu bar. Make sure it isn’t UTF8BOM. Is $all_events the contents of a FieldtypeTable? How much stuff is there to iterate? If you fetch a large amount of data just do discard it, it might be worthwhile to move the filtering to the database. Also if you just want all events that interesect the year somehow, you can do this foreach ($all_events as $ae) if ($ae->date_start <= $year_end && $ae->date_end >= $year_start && $ae->date_end>=$ae->date_start) $year_overview->add($ae);
  12. You’re not jumping in an out of namespaces in that sense (you could do that if you wanted to get really freaky). As long as you’re in the ProcessWire namespace, any function you declare belongs to that namespace. Since you’re inside the namespace anyway, you can call them without specifying ProcessWire\myFunction(), but apparently PHP’s dynamic features like call_user_func() need you to be more specific. I don’t know this per se, it’s a combination of googling and talking out of my bum bum, lol, so I’m probably getting a good amount of technicalities wrong. Here’s a link to the PHP docs about it https://www.php.net/manual/en/language.namespaces.dynamic.php.
  13. @ryan Thank you for the continued effort you put into PW and the quick solution to LMD’s problem, which bit me too for a second 😄! I just noticed there still seems to be an issue with the join/field selector. If used with pagination it appears to add the limit/pagesize to the total number of results, which distorts pagination. One too many pages are shown, the last of them being empty. For example, I have this selector: template=show, datum>=2019-01-01, datum<2020-01-01, has_parent=1234, sort=-datum, limit=50 With the join fields getTotal() gives me 102, without only 52 (one show per week, makes sense). Interestingly, on the second pagination page, getTotal() will say 54 (?!) and the superfluous 3rd page disappears.
  14. You’re in ProcessWire’s namespace, so if you paste the code you linked, those functions will actually be ProcessWire\exclaim() and ProcessWire\ask(). You can call them like this: printFormatted("Hello world", 'Processwire\exclaim'); printFormatted("Hello world", __NAMESPACE__.'\ask'); Or alternatively, you can add the namespace in printFormatted: function printFormatted($str, $format) { // Calling the $format callback function echo (__NAMESPACE__ . '\\' . $format)($str); } Or you could declare exclaim() and ask() differently. For example by putting them in a class or in an include file with a different/global namespace.
  15. Excellent question, because the documentation on it is a little stupid. The information is here: https://processwire.com/api/ref/page-render/render-page/. Although if you really want to see what’s going on, you can look at the code directly: https://github.com/processwire/processwire/blob/master/wire/modules/PageRender.module#L399. One would expect this to show up in the documentation for the Page class, but there isn’t even a link… The reason it’s a little convoluted is that the render method is added by a Module as a Hook, so I guess it doesn’t technically belong to the Page class. Maybe it’s not really supposed to be used that way. You wouldn’t have all that trouble with append files and cache using LMD’s method. However, you would need to pass your $item to it somehow (for example $files->render('yourfile.php', ['item' => $item]);).
  • Create New...