Tom. Posted October 4, 2018 Share Posted October 4, 2018 Hey, I'm having an issue where you see different output based on whether you are logged in or not: <div class="px-1"> <div class="flex flex-wrap -ml-1 -mt-1" uk-scrollspy="target: > div; cls: fade-up; delay: 100;"> <?php foreach($value as $item): $item->block = $blocks[$item->size->value]; ?> <?php if($item->size->value != 'half' || $item->prev()->size->value != 'half'): ?> <div class="pl-1 mt-1 <?=$item->block['class']?>"> <?php if($item->size->value == 'half'): ?> <div class="flex flex-wrap -ml-1 -mt-1"> <?php endif; ?> <?php endif; ?> <?php if($item->size->value == 'half'): ?> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <?php endif; ?> <?=$item->render()?> <?php if($item->size->value == 'half'): ?> </div> <?php endif; ?> <?php if($item->size->value != 'half' || $item->next()->size->value != 'half'): ?> <?php if($item->size->value == 'half'): ?> </div> <?php endif; ?> </div> <?php endif; ?> <?php endforeach; ?> </div> </div> This works great when you are logged in! It keeps the 'half' sized blocked grouped together when they are next to each other. See output: <div class="pl-1 mt-1 w-full lg:w-1/3 uk-scrollspy-inview fade-up" style=""> <div class="flex flex-wrap -ml-1 -mt-1"> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <a href="[hidden]" class="block-half block no-underline relative bg-grey bg-cover overflow-hidden"> <div class="group absolute pin p-3 md:p-6" style="background-color: rgba(0, 0, 0, 0.15)"> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-white uk-scrollspy-inview fade-up" style="">About us </h2> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-black uk-scrollspy-inview fade-up" style="">Our practice</h2> <span class="absolute pin-b pin-l ml-3 md:ml-6 mb-3 md:mb-6 xl:text-xl flex items-center opacity-0 group-hover:opacity-100 transition text-white">View About us</span> </div> </a> </div> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <a href="[hidden]" class="block-half block no-underline relative bg-grey bg-cover overflow-hidden"> <div class="group absolute pin p-3 md:p-6"> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-yellow uk-scrollspy-inview fade-up" style="">Feed </h2> <span class="absolute pin-b pin-l ml-3 md:ml-6 mb-3 md:mb-6 xl:text-xl flex items-center opacity-0 group-hover:opacity-100 transition text-yellow">View Feed</span> </div> </a> </div> </div> </div> Perfect! However, when you are logged in it displays like this: <div class="pl-1 mt-1 w-full lg:w-1/3 uk-scrollspy-inview fade-up" style=""> <div class="flex flex-wrap -ml-1 -mt-1"> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <a href="[hidden]" class="block-half block no-underline relative bg-grey bg-cover overflow-hidden"> <div class="group absolute pin p-3 md:p-6" style="background-color: rgba(0, 0, 0, 0.15)"> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-white uk-scrollspy-inview fade-up" style="">About us </h2> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-black uk-scrollspy-inview fade-up" style="">Our practice</h2> <span class="absolute pin-b pin-l ml-3 md:ml-6 mb-3 md:mb-6 xl:text-xl flex items-center opacity-0 group-hover:opacity-100 transition text-white">View About us</span> </div> </a> </div> </div> </div> <div class="pl-1 mt-1 w-full lg:w-1/3 uk-scrollspy-inview fade-up" style=""> <div class="flex flex-wrap -ml-1 -mt-1"> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <a href="[hidden]" class="block-half block no-underline relative bg-grey bg-cover overflow-hidden"> <div class="group absolute pin p-3 md:p-6"> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-yellow uk-scrollspy-inview fade-up" style="">Feed </h2> <span class="absolute pin-b pin-l ml-3 md:ml-6 mb-3 md:mb-6 xl:text-xl flex items-center opacity-0 group-hover:opacity-100 transition text-yellow">View Feed</span> </div> </a> </div> </div> </div> Which breaks the layout completely. I have ProCache & ProDrafts installed but both are turned off. I've tried Incognito mode both logged in and out to see if it's a caching issue, however it seems completely down to be logged in or not? Strange one. Anyone know what's going off here? I'm going to try `->next("include=all")` as that's the only thing I can think off at this point. If it works then it must be a bug. EDIT: ->next("include=all") fixes it. This is a bug as all repeater items are published. Link to comment Share on other sites More sharing options...
Robin S Posted October 4, 2018 Share Posted October 4, 2018 I believe this is because $page->next() is for traversing pages as they appear in the page tree. So when you use it on a repeater page it will refer to the next sibling page in the page tree, in the Repeaters section under the Admin branch. Those pages use a system repeater template that is accessed controlled. Non-superusers don't have access to those pages themselves, they only have access to repeater items via a repeater field value (a RepeaterPageArray). Whether this is a good thing or not has been under debate here: https://github.com/processwire/processwire-issues/issues/183 A better option might be to use WireArray::getNext() on the repeater field value, which will hopefully avoid the access issues for non-superusers. // $value is repeater field value if($value->getNext($item) && $value->getNext($item)->size->value != 'half') 4 Link to comment Share on other sites More sharing options...
Tom. Posted October 5, 2018 Author Share Posted October 5, 2018 @Robin S Thanks for your response - this has now been fixed: https://github.com/processwire/processwire-issues/issues/716#issuecomment-427372423 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now