Jump to content

Zeka

Members
  • Posts

    967
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Zeka

  1. Hi @manlio Have you seen this module? https://github.com/teppokoivula/ProcessLoginHistory Also you can use Google Analytics for tracking logged in users https://phppot.com/php/track-individual-logged-in-users-using-google-analytics/
  2. Hi @rastographics "task_status" is select options field? Have you try to 'task.task_status.title=finished' ?
  3. Hi @Crowdland Technology There has been a lot of changes in 3.0.185 that relative to ML support and other part of request handling so it's better to stay for some time on the stable 3.0.184. There is already an opened issue https://github.com/processwire/processwire-issues/issues/1447 So you can describe your case there
  4. Hi @prestoav Just find your selected page in the page tree and there will be 'Unselect' option. See screenshot at the thread
  5. Hi @PascalKonings You can use page refference field by implementing custom fields for you image field https://processwire.com/blog/posts/pw-3.0.142/
  6. // requeire https://processwire.com/modules/file-validator-svg-sanitizer/ and $svgSanitizer = $this->wire()->modules->get('FileValidatorSvgSanitizer')->getSvgSanitizer(); $svgSanitizer->minify(true); $svgSanitizer->removeXMLTag(true); $data->setArray([ 'inline_svg' => $svgSanitizer->sanitize($this->wire()->files->fileGetContents($category->get('svg')->filename)), ]);
  7. Hi @ryan Thank you for the updates and new module. I have used $session a lot in custom modules in the admin area, but not so much on the frontend (except areas where logged-in users could interact with site and basic $session redirects); I just checked the 'assets/sessions' folder which contains 115711 files (462.92 Mb) on one of the sites that have 50k visitors per day and I think that I would benefit if I disallow session for the guest visitors on the fronted, but I'm not sure about what I should consider in this case. Will $session->redirect etc work?
  8. Hi @horst. RewriteCond %{HTTP_HOST} ^(www\.)?example-b\.com$ [NC] RewriteRule ^(.*)$ http://www.example-a.com/subpage5/$1 [L,R=301] Maybe it's cache issue? 301 redirects are cached hard by the browser. For testing it's better to set 302 or test with browser tools open and cache disabled.
  9. Hi @sebr As for the first point. You can copy LanguageTabs module to the site/modules folder and adopt for you needs. As for the second point. There is no ready to use solutions but it doable by hooks. I've been working on the two module. One that allows to disable default language and the second one that add reuquirement for non default langauges of multilangauge fields and check if they are filled. They are site specific but you can use them as starting point and try to addot for your needs.
  10. Hi. You can try to use $page->if() https://processwire.com/api/ref/page/if/ if($page->if('image')) { // ... } $page->if('image', function($image) { // ... })
  11. Hi. I've never used this feature by from this thread I can assume that it meens that user has page-view permission for the corresponding template.
  12. @fbg13 The link is dead, where I can download your module? @eelkenet maybe you have an copy?
  13. Hi. https://github.com/processwire/processwire/blob/master/wire/core/Templates.php#L303 So it looks like cloning of the template doesn't clone fields context for template fieldgroup. You can do it by api like $sourceFieldgroup = $fieldgroups->get('service'); $newFieldgroup = $fieldgroups->get('test'); foreach ($sourceFieldgroup as $field) { if($sourceFieldgroup->hasFieldContext($field) && $newFieldgroup->hasField($field)) { $contextArray = $sourceFieldgroup->getFieldContextArray($field->id); $newFieldgroup->setFieldContextArray($field->id, $contextArray); } } $newFieldgroup->saveContext(); Probably there is better way but it worked for my case.
  14. Hi @millipedia. Nice write-up. How did you get forcing of PDF downloading? Recently I was working on the project where they had a large amount of science articles in PDFs and they wanted to force downloading of these files with settings custom file names (user provided). There is the code that I use, but for some reason some of PDFs files still open 'inline' in Chrome. $wire->addHook('/download/{pageid}/{basename}/', function ($event) { $page = $this->wire()->pages->get($event->pageid); if ($page->id) { $file = $page->filesManager->getFile($event->basename); $filename = $file->description ? $file->description . '.' . $file->ext : $file->basename; wireSendFile($file->filename, [ 'downloadFilename' => $filename, 'forceDownload' => true, 'exit' => true, ]); } else { wire404(); } });
  15. There some usefull examples if you are in ML setup
  16. @teppo Thanks for info. Will investigate proposed options. Could you please give an advice on how is it better to orgonize a large number of components. Curretly I add to boot.php wire('classLoader')->addNamespace('Wireframe\Blocks', paths('templates') . 'LayoutComponents/'); wire('classLoader')->addNamespace('Wireframe\Blocks', paths('templates') . 'BuilderComponents/'); In this way I put all components that are used in layout to LayoutComponents folder, all blocks for content builder to 'BuilderComponents' folder and component folder is used for components that are not part of the above groups. Maybe there is build in options for such task?
  17. Hi @horst Thanks for the code. Just one more question, how to update image/width/ratio info in DB for resized image?
  18. Hi @snobjorn $currentLanguage = $this->wire()->user->language; $languages = $this->wire()->languages; $selector = new Selectors("template=some-template"); if($currentLanguage->id === $languages->getDefault()->id) { $selector->add(new Selectors("status=1")); } elseif ($languages->findNonDefault()->has($currentLanguage)) { $selector->add(new Selectors("status{$currentLanguage->id}=1")); } bd($this->wire()->pages->find($selector)->count());
  19. Hi @teppo I need a small hint. I'm using components as building blocks of a layout like: // wireframe.php $this->wire()->set('siteJS', new FilenameArray()); $this->wire()->set('siteCSS', new FilenameArray()); $wireframe = $this->wire()->modules->get('Wireframe'); $wireframe->init(); echo $wireframe->render(); // layouts/default.php <?php namespace ProcessWire; ?> <!DOCTYPE html> <html lang="ru" class="<?= setting('html-classes')->implode(' '); ?>"> <head> <?= Wireframe::component("Head"); ?> </head> <body> <div class="layout"> <div class="layout__topbar"> <div class="layout__container"> <?= Wireframe::component("Topbar"); ?> </div> </div> <div class="layout__header"> <?= Wireframe::component("Header"); ?> </div> <div class="layout__masthead"> <?= Wireframe::component("Masthead"); ?> </div> <main class="layout__content"> <?= $placeholders->default; ?> </main> <footer class="layout__footer"> <?= Wireframe::component("Footer"); ?> </footer> </div> </body> </html> For the content part of a page, I'm using RepeaterMatrix and every type of repeater matrix is also a component prepared in the controller of a page. 'global' (Header, Footer etc.) and 'Matrix' (that are used for rendering matrix items) components could add its own CSS and JS assets like // components/Footer.php <?php namespace Wireframe\Component; class Footer extends \Wireframe\Component { public function __construct() { $this->wire()->siteCSS->add('footer); } // ... } Current program flow looks like Init method of a page controller file wireframe.php Render method of a page controller file layouts/default.php components/Head.php construct method components/Head.php render method construct and render method of other components components/Footer.php construct method components/Footer.php render method The issue starts here. Head component should render links to CSS and JS assets, but as it goes before any other component and the construct method of components that goes below are not called, so its assets is not yet populated. Hope you get what the issue is and can give a hit. ------------------- Before Wireframe, I used a custom front-end module that was doing the same thing that Wireframe does but differently. I had a controller also for layouts and in this way, all partials were already rendered, data needed for layout rendering was prepared before the layout was rendered. Say 'Copmonents' concept was exposed to the layouts. Is it possible somehow in the Wireframe? Thanks.
  20. Hi @snobjorn Probably you can use status in your count selector like $pages->find('template=post, status1023=1')->count() Where the 1023 is ID of your non-default langauge.
  21. Hi. Not tested but should work $this->wire()->addHookAfter('LanguagesPageFieldValue::getStringValue', function ($event) { $value = $event->return; $languagesPageFieldValue = $event->object; $languages = $this->wire()->languages; $userLanguageID = $this->wire()->user->language->id; $chineseLanguageID = $languages->get('chinese')->id; $newFallbackLanguageID = $languages->get('english')->id; if($userLanguageID === $chineseLanguageID && !$languagesPageFieldValue->getLanguageValue($chineseLanguageID)) { $value = $languagesPageFieldValue->getLanguageValue($newFallbackLanguageID); if(!strlen($value)) { $value = $languagesPageFieldValue->getDefaultValue(); } }; $event->return = $value; });
  22. Hi. I have over 3k pages with an image field that populated with quite large images. What I need to do is to replace the original image in this field with a resized version of original image. What would be optimal way to do that?
  23. $wire->addHookAfter('InputfieldPage::getSelectablePages', function (HookEvent $event) { if ($event->object->hasField->name === 'category') { // Server path to the PW installation $path = '/home/modules/www/'; // The root URL for the PW installation $url = 'http://modules.processwire.com/'; // Create a new ProcessWire instance $site = new ProcessWire($path, $url); // Find some pages $items = $site->pages->find("template=categories, limit=5, sort=-created"); $event->return = $items; } }); https://processwire.com/api/ref/inputfield-page/get-selectable-pages/ https://processwire.com/blog/posts/multi-instance-pw3/
  24. https://processwire.com/api/ref/session/remove/
×
×
  • Create New...