[Solved] Range GetPage can't evaluate field GetPage in type interface

Hi,

I have a frontmatter with a section with links to .md pages.

"offers": {
    "producteur": [
      "/vie-locale/producteur-test-product-local-plouer-sur-rance-22490-571.md",
      "/vie-locale/producteur-bord-de-rance-saint-malo-35400-618.md",
      "/vie-locale/producteur-producteur-saint-malo-35400-1037.md"
    ],
    "association": [
      "/vie-locale/association-les-doigts-fresnaisiens-saint-meloir-des-ondes-35350-625.md",
      "/vie-locale/association-afoc-association-force-ouvriere-consomateur-saint-malo-35400-628.md",
      "/vie-locale/association-afoc-association-force-ouvriere-consomateur-saint-malo-35400-629.md",
      "/vie-locale/association-mer-des-druides-pleudihen-sur-rance-22690-669.md",
      "/vie-locale/association-basket-loisir-plouer-sur-rance-22490-685.md",
      "/vie-locale/association-ludotheque-ploueraise-plouer-sur-rance-22490-720.md",
      "/vie-locale/association-souffles-d-espoir-contre-le-cancer-dinan-22100-722.md",
      "/vie-locale/association-aep-ecole-diwan-dinan-22100-735.md",
      "/vie-locale/association-la-communaute-du-39-saint-malo-35400-754.md",
      "/vie-locale/association-asso-du-bocage-saint-malo-35400-854.md",
      "/vie-locale/association-asso-geniale-saint-malo-35400-1038.md",
      "/vie-locale/association-asso-super-plouer-sur-rance-22490-1039.md"
    ]

I get the element table well.

{{ range $index, $element := .Params.offers.association }}
{{ $element }}
{{ end }}

=> 

 /vie-locale/association-les-doigts-fresnaisiens-saint-meloir-des-ondes-35350-625.md

    /vie-locale/association-afoc-association-force-ouvriere-consomateur-saint-malo-35400-628.md

    /vie-locale/association-afoc-association-force-ouvriere-consomateur-saint-malo-35400-629.md

    /vie-locale/association-mer-des-druides-pleudihen-sur-rance-22690-669.md

    /vie-locale/association-basket-loisir-plouer-sur-rance-22490-685.md

    /vie-locale/association-ludotheque-ploueraise-plouer-sur-rance-22490-720.md

    /vie-locale/association-souffles-d-espoir-contre-le-cancer-dinan-22100-722.md

    /vie-locale/association-aep-ecole-diwan-dinan-22100-735.md

    /vie-locale/association-la-communaute-du-39-saint-malo-35400-754.md

    /vie-locale/association-asso-du-bocage-saint-malo-35400-854.md

    /vie-locale/association-asso-geniale-saint-malo-35400-1038.md

    /vie-locale/association-asso-super-plouer-sur-rance-22490-1039.md

But if I add the function GetPage I have the following error:

{{ range $index, $element := .Params.offers.association }}
          {{ with .GetPage "page" "$element" }}
            {{ .Params.name }}
          {{ end }}
        {{ end }}

=>

executing "main" at <.GetPage>: can't evaluate field GetPage in type interface {}

Thanks for your help

Did you try $.GetPage because you’re inside a loop. Just an assumption, didn’t try myself.

2 Likes

Thanks @Leo_Merkel.
I 've just switch on my brain :slight_smile:

1 Like