Developer forum
E-mail notifications
render paragraph in code
Im am currently trying to develop a custom module that gets an array of paragraph, and inserts them on a page.
I have made the code that gets them, now is there a way for me to render them so I get the html of these paragraphs?
Replies
also need this one ... maybe you have figure that out ?
Hi,
You need Dynamicweb to render a page. We call a page through ajax using a "clean" ajax template, and simply process the body
Unfortunately, page templates need to be html valid, hence the doctype, and head
The template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<!--@Global:Area.LongLang-->" lang="<!--@Global:Area.LongLang-->"> <head> <title>Ajax Request</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <!--@MetaTags--> </head> <body> <div id="body" class="dwcontent ajax" title="AJAX Content" settings="sort:1;template:paragraphWithLink.html"></div> </body> </html>
The jQuery action
$.ajax({ url: "/Default.aspx?ID=000&LayoutTemplate=Designs/PortoTours/ajaxRetriever.html", dataType:'html', success:function (obj_xml) { str_newList = $(obj_xml).find('body').html(); // Do stuff with str_newList } });
Best Regards,
Nuno
Hi Nuno,
I've been using this template to generate clean output for JSON or XML:
<!--@If(1=2)--><html><head></head><body><div id="pageContent" class="dwcontent" title="Main content" settings="template:clean.html;default:true;"></div><!--@EndIf--><!--@DwContent(pageContent)--><!--@If(1=2)--></body></html><!--@EndIf-->
The trick is to wrap everything inside a condition that is never met. e.g. 1=2.
And since a parsed content area is translater into this when parsed
<!--@DwContent(pageContent)-->
That the only thing that i left outside my condition.
For JSON and XML you need to disable the performance comment :-)
Edit: Only HTML > Head + Body is required for the template to be valid. doctype is not needed :)
You must be logged in to post in the forum