Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/27/2022 in all areas

  1. Check with count($page->hero_items))instead of $page->hero_items as it return the field if it exist, not what's inside.
    2 points
  2. Not sure if that makes a lot of sense or even if it is possible. I happen to find myself iterating the page IDs and other IDs a lot during testing, only to delete the pages and whatnot afterwards. So I'm basically iterating the IDs for no good reason. Wouldn't it be nice to have a module that can reset that ID in the database, either manually or automatically, say upon deletion?
    1 point
  3. Yeah I'll have to search if there are any other threads for markup regions strat. Getting the same output with the suggestion above so did a bit of searching and found this - https://processwire.com/blog/posts/processwire-2.6.8-brings-new-version-of-reno-admin-theme-and-more/#new-this-gt-halt-method-for-use-in-template-files Adding $this->halt to the end of each case prevents the continued render when using it within _init.php (the prepended file). This does not work if just adding to _main.php. This is the action area now - <?php if($config->ajax && $input->post->bookmark){ bd($input->post->bookmark); // debug with tracy, uncomment if you have it $bookmarkid = $sanitizer->int($input->post->bookmark); $action = $sanitizer->name($input->post->action); $bookmarks = $user->getUnformatted('bookmarks'); switch($action) { case 'save': // save logic if(!$bookmarks->has($bookmarkid /* this was bookmark, now bookmarkid */)) { // add bookmark $bookmarks->add($bookmarkid /* same change here */); $user->setAndSave('bookmarks', $bookmarks); $message = 'Borat saved bookmark "'. $bookmark->id .'" ?'; $this->halt(); } else { $message = 'Nothing done'; } $success = true; break; case 'remove': // remove logic if($bookmarks->has($bookmarkid)) { $bookmarks->remove($bookmarkid); $user->setAndSave('bookmarks', $bookmarks); $message = 'Borat removed bookmark "'. $bookmark->id .'" ❌'; $this->halt(); } else { $message = 'Nothing done'; } $success = true; break; default: $message = 'error'; $success = false; } $json = array( 'id' => $bookmarkid, 'action' => $action, 'message' => $message, 'success' => $success ); header('Content-Type: text/json; charset=utf-8'); echo json_encode($json); return; } ?> Now I get this within preview: and FINALLY it now saves into the user area. A huge thank you @flydev ??. Learnt so much through this thread and hoping it helps others! I'll even keep in borat in recognition of your input.
    1 point
  4. A note for myself, and people interested on how an install can scale : ProcessWire 3.0.175 adds new database scalability options https://processwire.com/blog/posts/pw-3.0.175/
    1 point
  5. AHH awesome, I thought it had to go somewhere. I wasn't sure whether keep in the loop but remove the action line like you mentioned.
    1 point
  6. Hello @bernhard thanks for your answer. Now I understand how to set the locale for each language in the module and was able to achieve what I wanted. Finally my date code would look like this $data = strtotime($publicacion->data_publicacion); $dateFormatter = \IntlDateFormatter::create( $languages->getLocale(), \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, \date_default_timezone_get(), \IntlDateFormatter::GREGORIAN ); $contido .= '<time datetime="' . $publicacion->data_publicacion . '">' ."\n"; $dateFormatter->setPattern('EEEE'); $contido .= '<em>' . datefmt_format($dateFormatter, $data) . '</em>' . "\n"; $dateFormatter->setPattern('MMMM'); $contido .= '<strong>' . datefmt_format($dateFormatter, $data) . '</strong>' . "\n"; $dateFormatter->setPattern('dd'); $contido .= '<span>' . datefmt_format($dateFormatter, $data) . '</span>' . "\n"; $contido .= '</time>' . "\n"; And the final result:
    1 point
  7. There's no "ready to use" export function in processwire, but you can easily create one like described in the posts of AndZyk. But I think you have not understood how Processwire works ? a simple introduction can be found here https://processwire.com/docs/tutorials/hello-worlds/ The important thing is that you understand that the export must be programmed by you via php. The module "BatchChildEditor" simplifies the whole thing only a little. In the module description there is also a simple example: https://processwire.com/modules/batch-child-editor/ But you need an understanding of how PW is structured (Everything is a page, every page has a template, every template has fields, every field has a certain type).
    1 point
  8. Another example, clients receipts generated by the terminal are sent on real time to the "receipt app" which can be seen there: https://facture.kingspark.fr/ You can see something more than ~4M pages. This following example, is a dashboard for accouting things, a database of 10gb and more than 11M pages: (traduced by on-browser-google-trad)
    1 point
  9. This might be what you're looking for: https://processwire.com/api/ref/inputfield-text-tags/tags-array/ Corrected, this is the link: https://processwire.com/api/ref/inputfield-text-tags/get-tags-list/ You can also get the inputfield from the field like this: https://processwire.com/api/ref/field/get-inputfield/ Something like this might work, haven't tested: $inputfield = $page->getInputfield('tags_field'); $list = $inputfield->getTagsList(true); foreach($list as $item){ // echo checkboxes ? }
    1 point
  10. @bernhard, RF3 works like a charm and rock solid! After RF2 I can only thank you again for the clean code and documentation for RF3! ??
    1 point
  11. For not so complex ajaxified pages this is what I do. Something like: <?php if ($config->ajax) { echo wireRenderFile("./rendered-ajax-call-result.php", array('page' => $page)); return $this->halt(); } Page is the only variable passed to the template partial and if something else is needed I make sure it is already part of page so that I can access it in the partial. The halt method is the recommended way so that ProcessWire can tidy up before exiting the process.
    1 point
  12. Different set of tools here (but based on somas great wordlimiter! I don't use it in a module via hook just in my _func.php and i use it on several different strings to get clean values for example a sumary of the body text if no meta description is set...and so on. regards mr-fan /** * Wordlimiter cuts a textarea only after complete words not between * used seo function and in some templates */ function wordLimiter($str = '', $limit = 120, $endstr = '...'){ if($str == '') return ''; if(strlen($str) <= $limit) return $str; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } $out .= $endstr; return $out; } /** * Alternative with regex for striptags function * used for seo function and in some templates */ function ripTags($string) { // ----- remove HTML TAGs ----- $string = preg_replace ('/<[^>]*>/', ' ', $string); // ----- remove control characters ----- $string = str_replace("\r", '', $string); // --- replace with empty space $string = str_replace("\n", ' ', $string); // --- replace with space $string = str_replace("\t", ' ', $string); // --- replace with space // ----- remove multiple spaces ----- $string = trim(preg_replace('/ {2,}/', ' ', $string)); return $string; }
    1 point
×
×
  • Create New...