<?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: Unable to get Page field to pull in page data. Docs for content_by_id() not matching output in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441352#M23293</link>
    <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/174860"&gt;@NPeters&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything is working as expected in my portal...this is the code block I am using:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// below is to see what is output by the field alone
{{ content_by_id(module.page_field) }} 

// below is getting a li with the content title and url set by the field
{% set my_content = content_by_id(module.page_field) %}
&amp;lt;ul&amp;gt;
    &amp;lt;li&amp;gt;
        &amp;lt;a href="{{ my_content.absolute_url }}"&amp;gt;{{my_content.title}}&amp;lt;/a&amp;gt;
    &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;Could you add an example of your module html file?&lt;/P&gt;</description>
    <pubDate>Wed, 26 May 2021 20:27:49 GMT</pubDate>
    <dc:creator>dennisedson</dc:creator>
    <dc:date>2021-05-26T20:27:49Z</dc:date>
    <item>
      <title>Unable to get Page field to pull in page data. Docs for content_by_id() not matching output</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441211#M23280</link>
      <description>&lt;P&gt;I have created a module that uses the Page field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The aim is populate a block on a landing page that has the page title, and page link. Would be great to also pull in a cover image.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have followed the docs here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.hubspot.com/docs/cms/building-blocks/module-theme-fields#page" target="_blank"&gt;https://developers.hubspot.com/docs/cms/building-blocks/module-theme-fields#page&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tells me to &lt;STRONG&gt;expect an id to be returned&lt;/STRONG&gt;. That is &lt;EM&gt;not&lt;/EM&gt; true in my case. The output I get is some thing like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{url={type=CONTENT,%20content_id=47075729930,%20href=http://19957450.hs-sites.com/-temporary-slug-cce86271-271e-4ab4-a1b4-60b8ce2dab52},%20open_in_new_tab=false,%20no_follow=false}&lt;/LI-CODE&gt;&lt;P&gt;To access the id, it appears I need to do something like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set my_content = content_by_id(article.page_link.url.content_id) %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Seems very verbose, but it is what it is. I move on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The docs for content_by_id show that I should be able to access the keys 'absolute_url' and 'title'.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.hubspot.com/docs/cms/hubl/functions#content-by-id" target="_blank"&gt;https://developers.hubspot.com/docs/cms/hubl/functions#content-by-id&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;None are avaliable when I try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;a href="{{ my_content.absolute_url }}"&amp;gt;{{my_content.title}}&amp;lt;/a&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;When I try to inspect 'my_content' to see if anything will return, I get a string with the output:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Page 47075729930 Blog - Meet our new team members&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; So im guessing its a page type + page id + page title.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I reading the docs wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 15:28:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441211#M23280</guid>
      <dc:creator>NPeters</dc:creator>
      <dc:date>2021-05-26T15:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get Page field to pull in page data. Docs for content_by_id() not matching output</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441352#M23293</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/174860"&gt;@NPeters&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything is working as expected in my portal...this is the code block I am using:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// below is to see what is output by the field alone
{{ content_by_id(module.page_field) }} 

// below is getting a li with the content title and url set by the field
{% set my_content = content_by_id(module.page_field) %}
&amp;lt;ul&amp;gt;
    &amp;lt;li&amp;gt;
        &amp;lt;a href="{{ my_content.absolute_url }}"&amp;gt;{{my_content.title}}&amp;lt;/a&amp;gt;
    &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;Could you add an example of your module html file?&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 20:27:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441352#M23293</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-05-26T20:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get Page field to pull in page data. Docs for content_by_id() not matching output</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441384#M23297</link>
      <description>&lt;P&gt;Hi had a facepalm moment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And what I have realised &amp;nbsp;is I have been caught up in between the differences of a "Page" field and a "Link".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my mind I had used a "Link" field because I wanted to link to a page within the CMS. So I can see the docs show what will be returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I do use the&amp;nbsp;"Page" field. Everything gets returned as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess while I have you, I am keen to find a way to pull in a featured image for that page. Is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your patience.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 22:08:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441384#M23297</guid>
      <dc:creator>NPeters</dc:creator>
      <dc:date>2021-05-26T22:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get Page field to pull in page data. Docs for content_by_id() not matching output</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441821#M23332</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/174860"&gt;@NPeters&lt;/a&gt; , when in doubt, &lt;STRONG&gt;pprint.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I &lt;EM&gt;believe&lt;/EM&gt; this is what it should be &lt;STRONG&gt;{{ content_by_id(module.page_field).featuredImage }}&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;But you should try &lt;STRONG&gt;{{ content_by_id(module.page_field)|pprint }}&lt;/STRONG&gt; and see what that spits out in your preview.&amp;nbsp; Should be a giant json object with everything available&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 19:59:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Unable-to-get-Page-field-to-pull-in-page-data-Docs-for-content/m-p/441821#M23332</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-05-27T19:59:48Z</dc:date>
    </item>
  </channel>
</rss>

