Jump to content

Juergen

Members
  • Posts

    1,424
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Juergen

  1. Hi m-artin, thanks for pointing us to this post. I have implemented it on my site and it works quite well. But should not the multilanguage declaration be defined for every page in the sitemap instead for the root page only? Best regards Jürgen
  2. Hello @ all, in the past I had the problem that I wanted to add additional markup and manipulations to images that were added with the editor to my body field. My aim was to add Bootstrap framework classes to my images and to add additional containers for certain CSS3 effects. I have tried several ways with dom manipulation, jquery and other php manipulations, but all of them dont satisfy my exact needs. After searching Google i found a php library called "PHP Query" which works similar to jQuery but on serverside. After several tests it seems to me the best way for complex manipulations and so I decided to make a simple textformatter module. It consists of 2 files: the phpquery.php file for the library and the the module file itself which contains the manipulations The php query library file can be found at https://code.google.com/p/phpquery/downloads/list The module file: <?php /** * TextformatterPhpqueryImageFieldMarkupManipulator (1.0.0) * A textformatter module to change the markup of images added via editor with the help of the PHPQuery library. * * @author Kern Juergen * * ProcessWire 2.x * Copyright (C) 2011 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class TextformatterPhpqueryImageFieldMarkupManipulator extends Textformatter { public static function getModuleInfo() { return array( 'title' => "TextformatterPhpqueryImageFieldMarkupManipulator", 'version' => "1.0.0", 'summary' => "A textformatter module to change the markup of images added via editor with the help of the PHPQuery library (https://code.google.com/p/phpquery/).", 'author' => "Kern Juergen", 'href' => "", 'permission' => array( "" ), 'autoload' => false, 'singular' => false, 'permanent' => false, 'requires' => array( "PHP>=5.4.0", "ProcessWire>=2.5.28" ) ); } public function format(&$str) { require('phpQuery.php'); $id = $this->page;//grab the page id $galleryid = 'gallery-' . $id;// create the gallery $document = phpQuery::newDocumentHTML($str); // Selects all image elements added via editor $matches = $document->find('img'); foreach ($matches as $match) { //starting manipulations - examples (you can find more and a documentation at https://code.google.com/p/phpquery/wiki/Manual) pq('a > img')->addClass('linked'); //add linked class to all linked images pq('img')->addClass('img-responsive')->addClass('thumbnail'); //add thumbnail and responsive class to all images pq('.linked')->removeClass('thumbnail'); pq('a > img')->wrap('<span class="scalecontainer"></span>')->before('<span class="roll"></span>'); //add additional markup to images with links pq('img')->parents('a')->addClass('thumbnail')->attr('data-lightbox', $galleryid); //add thumbnail class to the link to the larger version and the data attribute pq("a > span > img.align_left)")->parents('a')->addClass('align_left'); pq("a > span > img.align_right)")->parents('a')->addClass('align_right'); pq("a > span > img.align_center)")->parents('a')->addClass('align_center'); pq("p > a.align_center)")->wrap('<div class="image-center"></div>'); pq("p > img.align_center)")->wrap('<div class="image-center"></div>'); //end manipulations } $str = $document; } } The module file includes the phpquery with the require command. $matches = $document->find('img');// Selects all the images This line of code grabs all images //starting manipulations - you will find more info at https://code.google.com/p/phpquery/ //These are some manipulations pq('a > img')->addClass('linked');//add linked class to all linked images pq('img')->addClass('img-responsive')->addClass('thumbnail');//add thumbnail and responsive class to all images pq('.linked')->removeClass('thumbnail'); //remove class thumbnail on linked images pq('a > img')->wrap( '<span class="scalecontainer"></span>' )->before('<span class="roll"></span>'); //add additional markup to images with links pq('img')->parents('a')->addClass('thumbnail')->attr('data-lightbox', $galleryid); //add thumbnail class to the link to the larger version and the data attribute pq("a > span > img.align_left)")->parents('a')->addClass('align_left'); pq("a > span > img.align_right)")->parents('a')->addClass('align_right'); pq("a > span > img.align_center)")->parents('a')->addClass('align_center'); pq("p > a.align_center)")->wrap( '<div class="image-center"></div>' ) ; pq("p > img.align_center)")->wrap( '<div class="image-center"></div>' ) ; //end manipulations This is the manipulation section. You can find a lot of examples at the php Query site. The best is that you can use CSS3 selectors to match a certain element on the page. This makes it much easier. I only posted this module for others who are interested in manipulating images. You use it at your own risk and I doesnt make it public on Github. The manipulations are only for my purpose and you can make your own. Just write it between "//These are some manipulations" and "//end manipulations". Install the module at site/modules/ and add this textformatter module to your editor field. All the images added with the editor will be manipulated in an elegant way. Best regards Jürgen PS.: I am not a skilled PHP pro, I have never learned it at a professional level. So if anybody has improvements please post it here Edit: The include of the phpquery.php file should usualy be at the top of the module file, but in this case it can make problems during the installation of the textformatter. This is the reason why I added it inside the function. If you run into problems after the installation please add this line of code to the top and everything works fine. TextformatterPHPqueryImageFieldMarkupManipulator.zip
  3. This is the simple way how to include all your hooks after page save: https://processwire-recipes.com/recipes/extending-page-save-process/
  4. I have another problem with Fredi and file upload. I have created a repeater field with a file upload field (and other fields). In the backend the file upload works quite well, but in the frontend it doesnt grab the file after uploading. Here is a video i made. https://youtu.be/TlFZJ7HMcQc Does anyone has the same problem?
  5. Hello laban, I use the latest firefox and in my case your sitemap is working, but I am not able to see how many links are in there.
  6. I am also using page tables but I have no problems at all. Maybe it is an CSS problem? As you can see, the close button is there.
  7. I have a general question about adding files to a template file. In PW you can use in the file tab of a template the possibility to add a prepend and a append file (fe header and footer) to a template. I have included them directly in the template with the include function. Is there a difference or advantage of using prepend/append in opposition to the include or doesnt it matter? Best regards
  8. Unfortunately it doesnt work with FREDI in modal windows.
  9. I have installed it at a 2.6.10 dev version. The installation process was successfull, but if I want to check the links I get the following messages: 2015-07-31 17:30:34 admin START: id!=2, has_parent!=2 2015-07-31 17:30:34 admin BATCH: 1/2 (pages 1-52/52) 2015-07-31 17:30:34 admin FOUND Page: / 2015-07-31 17:30:35 admin CHECKED URL: http://www.juergen-kern.at/site/templates/favicon.ico (200) Warning: PDOStatement::execute(): MySQL server has gone away in /home/.sites/24/site1275/web/site/modules/ProcessLinkChecker/LinkCrawler.php on line 405 Warning: PDOStatement::execute(): Error reading result set's header in /home/.sites/24/site1275/web/site/modules/ProcessLinkChecker/LinkCrawler.php on line 405 Fatal error: Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (in /home/.sites/24/site1275/web/wire/core/Modules.php line 2264) #0 /home/.sites/24/site1275/web/wire/core/Modules.php(2264): PDOStatement->execute() #1 /home/.sites/24/site1275/web/wire/core/Modules.php(2523): Modules->getModuleConfigData(Object(ProcessPageSearch)) #2 /home/.sites/24/site1275/web/wire/core/Modules.php(446): Modules->setModuleConfigData(Object(ProcessPageSearch)) #3 /home/.sites/24/site1275/web/wire/core/Modules.php(1032): Modules->initModule(Object(ProcessPageSearch), false) #4 /home/.sites/24/site1275/web/wire/core/Modules.php(939): Modules->getModule('ProcessPageSear...') #5 /home/.sites/24/site1275/web/wire/modules/AdminTheme/AdminThemeReno/default.php(25): Modules->get('ProcessPageSear...') #6 /home/.sites/24/site1275/web/wire/core/admin.php(148): require('/home/.sites/24...') #7 /home/.sites/24/site1275/web/wire/modules/AdminTheme/AdminThemeReno/controller.php(13): require('/home/.sites/24...') #8 /home/.sites/ in /home/.sites/24/site1275/web/index.php on line 254 Error: Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (in /home/.sites/24/site1275/web/wire/core/Modules.php line 2264) #0 /home/.sites/24/site1275/web/wire/core/Modules.php(2264): PDOStatement->execute() #1 /home/.sites/24/site1275/web/wire/core/Modules.php(2523): Modules->getModuleConfigData(Object(ProcessPageSearch)) #2 /home/.sites/24/site1275/web/wire/core/Modules.php(446): Modules->setModuleConfigData(Object(ProcessPageSearch)) #3 /home/.sites/24/site1275/web/wire/core/Modules.php(1032): Modules->initModule(Object(ProcessPageSearch), false) #4 /home/.sites/24/site1275/web/wire/core/Modules.php(939): Modules->getModule('ProcessPageSear...') #5 /home/.sites/24/site1275/web/wire/modules/AdminTheme/AdminThemeReno/default.php(25): Modules->get('ProcessPageSear...') #6 /home/.sites/24/site1275/web/wire/core/admin.php(148): require('/home/.sites/24...') #7 /home/.sites/24/site1275/web/wire/modules/AdminTheme/AdminThemeReno/controller.php(13): require('/home/.sites/24...') #8 /home/.sites/ This error message was shown because site is in debug mode ($config->debug = true; in /site/config.php). Error has been logged.
  10. I have added this to the wishlist some time ago :https://processwire.com/talk/topic/10074-file-upload-field-for-multilingual-site/ I hope it will be added in the future to the file upload fields.
  11. Little mistake - big effect: The syntax for the minutes was wrong: It has to be %M and not %m - now the date is correct multilingual
  12. In the current version of PW (2.6.9 dev) it is possible to add the date format via the PHP strftime syntax to get localized output. In my case I get a difference of 7 minutes between the choosen time in the backend and the outputted time in frontend. This is the date/time that I choose in the backend. The output format for each language in the field is like this: 1) German output format 2) English output format And this is what i looks like in the frontend: 1) German 2) English So as you can see the monthname is in the correct language and the time is also the correct format but I have got a difference of 7 minutes between the output on the frontend and the choosen time in the backend (18:07 instead of 18:00 in German and 06:07 PM instead of 06:00 in English). Could the cause be a server time problem where I hosted this site? Best regards Jürgen
  13. Yes, that was the problem. After changing 3 files from the Github dev version it works as expected.
  14. Problem with multilingual site. If the site is multilingual and you want to find a specific template to edit it is very troublesome to find the right template, because the name of the template is shortened. In this case it is impossible to use Strg + F to find the template you want to edit. So it would be better to leave the template file name path intact and do not shortened it with ....... otherwise you will go cracy. The search function doesnt work in this case. Edited: It is possible to find the right translation file in the "Select File(s)" area in the backend - I found it out a moment after I have posted this.
  15. The image grid in Firefox 39 is also displayed correctly since the update. The description is now above. Well done!
  16. Yeah, user image will be displayed since the last update - Thanks Renobird
  17. Hello Renobird, is it possible to add target="_blank" to the custom links in the top nav? I have tried to do this like that in the admin.php: "target" => "_blank" But this doesn`t work! Best regards Jürgen
  18. Hello Renobird, you are right - it depends on the browser. I use the Firefox 39. If I use the latest IE the description is above as LostKobrakai said. It seems that Firefox has more problems at the moment. I have also a problem with browser resize and responsive images. This is also a well known bug in the latest version.
  19. Here it is what the grid looks like in my backend. There is CSS problem at the description of the image field in the grid system. The description floats next to the images so a description clearing maybe would solve the problem. Best regards
  20. Yes I can verify that: Here are some screenshots: 1) image field selected in the template setting section 2) image in the user profile template 3) image settings in image field detail tab 4) Here it is what it looks like in the template nav Best regards Juergen
  21. Thanks for the awesome template, but in my case the user image will not be displayed at all. I have selected the image field in the settings.
  22. If the image or file upload field is not in an repeater, you can delete it with this line of code: $page->nameofyourfield->deleteAll();
  23. I have used $p->delete($p->filename) and it works!! Thanks
  24. Hello @ all, I am using a hook method to empty some database tables after the save action under certain conditions. It works just fine for "standard fields" with text, but i run into problems by deleting files (images or other files such as pdf). Here is the code that I use: //clean all up if event is cancelled if(($page->template == "events") AND ($page->cancelled == "1")){ $this->message("Folgende Felder wurden geleert: Einleitungssatz, Hauptteil,...); $page->body = ""; $page->introtext = ""; foreach($page->downloadrepeater as $p){ $p->downloadfield = ""; $p->downloadfieldtitle = ""; $p->downloadfiledesc = ""; } } The fields body and introtext will be deleted as expected. The file fields are in a repeater field (downloadrepeater). Therefore I use the foreach loop. The repeaterfield consists of 3 fields: - the file upload field (=downloadfield) - the title field for the file (=downloadfieldtitle) and - the description field (=downloadfiledesc) The values of the title and the description field will be deleted too - so this works. The problem is to delete the file of the file upload field. I know that $p->downloadfield = "" is not the right approach but I have tried it also with delete(). Unfortunately I was not able to figure out the right syntax to delete the file too. Can someone help to get the right api call? Best regards
×
×
  • Create New...