Linking to internal page with Repeater Option

SOLVE
Regular Contributor

Hey everyone!

 

I am currenly buildiong a tieriary navigation that has 3 options. I am accomplishing this by using a field group with the repeater option. The links are added from the staging content page. The issue is when the page is viewed/tested the URL(s) aren't inserted into the href attribute as specified. I have tried a few methods including a text field and a Page Field, with no success.

 

Code below (with text field):

{% for item in module.tunnel_group %}
      <article class="col-sm-12 col-md-4 tunnel-nav">
        <a href="{{ item.tunnel_link }}">
        <div class="tunnel-nav-header" style="background-image: url('{{ item.tunnel_image }}');">
          <div class="hero-caption hidden-md hidden-lg">
            {{ item.tunnel_caption }}
          </div>
        </div>
        
        <div class="tunnel-nav-body">
          <p class="hidden-sm">
            {{ item.tunnel_caption }}
          </p>
          <a href="{{ item.tunnel_link }}" class="btn btn-primary">
            {{ item.tunnel_cta_copy }} <i class="fa fa-caret-right"></i>
          </a>
        </div>
          </a>
      </article>
      {% endfor %}
Reply
0 Upvotes
2 Accepted solutions

Accepted Solutions
Highlighted
Top Advisor

Hi  @Kevin-C,

 

If you pretty print the page token:

{{ page_field|pprint }}

You will see that the field allows you to choose a page in your cos, pages contain attributes, one of which is absolute_url. if you want to print the url of a page from the page field you can do this:

{{ item.tunnel_link.absolute_url }}
Reply
0 Upvotes
Top Advisor

The only place to set up a page field is in a custom module. 

 

you need to copy the snipped to the entire repeater field, paste it into your editor, copy the page field snippet from the repeater snippet, place that in your href, and add '.absolute_url' to the snippet. 

 

The fact that you are getting nothing from the field shows me that it is mispelled or otherwise not correctly referencing the field.

Reply
0 Upvotes
4 Replies
Highlighted
Top Advisor

Hi  @Kevin-C,

 

If you pretty print the page token:

{{ page_field|pprint }}

You will see that the field allows you to choose a page in your cos, pages contain attributes, one of which is absolute_url. if you want to print the url of a page from the page field you can do this:

{{ item.tunnel_link.absolute_url }}
Reply
0 Upvotes
Regular Contributor

Thanks Jsum,

 

Edit: Just noticed I didn't mention I was working within a module and not a HubL page. Might this be the issue?

 

I must not be implementing this correctly as I am still getting no value inserted into the href attribute. The PPrint prints no value as well.

 

Might there be more documentation on this outside of this page?

Reply
0 Upvotes
Top Advisor

The only place to set up a page field is in a custom module. 

 

you need to copy the snipped to the entire repeater field, paste it into your editor, copy the page field snippet from the repeater snippet, place that in your href, and add '.absolute_url' to the snippet. 

 

The fact that you are getting nothing from the field shows me that it is mispelled or otherwise not correctly referencing the field.

Reply
0 Upvotes
Regular Contributor

Got it going! Very much appreciated.

Reply
0 Upvotes