// // GET: News [AllowAnonymous] public ActionResult Index(int? page) { var news = context.News.Include(m => m.Attachments).OrderByDescending(m => m.Pined).ThenBy(m => m.CreatedAt); int pageSize = 8; int pageNumber = (page ?? 1); return View(news.ToPagedList(pageNumber, pageSize)); }
<section id="about" class="about-section" style="padding: 0px;"> <div class="container thumbnail-box"> <div class="row"> @if (Model.Count() > 0) { foreach (var item in Model) { <div class="col-sm-3 col-lg-3 col-md-3"> <div class="thumbnail"> <img src="@(item.Attachments.Where(m => m.AttachmentTypeId == 2).Count() == 0 ? Url.Content("~/public/images/news-nopic.png") : Url.Action("News", "Storage", new { filename = item.Attachments.Single(m => m.AttachmentTypeId == 2).FilePath, download = "รูปภาพ.jpg", width = 320, height = 120 }))" alt="" style="max-height: 120px;"> <div class="caption"> <h4 class="pull-right"> </h4> <h4> <a href="@Url.Action("Detail", "News", new { id = item.Id })">@item.Title</a> </h4> <p>@Html.Raw(item.Content)</p> </div> <div class="ratings"> <p class="pull-right">อ่าน: @item.Viewer.ToString("#,##0")</p> <p> <i class="fa fa-clock-o"></i> @((DateTime.Now - item.CreatedAt).TotalDays > 2 ? item.CreatedAt.ToString("d MMM yyyy", new System.Globalization.CultureInfo("th-TH")) : item.CreatedAt.ToRelativeDate()) </p> </div> </div> </div> } } else { <div class="col-sm-12 col-lg-12 col-md-12" style="padding: 150px 0px;"> <i class="fa fa-commenting fa-fw"></i> ไม่มีสาระน่ารู้ </div> } </div> </div> @* ทำ paging ตรงนี้ *@ <div class="pull-right"> @Html.PagedListPager(Model, page => Url.Action("Index", new { page })) </div>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง