Developer forum

Forum » Development » Collect page content output for sending to external systems

Collect page content output for sending to external systems

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a situation where I have to send NewsArtcile content to external sources via custom integration.

One of the challenges is sending out the resulting content of the page, considering that the entire content is built using GridRows and Columns.
I remember that we used to have a RenderPageContent(PageId) but I don;t seem to be able to find it anymore.

Since this seems like a reasonable need, there are probably new ways of collecting the page result based on PageId. Can anybody point me in the right direction?

Thank you,

Adrian


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Adrian,

 

How about the /dwapi/content/pages/{id} endpoint? And eventually /dwapi/frontend/pageviews/{id} ?

 

Nuno

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

I have not tried those yet.

I can give them a try if there is no alternative method directly from the code.

Thank you,

Adrian

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

To get the content of a page with rows in the webapi, /dwapi/content/rows/{pageId} is the best option.

If you want the markup, you can use @RenderGrid in a template - will not give you the page, but only the grid content.

If you want the markup of the entire page, you can do something like this:

var pv = new PageView() { Redirect = false };
pv.ID = 1;
pv.Load();
var pageMarkup = pv.Output();
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

But of course, that would not work out of httpcontext.

This is how we do it in mails

using (PageViewIsolation pvIso = new PageViewIsolation(intPageID, false, true))
            {
                PageView PageView = PageView.Current();
                PageView.Redirect = false;
                PageView.IsEmailContext = true;
                PageView.Context = pageviewContext; //can be null

                return PageView.Output();
            }
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you. We'll try this approach.

I assume that "Output" will also include the header and footer of the page. In the case of a news article, it would include NAvigation, header and footer, right?

Thank you,
Adrian

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Yes

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I am coming back to this topic.

My need is to be able to send over to an external system, the news defined in Dynamicweb. I want to send over only the Grids (Rows and Paragraphs).

I am not sure if the endpoint approach would solve my need. Ideally, using a RenderGrid(int pageId) would be enough. But I don;t think that this is available out the current context.

Any suggestions or opinions?

Thank you,

Adrian

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Do you need the final html output or do you need structured data?
Is this a one-time thing or something you need to do on a regular basis?

If you need the html output and only need to do this once then you could get the html output without http context by using HttpClient to request each of the news article pages (and maybe use ?LayoutTemplate=MyNewsExport.cshtml or custom query to adjust and simplify the output). This would be a slow process, but if you only need to do this once then it shouldn't matter :)

If you need structured data then you can use the services defined in Dynamicweb.Content.Services.

/Morten

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Morten,

The process will be continuous. News articles will be defined in DW and those articles will have to be sent to a 3rd party system. Sometimes, we might even have to update news articles if they are edited in DW.

Therefore, it has to be on a regular basis.

The content I am interested in is the HTML for the Grids of the page.

One option that I am also looking into is to create an RSS feed with the news. But I may get into the same issue.

Thank you,

Adrian

 

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Using an RSS or ATOM feed sounds like a good solution to me.
You could either create templates for that or maybe use System.ServiceModel.Syndication to serialize the raw data.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Morten,

But I would still need to gather the content of the Grid for every page, right?

Adrian

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Maybe? I don't know what you need :)
If you need the rendered html of complete grids for each "news article" then yes.
How are these going to be used in the external system and what type of system are we talking about? Would it be possible to just use a good old iframe?

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Morten,

Nope. We need to send HTML content on a property (description) via API. Or via RSS feed.

Which means that we need something similar with RenderGrid(int pageId).

How do I accomplish that?

Thank you,

Adrian

   
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you very much. It seems to be exactly what I need.

Adrian

 

You must be logged in to post in the forum