Jump to content

froot

Members
  • Posts

    707
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by froot

  1. …that was key, because putting it on config.php doesn't do anything. It's like: you had one job!! Thanks, looks like you were right again after all, kind of ?
  2. thanks, I tried, but doesn't help. Also I can tell the issue doesn't seem to be the database because content from the db with äöüß gets displayed correctly, it's just the date, in German that'd be März (for march) that is displayed wrong. So I understand I don't need to fix the database, just tell php that it should be UTF-8 somehow, it seems to miss that part somehow since I moved some files around. Also, there's supposed to be a php header (?) like… header('Content-type: text/html; charset=utf-8'); I put this in the <head> also tried to include it earlier, in _init.php and even earlier in ready.php, doesn't help either.
  3. it wasn't hooks either. I fooled around a bit more and realised that it has to be the code that runs on the server to create the ajax response text. I replaced the entire code with just a simple echo command which was super fast, that's how I knew. But for some reason, it's faster now, even with the code, I'm not sure what exactly got it to work. Anyways, hard to say how to improve the code, I use a foreach loop with certain if-conditions to filter instead of proper PW-selectors. Here's my code: $year_start = $y.'-01-01'; $year_end = $y.'-12-31'; $year_overview = new WireArray; foreach ($all_events as $ae) : if ($ae->date_start<=$year_start && $ae->date_end>=$year_start && $ae->date_end>=$ae->date_start) : $year_overview->add($ae); elseif ($ae->date_start>=$year_start && $ae->date_end<=$year_end && $ae->date_end>=$ae->date_start) : $year_overview->add($ae); elseif ($ae->date_start<=$year_end && $ae->date_end>=$year_end && $ae->date_end>=$ae->date_start) : $year_overview->add($ae); endif; endforeach; echo table_events($year_overview); The code works fine. That said, I also still don't know how to save the variables in the in-memory database and then just access and filter what's in that memory instead of fetching from the database every time anew, I guess that would speed things up as well? Where can I see what's "in-memory", Tracy Debugger? https://processwire.com/talk/topic/6246-table/?do=findComment&comment=207312 More importantly, I'm facing another problem now which I didn't have in my previous setup, which is that Umlaute äöü don't get displayed correctly, instead I see this stuff: ���. I read online that it has to do with the database of which the collation is set to "utf8_general_ci" when it should be "utf8mb4_unicode_ci"? But I have doubts because it used to work before and I would rather not fool around with the database at all. Need to fix this quickly, it's live… Thanks for help
  4. I'm using TracyDebugger but it's a jungle to me, not sure how to use it efficiently. Google PageSpeed Insights can be useful though. I will check the hooks then. Thanks so far.
  5. do you reckon using json-encoding would speed things up? PW is so proud of being so fast, here it fails ?
  6. OK I re-activated the automatic inclusion of _main.php on the template settings, added $this->halt(); // also tried with return $this->halt(); makes sense and it does the same, so much so that it's not faster either.
  7. Thanks for the suggestion, however I don't use json output, it's just a php code that is called, that renders html markup. Not sure if that's the issue.
  8. is it a cache problem? some bottleneck? some redundant code? no idea how to even start, tracy debugger is not helping either.
  9. I now got it working like this: I exclude the _main.php (which includes the _head.php and all) on the template settings. I then create an if-condition on the template file, dividing the content as follows <?php namespace ProcessWire; if (!$config->ajax) { // here's all my static stuff echo '<div id="content">'; echo '<div id="dynamic">'; // place for the ajax response text by replacing the innerHTML echo '</div>'; echo '</div>'; ... include 'includes/_main.php'; } and else { // here's all my ajax loaded code/content from the server } lastly, I put: <script type="text/javascript" src="path/to/my/javascript.js"></script> My AJAX request looks as follows function getContent() { var xhr = new XMLHttpRequest(); if (xhr) { xhr.onreadystatechange = replaceContent; xhr.open("GET", "./?some=variable&someother=variable, true); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.send(null); }; }; function replaceContent() { xhr.readyState; if (xhr.readyState == 4 && xhr.status == 200) { var str = xhr.responseText; document.getElementById("dynamic").innerHTML = (str); }; }; It works, like it did before, except that now it is very slow. In my console I think I can see that the request gets sent quickly but the server takes about 5 seconds to respond so it's mostly waiting. I tested on my local MAMP machine (which is always slower) and live server, both have the same problem. So the TTFB is 4.51s, if I put the ajax-requested file in the root folder (as described in the the initial thread) I have a TTFB of 775ms thoughts?
  10. thanks @Jan Romero works like a charm. I wonder if that is best practice to jump in and out of namespaces, but I guess it doesn't matter. Also curious why that namespace declaration is necessary, cause I have created my own functions before, no problem. And, again, wondering how you know this and how I could know something like this without having to ask.
  11. actually the following would help me a lot if it worked, don't know why I didn't consider it, it's simple enough as it is. https://www.w3schools.com/php/php_callback_functions.asp But weirdly, if I use the code of the last example (user defined function) in PW, I get an error: Call to undefined function exclaim()
  12. now it works, thanks @Jan Romero May I ask how you know that?
  13. I know it looks and sounds simple but it doesn't work. As soon as I echo what I ->render(); the entire page breaks. It returns the entire page inside the <content> tag and inside that one's <content> tag it renders the entire page and so on. I'm using markup regions, I guess that's an issue…
  14. I tried with foreach ($items as $item) $out .= $item->render('somelayout.php') as well, to no effect. Correct me if I'm wrong. This the one that uses a simple array. So I turned to MarkupPageArray, which is the name of the module, ->renderPageArray() is its method that works for PageArrays (as the module name claims). None of the above work for me but completely mess up my layout. Just use foreach like you propose is not as simple as it sounds and the workaround that is needed to make the method that is build around normal php arrays work for wire arrays as well defeats the purpose of why I'm even here. I have a working solution with dozens of ifs and elses, just thought I could find a more elegant, scalable and straightforward solution instead.
  15. // somelayout.php echo $page->title; // somewhere else $items = $pages("template=posts, limit=10"); $filename = 'somelayout.php'; // inside /site/template/ $out = ''; $out .= $items->renderPageArray($filename); // module is installed echo $out; // result: nothing whatsoever.
  16. @Jan Romero so it doesn't work with PageArrays or WireArrays? just with regular php arrays? that's unfortunate… your code returns syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')'
  17. hm… maybe I didn't make myself too clear. So let's say I have an PageArray $items that should get a specific markup aka layout. Let's say the markup is something like… <li> <h3><?=$item->title?></h3> <p><strong>price: </strong><span><?=$item->price?></span> <p><strong>category: </strong><span><?=$item->category?></span> <p><?=$item->body?></p> </li> would I loop through the $items? $filename = "somelayout.php"; foreach ($items as $item) : $out .= $item->render($filename); endforeach; echo $out; or just do: $out = $items->render($filename); echo $out; Don't know why I ask this because both doesn't work but maybe this gives you an idea of my thinking.
  18. Yes, our provider actually does seem to block it at least when using Authentication, regardless of whether or not I "allow" sending without. And that's good, I must say I always found it strange that it's possible in theory to send an email from whatever email, given the right insecure email server. Yes, thanks, I found the ->replyto() method and it works like a charm. Just wondering now, I agree noreply@ is a very good practice, but since WireMail needs to be logged in with the sender's email-account, I need to create a noreply@ email-address and mailbox on my email-server? Thanks so far
  19. OK I just realised that an email send via my contact form only go through when $email is the actual SMTP-user's email address $m->from($email, $fullname); So I understand that by enforcing authentication when sending an email, the ->from email needs to be the authentified user's email. Thus the email that I receive can't and won't have the user's email. That's only possible with a connection without authentication? So I need to include the email somewhere else, in the email's body? So "replying" is not possible as such. Is my assessment accurate?
  20. What's wrong with my code? It just won't send emails. It worked before when not using wiremailSMTP but now it stops. This is used in a contact form. It has to be the code because when I run a test in the module, it works fine and the email reaches me. Even the Promailer-Newsletters using WireMail SMTP work fine now. Even when I put some debug code on the template to be send to me via email with every email, that email reaches me. But somehow the email in question, send with contact form does not. BTW if-condition works fine cause redirection works as well. Here's my code: if (isset($_POST['sendform']) && $captcha->verifyResponse() === true) : $givenname = $input->post->text('givenname'); $familyname = $input->post->text('familyname'); $fullname = $givenname.' '.$familyname; $fullname = ucwords($fullname); $email = $input->post->email('emailaddress'); $subject = $input->post->text('subject'); $message = $input->post->text('message'); $m = wireMail(); $m->to('myemail@mydomain.com', 'my Name'); $m->from($email, $fullname); $m->subject($subject); $m->body($message); $m->send(); $session->redirect($pages->get("/kontakt/danke/")->url); endif; I recently installed a SSL certificate on the webserver, but that should be irrelevant, right? Further settings: port: 587 Allow Connection without Authentication: no SMTP User and SMTP Password provided Use Start-TLS: no TLS Crypto method: 1.2 Use SSL: no Allow self signed certificated: no Thanks for help!
  21. I always thought you can exclude the _main.php file when you include index.php or something. On some page I do an AJAX-call and with the response text I replace the innerHTML of some div. I put the code that is requested via AJAX on a php-file that I put in the root folder, otherwise it also includes the "head" part which is included on _main.php so I would have the entire page inside the mentioned div, which is of course not what I want. This works fine. However, I'd like to clean this up a bit and make use of: if($config->ajax) : … ; else : … ; to either only include the header when it's not an ajax request or exclude them when it is. But include index.php doesn't seem to work. I tried to disable including of _main.php on the template settings and then do if ($config->ajax) : $config->prependTemplateFile = 'includes/_head.php'; endif; But that doesn't do anything. What am I not getting?
  22. thanks @Macrura It's a good start, but still not ideal. Like I said, technically pretty much exactly like the image-tags functionality when you check User selects from list of predefined tags + can input their own So it's possible in theory, I just need it to work for an only-text-field.
  23. I need a field that behaves somewhat like the native image tags field. What I mean is you can predefine values in the field settings, and then, when editing a page with that field, you can select those predefined values but also enter custom values. Is that something that exists already or should I go ahead and try to create a custom field type?
×
×
  • Create New...