Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zeka

  1. @Leftfield Welcome to the community. The easiest and most performant way is just to make page tree reflects your desirable URL structure. But often such structure looks messy. You can change it by using URL segments and rewriting page paths for your category and post templates. For example, for blogs, I use such a structure home/blog/ /authors /categories /cat1 /cat2 /posts /post1 /post2 I got such URLs site.com/blog/category/cat1 site.com/blog/posts/post1 etc. But I want to have such URLs and I want that every post can be listed in several categories, but for preventing contend duplication I want that it has only one accessible URL site.com/cat1/ site.com/cat1/post1/ site.com/cat2/post2/ To make it work you have to: 1. Enable URLs segments for your home page. 2. Create to Page Reference fields and add it to your post template blog_section - Page reference field ( Page field value type set to Single page, selector 'template=blog_category') - this one we will use for building URL for the current post. blog_categories - Page reference field ( Page field value type set to Multiple pages, selector 'template=blog_category') 2. In your ready.php $pages->addHookAfter('Page(template=blog-category)::path', function ($e) { $page = $e->object; $e->replace = true; $e->return = "/" . $page->name . "/"; }); $pages->addHookAfter('Page(template=post)::path', function ($e) { $page = $e->object; if ($page->blog_section) { $slug = $page->blog_section->name; } else { $slug = $page->parent('template=blog')->name; //fallback } $e->replace = true; $e->return = "/" . $slug . "/" . $page->name . "/"; }); 3. In your home.php if ($input->urlSegment3) throw new Wire404Exception(); if ($input->urlSegment2) { $post_name = $input->urlSegment2; $match = $pages->get($sanitizer->selectorValue($post_name)); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); } if ($input->urlSegment1) { $category_name = $input->urlSegment1; $match = $pages->get($sanitizer->selectorValue($category_name)); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); } It's not tested and there can be some errors, but I hope you get a general idea.
  2. @kimkuekas There is also WireCache and Page Cache that you can turn off in templates settings. You can try to you CleanCacheAdmin module https://processwire.com/talk/topic/13042-clearcacheadmin/
  3. @Robin S Thanks for the clarification about 'slices' method. I was on mobile, so couldn't test it till now, but the description from the blog post made me think that it would work as array_chunk. @Michkael sorry for confusing. Obviously, slices method is not the best solution in your case. One more example of implementing a chunk
  4. You can use new slices method for that. Take a look at these part of previous week's blog post http://processwire.com/blog/posts/processwire-3.0.119-and-new-site-updates/#new-wirearray-slices-method
  5. @Michkael No, just go to the settings of your repeater field and you will find this setting on the "Details" tab.
  6. @Michkael For now, you can turn off 'Repeater dynamic loading (AJAX) in editor' setting in repeater field settings. Also, it worth to test in clean chrome or firefox without extensions.
  7. On "Advanced" tab of a template settings page, you can enable setting ' Allow the 'created user' to be changed on pages?' Than you will be able to change 'create user' on settings tab on page edit page.
  8. @Roych Repeater items are also pages, but they are hidden under admin page, so they don't have URLs, but you can use URL segments for that. You should allow URL segments on you 'about' page template. Then you can construct URL based on team repeater item id or other fields inside repeater: <?php $summary = truncateText($team->body); echo "$summary ...";?> <a href="<?php echo $page->url($team->id); ?>">Read more</a> Then on you about page template: if ($input->urlSegment1) { $pagename = $input->urlSegment1; $match = $pages->get($sanitizer->int($pagename)); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); } ---------- By the way you can use $sanitizer->truncate() to truncate your summery text https://processwire.com/blog/posts/processwire-3.0.101-core-updates/
  9. @dragan Yes, didn't help. Still @bernhard I have opened an issue https://github.com/processwire/processwire-issues/issues/743 @BitPoet Thanks, yes I see, there is no way to prevent conversion to int if(is_int($value) || ctype_digit($value)) { $value = (int) $value; if($_sanitize == 'selectorValue') $_sanitize = ''; // no need to sanitize integer to string } Also, if you consider this as a bug, please, leave a comment on GitHub.
  10. @icietla Maybe you have set Page::statusSystem for some pages, in this case removing the status flag in the 'Settings' tab should make it work. What PW version do you use? There have been some updates to ProcessTrash class in 3.0.116, so probably it worth to update to dev branch.
  11. @a-ok Is there some reason why you are not on the master version which is 3.0.98? What you can do for testing purpose is to update your installation if it won't help try fresh installation, so we can determine is it somehow relative to your environment or installation. Any image-related third party modules installed?
  12. @a-ok Would be great to hear more info like PW, PHP and MySQL version, do you use admin interface or API for importing? Also, take a look at these links: https://github.com/processwire/processwire-issues/issues/132
  13. Yeap http://php.net/manual/en/types.comparisons.php Second line in 'Comparisons of $x with PHP functions' table. Also, I have found the usage of namespaces very сonveniently, as you can delete and preload several caches at once by $cache->deleteFor("my-namespace"); and $cache->preloadFor("my-namespace"); On one project I have used addition config variable 'disableWireCache' defined in config.php, so my statement looks like if (!$filters || config('disableWireCache')). It allows to 'disable' WireCache globaly for testing etc.
  14. @ripper2600 For sure you can use WireCache to cache number of matches. $cache->preloadFor('matches'); $today_matches = $cache->getFor('matches', 'today'); if(!$today_matches) { $latest_matches = $api->getLatestMatches('today'); $cache->saveFor('matches', 'today', $today_matches, 3600) } $yesterday_matches = $cache->getFor('matches', 'yesterday'); if(!$yesterday_matches) { $latest_matches = $api->getLatestMatches('yesterday'); $cache->saveFor('matches', 'yesterday', $yesterday_matches, 3600) } // setting setting([ 'matches' => WireArray([ 'today' => $today_matches, 'yesterday' => $yesterday_matches ]) ]);
  15. $page->setOutputFormatting(false); foreach($imagegallery as $filename) { $page->imagegallery->add($upload_path . $filename); $page->save(); } Though I'm not sure that it's obligatory to call $page->save() in the loop.
  16. Hi @suntrop pages('template=board, children.children.created>="-24 hours"'); It works for me.
  17. @BrendonKoz As you develop custom fieldtype you can add custom js file for the page inside iframe via a hook to page render method. $this->wire()->addHookBefore('Page::render', function ($e) { $page = $e->object; if ($this->input->get('modal') === 'panel') { $this->wire('config')->scripts->add($this->config->urls->YourFieldType . 'your-js-file.js'); } }); Then in 'your-js-file.js' you can directly find doms elements on the loaded page. Additionally, in hook, you can check whether the template of the current page (the one in the panel) has a field with your Fieldtype and then load you js.
  18. @BrendonKoz Try this: jQuery(document).on('pw-panel-opened', function (eventData, panelNode) { var $iframe = $(panelNode).find('iframe'); $iframe.on('load', function(e) { $panel = $(this).contents(); $panel.find('#Inputfield_title').focus(); }); });
  19. Probably you can make hook before session init, than get user id or role and change config->sessionExpireSeconds
  20. Hi @BrendonKoz Are you developing a custom module? $(document).on("pw-panel-opened", function(e) { console.log('opened'). }); This works for me. Where do you place your code? As for columns, it works for me, but only when screen larger than 1745 px. In this case, the width of the panel gets larger than 960px @media (min-width: 960px) .uk-width-1-5\@m { width: 20%; } Default width of pw-panel is 50%, but you can use ' data-panel-width='60%' or ' $button->attr('data-panel-width', '100%');' to tune the width, so you will get columns on smaller screens.
  21. https://github.com/Microsoft/vscode/issues/56467 https://github.com/textmate/html.tmbundle/issues/92
×
×
  • Create New...