<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Populate &amp;quot;choice&amp;quot; tag at runtime in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Populate-quot-choice-quot-tag-at-runtime/m-p/749914#M32646</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this scenario: we have a firebase database with some data ( let's say some articles ). We'd like to use a "choice" tag or field ( although with field I believe is not possible ) for allowing an editor to select which set of data ( article ) to be used in a template for creating a webpage. For example: we would have a dropdown selector ( generated by a choice tag ) with article titles as options. When the editor selects one of those, the template would use selected set of data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible? I tried this code in &amp;lt;head&amp;gt; of the template:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% require_js %}
&amp;lt;script&amp;gt;
window.choices = ... // async request using fetch to grab and properly format for "choices" the article titles from firebase. An example of the variable content would be: "First article title, Second article title"
&amp;lt;/script&amp;gt;
{% end_require_js %}

{% choice "select_article" label="Select Article", choices="{{window.choices}}" export_to_template_context=true %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but since choice tag is rendered by hubspot systems server side ( and so before the page reaches the browser ), obviously window.choices = null.&lt;BR /&gt;&lt;BR /&gt;Would this be a use case for a serverless function? Not sure if that can be executed server side before page being sent to the client.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2023 10:16:35 GMT</pubDate>
    <dc:creator>xyboox</dc:creator>
    <dc:date>2023-02-01T10:16:35Z</dc:date>
    <item>
      <title>Populate "choice" tag at runtime</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Populate-quot-choice-quot-tag-at-runtime/m-p/749914#M32646</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this scenario: we have a firebase database with some data ( let's say some articles ). We'd like to use a "choice" tag or field ( although with field I believe is not possible ) for allowing an editor to select which set of data ( article ) to be used in a template for creating a webpage. For example: we would have a dropdown selector ( generated by a choice tag ) with article titles as options. When the editor selects one of those, the template would use selected set of data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible? I tried this code in &amp;lt;head&amp;gt; of the template:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% require_js %}
&amp;lt;script&amp;gt;
window.choices = ... // async request using fetch to grab and properly format for "choices" the article titles from firebase. An example of the variable content would be: "First article title, Second article title"
&amp;lt;/script&amp;gt;
{% end_require_js %}

{% choice "select_article" label="Select Article", choices="{{window.choices}}" export_to_template_context=true %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but since choice tag is rendered by hubspot systems server side ( and so before the page reaches the browser ), obviously window.choices = null.&lt;BR /&gt;&lt;BR /&gt;Would this be a use case for a serverless function? Not sure if that can be executed server side before page being sent to the client.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 10:16:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Populate-quot-choice-quot-tag-at-runtime/m-p/749914#M32646</guid>
      <dc:creator>xyboox</dc:creator>
      <dc:date>2023-02-01T10:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Populate "choice" tag at runtime</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Populate-quot-choice-quot-tag-at-runtime/m-p/750287#M32658</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/474766"&gt;@xyboox&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for including those details. Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/101258"&gt;@Teun&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/20261"&gt;@louischausse&lt;/a&gt;, do&amp;nbsp;you have any insight you can share with&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/474766"&gt;@xyboox&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much! — Jaycee&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 21:02:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Populate-quot-choice-quot-tag-at-runtime/m-p/750287#M32658</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-02-01T21:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Populate "choice" tag at runtime</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Populate-quot-choice-quot-tag-at-runtime/m-p/751293#M32697</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/474766"&gt;@xyboox&lt;/a&gt;&amp;nbsp;have you considered migrating that content to HubSpot's HubDB? You could also leave the data there but use a serverless function to sync that data to HubDB.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 13:46:39 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Populate-quot-choice-quot-tag-at-runtime/m-p/751293#M32697</guid>
      <dc:creator>stefen</dc:creator>
      <dc:date>2023-02-03T13:46:39Z</dc:date>
    </item>
  </channel>
</rss>

