Jump to content

flydev πŸ‘ŠπŸ»

Members
  • Posts

    1,135
  • Joined

  • Last visited

  • Days Won

    35

flydev πŸ‘ŠπŸ» last won the day on September 27

flydev πŸ‘ŠπŸ» had the most liked content!

7 Followers

About flydev πŸ‘ŠπŸ»

  • Birthday 09/21/1983

Profile Information

  • Gender
    Male
  • Location
    France πŸ₯–

Recent Profile Visitors

6,247 profile views

flydev πŸ‘ŠπŸ»'s Achievements

Hero Member

Hero Member (6/6)

2k

Reputation

1

Community Answers

  1. The extension look cool and will install it on Windows, but its not available for Chrome iOS :(
  2. @Pete πŸ‘‹ A dark-mode could be available to view the forum ? iam near 40 and my eyes need more obscurity πŸ€¦πŸ»β€β™‚οΈπŸ˜‚
  3. After reading again Steve's messages, I added a new setting (enabled by default) which if set, delete orphaned logs files from the folder. Update to v1.4.26 to get that.
  4. Another update (v1.4.25) with a new setting available to customize the permission set on duplicator.sh when using the Native Mode feature. Thanks @netcarver It also delete the corresponding log file. ℹ️ The module can be upgraded again trough ProcessWireUpgrade, I was only updating a static var forgetting the module version field and then the module version was not reflected in the modules directory.. πŸ€¦β€β™‚οΈ
  5. I said, both module require the file `admin.less` or at least the compiled `admin.css` ? But forgot it, my question doesn't make sense as I didn't read the point #3 on AdminStyleRock github repo πŸ€¦β€β™‚οΈ It might serve as an example how to share your own styles with the community in a modular way instead of sharing admin.less files that can't be updated/monitored by the PW upgrades module.
  6. Yes that is what was planned, I talked about LESS mod, but I used your module in first instance and I think he will receive the PR to give the dark-mode available by default. I might be blind, but what's the difference between the LESS or Rock in the "sharing flow" ? they don't both require the admin.less files ?
  7. It take into account: the official ProcessPageList BreadcrumbDropdowns by @Robin S AutocompleteModuleClassName by @Robin S InputfieldSelectize by @Macrura InputfieldSimpleMDE by @Macrura to be continued...
  8. Just sharing an admin dark mode theme. Still a WIP, I need to figure out how uikit-inverse colors work and a switcher will be pushed. (great rock job @bernhard) Feel free to try it, submit issue or better pull-request. https://github.com/flydev-fr/ProcessWireAdminDarkMode
  9. great perseverance from you, learning new things from each others as always. @szabesz given the answer too there :
  10. Yes, because of the rendering order - (I am used to use the Delayed Output Strat so I can't tell you right now what's going on for real) - wrap the HTML output with `if(!$config->ajax)`. example : _main.php: <?php namespace ProcessWire; // place this on the top - easier for us to debug for your project. // but with the good logic, you could do it by feeling. // // return content set in `header()` (ext/json here) 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($bookmark)) { // add bookmark $bookmarks->add($bookmark); $user->setAndSave('bookmarks', $bookmark); $message = 'Borat saved bookmark "'. $bookmark->id .'" πŸ“Œ'; } else { $message = 'Nothing done'; } $success = true; break; case 'remove': // remove logic if($bookmarks->has($bookmark)) { $bookmarks->remove($bookmark); $user->setAndSave('bookmarks', $bookmarks); $message = 'Borat removed bookmark "'. $bookmark->id .'" ❌'; } else { $message = 'Nothing done'; } $success = true; break; default: $message = 'error'; $success = false; } // build the response data array that will be returned in `data` from `.done(function(data) {` $json = array( 'id' => $bookmarkid, 'action' => $action, 'message' => $message, 'success' => $success ); // convert data and send as JSON header('Content-Type: text/json; charset=utf-8'); // forgot this line echo json_encode($json); return; } ?> <?php // HTML code need to be rendered when a normal request happen (non-ajax, the user dont want the JSON thing, he want text/html to see it in his browser page) // render HTML only if not ajax detected if(!$config->ajax): ?> <!DOCTYPE html> <html lang="en-gb"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <link rel="alternate" href="https://ad-bank.co.uk/" hreflang="en-gb" /> <title> Browse Over 1000 Ad Creative Examples | Adbank.co.uk </title> <!-- .... --> </head> <body class="body"> <!-- Page Header --> <!-- Navigation --> <nav id="nav" class="unhidden"> <!-- .... --> </nav> <div id="content-main" class="adbank"> <!-- .... --> <header class="small-header"> <div class="full-width"> <div class="row flex header-content"> <h1>This is everything!</h1> <p>Here are all the ads we have collated. It seems a lot, it is and it's only growing. Check out the filters or the brand and industry sections. Struggling for inspiration? The blog has features collections based on styles, industries and our personal favourites.</p> </div> </div> </header> <!-- .... --> <div class="breadcrumbs"> <!-- .... --> </div> <!-- .... --> <section id="main-post-area" class="ab-post-area"> <div class="full-width"> <div class="row"> ...... </div> </div> </section> <!-- .... --> </div> <footer> great success </footer> <!-- PUT OUR JQUERY SCRIPT HERE AT THE VERY BOTTOM --> <script> jQuery(document).ready(function($) { // when clicked, send ajax request to server $('button.bookmark').on('click', function(e) { var btn = $(this).hasClass('clicked') ? false : $(this).addClass('clicked'); if (!btn) { console.warn(`⚠️ Bookmark already saved to profile`); return false; } $.post('<?=$pages->get('/')->url?>', { action: $(this).val(), bookmark: btn.data('id') }) .done(function(data) { console.log(data, "πŸ‘‰ response from ajax req"); console.info(`βœ… Bookmark id => ${data.id} ${data.action} `); }); }); }); </script> </body> </html> <?php endif; // /render HTML ?> Adjust you code, fire the button, report back (βœ…β“β“)
  11. 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/
  12. Check with count($page->hero_items))instead of $page->hero_items as it return the field if it exist, not what's inside.
  13. That's because header are already sent before, I mean, there is already output. Move for testing the block, on the top of the _main.php file: <?php namespace ProcessWire; [...] if($config->ajax && $input->post->bookmark){ [...] echo json_encode($json); return; [...] and adjust : `$.post('<?= $page->url?>` to `$.post('<?= $pages->get('/')->url ?>`
  14. We can see that first, request (XHR) is fired with the right data. You need to show us what is inside the "preview" tab to see what's the answer returned (the payload is what you send, the preview is the answer you get). About the code in your last post, (I didn't saw it before), should go in inside there: <?php namespace ProcessWire; [...] if($config->ajax && $input->post->bookmark){ [...] echo json_encode($json); return; [...] This chunk of code is what handle the actions, then put the logic inside it. if($config->ajax && $input->post->bookmark){ bd($input->post->bookmark); // debug post with tracy, lets see whats inside // if something was submited, but the user is not logged in, nohting will be done and we show an error if(!$user->isLoggedin()) { $action = ''; // if user not loggedin, let go to default case. } // user is logged-in else { $bookmarkid = $sanitizer->int($input->post->bookmark); // id of the bookmark $action = $sanitizer->name($input->post->action); // action that need to be done $bookmark = $pages->get($bookmarkid); // instead of $posts, get the bookmark from submitted id to work with bd($bookmark, "bm to work with"); $bookmarks = $user->getUnformatted('bookmarks'); // if($action === 'remove') { // save bookmarks //$user->setAndSave('bookmarks', $bookmarks); //$this->halt(); } switch($action) { // which action ? case 'save': // save logic if(!$bookmarks->has($bookmark)) { // add bookmark $bookmarks->add($bookmark); $user->setAndSave('bookmarks', $bookmark); $message = 'Borat saved bookmark "'. $bookmark->id .'" πŸ“Œ'; } else { $message = 'Nothing done'; } $success = true; break; case 'remove': // remove logic if($bookmarks->has($bookmark)) { $bookmarks->remove($bookmark); $user->setAndSave('bookmarks', $bookmarks); $message = 'Borat removed bookmark "'. $bookmark->id .'" ❌'; } else { $message = 'Nothing done'; } $success = true; break; default: // Default will throw an error $message = 'error borat'; $success = false; } // build the response data array that will be returned in `data` from `.done(function(data) {` $json = array( 'id' => $bookmarkid, 'action' => $action, 'message' => $message, 'success' => $success ); // convert data and send as JSON header('Content-Type: text/json; charset=utf-8'); echo json_encode($json); return; } The issue can be that the template is "include" in the _main.php. I look into it later, show us first the request answer. Your are not far from βœ…
Γ—
Γ—
  • Create New...