李木木
- PageAdmin新手
- 54
- 102
- 2021-12-23
|
2#
t
T
发表于 2022-02-16 09:15
|显示全部
回复 2楼xiyou的帖子- @{
- int columnId = Html.CurrentColumnId();
- string kw = StringHelper.Format<string>(HttpContext.Current.Request.QueryString["kw"]);
- string[] pagePathArr = Html.PagePath().Split('/');
- int currentPage = StringHelper.Format<int>(Html.CustomViewParameter("page"));
-
-
- if (currentPage <= 0)
- {
- currentPage = 1;
- }
- PageInfo pageInfo = new PageInfo()
- {
- PageSize = 10,//每页显示10条数据
- CurrentPage = currentPage, //当前页码,系统预设
-
- };
- var dataList = Html.InfoDataList(new { Table = "news" ,OrderBy="thedate desc"},"title like @kw", new { kw = "%" + kw + "%" }, pageInfo);
- ViewBag.Path = "/news/Search/"; //PagebreakPartial分页文件用到
- }
- <div class="container padding-bottom-60">
- <ul class="breadcrumb">
- <li><a href="@Html.SiteUrl()"><span class="fa fa-home"> 首页</span></a></li>
- <li><a href="">文章搜索</a></li>
- </ul>
- <ul class="news-list padding-top-10">
- <li style="border-bottom: 0px solid #dddbdb;">
- <span>搜索</span>
- <span style="color:#db3636">"@kw"</span>
- <span>共找到</span>
- <span style="color:#db3636">"<%=RecordCount%>"</span>
- <span>篇文章</span>
- </li>
- @{int num = 0;
- foreach (var item in dataList)
- {
- num++;
- string url = Html.InfoDataUrl((int)item.ColumnId, (int)item.Id);
- string date = item.Thedate.ToString("yyyy-MM-dd");
- <li class="item">
- <span class="title" style="background: url([img]http://129.0.12.91/Templates/CompanyDefault/images/5-1.png[/img]) no-repeat left center;">
- <a href="@url" target="_blank" title="@item.Title">@item.Title</a>
- </span>
- <span class="date">@date</span>
- </li>
- }
- if (num == 0)
- {
-
- <li class="line-height-2 padding-bottom-20 padding-top-20" style="height: 300px;margin-left:500px;border-bottom: 0px solid #dddbdb;">
- <img class="img4" referrerpolicy="no-referrer" src="http://129.0.12.91/Templates/CompanyDefault/images/not found2.png">
- <span class="word11">暂时没有找到匹配的记录</span>
- <span class="info7">请更换一个关键词重新搜索!</span>
- </li>
- }
- }
- </ul>
- @Html.Partial("PagebreakPartial", pageInfo)
- </div>
- <script>
- $("#input-search").val("@kw");
- //$searchBtn.trigger("click");//触发搜索按钮,显示搜索框
- </script>
复制代码搜索关键词高亮
|