Leaderboard
Popular Content
Showing content with the highest reputation on 11/15/2021 in all areas
-
I was addressing your first question This is a different question Have you read the Processwire Documentation ? Your answers are here: https://processwire.com/docs/start/variables/templates/ --------------------------------------------------------------------- Creating a new template with api <?php namespace ProcessWire; $fieldgroup = new Fieldgroup(); $fieldgroup->name = "something"; $fieldgroup->add("title"); // add some fields $fieldgroup->add("body"); $fieldgroup->add("summary"); $fieldgroup->save(); $template = new Template(); $template->name = "something"; // must be same name as the fieldgroup $template->fieldgroup = $fieldgroup; $template->save(); --------------------------------------------------------------------- Adding fields to a template with api <?php namespace ProcessWire; $template = $templates->get("some_template"); $template->fields->add("body"); // add some fields $template->fields->add("summary"); $template->fields->add("images"); $template->fields->save(); --------------------------------------------------------------------- Forum https://processwire.com/talk/topic/4921-how-to-create-template-file-using-api-under-a-module/ https://processwire.com/talk/topic/352-creating-pages-via-api/ Examples https://processwire-recipes.com/recipes/add-fields-to-template/ Beginner mistakes https://processwire.com/talk/topic/19415-trying-to-create-field-using-api/3 points
-
As a general rule (not related to PW specifically), when you see an inline style in the DOM it's almost always an indication that the style was added by JavaScript. It's not because somebody has some preference for inline styles as such. So if you see an inline style in the PW admin it's probably because the style needs to be set dynamically by JavaScript (or needed to be at the time the admin theme was authored). No doubt. But some of the bundled PW admin themes pre-date widespread browser support for flexbox. And fully overhauling a legacy admin theme would be huge job that I expect is not a major priority for Ryan. I haven't seen this in AdminThemeUikit, which is the most recently added core theme. If CSS3 features like flexbox are important to you then this is the admin theme you want to be using.3 points
-
Hello, @fruid! I think it is because of limit of RAM in your php.ini file. You can set memory_limit = 512M or larger instead of 256M there. Very likely the backup consumes more than 256M of memory.2 points
-
@ryan - Ok, I tracked that error down. Uninstalling the module is what triggered that. It turns out that during the uninstall, if I dump $change from inside this foreach: foreach($changes as $key => $change) { I get: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'page_autosave_changes' doesn't exist But back to the more important issue of why the module doesn't actually work for me. Firstly, the module does work on my local dev environment, but on a live servers, it doesn't. I still keep getting: "ajax error: error" If I inspect the Network tab, I see a 500 error for: /page/edit/?id=8074&modified=1636913850&fields=body but there don't seem to be any PHP errors, so I went looking in the apache logs and I am seeing these: [Sun Nov 14 09:54:27.525633 2021] [proxy_fcgi:error] [pid 24560:tid 139854520305408] (70007)The timeout specified has expired: [client 154.5.162.190:51384] AH01075: Error dispatching request to : (polling), referer: /?live_preview=1 [Sun Nov 14 09:54:34.477785 2021] [proxy_fcgi:error] [pid 24560:tid 139854579054336] [client 154.5.162.190:51384] malformed header from script 'index.php': Bad header: {"error":false,"message":"Ajax, referer: /page/edit/?id=8074 [Sun Nov 14 09:54:34.477904 2021] [proxy_fcgi:error] [pid 24560:tid 139854579054336] [client 154.5.162.190:51384] AH01070: Error parsing script headers, referer: /page/edit/?id=8074 [Sun Nov 14 09:54:34.477913 2021] [proxy_fcgi:error] [pid 24560:tid 139854579054336] (22)Invalid argument: [client 154.5.162.190:51384] AH01075: Error dispatching request to : , referer: /page/edit/?id=8074 The Network tab shows Response Headers: content-length: 0 I did a a little investigating to see if there are any known issues with SSE and these errors, but nothing useful so far.2 points
-
Hi all, I am experiencing a very strange issue inside the Tracy console for some time now. While typing, suddenly the new characters get inserted 1 position off to the left of the cursor. This is best demonstrated by a short clip: console.mp4 It makes editing impossible. This started happening on some installs for some time. But now is happening on all. I thought this must be a caching issue then. But it is happening across browsers (FF, Brave, Chrome - all on Linux). No JS errors in the dev console. I did a related search for ace editor that came up with https://stackoverflow.com/questions/15183031/ace-editor-cursor-behaves-incorrectly https://github.com/ajaxorg/ace/issues/2548 https://pretagteam.com/question/wrong-cursor-position-with-ace-editor-in-safari They all refer to a problem with none monospaced fonts used in the editor (specifically on iOs and Linux). Digging through the CSS, I found this rule which is injected in a style attribute by Tracy `<style nonce="" class="tracy-debug">`: .ace_editor, .ace_editor * { font-family: 'Monaco','Menlo','Ubuntu Mono','Consolas','source-code-pro',monospace!important; } When changing the rule to include Courier New, it works: .ace_editor, .ace_editor * { font-family: 'Courier New', 'Monaco','Menlo','Ubuntu Mono','Consolas','source-code-pro',monospace!important; } This might be just an issue on Linux. Can anybody confirm this for other operating systems? @adrian would it be possible to include Courier New in the font-family? This seems to be injected through site/modules/TracyDebugger/scripts/ace-editor/ace.js. So I'm not sure if you have influence on the contents of that file. A search on the ace issue tracker reveiles quite a few related issues. So the problem is well known but hasn't been fixed in years. As a quick fix, I added the extra font to ace.js but this will be gone with the next update. Oh wait, actually this is defined in site/modules/TracyDebugger/styles/styles.css around line 1787. I added Courier New there: .ace_editor, .ace_editor * { font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Courier New', monospace !important; } Would be great if this could be included in one of the next updates.1 point
-
Have you seen the processwire documentation ? https://processwire.com/api/ref/field/ 1) Setup a field of type textarea 2) Echo or include the textarea field where you want it echo $Yourpage->yourfield; include $Yourpage->yourfield;1 point
-
Sweet! ? I love your work and many, many thanks! Although I am disappointed not to be able to use Option B: Percentage based, this at least got rid of the plethora of inline width declarations and the very unwanted maxColHeightSpacer div. Also helps narrow down where the issue might lie. Maybe something about the upgrade has 'reverted' the B option to use the older js inline width and height declarations? Or perhaps a newly added feature to deal with some use-case. Either way, I am stoked for your help and mightily relieved. Love your work, you are a legend!1 point
-
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.1 point
-
1 point
-
While the first link provided by @Ivan Gretsky seems like a good starting point for creating forms with InputfieldForm, note that this is not exactly the simplest thing to do. Personally I've never found it very intuitive, or very useful for that matter. (This, of course, is a highly opinionated statement — so take it with a grain of salt.) In my opinion it's almost always easier to just create a basic HTML form: <form action="." method="POST"> <label for="your_name">Your name</label> <input type="text" name="your_name" id="your_name"> <input type="submit"> </form> ... and then process form input in the template file: <?php namespace ProcessWire; if ($input->post->your_name) { // always sanitize user input (https://processwire.com/api/ref/sanitizer/) $your_name = $sanitizer->entities($your_name); // do something with input echo "<p>Hi " . $your_name . "! What's up?</p>"; } Of course that's a super-simplified example, but hope you get the point. Using InputfieldForm, InputfieldText, InputfieldSubmit etc. is doable, but in many cases they mainly just add a whole new layer of complexity without much actual benefit ? If you want to save values to custom database tables, you need to work with "raw" SQL through the $database object. But here's the kicker: The preferred way to save data in ProcessWire is through pages. A "page" is essentially a general purpose data storage object: you can use pages to store publicly viewable (front-end) content, as well as (back-end only) categories or tags, or form entries — or really whatever it is that you need to store. The API is largely built around working with pages: creating, finding, reading, modifying, and deleting them. Again: you can work directly with database tables through the $database object, but that's not really what ProcessWire was built for. (It's useful for special situations, but for a beginner that's not what I would recommend starting with.) As such, likely the easiest way to save data would be to create a template with fields related to your entries, and then on each form entry creating, populating, and saving a page using that template. That's not necessarily scalable if you expect tens or hundreds of thousands of entries in a short period of time, but apart from that it will work just fine ? ... although, to be fair, a lot of folks just use Form Builder for building and managing forms. It's a commercial module, but in the long term it saves so much time and makes things so easy that it's well worth it. Especially if you're working on projects that you get paid for. This depends on the context: if you're writing code in a template file (/site/templates/some-template.php) then you can use $modules. If you're writing code within a class that extends the Wire object — module, Page class, etc. — then you need to use $this->modules instead. And if you're writing code within a module, you generally use wire('modules'), etc. Here's a docs page explaining when to use what: https://processwire.com/docs/start/api-access/.1 point
-
Thanks @ryan. All the pieces were already in place. I've been working on this concept for a while now and with live preview, everything has come together. @Ivan Gretsky That's just with custom CSS I'm loading in the admin. Like this: // assuming RM field is called 'builder' and matrix-type is called 'builder_column' #wrap_Inputfield_builder [data-typename="builder_column"].InputfieldRepeaterItem > label.InputfieldHeader { outline: 1px solid #777; outline-color: #777; background-color: #777; } @bernhard The 'options' field (powered by Mystique) has a plethora of options for each matrix-type. The 'Image' matrix-type has a 'width' and 'height' field that if set, will set it to the specified width (->width(width)), specified height (->height(height)) or size (->size(width, height)). If no values are entered, it uses the original dimensions.1 point
-
Here's a video demonstrating a RepeaterMatrix full page builder using PageAutosave with live preview. I really want to hear your feedback if you think "non-coders", but those with decent skills, could use such a builder successfully.1 point
-
Yes! Just downloaded it for tomorrow to play around with it. I have to thank you, @ryan!1 point
-
@wbmnfktr Sounds good, those are the boards you are able to view? I've added it to the first one you mentioned (ProFields board). Thanks.1 point
-
My solution to this has been simply to add a warning in ready.php. The solution above looks neater though, and not dismissible (which may be a good or bad thing).1 point
-
There is an option in template settings (Advanced tab -> Template toggles -> Allow the 'created user' to be changed on pages). After you activated this, you can use the API (inside a template or via Tracy Debugger console): $p = $pages->get(11201); d($p->created_users_id); // 41 $p->created_users_id = 10040; $p->save(); d($p->created_users_id); // 10040 d() is dump command inside Tracy1 point
-
Here are a few links to check out for PW calendars. I'm not recommending a solution here, just signposting. These are in the official PW module repository... https://github.com/ffub/MarkupiCalendar (iCalendar feeds anyone?) https://github.com/netcarver/PW-ProcessGcalEmbed (My old module) http://www.99lime.com/modules/recurme/ (Premium) These aren't (a.f.a.i.k.)... https://github.com/plauclair/Calendar https://github.com/ryancramerdesign/MarkupLoadGCal (Ryan's module) https://github.com/decadeofdefeat/church-website-processwire (Has a calendar implementation in it) https://github.com/lindquist/processwire-calendar https://github.com/UF-Asq-Fab-Lab/Scheduler Hope that helps!1 point
-
if you are not going to build your own, using PW data and frontend libs like fullcalendar, then you may want to look at this: http://modules.processwire.com/modules/inputfield-recurme/1 point
-
Hello everybody, I guess an easy question for you gusys: How can I configure ckeditor to look like here in the Forums? Actually I only need Text Color right now, but I don't know what kind of values I can add to the body input field. ckeditor toolbar settings look like the right place, I just don't know the options...1 point
-
Sorry Martijn, I used the "Answer-fast-and-edit-afterwards" trick But for my defence, I had to look up the code to be sure1 point