6 Replies Latest reply on Feb 22, 2016 7:10 PM by Liam Dilley

    Get Page Info

    ccEikou Level 1

      With {module_pagename} you get the pagename of the current page you visit.

      Is there also a way to get the template ID of the page you currently visiting with module or any liquid tags?



        • 1. Re: Get Page Info
          Eworks-WSI Level 2



          You can get this with liquid:


                    <p>PageID: {{oid_0.oid}}</p>

                  <p>Page Name: {module_pagename}</p>

                  {module_data resource="pages" version="v3" fields="id,templateId,name,template" resourceId="{{oid_0.oid}}" order="id" collection="myData"}

                  <p>Template ID: {{myData.templateId}}</p>

                  <p>Template: {{myData.template.name}}</p>

          • 2. Re: Get Page Info
            Liam Dilley Adobe Community Professional & MVP

            The OID position placement will differ per site based on the call, naming you collections is also important for good use in your projects.

            {module_pagename} can be set as a data element to say your body tag so it does not render in your actual website.

            From there, this is now accessible as a liquid data point.

            {{pagename.name}} To get:

            {module_data resource="pages" version="v3" fields="id,templateId,name" where="\{'name':'{{pagename.name}}'\}" skip="0" limit="2" order="id" collection="pageData"}


            That is a bit cleaner and more reliable.

            I have a couple of other posts with people thinking the template id could be useful for their liquid conditions. But it really is not though. You can not control templates on the front end, you can not dynamically change them. One page can only have one template.

            I see the thinking, but far other better options and ways to achieve things.

            • 3. Re: Get Page Info
              ccEikou Level 1

              Yes this approach works for pages.


              The only downside is when system generated pages like, blog,faq,system pages, webapps.  even those have different template assigned.

              I currently have now idea how to get the template Id if l landed on those system pages.


              Any ideas?

              • 4. Re: Get Page Info
                Liam Dilley Adobe Community Professional & MVP

                Possible, but just a lot of work and code on the layouts you have access too.

                Can I ask why? What are you trying to achieve? Like I said, I bet you do not need to do this.

                • 5. Re: Get Page Info
                  ccEikou Level 1

                  Thank you for your reply.


                  Currently I want to fully use the abilities of liquid and try to avoid javascript as much as possible.


                  Currently I want those pages with certain type of template to display different content.


                  {% if  {{myTemplate}} ==  'templateIDA' -%}


                  {% endif %}


                  {% if  {{myTemplate}} ==  'templateIDB' -%}


                  {% endif %}


                  Hope it is not too complex to achieve this. Or maybe other suggestions?


                  Thank for your time!

                  • 6. Re: Get Page Info
                    Liam Dilley Adobe Community Professional & MVP

                    Well your going page for that when you should be doing that within the scope of the template. Your over complicating that.