Jump to content

diogo

Moderators
  • Posts

    4,314
  • Joined

  • Last visited

  • Days Won

    80

Everything posted by diogo

  1. This worked really great for me in a site with thousands of pages $selector = "template=pages_template"; // as an example while (1) { $p = wire('pages')->get("{$selector}, id>$id"); // get page with id bigger than previous if(!$id = $p->id) break; // assign current page's id to $id or break the loop if it doesn't exist // do stuff using $p as the current page wire('pages')->uncacheAll(); }; Like this you never have an array in memory, only one page at each time, and you can do all the operation in one go. Of course you would probably have to constantly write to the csv file (like, open,write,close,open,write,close,open,write,close edit: this doesn't make any sense you can open, write, write, write,... close), but I don't think that would be a problem. Edit: Ideally you would do this from the terminal by bootstrapping PW, to prevent overloading apache.
  2. Read this https://processwire.com/api/multi-language-support/. If you did already, read again
  3. I'm guessing the important part there is the start=0, so just replace n by 10
  4. In your case I would probably create an english subsection on the tree. To give a simplistic example: home about events news contact english about contacts You can build a menu easily, being english one of the items. When you are in the "english part", your menu would be the children of english, plus the link to the default language. I'm assuming all the complex structure will for the default language, and that english will be pretty simple.
  5. The font is open sans, right? Ryan, if the problem persists, maybe you can switch it to google fonts to try.
  6. I understand that, but if you want to write about something, make sure you understood at least the basics.
  7. He got everything, but I mean EVERYTHING, wrong
  8. @LostKobrakai, you're right, my distraction. Still, my suggestion should work. @rooofl, I already used that site to find fonts , great work! Actually, this isn't even the first project of yours that I used, have a look at my bookmarks bar
  9. Pagination only works with wireArrays taken directly from the database. When you do $pages->get("/fonts/")->find("keywords=mykeyword") you're filtering a wireArray that is already in memory. Try to find a way to form the same array in one go, for example: $pages->find("has_parent=/fonts/, keywords=mykeyword")
  10. As I understand you are creating a page per property. In that case yes, straight in the foreach. Unlike find(), get() stops immediately after finding the first occurrence that matches the selector and keeps only that one object in memory, so it's very light and surprisingly fast. Edit: as for querying the db every time, I don't see a better solution. The alternative would be to loop through all the properties in the XML to collect the references, query the database to check which ones are still not there, collect them, and loop again the XML only using those... Not sure if this would be more effective.
  11. This should be enough: $ref = intval($property->Refnumber); $existing = wire('pages')->get("template=basic-page, property_ref=$ref"); if (!$existing->id) // you're good to go
  12. Hi andre, welcome to the forums. You're right, it hasn't been updated for a while. I can't work on it right now, but would be great to have some help with it
  13. Soma, that's a different thing of course. But I think you know that So, the problem above is partially solved. I only had to add one setting to sisyphus locationBased: true to tell it not to ignore the get values. Of course now ?id=2767 is different from ?id=2767&s=1, but this was just a quick fix.
  14. Just noticed that Sisyphus doesn't identify the pages as different, because it doesn't distinguish between different get parameters. They are all the same url for the plugin, so the data passes from page to page. Shouldn't be too hard to add an extra check, but I can't do it anytime soon. Again: don't use this in production websites!
  15. Guys, I implemented sisyphus.js as a module. You can test it from here https://github.com/ocorreiododiogo/Local-data-saver-Processwire To test, edit one or more fields in a page and open that same page in a new tab without saving. The data should magically appear there I didn't test it thoroughly, so, proceed carefully. In this implementation, all changes will be saved to local storage until the from is submitted. after submission the local storage is cleaned. Ideal implementation would have a visual clue that the data was loaded from local storage, and not from the db, and would have a button to clean the local storage and replace it with the real data. PS: I can see some cases where this can cause confusion with multiple users, but currently it can also happen without the module.
  16. Sorry to hear that There's nothing like writing in a offline editor and pasting it to the textarea for publishing. Or a browser extension like Horst said.
  17. Building on LostKobrakai's suggestion, you could do it like this: #1 Enable urlSegments on the home template https://processwire.com/docs/tutorials/how-to-use-url-segments/ Then, on the home template, you'll want to find the user by the provided segment: if ($input->urlSegment1) { $cleanUser = $sanitizer->pageName($input->urlSegment1); // sanitize user input $foundUser = $pages->get("parent=/users/, name=$cleanUser"); // find the requested user page if (!$foundUser->id) throw new Wire404Exception(); // throw a 404 if there isn't that user echo $foundUser->render(); // render the user page } else { // code for the homepage } The problem here is that if you have a page that is children of home with the same name as a user, that page will be called and the segment will be ignored. Make sure to check the best practices for working with url segments here: https://processwire.com/docs/tutorials/how-to-use-url-segments/page3 #2 You could still keep the products under /products/ and have a second urlSegment on the homepage. The logic would be the same as in #1. So, all together (written in the browser, don't trust the code too much): if($input->urlSegment3) throw new Wire404Exception(); // we don't care for a third segment, so throw a 404 if it exists if ($input->urlSegment1) { // first check the user $cleanUser = $sanitizer->pageName($input->urlSegment1); // sanitize input $foundUser = $pages->get("parent=/users/, name=$cleanUser"); // find the requested user page if (!$foundUser->id) throw new Wire404Exception(); // throw a 404 if there isn't that user if ($input->urlSegment2) { // check the product $cleanProduct = $sanitizer->pageName($input->urlSegment2); // sanitize input $foundProduct = $pages->get("parent=/products/, name=$cleanProduct"); // find the requested product page if (!$foundProduct->id) throw new Wire404Exception(); // throw a 404 if there isn't that Product echo $foundProduct->render(array('mobile' => $foundUser->id)); // render the user page telling the product template which user to use } else { echo $foundUser->render(); // render the user page } } else { // code for the homepage } I used render, but you can write the code directly of course. On the second render, I'm passing the user as an option so you can use it on the products template. Ryan explains options in render here https://processwire.com/talk/topic/3145-multiple-views-for-templates/?p=32876
  18. The retina screen will be replaced by a projection on the retina
  19. In the specific case of the checkbox to send the email I think the best is to add a note instructing people to save the page. Something like "send email after saving this page. Don't forget to save the page or the email will not be sent". A quick hack would be to use Admin custom files module to add some JS magic (read "hack") to do this instantly. You could for instance capture the change event on the checkbox to trigger the save button: $(".checkbox").change(function() { if(this.checked) { $(".save-button").trigger("click"); } }); ...or even replace the checkbox by a copy of the save button and change the text to "send email". The possibilities are infinite. -- PS: notice my first sentence. I still would prefer the simple informative solution.
  20. diogo

    ED newsletter

    Hey guys! Just announcing that from now on we will have a newsletter. Those that want to know about what we are doing besides of what I post in the showcase forum should subscribe it here http://eepurl.com/bk-QJz
      • 2
      • Like
  21. You're welcome! Greeting from the stormy Porto
  22. You can also put the file on the root of the website and call it directly, the .href rules are prepared to bypass the index if you call an existing file (that would imply moving the script also, probably).
×
×
  • Create New...