-
Posts
1,560 -
Joined
-
Last visited
-
Days Won
49
Everything posted by gebeer
-
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
- 5 replies
-
- 1
-
-
- PWimage plugin
- frontend
-
(and 2 more)
Tagged with:
-
ProcessPageEditImageSelect - hook and change default $page
gebeer replied to mr-fan's topic in Modules/Plugins
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). -
ProcessPageEditImageSelect - hook and change default $page
gebeer replied to mr-fan's topic in Modules/Plugins
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? -
ProcessPageEditImageSelect - hook and change default $page
gebeer replied to mr-fan's topic in Modules/Plugins
Will do that -
ProcessPageEditImageSelect - hook and change default $page
gebeer replied to mr-fan's topic in Modules/Plugins
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 -
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?
- 5 replies
-
- PWimage plugin
- frontend
-
(and 2 more)
Tagged with:
-
ProcessPageEditImageSelect - hook and change default $page
gebeer replied to mr-fan's topic in Modules/Plugins
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. -
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.
- 5 replies
-
- PWimage plugin
- frontend
-
(and 2 more)
Tagged with:
-
@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/
-
@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.
-
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/ ?
-
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.
-
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?
-
@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.
-
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?
-
try $hassidebar = array('home','project','projects','posts','partners'); if (in_array($page->template->name, $hassidebar) { //... } EDIT: adrian was quicker. Either of it should work.
-
How do you update a page with all its field via front-end?
gebeer replied to Marc's topic in Getting Started
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. -
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?
-
MarkupSEO - The all-in-one SEO solution for ProcessWire.
gebeer replied to Nico Knoll's topic in Modules/Plugins
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. -
Find most efficient solution for storing multiple values in a field
gebeer replied to gebeer's topic in General Support
@sforsman Thanks for the explanation. Very enlightening -
Find most efficient solution for storing multiple values in a field
gebeer replied to gebeer's topic in General Support
@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 -
Find most efficient solution for storing multiple values in a field
gebeer replied to gebeer's topic in General Support
I implemented it so that the deletion of old timestamps happens only after the user submits the form and before the new timestamps get created and saved. For my scenario this is sufficient and I don't need other automation options. I'm just wondering whether there might be a faster method to delete timestamps other than my foreach loop in step #6 above (which is pretty fast already anyways ). -
Find most efficient solution for storing multiple values in a field
gebeer replied to gebeer's topic in General Support
I'm wondering, too if this could be automated. When I just add new timestamps, the old ones are still there. That's why I'm deleting them before I add new ones. Deleting takes around 1.6 seconds for 3000 timestamps. So I can live with that. But if there is a way to make this faster, I would be very interested. -
Find most efficient solution for storing multiple values in a field
gebeer replied to gebeer's topic in General Support
@kongondo My implementation is as follows. 1. installed the inputfield Timestamps module that you supplied. 2. created a field "ad_publish_at" of type timestamp and add it to my advertisement template 3. render the form on the frontend with code based on Soma's gist. 4. use a custom function to find recurrences from start and end dates in my advertisement template. The function uses the barely documented PHP DatePeriod class function getRecurrences($startTime,$endTime,$interval) { $format = 'Y-m-d H:i'; $start = new DateTime(); $end = new DateTime(); $start->setTimestamp($startTime); $end->setTimestamp($endTime); $end = $end->modify( '+1 minute' ); $duration = 'PT' . $interval . 'M'; //where $interval is 15, 30 or 60 $interval = new DateInterval($duration); $daterange = new DatePeriod($start, $interval ,$end); return $daterange; } 5. $daterange contains an array of DateTime objects. I loop through them, convert each into a timestamp and save that to my timestamps field $times = getRecurrences($startTime,$endTime,$interval); //this is the daterange array with DateTime objects foreach ($times as $t) { $t = $t->getTimestamp(); $timestamp = new Timestamp();//this is the Class Timestamp found in Timestamp.php. Included via FieldtypeTimestamps. $timestamp->date = $t; // note stored in column 'data' in the db of the Field $editpage->ad_publish_at->add($timestamp); } 6. when a user edits an advertisement and changes dates, I have to manually delete all previously saved timestamps, before I add the new ones with step 5 above. For deleting the "old" timestamps I use this foreach ($editpage->ad_publish_at as $t) { //ad_publish_at is my timestamps field $editpage->ad_publish_at->remove($t); } If you have any further questions on my implementation, please ask. -
I have the exact same scenario and am using page field like sforsman suggested. To make your filters work you can use URL segments. Works like a charm.
- 8 replies
-
- 2
-
-
- dependencies
- inputfield
-
(and 1 more)
Tagged with: