how to write server side script in umbraco content field
i want to know can we write any server side script to umbraco content field and if yes then how to achieve the same in umbraco.
for instance:
my document type (static page) has one property - bodycontent(textbox multiple)
my template (static page) has the code to render @Umbraco.Field("Bodycontent")
content page - i have created 404, 403...etc page using this template.
now what i want is to write some server side script to content section. i do not want to write server side script to template because that will be applied to each content section.
Is there a way to write some server side script to content section.
will appreciate any help.
You could create a different template to put your server side code in that needs to be applied to only one page, and not to every content page.
Then for your content doc type you can allow this alternative template to be used; in addition to your normal content template.
Then for the page that needs to have the special server side code, on the properties tab, select your new alternative template and republish.
(If the page is a different kind of page to the rest of your site, consider creating it as a new document type + template; and give it a different icon; then in the back office tree, it will be clear this is a different type of content page)
Another completely different approach would be to wrap your serverside code in a Macro - and insert the macro only onto the specific page via a rich text area field.
how to write server side script in umbraco content field
i want to know can we write any server side script to umbraco content field and if yes then how to achieve the same in umbraco.
for instance:
my document type (static page) has one property - bodycontent(textbox multiple)
my template (static page) has the code to render @Umbraco.Field("Bodycontent")
content page - i have created 404, 403...etc page using this template. now what i want is to write some server side script to content section. i do not want to write server side script to template because that will be applied to each content section.
Is there a way to write some server side script to content section. will appreciate any help.
Hi Shobhit
You could create a different template to put your server side code in that needs to be applied to only one page, and not to every content page.
Then for your content doc type you can allow this alternative template to be used; in addition to your normal content template.
Then for the page that needs to have the special server side code, on the properties tab, select your new alternative template and republish.
(If the page is a different kind of page to the rest of your site, consider creating it as a new document type + template; and give it a different icon; then in the back office tree, it will be clear this is a different type of content page)
Another completely different approach would be to wrap your serverside code in a Macro - and insert the macro only onto the specific page via a rich text area field.
https://our.umbraco.org/documentation/Reference/Templating/Macros/Partial-View-Macros/
is working on a reply...