Jump to content

bora

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by bora

  1. Any ideas on topic or should I give more details?
  2. Hello, I'm migrated a few hundred users from an old system to PW via API. I created users, they can log in etc but only one thing is not working. Users have repeater fields. After I create users I also create those repeaters but I cannot get their value from front-end of the website. But if I go to users editing page from admin I see the values in place correctly. And when I save the user from editing page (without changing anything just saving), it starts to work normally. What am I missing here, what should I do to achieve this by API? Thanks
  3. That was actually what I did, disable templateCompile from config.php after running this script. Added this recommendation to gist as well to help anyone willing to try it. Adding namespace to all files and disabling templateCompile is, as far as I understand, is the cleanest state for PW3. By the way FileCompiler worked for modules flawlessly, except two small exceptions (one was my fault one was 3rd party module). This week I'll test further before migrating to PW3 on production as well. So far on my local copy I enjoy the perks of PW3 already On the other hand, adding namespace to every little view partial doesn't look like very ideal and practical. I will look into other possible ways of using partials instead of wireRenderFile. Error generally occured due to using global functions like wire() or functions from _func.php on non-namespaced files. Out of habit from Laravel, CakePHP etc. I assumed that global functions would continue working without a namespace but then I realized I should be thinking everything within Processwire.
  4. Yes, I use wireRenderFile method extensively. Now I tried again by changing all calls to wireRenderFile function to absolute from the wrapper function I use. I only put namespace on root folder of templates. But even though I use full paths on wireRenderFile, the .php files in templates/partials still throws errors like Fatal error: Call to undefined function getCatalogues() in /var/www/dev.com/pw3/site/templates/partials/main.php on line 9 (it's defined in _func.php)
  5. Hello everyone, Last night as a "saturday night shitty weather stay at home" project I attempted to migrate a project that was on PW 2.7.x to PW 3.x I use a lot of partials on the project so I have around 200 php files that needs to be namespaced. Compiler was giving me trouble with "Call undefined function" errors. Being the lazy developer I attempted to wrote a script after getting bored over pasting the namespace Processwire; line into around 10 files. Below you can find the script, that is very basically adds <?php namespace Processwire;?> as the first line of every .php and .module file in the given directory and shows you the results. Of course it checks for namespace Processwire first By default it assumes ./site/templates folder but I tried it with a module which is giving errors due to namespaces and worked fine. Be careful and remember to take backups first https://gist.github.com/borantula/e41c4b6ba36f78b1110d400a16754691
  6. Hello, Any of you also get "upstream sent too big header while reading response header from upstream," error and site went down with 502 while trying ChromePhpLogger? I found out it's a problem with nginx. https://github.com/ccampbell/chromephp/issues/10 I couldn't find a solution but in case anyone else has this, nginx is to blame :/
  7. Thank you for the tip I put the main email that collects all form submissions of the site in TO and rest of them in CC. This solves the problem fine for now, if it's needed I'll extend the class And thank you for compliment, the old one looked like a mafia guy in deed
  8. Hello, When I try to mail via wiremail, using an array of email addresses to send I always receive them as if only sent to me. ( What I mean is, I only see one address on to field when I receive mail) $mail = wireMail(); $to = ['myemail@email.com','otheremai@email.com']; $mail->to($to); Is there any way to send them together? Thanks ahead
  9. In the site we are developing we noticed a bug. If we save a page with already existing name in the secondary language it skips the "Already in use" check. (It uses latest dev version) I can open 2 pages under the same parent with the same url with the second language. To be sure I did another clean installation to see if it is a core bug or result of an extra module, it works well on the clean install. Where or which hooks should I check for this to find out which code might be causing this during save process? Thanks ahead
  10. bora

    Jump-Inc

    Great design work, I love the layout and colors. Without using absurd and heavy javascript effects you managed to create a very much alive site.
  11. To prevent open in new window or save link as by user.
  12. I just coded this functionality with updated methods of PW. I use it to give all the images of the news page as a package for press release purposes. This is triggered by a button on the page like below, so the link above does not change, page is stable but download starts. <button onclick="window.location.href='<?= $page->httpUrl; ?>?download=images'"> if ($input->get->download == 'images') { if ($page->images->count() > 0) { //collect images $imagesArray = []; foreach ($page->images as $img) { $imagesArray[] = $img->filename; } //zip images //TODO: in a function $zipPath = $config->paths->files . $page->id . DIRECTORY_SEPARATOR . $page->name . '.zip'; wireZipFile($zipPath, $imagesArray, [ 'overwrite' => true ]); $options = array( // boolean: halt program execution after file send 'exit' => true, // boolean|null: whether file should force download (null=let content-type header decide) 'forceDownload' => true, // string: filename you want the download to show on the user's computer, or blank to use existing. 'downloadFilename' => $page->name . '.zip' ); wireSendFile($zipPath, $options); exit; } }
  13. Hello, When I try this, it downloads the files (in my test case a docx file). It works but two things happen. 1- It renames file to download.doc 2- It converts the extension from docx to doc Any idea why that happens? Ok just after a second later figured it out. Setting forceDownload to false causes both of them. Works perfectly fine now, many thanks Soma.
  14. This is a sample website configuration for that works under domain.com/tr subdirectory (for historical reasons). Though it is a WordPress site, I think it might be similar (location /tr/ part) code is: server { root /usr/share/nginx/html/blog/; index index.php index.html index.htm; server_name domain.com; location / { # try_files $uri $uri/ =404; try_files $uri $uri/ /index.php?q=$uri&$args; } location /tr/ { try_files $uri $uri/ /tr/index.php?$args; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
  15. And as an additional advice, for creating dynamically, you may include a global option for all pages like "include in the menu" and you can use this option for filtering pages that you want to or don't want include in the tree
  16. Just installed and tried the dev branch and it works really good. Thank you. I really think it should be made to a module. By the way, I added another helper function to use while setting the FEEL js variable. So both local and live server works even if their relative paths are different. But I'm not use if this works with all cases. PHP: function feelPath() { //remove doc root from full wire path for relative wire path $wireRelativePath = str_replace($_SERVER['DOCUMENT_ROOT'],'',wire('config')->paths->wire); return $wireRelativePath; } JS: var FEEL = { wirePath: "<?=feelPath();?>" };
  17. 1,5 month later, after I did most of the project and be sure that I understand PW system, I finally finished that part. It's not perfect of course but it's working fine. Here is how I did it: Templates And Fields: I created 2 templates: grid and grid_item and 1 pagetableextended field grid_items. In grids page I can enter grid_items like below: Title, summary, featured_image for content on the grid items, external url for obvious reasons, grid_ratio is to determine size of item. Design is limited with ratios from 1x1 to 3x3, so I made it selectable page items from options use_border : for images with white bg, so they don't look like they are floating Modules I have created 3 modules. InputfieldGridBuilder,FieldtypeGridBuilder and GridBuilder. Whenever I save the page, new items from grid_items pagetable are available to use like below. I can order items, add new rows, delete row etc. Whenever I change something, there is a method that works to serialize data to the hidden input field,InputfieldGridBuilder. Also, just in case I call the function it every 5 seconds. I make a small fixed grid that is very similar to the one used in the frontend. So anything that you can do here with jQueryui sortables, it's available for using in the frontend. Last module GridBuilder is used for mostly utility purposes for both frontend and backend. It has methods like getItemSize, getItemImage, build etc. Frontend Normally these will be used in homepage but I made the view of page available to users with editing roles, so before using them they can see that it look like. For example this one in the gif above looks like this. So even with the empty rows, it works. And for using in the homepage, I added a multiple selection page field. So they can use more than one grid, or with the location options we already added they can select to have a different view for different countries. (I added Location settings is globally for every page) Questions, critics, feedbacks or "hi,there buddy"'s are highly welcomed.
  18. I think the site is down now, I got the message below This Account Has Been Suspended
  19. I'm not sure if makes a difference in behaviour but you may also use it like $page->buildings->filter("status=1")->count() . As it is object's own method it might be more reliable.
  20. Yes, I think setting upscaling to false by default is a good idea and whenever necessary you can do it by css anyway.
  21. As stated in the doc, you can use it when viewing but like: $image = $page->images->first()->getCrop('portrait', "height=400, sharpening=medium, quality=85"); Not sure if it will be sufficient for your needs.
  22. in your sites config.php you can set them like below. $config->imageSizerOptions = array( 'upscaling' => true, // upscale if necessary to reach target size? 'cropping' => true, // crop if necessary to reach target size? 'autoRotation' => true, // automatically correct orientation? 'sharpening' => 'none', // sharpening: none | soft | medium | strong 'quality' => 100, // quality: 1-100 where higher is better but bigger 'hidpiQuality' => 60, // Same as above quality setting, but specific to hidpi images 'defaultGamma' => -1, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0) );
  23. I tried the new bookmark system in the dev branch (2.6.17). It's great for quick access, but I have too many parents with the same name "Products" under different parents like "office/products" "home/products" etc. So I needed to change the labels for add new button on Tree view. After a little bit poking I found a solution, so I'm sharing for anyone who might need. public function init() { //hooking the event for editing list of bookmarked pages from my SiteHelper module $this->addHookAfter("ProcessPageAdd::executeNavJSON", $this, 'bookmarksEvent'); } public function bookmarksEvent(HookEvent $event) { $eventReturn = $event->return; foreach($eventReturn['list'] as $key => $item) { //if its a parent url for adding if( strpos($item['url'],'parent_id') > 0 ) { $url = str_replace('?','',$item['url']); parse_str( $url ); //get page in the bookmark $page = wire('pages')->get($parent_id); //my scheme is for a label format: parentTitle - title $newLabel = "{$page->parent->title} - $page->title"; $item['label'] = $newLabel; $eventReturn['list'][$key] = $item; } } $event->return = $eventReturn; }
  24. I think so. Identical site was working fine on local server, under same ubuntu version. Only thing I did was to remove gd and install again. Then it was fixed by itself.
  25. Hello again, I tracked down the problem on dev branch. Not sure if this is normal or something related to another module but this fixed the frontend problem. I realized that $inputFieldInstance check on the FieldtypeCroppableImage > getCrop always returns null on frontend with the multiple image field. I checked and changed the _getInputFieldInstance method as below. Only change is the $image->pagefile === $pagefiles check part. I also sent a pull request from github. I hope it's the right fix. public function _getInputFieldInstance(HookEvent $event) { $field = null; // where we'll keep the field we're looking for $image = $event->object; $page = $image->page; $action = $event->arguments[0]; // find all fields of type FieldtypeImage that are part of the page we're using // or regular image fields with InputfieldImage inputfield assigned $imageFields = array(); foreach($page->fields as $f) { if ($f->type instanceof FieldtypeCroppableImage || ($f->inputfieldClass && $f->inputfieldClass == 'InputfieldCroppableImage')) { $imageFields[] = $f; } } // loop through to find the one we're looking for foreach($imageFields as $imageField) { // good to get unformatted in case it's a single image field, // because it'll still be an array rather than 1 image $pagefiles = $page->getUnformatted($imageField->name); // TODO: name to lowercase $pagefilesFirst = $image->pagefiles->first(); // if the image's pagefiles property matches the one with the // field we're looking at, we have a match. save in $field foreach($pagefiles as $pageImageFile) { if($pagefilesFirst === $pageImageFile) { $field = $imageField->getInputfield($page); break; } } //This is commented, not working on dev branch 2.6.15 /* if ($image->pagefiles === $pagefiles) { $field = $imageField->getInputfield($page); break; } */ } if ($field) { //$event->return = $out; return $field; } return null; }
×
×
  • Create New...