Jump to content

salles

Members
  • Posts

    19
  • Joined

  • Last visited

Recent Profile Visitors

2,433 profile views

salles's Achievements

Jr. Member

Jr. Member (3/6)

0

Reputation

  1. @Soma it works perfectly now Soma, thank you! I'm using a text field for the "domain", but could I use a page field? So domains can be saved as childrens of "Domains" page in the tree. -edit nevermind, it doesn't work. i'll stick with the text field and then make the search via the field.
  2. @Soma hi Soma, I made the changes you suggested, but I'm getting this error now: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'SaveShortUrl' for key 'class'
  3. i erased everything to try again and i'm still getting that error when i try to install the module here's the full code of saveShortUrl.module that i'm using: <?php class saveShortUrl extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Rewrite field after save', 'version' => 1, 'summary' => 'An example module used for demonstration purposes. See the /site/modules/Helloworld.module file for details.', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => true, 'icon' => 'smile-o', ); } public function init() { // add a hook before the $pages->save, to issue a notice every time a page is saved $this->pages->addHookBefore('save', $this, 'saveShortUrl'); } /** * Save as another field. **/ public function saveShortUrl($event) { $page = $event->arguments[0]; //#todo Rename to your field names. $page->domain = parse_url($page->source_url,PHP_URL_HOST); //#todo Maybe some more error handling. $page->of(false); $page->save("domain"); $this->message("Save the domain {$page->domain}."); } } i'm using a field "domain" and a field "source_url"
  4. @adrian i'm getting this error when i try to install the module: Error: Call to undefined method stdClass::of() (line 29 of /Users/SF/Sites/pw/site/modules/saveShortUrl.module) line 29 is this: $page->of(false);
  5. @Philip The message "save the domain..." appears, but it doesn't save anywhere... Here's what I'm trying: $pages->get("sources")->find("domain") = parse_url($page->link_to_img, PHP_URL_HOST); I'm trying to get the page "Sources" and their children field "domain", so each page under "Sources" is a saved domain. But it doesn't work either...
  6. I even tried to write a module, but i just can't get my head around it programming - it's ok the php template part, but when it comes to writing modules i feel stupid would anybody be willing to make this code for me? i'll pay...
  7. But is it possible to automatically save it to pages?
  8. Hi guys I'm building a repository for inspirational images found through the web, so I have something like this: Images - Image 1 - Image 2 - Image 3 ..... Sources - Source 1 - Source 2 - Source 3 ... Each image template has the following fields: - URL fieldtype for the Source Link (for example, http://abduzeedo.com/daily-inspiration-1940) - Page fieldtype for the Source Site (where it connects to the Sources page all the image sources) So I was wondering if it's possible to automatically get the base domain from the Source Link and save to the Sources page. For example, the Source Link is http://abduzeedo.com/daily-inspiration-1940, so it automatically saves "abduzeedo.com" to the Source Site fieldtype, consequently to the Sources pages. Is it possible to do something like this?
  9. Ah, gotcha I wonder if this can be changed in some PW core file?!
  10. Ah, nevermind. Didn't realize this Just a note: I see the module supports capital letters in random strings but for some reason it only generates numbers and small letters...?
  11. @Soma - That's so awesome, thank you very much for writing this module! I can't wait to get home and try it! As for the copyrights, I was planning to add the images sources via a page fieldtype, manually. For example, if the image it's from Flickr, I'd manually add "flickr.com". But come to think of it, is there a way to automatically save/pull the main url in some page fieldtype? So for example if the image url is "http://flickr.com/some-image-etc.jpg", it would automatically save/store "flickr.com" in some page fieldtype. Too tricky? -Edit Just tried it, works like a charm! Small note though: I can't delete the image later if I want to, nothing happens when I click on the trash icon... Once again thank you, Soma!
  12. Hello! I have a cool upcoming project which its content will heavily depend on external images. Although I'd like to get rid of WordPress for this project and would love to use ProcessWire, WP has a great plugin called Grab & Save, that allows you to grab and save images from remote urls into your own WP media library. I was wondering if ProcessWire has a similar plugin or functionality, which it would be a huge time saver for these kind of projects!
  13. Hi adrian, does the module work if adding images via FTP?
  14. Hello guys Can anyone explain me how to add multiple images to PW via API? Many thanks, S
  15. yep exactly what was going on. all good now
×
×
  • Create New...