Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by gebeer

  1. Hello, I'm in the process of building a web application with PW that delivers data to mobile clients. There will be up to 1000 requests per minute to my webapp (later maybe more). Every request triggers a search through up to 1000 pages and compares timestamps that are sent by the mobile clients with the request to timestamps that are saved with each page that is being searched. The timestamps are saved in PW in their own table in the DB together with a page reference id which makes searching pretty fast. For my search I use: $ads = $pages->find("template=advertisement, ad_server=$serverID, ad_publish_at.date<$tsHigh, ad_publish_at.date>$tsLow"); I want to do some load testing for my webapp to ensure it can handle that many requests per minute and further optimize it. What I need is a testing framework that lets me simulate hundreds of requests/minute. Have you ever done this and what testing framework would you use? Here are some apps that I briefly took a look at: http://jmeter.apache.org/ http://www.pylot.org/ https://code.google.com/p/httperf/ https://github.com/JoeDog/siege
  2. @adrian I was able to solve my problem without the need for a module. See also my post in the other thread. Cheers Gerhard
  3. Bingo My assumption from my previous post was right. The PWimage plugin needs a hidden text input field with the value set to the page id of the page that you want to grab images from. I added a hidden input field to my form with $imgPageID = $pages->get("template=media, created_users_id=$uID")->id; $field = $modules->get("InputfieldText"); $field->label = " "; $field->attr("id+name","Inputfield_id"); $field->attr("value",$imgPageID); $field->attr("type","hidden"); $adform->append($field); Now I can choose images from the user's images page And there is no custom module with hook to ProcessPageEditImageSelect required. EDIT: This only works for PW 2.5. For 2.6.x some adjustments are needed. You'll find more info here
  4. Thanks a ton, adrian! I meanwhile discovered why I get an error with PWimage plugin in a frontend form and am currently looking into solving it. It looks like I might be able solve 2 problems together. I'll report back in my other thread. Cheers Gerhard
  5. OK talking to myself again - but at least I'm in good company I'm looking through the code that builds the PWimage plugin and gets the pages to choose images from. Namely wire/modules/Inputfield/InputfieldCKEditor/plugins/pwimage/plugin.js and wire/modules/Process/ProcessPageImageSelect/ProcessPageImageSelect.module In the former file the page_id is retrieved through var page_id = $("#Inputfield_id").val(); var edit_page_id = page_id; Since my form is living on the frontend, I don't have $("#Inputfield_id").val() because $("#Inputfield_id") is not there. Looking at the source code of the backend form, I can find this element: <input id="Inputfield_id" name="id" value="11551" type="hidden" /> Where value 11551 is the id of the page I'm on. For my frontend form I'm rendering the form with code from Soma's gist. And that doesn't render the hidden input field with the value for the page I'm on. Hence the error. Now I will go and add that input myself to the frontend form and report back here what the outcome will be EDIT: sometimes a good glass of port wine can make you see things that you hadn't seen before
  6. The page I want to choose images from is the one I get with $rootPage = wire("pages")->get("template=media, title={$user->name}"); In the 1st screenshot that page title and ID are echoed right on top in the second line: rootPage Title:gbr ID:11582 But then it says: "Images on Page: now (/advertisements/ad-now-1035)". This is the page where the CKeditor field is on. Here is where I need my rootPage. So it should read: "Images on Page: gbr" and show me the images on that page. That page contains only an images field with images in it (and the title field).
  7. OK, done testing in backend. With this code public function init() { $this->addHookAfter('ProcessPageEditImageSelect::execute', $this, 'changeParent'); } public function changeParent(HookEvent $event) { $user = wire("user"); echo "User:".$user->name." ID:".$user->id."<br>"; //if ($user->role == "frontend") { $rootPage = wire("pages")->get("template=media, title={$user->name}"); $rootPageID = $rootPage->id; echo "rootPage Title:".$rootPage->title." ID:".$rootPageID; $event->replace = true; $event->return = str_replace("rootPageID: 0", "rootPageID: ".$rootPageID, $event->return); //} } I get and after click on "change" I get So it is working But that is not what I need :-( I'd like to choose images from the rootPage itself and not it's children. And I'd like to have the rootPage chosen by default instead of the page I'm on when I click on the insert image button. Would this be possible to achieve with adding other hooks to the ProcessPageEditImageSelect.module?
  8. Thank you, adrian, for looking into this. I think I need to get the user with $userID = $this->wire("user")->id; Am I right here? But I can't really check if it is working because I get an error when clicking the PWimage button in the editor on my frontend form. I opened an extra thread for that problem. Sorry for cross posting here, but I thought I better check here for the validity of my module code. Cheers Gerhard
  9. I changed the way I organize images. Now my form doesn't contain an image field anymore. I moved image handling to it's own form because I need to have images organized per user and not per page. I modified adrian's module that I found in this post to change the rootParent for wire/modules/process/ProcessPageEditImageSelect/ProcessPageEditImageSelect.module. My ChangeImageSelectParent.module code now reads class ChangeImageSelectParent extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Change Image Select Parent', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { $this->addHookAfter('ProcessPageEditImageSelect::execute', $this, 'changeParent'); } public function changeParent(HookEvent $event) { $user = $this->wire("user"); if ($user->role == "frontend") { $rootPageID = wire("pages")->get("template=media, created_users_id={$user->id}")->id; $event->replace = true; $event->return = str_replace("rootPageID: 0", "rootPageID: ".$rootPageID, $event->return); } } } But I can't see if this has any effect because I still get the error from my first post: when I hit the insert image button in CKeditor. So again my question: can we use PWimage plugin in frontend forms?
  10. I have a special use case where I need to change the rootParent to a page owned by the logged in user that has the template "media". I think adrian's module with some modifications is exactly what I need, but I'm not quite sure how to modify it the right way. Here is what I've got so far. class ChangeImageSelectParent extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Change Image Select Parent', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { $this->addHookAfter('ProcessPageEditImageSelect::execute', $this, 'changeParent'); } public function changeParent(HookEvent $event) { $userID = wire("user")->id; $rootPageID = wire("pages")->get("template=media, created_users_id=$userID")->id; $event->replace = true; $event->return = str_replace("rootPageID: 0", "rootPageID: ".$rootPageID, $event->return); } } Any help would be much appreciated.
  11. Hello all, I have a frontend form with a CKEditor textarea and an image upload field. The image upload is working fine. But when I want to insert an image through the PWimage plugin, I get an error inside the modal window This is happening on a page that has already been saved after adding the image. A forum search for that error revealed only this post and it's related post. Nut they don't seem to offer a solution to my problem. Line 179 in ProcessPageEditImageSelect.module says $images = $this->getImages($this->page); I'm not a coder, but I guess this means that $this->page returns a nullpage and thus the error. I read quite a few posts about frontend image handling but didn't find anything related to my problem here. Is it not possible to use the PWimage plugin on frontend forms? Or could this be related to permission settings for my frontend user? EDIT: I changed the title of this post from "CKEditor..." to "PWimage plugin...", because the problem is not CKEditor specific, it seems.
  12. @netcarver here are some more timepickers that I was looking at when trying to quickly implement one with your field: https://fgelinas.com/code/timepicker/ : this one is based on jQuery UI http://jdewit.github.io/bootstrap-timepicker/ : personally, I like this one best, but it relies on Bootstrap and I couldn't get it to work with BS 3 and with other date fields present in the same form http://weareoutman.github.io/clockpicker/jquery.html : funny picker looks like a clock http://amsul.ca/pickadate.js/
  13. @teppo Thank you for this module. Exactly what I need. @moonwhaler There is a Trumbowyg plugin for image uploads. I'm looking into adjusting trumbowyg.upload.php to use it with PW wireUpload. Need an easy way for users to add images in a frontend form. I have read ongoing discussions about how PW implements image management and hope I can pull something together using this module.
  14. Thank you for the module. I'm using it on a site in development as input for publishing times. Discovered no problems so far. All is running smoothly. Have you considered adding optional JS to the field for user friendly input through a time picker like http://jonthornton.github.io/jquery-timepicker/ ?
  15. I can set the user timezone with date_default_timezone_set. It is important to set it before my form gets rendered, submitted and processed, not just before I save values. The current time in my date field gets calculated based on the set time zone. Example: set timezone Europe/Berlin, current date set timezone America/New_York, current date When PW saves publishing timestamps, I get timestamps for 2014-10-24 03:00 Europe/Berlin: 1414112400 America/New_York: 1414134000 Which is 21600 seconds or 6 hours off. Which is correct. So I think I'm on the right track now handling different timezones.
  16. Hi there, can't seem to get my head around handling user timezones the right way and hope to get some feedback from people more knowledgeable than me. My scenario: Users can set publishing date/time for pages they create through a frontend form. These should be saved in the users' timezone. I have a date field for publishing time. PW saves dates as unix timestamps to the DB. For conversion of the date/time to the timestamp PW uses the default server time zone setting (in my case Europe/Berln). Now when a user in timezone America/New_York creates a page and sets the publishing date, it will be converted to a timestamp using the server timezone Europe/Berlin and saved to the DB. Later the user checks if his page is being published at the set time in New York. But it will be published at the wrong time because the user is in a different timezone. I assume it would be best to convert the publishing date/time to a timestamp using the user timezone and save that to the DB. Am I right here? How would I accomplish that? I found date_default_timezone_set. Can I simply use this to set the user timezone before I save values, like date_default_timezone_set($userTimezone); // where $userTimezone is a string like "America/New_York" $editpage->of(false); foreach($adform as $field) { // loop through all fields and save them if(in_array($field->name, $ignorefields)) continue; $editpage->set($field->name, $field->value); } $editpage->of(true); date_default_timezone_set($config->timezone); // do I have to set it back to server timezone here?
  17. @sforsman Thanks, but not working. I get a JS error Uncaught Error: Syntax error, unrecognized expression: #Inputfield_ad_frequency_1082|1083|1084 Attribute data-show-if="ad_frequency=1082|1083|1084" in the field wrapper. I'm on 2.5 stable and on a frontend form where other dependencies are working fine.
  18. It seems like OR in dependencies is not working for radio buttons. I want to show a field only some specific options of the radio input "ad_frequency" are checked. I tried this in field dependencies settings: ad_frequency=1082, ad_frequency=1083, ad_frequency=1084 If I set it to a single radio option like ad_frequency=1082 everything is working as expected. In the docs it says that this will be implemented. Does anyone know, when?
  19. try $hassidebar = array('home','project','projects','posts','partners'); if (in_array($page->template->name, $hassidebar) { //... } EDIT: adrian was quicker. Either of it should work.
  20. Take a look at Soma's gist. It loops through all the fields of your page and displays a form. Then on Submit of the form it again loops through each field and saves the value. It also includes all styles and scripts that you need for your form to work on the frontend. This is working great for my frontend form. If you need help implementing it, let us know.
  21. Thank you for the module. Just one suggestion: In terms of human readable URLs, wouldn't it be better to attach the time as a Datetime string like "2014-10-21-16-04-33" rather than the unix timestamp?
  22. I'm implementing a custom field type based on Ryan's Event field type that uses a custom table for storage. I have compared performance to other methods like using a pages field. And the custom table field is much much faster, both when saving and querying values. So I'd recommend going with the custom table field following Ryan's Event field type module.
  23. @adrian Just tried your code and compared time for both methods. Deletion of 3073 timestamps. using $editpage->ad_publish_at->removeAll(); 0.2848 seconds using foreach ($editpage->ad_publish_at as $t) { //ad_publish_at is my timestamps field $editpage->ad_publish_at->remove($t); } 0.7537 So removeAll() is significantly faster and speeds up my application. Thank you! Cheers Gerhard
  • Create New...