Jump to content

Soma

Moderators
  • Posts

    6,803
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. Dont want to be mean but have to say that I already built multiple working front end form examples that work. The one Reno linked would be what you do. So this is not so much about making a working example but to help you debug your code you messed up. :-P #hides behind stone# Of course yours has some more fields, but there's no validation happen on those, which I think should be the lesson here. To make it easy on this subject I would suggest looking at my other front end forms using PW forms and field that will make it more streamlined and easy. Its also in my gists examples.
  2. Much better... and just now I spoted (starting from top) an error if ($input->get->contactname){ Your form is method post and not get! So you would have easily spoted this already if you add an pseudo echo "Hello" after the if() to see it gets to after the check. As I said it's really simple if you go step by step and output vars to test and see if it really get's there.
  3. Im saying gist.github.com not github itself
  4. I didn't say move this discussion to github, but the snippet maybe?
  5. I also know what you're saying, but I have to strongly disagree. I could've write this in any other similar thread. The problem is the code posted in a wysiwyg is "horrible" to read and even copy it. Then after this is working (as with 1000 other code here in the forum), there comes the next who takes this code but need another feature.. then the game start again with same story same code but different bugs issues. What I would like to do is helping how to code and debug, not have 1 million snippets that are sometimes very bad coded and not complete best practice or not even working spooking around the forum. It already happened many times and it will get worse by time. I know what you're wanting to do and I understand, but in the long run what we are practicing here since 2 years is very bad for newcomers. We better this energy and time to help with little tutorials and snippets that are good to start with in a dedicated site/place.
  6. Not the ideal way to debug like this code in a forum. Nothing against anyone personally. Now the code lost intendation and no way to go through it. Please post code to some snippet site like Gist or bitbucket. In general, we should provide some more practice and best ways HOW TO DEBUG YOUR CODE. Good coding is learning how to debug. There's simple steps you can go through to test all vars and parts of code to see where the problem lays. Sometimes it's simple sometimes it can get hard, as you when you don't have errors. Ok. What I spotted too is the last bit, where is the $u->getErrors() coming from? Also as you say the page isn't created at all? I would start there and get that right first and work you way up. Thanks, Soma
  7. For backend hook include additional script. Take a look the InputfieldDatetime.module ___render() is hookable (three underscores) So you would roughly create an autoload module that hooks into InputfieldDatetime::render to initiate that a datetime field is rendered somewhere and a good point to add our script: $this->addHookBefore("InputfieldDatetime::render", $this, 'addScripts'); And in the function add the script like ryan showed. public function addScripts($event){ $this->config->scripts->add($this->config->urls->templates . "your/script.js"); } And it will add it to the admin, when a Datetime field is rendered. Ahhhh form builder! You can add that line from Ryan to form-builder.inc template... You can't change the InputfieldDatetime module itself with hooks, just to additional stuff when a datetime is "rendered".
  8. If it's for frontend why can't you just include the script in your templates? Or on what kind of form are we speaking about?
  9. And you're sure $error is your email address?
  10. Andrew, it would help greatly if you would let us know what is not working? What happens that you say it is not working? Errors? Have you enabled debug mode in /site/config.php to see if any warnings are shown?
  11. Yet another issue: http://processwire.com/talk/topic/866-image-upload-weird-issue/?p=30451
  12. To make this more real world code. It's best practice to better check if there really is children and images if ($page->child->id) { // at least one child page viewable (access), access save foreach($page->children as $selectedthumbs) { if(!count($selectedthumbs->selectedimages) continue; // no image found continue foreach $firstimage = $selectedthumbs->selectedimages->first(); $thumb = $firstimage->size(100, 100); echo "<a href='{$selectedthumbs->url}'><img src='{$thumb->url}' alt='{$firstimage->description}'></a>"; } } You can also use the fast check if($page->numChildren) {... But it's not access aware and also includes unpublished pages. BUT it's faster than for example if($page->children()->count()){ .. If you have 1 million children (cite Ryan) it would matter and children->count() example would get slow. So what if I numChildren() returns true but there's no page viewable by the visitor? It doesn't matter if you only output something inside the foreach(...), because there you use $page->children which does only return pages published and viewable pages. But this could leave you with empty UL's: if ($page->numChildren) { echo "<ul>"; // this may output even if the following foreach doesn't find children foreach($page->children("limit=25") as $child) { echo "<a>$child->title</li>"; } echo "</ul>"; // this also } End of lesson.
  13. Turnz off ProcessPreview module.
  14. Ist das jetzt deutsches forum?
  15. Hmm. $arts = $pages->find("template=article"); $arts->setOutputFormatting(false); foreach($arts as $art){ foreach($art->categories as $cat){ // loop current categories // find subcategory with same name $subcat = $pages->find("has_parent=/path/to/subcategories/, template=subcategory|advices, name=$cat->name")->first(); if(!$subcat->id) { echo "<p>subcategory not found $cat->name</p>"; } else { // add it to subcategories page field $art->subcategories->add($subcat); // save field $art->save("subcategories"); } } } Something like this would do.
  16. description_job and description_person are two different things at the end and makes perfect sense to separate them. I see no reason to have them both share same field like "description".... unless you have them separated by the template context. Person template and job template. Repeater is nothing more than if you have a template person and job, and have the job be children of the person.
  17. http://www.w3schools.com/cssref/pr_text_text-transform.asp
  18. Ok, testing for ajax does solve the problem but the preview doesn't work anymore (shows no changes). Adding this instead: public function changeView(HookEvent $event) { if($this->page->process == "ProcessPageSort") return; Does make it work, and solves the sort problem. But still you add with $this->addHook("ProcessPageView::execute") which will be execute by every page view (admin and front-end) it seems it's sensitive to everything that happens in PW even process page sort. Replace the above with exit(); and you won't be able to view something.
  19. Especially I'd like to see if the way you do hook ProcessPageView is right without additional checks for if on front or backend. Especially when making hooks like this you want to make sure everything works correct and doesn't have unwanted effects as in the past of this module
  20. Not really sure what it has to do with ProcessPageView but sort is ajax based and since it's calling a process execute page there might be something triggered. For now I think adding a check in the start of that function would solve it. if($this->config->ajax) return; But also would like to understand more why. Ryan?
  21. Yep, this is indeed strange, and I have no idea why. Maybe if you could share some light on the exact setup you have. Where are the script and where included/called... Maybe someone has an idea then.
  22. As I said before, it works the way it should. It does get saved with the user id (user logged in or if not as 'guest'). It's there in the Pages::save and does work. If it doesn't work in your case, as I said previous it may has something to do with: Session's usually don't transfer to another domain, even if on same server.
  23. Nope I haven't anything, since those pages are anyway only for admin, I didn't take care of it for now. And it wasn't considered at the time I forked the module. Admin pages have template "admin" I think you have to ask mindplay, I think it's in there in the module configuration screen. But haven't tried.
  24. Ok glad you got it. Please report it in the ProcessPreview thread. Thx.
  25. If you click on the xhr request, what is the response? finished loading isn't telling anything. It should have something like this if it works: {"error":false,"message":"Updated sort for 2 pages"} - ProcessPreview, there happend to be some issue with it. Make sure it's up to date or deinstall it to try.
×
×
  • Create New...