Jump to content

bernhard

Members
  • Posts

    6,674
  • Joined

  • Last visited

  • Days Won

    367

Everything posted by bernhard

  1. Don't know about the core Inputfields but this can easily be done by adding scripts in the init() method of the module, not the render method.
  2. Credits to Ryan - I didn't know about that detail and he added it to the blogpost while proofreading it Sorry I think I misunderstood you try $headline = 'Happy ' . date('Y'); $this->headline($headline); $this->wire('processBrowserTitle', $headline);
  3. bernhard

    Fields

    There are several links inside this thread. Using google to search the forum works really well, see the link in my signature
  4. $wire->addHookAfter('InputfieldText::render', function($event) { $field = $event->object; if($field->name != 'title') return; $repeaterBtn = $this->modules->get("InputfieldButton"); $repeaterBtn->attr("value", "Generate something"); $repeaterBtn->attr("type", $submitID); $repeaterBtn->attr("id+name", "btn"); $repeaterBtn->attr("href", "/admin/page/edit/?id=1"); $repeaterBtn->attr("target", "_blank"); $repeaterBtn->addClass("customClass"); $event->return .= $repeaterBtn->render(); }); btw: panels are a great alternative for new browser tabs: https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/#using-internal-components-modules
  5. bernhard

    Fields

    Hi @Jwenk and welcome to the forum, the preciser you ask your questions the better the answers will be What are you trying to do?
  6. hey @Federico i didn't read all your code but I would hook the inputfield's render method of the field that is inside the repeater. or you create a runtime markup field with your code. that might be easier. the only thing you have to take care of when hooking yourinputfield::render() is that the $field->name is not the field's name only but it has some appended or prepended string (repeater name or id, not sure at the moment... you can easily check this with tracy). always start without any additional checks/ifs/returns and then continue step by step until you get where you want, for example this in your /site/ready.php: $wire->addHookAfter('Inputfield::render', function($event) { $field = $event->object; bd($field->name); }); then you can modify the hook to only execute when needed (like hooking InputfieldText instead of the Inputfield base class, doing a return when the field name does not match...). i think @Robin S came up with a good solution how to check for the right field name inside repeaters but i can't find where he mentioned it in the forum. this is another way of checking that i used, but maybe robin can show us the better way
  7. I'm sorry @modifiedcontent but I put a LOT of effort in the blogpost, so as long as you don't come up with preciser descriptions of what EXACTLY you are trying to do I can not help. Maybe someone else understands your needs better and can therefore help you better. maybe a google search for "dashboard" has some interesting reads for you: https://www.google.at/search?q=site:processwire.com+dashboard
  8. hi modifiedcontent, this sounds a little strange. the easiest way of editing content is of course the normal pw edit screen. you can do a lot with normal pw features (like hiding fields on several conditions etc). if you really need more customized forms I show how you can do that here: https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/#create-our-first-real-inputfields ; that's only one way of doing it. you can also easily modify the page edit forms via hooks. sorry for that. you can also start by using InputfieldRuntimeMarkup - maybe that's easier to begin with... totally up to you. you can create several pages in one module: https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/#hello-page2 ; but you could also create one module for each page. It depends on you and your usecase which level of separation makes sense. sure, thats what i do throughout the tutorial. start with hello world, end with a custom CRM
  9. hm... @dragan i guess the runtimemarkup field only has to return the "<button>" element (without the <li>, <div.InputfieldContent> and so on... you are right see this post for example (and the following): and also this: https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/#using-internal-components-modules (scroll down to the buttons section)
  10. Nice one Canada should be adrian's territory - I hope they hired him
  11. really nice feature introduced in november: live share (great way of collaborating with others!) https://code.visualstudio.com/blogs/2017/11/15/live-share ps: i don't want to abuse this thread for interesting stuff about vscode that is not related to processwire if that is not wanted...?
  12. @SamC great. Maybe you want to use less.js (http://lesscss.org/#using-less-third-party-tools) to show a very simple way of playing around with the admin themes LESS files? We could even build a theme generator using less.js and/or AIOM's php based less parser... Changing colors of the theme should be a lot easier than downloading source files, compiling everything, uploading...
  13. hi @theoretic this looks very nice. I'm just not sure about the blue link color... I think the main problem is that there is no guide at all of how to customize the uikit theme properly. Maybe you could share what we have to do in a tutorial?
  14. hi suntrop, I don't know why and I don't know if this is the best option (hooking is for sure also fine, or even better), but I like to create custom endpoints in the admin for that purpose via a ProcessModule. There i create an execute method (like executeMycustomcopyfunction) so that you can call this endpoint easily like this: <a href="/admin/page/mymodule/mycustomcopyfunction/?pagetocopy=123&newparent=456&copychildren=1">copy to new parent with children</a> In this method you can do whatever you want (don't forget to check permissions if that's important in your case). Somehow I found this way easier than hooking One drawback could be that you need to check if the page has some unmodified changes. I use my clone link on an overview-table so thats no factor in my case since the page is not being edited when clicking the clone link.
  15. The module supports less, you can also define variables there
  16. Ok sorry i shut up since I don't have a clue about this module
  17. of course you can! just clear your post data and redirect to the same page. If you do not show the submitted data, then this works (for example if you had a general "thanks for your message"). if you want to show data to the user (like "thanks alan for your message, we'll contact you soon") you could save that data to $session and display it from the session variable after clearing the post data. edit: actually the post data should get cleared already by the redirect
  18. I have never used this module so I don't know how it works but your problem can easily be solved by a redirect: https://stackoverflow.com/questions/3923904/preventing-form-resubmission
  19. If I remember correctly unpublished repeater pages get cleaned up by processwire at some time interval (I think one day or so). Would that explain your situation?
  20. no clear all your unnecessary server and client cache+sessions+cookies etc related to that site and try it again.
  21. that's exactly why using tracy is so great, because now you know that the hook did not execute it's the same for me. don't know why it is not executed. maybe it's a bug, maybe we are using the conditional hook wrong. I didn't use conditional hooks for a long time and sometimes hooks with if-statements are even easier to read. so it's totally up to you which one you use.
  22. use tracy and debug $event: wire()->addHookBefore('Page(template=user)::changed(0:last_name, 1:first_name)', function($event) { bd($event); }); hookevents ($event) always have the object (class) and the arguments (parameters), in this case $event->object is the class ($page you are looking for) and ps: i prefer addHookAfter most of the time to be sure that the method itself does not overwrite the value again... don't know if that makes sense in your case but just wanted to point out that you have to take an eye on that. you see very well that $event->object = user, $event->arguments(0) = field name, (1) = old value, (2) = new value. it did only work for me like this: wire()->addHookBefore('Page(template=user)::changed(0:email)', function($event) { bd('user changed'); bd($event->arguments(0)); bd($event->arguments(1)); bd($event->arguments(2)); bd($event); }); id didn't work with multiple fields in the changed() part. don't know why. you can investigate this on your own with the help of tracy and some try&error.
  23. no, but saveReady belongs to the pages class, so the template condition won't work. You could use Page(template=user)::changed(0:first_name, 1:last_name) i guess... but saveReady hooks with an if statement are totally fine
  24. the if-statement is totally fine. you can also use conditional hooks: https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks don't think that there is a best practice or any performance difference between conditional hooks and if statements but that's just a wild guess...
  25. hi laps, i strongly recommend using tracy during development, then you can see instantly whats going on in most of the cases... $wire->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments('page'); bd('page title: ' . $page->title); }); just put this in your /site/ready.php and save any page you like and you'll see the output in your debug bar: just put it in your /site/ready.php file - you don't need to define anything else. Prepend and append files are for rendering the frontend.
×
×
  • Create New...