1

Okay, so I am trying to make a div id in a Tumblr theme equal to a {Tag} if the {Tag} is "digital", "canvas" or "paper". So I've been trying this:

{block:TagPage}
    <script>
        function checktag(){
            if({Tag} == "digital" || {Tag} == "canvas" || {Tag} == "paper"}){
                document.GetElementById("tag").setAttribute("id", {Tag});
            }
            else {
                document.GetElementById("tag").setAttribute("id", "generictag");
            }
        }

        checktag();
    </script>

    <div id="tag">

    <!-- Include Post loop here -->
    </div>
    {/block:TagPage}

And It's not working. I have tryied replacing {Tag} in conditionals by the new {PlaintextTag} and It does not work as well. How the variable is stored on Tumblr, isn't the {Tag} already a string? What am I doing wrong here?

Daniel Guedes
  • 387
  • 1
  • 4
  • 14
  • any errors in the console? Looks like when checktag runs the div with id of tag does not exist so even if `document.GetElementById` would exist (it doesn't because it's `document.getElementById`) it would throw an error. – HMR Nov 28 '17 at 07:13
  • Hmmm.... didnt know that, I thought that 'document.getElementById' would parse the entire html file. But then, how do we do it? If I would place the script after the div, how the div would render since it needs the output of the function to know what id it is ??? I'm sure there's a solution to this. Thanks in advance! – Daniel Guedes Nov 28 '17 at 11:33
  • The block `{block:TagPage}` refers to the `tagged` pages (aka the view when you want all posts tagged "digital". You need to use the block `{block:Tags}` inside a post block: https://www.tumblr.com/docs/en/custom_themes#tags – mikedidthis Nov 30 '17 at 21:28

0 Answers0