Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by verdeandrea

  1. Hi guys, i have a news archive, where i cycle through a lot of pages and this cycle is paginated. In my home page i need to link to a specific news, but not directly to its page, but to the archive page containing this news. So if, for example, i have e news in page 3 of my archive, i would like to link to this page. The question is, what is the best way to get the link to the right page of my archive? Thank you
  2. Hi, I've followed this post https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users%C2'> I've created a new template and a new parent page for some kind of user. Everything is working fine, but i would like to have a default role for this kind of user when a new one is created, so the site administrator doesn't have to change it (...and probably mess with it....). Is it possible? Thanks
  3. Hi guys, this is what i'm trying to do. I have a template with a textarea and a repeater field. When I create a page i want to paste some text copied from excel and the when i save the page i want to cycle through that text and create new repeaters item in the same page according to it. I'm just starting with hooks and stuff so i'm doing something wrong caso I alway get this error "Call to a member function getNew() on null" Here is what I've written in my module public function init() { $this->pages->addHookAfter('Pages::saveReady', $this, 'afterRankSave'); } public function afterRankSave($event) { $page = $event->arguments[0]; // excel_paste is the textarea field where i paste from excel if($page->template == 'group_rank' && $page->excel_paste !== '') { $this->message("You pasted an excel"); $rows = explode("\n", $page->excel_paste); foreach($rows as $idx => $row) { $row = explode( "\t", $row ); $this->message($row); $rank_position = $page->group_rank_user_repeater->getNew(); $rank_position->group_rank_user_name = $this->sanitizer->text($row[0]); $rank_position->group_rank_user_concessionaria = $this->sanitizer->text($row[1]); $rank_position->group_rank_user_points = $row[2]; if($row[3] == 1) { $rank_position->gruppo_rank_user_winner = 1; }; } $page->excel_paste = ''; } } I need to empty the "excel_paste" fielsd, otherwise it get in an infinite loop. I'm not sure on what hook I should use. I not sure about the logic of this stuff. Thank you!
  4. Now I've tried upgrading to the last PW dev version, but this didn't work too. No one knows what could I try with this problem, guys? Ryan? I think that the only thing i can do is recreate every page and every page field related to tem via api.
  5. It wasn't so hard in the end. I decided not to store the rank in the database, but just constructing it from the user points. I solved the problem of users with the same rank position in this way // I get the players pages and sort them by points $players = $users->find("sort=-user_points, sort=name"); // I explode the players into a scores array $scores = $players->explode("user_points"); // Using array_unique to remove duplicated scores $unique_scores = array_unique($scores); // With array_unique previous key are preserved so i need to create a new array with new keys $reindexed_scores = array_values($unique_scores); // I cycle through players foreach($players as $player) { // I get the key of the user pointe in the array $position = array_search($player->user_points, $reindexed_scores); echo $position; echo " - "; echo $player; echo " - "; echo $player->user_points; } Hope this could help someone else with the same need.
  6. It seems I have no luck here. I check "Users override CSV settings", then save, but when the page load again "Users override CSV settings" is still unchecked
  7. Thanks @adrian . I'm trying the solution you described. I don't know if I'm doing something wrong but the "Fields to export" select is not showing the user template fields. I made some screenshot of the setting tab and of the "field to export" select. The editor is giving me some problem attaching them so here are the links to the screenshots https://www.dropbox.com/s/16oqik2ann07y40/settings_tab.png?dl=0 https://www.dropbox.com/s/c0h2gvgty27k3uw/Schermata%202015-11-04%20alle%2009.57.46.png?dl=0
  8. Thanks @adrian yes i was talking about Home > Admin > Access > Users Unfortunately i've commented that line, and i can see the Batch Child Editor block in Children Tab, but when i click on export csv nothing happen And yes i need this to be available regularly to export users. Thanks for helping.
  9. Thanks Adrian, great module! I'm trying to use it to export users page into csv, but the module doesn't show in "Users" parent page. Is there a way to make it work?
  10. Hello guys, this is my situation. I have a website where users can do some tests. At the end of the test they earn some points. Se there is a rank showing users results. I'm trying to understand what could be the best way to store and organize data in this case. I'm thinking about using ProField Table to create an edit the rank. Every row of the table would have this information: Rank position - User - Points Everytime a user do a new test the rank should be updated. Can this be a good solution? Can i find and edit row of the table via API? Can Table field be sorted by one column? I was also thinking about using repeater. One repeater item for every rank row. Another problem is the rank should be like this: - 1. John Smith - 240 - 2. John Doe - 200 - 2. Jane Doe - 200 - 3. Bla bla bla - 180 etc. So if more user have the same points they should have the same rank position. I need to show "You rank position is: n" in home page for every user. So i would like to have a function like "get_rank_position($user)" but i have no idea where to start with this. Have any of you ever done something like that? Thanks!
  11. I've tried deleting the repeater items for a page, and the adding then again but nothing change. It only works if i delete the page and i create a new page. But there are alot of pages, related to other pages, so i can not recreate every page. Does anyone have an idea about how to resove this problem? Please tell me if my previuos explanation is not clear enough. Thanks.
  12. Hi guys, something very strange is happening with a multilanguage site. Some repeater fields are not showing if i change the active language. I have this pages with information about professors and one of the fields is a repeater field called "professor_info". So, if in a blank professor template i write "echo $page->professor_info" i get ids of the repeater items, but if i switch language to english (the default language is italian) those fields are not showing. Moreover, this only happens with existing pages. If I create a new page the repeater field is working in both languages. I can't understand what is causing this problem.
  13. Thanks netcarver, i've tried that but it's still not working. Could it be something related to "addHook"?
  14. Hi guys, i've working on this site based on pw. I'm getting the error 324 err_empty_response in my homepage, but soon as i delete this line wire()->addHook("Page::wordLimiter", null, "wordLimiter"); everything is working fine again. This is the complete code of the hook function wordLimiter(HookEvent $event){ $field = $event->arguments[0]; // first argument $limit = $event->arguments[1]; $endstr = isset($event->arguments[2]) ? $event->arguments[2] : ' …'; $page = $event->object; // the page $str = $page->get($field); $str = strip_tags($str); if(strlen($str) <= $limit) return; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } return $event->return = $out .= $endstr; } wire()->addHook("Page::wordLimiter", null, "wordLimiter"); and is written on the top of the page. I really don't get what can cause that problem. Could you please help and suggest what can be wrong? Thanks
  15. Another possible and very useful solution could be a field that works like a page field when you choose and existing page but works like a page table field when you create a new one. That would be great not just in this case but in a lot of other cases i can think of. But probably the easiest solution for now is trying to understand if we can change some pw core file to get that result.
  16. Thanks LostKobrakai. How can i use the snippets you suggested for the admin panel? I'm creating pages using the panel and not via API. Thanks
  17. Hi guys, i'm working on a multi language website (italian and english) . I'm trying to create a simple tag system using a page as tags container and its children pages as tags. Then in my news template i'm using a page field that allows new pages to be created from this field. Now, everything works fins but when i create a new tag using the page field it actually creates a news page but the name for the second language is not active (see the attached image). If i create a new page using the pages tree the active checkout is already checked. Is there a way to make it automatically active everytime a new page is created using the page field? Thanks a lot
  18. Great thanks! It seems to work properly now. Yes i have "Rename on save" checked, i forgot to tell. Really thanks!
  19. These are the logged errors in a page with two repeater items, one image per each: pageid: 1372 page->id: 1053 page->name: digital-compositing-nuke fieldid: 98 field->name: single_image template->name: corso pageid: 1373 page->id: 1053 page->name: digital-compositing-nuke fieldid: 98 field->name: single_image template->name: corso pageid: 1373 page->id: 1373 page->name: 1427738337-12-1 fieldid: 120 field->name: cover_image template->name: repeater_slideshow I'm not sure, but maybe there is something strange with this: "page->name: 1427738337-12-1" (that's not the page name), and this "field->name: cover_image" because cover_image is not a field inside the repeater, it's outside. If it can help you I can give you access to the admin page, or to the project directories. Thanks!
  20. Sure, Adrian. This is the filename format: {$page->title}-## These are the fields on that template: - the field slideshow_repeater, that gives those problems has an image_field (that has maximum files allowed = 1) and a url field. - an image field with maximum files allowed = 1 (i had no problems with this field) - an image field with maximum files allowed = 0 (i had no problems with this field) - 2 files field - a lot of text and textarea fields - all the seo fields from the Seo Module There are no other repeaters on that template (i'm attaching a screenshot). I'm also using the image extra module on InputfieldImage and InputfieldFile I'm using PW 2.5.23 dev I'm sorry, i'm not so sure how to log the errors you asked, i'm not a php developer, so i tried with error_log() and i just get "Pages" for $this->pages and i get "1.jpg" or "2.jpg" etc for $this->pages->get($pageid)->$field Thanks a lot!
  21. Adrian thanks for this module. I'm having some problems with images inside repeater. It acts very strange. It gives errors when i try to add o remove images from the repeater field, and then save the page. And if i try to add a new repeater item, the image field in it is already populated with an image i thought i had deleted. I attach some screenshots with various errors i'm receiving. Let me know how can i help to make this more clear.
  22. I'm also interested in this topic. Did you find a solution? Can anyone suggest a solution? Thanks!
  23. I've an SQL error adding a new language (in latest dev). This is the error Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pages.name1020' in 'where clause' (in /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/PageFinder.php line 292) #0 [internal function]: PageFinder->___find(Object(Selectors), Array) #1 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array) #2 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(320): Wire->runHooks('find', Array) #3 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(199): Wire->__call('find', Array) #4 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(199): PageFinder->find(Object(Selectors), Array) #5 [internal function]: Pages->___find('path=/admin/set...', Array) #6 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array) #7 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Wire.php(320): Wire->runHooks('find', Array) #8 /Users/andrea/Dropbox/Sites/htdocs/pw/wire/core/Pages.php(299): Wire->__call('find', Array) #9 /Users/and This error message was shown because you are logged in as a Superuser. Error has been logged. After this i can not access the admin page anymore. I've opened an issue to the PW Github page.
  24. Hi guys, i want to sort the children of a page via manual drag 'n drop but i'd like to have every new page saved as the first of the list (currently PW put the new pages at the end of the list). Is this possible? Thanks a lot! Andrea
  • Create New...