ORIENT/themes/modern2/pages/new/newPost.htm

145 lines
4.3 KiB
HTML

title = "newPost"
url = "/new/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
==
<?php
function onStart(){
//dd($this->page->blogPost);
$postId = $this->param('id');
$currentPost = RainLab\Blog\Models\Post::where('id', $postId)->with(['category_groups'])->first();
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;
}
}
}
}
?>
==
{% put styles %}
<style>
p img {
width: 100%;
}
</style>
{% endput %}
{% set post = blogPost.post %}
<main class="article">
<div class="container">
<div class="article-inner">
<div class="article-content">
<div class="article-content-top">
<div class="article-head">
<h2>
{{post.title}}
</h2>
<span id="view" style="display: flex !important;">{{post.published_at|date('d.m.Y')}} | {{post.published_at|date('H:i')}} | <div style="padding-left: 10px;padding-right: 10px;"><img src="{{'assets/new/icons/eye.svg'|theme}}" alt="" style="width: 18px;" /></div> {% partial 'view' %}</span>
</div>
<div class="article-swiper-wrapper">
<div class="swiper articleSwiper">
<div class="swiper-wrapper">
{% if post.more_photo|length > 0 %}
{% for img in post.more_photo %}
<div class="swiper-slide">
<div class="article-item">
<img src="{{img.photoq|media_cdn|resize(1112)}}" alt=" {{post.title}}" />
</div>
</div>
{% endfor %}
{% else %}
<div class="swiper-slide">
<div class="article-item">
<img src="{{post.featured_image|media_cdn|resize(1112)}}" alt=" {{post.title}}" />
</div>
</div>
{% endif %}
</div>
<div class="photo-prev video-prev article-prev">
<img src="{{'assets/new/icons/arrow-left-white.svg'|theme}}" alt="" />
</div>
<div class="photo-next video-next article-next">
<img src="{{'assets/new/icons/arrow-right-white.svg'|theme}}" alt="" />
</div>
</div>
</div>
<div class="article-desc">
{{post.content|md}}
<!-- <h5>ORIENT NEWS</h5>
<h5>Фото: figma.com</h5> -->
</div>
{% partial 'new/social' %}
</div>
{% partial 'new/post-featured' %}
</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/article.js'|theme}}"></script>
{% endput %}