2017-04-18 96 views
0

我有一些JSON如下使用博客文章標籤用JSON

"tags": 
{ 
    "business-school": 
    { 
     "name": "Business School", 
     "slug": "business-school", 
     "parent": 0, 
     "description": "", 
     "post_count": 13, 
     "id": 169072, 
     "taxonomy": "post_tag" 
    }, 
    "canterbury": 
    { 
     "name": "Canterbury", 
     "slug": "canterbury", 
     "parent": 0, 
     "description": "", 
     "post_count": 37, 
     "id": 5349, 
     "taxonomy": "post_tag" 

我已成功地顯示與帖子中輸入的相關標籤。在其他博客上,儘管我已經將這些標籤看作超鏈接,並且想知道這是如何實現的。他們會與什麼關聯?是否有可能在JSON框架中使用PHP軸承記住我不熟悉JSON或者最好留給博客網站。

+0

你在哪個其他博客上看到過標籤爲超鏈接。你能分享我們的鏈接嗎? – mi6crazyheart

+1

如果你不知道他們會被鏈接到什麼,那麼這是一個相當流行的問題。首先決定將它們連接起來,然後擔心如何鏈接它們,然後擔心如何鏈接它們 – RiggsFolly

+0

不太清楚你的意思,但是如果你能夠顯示標籤,你可以在標籤上添加一個錨點以使它們成爲鏈接。 tags。至於鏈接的鏈接,由您決定網址。 – Shiping

回答

0

如果你能保持你的數據的關係如下,那麼你可以很容易地在你的博客文章中用HYPERLINKS技術實現該TAG。

格式標籤在哪裏每個標籤將與ID相關聯

所以錨鏈接就會像 - 關於

https://blogs.canterbury.ac.uk/cafa/tag/555/https://blogs.canterbury.ac.uk/cafa/tag/777/

"tags": 
{ 
    "business-school": 
    { 
     "name": "Business School", 
     "slug": "business-school", 
     "parent": 0, 
     "description": "", 
     "post_count": 13, 
     "id": 169072, 
     "taxonomy": "post_tag", 
     "tag_id": 555 
    }, 
    "canterbury": 
    { 
     "name": "Canterbury", 
     "slug": "canterbury", 
     "parent": 0, 
     "description": "", 
     "post_count": 37, 
     "id": 5349, 
     "taxonomy": "post_tag", 
     "tag_id": 777 
    } 
} 

格式博客文章對那些TAG ID

當用戶點擊這些超鏈接中的任何一個時,您將從這些TAG ID中獲得TAG ID &,您可以使用這些ID標記各自的POSTS。 Ex-TAG ID 555與2個POSTS相關聯。

{ 
    "555": [{ 
     "blog_id": 111, 
     "blog_excerpt": "your blog excerpt", 
     "date": "2017-04-15" 
    }, { 
     "blog_id": 222, 
     "blog_excerpt": "your blog excerpt", 
     "date": "2017-04-16" 
    }], 
    "777": [{ 
     "blog_id": 333, 
     "blog_excerpt": "your blog excerpt", 
     "date": "2017-04-17" 
    }, { 
     "blog_id": 444, 
     "blog_excerpt": "your blog excerpt", 
     "date": "2017-04-18" 
    }] 
} 

希望你能明白我的觀點。

+0

是的,謝謝你的時間 – wilky