<?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: Detect mobile / desktop screen on hubl coding? in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/754090#M32769</link>
    <description>&lt;P&gt;I think the main problem is the user-agent. &amp;nbsp;I've no idea how to handle changes in these agentes in future... I think i will run in a lot of problem with this &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;But thanks a lot&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/11411"&gt;@Thomastechweb&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2023 14:12:56 GMT</pubDate>
    <dc:creator>TimD1</dc:creator>
    <dc:date>2023-02-09T14:12:56Z</dc:date>
    <item>
      <title>Detect mobile / desktop screen on hubl coding?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/753904#M32764</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I've created a custom module with two diverent stages for desktop and mobile. To make sure not run into SEO trubble because of duplicate content I try to find a solution to caputure the browser widow/screen size in Hubl and diliver just necessary code.&lt;BR /&gt;&lt;BR /&gt;Found this solution but unfortunately this will not work.&lt;BR /&gt;&lt;A href="https://community.hubspot.com/t5/CMS-Development/How-to-Detect-mobile-device-on-hubl-coding/td-p/375605" target="_blank"&gt;https://community.hubspot.com/t5/CMS-Development/How-to-Detect-mobile-device-on-hubl-coding/td-p/375605&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I think the user-agent will not return any "mobile" string...&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{% set agent = request.headers['user-agent']|lower|string %}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{% set is_mobile = false %}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;YOUR DESKTOP CONTENT GOES HERE......&lt;BR /&gt;&lt;SPAN&gt;{% if agent is string_containing "mobile" %}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{% set is_mobile = true %}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;YOUR MOBILE CONTENT GOES HERE......&lt;BR /&gt;&lt;SPAN&gt;{% endif %}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Hope somebody can help...&lt;BR /&gt;THX&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 08:43:45 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/753904#M32764</guid>
      <dc:creator>TimD1</dc:creator>
      <dc:date>2023-02-09T08:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Detect mobile / desktop screen on hubl coding?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/753993#M32765</link>
      <description>&lt;LI-CODE lang="python"&gt;{% set agent = request.headers['user-agent']|lower|string %}
{% set is_mobile = false %}
{% if agent is string_containing "mobile" || agent is string_containing "android" || agent is string_containing "iphone" %}
  {% set is_mobile = true %}
  YOUR MOBILE CONTENT GOES HERE......
{% else %}
  YOUR DESKTOP CONTENT GOES HERE......
{% endif %}
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;This should work better.&lt;BR /&gt;I've made some small changes to your if statement logic and added two OR conditions.&amp;nbsp; (can be expanded if needed)&lt;BR /&gt;&lt;BR /&gt;- The code can also be made cleaner by removing the "is_mobile" variable unless you're going to use it somewhere else.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 11:31:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/753993#M32765</guid>
      <dc:creator>Thomastechweb</dc:creator>
      <dc:date>2023-02-09T11:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Detect mobile / desktop screen on hubl coding?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/754072#M32766</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/11411"&gt;@Thomastechweb&lt;/a&gt;&amp;nbsp;for your feedback!&lt;BR /&gt;Your version works but unfortunately not that perfect in my case :-(.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;My promblem in detail:&lt;/STRONG&gt;&lt;BR /&gt;An agency created several custom moduls for us which has two (other modules have three) different design stages one for desktop and one for mobile (and sometimes one also for tablet). With media quiries the different stages will switch&amp;nbsp;so nothing special. The problem is that this modul crates a lot of duplicate content because both parts are loading in the code.&lt;BR /&gt;Now I try to find a way to load just the moblie or the desktop part... Do you have any idea how to handle this?&lt;BR /&gt;&lt;BR /&gt;Hope that makes sense &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Best &amp;amp; THX&lt;BR /&gt;Tim&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 13:34:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/754072#M32766</guid>
      <dc:creator>TimD1</dc:creator>
      <dc:date>2023-02-09T13:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Detect mobile / desktop screen on hubl coding?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/754081#M32767</link>
      <description>&lt;P&gt;Ok, it's diffcult to write the entire solution without seeing all you code.&lt;BR /&gt;But here's a &lt;SPAN&gt;suggestion&amp;nbsp;&lt;/SPAN&gt;for mobile / desktop&amp;nbsp; (not tablet)&amp;nbsp; which should&amp;nbsp;meet your needs:&lt;BR /&gt;&lt;BR /&gt;If you change the code to and add it to the top your module:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% set agent = request.headers['user-agent']|lower|string %}
{% set is_mobile = false %}
{% if agent is string_containing "mobile" || agent is string_containing "android" || agent is string_containing "iphone" %}
  {% set is_mobile = true %}
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Then you can wrap your mobile / desktop specific content with simple IF tests:&lt;BR /&gt;&lt;BR /&gt;If mobile, show this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% if is_mobile %}
&amp;lt;div class="d-lg-none"&amp;gt;
&amp;lt;!-- Only show on mobile --&amp;gt;
&amp;lt;/div&amp;gt;
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If not mobile show&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% if !is_mobile %}
&amp;lt;div class="d-none d-lg-block"&amp;gt;
&amp;lt;!-- Only show on desktop --&amp;gt;
&amp;lt;/div&amp;gt;
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 13:59:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/754081#M32767</guid>
      <dc:creator>Thomastechweb</dc:creator>
      <dc:date>2023-02-09T13:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Detect mobile / desktop screen on hubl coding?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/754090#M32769</link>
      <description>&lt;P&gt;I think the main problem is the user-agent. &amp;nbsp;I've no idea how to handle changes in these agentes in future... I think i will run in a lot of problem with this &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;But thanks a lot&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/11411"&gt;@Thomastechweb&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 14:12:56 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/754090#M32769</guid>
      <dc:creator>TimD1</dc:creator>
      <dc:date>2023-02-09T14:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Detect mobile / desktop screen on hubl coding?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/870832#M36463</link>
      <description>&lt;P&gt;Hey, thanks a ton for the clear examples, &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/11411"&gt;@Thomastechweb&lt;/a&gt;! I just wanted to point out that an alternative to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% if !is_mobile %}
...
{% endif %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;would be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% unless is_mobile %}
...
{% endunless %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some HubL students finding this post (such as myself &lt;span class="lia-unicode-emoji" title=":cowboy_hat_face:"&gt;🤠&lt;/span&gt;) may feel it's easier to scan their code logic this way.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 22:44:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Detect-mobile-desktop-screen-on-hubl-coding/m-p/870832#M36463</guid>
      <dc:creator>DeZinerly</dc:creator>
      <dc:date>2023-10-26T22:44:53Z</dc:date>
    </item>
  </channel>
</rss>

