Jump to content

diogo

Moderators
  • Posts

    4,296
  • Joined

  • Last visited

  • Days Won

    79

Everything posted by diogo

  1. The questions was about the installation of a plugin in ProcessWire. If you give instructions on how to install the plugin in ProcessWire, add it to a field and show that it does a better job then the plugin referred by the OP, especially if documented with screenshots of the plugin working in the PW admin. We will gladly let you link to it.
  2. It already exists while editing the template and after adding a field, click on it's name. I think you have to save before, but I'm on mobile and can't try.
  3. Thanks! Corrected my old post, in case someone stumbles on this
  4. @web-master, @web-master, and how would you do that in PW specifically? I'm sorry but I won't let you link to your plugin if you don't, at least, answer this question.
  5. That's one way, but you will be changing all the concept of the website only because of this problem. My suggestion is that you tell the editors to write outside of PW and send their texts to someone that is responsible for pasting them in place. This is a good practice anyway and will prevent other problems as: different formatting, loosing all the work because of a page refresh or browser crashing, etc.
  6. @mr-fan one point less for linking to bild
  7. The code on the post above is not full proof, if the process is interrupted for any reason, you would have to start over. The ideal would be to, on each iteration, read the last line of the file, identify the user, find the next user, and write the next line.
  8. 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.
  9. Read this https://processwire.com/api/multi-language-support/. If you did already, read again
  10. I'm guessing the important part there is the start=0, so just replace n by 10
  11. 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.
  12. The font is open sans, right? Ryan, if the problem persists, maybe you can switch it to google fonts to try.
  13. I understand that, but if you want to write about something, make sure you understood at least the basics.
  14. He got everything, but I mean EVERYTHING, wrong
  15. @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
  16. 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")
  17. 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.
  18. 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
  19. 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
  20. 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.
  21. 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!
  22. 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.
  23. 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.
  24. 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
×
×
  • Create New...