Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Can you add human readable name also? Both are useful for different purposes, but a human readable version would be great, thanks :)
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm not sure what you mean, what variable is this ? I can't find any similar thing in node.tpl.php
Do you mean the node-type class ?
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedNo, not a class, the variable "$type" in node.tpl.php prints out "forum" or "blog" or "story", etc. I'd like a variable that prints out "Forum Topic" instead of "forum", "Blog" instead of "blog", etc.
Comment #3
SteveK CreditAttribution: SteveK commentedThis can be added quite easily through the page preprocess function if needed. I don't believe this is feature worthy since it creates "class" bloat and redundancy with pre-existing classes.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedHey Steve, you're traveling!!
Get out of Drupal.org !!!
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedWell, can you tell me how to do it? "Easy" is a relative term, depending on how much you already know.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedYou could use this simple snippet for replacement, but you will have to declare each type (meaning, adding each type case and its replacement) :
Makes sense ?
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedWith that, do I only need to put that chunk of code in the template once, and then every case of $type would give me the altered version wherever $type is within the template, or do I have to put that in the place of every instance of $type in the template? I was hoping to avoid the later, but I can work with the former. Ideally it wouldn't have to be manually edited when I create a new content type, but if that's my only option it'll work.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedYes, you would have to create a case for each possible type.
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedThat's not what I meant. I meant in the template, would I put those type definitions in only once, or would I have to put that chunk of code in anywhere in the template that the $type variable is placed?
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedThis chunk of code is really just a string replacement. So if you want to output the $type variable two time, yes, you'd have to put that chunk two times.
Comment #12
chawl CreditAttribution: chawl commentedNonsense, use this.
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedThank you! I knew something straight forward like that had to be available somewhere!