Jump to content

ryan

Administrators
  • Posts

    16,715
  • Joined

  • Last visited

  • Days Won

    1,517

Everything posted by ryan

  1. For a field that can contain multiple images, the value of that field is always going to be a type of array. So you'd have to either check to see if there are any items in the array, or try to retrieve the first time like Soma did. Here's how I usually check if there are any images: if(count($page->images)) { // images here } else { // no images } When it comes to a single image field, you are dealing with just one item that is either set or it isn't (rather than an array). You only need to check if it has a value: if($page->image) { // image here } else { // no image } When you use $pages->find(), $pages->get(), $page->children(), etc., you can also find pages that have a given amount of images. So if you wanted to find pages that don't have any images, you could do this: $pages->find("images.count=0"); ...or pages that have one or more images: $pages->find("images.count>0");
  2. This may not be a safe inclusion because it's not specific enough. It's going to search all of PHP's paths for a "pw" dir before it searches the current dir. So be sure to complete that to a absolute or relative path. Absolute meaning a full "/path/to/pw/index.php" or relative meaning one that starts with a dot, i.e. "./pw/index.php" or "./index.php" or whatever it is relative to your PW installation. Also, for your API call, I suggest using wire('pages')->get() rather than $wire->pages->get().
  3. I recommend starting with another language pack, like this one: And then just replace the existing translations with your own.
  4. I don't have experience with PHPmailer, but would guess that the $mail->Send() is failing, since $success never gets set to true. I think the best bet here is to figure out how to retrieve the error message from PHPmailer, as I think that would likely answer the question. Also want to mention that when you finish this up, be sure to run all the fields in your $form and $required_fields through a sanitizer. Particularly any that can appear in email headers like Subject or From.
  5. Thanks for your interest in making this language pack. While I can't help with translation, just let me know anything else I can do to help.
  6. I have the same wish. But this is a little more complex than it sounds, so has to wait until there's time to do it right. However, shorter term the intention is that one can use an image field in a repeater to achieve something similar.
  7. ryan

    Voetvolk

    Nice work Sylvio. Quite an interesting and unique site! Why PW 2.1 and not PW 2.2?
  8. Thanks Robert. It looks like we had a bug where the multi language fields expected you to have more than 1 language before you started using multi-language fields. I fixed this and posted the update per your GitHub report.
  9. You are doing a great job of learning the PHP basics and asking all the right questions. Unlike what you learn with EE, everything you learn in ProcessWire (PHP) will be things you can take with you to almost any other development situation, whether in ProcessWire or not. There are two types of while() loops. A regular while loop only executes while the condition is met. It will execute 0 or more times, since the condition has to be met before it will begin looping: while(condition) { // some code } The other type of while() loop starts with a "do". Note that the condition check is at the bottom rather than the top. That means that this loop will always execute 1 or more times, since it doesn't decide whether to continue for another round until it reaches the end. do { // some code } while(condition); Like Sinnut said, the shift() function is just a way to shift the first item off the beginning of the array. I don't really know the source of the word 'shift' but I used it in PW's API just for consistency with PHP's array_shift function. If you wanted to instead pop off the last item from the array, you'd use the pop() function (which is consistent with the naming of PHP's array_pop function, and a little easier to remember). I'm not good at remembering all the PHP or PW function names off the top of my head... I pretty much always have to refer to the cheatsheet or docs.
  10. I agree with Soma on all points. The first thing I would try is his suggestion to drag/sort the last page to the first spot. That would force it to re-populate the 'sort' field from all the pages in the list. But if that doesn't do it, I think a table repair would be the next step. Any time MySQL is producing some unexplainable behavior, a repair is a good way to go. But luckily that's not often.
  11. I'm still not sure I'm understanding this. Are you talking about a Page reference field, where you've set the PageAutocomplete as the Inputfield? That's the only autocomplete instance that is built into PW. But even if we're talking about that, I'm not sure how that connects to the URL? Is it possible we're talking about a web browser behavior rather than PW one?
  12. That's good to hear. From what you say, it sounds like LiteSpeed is a good web server to use with PW because it is so Apache compatible.
  13. The behavior you see here where sometimes it allows commas and sometimes it doesn't is because it depends on what other characters are in the strong. So it'll let a comma stay in "test, test2" but not "guns n' roses, mötley crüe". It's a little too strict, and this function could be a lot smarter, so I'm working on some updates to it that I'll post later this week.
  14. Thanks for sending me the profile Seddas--I will take a look and fix. I did actually just commit some updates earlier today that may possibly resolve this particular issue, but since I was focused on fixing another issue, I think there's only a 50% chance of that. So I will be testing this soon.
  15. Thanks for the good description on the issue there. I finally understand it and have fixed it (I think). But I'm making some other updates to the Date Inputfield so going to be committing them all together.
  16. Seddass, are you running the latest PW? Some fixes were put in a couple weeks ago, and those fixes may resolve the issue you are running into. Let me know if you are already running the latest or if they don't resolve it, and I'll get back to work on it.
  17. When you enable the URL segments option for a given template (Templates > Edit Template > URLs > URL Segments) then PW will accept non-existant URLs, so long as they start with one that does exist. So lets say that you have a page called /products/widget/. If URL segments are enabled, then you could access any URL below that and it would be sent to /products/widget/. So accessing /products/widget/photos/ (a page that doesn't exist) would still get sent to /products/widget/. (If URL segments are not enabled, then of course accessing /products/widget/photos/ would generate a 404 instead.) Using the /products/widget/photos/ URL, the 'photos' portion would be considered URL segment 1. You can check the value of URL segment 1 in your template file with $input->urlSegment1. If there were another segment on there too, like, /products/widget/photos/cats/ then 'cats' would be URL segment 2 ($input->urlSegment2), and so on. The advantage of URL segments is that you can have just 1 page handling many URLs. The portion of those URLs that are translated to URL segments are not pages in PW. In fact, if you actually created a page in PW named /products/widget/photos/, then your 'widget' page would no longer receive the 'photos' URL segment, as the new photos page would then have control over it.
  18. This should be reasonably simple to do in PW. I think your best bet is to just grab all the entries you want to display at the top, and then use a counter to keep track of where you are. Written in the browser here, so may need adjustment: $entries = $page->children("sort=-sort"); $images = $page->get("/image_uploads/"); $cnt = 0; do { $cnt++; $entry = $entries->shift(); if($entry) { // output 1 entry } if($cnt == 3) { while(++$cnt <= 6) { $image = $images->shift(); if($image) { // output 1 image } } $cnt = 0; } } while(count($entries) && count($images));
  19. Isn't TAB supposed to tab to the next field? That's what it does in my browsers at least. Do you have a plugin installed that is taking over that behavior? If not, what browser are you using?
  20. I don't know enough about LiteSpeed to say what issues there might be, so my reply is more general purpose and applicable to other servers like nginx or IIS. If everything appears to be working properly with ProcessWire, then the only remaining concern would be security. ProcessWire's .htaccess file is used to keep prying eyes out of some directories and files. Try to access these things in your web browser: /site/templates/basic-page.php /site/assets/logs/errors.txt /wire/core/Page.php /site/modules/Helloworld.module /wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module You should get either a 403 (Forbidden) or a 404 (Not Found) when you try to access any of these. This is kind of a random sampling of stuff, but should answer the question as to whether LiteSpeed is translating the blocked directories/files properly. If it is not, that would be a real security problem, so we'd need to figure out how to block LiteSpeed from allowing access.
  21. Landitus, try adding this to one of your templates somewhere, view a page using it, and see what it says. Replace '/path/to/parent/' with the path to the parent page of the children that aren't getting the correct sort in the admin. $children = $pages->get('/path/to/parent/')->children(); echo "<ul>"; foreach($children as $child) echo "<li>{$child->sort}: {$child->url}</li>"; echo "</ul>"; What you should see is a list of a child pages with the number on the left starting at 0 and incrementing by one for each. But let me know if you see something different. Another thing to try would be to change your parent to have some specific sort, save it, then change it back to no sort. I can't say as though I've ever had to do that before, but it seems like one way to just reset things there, just in case.
  22. I'm unfortunately not trained in legal matters well enough to know what the distinction is or if it even matters. The GNU license doesn't like copyrights removed, but don't know how specific it is. So I can't give a solid answer one way or another here. I'll make a note to ask this the next time I come across someone that knows about this stuff though. However, outside of this, there are a couple reasons you may not want to remove it: 1) unless you make your own admin theme, you'll have to do the same thing every time you upgrade (which would be a pain); 2) With GNU software, it's required that the client gets the same GNU license, and they should understand it and that it's copyrighted software. You don't want them to think they are paying you for the software itself rather than your services.
  23. Just to confirm, the sort settings in your screenshot are for the parent page of those you are trying to sort? If you can, turn on your developer tools (Firebug in FF or Dev Inspector in Chrome). Watch what it does when you finish the sort. Do you see any JS errors? If you click on the network request, do you see any messages in the response that look like errors?
  24. I think what's missing here is that $newpage doesn't yet have a template assigned, or an ID, so technically there is no images/files path that exists yet. You would need to assign a template to $newpage before it would even have an images field, and then you'd need to save the $newpage before it would create any directories for file storage. $newpage = new Page(); $newpage->template = 'template_with_images_field'; $newpage->parent = '/'; $newpage->title = 'New Page'; $newpage->save(); // now these should work. echo $newpage->images->path; echo $newpage->images->url;
×
×
  • Create New...