Developer forum

Forum » Rapido » How to use Json Feeds and show it to page, paragraph

How to use Json Feeds and show it to page, paragraph

Hung
Reply

I am a newbie, i see this link https://doc.dynamicweb.com/downloads/rapido#sideNavTitle1-4-1-5, which introduce about Json-Feed template.

For practice, i created json feed and json template. But i don't know how to configure to show it on page.  Any bro, please help me make a tutorial step by step from creating json feed to display it on page (frontend). Thank you so much with a gift from VietNam.

Below are my json feed file and json template file (or you can get them in attachments):

    - File Json feed following the path "/Template/Designs/Rapido/Json/Paragraph/JsonFeed.cshtml", below is code:

@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
@using System.Web;
 
@functions {
    public class Root
    {
        public string ContactId { get; set; }
        public string ContactName { get; set; }
        public string Email { get; set; }    
    }
}
@{
    List<Root> feedObject = new List<Root>();
 
    Root feedRoot = new Root();
    
    feedRoot.ContactId = "ID1";
    feedRoot.ContactName = "Name1";
    feedRoot.Email = "Email1";   
    feedObject.Add(feedRoot);
    string jsonFeed = Newtonsoft.Json.JsonConvert.SerializeObject(feedObject);
}
@jsonFeed
 
    - File json template follow the path "/Templates/Designs/Rapido/Paragraph/JsonFeedTemplate.cshtml", below is code:
 
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
@using Dynamicweb.Extensibility
@using Dynamicweb.Content
@using System
@using System.IO
 
@{
int jsonFeedId = GetPageIdByNavigationTag("JsonFeed");
}
 
<div class="js-ajax-container" id="miniCart" data-template="MiniCartContent" data-json-feed="Default.aspx?ID=556&Purge=True" data-init-onload="false"></div>
 
<script id="MiniCartContent" type="text/x-template">
<div>Email: {{Email}}</div>
  <div>DataEmail: data.Email</div>
</script>

Replies

 
Nicolai Pedersen
Reply

Hi Hung

Check out this article on how to setup feeds in general:

https://doc.dynamicweb.com/documentation-9/how-tos/general/setting-up-a-google-merchant-product-feed

Just make sure you choose a json content type.

BR Nicolai

 

You must be logged in to post in the forum