Skip to content

Instantly share code, notes, and snippets.

@jmartsch
Created June 4, 2013 12:30
Show Gist options
  • Save jmartsch/5705552 to your computer and use it in GitHub Desktop.
Save jmartsch/5705552 to your computer and use it in GitHub Desktop.
Common used code snippets for Processwire
// First child redirect
<?php if($page->numChildren) $session->redirect($page->child()->url);
// Redirect to specific page
$session->redirect($pages->get('/')->url);
// Create a menu, needs MarkupSimpleNavigation Plugin
<?php
$treeMenu = $modules->get("MarkupSimpleNavigation"); // load the module
$rootPage = $pages->get("/ueber-uns/"); // if you want to overwrite start level for the menu, for example for breadcrumbs
$options = array(
'parent_class' => 'active parent',
'current_class' => 'active',
'has_children_class' => 'has_children',
'levels' => false,
'levels_prefix' => 'level-',
'max_levels' => 1,
'firstlast' => false,
'collapsed' => false,
'show_root' => false,
'selector' => '',
'outer_tpl' => '<ul class="nav nav-pills pull-right">||</ul>',
'inner_tpl' => '<ul>||</ul>',
'list_tpl' => '<li%s>||</li>',
'list_field_class' => 'asass',
'item_tpl' => '<a href="{url}">{title}</a>',
'item_current_tpl' => '<a href="{url}">{title}</a>',
'xtemplates' => '',
'xitem_tpl' => '<span>{title}</span>',
'xitem_current_tpl' => '<span>{title}</span>'
);
echo $breadcrumbs->render($options,null,$rootPage);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment