Jump to content

bernhard

Members
  • Posts

    5,624
  • Joined

  • Last visited

  • Days Won

    257

Everything posted by bernhard

  1. https://www.google.at/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=google%20maps%20calculate%20distance http://stackoverflow.com/questions/7997627/google-maps-how-to-get-the-distance-between-two-point-in-metre/7997732#7997732 http://stackoverflow.com/questions/1502590/calculate-distance-between-two-points-in-google-maps-v3
  2. once more outstanding support in the forum. thank you! also thank you pwFoo but a simple if($page->id) did it
  3. hi guys, i have the following saveReady hook: public function createCodeFile($event) { $page = $event->arguments('page'); if($page->template == 'code' OR $page->template == 'treenode') { // create file if textarea is not empty if($page->code) { $filename = "tmpupload/code" . $page->id . "_" . $page->name . ".inc"; file_put_contents($filename, $page->code); $page->codefile->removeAll(); $page->save('codefile'); $page->codefile->add($filename); unlink($filename); } else { $page->codefile->removeAll(); $page->save('codefile'); } } works great for editing pages, but when i create a new page, i get the error New page '/simple-map/functions/test-test/' must be saved before files can be accessed from it the problem is in the else-block: else { $page->codefile->removeAll(); $page->save('codefile'); } how can i check if "codefile" is accessible? or should i use another hook? if i hooked after "saved" i would have to save the page on my own and that would lead to an endless loop, wouldn't it? thanks for your help!
  4. since 2.5.24 OR-dependencies are possible: https://processwire.com/blog/posts/processwire-core-updates-2.5.24/#field-dependencies-upgrades
  5. nice! also a good read: https://processwire.com/talk/topic/1799-routes-and-rewriting-urls
  6. thanks! http://php.net/manual/de/language.types.integer.php
  7. yes, the helloworld tutorial is a good starting point! thereafter you can easily setup a kind of "sub-template-system" (how you call it) like this: this is the "default intermediate edition" profile - just install this on your dev-environment and read the files _main.php, _init.php and basic-page.php and you will understand how easy it is to setup very flexible and custom things with processwire! also welcome to the forum ps: actually you would only have to append "<?php" on top of _init.php and all your template files - everything else is ready to use!
  8. hi baba_mmx, very cool! cstevensjr was faster with the images: https://processwire.com/talk/topic/8597-best-way-to-get-random-quote-displayed-on-refresh/?p=83195 is it a good idea to post your app id and secret? don't know how they are used and if anybody can misuse them? your version number is still 002 and not 2 'version' => 2, don't know what could be the problems but i'm trusting horst and the ryan's helloworld module
  9. looks really gut, but personally i was a little bit annoyed by so much scrolling. if you change the whole page on one scroll action its better (for me) than having to roll the wheel over and over to get the new teaser text + image. but others may experience this differently...
  10. i really respect this approach but i think the possibility should at least be there after clicking on "change" so it would appear beside "cancel" or like the new pageDelete floating right. for my project this behaviour is a nightmare... unfortunately i'm not skilled enough to make this on my own, but i thought maybe this would be a 5-min-thing for ryan or any of the other gurus
  11. when a PageListSelect is populated it looks like this: if you want to clear the value of this field rather than changing the referenced page, you have to do lots of clicking if your selected page is somewhere down the tree: it would be great to have a "clear" button right beside the "change" button
  12. or on frontend templates: echo "Name: " . $page->fullname; definitely depends on where you want to add "Name: "
  13. you can create an autoload module that adds this on save via a hook: look at site/modules/helloworld.module copy+rename it to eg addNameOnSave.module edit classname + content of getModuleInfo() install + test it - it should say "helloworld ..." after save edit your init function: public function init() { $this->pages->addHookAfter('saveReady', $this, 'saveactions'); } remove the helloworld functions and add this one: /** * do some actions on saving */ public function saveactions($event) { $page = $event->arguments('page'); if($page->template == 'your_template') { $page->fullname = "Name: " . $page->forename . " " . $page->surname; } } not tested, hope i did not forget anything
  14. thank you for that suggestion - unfortunately that has no effect. ha - often asking for help brings up the solution: saving the field before adding the new file does the trick $page->codefile->removeAll(); $page->save('codefile'); $page->codefile->add($filename);
  15. hey wanze, looks great and could help me a lot if i find time to code some day for what is in my head for a long time ^^ https://github.com/wanze/Pages2Pdf/blob/master/Pages2Pdf.module#L97 shouldn't it check if the user has at least viewing access for the page with the given ID because i think $pages->get(id) via API returns the page independent of its current publishing/hidden state and access? maybe anyone could easyly change the page id and download pdfs of pages he is not allowed to see?
  16. thank you guys! this works: public function init() { $this->addHookBefore('ProcessPageEdit::buildForm', $this, 'populateField'); // populate textarea field from file content $this->pages->addHookAfter('saveReady', $this, 'createCodeFile'); // create code file from textarea field } public function createCodeFile($event) { $page = $event->arguments('page'); if($page->template == 'code') { // create file if textarea is not empty if($page->code) { $filename = "tmpupload/code" . $page->id . "_" . $page->name . ".inc"; file_put_contents($filename, $page->code); $page->codefile->removeAll(); $page->codefile->add($filename); unlink($filename); } } } public function populateField($event) { $page = $event->object->getPage(); if($page->template == "code") { if($page->codefile) { $page->code = file_get_contents($page->codefile->first()->filename); } } } @adrian you are absolutely right on that - i wanted to explain it but was in a hurry i'm working on an update of geowire. you can devide the map javascript into some logical parts (pw pages) and reuse parts that you need more often. for example you can create a layer like this: var opencyclemap = new OpenLayers.Layer.OSM("OpenCycleMap", ["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"] ); map.addLayer(opencyclemap); this works great using the new ACE editor field! on the other hand, if you have complicated functions/controls with lots of code ACE is not ideal, so i thought it would be great to have the opportunity to edit those files via your favourite editor without having to copy/paste between ACE and your IDE. therefore i need to update the textarea field if the codefile has changed in the meantime! outsourcing the code to a file also has the benefit that i can execute php code like this: var opencyclemap = new OpenLayers.Layer.OSM(<?php echo $page->title ?>, [...] ); but there is one more little problem: when i save the page, the file gets created - filename code1010_test.inc when i save the page again, the old file gets removed, the new file gets created, but the name is code1010_test-1.inc when i save it again, the filename is code1010_test.inc again it seems that the original filename is still blocked although i did a codefile->removeAll() any help for this?
  17. hi, i want to populate a textarea on render based on the content of a file that is stored in a hidden file field my template looks like this: title ____________ _____________ | | code |___________| codefile code.inc here is my module code: public function init() { $this->addHookBefore('Inputfield::render', $this, 'render'); // populate textarea field from file content $this->pages->addHookAfter('saveReady', $this, 'createCodeFile'); // create code file from textarea field } public function createCodeFile($event) { $page = $event->arguments('page'); if($page->template == 'code') { // create file if textarea is not empty if($page->code) { $filename = "tmpupload/code" . $page->id . "_" . $page->name . ".inc"; // create temp file file_put_contents($filename, $page->code); // remove old files $page->codefile->removeAll(); // ad new file to hidden field $page->codefile->add($filename); // delete temp file unlink($filename); } } } public function render(HookEvent $event) { $field = $event->object; if($field->name == "code") { $field->value = "test"; // works, but what i want is something like this: $field->value = file_get_contents($page->codefile); } } how can i access the page object from the page that contains the field that im hooking? or should i do that completely different? help would be very appreciated as i've been searching quite for a while...
  18. just tried your module and i love it! great for my geowire project where i'm working on an update right now. i wanted to suggest a fullscreen mode, but i saw it's already on your roadmap... +1 for that. would really be great thanks for the awesome work!
  19. bernhard

    Poll site

    wow! didn't know about mapbox, thanks for that!
  20. great news! this feature is now in the core - and you can guess, ryans solution is far better than my initial module https://processwire.com/blog/posts/processwire-core-updates-pull-requests-and-more-2.5.25/#clear-page-cache-by-matching-pages-with-custom-selector again a great example of how processwire evolves from the needs of every single user. thank you teppo for taking this further! edit: how would i set the "has_parent" id to page id of the page that is being saved?
  21. i did something similar here: https://github.com/BernhardBaumrock/vagrant-pw-lamp/blob/master/bin/grabpw maybe it helps anyone who is as new to bash scripts as i am the part of creating the database is not needed in the new dev versions as this is already built in to core it is part of my vagrant lamp that i use for quickly setting up dev-environments on my windows machine. i really like it! but there are other threads in the forum about this topic... there's a lot more to find: https://processwire.com/talk/topic/9541-pw-cookie-cutter/
  22. of course i read the error message and of course i did investigate some time to find the problem myself... but "$page->setOutputFormatting(false)" as written in the error was not the solution - and i thought i've already done that by calling $np->of(false). fortunately your suggested $pages->setOutputFormatting(false) did the trick! the working code is this $pages->setOutputFormatting(false); $np = $pages->clone($pages->get('/original/'), $pages->get('/original/'), false); // creates a copy of "original" as a subpage of itself $uid = uniqid(); $np->title = $uid; $np->name = $uid; $np->save(); $pages->setOutputFormatting(true); $pages->of(false) did NOT work btw! and i didn't find $pages->setOutputFormatting() anywhere in the docs so i thought it were only for single-page instances ($page). anyway - thanks for the solution!
  23. thank you macrura, but that's not the problem: i have this simple code <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->title; ?></title> <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" /> </head> <body> <h1><?php echo $page->title; ?></h1> <?php if($page->editable()) echo "<p><a href='$page->editURL'>Edit</a></p>"; ?> <?php $np = $pages->clone($pages->get('/original/'), $page, false); $np->of(false); $uid = uniqid(); $np->title = $uid; $np->name = $uid; $np->save(); ?> </body> </html> and this is the problem (please see the 1:48min screencast) http://screencast-o-matic.com/watch/coeYbres8Q
  24. sorry for the double-post - nobody an idea? i can imagine that i will need this quite often in future so it would be really important to know how to do this right!
×
×
  • Create New...