PageAdmin网站内容管理系统(CMS)交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

tag标签根据模板教程填写的怎么只在网站显示一串字,无法点击呢... [复制链接]

1#


分享 转发
TOP
2#

可以在循环中填写a标签实现链接
标签的链接是自定义的,需要通过自定义文件实现
http://www.pageadmin.net/help/30.cshtml
TOP
3#

如何制作可以点击的tag

我实现了可以点击的tag, 在原有的新闻中心/imageList或NewsList基础上修改:
首先可以结合PageAdmin自带的tag标签功能,创建标签。
可以通过以下代码获得tag信息,tag id就是item.Id
[code]@foreach (var item in Html.TagList(new { Table = "team" }))
                {
                    string url = "/team/?tag="+@item.Id;
                    <button type="button" class="btn btn-default btn-sm"><a href="@url">@item.Name (@item.Count)</a></button>
                }[/code]

tag对应的url通过keyword获得:
[code]  var keyword = Request.QueryString["tag"];//获取搜索关键词[/code]

如果没有传入tag值就全部显示。

全部代码如下:
[code]@{
    int columnId = Html.CurrentColumnId();//当前栏目id
    
    PageInfo pageInfo = new PageInfo()
    {
        PageSize = 12,//每页显示12条数据
        CurrentPage = (int)ViewBag.CurrentPage //当前页码,系统预设
    };
    var dataList = Html.InfoDataList(new { ColumnId = columnId }, null, null, pageInfo);

  var keyword = Request.QueryString["tag"];//获取搜索关键词
}
<div class="container padding-top-20">
    <div class="row">
        <div class="col-md-3">
            @Html.Partial("subNavPartial")
        </div>
        <div class="col-md-9" style="background: white">
            @Html.Partial("BreadcrumbPartial")
           <div class="tag-list" style="margin: 20px">
                <button type="button" class="btn btn-default btn-sm"><a href="/team">全部</a></button>
                @foreach (var item in Html.TagList(new { Table = "team" }))
                {
                    string url = "/team/?type="+@item.Id;
                    <button type="button" class="btn btn-default btn-sm"><a href="@url">@item.Name (@item.Count)</a></button>
                }
            </div>
            <div class="images-list imgae-same-size" id="imageList" style="margin: 20px">
                <div class="row">
                @if(string.IsNullOrEmpty(keyword))
                {
                    foreach (var obj in dataList)
                    {
                        string link = Html.InfoDataUrl((int)obj.ColumnId, (int)obj.Id);
                        string thumbnail = obj.Thumbnail;
                        <div class="col-md-4 col-sm-6 item">
                            <a href="@link" target="_blank"><img src="@thumbnail" alt="@obj.Title"></a>
                            <a href="@link" target="_blank" class="text-center line-height-3 font-weight-600">
                                @obj.Title
                            </a>
                        </div>
                    }
                }
                @if (!string.IsNullOrEmpty(keyword))
                {
                    foreach (var item in Html.InfoDataList(new { ColumnId = columnId, TagId=keyword}))
                    {
                    string url = Html.InfoDataUrl((int)item.ColumnId, (int)item.Id);
                    string thumbnail = item.Thumbnail;
                    <div class="col-md-4 col-sm-6 item">
                        <a href="@url" target="_blank"><img src="@thumbnail" alt="@item.Title"></a>
                        <a href="@url" target="_blank" class="text-center line-height-3 font-weight-600">
                            @item.Title
                        </a>
                    </div>
                    }
                }
            </div>
            @Html.Partial("PagebreakPartial", pageInfo)
        </div>
    </div>
</div>[/code]
TOP
发新话题 回复该主题