2012-01-13 140 views
10

比方說,我有標記,像這樣:如何使用「UserComments」模式項目?

<ul id="comments"> 

    <li class="comment"> 
    <div class="author">on Friday 3th, Jenny said:</div> 
    <div class="content"><p>bla bla</p></div> 
    </li> 

    <li class="comment"> 
    <div class="author">on Friday 3th, Jenny said:</div> 
    <div class="content"><p>bla bla</p></div> 

    <ul class="level-2"> 
     <li class="comment"> 
     <div class="author">on Friday 3th, Mary said:</div> 
     <div class="content">stfu jenny</div> 
     </li>  
    </ul> 
    </li> 
    ... 

如何使用「UserComments」項目在這個加價? http://schema.org/UserComments

在哪裏可以添加itemscope itemtype="http://schema.org/UserComments"?一旦在列表容器上,或在每個列表項上多次?

回答

6

根據HTML5 Microdata鍵入的物品規格,您可以將其添加到您的評論部分的容器中,例如,

<section itemscope itemtype="http://example.org/animals#cat"> 
<h1 itemprop="name">Hedral</h1> 
<p itemprop="desc">Hedral is a male american domestic 
shorthair, with a fluffy black fur with white paws and belly.</p> 
<img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months"> 
</section> 

因此,對於您的評論部分的項目範圍將被格式化是這樣的(考慮到項目性質):

<ul id="comments" itemscope itemtype="http://schema.org/UserComments"> 

    <li class="comment"> 
    <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Jenny said:</div> 
    <div itemprop="commentText" class="content"><p>bla bla</p></div> 
    </li> 

    <li class="comment"> 
    <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Jenny said:</div> 
    <div itemprop="commentText" class="content"><p>bla bla</p></div> 

    <ul class="level-2"> 
     <li class="comment"> 
     <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Mary said:</div> 
     <div itemprop="commentText" class="content">stfu jenny</div> 
     </li>  
    </ul> 
    </li> 
... 
+0

正如下面的mattrepublic所述,作者使用「creator」屬性標記,而不是「name」doc表示:_這與CreativeWork_的Author屬性相同。 另外,如果可能,最好使用適當的標籤,因此在這種情況下,日期爲

+3

這是**不正確**。每條評論都需要成爲一個獨立的項目。在你的代碼中,只有*一個評論*有幾個不同的名稱/時間/文本。 – unor 2014-04-03 15:31:28

5

每個註釋將是一個自己的項目(在你的例子UserComments)。您可能還想爲每條評論使用article元素。

<article itemscope itemtype="http://schema.org/UserComments"> 
    <header> 
    on 
    <time itemprop="commentTime" datetime="…">Friday 3th</time>, 
    <span itemprop="creator" itemscope itemtype="http://schema.org/Person"> 
     <span itemprop="name">Jenny</span> 
    </span> 
    said: 
    </header> 
    <p itemprop="commentText">bla bla</p> 
</article> 

不過,現在也有Comment,這似乎是因爲它是一個CreativeWork(而不是一個事件,像UserComments)更爲合適。

相關問題