本文整理汇总了PHP中api::subpages方法的典型用法代码示例。如果您正苦于以下问题:PHP api::subpages方法的具体用法?PHP api::subpages怎么用?PHP api::subpages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api
的用法示例。
在下文中一共展示了api::subpages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show($id)
{
$page = $this->page($id);
$blueprint = blueprint::find($page);
$fields = $blueprint->fields($page);
$content = $page->content()->toArray();
$files = null;
$subpages = null;
$preview = null;
// create the preview link
if ($previewSetting = $blueprint->preview()) {
switch ($previewSetting) {
case 'parent':
$preview = $page->parent() ? $page->parent()->url() : $page->url();
break;
case 'first-child':
$preview = $page->children()->first() ? $page->children()->first()->url() : false;
break;
case 'last-child':
$preview = $page->children()->last() ? $page->children()->last()->url() : false;
break;
default:
$preview = $page->url();
break;
}
}
// make sure the title is always there
$content['title'] = $page->title();
// create the form
$form = new Form($fields->toArray(), $content);
// check for untranslatable fields
if (site()->language() != site()->defaultLanguage()) {
foreach ($form->fields() as $field) {
if ($field->translate() == false) {
$field->readonly = true;
$field->disabled = true;
}
}
}
// create the subpages if they exist
if ($blueprint->pages()->max() !== 0 and $blueprint->pages()->hide() == false) {
// fetch all subpages in the right order
$children = api::subpages($page->children(), $blueprint);
// add pagination to the subpages
if ($limit = $blueprint->pages()->limit()) {
$children = $children->paginate($limit, array('page' => get('page')));
}
// create the snippet and fill it with all data
$subpages = new Snippet('pages/sidebar/subpages', array('title' => l('pages.show.subpages.title'), 'page' => $page, 'subpages' => $children, 'addbutton' => !api::maxPages($page, $blueprint->pages()->max()), 'pagination' => $children->pagination()));
}
// create the files
if ($blueprint->files()->max() !== 0 and $blueprint->files()->hide() == false) {
$files = new Snippet('pages/sidebar/files', array('page' => $page, 'files' => api::files($page, $blueprint)));
}
// create the monster sidebar
$sidebar = new Snippet('pages/sidebar', array('page' => $page, 'preview' => $preview, 'deletable' => !$page->hasChildren() and $page->isDeletable() and $blueprint->deletable(), 'subpages' => $subpages, 'files' => $files));
return view('pages/show', array('topbar' => new Snippet('pages/topbar', array('breadcrumb' => new Snippet('pages/breadcrumb', array('page' => $page)), 'search' => purl($page, 'search'))), 'sidebar' => $sidebar, 'form' => $form, 'page' => $page, 'notitle' => !$form->fields()->get('title')));
}
示例2: index
public function index()
{
$site = site();
$widgets = array();
$wroot = kirby()->roots()->widgets();
$wdirs = dir::read($wroot);
// fetch all top-level pages in the right order
$blueprint = blueprint::find($site);
$pages = api::subpages($site->children(), $blueprint);
foreach ($wdirs as $dir) {
$file = $wroot . DS . $dir . DS . $dir . '.php';
if (file_exists($file)) {
$widgets[$dir] = (require $file);
}
}
return view('dashboard/index', array('topbar' => new Snippet('pages/topbar', array('breadcrumb' => new Snippet('breadcrumb'), 'search' => purl('pages/search/'))), 'history' => history::get(), 'site' => $site, 'pages' => $pages, 'addbutton' => !api::maxPages($site, $blueprint->pages()->max()), 'widgets' => $widgets, 'user' => site()->user(), 'license' => panel()->license()));
}
示例3: index
public function index($id = null)
{
$page = $this->page($id);
$blueprint = blueprint::find($page);
$visible = api::subpages($page->children()->visible(), $blueprint);
$invisible = api::subpages($page->children()->invisible(), $blueprint);
$baseUrl = rtrim(purl('subpages/index/' . $page->id()), '/');
// don't create the view if the page is not allowed to have subpages
if ($blueprint->pages()->max() === 0) {
goToErrorView();
}
if ($limit = $blueprint->pages()->limit()) {
$visible = $visible->paginate($limit, array('page' => get('visible')));
$invisible = $invisible->paginate($limit, array('page' => get('invisible')));
$visiblePagination = new Snippet('subpages/pagination', array('pagination' => $visible->pagination(), 'nextUrl' => $baseUrl . '/visible:' . $visible->pagination()->nextPage() . '/invisible:' . $invisible->pagination()->page(), 'prevUrl' => $baseUrl . '/visible:' . $visible->pagination()->prevPage() . '/invisible:' . $invisible->pagination()->page()));
$invisiblePagination = new Snippet('subpages/pagination', array('pagination' => $invisible->pagination(), 'nextUrl' => $baseUrl . '/visible:' . $visible->pagination()->page() . '/invisible:' . $invisible->pagination()->nextPage(), 'prevUrl' => $baseUrl . '/visible:' . $visible->pagination()->page() . '/invisible:' . $invisible->pagination()->prevPage()));
}
return view('subpages/index', array('page' => $page, 'topbar' => new Snippet('pages/topbar', array('menu' => new Snippet('menu'), 'breadcrumb' => new Snippet('pages/breadcrumb', array('page' => $page, 'items' => array(array('url' => purl('subpages/index/' . $id), 'title' => l('subpages'))))), 'search' => purl($page, 'search'))), 'baseurl' => $baseUrl, 'addbutton' => !api::maxPages($page, $blueprint->pages()->max()) and $page->hasChildren(), 'sortable' => $blueprint->pages()->sortable(), 'visible' => $visible, 'flip' => $blueprint->pages()->sort() == 'flip', 'visiblePagination' => $visiblePagination, 'invisible' => $invisible, 'invisiblePagination' => $invisiblePagination));
}
示例4: site
<?php
$site = site();
$blueprint = blueprint::find($site);
$pages = api::subpages($site->children(), $blueprint);
$addbutton = !api::maxPages($site, $blueprint->pages()->max());
$options = array(array('text' => l('dashboard.index.pages.edit'), 'icon' => 'pencil', 'link' => '#/subpages/index/'));
if ($addbutton) {
$options[] = array('text' => l('dashboard.index.pages.add'), 'icon' => 'plus-circle', 'link' => '#/pages/add/', 'key' => '+');
}
return array('title' => array('text' => l('dashboard.index.pages.title'), 'link' => '#/subpages/index/', 'compressed' => true), 'options' => $options, 'html' => function () use($pages) {
return tpl::load(__DIR__ . DS . 'pages.html.php', array('pages' => $pages));
});