Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/03/2023 in all areas

  1. In PW you would typically use https://processwire.com/docs/front-end/how-to-use-url-segments/ The docs should help you get started. If not, feel free to ask.
    2 points
  2. I'm putting this here in case anyone finds this useful (or I google this myself in a few years)... Let's say you have the following in config.php: // config.php $config->myArray = [ 'foo' => [ 'k1' => 'v1', 'k2' => 'v2' ], 'bar' => 'some string', 'baz' => ['some', 'other', 'array'] ]; Now you want to want to add an item to the 'foo' array somewhere else in your codebase (template file, a module's init method, etc.). This won't work (overloaded notice will occur): $config->myArray['foo']['k3'] = 'v3'; Correct way to do it: $config->myArray = array_merge( $config->myArray, [ 'foo' => // existing $config->myArray['foo'] + // new [ 'k3' => 'v3' ] ] );
    2 points
  3. 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! 🥷
    1 point
  4. Ok got it!! I understand it all a lot better now, thanks!
    1 point
  5. Sorry to be so unclear! But this "we" referred to the PW project! 🤩 And yes, as @Jan Romero already said, it is only one in the wire directory, so that you can use your own in the site directories.
    1 point
  6. The error that you are seeing comes from RockMigrations and not from get_defined_vars() - sorry for that. It has been fixed in the dev branch here already: https://github.com/baumrock/RockMigrations/commit/3ab756003e697f5fb2af0e2357094613464bd901#diff-f2f9bf51d98ac65f5b9abedff5f904a71b54b3ba563b1756756a37c5e9852635L4326 The problem was that ->getInfo()['version'] did not work anymore since I split the module info into it's own file to support PHP8 requirement. I'll merge everything into main soon 🙂
    1 point
  7. It's all about consuming data provided in your templates from your components. To give you an example with repeater, imagine the navigation is built from a function in the template home.php which return a JSON object with all required page's name, child, id, href, etc.. Now, I want to use a repeater to build the navigation object. I can add a new repeater in the home template and write the code to make the navigation object with a foreach(...) loop. If the object contain more or less the same structure which can already feed the data expected by the Navigation.svelte component, then you do not need to build the site again. You only need to rebuild when you make change in your component(s). Not the template(s) php or backend field's. If you require a site completely static, this setup is not really made for, you could achieve it already by providing all your data from API and coding the static route in your app.
    1 point
  8. With this I mean edits in a CKEditor, or added a repeater item that update some content in the form of a list. Is "npm run build" ran after updating this content? Do this updated trigger a "rebuild workflow" (for example for Vercel) so that the site is completely statically generated?
    1 point
  9. There is a setting for url fields to allow or disallow quotation marks. I’m pretty sure it defaults to disallowing them. Have you checked that?
    1 point
  10. Thanks @elabx for your input. The first live example1 will be the doc which is built on top of this stack and it will also be released as a profile. I am currently rushing a thing for the work, so I hope to release the module on incoming week-end or at least next week. (you can find one online, built with Svelte, ProcessWire, ThreeJS and shaders as an experiment, but here is not much thing to see as it's not finished 1). What is planed is to release the ProcessWire's Vite module, to publish the NPM package, the doc and the associated profile. There will be also a profile for React and Vue released. I will release it as an alpha-version, but if the stack is used without SSR, like for building a dashboard, it can be considered as STABLE. If some of you want to integrate, eg. Elm or Angular, I will give support for it on request basis. I think that most users already using Vite are aware of getting their framework working, maybe some of them are just confused about the integration into ProcessWire and using his built-in API/pages/templates. Then once the technical article will be online, you will get the idea of how to integrate Vite or other bundler easily in PW or even other pieces of software. Wordpress what ? 🤣 (you can get deeper on the request, I don't get it 😉 )
    1 point
  11. It’s only in the /wire/ directory so you can do your own thing in /site/.
    1 point
  12. HTMX is not listed because HTMX is a different tool and do not require ViteJS which is a build tool and development server that focuses on providing a fast development experience using features like native ES modules, hot module replacement, and optimized production builds, and if it was, you could say I am quite confused. But I can say they can be used together in certain scenarios and we could start another thread with constructives and interestings discussions, sharing each other experiences. It's really about how you use ProcessWire, and differents topics, like flexibility, complexity and requirements of what you need to build the final product. I really understand why a developer take the way of HTMX's for a simple and dynamic website or even web-app without the need for JavaScript frameworks, it's not new, we used ajax 20 years ago, it's funny. To give an example of why I am personally using a frameworks like Svelte, and ViteJS to build the thing, is that I need to consume JSON data and not HTML fragment to interact with other native apps. And in a complex scenario, the benefits of Svelte's component-based architecture, reactive programming model, and offline capabilities outweigh the simplicity offered by HTMX. Again, this is really a question of requirements more than anything else. Another little example, if was using HTMX in my pages written in Pascal, this will quickly turns into a huge mess. What I could add as a bonus for HTMX, it will level up the level of frontends devs on a team. All that said, HTMX is out of topic here 🙂 🙂
    1 point
  13. @WillyC yes, the use case was an import - a big migration from another CMS; I wanted to maintain a known list of tags in memory for efficiency, rather than sending an airplane to fetch all tags again and again - you know, for the climate's sake 😸 But anyway, it's fine. I suppose I could have maintained my own vanilla array index instead of a PageArray but I thought I was being cool using the new tools, until I found out it's a tractor. Anyway, tis done now. @flydev thanks, but that requires me to know that there aren't two distinct items: "system change" and "change system". At first I posted because I thought there might be something I was missing (like WireArray::setCaseInsensitiveMatching() or such). But then as I dug into it I found that the limitations are hard coded. None of the help/docs pages I read have any warning of this; there's many examples of chaining from a db query ($pages->find()) into some other filter without warning. I think there should be warnings in the docs about the different implementations, when suggesting filtering on a WireArray, as opposed to a $pages query. I think there should be an equals operator that is explicitly case insensitive. (though perhaps we've exhausted every combination of symbol already...!) I think the codebase should be updated to be UTF-8 compatible so that É matches é, for example on the case-insensitive matchers. But I'm too much of a noob to do PRs yet (and I have to train my editor to use tabs not spaces 🤣) Anyhoo, thanks for the suggestions, all.
    1 point
  14. Hello @Martinus, maybe findRaw() could simplify your solution: $a = $pages->findRaw("parent=/products/, seller=amazon, rating>0", "rating"); print_r ($a); // check array echo array_sum($a); // sum of all values in array Regards, Andreas
    1 point
  15. Well, you can just send your POST request in such a way that the Json will be available as $input->post['myData'], that is, as FormData or UrlEncoded: fetch('https://example.com', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Requested-With': 'XMLHttpRequest' }, body: new URLSearchParams({ 'myData': JSON.stringify(someObject) }) }); or const formData = new FormData(); formData.append('myData', JSON.stringify(someObject)); fetch('https://example.com', { method: 'POST', headers: { 'X-Requested-With': 'XMLHttpRequest' }, body: formData }); If your object is just a simple key-value affair, you may actually want to send it that way and not as Json at all, because you’ll be able to use the sanitizer methods for each value. With the Json you have to parse it and then sanitize the properties, watch out for properties you didn’t want etc.
    1 point
  16. I am assuming you are using fetch() to send an Ajax request to some endpoint. ProcessWire will not recognise Ajax requests without the below in the header: 'X-Requested-With': 'XMLHttpRequest' The this will work: <?php if($config->ajax){ // handle ajax request here $id = (int) $input->some_input_with_id; }
    1 point
×
×
  • Create New...