$page->hide() reversed function?

Hey,

http://getkirby.com/docs/cheatsheet/page/hide

I have seen there’s a function the hide a page with this function.

However I couldn’t find a function which does the exact opposite. Is there one or would I need to use

http://getkirby.com/docs/cheatsheet/page/update

don’t see how to update being visible though. Another thing is how the order is going on :open_mouth: if there was a function like that.

Cheers.

How about a mixture between

 $pages->last()->num() 

to get the last page sorting number, then +1 it, and use the php

rename()

function to change the invisible folder adding the new sorting number in front of it.

Would that work to make the folder visible other than using the panel?

Cheers.

I tried the nightly 2.0.7 and there’s been an update to the panel:

Toggle status :smile:
Is that it?

The publish function from the panel:

 public function publish($id) {
    if($page = $this->page($id)) {
      $parent = $page->parent();
    } else {
      return response::error(l('pages.error.missing'));
    }
    if($page->isErrorPage()) {
      return response::error('The error page cannot be published');
    }
    $subpages = new Subpages($parent);
    $num      = $subpages->sort($page, 'last');
    return response::success('The page has been sorted', array(
      'num' => $num
    ));
  }

This could work for your purpose as well.

Maybe also something like

$page->sort($page->siblings()->visible()->last()->num() + 1)

as a ->show() alternative.

just for anyone who is asking the same, i’ve seen in the cheatsheets there’s indeed a function to make pages visible.

http://getkirby.com/docs/cheatsheet/page/sort

@carstengrimm as in my last comment :wink: the question remains how to define the sort number, not technically but for your or someone’s use case

oh yeah, haven’t realized your code includes sort command :wink:

well anyways I’ll try if i get anything done …

I’ve successfully did it a shot. However with @distantnative 's suggestion I’ve been getting some php error and it has not cought the last number. For my own needs I’ve used what he gave as a suggestion and turned it to:

$sort = $pages->find('somesubpage')->children()->visible()->count();
                    $sort = $sort +1;

               page('somesubpage')->find('searchparameter')->sort($sort);

Resulting in making the page visible as the last entry.

Best regards.

2 Likes