• Content count

  • Joined

  • Last visited

Community Reputation

24 Excellent

About Marc

  • Rank
    Full Member

Profile Information

  • Gender
  • Location

Recent Profile Visitors

1,771 profile views
  1. Marc

    My company developed a website where we sell greeting cards and gift products that our customers can customize and apply their own designs to. The designs can then be previewed in interactive 3D. We use a software package called Taopix 3D Designer for this. Taopix are using three.js to render the preview, so you may want to look into that javascript library as well.
  2. I have setup a template called 'product-collection'. The edit permissions are set by this template and assigned to a user role called 'editor'. 'Allow edit-related access to inherit to children' is enabled. I have another template called 'product-card' with no permissions specified. I have setup two pages, a parent page that has template product-collection and a child with product-card. The user with the editor role can edit this product-card page just fine, so the edit-related settings work as expected. There is an issue with the pagelister though: once the product-card page is unpublished, the editor can no longer list this page unless he specifically sets a filter to include unpublished pages. This is because the pagelister shows this warning beneath the filters: "Not all specified templates are editable. Only 'include=hidden' is allowed". So while the specified template (product-card) IS editable (because it inherits edit-permissions from its parent), the pagelister does not know this. One way around this is by setting the edit permissions of the product-card template manually instead of by inheriting from the parent. If you do this the warning goes away and unpublished pages are listed without setting a status filter. This behavior seems like a bug to me. What do you think? I'm using the latest development version.
  3. I figured it out, hopefully this might be useful to others as well: // Remove current thumbnail first. $currentThumb = $page->image_thumb->first(); $page->image_thumb->delete($currentThumb); // Get the image we want to copy. $original = $page->image_front; $file = $original->getFile($original); // Clone that image and append it to the image_thumb field. $new = $original->clone($file, array('action' => 'append', 'pagefiles' => $page->image_thumb)); $page->save(); I noticed that this does not work if the filename of the file you are trying to clone ends with -0 (e.g. myfile-0.jpg). I think that is a bug which I'll post to GitHub.
  4. I understand I can generate different sizes and that is exactly what I'm doing right now. I do some checks to see if the uploaded thumbnail is of high enough quality by checking its dimensions and if it is not, I fallback to the image_front field which is always of higher quality and I resize on the fly to the correct dimensions. I want to get rid of these checks so I want to do a one time replacement of a bunch of thumbnails by cloning the image_front image to the thumbnail field.
  5. I want to use the API to duplicate an image from one field to another (on the same page). The duplicated image should be a new file so both fields should not point to the same physical file. The field that holds the image that I want to duplicate is called 'image_front' and the duplicated image should go to a field called 'image_thumb'. Any image that is already attached to image_thumb should be removed because it should hold only one file. The same goes for image_front, it should have only one image. Here's what I have so far: $original = $page->image_front; $file = $original->getFile($original); $new = $original->clone($file); $page->save(); $page->image_thumb = $new; $page->save('image_thumb'); This works in the sense that the image is successfully cloned but it is attached to both fields so both fields end up have their original image plus the cloned image. 'Image_thumb' should only have the cloned image and 'image_front' should only have the original image. What would be the best way to remove those images and am I even approaching this correctly?
  6. Has anyone managed to overwrite the cache path and URL? It does not seem to work so all sites will be sharing the same cache, which might be problematic. Edit: looks like template cache does use the custom cache path/URL and other forms of cache use the default cache folder.
  7. I really like what you guys came up with here, I think I'm going to implement this on a bunch of websites. One thing to note is that when you are using multi-instance like I do, and you connect from a PW site that is not part of your 'multisite' setup, the $_SERVER['HTTP_HOST'] condition in config.php won't trigger and you will not get the data you are after. One way to get around this is to create the instance like this: $site = new ProcessWire('/srv/users/me/apps/website/public/', ''); Adding the domain as the second parameter will set a variable called $httpHost (to '' in my example) in wire\core\ProcessWire.php which is available to config.php. Therefore, if you alter the condition in config.php to this, multi-instance should work: if ($_SERVER['HTTP_HOST'] == '' || $httpHost == '') { $config->dbName = 'name'; $config->dbUser = 'user'; $config->dbPass = 'pass'; //etc } I have not tested this extensively but it seems to work fine.
  8. Thank you, that's it of course I was using the wire way at first but searching the forums I noticed someone using $event object for this so I decided to give it a try, not really understanding the differences.
  9. I am trying to make a simple wiredata module that lets me select a page I want all visitors to be redirected to. I have this working in ready.php but then I decided on putting it in a module and I can't get it to work. Here's the relevant bits: public function ready() { $this->addHookBefore('Page::render', $this, 'redirectUsers'); } public function redirectUsers(HookEvent $e) { $page = $e->object; // The page we want to redirect to. $redirect = $e->pages->get($this->redirectPage); if ($page->id == $redirect->id) return; // Prevent infinite loop. if (!$e->user->isLoggedin()) { $e->session->redirect($redirect, false); // 'false' indicates 302 temp redirect. } } I left some checks out for simplification. Whenever I'm not on the page that I want to redirect to, an infinite redirect loop starts. Could anybody explain why that is?
  10. I have setup two websites, A and B. A can read pages from B using the multi-instance API. But how do I get A to save a new page to B? I have this simple test setup: $path = "C:/Users/Marc/Documents/development/www/siteB/"; $url = "/siteB/"; $siteB = new ProcessWire($path, $url); $np = new Page(); $np->template = "my-template"; $np->parent = $siteB->pages->get('/forms/'); $np->title = 'test multi-instance form'; $np->save(); The page is saved to site A instead of B, with no parent. Is this a case of saving it to the wrong instance? If so, how do I save it to the correct instance (site B)?
  11. Marc

    Thanks, gonna try this out
  12. Marc

    Is it possible to temporarily overwrite the smtp host and smtp user defined in settings with the API? I would like to send some emails using a different smtp server with different credentials from the one I entered in the module settings.
  13. Marc

    I read that post but I was confused by it. But now understand: I need to open the site/modules/PageImageManipulator folder that was downloaded by PW and remove the module files that are not PageImageManipulator02 and then install it. Thanks for the module!
  14. Marc

    This module is not working for me on PW 3.0.58. I'm trying to convert PNG to JPG. When I do $img->pim2Load('template')->setOptions($options)->width($img->width())->pimSave() I get a fatal error: When I use pimLoad instead of pim2Load, there's no error and JPG's are generated. But since I'm on PW 3, I should use pim2Load. I'm calling the function in one of my templates. Any idea as to why pim2Load would not be working?