Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zeka

  1. Zeka

    Wireframe

    @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?
  2. Hi @horst Thanks for the code. Just one more question, how to update image/width/ratio info in DB for resized image?
  3. 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());
  4. Zeka

    Wireframe

    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.
  5. 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.
  6. 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; });
  7. 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?
  8. $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/
  9. https://processwire.com/api/ref/session/remove/
  10. Hi @picarica Not sure, but could you try to use $children = $root->children("start=0, limit=150"); Does it change anything?
  11. Hi @picarica Have you tried something like $pages->find('template=hry_home, children.count=0'); or $pages->find('template=hry_home')->not('children.count=0'); ?
  12. @kaz Determine what template(s) you want to use pagination with. Go to Admin > Setup > Templates > [Your Template] > URLs, and check the box for: Allow Page Numbers. Save. https://processwire.com/docs/front-end/markup-pager-nav/
  13. Hi @cb2004 https://processwire.com/api/ref/page/#pwapi-methods-manipulation $page->addUrl($url)
  14. Hi @Orkun // For view actions urls and all url for the pages wire()->addHookAfter("Page(template=post)::path, Page(template=post)::localHttpUrl, Page(template=post)::localUrl, Page(template=post)::localPath", function($e) { $page = $e->object; $pages = wire('pages'); $user = wire('user'); $language = $user->language; $langSegment = $pages->get("/")->localPath($language); $pageName = $page->localName($language, true); $e->return = $langSegment . "$pageName/"; }); // this hook is needed to change parent path so we can get right url in link above page name field wire()->addHookBefore("InputfieldPageName::render", function($e) { $inputfield = $e->object; $parentPageID = $inputfield->parentPage->id; $hookId = wire()->addHookAfter("Page(id=$parentPageID)::path", function($e) { $pages = wire('pages'); $user = wire('user'); $language = $user->language; $langSegment = $pages->get("/")->localPath($language); $e->return = $langSegment; }); wire()->addHookAfter("InputfieldPageName::render", function($e) use($hookId){ $e->removeHook($hookId); }); });
  15. Zeka

    Wireframe

    @teppo Thanks for the update. I'm migrating a live site to the Wireframe and I need to set altFilename to wireframe for specific templates on the runtime via hook or somehow else only for superuser role. Is there is a way to do that?
  16. Zeka

    Wireframe

    @teppo Hi and thanks for the great tool! Have a small issue with $persistent_cache_name in the current implementation it's not language-aware. Maybe it worth changing it to something like $persistent_cache_name = 'Wireframe/MethodProp' . '/' . $context . '/' . static::class . '/' . $name . '/' . $this->wire('page'); if($this->wire()->modules->isInstalled("LanguageSupport")) { $current_language = $this->wire()->user->language; $default_language = $this->wire()->languages->getDefault(); if ($current_language !== $default_language) { $persistent_cache_name .= . '/' . $current_language->id; } } or even move out to a separate hookable method, so we can tune names if needed.
  17. Hi. I have an issue with $page->url('+') and $page->url('-') where produce wrong URLs like site.com/some-page/-/page1/ and not site.com/some-page/page1/ etc. I have tested it on the latest dev version. I tracked down it to this line https://github.com/processwire/processwire/blob/d8945198f4a6a60dab23bd0462e8a6285369dcb9/wire/core/PageTraversal.php#L616 I think that there should be addition check like 'urlSegmentStr' => is_string($options) && !in_array($options, array('+', '-')) ? $options : '', Before opening an issue I would like to ask to confirm it. Thansk.
  18. Greate theme! Looks very Kirby inspired.
  19. @Falk $string = '<figure class="align_right"><img alt="some random alt text" src="path/to/image-file" /> <figcaption>some random caption text</figcaption> </figure> <p>some random text</p>'; $purifier = $sanitizer->purifier(); $purifier->set('HTML.ForbiddenElements', array('figure')); $purifier->set('Core.HiddenElements', array('figure' => true)); $clean = $purifier->purify($string); $text = $sanitizer->truncate($clean, [ 'type' => 'sentence', 'maxLength' => 400, 'visible' => true ]); $content = "<p>"; $content .= $text; $content .= "</p>"; d($content);
  20. @ryan Thanks for update! For some time I see a lot of such changes in the commits: //before $config = $this->wire('config'); $log = $this->wire('log'); //after $config = $this->wire()->config; $log = $this->wire()->log; Is there is some technical background for such changes or it's just a matter of preference? (I remember that you have explained it in some other thread or blog post, but I could not find it).
  21. if($this->showForBackend) { $this->addHookBefore('ProcessPageList::execute', function ($event) { wire('config')->styles->add($this->config->urls->PageHitCounter . 'PageHitCounter.min.css'); if($this->wire('input')->get('mode') != 'select') { $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListHitCounter'); } }); }
  22. I have removed all logs and it bar started to load, then I have refreshed modules and again it stopped to load. http://360px.com.ua/monosnap/chrome_nrIfSIDBVh.png That`s all that I have in the logs. Changing mentioned line to any of this version fixes issue $entriesArr[$itemKey]['url'] = json_encode('<a href="' .$entry['url']. '">'.$entry['url'].'</a>'); // or $entriesArr[$itemKey]['url'] = '<a href="\\' .$entry['url']. '">'.$entry['url'].'</a>'; // or $entriesArr[$itemKey]['url'] = "<a href='".$entry['url']."'>".$entry['url']."</a>";
  23. @adrian I have tracked it down that if I remove ProcessWire Logs panel from the list of loading panels TB bar loads.
×
×
  • Create New...