1

I have a python file which creates an array with a path to an image and a page URL

self.banner1 = [self.context.defaultBanner1.filename,self.context.defaultBanner1bUrl]

I want to access this within my page using TAL. I have tried this without success

<h1 tal:content="view/banner1[0]"></h1>

How do I access the array using TAL?

lukeocom
  • 3,243
  • 3
  • 18
  • 30

2 Answers2

4

You can't do that with a path expression, but you can use a Python expression:

<h1 tal:content="python:view.banner1[0]" />
David Glick
  • 5,422
  • 17
  • 23
0

You could have a view that make it for you (and test if the array is not empty).

def get_banner(self, banner):
    """ """
    if banner:
        return banner[0]

In the template :

<h1 tal:content="view/get_banner"></h1>
Jihaisse
  • 977
  • 5
  • 24