Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. 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
  2. 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".
  3. 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?
  4. And you're sure $error is your email address?
  5. 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?
  6. Yet another issue: http://processwire.com/talk/topic/866-image-upload-weird-issue/?p=30451
  7. 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.
  8. Turnz off ProcessPreview module.
  9. 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.
  10. 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.
  11. http://www.w3schools.com/cssref/pr_text_text-transform.asp
  12. 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.
  13. 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
  14. 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?
  15. 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.
  16. 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.
  17. 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.
  18. Ok glad you got it. Please report it in the ProcessPreview thread. Thx.
  19. 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.
  20. What browser/version? Does this happen with all pages or only certain pages? If you open console and then drag sort, there's a ajax request happening, does that show any errors? What modules (3rd party) installed?
  21. I already mentioned soemthing about this in here http://processwire.com/talk/topic/2979-multi-language-page-names-urls/?p=29567 LLU just exists because of the lack of what now becomes a core feature. It doesn't make sense to have a slow parser if there's a performant way to do it out of the box now. It just has some small features added which aswell could be done on a per site scenario with some code or module. If core support will have language segments /en/, /de/ support there will be no reason to have LLU anymore.
  22. Still not sure what you want to do or what is wrong. Just to verify. Page modified and created, so modified_users_id and created_users_id get set on page save. You can't overwrite it, since it done on every save. When creating page it set's both, which is desired. When creating page from bootstrap the current user is used to save id according. If you want to overwrite some of it, you'd have to make it through SQL manually. See some post here http://processwire.com/talk/topic/651-set-created-by-creating-a-page-via-api/
  23. That's correct. It's not inside container but outside. Was always like this and should be. Yes, it's fixed and should stay and not scroll with page. Yes that's intentional.
  24. Looks like theres no user logged in in your case because it saves the user logged in with the request. Works fine here. My guess would be PW version or because you are having different domain where you lose login or session or alike.
×
×
  • Create New...