文章详情页模板(single.blade.php)

1、引入公共文件

@include("template::mycms.views._header")
@include("template::mycms.views._footer")

2、文章详情

文章对象变量,通过此变量可以获取当前文章的相关信息。

$article

示例使用:

//文章内容
{!! $article->content !!}

//文章标题
{{$article->title}}

//文章作者
{{$article->author}}

//文章分类名
{{$article->category->name}}

3、文章标签

参数 : 文章ID

article_tags($article->id)

使用示例

@foreach(article_tags($article->id) as $tag)
	<li><a href="{{tag_path($tag->id)}}"
		   class="tags-link">{{$tag->tag_name}}</a></li>
@endforeach

4、文章评论

参数1 : 文章ID

参数2 : 评论根ID

article_comments($article->id,$comment->id)

使用示例

@if(($comments = article_comments($article->id)) && $comments->count() > 0)
	<ul>
		@foreach($comments as $comment)
			<li>
				<div class="single-commentor-user">
					<img
						src="{{$comment->user->img ?: '/mycms/cms/theme/mycms/assets/img/user/user-default-img.png'}}">
					<div class="single-commentor-user-bio">
						<div class="single-commentor-user-bio-head">
							<h5>{{$comment->user->name}}</h5>
						</div>
						<p class="mb-20">
							{{$comment->content}}
						</p>
						<a href="javascript:" onclick="reply(this)" class="share d-block"  data-id="{{$comment->id}}" data-user-name="{{$comment->user->name}}">
							<img
								src="/mycms/cms/theme/mycms/assets/img/icons/reply.png">
							回复
						</a>
					</div>
				</div>
			</li>

			@foreach(article_comments($article->id,$comment->id) as $child)
			<li>
				<div class="single-commentor-user de-bpd">
					<img src="{{$child->user->img ?: '/mycms/cms/theme/mycms/assets/img/user/user-default-img.png'}}">
					<div class="single-commentor-user-bio">
						<div class="single-commentor-user-bio-head">
							<h5>{{$child->user->name}}</h5>
						</div>
						<p class="mb-20">
							{{$child->content}}
						</p>
						<a href="javascript:" onclick="reply(this)" class="share d-block"  data-id="{{$child->id}}" data-user-name="{{$child->user->name}}">
							<img src="/mycms/cms/theme/mycms/assets/img/icons/reply.png">
							回复
						</a>
					</div>
				</div>
			</li>
			@endforeach

		@endforeach
	</ul>
@else
	<p style="text-align: center">空空如也~</p>
@endif

5、获取最新/火的5篇文章

参数1 : 固定第一页

参数2 : 文章的数量

参数3 : new 标识,即为最新的文章;hot 标识,最火的文章

articles(1,5,'new')

使用示例

@foreach(articles(1,5,'new') as $article)
	<div class="recent-post-single">
		<div class="recent-post-pic">
			<img src="{{$article->img}}" style="width: 80px">
		</div>
		<div class="recent-post-bio">
			<h6>
				<a href="{{single_path($article->id)}}">{{$article->title}}</a>
			</h6>
			<span>
				<i>
					<img src="/mycms/cms/theme/mycms/assets/img/icons/rc.png">
				</i>
				{{created_at_date($article->created_at)}}
			</span>
		</div>
	</div>
@endforeach

6、获取整站标签列表

tags()

使用示例

@foreach(tags() as $tag)
	<a href="{{tag_path($tag->id)}}" class="tags-link">{{$tag->tag_name}}</a>
@endforeach