Jump to content

Can

Members
  • Posts

    350
  • Joined

  • Last visited

Everything posted by Can

  1. I'm trying to figure out the same. Got the PW3 front end edit modal and want it to redirect to changed page on save. Reason: The edit might change the name and therefore the url of the page. @thetuningspoon what's your code so far? This is what I got: $wire->addHookBefore('ProcessPageEdit::processSaveRedirect', function($event) use ($page) { $url = $event->arguments[0]; if($this->input->get->modal && $page->process && $page->process != 'ProcessPageView') { $event->arguments(0, $page->url); } }); It's still just closing the modal and staying on the same page.. When changing $page->url to eg "http://example.dev" I get the following error, which shows up in browser console Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://www.happyfamily.dev" from accessing a frame with origin "null". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "data". Protocols must match.
  2. Anything new on this front? Maybe bootstrapping with PW 3? I'm not too familiar with namespaces and the possibilities..
  3. Would be amazing to get multilanguage ckeditor in form api Or am I mixing things up and it's only not supported for module configs? If so please let me know how to use multilanguage ckeditor with form api, I got a little Newsletter ProcessModule and right now I use 2 textareas side by side, would be neat two have 'em like on a page edit page
  4. just in addition. there is return $this->halt(); now, to stop further output, but still let processwire shut down properly ;-)
  5. I went another way, don't know why but those others felt a little more hacky, maybe I still don't understand enough in this fields.. Maybe someone got improvements or is just interested in using another approach here it is: $limit = 42; $current_page = $input->pageNum ? : 1; $start = ($current_page - 1) * $limit; // I'm joining pages table because I needed only images from certain templates in this case tpl_id 44 & 52 // and I'm sorting by page published date // if you don't need this context you could of course go without the join $images = $database->prepare('SELECT i.pages_id, i.data, i.description, i.tags FROM field_images AS i LEFT JOIN pages AS p ON p.id = i.pages_id WHERE p.templates_id IN (44,52) ORDER BY p.published DESC, i.sort ASC LIMIT :start, :limit '); $images->bindValue(':start', (int)$start, PDO::PARAM_INT); $images->bindValue(':limit', (int)$limit, PDO::PARAM_INT); // I tried to pass the params via the execute, but somehow I couldn't get it working, he wouldn't treat them as integer, even though some people are doing it..?! $images->execute(); while ($rawImage = $images->fetch(PDO::FETCH_OBJ)) { // for easier image handling I turn the raw data into an actual Pageimage $p = $pages->get($rawImage->pages_id); $i = new Pageimage($p->images, $rawImage->data); // create whatever markup you prefer for your gallery } // Just read about "SQL_CALC_FOUND_ROWS" here http://stackoverflow.com/a/12887293/3484824 $totalImages = $database->query('SELECT count(*) FROM field_images AS i LEFT JOIN pages AS p ON p.id = i.pages_id WHERE p.templates_id IN (44,52)'); $totalImages = $totalImages->fetchColumn(); $totalPages = ceil($totalImages / $limit); // and the pager $content .= "<ul class='pagination'>"; if ($input->pageNum > 1) { $prevPage = $input->pageNum > 2 ? $page->url . 'page' . ($input->pageNum - 1) : $page->url; $content .= "<li class='pagination__item'><a href='$prevPage'>prev</a></li>"; } for ($i = 1; $i < $totalPages; $i++) { $pagerPage = $i === 1 ? '' : "page$i"; $current = $input->pageNum === $i ? ' pagination__item--current' : ''; $content .= "<li class='pagination__item{$current}'><a href='{$page->url}{$pagerPage}'>$i</a></li>"; } if ($input->pageNum < $totalPages) { $nextPage = $page->url . 'page' . ($input->pageNum + 1); $content .= "<li class='pagination__item'><a href='$nextPage'>next</a></li>"; } $content .= "</ul>"; So far so good, hope you enjoy this peace of code and improvements, tips and tricks are always welcome as I'm still learning
  6. I'm getting the same error and quite often. Maybe it's about the admin/superuser account? Cause Soma said indice of pages_id and sort in this case, or at least in my case it should be about language or roles field of the superuser, but I'm not changing my own language or roles any where via api only having a few $user->isSuperuser conditionals...installation is quite new PW 2.7.1 just a few module manually imported from another PW installation and re-modeled almost everything Would love to fix this, but as long as nobody else will be annoyed by this error visibly it's not too bad.. ;-)
  7. Thanks for sharing LostKobrakai, I got only one additional language, so for me it fits for now, but with more it's better to automate it of cause. That's a valid point I guess your idea title.lang.de is nice and then title.lang.all to query all languages
  8. Hey folks, I use InputfieldPageAutocomplete a lot, but because the website is dual language it's a little awkward when creating new tags with this field. While looking if anyone else had a solution for this I found out that InputfieldPage is still not activating language urls https://github.com/ryancramerdesign/ProcessWire/issues/889 but couldn't find a solution how to translate new entries on the fly. Maybe someone comes up with a nicer solution, but for now it works for me. I copied InputfieldPage.module to /site/modules/ and added a few lines of code. Now when creating a new tag using for example autocomplete field, I just enter "foo:bar" where foo is default (english) and bar is german title. So as you can see, right now it's quite static.. Here my complete file, I commented my additions with "added by Can" I would love to read your thought on this. Maybe it could be interesting to have it check for both (or all) languages if the provided exists, but I'm not exactly sure how to do that. change user language via api and run line 610 again? Or a direct $database query would be possible.. By the way, I think it would be amazing to have language selectors, like a sub-selector "title.de" or something
  9. Maybe it's because of "Allow relative/local URLs without "http://" at the beginning?" in the url fields details tab settings?
  10. As far as I know you would need to add some custom css/js to accomplish this. This could help modules.processwire.com/modules/admin-custom-files/ but there other approaches out there, e.g. custom module or /site/init.php or /site/ready.php Sorry don't have a quick example write know Or you could even take /wire/modules/Fieldtype/FieldtypeRepeater folder copy it to /site/modules/ make you changes/additions go to your admin backend click on modules -> refresh and then choose your Fieldtype repeater version (Processwire will detect both versions after refreshing and prompting you to choose in a notification) cheers Can
  11. welcome ounos 1. I think you need to clarify a little more, where should it fallback to default if german is not active? Maybe you mean "Inherit value from default language" under Field Settings -> Details? 2. Not directly, but you could have your own redirection, for example create a custom field e.g. "only_de" than in your template or prepended template file _init.php if($page->only_de) { $de = $languages->get('de'); $session->redirect($page->localUrl($de)); } 3. Edit you home page (page with page id 1) and under settings you remove default name for default language, so you leave the url field empty and set "de" for your german url for example Just ask if something isn't clear or I got you wrong Chears
  12. I guess you enabled "directory traversal" in AIOMs module settings?
  13. But the name of the default language is "default" so she won't get "de", or am I missing something here? Ah thanks SiNNuT, I remember
  14. Hola Hanna, actually I dont't know _x() probably this function but __("string to translate") (two underscores) translates strings in template files, or better to say let's you translate via /processwire/setup/languages/ So in your case you would either change the line from <html lang="<?php echo _x('en', 'HTML language code'); ?>"> to <html lang="<?php echo _x('de', 'HTML language code'); ?>"> or you in admin you go to /setup/languages/ select your default (german) language and click on_main.php to translate, somehwere there should be written "HTML language code" and there you enter "de" I used a different approach in _init.php I defined the following // define var $lang for use in tpl files if($user->language->name == 'default') $lang = 'de'; else $lang = $user->language->name; then you can just put this in _main.php <html lang="<?= $lang; ?>"> and of course re-use wherever you like. Or, you could use the languages title field or add another custom field to language template and name it for example "language_short_code" or maybe you got an already created textfiel which you could re-use here. then you don't need to override the default languages name but just output your shortcode field like <html lang="<?= $user->language->language_short_code; ?>"> Hope it helps, enjoy Processwire
  15. I think I fixed the Maximum Execution Time Error by fixing an unclosed comment tag within a CSS file. At least on my local machine it's working, should work live, too but haven't tested it yet.. And I ran into an issue with JS minification "Error JSMin: unterminated byte.." Fixed it by renaming already minified files to NAME.min.js, seems to work for now Why isn't AIOM clearing cached files when creating new once, like replacing them. I had quite a long expiration time and had sometimes over 80 cached files in cache..? Maybe my fault^^
  16. Thanks for replying and the tip Ryan, good idea. After searching for "body contains text = 13386766403_26b808ce9f_b.jpg" I got one article matched. But after clicking on edit I couldn't find the image, searched body in source mode and checked english and german tab. Then I remembered your "in memory" saved the page (without any changes) hit the Lister refresh button et voilà, the page is gone from the results.. Error Image referenced on page /blog/the-body-is-small-the-soul-is-big/ that user does not have view access to (/site/assets/files/9910/gaiabelly.225x0-is-pid10393.jpg) Found image in body field, just opened it, for now the error seems to stay away. Then I have errors like this Image file on page /de/globetrawter/galerie/ no longer exists (0) so no image name, it only says field: body and links the mentioned page when I collapse the error. But the body field is empty on this page, it's actually just a container (album template) for images. Image file on page /blog/the-universe-is-your-mirror/images/ no longer exists (thumbnail_523370_10150668435971769_265394792_n.jpg) 20 secs Field: body Page: images Thats a container, too. So no function itself or content other than title. It holds image children.. Actually I forgot to redirect those to the parent page, in this case the article..Just fixed this. Maybe this triggered the error somehow? Trash is empty. Don't have the LinkAbstractor installed. Whats the best way to get you a clean list of all my installed 3rd party modules? Just removed all notifications but they're coming right back, one by one..I guess triggered by some bot or something? Okay it started one by one..now they're back to 99. What do you think. Run $p->save() or maybe just $p->save("body") on all affected pages? Or what exactly does "page loaded in memory" mean? What memory? By the way, some notifications are not closable because the icon gets overlapped by title or sometimes the created time. Just tested again, seems like time is the "problem" it triggers the notification to collapse. Kay I copied the modules list from db for now. So not only 3rd party. The number is the flag column from the table
  17. I highly recommend reading the second post, too before implementing anything, as it might simplify a lot, depending on your setup.. Because I just updated all MarkupCaches with newer WireCache, couple of weeks ago, and really like it, I thought why not share it. So I got _init.php as prependTemplateFile, and _out.php as appendTemplateFile. But let's check out the interesting part, for example an article.php template. but for some pages, for example blog, it makes sense to include all children ;-) You can include any page you like, or define a time or a template as expiration rule. Here my defaults from the _init.php $cacheNamespace = "hg"; $cacheTitle = "$page->template-" . $sanitizer->pageName($page->getLanguageValue($en, "title")) . "-$page->id-{$user->language->name}"; $cacheTitle .= $pageNum ? "-$pageNum": ''; $cacheExpire = $page; I'm not exactly sure if there is any benefit in using a namespace, you can omit the namespace part and if needed just prefix the cache title. Works both. You'll see why I added the namespace/prefix a little later ;-) For the title I'm getting, the template, english page title (you can of course use the language title and omit the language name part, but I liked it better to have the caches grouped.. After language name I'm adding the page number if present. If you need you can of course create a different, more or less specific cache title. Add get parameters or url segments for example. Then I have $cacheExpire already set to $page as default value, so I don't need to set it in every template So my markup (only the important parts) looks like this: //You can have anything you like or need uncached above this $cacheExpire = $page->chilren(); $cacheExpire->add($page); $cache->getFor($cacheNamespace, $cacheTitle, "id=$cacheExpire", function($pages, $page, $users, $user) use($headline) { // as you can see, within the function() brackets we can pass any Processwire variable we need within our cached output. // If you don't need any you can of course leave the brackets empty // and if you need any other variable wich you had to define outside this function you can pass them via use() // so here goes all your markup you want to have cached // for example huge lists, or whatever }); // Then I have some more uncached parts, a subscription form for example. // After this comes another cached part, which gets -pagination appended to the title. Otherwise it would override the previous one. // It's not only caching the pagination, I just needed a name for differentiation. $cache->getFor($cacheNamespace, $cacheTitle.'-pagination', "id=$cacheExpire", function($pages, $page, $users, $user) use($headline) { // so here comes more cached stuff }); After this your template could end or you can have more uncached and cached parts, just remember to append something to the cache title ;-) Now comes, at least for me, the fun part haha In my prepended _init.php template file I have the following code under the cache vars: if($user->isSuperuser() && $input->get->cache == 'del') { if($input->get->clearAllCaches == "true") { $allCaches = $cache->get("hg__*"); foreach($allCaches as $k => $v) $cache->delete($k); $session->alert .= "<div class='alert alert-success closable expire'>All (".count($allCaches).") caches have been deleted. <i class='fa fa-close'></i></div>"; } else { $currentPageCaches = $cache->get("hg__$page->template-" . $sanitizer->pageName($page->getLanguageValue($en, "title")) . "-$page->id*"); foreach($currentPageCaches as $k => $v) { $cache->delete($k); $session->alert .= "<div class='alert alert-success closable expire'>Cache: $k has been deleted. <i class='fa fa-close'></i></div>"; } } $session->redirect($page->url); } So when I append the parameter "?cache=del" to any URL all cache files within my namespace and beginning with the predefined $cacheTitle will be removed. Means all language variations and the "-pagination & -comments" caches will be deleted, too. This is the else part. But if I append "&clearAllCaches=true", to the first parameter, it will get all caches within my namespace and clear them. Without the namespace it would clear Processwires caches (like the module cache), too. I'm storing a little success message in a session called "alert" which is closable by the FontAwesome icon via jQuery and expires after some seconds, means it will remove itself, so I don't have to click ;-) Maybe it makes more sense to change the cache title and have the page->id first, so you could select all related caches with $cache->get("hg__{$page->id}*"); I liked them grouped by template in the database, but maybe I change my mind soon because of this For not having to type those params manually I have two buttons in my _out.php template file. I have a little, fixed to the left bottom corner admin menu with buttons for backend, edit (current page), and now clear cache button which unveils the clear all caches button on hover, so it's harder to click it by mistake. When someone writes a comment, I added similar lines as above, after saving the comment, to clear comment caches. Ah, the comment caches look like "-pagination" just with "-comments" appended instead. I don't know if there is an easy way to expire a cache when a new children (especially backend created) is created, other than building a little hook module. With MarkupCache it could be a pain to delete all those folders and files in /assets/ folder, especially with slow connection. The database driven WireCache makes it much faster, and easier when set up those few lines of code to make it for you. more about WireCache http://processwire.com/blog/posts/processwire-core-updates-2.5.28/#wirecache-upgrades https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/WireCache.php Hope it helps someone and is okay for Tutorial section, if you have any questions, suggestions or ideas feel free to share. Hasta luego Can
  18. Right, but I disabled this function because it was to enoying and then I forgot about it. Now that I stumbled again upon this feature and activated it again I thought would be nice to know the reason, so I could finally use it ;-)
  19. 2.6.9 but I had it since the feature was introduced in january 2nd http://processwire.com/blog/posts/quality-assurance-for-images-in-rich-text-fields/ Then I disabled it for a while, and now enabled it again, with the same issue..
  20. Like the title says. After enabling "Markup/HTML with image management" on my CKE textarea field I'm getting weird notifications. And I'm not getting what's wrong. Image referenced on page /blog/big-water-is-watching-you/videos/dirt/ that user does not have view access to (/site/assets/files/36361/bildschirmfoto_2015-04-14_um_23_18_42.400x0-is-pid36356-hidpi.png) Image file on page /de/globetrawter/galerie/13387363293/ no longer exists (13386630735_08db795401_b.jpg) They don't even have a textarea with enabled image management, the page doesn't even hold the mentioned image and I'm pretty sure that I didn't replaced anything on those pages. I'm getting hundreds of them, simple closing wont help. Many thanks in advance, all hints are welcome Saludos, Can
  21. You can use Apeisa's Multisite module http://modules.processwire.com/modules/multisite Thread: https://processwire.com/talk/topic/1025-multisite/ And in the Docs: https://processwire.com/api/modules/multi-site-support/ Saludos Can
  22. You can use language alternate fields in this case. Let's say your primary file field is called "files" (which will serve the default language) then you just create one field per language (files_lang) for example files_de files_fr files_be and so on. As described in the docs https://processwire.com/api/multi-language-support/multi-language-fields/#language-alternate-fields
  23. May I use this thread because Nico asked about translatability for wireRelativeTimeStr Just wanted to "complain" about the translation of this function, but after rechecking the translation file in back end, wondering about "Q P T", checking code again, try to reorder Q P T in german to "T Q P" et voilà it's exactly like it should be in german, at least for my thinking ;-) Never stumbled upon such a way, but I really like it. Ryan you genious!
×
×
  • Create New...