We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19315
    • 84 Posts
    Hi,

    Is it possible to call a snippet from within a description (or custom) field? I have tried, and the snippet call just disappears (although I have managed to use HTML in the field by removing the :htmlent from the placeholder in the template.

    My reason for this is that I would, sometimes, need to specify the language of text as different from the rest of the document. I actually have a snippet that includes span tags with either the xml:lang attribute, or both the xml:lang and lang attributes, depending on whether the page is served as application/xhtml+xml or text/html. I use XHTML 1.0 Strict, and I think this allows both attributes, whether served as text/html or application/xhtml+xml (dependent on browser http_accept header), and indeed if served as text/html I think it should have the lang attribute. Thus I think the snippet is technically useless, I could just use both lang and xml:lang everywhere.

    However, eventually I might move to XHTML 1.1, which does not allow the lang attribute. At that time I would prefer to not have to go through and remove all the lang attributes, it would be far easier just to change the snippet code. Hence my wanting to call the snippet from description (or custom) fields.

    (Note I know that if the field has HTML, then it can’t be the text of an alt attribute).

    Michal.
      • 19315
      • 84 Posts
      I’m actually now thinking that my snippet is a bit of a waste of time. I think maybe just use both the lang and xml:lang attributes everywhere and be done with it.

      Michal.
        • 7923
        • 4,213 Posts
        You should add your snippet to the templates of maxigallery. eg. change [+maxigallery.picture.desc+] with [[yoursnippet? &input=`[+maxigallery.picture.desc+]`]] and make your snippet return the maxigallery picture description wrapped in the way you like.


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 19315
          • 84 Posts
          Quote from: doze at Apr 10, 2008, 10:53 PM

          You should add your snippet to the templates of maxigallery. eg. change [+maxigallery.picture.desc+] with [[yoursnippet? &input=`[+maxigallery.picture.desc+]`]] and make your snippet return the maxigallery picture description wrapped in the way you like.
          I was more thinking that only a subset of the field would require the lang attributes around it, or indeed several distinct subsets. Would that be possible?

          Michal.
            • 7923
            • 4,213 Posts
            I don’t understand what you mean.. could you explain more?


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 19315
              • 84 Posts
              Ah, sorry if I was unclear.

              The description for a single photo could be in multiple languages, say with foreign place names:

              "Michal at Bydgoszcz bus station, about to get on the bus to Łódź" (ok, I don’t actually have a photo of this, it’s just an example)

              Now, a screen reader set to read English I imagine would have tremendous problems with Bydgoszcz and Łódź. (Even if Łódź were spelt Lodz, Łódź is properly pronounced more like "Wudge"). Thus I would think that in an English language page, the description should be something like:

              "Michal at <span lang="pl" xml:lang="pl">Bydgoszcz</span> bus station, about to get on the bus to <span lang="pl" xml:lang="pl">Łódź</span>"

              However, for a page served as application/xhtml+xml (i.e. for XHTML 1.0 served as application/xhtml+xml, and definitely for any XHTML 1.1 page), I thought, initially, that there should only be the xml:lang attribute, and for other pages, such as HTML or XHTML 1.0 served as text/html, there should only be lang attribute. (However, I have since revised my stance, and I now think it’s fine to include both in XHTML 1.0 pages, however they are served: the W3C home page seems to anyway!).

              My pages are served either as text/html or application/xhtml+xml using the "application/xhtml+xml" plugin. In the rest of my site, I have used a snippet to control which language attributes are sent in the page, i.e. I would have the description as:

              "Michal at <span [!LanguageAttributes? &lang=`pl` !]>Bydgoszcz</span> bus station, about to get on the bus to <span [!LanguageAttributes? &lang=`pl` !]>Łódź</span>"

              (This is an example of what I meant by "several distinct subsets" of the field would need language attributes round them. In this case "Bydgoszcz" and "Łódź").

              I was trying to do something similar in a field for the description of pictures, but the snippet call just seems to vanish.

              Michal.