sitemap.php
2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
use artbox\core\models\SitemapStatic;
use yii\bootstrap\ActiveForm;
use yii\bootstrap\Html;
use yii\helpers\Url;
use yii\web\View;
use yiister\gentelella\widgets\Panel;
/**
* @var View $this
* @var SitemapStatic[] $models
*/
$form = ActiveForm::begin();
$xPanel = Panel::begin(
[
'header' => \Yii::t('core', 'Static pages'),
'collapsable' => true,
'options' => [
'class' => 'x_panel dynamic_fields',
],
]
);
foreach ($models as $index => $model) {
echo Html::tag(
'div',
$form->field(
$model,
"[$index]url",
[
'options' => [
'class' => 'form-group col-xs-5',
],
]
)
->textInput() . $form->field(
$model,
"[$index]priority",
[
'options' => [
'class' => 'form-group col-xs-2',
],
]
)
->textInput() . Html::icon(
'minus',
[
'class' => 'col-xs-1 field-group-remove',
'onclick' => 'sitemap_remove(this)',
]
),
[
'class' => 'row field-group',
]
);
}
echo Html::button(
\Yii::t('core', 'Add field'),
[
'class' => 'btn btn-default',
'onclick' => 'sitemap_add(this)',
'data' => [
'url' => Url::to([ 'seo/create-static' ]),
],
]
);
$xPanel::end();
$xPanel2 = Panel::begin(
[
'header' => \Yii::t('core', 'Dynamic pages'),
'collapsable' => true,
]
);
echo Html::tag('h3', 'To be done...');
$xPanel2::end();
echo Html::submitButton(
\Yii::t('core', 'Generate'),
[
'class' => 'btn btn-primary',
]
);
$form::end();
$js = <<<JS
function sitemap_add(e) {
var url = $(e)
.data('url');
var form_id = $(e)
.parents('form')
.attr('id');
var form = $('#' + form_id);
var count = $('.field-group').length;
console.log(form_id);
$.get(
url, {
'formId': form_id,
'count': count
}, function(data) {
form.find('.field-group')
.last()
.after(data);
}
);
}
function sitemap_remove(e) {
if($('.field-group').length > 1) {
$(e)
.parents('.field-group')
.remove();
}
}
JS;
$this->registerJs($js, $this::POS_END);