Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/18/2021 in all areas

  1. The word "tag" is very a technical thing. Call them "keywords" instead, and more than half of your users' questions will evaporate instantly. That's what I learned at my current job when I trained colleagues and heard the relieved insight, "Oh, you're talking about keywords!" rather often. The other half you'll only catch with real-life examples. Depending on the number of pages and content editors, it might make sense to moderate keywords for a while until everybody got their footing. Just a small Pages::published hook that sends a backend link to the new page to the tags moderator so they can give the chosen tags a once over and clarify with the editor what makes sense and what doesn't. I did that with a small knowledge base section for our technical sales managers when they went into a new market area, and we used the direct feedback to fill the tags (later keywords) FAQ with examples and explanations that made sense to them. Actually, that's no longer the case. Since 3.0.177, you can use the new InputfieldTextTags, and choosing a delimiter other than space will allow multi word tags.
    3 points
  2. Hi, welcome to the ProcessWire forums! The questions in your recent threads are kind of broad and it’s difficult to tell what exactly you’re struggling with and what you already know. I’m assuming you have ProcessWire installed and working, and you want to save some user inputs from the frontend into the fields you have created in PW’s admin area. Saving fields using the ProcessWire API First of all, you need a page to hold the data. Perhaps this page already exists, then you just get it using selectors, or maybe it’s the page you’re already on. Likely you want to save a new page for every time a user fills out the form, so let’s create a page: $p = new Page(); $p->template = 'form-submission'; //or whatever your template is called $p->parent = wire('pages')->get('/submissions/'); //or whatever the parent page is called Nice. Now, to get the information from the form you’re going to need ProcessWire’s input capabilities. You can find out all about it at the link and you’ll need to make some decisions about validation/sanitization depending on the data you’re dealing with, but the gist is to get stuff from the POST request sent by your user and put it into fields. Let’s say your user submits their e-mail address and you want to save it to a field called email: /* You see the name “email” three times: * 1. The first is the field you set up in the admin area. * 2. The second is the sanitizer that makes sure the thing the * user sent you actually looks like an email address. * 3. The third is the name of the input from from the form the * user filled out and submitted. */ $p->email = $input->post->email('email'); //Now you will probably want to fill out some more fields the same way: $p->comment = $input->post->textarea('comment'); $p->title = 'Form submission from ' . date('Y-m-d H:i'); Then you save the page and you’re done. You can go to the admin backend and check out the newly created page. $p->save(); However, we haven’t talked about the frontend bits yet. Creating a frontend form and sending submissions to ProcessWire Once again much depends on what you actually want to do, but for simplicity’s sake, let’s say this all happens on the same page. You have a ProcessWire template associated with a template file and all the above code is in it. Now we put the form into the same file. Basically the form is sent to the same page it’s coming from, but as you’ve seen above, you can still create the new page wherever you want. So here’s a simple HTML form that submits to the same page: <form method="POST" action="<?php echo $page->url; ?>"> <label for="email">Your e-mail address</label> <input name="email" type="email" /> <label for="comment">Your comment (no swearing!!!)</label> <textarea name="comment" rows="5"></textarea> <input type="submit" value="Send"/> </form> Note how the names of the input fields match the names we accessed earlier using $input->post(). Putting it together If you simply copy all my code blocks into your template file, you’ll probably notice that it tries to create a new page ever time the page is loaded. You’ll need to figure out if there is a form submission at all before you deal with it, and otherwise just skip that part and show the blank form. You may just check if there is anything in the comment variable. So here is your complete template file: <?php namespace ProcessWire; $thanks = ""; if ($input->post('comment')) { $p = new Page(); $p->template = 'form-submission'; //or whatever your template is called $p->parent = wire('pages')->get('/submissions/'); //or whatever the parent page is called $p->email = $input->post->email('email'); $p->comment = $input->post->textarea('comment'); $p->title = 'Form submission from ' . date('Y-m-d H:i'); $p->save(); $thanks = "Thanks a bunch, we value your feedback!"; } ?> <!doctype html> <html> <head> <title>Post a comment</title> </head> <body> <?php if ($thanks !== "") { echo "<h1>{$thanks}</h1>"; } ?> <form method="POST" action="<?php echo $page->url; ?>"> <label for="email">Your e-mail address</label> <input name="email" type="email" /> <label for="comment">Your comment (no swearing!!!)</label> <textarea name="comment" rows="5"></textarea> <input type="submit" value="Send"/> </form> </body> </html> Now I’m not saying you should put this exact code on your website, but it’s a demonstration of the most bare-bones things you’ll need to get input from users: A HTML form that generates a POST request and some PHP code to receive it. It doesn’t matter where these things are or what they’re called or how they’re generated. In this example we’ve written the form by hand because it’s easy, but you could just as well generate it from ProcessWire’s fields.
    3 points
  3. Hello, my Processwire family. Just minutes ago I flipped on the switch for my agency's new website. Check it out here: https://supertiny.agency/ This is a year of changes. I've finished my collab with a major studio, focused back on Supertiny, Liliana joined me for marketing, campaigns and strategy services, and over the last few months I've been working on the agency's website overhaul. Curiosities: Threejs based intro: After learning a few new tricks from the Awwwards winner Bruno Simon and his incredible course, I went oldschool and made an intro for this website. The intro runs once, the session remembers it's been played and turns to a discreet mode if users return to the homepage, allowing a replay. Using my Tiny Cookie Consent as a web component, I made an approach that I'll probably use a lot going forward. I have a text field in the CMS for all the scripts, and with some PHP find/replace that's undone on the client side, trackers and stats are being turned on only when the user allows it. As usual, repeaters and content blocks allow mix and match when building content. The design and overall vibe takes cues from 80's sci-fi. When I started designing this I was playing Control on my PS4 and overloaded with nostalgia, and attempted to convey some of that in this website. Now, there's a bit of an experiment here. All UX bibles are saying that it's a sin make an intro, lock scroll and whatnot. But this is a site users are probably only going to see once. So my approach here is more like a Yield sign. There's an intro, the scroll is locked, but you have a skip button. I'm basically trying to make the user slow down a bit and take in the concept, but let them through if they're really in a rush. Also, as a communication strategy, I'm placing my bets on case studies that will be promoted in social networks, and also new content on the Insights which will hopefully become more interesting with video content. Users coming from there will only see the intro if after seeing that content they get curious and have a lookaround. This is making sense in my head, but it's a bet. I'm curious to see how it performs and if I have to change the approach. Let me know what you think.
    2 points
  4. Hi @Robin S, I made a pull request to add a new method `addFromUrl` to Pagefiles. In a project I'm working on I needed this function from the API. Coming across your module I extracted the bit I was interested in but then I thought it might be a good addition to your module. Hope it helps!
    1 point
  5. From a conversation with ryan I think to remember that /site/assets is supposed to be writable while /site/templates is not. https://processwire.com/docs/start/structure/files/ does not state the latter one but it confirms my first point.
    1 point
  6. Generally that's correct, htmx.onLoad() replaces the standard jQuery initalizer. Only real trick is that you initialize stuff in the content passed in to the onLoad() callback, rather than initializing the whole document like you do normally in jquery: Note that the query selector is run against the newly inserted `content` element, rather than globally, so you can initialize the library just for the new content that has been added to the DOM (and avoid accidental double-initialization of things.) Alternatives are: using alpine to init the element on load using hyperscript to init the element on load The first one is sane, but not how I would do it unless I already had alpine in my code base and I was comfortable with it. The second one is insane and not recommended, but I do love hyperscript.
    1 point
  7. I had quite a bit of fun watching the intro video. It didn't really seem to (for me) add anything of value in terms of purpose or content, but it was fun - and different. If all websites started doing this I'd definitely be turned off, but in a case where it's a unique scenario and having some free time, it worked well. I'd be curious - if you're willing - to hear more about how you're handling the cookie consent to only allow scripts if/when a user allows it? It sounds like it's a fairly simple, yet robust solution, and since there are many various solutions to this, I'd be curious to hear yours (again, if you're willing to share). A well done, clean design overall! I might pop a link to this over to Jack McDade (yes, Statamic's Jack McDade) since he loves 80's/90's style designs, though his are more in the pop-fashion that SciFi, he does love everything from that decade genre.
    1 point
  8. What if… Visual Studio Code became the editor of in-browser Developer Tools? www.youtube.com/watch?v=77qEmDlFtzg https://www.youtube.com/watch?v=g_TpkkmYzXs
    1 point
  9. There you go ?. Thanks for responding to my Reddit post. It **really** is an honor.
    1 point
  10. Nice catch @bernhard - should be fixed in the latest version. FYI in case you don't already know - if you are on the module settings page, the RequestInfo panel will show all the module settings. Also, you can just do: d($module); when on a module settings page because $module is set to the current module, same as $field and $template when on the settings for any field or template.
    1 point
  11. ? I appreciate that, but htmx is fairly feature complete and is supported by my other work. intercooler.js, the predecessor to htmx, has been up for nearly a decade without any sponsorships: https://intercoolerjs.org I don't anticipate htmx being any different, although I always do appreciate any sponsorships! Thank you for the warm welcomes. I don't know how useful I'll be, but I'll try to answer any questions I can around htmx as honestly as possible.
    1 point
  12. Carson, what an honour to have you here! ?.
    1 point
  13. The newest posted versions of PageAutosave (v3 and v4 in ProDevTools, ProDrafts, ProFields) adds the following: Support for alternate event driven ajax live preview mode, which appears to provide improved performance and work in live environments where the streaming/SSE didn't. Since this seems to work better, it is the new default setting. The SSE option is still there but you have to manually select it in the module settings if you want it. Support for remembering live preview window position, plus automatically detecting and using an optimal preview window position. Meaning, it'll find the location on the screen where there is the most room for the preview window and then move and resize it there. Once the window is in position (or if you move or resize it) it'll remember your setting in a cookie so that you won't have to move and resize your live preview window every time you edit another page. Automatic insertion of pw-value-* classes in markup to support replacement of individual fields native to $page, without having to re-render the page. This means you no longer have to insert your own pw-value-* classes in markup for improved performance, as the module will do it for you when rendering a live preview request. If it causes any issues with your site, you can optionally turn off the feature in the module settings.
    1 point
  14. Field that stores one or more references to ProcessWire pages with additional data in field context. Values are editable via page edit modal of the referenced page provided from the field if module AdminPageFieldEditLinks is installed and "Enable link to create new pages?" is checked in field settings. Requirements: AdminPageFieldEditLinks >= 3.1.4 https://github.com/kixe/FieldtypePageContextData https://processwire.com/modules/fieldtype-page-context-data/ Use case example: The planning of the Tonmeistertagung in the CCD (Congress Center Düsseldorf) from November 3rd, 2021 to November 6th, 2021 is in the finalization phase. The conference consists of a conference part and an exhibition. The planning is done via a separate frontendless PW instance. There, all companies (pages) that are active at various events are kept in a pool. Changes (address, logo) can always be done there. For the exhibition of the current conference in November, the exhibitor-companies (pages) are selected via a page reference field. A stand number must now be assigned to each selected company (page). We had originally solved this using the Profield FieldtypeTable. However, this had the disadvantage that each entry again made all companies available for selection and did not recognize which were already selected in a previous table row. The new field type now allows the value (company's stand number) to be assigned to a Company (page) in context to a specific Pagefield living in a specific page. https://tonmeistertagung.com/en/exhibitors/exhibition/
    1 point
  15. Thanks for the clarification ? Grouping can be done by pretty much any imaginable way with ProcessWire data types as well, but I was wondering if this would be solvable with something that's "generic enough" to be added to the module as a feature. Technically I could add settings for grouping with custom fields etc. as well, but that sounds like it would be a lot more complex — as a module setting, meaning that it would have to work with a lot of different configurations — than just by template.
    1 point
  16. I don't know the drawbacks of this, but I just managed to do make the dynamic stylesheet proposed on css tricks work has a pw template. So, this is how to do it (someone stop me if this is a bad bad thing to do): 1. Create a template file css.php and put all your css code inside. On the top of the file put this code <?php header("Content-type: text/css"); ?>. 2. Create a "css" PW template with that file. 3. Create a "css" page and give it the "css" template. 4. Link to the stylesheet like this <link rel="stylesheet" href="<?php echo $pages->get('/css/')->url; ?>">. 5. use the PW API on your stylesheet Extra: 6. put some fields on the "css" template and use them on your css Examples: the color picker field for colors; an image field with your style pictures (background, logo, etc). edit: onjegolders was faster! edit2: not the same answer. Mine is more interesting
    1 point
×
×
  • Create New...