<?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 Re: HubL - Any way to get the id of the module instance? in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358226#M17781</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/113902"&gt;@kchung&lt;/a&gt;&amp;nbsp;would you mind sending over a screenshot of your code? Are you trying to have a unique id/class usign {{ name }} for each module instance (e.g. an image module is added to a page three times) or for a module field in a for loop (e.g. a tabber with repeatable tabs)?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jul 2020 16:09:35 GMT</pubDate>
    <dc:creator>JasonRosa</dc:creator>
    <dc:date>2020-07-29T16:09:35Z</dc:date>
    <item>
      <title>HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/244261#M10462</link>
      <description>&lt;P&gt;When the custom module is rendered, an unique id is attached to the HTML div component with the format&amp;nbsp;&lt;SPAN&gt;hs_cos_wrapper_widget_1538643526593&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a way to get this unique ID in the module itself through HUBL?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Basically I'm looking for a way to identify the very instance of the module in template to assign media-query specific CSS. Class alone is not unique enough for our use-case.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Appreciate any insight! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 17:47:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/244261#M10462</guid>
      <dc:creator>yidanwang</dc:creator>
      <dc:date>2019-01-04T17:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/244488#M10479</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/21478"&gt;@yidanwang&lt;/a&gt;&amp;nbsp;I believe that you can access that using the {{ name }} variable in HubL within the custom module. Here is an example where I used the variable in my code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NameVariable.png" style="width: 810px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/13963i1183ADF7E50EA294/image-size/large?v=v2&amp;amp;px=999" role="button" title="NameVariable.png" alt="NameVariable.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the output that I received&amp;nbsp;in the HTML as a result:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HTML.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/13964iF0B53EC8CBB837EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="HTML.png" alt="HTML.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in your case you might need something like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.hs_cos_wrapper_{{name}} {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that HubL can only be used in the HTML pane of the custom module editor so you might need to put your CSS in some &amp;lt;style&amp;gt; tags in the HTML pane and wrap that in {% require_css %}{% end_require_css %}&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 18:47:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/244488#M10479</guid>
      <dc:creator>JasonRosa</dc:creator>
      <dc:date>2019-01-07T18:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/244545#M10486</link>
      <description>&lt;P&gt;WORKS LIKE A CHARM! Thank you SO MUCH, Jason! This saves my world!&amp;nbsp;&lt;/P&gt;&lt;P&gt;One minor twist to your answer: the css selector is # (Id selector), not class selector &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 21:24:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/244545#M10486</guid>
      <dc:creator>yidanwang</dc:creator>
      <dc:date>2019-01-07T21:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/244644#M10493</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/21478"&gt;@yidanwang&lt;/a&gt;&amp;nbsp;I'm happy to hear this is working for you! Also, good catch on the ID&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.hubspot.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 12:58:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/244644#M10493</guid>
      <dc:creator>JasonRosa</dc:creator>
      <dc:date>2019-01-08T12:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358219#M17780</link>
      <description>&lt;P&gt;Hi Jason,&lt;/P&gt;&lt;P&gt;I tried placing in:&amp;nbsp;{{ name }}&lt;/P&gt;&lt;P&gt;But it gives me the same ID number for each item or instance the module creates.&lt;/P&gt;&lt;P&gt;Is there a way to have it produce completely different IDs for each item within the module?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 15:59:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358219#M17780</guid>
      <dc:creator>kchung</dc:creator>
      <dc:date>2020-07-29T15:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358226#M17781</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/113902"&gt;@kchung&lt;/a&gt;&amp;nbsp;would you mind sending over a screenshot of your code? Are you trying to have a unique id/class usign {{ name }} for each module instance (e.g. an image module is added to a page three times) or for a module field in a for loop (e.g. a tabber with repeatable tabs)?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 16:09:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358226#M17781</guid>
      <dc:creator>JasonRosa</dc:creator>
      <dc:date>2020-07-29T16:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358231#M17782</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/29768iA75FCA0079A01FEA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 16:12:44 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358231#M17782</guid>
      <dc:creator>kchung</dc:creator>
      <dc:date>2020-07-29T16:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358233#M17783</link>
      <description>&lt;P&gt;Jason,&lt;/P&gt;&lt;P&gt;Its on line 4.&lt;/P&gt;&lt;P&gt;I tried placing it in Class and then I tried it with id=""&amp;nbsp; - as you see it in the screen capture.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 16:14:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358233#M17783</guid>
      <dc:creator>kchung</dc:creator>
      <dc:date>2020-07-29T16:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358274#M17788</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/113902"&gt;@kchung&lt;/a&gt;&amp;nbsp;thanks for sending that example! So {{ name }} would be individual to the module as a whole and not a field within a repeater of the module. For example if you added {{ name }} to the top level class on your module (on line 1), each time you added that module to a page the module you added would have a unique class name. If you wanted to have a unique class name for each item in a loop I'd recommend {{ loop.index }} (&lt;A href="https://developers.hubspot.com/docs/cms/hubl/for-loops#loop-properties" target="_blank"&gt;https://developers.hubspot.com/docs/cms/hubl/for-loops#loop-properties&lt;/A&gt;). For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;{% for item in forloop %}&lt;/P&gt;
&lt;P&gt;&amp;lt;div id="story-item-{{ loop.index }}"&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/div&amp;gt;&lt;/P&gt;
&lt;P&gt;{% endif %}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should output a number after "story-item-" for the ID which should keep each loop item unique.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 18:14:45 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358274#M17788</guid>
      <dc:creator>JasonRosa</dc:creator>
      <dc:date>2020-07-29T18:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358281#M17789</link>
      <description>&lt;P&gt;Hi Jason,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works! It created a unique ID for each of the items within the module. Now I can target each item to re-style in CSS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 18:36:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358281#M17789</guid>
      <dc:creator>kchung</dc:creator>
      <dc:date>2020-07-29T18:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: HubL - Any way to get the id of the module instance?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358293#M17790</link>
      <description>&lt;P&gt;No problem! Happy to hear it worked&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 18:51:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m-p/358293#M17790</guid>
      <dc:creator>JasonRosa</dc:creator>
      <dc:date>2020-07-29T18:51:13Z</dc:date>
    </item>
  </channel>
</rss>

