Jump to content

froot

Members
  • Posts

    686
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by froot

  1. thanks, I just saw this now and I'm sure it works cause I found the issue. OK just so to clarify… A is this one: include_once ('_organizer.php'); B is this one: include_once ('site/templates/_organizer.php'); The field itself is set to output Y-m-d which doesn't work with strtotime($item->date_start). A doesn't work, but because B is loaded over ajax and/or because it makes a detour over the root folder, it ignores that output format, outputs the unix timestamp instead and works fine. If I remove the strtotime, A works fine cause the value is formatted anyway but it conflicts with the strftime of B. Very confusing. So when I removed the output format for the field altogether it works. All good now, thanks for the input.
  2. I came across a weird issue with date output and I would appreciate if you could thought-shower with me so I can find the root of the problem. So I have a function that returns the content of a datetime-field. I use this function on two different templates, and used to include it on each of these templates seperately. But then in the process of tidying up the code I put that function on a separate php file in order to just include it on the mentioned templates, so I don't have to apply changes twice in the future, you know the drill. Long story short, when in the code it says: <?=strftime('%A, %e. %B %Y', $item->date_start)?> // cause it's german :D it returns the correct date on one template but on the other I get a: PHP Notice: A non well formed numeric value encountered in… and of course the good old 1. January 1970 with the exact same code! When I change it to <?=strftime('%A, %e. %B %Y', strtotime($item->date_start))?> It fixes the issue for that template but then it shows up on the other… So strange! I might add that the way these two templates include the script differ a bit. include_once ('_organizer.php'); and include_once ('site/templates/_organizer.php'); // this template is in the root folder because it is loaded via ajax Any ideas?
  3. Hi friends, just 7 months ago, I was "just" a designer and a rather semi-developer, still struggling with WordPress sites and more often than not delegating that work to pros. ProcessWire really helped me realising that it's not that hard after all (well it's still hard but it's doable) and you learn a lot just by doing it which has to be true for all developers anyway. So I started coding myself, I might also have to thank the 2020 pandemic to help me focus a bit more than usual, I created a bunch of websites using PW already – one of which I can't wait to put on showcases but it's still not live yet. That is one big personal milestone for me. The next milestone would be to give something back, and so I'd like to take on contributing some code I wrote, namely a event calendar for anyone to use. It's my first attempt doing this so please don't eat me alive. It's not a PW module yet (that's the plan however) just a git but I'm positive it will be useful once it works – well it works but it still needs more work – because if I had found a module that came close I wouldn't have started coding it myself :D With that, I will appreciate all input, be it how to improve the .js (probably especially), or the templates, or guidance how to proceed turning this into a PW-module, and of course, in that last process, no pun intended, suggestions to make it more versatile for different needs. git: github.com/bbblgmsp/ProcessEventCalendar demo: http://foobar.roofaccess.org/events/ Thank you!
  4. I get a very similar issue (repeatedly) SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4612-0' for key 'PRIMARY' (4612 being the highest page-id, I think) I get the above error message (just 4612-0, 4612-1, 4612-16, … would vary like that) a couple of times when uploading multiple images to an images-field when I upload multiple images at once. It happens on every PW-installation I run on easyname.com webhosting so I doubt it has to do with any modules because the website-installations are quite different and even on the simplest of them it still happens (no hooks or ->save() commands in my php code). Doesn't happen on local though for the same websites and databases. And unfo I don't have any other webhost to compare it with. I talked to the host, they advised me to address ProcessWire. I guess it has to be some basic database structure configurations but it's beyond me and I'm hesitant to mess with it. Might it have to do with the incremental number? Do I need to reset it? How do I? Why is in in conflict? I very much appreciate any help!
  5. @daniel_puehringer I'm facing the same problem, what did resolve this issue for you, may I see your .htaccess file?
  6. @rolisx facing the same problem, how did this end in your case?
  7. thanks so much! It works like a charm now. I did notice the (int) but didn't think to much about it. The problem is my knowledge is a bit all over the place, learning by doing, you know. And I also did try with $fields->get('images'); // some string conversion error or whatever but not with $fields->get('images')->id; // this was the last piece of the puzzle Anyways, thanks again, great module/module-action. I won't even suggest to turn this requirement here into a separate action, I think it's just too simple?
  8. true, now that error is gone, thanks! And I'm four lines further in ? Call to a member function add() on null 78: $destinationPage->$fieldName->add($item->getPathname()); The field "images" is clearly on the template though…
  9. I'm on localhost so it must be '/Applications/MAMP/htdocs/example.com/site/assets/cache/AdminActions/'.$np->id.'/'; // returns e.g. /Applications/MAMP/htdocs/example.com/site/assets/cache/AdminActions/4075/ I wish you were right, but the error persists
  10. that might explain why the folder is not there, cause, you know, haven't written any so far. I tried with $modules->get("ProcessAdminActions")->FtpFilesToPage($options); apparently this is allowed, you can access the module's method via API, however now I get RuntimeException Directory name must not be empty. 74: $dir = new \DirectoryIterator($sourceFolder); How is that possible? neither 'sourcefolder' => $urls->cache.'AdminActions/'.$np->id.'/', nor 'sourcefolder' => "/assets/cache/AdminActions/$np->id/", work but the folders are clearly there and not empty.
  11. hm, a little bit confused now. the "actions" folder was and is in site/modules/ProcessAdminActions/. I guess you mean that one when you say "AdminActions" folder and also not in /templates/ ? And I also guess you don't mean the actual /wire/core/ folder. Otherwise I'm more confused. I thought I could do something like $import = $modules->get("FtpFilesToPage"); or $import = $modules->get("ProcessAdminActions"); and then proceed with my foreach (as described above) $import->executeAction($options); but apparently it's not that easy.
  12. it says Call to undefined function ProcessWire\executeAction() Maybe a dumb question – do I need to copy paste the entire mentioned code you put as a reference? I assumed, since the module is installed, that the function is now in the namespace somehow. Thanks for help!
  13. I will try today, I have some concerns with 'field' => 'images', wondering if that's specific enough.
  14. @adrian I'm trying to add in batch the images from separate folders to separate corresponding pages. Judging from the action code that is viewable in the module's settings, I reckon this might work… $newpages; // array of pages to add the images to foreach ($newpages as $np) : $options = array( 'sourcefolder' => "/assets/cache/AdminActions/$np->id/", 'field' => 'images', 'destinationPage' => $np, 'deleteFolder' => 'false', ) executeAction($options); endforeach; What do you think?
  15. any chance we could test ProMailer before buying it?
  16. OK got it working now, I should always never forget that even though it's just one item, it's still inside an array. thanks
  17. so I have a Profields Table on a sibling's page, trying to access it from its sibling's page (DUH!) which is $page now, cause that's where I am right now. I do $toc = $page->siblings("template=tableofcontents")->tableofcontents_table; $toc->render(); or $toc = $page->siblings("template=tableofcontents"); $toc = $toc->tableofcontents_table; $toc->render(); but it just won't work because Call to a member function render() on null The table clearly is there and clearly is a sibling and its template is as stated and the table also. Please help me quick, about to throw the computer out the window, thank you.
  18. OK I got it working now, a little workaround made it happen it's acceptable… if (count($item->images) > 0) : $output .= '<img src="'.$item->images->first->size(450, 250, $options)->url.'"/>'; else : $defaultID = $fields->images->defaultValuePage; $output .= '<img src="'.$pages->get("id=$defaultID")->images->first->size(450, 250, $options)->url.'"/>'; endif; Also needed to be careful about the if conditions to avoid having ->size() be called on a NULL object. Hope this helps someone in the future… cheers
  19. it's working fine. even got the cropping work now. There's no access problem to the real images, just cannot access the default images. I could save the default images in another folder on root level, crop them without the API etc. but I'm not sure this is the easiest way. Any ideas?
  20. I have a related question I believe. I had a AJAX working fine, the markup of which is pretty much identical to what is initially loaded normally – except for the variables's values of course – and the AJAX loaded content replaces that. The php file that is loaded via AJAX sits in the folder above /site/. Now I started to use default images for the images fields and it doesn't work anymore. Default image, just to clarify, I set by creating a dummy page with the same template with the same image field. This works for the normally loaded content, but the AJAX call seems to fail to call functions like size() on the images: Call to a member function size() on bool When I remove the size()-function, the image is there, just not cropped. And also it fails to access the default value for the image fields. Forbidden You don't have permission to access the/path/to/site/assets/files/1234/ Any ideas?
  21. any more advice here? This is my archnemesis, I can't get it to work, I tried in so many different ways. Also, while we're at it, never sure how to escape with selectors… for example if I predefine selectors as $selector = "(events.name~%=$q, events.location~%=$q)"; $limit = "limit=24"; and I then include that to select with either… $items = $page->find("$selector, $limit"); $items = $page->find("$selector", "$limit"); $items = $page->find('$selector, $limit'); $items = $page->find('$selector', '$limit'); $items = $page->find($selector, $limit); or should I do… $selector = "events.name~%=$q, events.location~%=$q"; $limit = "limit=24"; and then either… $items = $page->find("($selector), $limit"); $items = $page->find("($selector)", "$limit"); $items = $page->find('($selector), $limit'); $items = $page->find('($selector)', '$limit'); $items = $page->find(($selector), $limit); what about without variables… $items = $page->find("events.name^=a, $limit"); $items = $page->find("events.name^=a", "$limit"); $items = $page->find('events.name^=a, $limit'); $items = $page->find('events.name^=a', '$limit'); $items = $page->find('events.name^=a', $limit);
  22. why shouldn't I overwrite the title? If I shouldn't and consequently won't, then there's no need for any mentioned work-around-solutions after all. Using the full title (i.e. parents-title/page-title) for the products and the actual title (here short title) for breadcrumbs and admin backend is what I need. Composing the breadcrumbs on the _main.php won't work for me. I was able to accomplish what I need by including _breadcrumbs.php on _init.php. On _breadcrumbs.php I compose the breadcrumb-markup making use of the ->shorttitle and ->fulltitle hooks I created on _init.php, and store this markup in a $breadcrumbs variable. On _main.php I output this variable and done. However, now I'm in doubt again because… What's the concern? It seems to work fine…
  23. OK thanks for the input, it helps. I stick with markup regions and just "include" _head.php and _foot.php in the _main.php rather than using markup regions in this case (i.e. <div id="head">) or prepending/appending. But why did I even start want to change that? Because I'm hooking the page-object to add a ->fulltitle and a ->shorttitle method. the full title is $page->parent->title.'/'.$page->title; and will be used for the snipcart-basket. And the shot title is $page->title and will be used for the breadcrumbs to avoid redundancies. I thought the hooks kind of store whatever I tell them to store before anything else renders. Now I realise the value they return is composed at the moment the method gets called. So on the product-page I put: $product->title = $page->title; // which is the full title And since the _main.php renders last and that's where my _breadcrumbs.php is included, the ->shorttitle method thinks the ->title is the fullttitle and basically overwrites what the hook is doing. I hope I made myself clear. Solutions could be to not set $product->title = $page->title but I don't know any other way to change the title that gets sent to the cart. Or, include the breadcrumbs on _init.php ? But then it's above all the content… Store it in a variable on _init.php and return on _main.php? I had a working version where I basically manually composed on each page it's required what my ->fulltitle hook is doing and then disassemble it manually with standard php to accomplish what my short-title hook is doing. I thought using hooks would make this matter simpler, now in doubt. Thanks for further help!
  24. it's actually astonishing how far I got while not thinking too much about this detail. I re-read the whole output strategies documentation, I say re-read because I did before, it probably just was too much to take in at once. I have been using Markup Regions, it gives me the best of both worlds, just as it states. I also appreciate the fact that I can thereby escape the php-syntax highlighting in my editor when there's a lot of HTML-markup in the template file and have it show HTML-syntax-highlighting instead and still delay the output. I also put $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; $config->prependTemplateFile = '_head.php'; // this I added now $config->appendTemplateFile = '_foot.php'; // this I added now $config->useMarkupRegions = true; $config->useFunctionsAPI = true; in the config.php file and remove the head and foot section from the _main.php file. Now I get the error: Call to undefined function ProcessWire\ukIcon() which I reckon is just one of many functions. If I add include '_head.php' to the top of whichever template, everything works fine, just not the prepending (and possibly appending) on config file. What could be the reason? What am I missing? As much as I enjoy programming, I dislike this guessing around for hours and days so I turn to the forum. Does the order of the $config->prependTemplateFile-included files matter? Does in the above scenario _init.php get included before _head.php or vice versa? Thanks for help!
  25. I got the empty-body requirement working, simply with a selector like ("body!=") – works fine. However, still struggling to return results in one language on another language, i.e. showing german results with no empty body on the english site. I followed this advice: and here's my code $language = $user->language; // save the user's language $languages = $page->getLanguages(); $user->language = $languages->get("de"); // returns 'Deutsch' $descendants = $page->descendants("template=cast, body!="); $total = count($descendants); $total = "(".$total." ".__('events').")"; echo $user->language->title.' '.$total; // returns 'Deutsch: (0 events)' when on english page :( $user->language = $language; // restore the user's language but it still doesn't work. Any ideas? I don't know how to select the german version of the page nor how to loop them.
×
×
  • Create New...