Skip to content

Commit

Permalink
fixed composer json, updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Stebe committed Mar 31, 2015
1 parent d36e89e commit b94464c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
53 changes: 51 additions & 2 deletions README.md
Expand Up @@ -33,7 +33,54 @@ fig run web ./yii migrate \
Usage
-----

**find a root node / leave node**
#### site/index action in controllers/SiteController

```
/**
* Site/index for use with dmstr/yii2-pages-module
* @return string
* @throws HttpException
*/
use dmstr\modules\pages\models\Tree;
public function actionIndex()
{
Url::remember();
$this->layout = '@app/views/layouts/main';
$localizedRoot = 'root_' . \Yii::$app->language;
$page = Tree::findOne(
[
Tree::ATTR_NAME_ID => $localizedRoot,
Tree::ATTR_ACTIVE => Tree::ACTIVE,
Tree::ATTR_VISIBLE => Tree::VISIBLE
]
);
if ($page !== null) {
// Set page title
$this->view->title = $page->page_title;
// Register default SEO meta tags
$this->view->registerMetaTag(['name' => 'keywords', 'content' => $page->default_meta_keywords]);
$this->view->registerMetaTag(['name' => 'description', 'content' => $page->default_meta_description]);
// Render view
return $this->render($page->view, ['page' => $page]);
} else {
\Yii::info(\Yii::t('app', 'Pages: Root node anlegen.'), 'pages');
\Yii::warning(\Yii::t('app', 'Page not found.') . ' [NameID: ' . $localizedRoot . ']', 'pages');
$this->redirect(['/pages']);
}
}
```



#### layouts/main render Navbar

*find a root node / leave node*

by `name_id`

Expand All @@ -42,7 +89,7 @@ $localizedRoot = 'root_' . \Yii::$app->language;
$menuItems = \dmstr\modules\pages\models\Tree::getMenuItems($localizedRoot);
```

**use for example with bootstrap Navbar**
*use for example with bootstrap Navbar*

```
$localizedRoot = 'root_' . \Yii::$app->language;
Expand All @@ -56,3 +103,5 @@ $localizedRoot = 'root_' . \Yii::$app->language;
]
);
```


2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -16,7 +16,7 @@
],
"require": {
"yiisoft/yii2": "2.0.*",
"kartik-v/yii2-tree-manager": "@dev",
"kartik-v/yii2-tree-manager": "*",
"kartik-v/yii2-widget-select2": "*",
"rmrevin/yii2-fontawesome": "2.8.*",
"devgroup/yii2-jsoneditor": "1.0.*"
Expand Down

0 comments on commit b94464c

Please sign in to comment.