Jump to content

flydev

Members
  • Posts

    1,339
  • Joined

  • Last visited

  • Days Won

    48

Everything posted by flydev

  1. Hi, I had integrated ViteJS a year ago or a bit more, it could be used to build for example a dashboard, or even a website, but the main issue I faced was to make Server Side Rendering working with all the setup to be able to get better SEO/ranking. That's said, SSR code was done this morning ๐ŸŽ‰๐ŸŽ‰ The test below was made on a non optimized Caddy setup on Windows with sad php-fpm. I built a javascript package which will be published on NPM to give you a smooth experience to integrate Vite into ProcessWire. I have to build a ProcessWire module to make thing even easier instead of putting some file in our template dir, that will be made asap as it doesn't require lot of work. It's also shipped with InertiaJS which I find no point of not using it, but could be used without it. Everything can work with Svelte Framework (I am a big fan of it, I feel like coding web on the 2k years), React work also, and Vue should work without hassle as any other frameworks/libraries. Just saying, but his one I think will not be much of interest for you, I also built a solution which replace Electron for building desktop application based on native code (Pascal) and JavaScript bindings, where ProcessWire is used as headless cms (I think I had already spoke about it in some threads), it could be used as is without the need to put your hand in native code. I'm curious to hear what others in the ProcessWire community think about using ViteJS for your development. Have you tried it before? What has your experience been like? Please share your thoughts and feedback in the comments, and feel free to vote in the poll below to let me know if you're interested in more tutorials and resources on this topic, like profiles, themes. And pheww, I am quite happy! ๐Ÿฅท
  2. In any case, it has not stopped since 2020, it is rather worse. Time to put a captcha thing maybe.
  3. Another option could be copy/paste the core ProcessModule inside site/module (it could be patched on ProcessWire version upgrade, if needed, automatically). Maybe @Robin S will have a clearer idea.
  4. Make sure: in myTemplate settings>URLs you Allow URL Segments then // decomposed example $title = $input->urlSegment1; // single $ref = $pages->get("template=myTemplate, title=$title"); // get retrieve a single result $pageList = $pages->find("template=myTemplate, prfield=$ref"); // or if many is needed $refs = $pages->find("template=myTemplate, title=$title|Foo|Bar"); // find retrieve a page array $pageList = $pages->find("template=myTemplate, prfield=$refs");
  5. Give a read to this Ryan 2012 answer. Then, a good habit in pw, is to just read his clear and concise comments on the source code, easy as .. Do not hesitate to ask for help if needed. Documentation: https://processwire.com/api/ref/wire-database-p-d-o/
  6. A friend of mine has changed his job, he owns a video game room, he now "develops" websites, I could see a result, and the tools used, I prefer to keep quiet here (it's in the title). I have to interfere in his conversion process before it's too late: Have the right habits, keep in mind that the goal is to help the client to improve the conversion of his business through his website, and thus to make more money rather than losing it. Otherwise, what's the point, an instagram or facebook page would have been enough. So I wanted to make a synthesis of the arguments to make him take into account, I also saw an old forum thread that came up recently, so I wanted to ask a neutral "person" (person.. lol) what she think. I have the impression that the arguments are those already exposed in the answers given to these threads. In short, a good synthesis, I think, and non-biased, I hope. As always, the same question, "How to convince my client to use Processwire instead Wordpress?" Yours sincerely, GPT ๐Ÿค–
  7. PHP as there is no HTML file to lookup anymore, use ncm2 and php-actor plugins. But, as a small advice (I am a nano guy, you know it, real programmers use nano lol), do yourself a second favor, try VSCode, optionally install the VIM theme ๐Ÿ˜‚
  8. Welcome, I see you already got gud answers, and I like to put as always what made me understand ProcessWire on first start. https://youtube.com/watch?v=IHqnLQy9R1A There is one or two more vid to see. Then there on the forum is a lot of good threads. I am on mobile so I give you the oldest but still โœ… to follow, quite a gold post for beginners : https://processwire.com/talk/topic/4173-grouped-forum-posts-links-articles-tutorials-code-snippets/ Forgot to add something you should also consider giving a look - page-grid - https://weekly.pw/issue/454/ Enjoy ๐Ÿ™‚
  9. @SebastianP if you really need the module, you can try to check xhr (I can't confirm the behavior..): if (!$this->config->ajax) { // add this if(in_array('View', $this->hiddenTabs)) { $event->return .= ' <script> $(document).ready(function() { $("#_ProcessPageEditViewDropdown").remove(); }); </script>'; } } // <-- add this https://github.com/adrianbj/RestrictTabView/blob/88bbee5a1fbf9a52e16df8573c0a243ee9feca97/RestrictTabView.module.php#L72-L79
  10. Hi, we need more details. Modules, Version, logs, etc. Essentially this sort of issue arise when html markup is returned before the JSON result expected, then the xhr fail. My bet is that you have a hook somewhere, do you have something related in ready.php or _init.php or admin.php ?
  11. Hello, A simple way, by code, could be to redirect the user if the page is hidden. In the page's settings set the status `hidden` and then in the template(s) you can do: <?php namespace ProcessWire; // Template file for pages using the โ€œbasic-pageโ€ template // the code below is an example of how to check if a page is hidden or unpublished // and redirect to the homepage if it's the case. // (/? hint > the check use a bitwise OR operator) if ($page->is(Page::statusHidden | Page::statusUnpublished)) { $session->redirect($pages->get('/')->url); // redirect the user } ?> <div id="content"> Contact or Company page </div> Another simple way, using template's settings, is to remove the view access of the guest role, see :
  12. Thanks @Claus, fixed, you can grab the new version. Can you tell me which type of host and the name if not secret please ? (use private messaging if you want)
  13. And to be sure, you can try the code above on a mock server: // $url = 'https://json-api-url-domain.com/matches?id=XX&division=YY&teams=[ZZ]'; $url = 'https://my-json-server.typicode.com/typicode/demo/comments'; With pw, or not - should give you a resource ok message, a 200 http code, with an array of two objects as a result.
  14. Ok, then try the following, you need to know what's the error. Which version of PHP you are running the code on ? Also, checking the target logs might give you more hints on what's is missing. A cookie maybe ? $url = 'https://json-api-url-domain.com/matches?id=XX&division=YY&teams=[ZZ]'; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json' )); $result = curl_exec($cURL); if (curl_errno($cURL)) { echo curl_error($cURL); die(); } $http_code = curl_getinfo($cURL, CURLINFO_HTTP_CODE); if ($http_code == intval(200)) { $json = json_decode($result, true); echo "Resource OK: "; var_dump($json); } else { echo "Resource NOTOK: " . $http_code; } die();
  15. If you are throwing the request from a ProcessWire template, then please show us the code. The 500 error is quite strange there, you should at least get a pw exception if $debug is true, and in reality, you shouldn't get a 500 error. (The code posted above run on PW with php-7/8 printing curl error if one exist) Gve more details on your setup ๐Ÿ™‚ The site is the source or the target ?
  16. Hi, the code seem good, and what I understand from the result, is that the request is ok, as you get a result, but as a result, the server tell you there was an error, and it seem that the error come from a javascript backend. You could try to run curl from cmd line, and compare response headers. Are you sure you do not need CURLOPT_FOLLOWLOCATION ? try to dump error: $url = 'https://json-api-url-domain.com/matches?id=XX&division=YY&teams=[ZZ]'; $cURL = curl_init(); try { curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json' )); $result = curl_exec($cURL); if (curl_errno($cURL)) { echo curl_error($cURL); die(); } $http_code = curl_getinfo($cURL, CURLINFO_HTTP_CODE); if ($http_code == intval(200)) { $json = json_decode($result, true); echo "Resource OK: "; var_dump($json); } else { echo "Resource NOTOK: " . $http_code; } } catch (\Throwable $th) { throw $th; } finally { curl_close($cURL); } die();
  17. Test the solution below if it fit your needs : if ($user->hasRole('testrole')) { // $ap = $user->editable_pages[0]->id; //there is always only one page // $wire->addHookBefore('Page(id!=' . $ap . '|1023)::listable', function ($event) { //1058 is the id of the parent page // $event->return = false; // }); // ๐Ÿ‘‡ // get the parent id of the user's editable page $parent_id = $user->editable_pages[0]->parent_id; //there is always only one page $this->addHookBefore('ProcessPageList::execute', function (HookEvent $event) { // hide root (/) page in list (optional) $event->object->showRootPage = false; // limit number of pages shown - that's the trick to avoid pagination in the lister $event->object->limit = 100; // you might need to adjust this value }); $this->addHookAfter('ProcessPageList::execute', function (HookEvent $event) use ($parent_id) { // run only on ajax requests if ($this->config->ajax) { // manipulate the json returned $json = json_decode($event->return, true); // remove any pages that are not editable or addable and not the parent page foreach ($json['children'] as $key => $child) { $p = $this->pages->get($child['id']); if (!$p['editable'] && !$p['addable'] && $p['id'] !== $parent_id) { // remove the page from the json unset($json['children'][$key]); } } // set the json back to the event $json['children'] = array_values($json['children']); $event->return = json_encode($json); } }); }
  18. Ah yes I see. I remember a discussion about it. I cant confirm itโ€™s possible with a simple hook. From mobile right now - but you can try to hook ProcessPageLister ___find, the goal is to remove unwanted pages from the JSON result. Adrian might have an answer here.
  19. I don't get the whole idea, but you might be able to achieve it using path-hooks to handle pagination. Look there if it can help: https://processwire.com/blog/posts/pw-3.0.173/#handling-pagination
  20. Hello, the following is quite an opinionated use. On complex layout, where the fields might also be re-used on differents templates, I tend to give as name to my fields `text1`, `text2`, `text3` ... and override the Label on template basis.
  21. Thanks @DV-JF just fixed it to make things easier.
  22. Fixed it, it will be released in Duplicator v1.5.0. I tested AWS, no problem found. I will release also the updated Duplicator-SDKs. It's committed.
ร—
ร—
  • Create New...