[ZPT] CSS relativity

Arnar Lundesgaard arnar.lundesgaard@creuna.no
Mon, 25 Feb 2002 18:34:52 +0100


Not certain if this is what you want to do, but you get an idea.

Below are three examples:
  <span tal:define=3D"test1 python: 1; test2 python: 0"
        tal:attributes=3D"class python: test1 and 'nav'
                                   or test2 and 'herenav'
                                   or 'subnav'">
    Example One
  </span>

  <span tal:define=3D"test1 python: 0; test2 python: 1"
        tal:attributes=3D"class python: test1 and 'nav'
                                   or test2 and 'herenav'
                                   or 'subnav'">
    Example Two
  </span>

  <span tal:define=3D"test1 python: 0; test2 python: 0"
        tal:attributes=3D"class python: test1 and 'nav'
                                   or test2 and 'herenav'
                                   or 'subnav'">
    Example Three
  </span>

Which gives:
  <span class=3D"nav">One</span>
  <span class=3D"herenav">Two</span>
  <span class=3D"subnav">Three</span>


Your test might be written something like this.
This is not tested, so you will have to work out
the details yourself though.

<tal:loop repeat=3D"item python:container.objectValues(['Folder'])">
  <span tal:define=3D"test1 python: item.title in request.URL;
                    test2 python: request.here in request.URL;
                    nav   python: test1 and 'nav'
                               or test2 and 'herenav'
                               or 'subnav'"
        tal:attributes=3D"class nav">
    <a href=3D"dummylink" class=3D"dummyclass"
       tal:attributes=3D"href item/absolute_url; class nav">
       tal:content=3D"item/title"
      Dummy linkcontent
    </a>
  </span>
</tal:loop>

- Arnar

mailto:arnar.lundesgaard@creuna.no
Creuna as=20
Bryggegata 3=20
NO-0250 Oslo=20
phone office: (+47) 23 23 88 00=20
fax: (+47) 23 23 88 50=20
http://www.creuna.no/=20



> From: Isaac Levy [mailto:ike@visuallistening.com]
> Sent: 25. februar 2002 09:29
> To: zpt@zope.org
> Subject: [ZPT] CSS relativity
>=20
>=20
> Hello all,
>=20
> I'm trying to do something I don't know can be accomplished with Page=20
> Templates, and it's making me batty trying to figure it out.  Any help =

> or suggestions would be most appreciated!:
>=20
> Here's what I'm doing-
> I'm trying to get a class attribute to change based on the =
relationship=20
> between 2 kosher (functioning) TAL variables,
>=20
> 1) the return of folder values, [to be used as links, etc...] from a=20
> python script
>=20
> 2) the navigation is based on folder titles, making up the URL =
strings,=20
> and I'm looking to feed back a different stylesheet class based on=20
> weather or not the link (navigation path) is in the REQUEST/URL.
>=20
> i.e.-
>=20
> ------
> ##primary_nav_py is a tiny python script that feeds me folder location =

> variables:
>=20
> return container.objectValues(['Folder'])#
>=20
> --
> OK the TAL-
>                  <span tal:repeat=3D"item =
container/topics/primary_nav_py"
>                        tal:define=3D"nav ##the thing I describe =
below##"
>                        class=3D"nav"
>                        tal:attributes=3D"class nav">
>                  <a href=3D"item/absolute_url"
>                        tal:attributes=3D"href item/absolute_url"
>                        tal:content=3D"item/title"
>                        class=3D"##NAVTHING##" >repeated link
>                  </a><br>
>                  </span>
> --
> ##NAVTHING is where I'm trying to do something like:
> if
> the [request/url] contains [item/title] return 'nav'
> elseif
> the [request/url] contains [request/here] return 'herenav'
> else
> return 'subnav'
> ------
>=20
> Is there a way I can put this in via TAL, or is there some other =
method=20
> I should investigate?
>=20
> Thanks in advance for any advice!!!!!
>=20
> Best,
> Isaac
> --
> www.visuallistening.com
>=20