Jump to content

Juergen

Members
  • Posts

    1,306
  • Joined

  • Last visited

  • Days Won

    13

Everything posted by Juergen

  1. Hello @ all, I want to manipulate the markup of images added via the editor. In this case I have 2 possibilities: 1) To create a textformatter module or 2) to manipulate the output via jQuery General question: Will be the markup from a textformatter module cached or will it be created on runtime like jQuery? I prefer cacheable content so if it will be cachable I would tend to create a module instead of jQuery manipulation. Thanks in advance for your help.
  2. My goal was not to copy only one field. The body field was only an example. It would be great to copy all multilingual fields in the template with only one click. Imagine you have more textareas or editor fields in a template. One click and you have copied all your fields at once.
  3. Copying the source code is necessary at the moment. Anyway. It could be a useful feature to copy content via clicking a button and maybe it could be integrated easily without a lot of effort. But this is not a real important feature. It was only a thought of mine to improve the workflow. Best regards
  4. It would be great to add a copy button for content fields on multilingual site. F.e.: You have written a complex text with images, tables and so on in your body field in your default language (fe English). After that you want to translate the content to other languages (German, French). Therefore you have copy all the content. If there will be a copy button to copy the whole content of the default language body field to all the other language body fields with only one click. You will only have to translate the content. There will be no need to insert all the elements once more by copy and paste. This would be a great addition to make working with multilingual sites much more comfortable. Best regards
  5. I would suggest to include a delete button for images in the modal window of the editor. Today it is possible to upload images directly with the editor, but it is not possible to remove them in the modal window. So a delete button next to the upload button would be a great addition. At the moment it is only possible to delete an image at the image field. Best regards
  6. This is the solution to remove unwanted table attributes from CKEditor. Go to /wire/modules/Inputfield/InputfieldCKEditor/ckeditor-4.4.6/config.js and insert this piece of code into the config.js: CKEDITOR.on( 'dialogDefinition', function( ev ) { var dialogName = ev.data.name; var dialogDefinition = ev.data.definition; if (dialogName == 'table') { // Get the advanced tab reference var infoTab2 = dialogDefinition.getContents('advanced'); //Set the default // Remove the 'Advanced' tab completely dialogDefinition.removeContents('advanced'); // Get the properties tab reference var infoTab = dialogDefinition.getContents('info'); // Remove unnecessary bits from this tab infoTab.remove('txtBorder'); infoTab.remove('cmbAlign'); infoTab.remove('txtWidth'); infoTab.remove('txtHeight'); infoTab.remove('txtCellSpace'); infoTab.remove('txtCellPad'); infoTab.remove('txtCaption'); infoTab.remove('txtSummary'); } }); After that you have only a few attributes left. This is the best way to prevent customers from filling out useless table attributes. This works for other plugins (images, links and so on) too. A big thanks to Lostkobrakai for pointing me into the right direction.
  7. Sounds interesting, I will check this tomorrow. Thanks
  8. Hello @ all, I want to disable some of the obsolent and unnecessary attributes ot tables that CKEditor offers, because they are not HTML5 compliant or not necessary. I am talking about the summary, the border and the other attributes that CKEditor offers. I want to disable them so that customers cannot be able to use them. I am not talking about to clean up the html Markup - I can get rid of unwanted markup via a textformatter module, thats not the problem. I am talking about the table plugin button in the editor itself. If you click on that button you will be able to add borders, width, class, id and so on. I want to disable some of them, but I dont know if this is possible or not. Maybe someone can gave me a hint. Best regards Jürgen
  9. Works perfect!!!!!! This is exactly the way that I want. Thanx. PDO is new to me - I have to take a look.
  10. Thanks Adrian, I included the code and it works. Yes you are right, this is not the "last visit", it is the current visit. Unfortunately the query doesnt output all logins of the user which are stored in the column "login_timestamp". So it is not possible to grab the second position "last visit".
  11. For everyone who also wants to use the Login history module from Teppo (http://modules.processwire.com/modules/process-login-history/), here is my attempt to make a sql query to output the date and time of the last visit on a frontend template. $query = $db->query("SELECT login_timestamp FROM process_login_history WHERE username='{$user->name}' AND login_was_successful=1 ORDER BY login_timestamp DESC"); $lastvisit = $query->fetch_row(); echo $lastvisit[0]; This will give you an output for the last successful login like this: 2015-05-08 16:40:59 It calls the table "process_login_history" from the module. The dates of the logins are stored in the column "login_timestamp". If the login was successful or not is stored in the column "login_was_successful" and has the value "1" for a successful login. The username is stored in the column "username". I dont know if the code is the best but it works. If someone has an improvement, please post it here. Best regards
  12. Adrian, thank you so much for your efforts. I havent seen that there is also a module available. This seems the best approach to me because it stores both (frontend and backend) logins. The other possibilities only show frontend logins. Thanks!!!!!
  13. I have tried the code above, but it always stores the date and time of the present login (the current date and time) and do not shows the last login date and time. The code is inside the user frontend profile template. $username = $user->name; wire()->addHookAfter("Session::login", function(HookEvent $event) { $person->of(false); $name = $event->arguments('$username'); $name = $this->wire('sanitizer')->username($username); $person = wire('users')->get($username); $last = $person->last_page_load; $person->last_page_load = date('Y-m-d H:i:s'); $person->save(); }); I have never worked with hooks and therefore its quite difficult to me to figure out. What I want to achieve: If a user logs out (or maybe logs in) then the date and time of the logout (or login) will be stored in a userfield called "last_page_load". If the user logs in the next time, the date and time of the last visit will be displayed in his user profile on the frontend.
  14. Sorry, I dont need to save the checkbox status after redirect, because the redirect only take place if the form has no errors. So all correct data will be submitted via the form and will be stored in the database before the redirect starts. No need to keep the checkbox state alive. [CLOSED]
  15. hello @ all, today I am struggeling with the following problem: I have a checkbox field in a frontend user profile form. <input name="delete" type="checkbox"> Delete profile image If the user clicks the checkbox the profile image will be deleted after submission. In the same form there is also a select drop down field for the language where the user can change his prefered language (German or English). After saving the user will be redirected to the english page with these lines of code. if ($newuserlanguage) {//if language has changed $languageurl = $page->localUrl($newuserlanguage); //get url for the new language $session->redirect($languageurl); //redirect to the new page } This piece of code will be executed POST after submitting the form and works as expected. The user will be redirected to the new page after submit. PROBLEM: The redirect leads to that the checkbox value is always empty - in other words the checkbox status (checked or unchecked) will not be stored if a redirect is present. If I remove the redirect code it will work as expected. I am not a PHP-Pro so I have no idea how I can fix this problem. Has anyone an idea how to handle checkboxes and redirects. I dont want to store values in a cookie if there could be another way. I have tried it to store it in a session but I cannot get it to work. Best regards Jürgen
  16. I found the solution: you have to include $user->userimage->removeAll(); // wirearray before this line of code $user->userimage = $upload_path . $files[0]; This removes the image array in a first step and then loads the new image in the database.
  17. But for what is the API call "setOverwrite(true)" ? It must be possible to overwrite the existing image by uploading a new image without deleting the old manually. In backend it works perfectly. Only one image is allowed: setMaxFiles(1) If I upload a new one then delete (overwrite) the old on and store the new: setOverwrite(true) This seems logical to me
  18. hello @ all, I have tried to use a code that i found in the forum to make a single image upload on the frontend. The problem is that it stores multiple images instead of deleting the old and storing the new. My aim is to offer subscribers to add/change their profile image in the frontend. Here is the code that I use from the post that I have found: <?php $upload_path = $config->paths->assets . "files/avatar_uploads/"; $f = new WireUpload('userimage'); $f->setMaxFiles(1); $f->setMaxFileSize(1*1024*1024); $f->setOverwrite(true); $f->setDestinationPath($upload_path); $f->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); if($input->post->form_submit) { if(!is_dir($upload_path)) { if(!wireMkdir($upload_path)) throw new WireException("No upload path!"); } $files = $f->execute(); if ($f->getErrors()) { foreach($files as $filename) @unlink($upload_path . $filename); foreach($f->getErrors() as $e) echo $e; } else { //$u = $users->get($user); //$u = $user->name; //Save the photo to the avatar field $user->of(false); $user->userimage->removeAll(); // wirearray (line added by @horst: explanation is three posts beneath) $user->userimage = $upload_path . $files[0]; $user->save(); $user->of(true); @unlink($upload_path . $files[0]); } } ?> <form class="forum-form" accept-charset="utf-8" action="./" method="post" enctype="multipart/form-data" > <input type="file" id="attach" name="userimage" accept="image/jpg,image/jpeg,image/gif,image/png" /> <input type="submit" name="form_submit" value="Submit"/> </form> $f->setMaxFiles(1); so it is set to 1 file $f->setOverwrite(true); so it should overwrite the existing image Every time I upload a new image it will be added instead of deleting the old. So I have more than one image displayed in the backend area. If I upload the image in the backend it works as expected. I use the latest dev version of PW. Has anyone an idea why MaxFiles and setOverwrite will be ignored? This ist the array output if I use var_dump: object(Pageimages)#729 (2) { ["count"]=> int(2) ["items"]=> array(2) { ["chrysanthemum.jpg"]=> string(17) "chrysanthemum.jpg" ["desert.jpg"]=> string(10) "desert.jpg" } } Best regards Jürgen
  19. Thanks Lostkobrakai this was a mistake, I am switching between Joomla and Processwire and therefore I wrote TinyMCE. I will check out the link you provided. Thanx
  20. Hello @ all I use the Tiny MCE editor and I want to remove some of the settings for the tables. The editor offers some attributes which are obsolent (f.e. width and height). It also offers to change the paddings or to show a border around the tables or to change the alignment. I want to disable all of them because customers are always irritated and I use CSS to make all the tables look like the same. Has someone dealed with the same problem and has found a way to disable this settings in the editor? Best regards Jürgen
  21. Today I had to output notes in a form at the frontend. This little code snippets show you how it can be done via the API: 1) One language site: $notesofmyfield = $page->fields->get("myfield")->notes; echo $notesofmyfield; 2) On a multilanguage site if ($user->language->name != 'default') { $notes = "notes{$user->language}"; } else { $notes = 'notes'; } $notesofmyfield = $page->fields->get("myfield")->$notes; echo $notesofmyfield; Happy coding!!
  22. I have changed the image settings from "auto" to "single element (null if empty)" and now it works. Thanks for your efforts
  23. $userimage = $user->userimage->first() and $userimage = $user->userimage return both the same array with var_dump: object(Pageimages)#656 (2) { ["count"]=> int(1) ["items"]=> array(1) { ["bewerbungklein-1.jpg"]=> string(20) "bewerbungklein-1.jpg" } } Strange behaviour because if the image is in a page template like $pageimage = $page->userimage this will work.
  24. Hello @ all, I added a profil image to the user template in the backend. Unfortunately I am not able to resize the image in frontend. $img = $image->size($x, $y) This function doesnt work for images which are stored in the user template. Here is the complete code $userimage = $user->userimage; if ($userimage){ $options = array( 'quality' => 90, 'upscaling' => false, 'cropping' => 'north' ); $img = $userimage->size(80, 100, $options); echo '<img src="'.$img.'"/> } I always got this error: Error: Exception: Method Pageimages::size does not exist or is not callable in this context (in /home/.sites/24/site1275/web/wire/core/Wire.php line 350) Imagefield setup: Number of allowed images = 1 Format = auto Is it not possible if I call an image from the user? Thanks for your answeres
×
×
  • Create New...