Jump to content

Jan Romero

Members
  • Posts

    612
  • Joined

  • Last visited

  • Days Won

    15

Everything posted by Jan Romero

  1. My occam’s razor guess would be that PW couldn’t have anything to do with this at all, since it’s all server side, while Chrome only gets to see the final product. So it would have to be some local caching that Chrome does on its own. This admittedly dated SO thread shows a couple of settings that may be of interest: http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development
  2. There is this module by Ryan. Sounds like that’s what you want. Using the visibility setting to hide a field is probably a bad idea, because that will only hide it client-side with JavaScript.
  3. Isn’t it just this? $out = array(); foreach(Page::getStatuses() as $status=>$value) { if ($page->status & $value) $out[] = $status; } return $out; That should return an array with all statuses set for $page, right?
  4. Jumplinks can handle this. I’ve had the same problem recently. I do also think ProcessWire should 404 these kinds of URLs, though.
  5. I just ran into an issue with ProcessPageLister that has been addressed in this commit, but still persists for me. Non-Superusers can’t find unpublished pages in the Lister (nor via the search box in the menu), even if they themselves unpublished them in the first place. The user can view and edit the page because his role has all permissions on the root-page template, but Lister doesn’t seem to account for inherited access. TBH I don’t understand why Lister checks access at all, considering there’s nothing stopping anyone from seeing unpublished pages in the page tree anyway, whether they can edit them or not? Or am I doing something wrong? @Beluga: I can’t reproduce this here. Are you using any modules that manipulate field markup?
  6. Are you aware of this? What do you need help with specifically? You should be able to feed Instagram’s API URLs into $wireHttp->getJSON($url) and get the requested data back as an array. See here for more info.
  7. As long as you don’t need to physically store the files in one central directory, I’d create a page that accepts the file names as urlSegments, and serve them from there. The file names would have to be unique anyway for your proposal to work, so you should have no problem fetching them. The only problem would be that this solution does not guarantee unique upload file names, because the files would still be in separate directories. You could ignore this or hook into the file upload somewhere to make sure. E. g. you may do this: $filename = $sanitizer->selectorValue($input->urlSegment1); $p = $pages->get('images=' . $filename); if ($p->id > 0) header('Location: ' . $p->images->get($filename)->url); else throw new Wire404Exception(); die(); Bit crude but you get the idea.
  8. On the edit page of the user role, below the checkboxes, it says: To do this, go to Setup→Templates and edit one of your templates. To keep it simple, you may choose the template of your Frontpage, as all other pages will inherit the permissions you set here. In the Access tab, check page-edit for the roles of your choosing.
  9. The maximum function nesting thing reeks of recursion. Maybe one of your widgets tries to render itself or some other page that also has this widget? Perhaps inside a prepended/appended file? Is _main.inc auto-appended?
  10. $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; $u = $users->get($username); if($u->id && $u->tmp_pass && $u->tmp_pass === $pass) { ... } $u = $session->login($username, $pass); This is where you try to find the user by the submitted name and then check if you got one by seeing whether $u->id is 0. So what you want to do is, if you didn’t find a user with that name, assume that an e-mail address was submitted instead, and check that: // Get user by the input name $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; // (password is irrelevant for this, so we don't have to repeat it below) $u = $users->get($username); if ($u->id == 0) { // no user was found, so let's do the same thing, only // this time, treating the input as a mail address $usermail = $sanitizer->email($input->post->username); $u = $users->get("email={$usermail}"); // select by matching the mail field } // Now do the same checks as before and see if // the user was found after all if($u->id && $u->tmp_pass && $u->tmp_pass === $pass) { ... } // log in with $u->name, the name of the matched // account, instead of $username. If only the NullUser // was found, this will be an empty string. $u = $session->login($u->name, $pass);
  11. Hi Jonah, welcome to the PW community! Your issues mostly seem to pertain to PHP, not ProcessWire specifically. To answer #3, you are correct in that there is no special ProcessWire syntax. In the code you show, there is nothing really “PW-specific”. What ProcessWire does here is provide you with variables you can use in your template, namely $page to access data related to the requested page. The PW-specific knowledge you need is not of syntax, but of those variables, their classes and their methods. In the example, you need to know what kind of object the field image_details is, so you can know to access it with foreach. In #1, be aware of PHP’s assignment and equality operators! In your if condition, you want to compare values, so you must use == or ===, but never =! You should also wrap the conditional blocks in {curly brackets}. It is not necessary if you only need one statement, but good practice if you ever need to add some more. Since it is a PHP question, I’ll let StackOverflow explain the difference between 'single' and "double" quotes: http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php Basically, it doesn’t really matter, but double quotes give you more functionality. I assume #2 is related to #1 in that you have overwritten $page->title with the string "home", because you used the assignment operator = instead of comparing with ==.
  12. I’m not familiar with Sublime Text, but this seems to be a problem of both your phone and Sublime Text not honoring Unicode guidelines (check this out), albeit in different ways. Sublime Text doesn’t show you the problematic character at all and your mobile browser shows a missing glyph symbol. Try viewing your code sample from the first post on your phone. You’ll see the same rectangle right behind the closing PHP tag ?>. Sublime Text should have a view mode that shows invisible white space characters (like tabs, spaces, and your 2028 separator). If you turn that on, you should be able to delete it easily You have run into the same issue as this guy. That is to say, it’s not ProcessWire inserting the symbol
  13. This one has always annoyed me too. I still find myself middle-clicking page titles in page tree and page list, trying to open multiple edit tabs. Then when I’m done they’re all just page trees…
  14. You have a unicode line separator (U+2028, E2 80 A8) between ?> and </ul>, but your main problem is using Android If you switch your editor to ANSI, it will show up as 
