Created
June 4, 2013 12:30
-
-
Save jmartsch/5705552 to your computer and use it in GitHub Desktop.
Common used code snippets for Processwire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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