-
Posts
4,077 -
Joined
-
Last visited
-
Days Won
87
Everything posted by horst
-
Possible buggy url Segments / Page Numbers Interaction
horst replied to tiagoroldao's topic in API & Templates
You can do a call with your selector but with a limit=2 for the getTotal() call. This has less overhead.- 8 replies
-
- Bug
- Url Segments
-
(and 1 more)
Tagged with:
-
Hi, I have bought a ProCache licency for 3-sites and have got one key together with the download link. When I try install it on a site I get an error: Unable to validate license key. Do I need to register it somewhere? If so, where? Or do I need to do something else?
-
Hi, I use the zipupload for images with the default unzip command, I think. $config->uploadUnzipCommand = '/usr/bin/unzip -j -qq -n /src/ -x __MACOSX .* -d /dst/'; And everything works fine. Zip is uploaded, images are unzipped and added to the imagesfield. Except the resulting sortorder in the imagesfield isn't fine. If I have images like 001.jpg, 002.jpg, 003.jpg, ... I want to have this order with my imagesfield, but the images gets stored unorderd. How can I get the images stored in (alpha) numeric order with zipupload?
- 2 replies
-
- zipupload
- imagesfield
-
(and 1 more)
Tagged with:
-
rock solid
-
Hey Martijn, - right, but I've thought it was this one, ...
-
in the first post of the thread is the download link of a zip-archive: http://processwire.com/talk/index.php?app=core&module=attach§ion=attach&attach_id=695 it contain pngs, pdfs, eps's and svgs
-
Today I have added a hook to the module that add pim_* variations to pageimage-variation-collection. This is usefull to not have mass orphaned (pim_)images on the disk when original images got deleted. I have had this code ready for many weeks and would have done some more (workaround for GDlibs buggy sharpening on pngs with alpha-transparency) before update the module. But I haven't had time for this. So, there are no other changes in module version 0.1.1 what is available now at github and in the modules section. Cheers!
-
Hi, maybe a bit OT but worth to mention I think: PHP has a nice function to create and open a pointer to a temporary file - but with the advantage that it first write to memory and only flush content to the disk if a specified amount of memory is reached: $mb5 = 5 * 1024 * 1024; $fp = fopen('php://temp/maxmemory:' . $mb5, 'rb+'); // then add content to the pointer ... fputs($fp, "hello\n"); // At the end rewind and echo out the content: rewind($fp); echo stream_get_contents($fp); The first 5 MB will kept in memory and if the content hits the limit it gets written into a temporary diskfile. see: http://www.php.net/manual/en/wrappers.php.php
-
festival site with processwire and ajax - Boom Festival
horst replied to retinafunk's topic in Showcase
@retinafunk: WOW! --------- found this and thought it maybe of interest: https://github.com/webcreate/infinite-ajax-scroll/blob/master/src/jquery-ias.js#L630 ? -
Looks good. I'm actually working on a DB for a colleague and I have imported 2000 pages and 35.000 images similar like that. For testing I use breaks in the loop to just test only one import, or use a counter and import 5 or 10 images before breaking. When seeing it works well I comment the breaks. Also I make a SQL-Dump before testing/modifying/importing. And I write logfiles. And I love importer-scripts!
-
@Ryan. Ooh, - it was based on the default Basic-Profile, but have switched to use Spex and have created many Fields, Templates and Pages. During this I (must) have set the Template of the http404 page to tools. Switched back to basic-page template it works as expected again! Thanks Ryan.
-
Yes, have switched to language support!
-
I get this Errormessage when calling a page that doesn't exist. I think I have disabled / messed up the correct handling of 404 codes by PW, but don't know where. How can I correct it? <br /> <b>Fatal error</b>: Exception: Template file does not exist: '/www/htdocs/site/templates/tools.php' (in /www/htdocs/wire/core/TemplateFile.php line 67) #0 /www/htdocs/wire/core/TemplateFile.php(55): TemplateFile->setFilename('/www/htdocs/w01...') #1 /www/htdocs/wire/core/Page.php(1260): TemplateFile->__construct('/www/htdocs/w01...') #2 /www/htdocs/wire/modules/PageRender.module(297): Page->output(true) #3 [internal function]: PageRender->___renderPage(Object(HookEvent)) #4 /www/htdocs/wire/core/Wire.php(359): call_user_func_array(Array, Array) #5 /www/htdocs/wire/core/Wire.php(317): Wire->runHooks('renderPage', Array) #6 /www/htdocs/wire/core/Wire.php(381): Wire->__call('renderPage', Array) #7 /www/htdocs/wire/core/Wire.php(381): PageRender->renderPage(Object(HookEvent)) #8 /www/htdocs/wire/core/Wire.php(317): Wire->runHooks('render', Array) #9 /www/htdocs/wire/modules/Process/ProcessPageView.module(433): Wire->__call('render', A in <b>/www/htdocs/index.php</b> on line <b>225</b><br /> <p class='error WireFatalError'><em>This error message was shown because site is in debug mode ($config->debug = true; in /site/config.php). Error has been logged. Administrator has been notified. </em></p> I don't know why it checks for a template file 'tools.php'. I have called childpages from different parents that have templates 'basic-page', 'gallery', etc. but no one uses the template 'tools'.
-
you also should check apache / htaccess, especially: <IfModule dir_module> DirectoryIndex index.php index.html index.htm </IfModule>
-
Don't really know if it supports what you needs, but seems to be worth a look / try: http://processwire.com/talk/topic/3471-ability-to-sort-and-search-through-users-in-admin/#entry36481 https://github.com/apeisa/ProcessUserExtended/blob/master/ProcessUserExtended.module
-
Module: Spex: An asset and template management module
horst replied to Jonathan Dart's topic in Modules/Plugins
Hi Jonathan, it's really nice & fun to use Spex! Now as I have played around with it when switching debug mode to false I run into an issue that breaks the minify process and end up with a page without styles. In the modules method compileStyle a link to a stylesheet appended by a ?v=100 isn't recognized correctly. A vardump of the pathinfo outputs something like: array(4) { ["dirname"] => string(34) "/site/modules/AdminTemplateColumns" ["basename"] => string(30) "AdminTemplateColumns.css?v=100" ["extension"] => string(9) "css?v=100" ["filename"] => string(20) "AdminTemplateColumns" } The extension isn't recognized. As the $stylesheet is a URL at first and not a filesystem link I come up to pass it through parse_url() first and use that path. Also needed is to keep the extracted path and return it back if it isn't a less-file: $sheetInfo1 = parse_url($stylesheet); $sheetInfo2 = pathinfo($sheetInfo1['path']); if ($sheetInfo2['extension'] != 'less') return $sheetInfo1['path']; This solved the issue with breaking the Minify. -
EDIT: SOLVED: http://processwire.com/talk/topic/4562-module-spex-an-asset-and-template-management-module/#entry46402 I have found a solution with the Spex module, sorry for bothering here! -------------------------------------------------------------------------------------------------------------------------------------------------------- @Pete: thanks for the two columns in Admin! It's really helpfull. But also I run into a little issue with the css filename you use. It is appended a ?v=100 to it, and that seems to crash the Minify module. Haven't investigated further because I use Spex together with Minify and all is new to me. But I'm also wondering why the css of the admin backend is loaded in a front end page? Is this because I'm logged in and all styles & js of the modules get loaded automatically? complete URL to call Minify is: /site/modules/Minify/min/?f=/site/modules/AdminTemplateColumns/AdminTemplateColumns.css?v=100,/site/template/styles/main.css I don't know where the process should be tweaked (admintemplatemodules, minify, spex, pw-styles-loader) but as you have done this one and the Minify module I've thought here is a good place to ask.
-
It doesn't work with negative numbers. They get corrected to 0 (zero) at some other points in PW, not only at Pages::setupNew()
-
Pagetree Add New Child Reverse New Pages in Descending Sortorder (newest first) while sortmode can be "Manual Drag-n-Drop" When a site display an overview of the latest posts, news, image-albums, etc. the newest entries should be on top of the list. We can achieve that by using an automated setting for the sortfield e.g. when the page was created = "-created". But this way we are not able to manually move a single page in the tree. This module enables us to do exactly that. It works with manually created pages, with pages created via the API, also when bootstrapped by importer scripts. Pagetree "Newsitems" with 3 newsitems sorted in descending order. New created item 4 is added to the top. To change the order click item 3 and drag it to the top and drop it. How to use it Download the module into your site/modules/ directory and install it. In the config page you find a single textarea field. Here you can enter the templatename or page-ID of the page which children should get reverse added, - optionally followed by a comma and the child-templatename if you need a more precise selector. You can add as many parents as you like, but only one on each line and in this format: TEMPLATE-NAME or PAGE-ID[,CHILDTEMPLATE-NAME]. A few examples: newsitems posts,post 1042 1033,album You want set your template(s) sortfield(s) to 'Manual drag-n-drop' if not have done already. ATTENTION You need to setup the TreeParent and the module config when there are no children in it! Otherwise it will not work! Also disabling the module once you have added children and then add one new page to it will mess up all! (You may think about to install the module as permanent in critical situations.?! see below ->) If you need to install it in a site for an already existing branch, you can do it this way: move / rename your existing branch create a new (empty) branch with the original name move your childpages into the new branch remove the renamed (and now empty) old branch DOWNLOAD - Version 1.0.2 get it from the Modules Directory Want to make it bulletproof? If you are concerned that the module settings could be dropped by other users or that the module itself could be uninstalled by accident, you may edit the module file directly: add the settings to the class constant permanentValue uncomment setting for permanent in the ModuleInfo This way the permanent settings couldn't be dropped by accident. To change it you first need to edit the modules file again. Example: You have two settings in the inputfield of the modules config, without permanent setting: parenttemplate1,childtemplate1 parenttemplate2,childtemplate2 Now you want to have the the first setting become bulletproof permanent: a) you enable the setting in the getModuleInfo, (uncomment setting for permanent) b) you write your permanent settings under the constant permanentValue const permanentValue = "parenttemplate1,childtemplate1"; After both steps, the module cannot get uninstalled anymore (Step a), and the first setting cannot get deleted anymore (Step b), as it is recreated with every call of the configscreen. (See first code line of method getModuleConfigInputfields) If you want to keep both definitions permanent, write them separated with a newline character "\n" : const permanentValue = "parenttemplate1,childtemplate1\nparenttemplate2,childtemplate2"; History of origins create pages via API, how add to the top of tree? Create new child as top sibling rather than bottom? New page on top? Pin Page to Top of Page Tree? move and sort pages with the API
- 34 replies
-
- 12
-
coming back to this: I have made good progress! I do not use the htaccess file in site/assets/files/ anymore but have edited the htaccess file in pw root folder. Somewhere at top of the mod_rewrite directives I have added my lines that should redirect requests to original images to a proxy-script and let others pass through: htaccess with Pim1 and PW < 2.5.11 .htaccess with PW 2.5.11+ / PW 3+ # ----------------------------------------------------------------------------------------------- # CUSTOMSETTING : redirect original images to proxy-script - /pwimg.php?fn=... # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} (^|/)site/assets/files/(.*?)/ RewriteCond %{REQUEST_FILENAME} \.(jpg|jpeg|gif|png)$ [NC] RewriteCond %{REQUEST_FILENAME} !-piacrop RewriteCond %{REQUEST_FILENAME} !-piacontain RewriteCond %{REQUEST_FILENAME} !-pim2-full RewriteCond %{REQUEST_FILENAME} !-blogthumb RewriteCond %{REQUEST_FILENAME} !.*/.*?\.([0-9]+)x([0-9]+)\.(jpg|png|jpeg|gif)$ [NC] RewriteRule ^(.*)$ pwimg.php?fn=$1 [L] Now from all existing images the originals get redirected to the proxy-script and the others will delivered directly by apache. Requests to none existing imagefiles get answered by a 404. So as everything seems to work fine, the RewriteConditions could be optimized a bit. ---- pwimg.php ---- <?php // check filename $imgFilename = isset($_GET['fn']) ? preg_replace('/[^a-zA-Z0-9_\-\/\.@]/', '', $_GET['fn']) : false; $imgFilename = is_file(dirname(__FILE__) . "/$imgFilename") && is_readable(dirname(__FILE__) . "/$imgFilename") ? dirname(__FILE__) . "/$imgFilename" : false; if (false == $imgFilename) { header('HTTP/1.1 404 Not Found'); exit(2); } // check imagetype $imgType = getImageType($imgFilename); if (false == $imgType) { header('HTTP/1.1 403 Forbidden'); header('Content-type: image/jpeg'); exit(1); } // bootstrap PW require_once(dirname(__FILE__) . '/index.php'); // check user-account if (! wire('user')->hasRole('superuser|editor')) { header('HTTP/1.1 403 Forbidden'); header('Content-type: ' . $imgType); exit(1); } // collect infos $maxAge = (60 * 60 * 2); // 2 hours $imgTimestamp = filemtime($imgFilename); $imgExpiration = intval(time() + $maxAge); // create headers $imgHeaders = array(); $imgHeaders[] = 'Content-type: ' . $imgType; $imgHeaders[] = 'Content-Length: ' . filesize($imgFilename); $imgHeaders[] = 'Date: ' . gmdate('D, d M Y H:i:s',time()) . ' GMT'; $imgHeaders[] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s',$imgTimestamp) . ' GMT'; $imgHeaders[] = 'Expires: ' . gmdate('D, d M Y H:i:s', $imgExpiration) . ' GMT'; $imgHeaders[] = 'pragma: cache'; $imgHeaders[] = "Cache-Control: no-transform, private, s-maxage={$maxAge}, max-age={$maxAge}"; // send headers foreach($imgHeaders as $imgHeader) header($imgHeader); // send file $errorCode = @readfile($imgFilename) === FALSE ? 1 : 0; // and exit exit($errorCode); // --- functions --- function getImageType($fn, $returnAsInteger = false) { $types1 = array(1 => 'gif', 2 => 'jpg', 3 => 'png'); $types2 = array('gif' => 1, 'jpg' => 2, 'jpeg' => 2, 'png' => 3); if (function_exists('exif_imagetype') && isset($types1[@exif_imagetype($fn)])) { $success = $types1[exif_imagetype($fn)]; } if (!isset($success) && function_exists('getimagesize')) { $info = @getimagesize($fn); if (isset($info[2]) && isset($types1[$info[2]])) { $success = $types1[$info[2]]; } } if (!isset($success)) { $extension = strtolower(pathinfo($fn, PATHINFO_EXTENSION)); if (isset($types2[$extension])) { $success = $types1[$types2[$extension]]; } } if (!isset($success)) return false; return true === $returnAsInteger ? $types2[$success] : $success; }
-
Good find, Yannick!
-
@Marty: I do this by using a module. It's a copy from somas PageListShowPageId. the PHP code is public function init() { $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageArchivnummerLabel'); } public function addPageArchivnummerLabel($event) { $page = $event->arguments('page'); if('album'==$page->template) { //$event->return = str_pad(count($page->images), 3, '0', STR_PAD_LEFT) . " " . $event->return; $event->return = $event->return . ' <span class="jhpPageListArchivnummer">' . $page->archivnummer . '</span> ' . ' <span class="jhpPageListImageCount">' . count($page->images) . '</span>'; } } and the CSS is .content .PageListItem > a span + span.jhpPageListImageCount:before { content: 'count: ' !important; } .content .PageListItem > a span + span.jhpPageListArchivnummer:before { content: '' !important; } .content .PageListItem > a span + span.jhpPageListImageCount, .content .PageListItem > a span + span.jhpPageListArchivnummer { font-size:0.9em; background-color:#EEE; color: #777; padding: 2px 5px 1px 5px; border: medium none !important; border-radius: 3px 3px 3px 3px; }
-
I don't like working with RTEs, especially don't use them together with images. So at least you are right: we shouldn't assume that there isn't embedded width and height in all situations.
-
@adrian: I don't think that this could make trouble because he searches for "<img " and replaces it with "<img width='150' height='150' " This seems to be 100% robust as every html-image-tag has to begin with <img followed by at least one space
-
delete orphaned files/images from site/assets/files
horst replied to interrobang's topic in General Support
Hi Nik, thanks to clarify. You may have a look into some existing modules that deal with images and textareas: http://modules.processwire.com/categories/photo-video/ for example the ImageInterceptor. Maybe you find code that preg_matches all imagelinks of textareafields. somas Images Manager also deals with textarea fields in some parts: https://github.com/somatonic/ImagesManager/blob/master/ImagesManagerParser.module And if you don't get it to work, please come back here to ask for help. To enhance the script to also support images in textareas is usefull for many other users I think. I think the new code can be go here: // ... // determine which files are valid for the page $valid = array(); foreach ($page->template->fieldgroup as $field) { if ($field->type instanceof FieldtypeTextarea) { // here comes the code to parse the content of textarea for images links that resides in assets/files/idOfCurrentPage/ // all found images must be added to the array $valid! // ... } elseif ($field->type instanceof FieldtypeFile) { // here follows the existent code for files and images fields