簡體   English   中英

像stackoverflow一樣在umbraco 4.11中進行標記

[英]tagging in umbraco 4.11 just like stackoverflow

即時通訊使用snipper標簽系統和以下文章:

http://daniel.streefkerkonline.com/tag/umbraco/

我可以成功安裝和使用狙擊手標簽系統。 但是當我瀏覽頁面時..tags顯示為文本而不是超鏈接...

我在想什么嗎? 是一些javascript文件,還是缺少標記的步驟?

有任何想法嗎? 這是我的頁面: http : //www.leezardpharma.com/pharmacy/our-products/weight-loss-medicine/gastro1.aspx

在這里,相關的標簽是由於搶奪者而來的..但它們沒有可點擊的。

如果您需要創建標簽作為帶有選項的鏈接來顯示被標簽的產品,則可以創建一個名為../search.aspx?tag=tagname的新頁面,然后搜索該標簽中的產品,代碼如下:

@inherits umbraco.MacroEngines.DynamicNodeContext
@using System.Text
@using umbraco.MacroEngines
@using umbraco.cms.businesslogic.Tags

@{   
    string searchFor = Request["tags"];

    if(string.IsNullOrEmpty(searchFor))
    {
        @* No tags were specified *@ 
        <p>Please specify a tag to search for</p>
        return;
    }

    // this is to search from the tags added and then get all the nodes
    var matchingNodes = Tag.GetNodesWithTags(searchFor).ToList();

    string tagsText = searchFor.Split(',').Count() > 1 ? "tags" : "tag";

    if (matchingNodes.Count < 1)
    {
       @* No results were found for the specified tags *@ 
       <p>No tagged items were found that matched the @tagsText: @searchFor</p>
       return;        
    }

     @* Some results were found for the specified tags *@ 
     <p><strong>@matchingNodes.Count</strong> products were found that matched the @tagsText: "@searchFor"</p>

      <ul>

      // go through the code and create URL for that product
      @foreach (var node in matchingNodes)
      {
        dynamic dn = new DynamicNode(node.Id);

        <li><a href="@dn.Url">@dn.Name</a></li>
      }
      </ul>
}

您可以參考本文,因為我已經對其進行了檢查, 請單擊此處然后在一半的位置,您將看到此代碼

讓我知道更多的解釋需要。 我對此進行了評論,以便您可以簡要了解代碼。

您確定要這樣做嗎?

<ul>
  @foreach (var node in matchingNodes)
  {
    dynamic dn = new DynamicNode(node.Id);

    <li><a href="@dn.Url">@dn.Name</a></li>
  }
</ul>

在此處顯示標簽的地方看起來不正確: 在此處輸入圖片說明

這兩個鏈接來自哪里?

沒有javascript或任何花哨的東西。 這些都是在服務器端以剃刀完成的。

我寫了狙擊標記控件。

如果您想要標記的友好URL,請創建一個重寫規則以將/ tags /([[w] *)重寫映射到tagsearch.aspx?tag = $ 1,然后實現tagsearch.aspx以獲取該標記參數並返回包含該標記參數的所有頁面。如上所述。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM