$core_v2_widget.GetStringValue() vs. GetHtmlValue()?

I was building a widget and had inadvertently used $core_v2_widget.GetStringValue() instead of $core_v2_widget.GetHtmlValue() and noticed some differences.  I feel that understanding what is going on under the hood allows me to be an effective developer, so I had some questions.

Q: $core_v2_widget.GetStringValue() converted the URL in an HTML snippet (shown below).  Why does it do this, and are there any other transformations that it performs?

Example input value: <a href="https://community.telligent.com/community/11">Click me</a>

Example output: <a href="~/community/11">Click me</a>

Q: How does $core_v2_widget.GetHtmlValue() differ from $core_v2_widget.GetStringValue()?

Q: $core_v2_ui.Render() is supposed to make the content "safe".  What does "safe" mean?  And how do the transformations change when you use the optional "target" value?

Many thanks.

Top Replies

  • Q: $core_v2_widget.GetStringValue() converted the URL in an HTML snippet (shown below).  Why does it do this, and are there any other transformations that it performs?

    File embedding is enabled…

Parents
  • Q: $core_v2_widget.GetStringValue() converted the URL in an HTML snippet (shown below).  Why does it do this, and are there any other transformations that it performs?

    File embedding is enabled for HTML fields, but not string fields. Internally, we resolve URLs to local resources to "application root", inspect if they reference files (if they do, we'll collect the file resources and associate them for proper permission checking), and store the values in this escaped format to make them more portable.

    Q: How does $core_v2_widget.GetHtmlValue() differ from $core_v2_widget.GetStringValue()?

    The only notable difference is the resolution of embedded local URLs.

    Q: $core_v2_ui.Render() is supposed to make the content "safe".  What does "safe" mean?  And how do the transformations change when you use the optional "target" value?

    The core_v2_ui.Render method allows plugins that handle Html.Render events to process disconnected content (these events are automatically executed when API entities, such as blog posts, have their body rendered but can be manually executed when the content is disconnected). HTML render event handlers include: Emoticon processing, float clearing (to prevent content overflowing its HTML container), embedded content processing (code, polls, etc), and file viewers. The event itself is an extensibility point, so other plugins can participate and adjust the content provided to the core_v2_ui.Render() call.

    The target provided is passed through the Render event to allow each handler to execute differently based on the rendering target. For example, emoticons will render differently when rendered to "Web" than to "Email".

Reply
  • Q: $core_v2_widget.GetStringValue() converted the URL in an HTML snippet (shown below).  Why does it do this, and are there any other transformations that it performs?

    File embedding is enabled for HTML fields, but not string fields. Internally, we resolve URLs to local resources to "application root", inspect if they reference files (if they do, we'll collect the file resources and associate them for proper permission checking), and store the values in this escaped format to make them more portable.

    Q: How does $core_v2_widget.GetHtmlValue() differ from $core_v2_widget.GetStringValue()?

    The only notable difference is the resolution of embedded local URLs.

    Q: $core_v2_ui.Render() is supposed to make the content "safe".  What does "safe" mean?  And how do the transformations change when you use the optional "target" value?

    The core_v2_ui.Render method allows plugins that handle Html.Render events to process disconnected content (these events are automatically executed when API entities, such as blog posts, have their body rendered but can be manually executed when the content is disconnected). HTML render event handlers include: Emoticon processing, float clearing (to prevent content overflowing its HTML container), embedded content processing (code, polls, etc), and file viewers. The event itself is an extensibility point, so other plugins can participate and adjust the content provided to the core_v2_ui.Render() call.

    The target provided is passed through the Render event to allow each handler to execute differently based on the rendering target. For example, emoticons will render differently when rendered to "Web" than to "Email".

Children