Leaderboard
Popular Content
Showing content with the highest reputation on 11/16/2015 in all areas
-
Creating my book websites with Processwire http://cchogan.com/food-and-stuff/using-processwire-for-my-book-websites/3 points
-
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.3 points
-
u cane do $session->removeNotices(); aftr u dipslay.notices2 points
-
2 points
-
2 points
-
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)2 points
-
[[!ProcessWire? &var=`Stable, fast, powerful, consistent and makes you smile.`]] And doesn't use silly snippets2 points
-
WillyC is right. I noticed this too, and updated a relevant issue at GitHub.1 point
-
Ryan did move the whole page actions handling to a separate file, therefore the old translations won't work anymore.1 point
-
Ah, OK, I see. Have no idea really why that is happening. Did your config settings change? (the module system notification ones)? Other than that, cool admin!1 point
-
Thanks Adrian. I actually had gotten to that point yesterday, but noticed it was still pulling in the parents. I got it working with: return $page->parent->children();1 point
-
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(); }1 point
-
Now that's interesting. The data array seems to be correct even after the if statement, so something in the lines below must be the culprit. Maybe some db query caching or such? That's maybe a bit to deep even for my knowledge of the core.1 point
-
Dear all, I know this post is old, but in case someone else stumbles across it, here is a modified version of Soma's getLabel() hook which takes an optional second parameter to decide if you want a fallback to the default language if no localized name of that field is available: $fields->addHook("getLabel", null, "getLabelLang"); function getLabelLang($event){ $field = $event->arguments(0); $fallback = $event->arguments(1) === null ? true : $event->arguments(1); $lang = wire("user")->language->isDefault() ? "" : wire("user")->language->id; $field = wire("fields")->get($field); $caption = $field->get("label$lang"); $caption = (count($caption) === 0 && $fallback) ? $field->get("label") : $caption; $event->return = $caption; } Usage: $fields->getLabel("labelName"); -> returns the localized label name with fallback to default language. $fields->getLabel("labelName", false); -> returns the label name without fallback to default language. I am not very good with php, any code improvements welcome!1 point
-
With the help of Firebug html#facebook body {background-color: #000; border: 1px solid #fff;} #fff, #c8c8c8, etc. "0 Comments" ._50f7 {color: #fff;} #fff, #c8c8c8, etc. "Sort by" ._pup {color: #fff;} #fff, #c8c8c8, etc. Top inside bar ._491z {border-bottom: 1px solid #fff;} #fff, #c8c8c8, etc. Bottom inside bar ._5lm5 {border-top: 1px solid #fff;} #fff, #c8c8c8, etc. Facebook text link ._42ef a {color: #fff;} #fff, #c8c8c8, other blue, etc.1 point
-
1 point
-
Definitely gonna try the select boxes style tweak, thanks for the heads up! The facebook dark color scheme doesn't seem to be working for me, supposedly it should work with adding a data attribute to the element where the comments will be added, I'll keep on looking for a solution.1 point
-
1 point
-
At least the design is top notch Why are you looking elsewhere? Looking for challenges?1 point
-
just completed and updated the function in the post above.1 point
-
@tired_eyes, everything ends but ProcessWire just stepped in a new era and is not likely to go away soon. The 3.0 step will be a big transition but for building sites (writing templates) it's not going to change anything. I don't know any system that's more consistent and simple to use, yet so powerful. Say your PW journey ends over a year of 5 you've gained so much `ProcessWire` knowledge, you will realise then that you fully mastered the language PHP.1 point
-
Please, someone kick me in the head, I must be sleeping or something. https://github.com/ryancramerdesign/ProcessWire/issues/1506 I've opened this ticket yesterday, and today it's already resolved. I'm realy impressed by such amazing speed and feedback. Honestly, right now every thing about PW looks too good to be true. I realize that this is sort of "honeymoon" with new software that eventually will end, but oh well.1 point
-
There are many former really great modx members out there in this wild hood... Very warm welcome to your own new journey to redefine your thinking and workflow.... Please use google to search the forums (this the only con of this forum) to get more and better information about the force of PW! Best regards mr-fan1 point
-
Also check out the ProcessWire Weekly that comes out every Saturday.1 point
-
hi tired_eyes, welcome to processwire! you can also take a look at the blog https://processwire.com/blog/ - there's the place where you see all the news explained in detail. i've added the rss feed and am always looking forward to fridays (the day where blog posts are published) have fun with pw!1 point
-
Hi, and welcome to the forums! The ProcessWire eco-system is active. Ryan Cramer, the creator, is continuously adding new features to PW (on the dev branch) and fixing bugs as he goes along. The community here is small, but active and very helpful. The Modules Directory is also active, with some interesting modules popping up on a regular basis. As mentioned above, PW3 will be Composer-ready, with namespace support. Many here are quite excited about PW3. Version 2.7 is just around the corner (maybe this week), and contains several great updates in comparison to the current 2.6.1 stable. So yes, I recommend the jump.1 point
-
There is a new development release of Processwire every week that you can download. The upcoming version 3 (currently in alpha) will allow for composer support and lots of other things. Its a good time to get involved. I made the switch about 6 months ago and I haven't looked back. I feel I have only just scratched the surface with what this system could potentially do.1 point
-
You'll probably like the Bourbon family, on SCSS. http://bourbon.io -- Mixins http://neat.bourbon.io -- Semantic grid http://bitters.bourbon.io -- Bootstraping styles On bigger/more complex projects, have a look at the Susy SCSS layout framework, mixed with Bourbon and Bitters. http://susy.oddbird.net uikit and the like are nice, but I think there is too much overhead when modifying them.1 point