Jump to content

Sergio

Members
  • Posts

    531
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Sergio

  1. You're welcome! And yes, for multiple values the querystring approach is better.
  2. You can put the filter logic in your articles.php template: // First Approach //Allow URL segments on the articles template // so the url will be example.com/articles/cars/ 1 - $category = $sanitizer->selectorValue($input->urlSegment1); // Second Approach // If you don't want to use segments, you can use querystrings, but getting a less refined approach IMHO // example.com/articles/?cat=cars 2- $category = $sanitizer->entities($input->get->cat); $filtered_articles = pages()->get('/articles/')->children("categories=$category, limit=10");
  3. Do you really need the /en on the URL as it's the default language? I would not recommend that, because it's a pointless redirect IMHO that hurts your page loading time (albeit a little bit).
  4. $bool = $user->isLoggedin(); https://processwire.com/api/ref/user/is-loggedin/
  5. Great hook, @Robin S! I'll use this on a future project. Thank you!
  6. Multiple sorts improve the memory usage or other measurable factor? I really don't know. If yes, great! Regarding the feature limit, liked I said, users can be lazy and leave several itens marked as featured in the page tree. So that's an easy way to filter them when your front end page only accepts one featured item at a time.
  7. Hi Carolyn! No, sorry! They expired months ago.
  8. First contribution, "Yet another sorting of featured and non featured articles" /* * Find the children by date, filter by featured (checkbox) and exclude this filtered item * from the final array so it won't appear repeated on pagination. * If there's more than 1 featured item on Admin, sort them by date. * Useful when the user is lazy and marked several items as featured. */ $children = $page->children("sort=-published_at, limit=10"); $children->prepend($children->find("featured=1, limit=1, sort=-published_at")); $featuredItem = $children->first(); $children = $children->not("$featuredItem"); If there's a better way, let me know!
  9. Developing a mobile app is a lot of pain, trust me, so for the new version of my client's app, we decided to trash our bespoke version (made using Appcelerator Titanium) and sign up for a service that takes this pain away. After comparing features and pricing, the client decided for using GoodBarber.com and is pretty happy (currently paying $48/month). The app is pretty simple but met our objectives. GoodBarber enables push notifications but we not using though, as it doesn't work for our main content: podcasts episodes that came from Soundcloud feed. The app in questions is this one: https://itunes.apple.com/br/app/project-management-connector-with-ricardo-vargas/id385663838?mt=8 https://play.google.com/store/apps/details?id=com.goodbarber.pmconnector
  10. Thanks Adrian! I can understand the decision about it. The problem is that is not clear. If you add a permission "user-admin-all" you expect that the user will be able to add to all users any roles BUT the superuser's. That's why I got confused.
  11. Hi @geekpete, welcome to the forums. As Robin S. said, there are better alternatives. I'd like to suggest @tpr's module Template Latte Replace This is a great template engine that I'm truly happy to use on more complex websites.
  12. Yep, to add "user-admin-all" you must have "user-admin" checked. And I tried adding "user-admin-editor" to see what happens, but this is just a more granular control than "user-admin-all". I followed your tip and created a "user-manager" role, and added to it the user-admin and user-admin-all permissions. Also removed them from the editor role. Now, the user with "editor" role can promote another user to the "editor" role, but cannot promote to "user-manager" role. The thing is, as I see, a user with "user-admin" permissions cannot promote another user to his/her same role level. This appears odd.
  13. I have this "editor" role, that has the "user-admin-all" permission. I tried several times, doing different things sets of permissions, but I can't make a user with this role being able to make another user an "editor" too. PW disables the "editor" checkbox. I read the documentation 3 times that my eyes cannot see what I'm missing anymore. Any clues?
  14. Yes, you can use the database class: https://processwire.com/api/ref/database/ You can create a module (recommended) or do it directly on your template. See this example: public function saveViews(Page $page) { $db = $this->wire('database'); $table = "table-name"; $sql = "SELECT page_id, COUNT(page_id) as total_views FROM $table WHERE page_id=:page_id"; $query = $db->prepare($sql); $query->bindValue(':page_id', $page->id, \PDO::PARAM_INT); try { $query->execute(); while ($set = $query->fetch(\PDO::FETCH_ASSOC)) { $new_views = $set['total_views']; $current_views = $page->page_views; $page->setOutputFormatting(false); $page->page_views = $current_views + $new_views; $page->save('page_views'); $this->wire('log')->save("messages", $new_views.' views imported for page '.$page->title); } } catch(\Exception $e) { // intentionally blank } }
  15. Indeed. I run a medium website in a VPS with 2GB and hardly use more than 70% of the RAM.
  16. Did you install any new module or are you running any complex cron job? Ask the hosting company to send you a log so you can see what's happening. Usually is MySQL the usual suspect of using too much ram, not PW.
  17. I'm with @kongondo! Glad you and your family are ok!
  18. You got me!! Merry Xmas @SamC!!
  19. Beware of the large JS load that comes with Discuss, that's why I load it only if the user clicks the "Comments" button. It's possible to show the current comment count, calling the discuss API, but I didn't want it. Example page: https://ricardo-vargas.com/podcasts/think-about-how-to-connect-your-strategy-design-with-your-ability-to-deliver-or-pay-the-price/
  20. I just bought Crysis (never played it!) and MotoRacer (oh the good memories...). Thanks for the tip @FrancisChung!
  21. My boss is pretty well know in the Project Management sector in many countries, and I built his website in PW: https://ricardo-vargas.com/biography/
  22. Most likely, Ryan used the getTotal() method of the page array. You can see it here: https://processwire.com/api/arrays/page/
  23. You can add the random repeater to the $events array and shuffle it after that. $events->append($cta); $events->shuffle(); Sorry, I just saw that you are ordering the events. So this will not work. In this case I think using insertAfter() is a good solution.
  24. You need the ES language pack on your server, take a look at: https://www.simonholywell.com/post/2015/07/php-date-setlocale-localisation/
×
×
  • Create New...