Skip to content

Commit

Permalink
added request_param support
Browse files Browse the repository at this point in the history
  • Loading branch information
schmunk42 committed Mar 15, 2016
1 parent a5a4758 commit 7b796cf
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
21 changes: 13 additions & 8 deletions models/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use yii\db\Expression;
use yii\helpers\ArrayHelper;
use yii\helpers\Inflector;
use yii\helpers\Json;
use yii\helpers\Url;

/**
Expand Down Expand Up @@ -240,15 +241,19 @@ public static function optsRoute()
*/
public function createUrl($additionalParams = [])
{
return Url::toRoute(
[
'/'.$this->route,
$route = [
'/'.$this->route,

'id' => $this->id,
'pageName' => Inflector::slug($this->page_title),
'parentLeave' => $this->parents(1)->one() ? $this->parents(1)->one()->page_title : null,
]
);
'id' => $this->id,
'pageName' => Inflector::slug($this->page_title),
'parentLeave' => $this->parents(1)->one() ? $this->parents(1)->one()->page_title : null,
];

if (Json::decode($this->request_params)) {
$route = ArrayHelper::merge($route, Json::decode($this->request_params));
}

return Url::toRoute($route);
}

/**
Expand Down
36 changes: 35 additions & 1 deletion views/treeview/_form.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

namespace dmstr\modules\pages\views\treeview;

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2015
* @package yii2-tree-manager
Expand All @@ -9,12 +12,14 @@
use kartik\form\ActiveForm;
use kartik\tree\TreeView;
use rmrevin\yii\fontawesome\FA;
use yii\bootstrap\Collapse;
use yii\helpers\Html;
use yii\helpers\Inflector;
use yii\helpers\Url;
use Yii;

/**
* @var yii\web\View $this
* @var \yii\web\View $this
* @var kartik\form\ActiveForm $form
* @var $node dmstr\modules\pages\models\Tree
*/
Expand Down Expand Up @@ -304,7 +309,36 @@
]
)->label(false); ?>
</div>

</div>

<?php $this->beginBlock('request_params') ?>
<div class="row">
<div class="col-xs-12">
<?= $form->field(
$node,
'request_params',
[
'addon' => ['prepend' => ['content' => Inflector::titleize('request_params')]]
]
)->widget(\devgroup\jsoneditor\Jsoneditor::className(), ['model'=>$node,'attribute'=>'request_params'])->label(false) ?>
</div>
</div>
<?php $this->endBlock() ?>

<?php
echo Collapse::widget(
[
'items' => [
// equivalent to the above
[
'label' => 'Advanced URL settings',
'content' => $this->blocks['request_params'],
],
]
]
);
?>

<h4><?= Yii::t('kvtree', 'SEO') ?></h4>
<div class="row">
Expand Down

0 comments on commit 7b796cf

Please sign in to comment.