. Obviously, that doesn’t belong there. Just remove it and you’re good
  15. ProcessPageEdit::buildForm returns an InputfieldForm element. So you want to hook after it’s done creating the form using addHookAfter. Then you can get the form element like so: $form = $event->return; Now all you can modify it to your heart’s content. To get the submit button, I think you can simply do $submitbutton = $form->get('submit_save'); Sorry, no copypastable code. I’m on mobile.
  16. I’ve recently had these symptoms after migrating to a different host. Turned out to be a memory shortage when resizing images. You said you checked all the image files. Did you see if there were any corrupted size variations by any chance? Does the problem also affect pages that already have all the necessary variations (or have no images at all)? Have you checked the site’s logs?
  17. This has apparently been disabled because the circular reference lead to problems: https://github.com/ryancramerdesign/ProcessWire/issues/663 One possible solution for you would be to default to $page if no page is selected. Seems intuitive enough for the user, unless you need “no selection” to actually mean “no selection”. Another thing you could do would be to add a “proxy” page somewhere, called “<This Page>”, and check if that was selected, then use $page.
  18. Passwords aren’t stored as plain text in the DB, so that shouldn’t be an issue. If one is worried about leading/trailing whitespace, one might as well disallow that specifically, or routinely trim passwords (and tell the user about it). Plus, we deal with spaces in POST data all the time anyway?! Even this forum allows spaces in usernames, which kind of blew my mind the first time I logged in. I really dig it. I’m a big proponent of long passwords and I feel, calling them “passwords” instead of “pass phrases” was a major mistake, leading to the stupid password policies we see everywhere, when in reality, the best thing you can do is just have a long-ass combination. Personal sentences are great for this. Easily typed, because that’s what we’re used to type, and easy to remember, because unlike cryptic alphanumeric combinations with an obligatory exclamation point at the end, they make sense even without thinking up mnemonics first…
  19. Hi, a draft should be created automatically when editing a page, unless you are a superuser and/or have the permission “managedrafts”. If you see the new page in the admin menu, you're allowed to edit pages without having to make a draft first, so you're not redirected. Try logging in as a less privileged user. I'm doing a little overhaul at the moment, putting the draft relations into the database and adding a couple of things here and there. If you have any suggestions for the admin side, I'm all ears, because I'm not really using it that way, so I have no real direction..
  20. It is thanks to Horst. http://modules.processwire.com/modules/page-tree-add-new-childs-reverse/
  21. Hey man. That’s a huge post and I don’t have a lot of time, but I have a feeling correcting the array keys in $form will fix a bunch of it. For example: mail($emailTo, $subject, $message, "From: $form[email]"); The error message you get refers to the $form part. See what's wrong? email isn’t a thing. You have to give it a string as a key You have the same issue every time you refer to the $form array. Just put quotation marks around it and you’re almost there. The next thing is that the keys you try to access are not the ones you set here: $form = array( 'Nom complet ' => $sanitizer->text($input->post->fullname), 'E-mail ' => $sanitizer->email($input->post->email), 'Message ' => $sanitizer->textarea($input->post->comments), ); So you have to decide whether you want to use $form['Nom complet '] or $form['fullname'], $form['E-Mail '] or $form['email'], etc. Also, watch out for those spaces. They should work fine, if you want to go with those keys, but they’re pretty ugly. Disclaimer: I haven’t read your full post yet :< Edit: By the way, I'm not sure, but it might be that this will not parse correctly: "From: $form['email']" I suspect PHP might stop reading the variable after $form. For better control over complex variables inside literals, you can use curly braces like so: "From: {$form['email']}"
  22. So with your current structure, Folder1 appears under two separate urls. Once under root, and once under /folder1/. To do this in ProcessWire, you can keep the page structure the same way you have shown, with Folder1, Folder2 and Folder3 as children of the frontpage. They are still “neighbors”, or siblings as PW calls them (you can get a page’s siblings by calling $page->siblings()). Since you don’t want to have a dedicated frontpage, you would create a special template for the frontpage and either redirect it to /folder1/, or render Folder1 right there: <?php echo $page->child->render(); //child gets the first child. //this is the entire template. The redirect would work like so: <?php $session->redirect($page->child); //if you put any code here, it will //not be executed. The first option would be more like what you have now, where the frontpage simply mirrors its first child. You can use the same template for other “category” pages, where you don’t need an overview page, but want to go directly to the first item. For completeness’ sake, this would be the full page tree (just add Home at the top): HomeFolder1Page1 Page2 Page3 Folder2Page1 Page2 Page3 Folder3Page1 Page2 Page3 When you think about it, ProcessWire’s approach makes the most sense anyway. Url paths describe a tree, so it’s only natural that there must be a root page.
  23. Yeah, that’s true. It works in Ryan’s example at the beginning of the thread because he calls isLoggedin() before overwriting the $user variable with a normal string (strings in php are indeed different from objects). So, confusingly, in that example $user refers to different things at separate times. He should probably edit the post for posterity.
  24. That’s how callbacks work, but I believe LostKobrakai can’t use a standard callback, because his requests will be asynchronous. So the callback would get executed as soon as all requests have been made, but it won’t wait for the actual responses. For that he’ll have to use events. So either pool the events of the request objects and fire your own event when all are done, or have a single function handling all requests and executing the callback upon completion. @diogo hehe, I’m glad you got that reference %) @Mike Anthony that’s brilliant! I’ll have to save that link
  25. Fun fact about SVGs: Internet Explorer will not scale <img> SVGs properly if they don’t have the viewBox attribute. I’m not sure if it was Inkscape or the optimizer I used, but my SVGs were missing this, and I had to edit it in for IE: width="1024" height="512" viewBox="0 0 1024 512" Without viewBox, the image would remain 1024x512 in IE, but it won’t scale it down and clip it to the <img> tag’s dimensions instead.
×
×
  • Create New...