Skip to content

Commit

Permalink
Some code snippets and base templates as examples for bootstrapping n…
Browse files Browse the repository at this point in the history
…ew site.
  • Loading branch information
velosipedist committed Apr 14, 2015
1 parent 3c60776 commit 084a8dd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
7 changes: 7 additions & 0 deletions snippets/init.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?
// bitrix/php_interface/init.php
require_once '/downloaded/beatrix.phar';
Beatrix::init(array(
Beatrix::SETTINGS_TEMPLATES_DIR => $_SERVER['DOCUMENT_ROOT'].'/.tpl' // where to look for templates
));
//Beatrix::view()->addFolder('email', '<somewhere else folder>');
3 changes: 3 additions & 0 deletions snippets/template/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?
// Just
Beatrix::templateFooter();
24 changes: 24 additions & 0 deletions snippets/template/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?
// capture anything printed on site before template rendering
Beatrix::templateHeader();

// if you want to automate sections depending on addresses
Beatrix::layout()->sectionsDefaults([
// empty default sections
'/' => [
'sidebar.left.top' => '',
'sidebar.left.middle' => '',
'sidebar.left.bottom' => '',
'sidebar.right.top' => '',
'sidebar.right.middle' => '',
'sidebar.right.bottom' => '',
],
// any sub-page has left menu
'/.+' => [
'sidebar.left.top' => ['layout/snippets/sidebar-menu-left'],
],
// but not in search page
'/search/?.+' => [
'sidebar.left.top' => '',
]
]);
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* @var $showStartEndArrows
* @var $showArrowsWhenInactive
* @var $size null | 'sm' | 'lg'
* @var CAllDBResult $result
*
* auto-computed vars
* @var bool $isPrevArrowActive
Expand Down Expand Up @@ -41,11 +40,11 @@
$startUrl = str_replace('__PAGENUMBER__', 1, $urlStartTemplate);
$prevUrl = str_replace(
'__PAGENUMBER__',
$result->NavPageNomer - 1,
($result->NavPageNomer == 2 ? $urlStartTemplate : $urlTemplate)
$pageNumber - 1,
($pageNumber == 2 ? $urlStartTemplate : $urlTemplate)
);
$nextUrl = str_replace('__PAGENUMBER__', $result->NavPageNomer + 1, $urlTemplate);
$endUrl = str_replace('__PAGENUMBER__', $result->NavPageCount, $urlTemplate);
$nextUrl = str_replace('__PAGENUMBER__', $pageNumber + 1, $urlTemplate);
$endUrl = str_replace('__PAGENUMBER__', $pageCount, $urlTemplate);
?>
<ul class="pagination <?=($size ? "pagination-$size" : '')?>">
<?if($showArrows):?>
Expand All @@ -68,8 +67,8 @@
<?endif?>
<!-- numbers-->
<?
foreach (range(1, $result->NavPageCount) as $pageNum) {
$isActive = $pageNum == $result->NavPageNomer;
foreach (range(1, $pageCount) as $pageNum) {
$isActive = $pageNum == $pageNumber;
$url = str_replace('__PAGENUMBER__', $pageNum, ($pageNum == 1 ? $urlStartTemplate : $urlTemplate));
?>
<li <?=$isActive ? 'class="active"' : ''?>><a href="<?=$url?>"><?=$pageNum?></a></li>
Expand Down
1 change: 1 addition & 0 deletions templates/layout/empty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?=$this->section('content');

0 comments on commit 084a8dd

Please sign in to comment.