2017-04-18 120 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

相关问题