• Content Count

  • Joined

  • Last visited

  • Days Won


Zeka last won the day on November 4

Zeka had the most liked content!

Community Reputation

642 Excellent

About Zeka

  • Rank
    Hero Member
  • Birthday 04/12/1989

Profile Information

  • Gender
  • Location
    Kiev, Ukraine

Recent Profile Visitors

2,250 profile views
  1. Zeka

    @kongondo As for me it should be changed to setArray as in current implementation WireArray() looks like an alias (in most scenarios) for WireArray->import and not new WireArray().
  2. Zeka

    No, it behaves in that way when different 'keys' have the same values. One more example $array = WireArray([ 'test' => 'test1', 'test1' => 'test1', 'test2' => 'test2' ]); d($array); count => 2 items => array (2) - test => "test1" (5) - test2 => "test2" (5) Actually, I think that it's a bug in WireArray() function as if use new WireArray() it works as expected $test = [ 'test' => 'test1', 'test1' => 'test1', 'test2' => 'test2' ]; $array = new WireArray(); $array->setArray($test); d($array); count => 3 items => array (3) - test => "test1" (5) - test1 => "test1" (5) - test2 => "test2" (5) Here is code for WireArray(); public static function newInstance($items = null, $class = '') { if(empty($class)) $class = get_called_class(); /** @var WireArray $a */ $a = new $class(); if($items instanceof WireArray) { $items->wire($a); $a->import($items); } else if(is_array($items)) { $a->import($items); } else if($items !== null) { $a->add($items); } return $a; } So the issue is in the usage of import method as it skips any items already present in WireArray.
  3. $insert = new Event(5555); if($s->count() > 5) { $s->insertAfter($insert, $s->eq(5); }
  4. Also it worth to take a look at this thread
  5. @Leftfield There is answer from Ryan
  6. @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.
  7. Zeka

    @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/
  8. @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
  9. 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
  10. @Michkael No, just go to the settings of your repeater field and you will find this setting on the "Details" tab.
  11. @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.
  12. @stizzle You can try to use 'pw -panel-closed' event.
  13. Zeka

    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.
  14. @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/