We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19604 ☆ A M B ☆
    • 179 Posts
    Hi there,
    I use the output filter option "HTML" to supply the wrappers for CSS (and JS) code when using the output filters "htmlToHead" and htmlTo Bottom".

    By doing so, this here:
    [[*css:htmlToHead:notempty=``]]
    
    (with the TV 'css' set to 'tag { foo: bar;}'
    

    results in that:
    <head>
    ....
    <style id="csstv">tag { foo: bar; }</style>
    </head>
    

    So far, that's great!

    But there is a downside: The "id=tvname+'tv'" is ALLWAYS set automatically! So when using this technique multiple times on one side, you get invalid HTML-code by using an id multiple times.

    Has anybody an idea how to deal with that?

    thanks
    Oliver

    This question has been answered by sottwell. See the first response.

    [ed. note: mindeffects last edited this post 13 years ago.]
      MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
      http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Mark Hamstra Reply #2, 13 years ago
      Why do you need the htmlToHead output filter on [[*css]] - why not put it into your header directly?

      I just set up a textarea TV, specified the output type as HTML Tag and changed the type of the tag to style. Didn't get an ID, but there is an ID option. Check out the output type tab, you probably defined the ID there.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 19604 ☆ A M B ☆
        • 179 Posts
        Thanks, Mark, but sadly: Nope. This I checked first. The output filter HTML option field "id" is perfectly blank. The output filter somehow passes the name of the tv over to the output (and appends the string 'tv' to it).

        I cannot place the TV in the header, because I need it for code that apears at certain places inside the page, like inside seceral resources that are combined by a getResources call. I want to shift the code from the middle of the Page to the head (css) or the bottom (js). But when I use a TV several times, like with getResources, I will get multiple "id=csstv" containers. This still works, but is not valid HTML code.
          MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
          http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
        • discuss.answer
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I would say that's a bug. If the ID field is empty, there should be no ID attribute added. I can't find the code where it's being generated.

          Ok, found it, obviously enough it's htmltag.class.php. I see the problem.

          The field is "tagid", and the code generates a $domid out of the $tagid if it's set, or makes one up out of the tv name if it isn't. Seems to me, though, if there's no "tagid" set, then no id attribute is wanted.

          Line 24 should be
          'id' => empty($params['tagid']) ? null : $domId, /* 'tv' already added to id */
          
          [ed. note: sottwell last edited this post 13 years ago.]
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 19604 ☆ A M B ☆
            • 179 Posts
            Quote from: sottwell at Oct 10, 2013, 05:24 PM

            Ok, found it, obviously enough it's htmltag.class.php. I see the problem.
            Line 24 should be
            'id' => empty($params['tagid']) ? null : $domId, /* 'tv' already added to id */
            
            That EXACTLY did the trick! THANK YOU, SUSAN!

            Maybe I am not the only one who does like "freedom of choice" even when choosing a HTML-id – or NOT choosing to have an id. ;-)

            Do you want to contribute that to the core (team) on GitHub? I never did so and don't want to take the honor for YOUR work.
              MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
              http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I already posted it as a bug. They'll do with it what they please. If you want to contribute it as a pull request, be my guest. I've never gotten that far in my working with git and github.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org