ORIENT/themes/modern2/pages/new/afisha-post.htm

155 lines
4.5 KiB
HTML

title = "Афиша"
url = "/new/afisha-post/:id/:slug"
layout = "new/master-inside"
is_hidden = 0
robot_index = "index"
robot_follow = "follow"
[views]
slug = "{{ :slug }}"
[blogPost]
slug = "{{ :slug }}"
id = "{{ :id }}"
categoryPage = 404
[SeoBlogPost]
post = "post"
==
<?php
function onStart(){
//dd($this->page->blogPost);
$postId = $this->param('id');
$currentPost = RainLab\Blog\Models\Post::where('id', $postId)->with(['category_groups'])->first();
$this['featuredPosts'] = RainLab\Blog\Models\Post::with(['categories'])->where('id', $postId)->paginate(10);
$catId = $this['featuredPosts'][0]->categories[0]->id;
//dd($this['featuredPosts'][0]->categories[0]->slug);
if($this->menuItems && $postId && $currentPost && $currentPost->category_groups){
$currentGroup = $currentPost->category_groups[0]->name;
foreach ($this->menuItems as $menu){
//dump($menu->title);
if($menu->title === $currentGroup){
$menu->isActive = true;
break;
}
}
}
// dd($this['posts']);
}
?>
==
{% put styles %}
<style>
p img {
width: 100%;
}
</style>
{% endput %}
{% component 'SeoBlogPost' %}
{% set post = blogPost.post %}
<main class="affiche-item">
<div class="container">
<div class="affiche-item-inner">
<div class="affiche-item-content">
<div class="affiche-item-head">
<h1>
{{post.title}}
</h1>
<span>{{post.published_at|date('d.m.Y')}} | {{post.published_at|date('H:i')}}</span>
</div>
<div class="affiche-item-item">
<div class="affiche-item-top">
<div class="affiche-item-data">
<div class="affiche-item-data">
{% if post.afisha_address %}
<div class="affiche-item-data-row">
<div class="affiche-item-data-img">
<img src="{{'assets/new/icons/location.svg'|theme}}" alt="" />
</div>
<span>{{ post.afisha_address }}</span>
</div>
{% endif %}
{% if post.afisha_address %}
<div class="affiche-item-data-row">
<div class="affiche-item-data-img">
<img src="{{'assets/new/icons/phone.svg'|theme}}" alt="" />
</div>
<span>{{ post.afisha_phone }}</span>
</div>
{% endif %}
<div id="view" class="affiche-item-data-row">
<div class="affiche-item-data-img">
<img src="{{'assets/new/icons/eye.svg'|theme}}" alt="" />
</div>
{% partial 'view' %}
</div>
</div>
</div>
<div class="affiche-item-img">
{% if post.featured_image %}
<img src="{{post.featured_image|media}}" alt="{{post.title}}" />
{% endif %}
</div>
</div>
<div class="affiche-item-bottom">
{{post.content|md}}
</div>
</div>
</div>
{% partial 'newHome/right-sidebar.htm' class="article-aside" %}
</div>
</div>
</main>
{% put scripts %}
<script>
$.request('views::onIncrement', {
update: { view: '@#view' },
})
var re = /\[video poster=\"(.+?)\".+?mp4=\"(.+?)\"/g;
// re = /(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/g
var ptags = document.querySelectorAll('p');
ptags.forEach(s => {
var m;
m = re.exec(s.innerText);
if (m) {
var video = document.createElement('video');
video.setAttribute('src', m[2]);
video.setAttribute('controls', "")
video.setAttribute('width', "100%")
video.setAttribute('type', "video/mp4")
video.setAttribute('poster', m[1])
s.parentNode.replaceChild(video, s);
}
});
</script>
<script src="{{'assets/new/scripts/core/affiche-item.js'|theme}}"></script>
{% endput %}