Jump to content

horst

PW-Moderators
  • Posts

    4,077
  • Joined

  • Last visited

  • Days Won

    87

Everything posted by horst

  1. Have you set $config->debug to true in your site/config.php ?
  2. you can call $database->getQueryLog():
  3. EDIT 3: Updated the code. Now it doesn't alter the modified time and modified user-id anymore. Before the change, it altered it of each page that changes the sort value! Also now it is lightning fast! instead of 30 seconds it now only uses 2 seconds.
  4. I have changed the line in my code that uses $page->setAndSave() with an own function that updates the values directly in the pages table. This way it works for me at the moment. But I think, we should send Ryan a link to this thread. databaseUpdateSortInPages($page->id, $sortValue); function databaseUpdateSortInPages($id, $sort) { $sql = "UPDATE pages SET sort = $sort WHERE id = $id"; $query = wire('database')->prepare($sql); $query->execute(); }
  5. yes, i have. Here is what is in the $options array when it reaches Line 1110, just before the if(empty($options['quiet']): $options array(6) { ["uncacheAll"] bool(true) ["resetTrackChanges"] bool(true) ["adjustName"] bool(false) ["forceID"] int(0) ["ignoreFamily"] bool(false) ["quiet"] bool(true) } $data array(5) { ["parent_id"] int(1011) ["templates_id"] int(44) ["name"] string(64) "sanierung-industriegebaeude-weiss-umwelttechnik-gmbh-reiskirchen" ["status"] int(1) ["sort"] int(999998749) } And after the if statement, $data looks like this: $data array(9) { ["parent_id"] int(1011) ["templates_id"] int(44) ["name"] string(64) "sanierung-industriegebaeude-weiss-umwelttechnik-gmbh-reiskirchen" ["status"] int(1) ["sort"] int(999998749) ["modified_users_id"] int(41) ["created_users_id"] int(1101) ["modified"] string(19) "2015-11-15 22:06:54" ["created"] string(19) "2015-09-25 08:18:44" } The info in the page, before executing the code is: After the execution, the info looks like this:
  6. Yes, I have seen this. But in my case it seems not to use the old values. I only want to change the sort value, and therefore it would be really good to not update the last modified timestamp. But when I inspect those pages in the pages finder, the modified time shows "before 2 seconds" or that like. I already have hacked into page::save and pages::savePageQuery with an debug function and saw that it retrieved the right values from the DB. So, I don't understand where it lost that or where it changes it or if it do another save after that ?? It shouldn't. My code is really simple, it is that piece to move pages down in the pagetree.
  7. Hi, I try to avoid updating of the modified timestamp and modified user. It should be done with passing "quiet"=>true in an options array together with the save method(s): $page->setAndSave('sort', $mySortvalue, array('quiet' => true)); But regardless if I use setAndSave() or save(), it gets updated every time. What I'm missing? I use PW 2.7 stable.
  8. @ukyo: you were right, there was a bug with the naming of variations. With using them from API in templates, it wasn't a big problem, but with trying to use them with the CKeditor it was, because the created name of the variation prevents PW from identifying them as variations, as you said. I found out that there simply was missing a single dot in front of the suffix string: -pim2-suffix has to be .-pim2-suffix in cases where only the pim works on original images, whereas when pim worked on a variation, everything worked alright. This is fixed now with version 0.2.7 of pim2.
  9. just completed and updated the function in the post above.
  10. Many thanks for all the suggestions! My current working solution is using a Pagefield with PageTreeSelect, and as a sidenote: wow! I never have used this fieldtype combination before. I always used ASM-Select. Just fallen in love again with PW. The second element is an injected button, what I have learned recently from a nice and usefull snippet of @Lostkobrakai. The working code is located in the ready.php and uses the PW API. Our pages in the example here uses the PageTreeAddNewChildReverse module, so the sort numbers stored in the DB are very high. (If you wonder why they have such high numbers in the screenshots.) The Pagefield where we select the new neighbour page is named "albumselect". /* moving albumpages programatically in the PageTree */ $wire->addHookAfter("ProcessPageEdit::buildForm", function(HookEvent $event) { $DEBUG = true; $FIELD = 'albumselect'; // change to the name of your Pagefield ! $page = $event->object->getPage(); if (!(bool)$page->fields->get($FIELD)) return; // check if the page includes the submitbutton for our function if (!$page->sortable()) { // check if the page is sortable and the user has the right to sort it $this->warning($this->_("You have not the right to sort this page.")); return; } if ('sort' != $page->parent->template->sortfield && '' != $page->parent->template->sortfield) { $this->warning($this->_("The sortsetting of the parent page does not allow drag and drop. It is set to: {$page->parent->template->sortfield}")); return; } $form = $event->return; $input = wire('input'); $pages = wire('pages'); $i = $num = 0; if ($input->post('hook_move_page_in_pagetree') && $input->post($FIELD)) { $page->of(false); $selectedNeighbour = $pages->get($input->post($FIELD)); #$sortLow = $page->parent->child('include=all')->sort; // the sortnumber of the first page in the tree, top page $sortCur = $page->get('sort'); // the current number of the page we want to move $sortEnd = $selectedNeighbour->getUnformatted('sort'); // the number of the page where we want to sort in the current page if ($DEBUG) my_var_dump(array('sortCur' => $sortCur, 'sortEnd' => $sortEnd), 1); if (0 < $selectedNeighbour->id) { if ($sortCur != $sortEnd) { // has the user selected a real or valid change of position? if ($sortCur < $sortEnd && $sortCur != $sortEnd - 1) { // we want to move this page down in the tree foreach($page->parent->children('include=all') as $p) { $num++; $p->of(false); if ($i++ > 50) { set_time_limit(30); $i = 0; } // just to play save, reset timelimit if ($p->sort == $sortEnd) { // we reached the page on which top we want to place the current one if ($DEBUG) { my_var_dump(array('num' => $num, 'page->sort' => $page->sort, 'result' => $sortEnd - 1, 'sortCur' => $sortCur, 'sortEnd' => $sortEnd, 'break' => true), 1); } else { #$page->setAndSave('sort', $sortEnd - 1, array('quiet' => true)); databaseUpdateSortInPages($page->id, $sortEnd - 1); } break; // we are finished now } if ($sortCur < $p->sort) { // only change sort for pages that are between $sortCur and $sortEnd if ($DEBUG) { my_var_dump(array('num' => $num, 'p->sort' => $p->sort, 'result' => $p->sort - 1, 'sortCur' => $sortCur, 'sortEnd' => $sortEnd), 1); } else { #$p->setAndSave('sort', $p->sort - 1, array('quiet' => true)); databaseUpdateSortInPages($p->id, $p->sort - 1); } } $pages->uncache($p); // free memory } } elseif ($sortCur > $sortEnd || $sortCur == $sortEnd - 1) { // we want to move this page up in the tree foreach($page->parent->children('include=all') as $p) { $num++; $p->of(false); if ($i++ > 50) { set_time_limit(30); $i = 0; } if ($p->sort >= $sortEnd && $p->sort <= $sortCur) { if ($p->sort == $sortCur) { if ($DEBUG) { my_var_dump(array('num' => $num, 'p->sort' => $p->sort, 'result' => $sortEnd, 'sortCur' => $sortCur, 'sortEnd' => $sortEnd, 'break' => true), 1); } else { #$page->setAndSave('sort', $sortEnd, array('quiet' => true)); databaseUpdateSortInPages($page->id, $sortEnd); } break; } else { if ($DEBUG) { my_var_dump(array('num' => $num, 'p->sort' => $p->sort, 'result' => $p->sort + 1, 'sortCur' => $sortCur, 'sortEnd' => $sortEnd), 1); } else { #$p->setAndSave('sort', $p->sort + 1, array('quiet' => true)); databaseUpdateSortInPages($p->id, $p->sort + 1); } } } $pages->uncache($p); } } } } if ($DEBUG) die(); } $button = wire('modules')->get('InputfieldSubmit'); $button->attr('id+name', 'hook_move_page_in_pagetree'); $button->value = __('jetzt einsortieren!'); $button->addClass('ui-priority-secondary'); $form->insertAfter($button, $form->get($FIELD)); }); function databaseUpdateSortInPages($id, $sort) { $sql = "UPDATE pages SET sort = $sort WHERE id = $id"; $query = wire('database')->prepare($sql); $query->execute(); } . . EDIT: Updated the above code. It supports up and down moving now. Also it has a debug function now. (The used function for debug output is in the spoiler beneath) What could be done better: [x] first check if the pages are set to use manually drag/drop sortorder or not. [x] test with direct manipulating DB-tables to improve speed. Currently, on my server, it took up to 35 seconds for iterating over 1250 pages and saving a new sortvalue for each of them. But this only happens if we move it from one end to the other (first place to last place). If we move a page 150 places, there will be only changed 150 pages in DB. This tooks around 4 seconds here. EDIT 2: Updated the code and included @Lostkobrakais idea to check for the PagetreeField on every page, and not on templatenames etc. This way we can add/remove the functionality to every templates we like, just by adding/removing the Pagefield to them, without altering the hook-function. (In our case the pagefield is called 'albumselect'). EDIT 3: Updated the code. Now it doesn't alter the modified time and modified user-id anymore. Before the change, it altered it of each page that changes the sort value! Also the execution time is much faster now. It only takes 3 seconds on my server to move it 1200 pages down or up. (Before using direct DB-access, it took 35 seconds)
  11. I believe this isn't doable in PW because on every manually move in the pagetree all integer sort fields gets rebuild in a linear row, without those niches. Otherwise this would be the best or simplest solution, I agree.
  12. What do you mean with the timestamp? The timestamp when the variation will be created / recreated? If yes, I think this isn't possible without some extra programming logic. CroppableImage is an API tool, that means, you have to define some (static) constants in the template files during development time, like a suffix. This is needed to detect if an imagevariation already exists or need to created on execution time. It would need an extra layer, etc. I don't know what you want to do with the timestamp, but you know you are totally free how to create the markup for an image tag. And the timestamp is already stored in the filemtime() of the file. So, if you need the timestamp in PHP, you already have it with filemtime(), but I guess you need it on client side with javascript? Then you may read it and put it into a data-timestamp attribute of the image tag, for example: $ts = filemtime($image->filename); echo "<img src='{$image->url}' data-timestamp='{$ts}' />"; If that isn't helpful for you, please tell us a bit more what you are after with the timestamp. And welcome to the forums!
  13. here is a troubleshooting guide: http://processwire.com/docs/tutorials/troubleshooting-guide/page3 or maybe your problem is described one page back.
  14. It isn't about sorting 400 pages. The pages have kind of a chronological order. And mostly there will be added new projects to the tree what only need to be sorted within the top 20 pages. That's just fine. But there are also some older projects that should find the way into the online archive. And this pages needs to be pulled down 400 pages or more. (sigh') I think the first thing I will experiment with, is to display the pages sort (range) number in the pagetree. So we can see them and easily pick one we want a new page moved to. Add a "desired sort range" inputfield and maybe a button to those pages template, where we can add in a sort range number where the page gets moved to on / after saving or when an own button was pressed.
  15. On a site we have a branch with 1200+ pages. The sort order is manual drag and drop. Sometimes we need to move new created pages 300 or 400 places in the pagetree. This is a real pain. Is there any way (besides moving them manually) how we can sort in a page at a desired place?
  16. I'm using it with insertBefore the image field and it works fine, regardless of PageStatus. I also have added two lines to the AdminCustomFiles/AdminThemeXXXXX.css files to move it to the right: #wrap_hook_sort_images { float: right; } #wrap_hook_sort_images:after { clear: both; } Such a nice and helpful snippet from @LostKobrakai, I really love it.
  17. Haha, funny sentence, >> "it should be easy" << But seriously, how have you setup this? Are both programms running on the same server and within the same domain? Or are they separated by subdomains? But regardless, I would create a script within the WordPr*ss site / directory, according to the guidance you have linked too, but would create and output JSON data. The URL of that script, I would read in from PW and create the posts. $url = "http://wrdprss.domain.tld/path/to/jsonexport.php"; $opts = array( 'http' => array( 'method' => "GET", 'header' => "Accept: application/json\r\n" ) ); $context = stream_context_create($opts); $jsondata = file_get_contents($url, false, $context); if (preg_match("#HTTP/[0-9\.]+\s+([0-9]+)#", $http_response_header[0], $matches) && 200 == intval($matches[1])) { // now parse the data and build the html ... }
  18. If you have set the sort order to manually in the childrens parent site, you can use "sort=sort" or "sort=-sort" in the selector. (Hope this is what you are asking for??)
  19. Do you use A) different values for $config->userAuthSalt in site/config.php B) different PHP versions with the environments ?
  20. Maybe that can work, but haven't tested: you can create another parent template, (as a copy from your current), but only the template in PW backend, not with a template file!! than you assign your current templatefile to the new template under Template Edit _> Files -> "Alternate Template File", as children, you only assign that date template, with setting the auto name format I think you have to experiment with it, so highly recommend to do this in a playground install, not in your current projects install !!
  21. I can confirm a behave like @NoremPload describes, but not like @tsdtsdtsd said. This must be different things. I have noticed this two times by myself: 1) on a PW 2.3.5 site, a year ago or so. Here it has gone away without any interaction. (??) weird! 2) on a local installation of a friend, where it occured from time to time. But couldn't detect any reason why it behaves that way. All images were stored in the assets files subfolder and all admin thumbnail variations were successfully created. After a page reload, with or without using the save button, some images were gone from the images field. (not written into DB) And without allowing to overwriting existing images on upload in the field edit page, you are not able to upload them again! (Error about image files are already exists, but may belong to another field of that page!) Only thought is, that it (must) have to do with the MySQL DB and the lot of concurrent save requests for the pages image field! But I'm not very familiar with DB stuff. So, as it is also a bit weird that an optional wanted sort order gets distorted by a multiple asynchronus upload I always use zip upload nowadays. You can enable zip upload to image fields. This way only one file gets uploaded, and than one by one image gets extracted, registered and variation created. No concurrent tasks anymore. Also an optional wanted alphabetical sortorder is kept. As this only is a workaround, the asynchronous concurrent images upload should work too. And it does work for maybe 99,9995 percent. But if you run into that 0,0005 percent, it is weird. If you like, you can open an issue on github. If not, I will do so later. Am on the go now. BTW: @NoremPload, your avatar reminds me of an old friend of mine.
  22. I have answered to it on Github: https://github.com/ryancramerdesign/ProcessWire/issues/1236#issuecomment-151254248 would this be a solution?
  23. Does you have any page or module created / named "language" ?? (NOt one from the LanguageSupport)
  24. Hi Marty, I'm not sure, but shouldn't it be with a comma, before your image field? $matches = $pages->find("template=portfolio, title|first_name|last_name|body%=$q|portfolio_images.tags*=$q, limit=150"); $matches = $pages->find("template=portfolio, title|first_name|last_name|body%=$q,portfolio_images.tags*=$q, limit=150"); > ! < (Not tested)
×
×
  • Create New...