Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by zyON

  1. Hi, After the move to ProcessWire on one of our major websites, I had to build myself a module/plugin so I could use the Amazon S3 / CloudFront infrastructure. The module/plugin uses Amazon S3 PHP SDK and the idea was to provide a clean way to upload/backup files to S3 and distribute the assets via Cloudfront. The current version of the module/plugin will copy the page files to Amazon S3 so you can then serve the via Cloudfront automatically. Note that the files are still also copied to the server where your PW installation resides. There's an option to backup the deleted files to another folder on S3 because when you delete a file on PW via the admin, the file is also deleted from it's folder on S3. The module also supports Apeisa's Thumbnail module so it also stores the thumbnails on S3. Note that the native size() method to create image thumbnails on S3 is currently not supported. As it is, the module will only upload new assets, so beware that if you already have pages created with assets you'll definitely have errors, so my advice is to test this with a blank installation of PW. If anyone wants to test it and contribute to it, I think this provides a good proof of concept for a functionality that is requested by several users (me included). Please note that I'm not a PHP developer, my skills (very) limited and I'm aware that it can be improved and I'm open to suggestions, feedback and most of all, collaborators. The module is hosted on github here and it's available in the ProcessWire modules directory. Nelson Mendes
  2. Teppo, Ok, thanks. That's what I'm doing now.
  3. I need to get the name of a page at the moment when it is permanently removed from the Trash. I need this because I have to do some cleanup for files associated with it that I'm uploading to Amazon S3 with a module I'm trying to develop. Now, for example, it I use the following hook: $this->addHook('Pagefiles::delete', $this, 'deleteStuff'); I can get the name of the file being deleted, the field it belongs to but when I try to get the page name I get a different name like this: "pageid_pagename" not the original page name. public function deleteStuff($event){ $file = $event->arguments(0); $filename = $file->name; // filename OK $field = $file->field->name; // field name OK $page = $file->page->name // Not what I was looking for (...) The page name is changed when the page is moved to the Trash. Any ideas on how can I get the clean name (without parsing this new string)?
  4. interobang, That's it. Thanks. this is all I need now: $p = $event->arguments(0)->page->getForpage()->title; I know we have available the very useful cheatsheet provided by Soma but is there further documentation for the PW API other than that provided here?
  5. Nico, I just wanted to know if there was a better way (through referencing?) than using: $p = $event->arguments(0)->page->parent->name; $page = wire(pages)->get("name={$p}")->title; to get the name of the page (not that there's anything wrong with that). Ok, the reason I need the to upload a field with a repeater with file fields inside is because I need to add a description of those files that must be translated in 5 languages. That was the fastest way I've found to achieve this.
  6. On this topic: I've asked (and answered myself) how to get the field name on a page used for uploading files. Now, what if I'm using a repeater field to upload files? How can I get the name of the page of the item uploaded to? I'm using a InputfieldFile::fileAdded hook and even if I try to get the $event->arguments(0)->page->name I get the internal name of the repeater page, not the name of the page where the field is. $event->arguments(0)->page->parent->name is almost what I need because I get the name "for-page-xxxx" and xxxx is the id of the page where the field belongs. Is there any easier way to reference this page name without, I don't know, parse this string to extract the numeric id and then search for the page name?
  7. Ok, found it: Using a InputfieldFile::fileAdded hook that returns a pageFile object: public function addFile($event){ $file = $event->arguments(0); // file uploaded $field = $file->field->name; // name of the field on the page used for uploading the file (...) }
  8. I'm using hooks to process documents after the upload on a page. I've 3 different fields that can be used for uploading documents like "photos", "pdfs", "floorplans". How can I know which field on the page activated the hook so I can process them differently? Thanks.
  9. Apeisa, Thanks, you're right. I've used: public function addFile($event){ $file = $event->arguments(0); $this->message("You Added a file: {$file->name}.", Notice::log); } and the file name is logged in the messages.txt file. It's the first time I've used the log and I had to search inside the PW files on how to use it. I guess when you wrote "Try writing $log instead of message" you are referring to the same thing but I guess there's a way using the $log variable?
  10. I'm trying (slowly) to build my first PW Module, mostly to learn how everything works internally with the API. I'm trying to attach a function with a hook to grab the event of adding a new file to a page but I'm can't seem to fire it (I'm talking about adding a new file via de admin interface). I've declared the hook in the init() fuction of the module as: $this->addHook('InputfieldFile::fileAdded', $this, 'addFile'); and my function looks like this: public function addFile($event){ $file = $event->arguments(0); $this->message("You Added a file: {$file->name}."); } The message is never displayed. I've tried with InputfieldFile::processInputDeleteFile and it works. Also I've tried with InputfieldFile::processInputDeleteFile but it doesn't seem to work either. I'm using PW 2.4.0. Any ideas? Thanks.
  11. I really need a solution for this and starting to look into this topic as we use Amazon Cloudfront CDN services to serve heavy media content like video and photos. I've found this script: http://timkay.com/aws/ that may can work on shared hosted accounts (I think it only uses core Perl libraries) so maybe this could be used with some kind of post hook event on the file uploads via PW?
  12. I'm migrating a site to PW using Multi-Language support (5 languages) and all is really working very well except for one annoying thing: I'm translating strings using the translation files (json) but when I try to update a file already linked on the Setup > Languages > language section, I can see the new strings I've added to the document with the corresponding textfields but when I save the changes, the field (or fields) do not hold the new value. I get the messages: 1 translations changed Saved site--templates--property-php But the field is blank and there's no change to the .json file. Anyone experienced this issue?
  13. Hi. We're looking for a developer that can create a module/plugin to power an Auctions website via Processwire for a client. It should support the basic functionality of an Auctions site like this: http://www.lauritz.com/en/auctions/?FLId=2&FCId=5 Some of the core features it must have: * Creation of multiple auctions holding multiple items; * Support for simple bidding and Proxy Bidding (Automatic outbidding); * Support for reserve price and "Buy it now"; * Bidding History; * User Registration and Login auction bidding; * E-mail alerts for users on outbidding, end of auction, etc; It must be complete until the 30th of April 2014. Please PM me if you are interested and I can fill you with more details. NM
  14. Hmmm... Actually I'm having the same problem on Chrome (Mac) with the Teflon 1.0.3 Theme by Soma on PW 2.3 :/ * EDIT * Just upgraded the Teflon theme to version 1.0.4 and all is working now.
  15. Ok, so it goes like this: On admin.php I have set up the hook as this: $pages->addHook('saveReady', null, 'storeFullURL'); function storeFullURL($event) { $page = $event->arguments(0); if($page->template == 'manequim') { $page->fullurl = "{$page->parent->url}{$page->gama->name}/{$page->tipo->name}/{$page->colecao->name}/{$page->name}" ; } } On the product template php file (in this case on manequim.php) I have on the top of the page this: foreach($pages->find("template=manequim") as $p) { $p->of(false); $p->trackChange('fullurl'); $p->save(); } The fullurl field is correctly filled if I go to a page on the admin and save it. I'm not getting any error now, the field for the already created pages just doesn't get automatically filled when I load the template file.
  16. This is the code that I'm actually using: foreach($pages->find("template=bustotorso-especial") as $p) { $p->of(false); $p->trackChange('fullurl'); $p->save(); } The post hook on save is correctly working as when I save a product in the admin the fullurl field is correctly filled. The above code is used on the template and should fill automatically the fullurl for all the already created products using that template (as ryan suggested).
  17. Yes, I tried that after remembering that $page was a reserved word, and used $p instead. I've just pasted the wrong code. but it doesn't work.
  18. Soma, yes, sorry I did not mention that I've changed the variable name like this: foreach($pages->find("template=bustotorso-especial") as $page) { $page->of(false); // add this line $page->save(); Still no luck
  19. Hmmm... I'm getting this error now: Error: Exception: Can't save page 1152: /catalogo/bustos-torsos/homem/36b/: Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved. I tried to add $page->setOutputFormatting(false) before the save, but then nothing happened, the value was not being updated.
  20. Hi Ara, I think you'll find (as I did) Processwire really simple to use and understand. Of couse that it always depends on what you are trying to achieve, but I've started using PW with a fairly complex site and, with the help of the great and helpful people of this forum, I'm loving it and feel confident that I'll be using it for every project that needs content management in the future. Definitely I've found it easier and with fewer restrictions out of the box than other CMS's I've used (including Expression Engine).
  21. I'm having a similar issue with the Info field on the admin. It shows the server time, not the time I've defined in site/config.php: $config->timezone = 'Europe/Lisbon';
  22. ryan, I've successfully created the hook (not for updating the quantities, but to store the full url of the product, as it is composed of brands, collections, etc that don't belong directly to the hierarchy). It's working when you save the product in the admin but I can't seem to make it work to update the already created products by using the method you described. Can this be something related to the $page variable not being resolved somehow?
  • Create New...