Jump to content

Jan Romero

Members
  • Posts

    695
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Jan Romero

  1. The method get() returns only one page. Your code is looking for a page with the path /case-references/. If this path doesn’t exist on your site, you will get a NullPage. You can check if you got a NullPage by testing for $references_parent->id === 0 or $references_parent instanceof NullPage. Because you only get a single page from get(), your variable $num will always be 0, as page objects don’t have a count. To find multiple pages, you should use wire('pages')->find(). Unfortunately it is unclear which pages you want exactly. I’m guessing you want all the children of /case-references/. In that case, try wire('pages')->find('parent=/case-references/'). You may also want to specify the template of the pages you’re looking for. Also in your first line you are testing whether $page->id is false AND $page is unpublished. That seems like an unlikely combination, because the NullPage is usually published.
  2. While Praegnanz do use ProcessWire in some of their projects, I doubt Computerbase.de is among them. Here is a German blog post about the project, where they say they were only responsible for the frontend design: http://praegnanz.de/weblog/computerbase-workflow Gerrit van Aaken of Pragenanz is one of the best-known German web developers and he occasionally posts here in the PW forums.
  3. Of course you can totally roll your own table and SQL, but the “ProcessWire way” would be to have a Review template and a separate page for each review. There are a couple of different ways to model the relation between reviews and their pages, the simplest being just making them children. So you’d have --Listing (?? or whatever) ----Review 1 ----Review 2 If you don’t want to pollute your page tree with this, and/or have the convenience of editing reviews directly from the page edit screen, you may use a page field, a page table field, or possibly a repeater field. PageTable would probably provide the nicest UI for editors, if that’s a concern. If you’re interested in accessing the database, these threads about the $db variable may also be of interest: Functions/methods to access the DB? Reading and displaying data from a custom table
  4. Hi mattcohen, since you specifically asked about “more control over the results other than using foreach”, I’d like to add to the responses above that you can absolutely sort, modify, filter the results you get from find()! What ProcessWire’s $pages->find() gives you is a special kind of array object called PageArray. PageArrays have a number of methods detailed in the ProcessWire Cheatsheet. If you need to sort the gyms from your example by location after finding them, you can do this: $gyms->sort('location'); //Sorts ascending. For descending prepend a "-" like so: sort('-location') This may be useful if, for example, you want to output the same list of gyms twice. Once sorted by rating and once by location, perhaps. You can also use find() on an existing PageArray. Maybe you want to show all gyms, but feature the three top rated ones above. You may do something like this: //Find all gyms sorted by location $gyms = $pages->find("parent=/gyms/, sort=location"); //Copy the 3 with the highest rating into $top_three (another PageArray) //No need to go to the database again, because we have $gyms already $top_three = $gyms->find("limit=3, sort=-rating"); foreach ($top_three as $top) { echo "$top->title: $top->rating Stars"; } foreach ($gyms as $gym) { echo "$gym->title in $gym->location"; }
  5. 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
  6. 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.
  7. 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?
  8. Jumplinks can handle this. I’ve had the same problem recently. I do also think ProcessWire should 404 these kinds of URLs, though.
  9. 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?
  10. 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.
  11. 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.
  12. 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.
  13. 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?
  14. $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);
  15. 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 ==.
  16. 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
  17. 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…
  18. 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
  19. 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.
  20. 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?
  21. 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.
  22. 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…
  23. 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..
  24. It is thanks to Horst. http://modules.processwire.com/modules/page-tree-add-new-childs-reverse/
  25. 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']}"
×
×
  • Create New...