-
Posts
695 -
Joined
-
Last visited
-
Days Won
20
Everything posted by Jan Romero
-
That seems good because it’ll continue to work if JavaScript is unavailable. I would keep it. On the server I would keep everything the same and add the $config->ajax condition to send back different output for ajax requests. For example, for a deletion it would suffice to send back success or failure http headers. In your JavaScript you could then hijack all the delete links and open them asynchronously instead: function deleteAsync(event) { event.preventDefault(); const listItem = event.currentTarget.closest('li'); //assuming currentTarget is the clicked link and it’s inside the list item listItem.style.display = 'none'; //immediately hide the item to make the action appear instantaneous const xhttp = new XMLHttpRequest(); xhttp.onload = function() { if (this.status < 200 || this.status >= 300) this.listItem.style.display = 'initial'; //deletion failed, unhide the item and maybe show an error message else this.listItem.remove(); //only really remove the item if deletion was successful }; xhttp.listItem = listItem; //add the item to the request to be able to access it in the onload callback xhttp.open('GET', event.currentTarget.href, true); xhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); //you need this for $config->ajax to work xhttp.send(); }
-
Are you using pagefileSecure? If you do, or otherwise use ProcessWire to send the file, you can change the config to force mp3s to always download using this incantation: $config->fileContentTypes = array_merge($config->fileContentTypes, ['mp3' => '+audio/mpeg']); The + sign in front of the mime type will tell PW to use the header “Content-Disposition: attachment” when sending the file type in question. Cf. https://github.com/processwire/processwire/blob/master/wire/config.php#L632
-
Mh, following the 4 steps from the blog works fine for me on 3.0.172 (in fact, i believe step 2 hasn’t been necessary for a while). Can you confirm that the config takes by putting var_dump($config->pageNameCharset, $config->pageNameWhitelist); into a template somewhere? Btw, just uncommenting 16B in .htaccess won’t do. You must also disable 16A.
-
How to create your very own custom Fieldtypes in ProcessWire
Jan Romero replied to bernhard's topic in Tutorials
Hi @fruid. I’m not going to get into this fully right now, just some suggestions. Most importantly: What you really want to do is just buy FieldtypeTable. It’s dope, trust me. Secondly, do yourself a favor and install Tracy. I have no idea how that error came about, but the stack trace will help you figure it out. If you can’t get it to work, I suggest starting a separate thread with specific questions and code snippets and Tracy traces. Your project is kind of out of scope for Bernhard’s tutorial here ? Well, you’re trying to make a Multi-Field (extend FieldtypeMulti), which is a little more of an endeavor than a single value field. Lastly, you can name a hook’s $event argument anything you want, if that is what you mean. $event is kind of a convention, but you might as well use $e or $hook or $args or whatever. You can even just leave it out if you don’t need it. Hooks work with callback functions. That is to say, it’s your own function. You name the function itself and its arguments. -
Ah, useful, thanks! ?
-
Nice stuff, I’m definitely going to try some of these ? What’s the smiley little guy who is sometimes a sofa? Maybe add a title attribute?
-
No, the values are not imported. It only connects the Fields of the chosen Template to the current Template as well. A Field can be used by multiple Templates. For example you might have a website that showcases a lot of products and also has a blog. For this you could make a Template “product” with Fields for price, dimensions and so on, as well as of course a Field called “title” and a textarea Field called “body” for the product name and a description. Now in your “blog” Template you could use “title” and “body” as well. You can even change some Field settings depending on the Template.
-
Hi @Marvin, you can definitely have all kinds of relationships between pages in ProcessWire. The term “Page” is slightly misleading because it can imply a close connection to a web-page in your front-end. Instead, in object-oriented terms, you can think of pages as objects and templates as classes. To model the relationships between pages you can use page fields and the hierarchy of the page tree (a page will always know its children and parents).
-
I’m only aware of this term in the realm of UI design. If that’s what you mean, ProcessWire will not get in your way implementing such a user interface, since it’s very output agnostic. It’s not clear to me what you’re trying to do. Do you mean this? https://en.wikipedia.org/wiki/Single_Table_Inheritance ProcessWire’s data model doesn’t involve inheritance, if that’s what you mean? You can get a pretty good idea of PW’s database strategy by looking at the tables of an existing PW installation.
-
this is why I for one only make websites that no one is ever going to look at anyway.
-
yeah, the module LanguageSupportPageNames offers this in the module settings.
-
Ticket vendors often temporarily reserve the space as soon as it’s added to the cart. You could use that to count towards the occupied spaces and remove the reservation if the transaction isn’t finalized in time. For example you could store the time of the reservation and to calculate availabilty subtract completed bookings as well as reservations younger than 15 minutes or so.
-
Store the bookings themselves, then subtract the amount of bookings from the available spaces on the fly. Don’t store a single constantly decremented/incremented number!
-
Passing an argument to a page - Best practice question
Jan Romero replied to Davis Harrison Dion's topic in General Support
Yeah, the documentation is kind of buried: https://processwire.com/api/ref/page-render/render-page/. I don’t even know how to get there, really. The PageRender class doesn’t show up on the API frontpage at all… -
Passing an argument to a page - Best practice question
Jan Romero replied to Davis Harrison Dion's topic in General Support
If you use $myPage->render() you can use the options array: echo $myPage->render(['lol' => 'dongs']); /////// then on $myPage’s template ///////// echo $options['lol']; Or you could just add the property to the Page object: $myPage->set('lol', 'dongs'); echo $myPage->render(); /////// then on $myPage’s template ///////// echo $page->lol; -
You can do that with hasChildren() just like you proposed, but you have to get the grandchild first. If you want to get the first child of $page and then the first child of that, and then check if that has children, you can do $page->child()->child()->hasChildren(). You can also put selector strings between each of the parentheses to only get specific children. Yeah, I’m pretty sure this should work: $pages->count("has_parent=$child, template=tops|tops2, projekt_top_vermietet=1") If you already know there aren’t any other templates under $child, you can just remove the template selector entirely.
-
You mean like this? Use this very hackish hook and replace the word “tabcontents” with the name of your FieldsetPage field: $this->addHookAfter('ProcessPageEdit::execute', function(HookEvent $event) { $event->return = $event->return . '<script>document.querySelector("#wrap_Inputfield_tabcontents > label.InputfieldHeader").remove();</script>'; }); Might want to only apply it to certain templates, too, but whatever. Sorry, I couldn’t find an easy way to remove the element from the output directly, but this should be fine.
-
you’re missing october there ?
-
$config->pageNameWhitelist = ''; This should allow everything that gets past .htaccess. It will only remove some characters explicitly blacklisted in the core.
-
I was a pretty confused here, but I see now that FieldsetGroup is a Pro Module and FieldsetPage isn’t. Maybe ask in the ProFields-Support board? Otherwise you’ll have to compare the two modules’ code. I assume you’ve already ruled out creating a standard FieldsetTab and putting it around your FieldsetPage? I just tried that and it looks fine to me. @rjgamer @Neue Rituale
-
Can you show your code and ideally explain what all the relevant variables are?
-
Uninstalling and reinstalling LazyCron fixed it for me.
-
[Solved] Error after upgrade - Blog Module 2.4.0 to 2.4.5
Jan Romero replied to prestoav's topic in General Support
This tries to count the items in blog_tags and fails because the field isn’t available. I’m not familiar with the module, but it appears to assume all blog posts (?) to have that field, so just adding the field to the relevant template should fix this particular error.- 4 replies
-
- upgrade
- blog module
-
(and 1 more)
Tagged with:
-
[Solved] Error after upgrade - Blog Module 2.4.0 to 2.4.5
Jan Romero replied to prestoav's topic in General Support
Does your template have a page-reference field called blog_tags?- 4 replies
-
- upgrade
- blog module
-
(and 1 more)
Tagged with:
-
Make sure you click on Subpage A so its background turns grey as with Home and About. Then drag Subpage B on top of Subpage A until the yellow marker moves to the right where you want it.