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.
Currently there is no theme function explicitly defined to theme the "Submitted by on ". Raw text is assigned to the phptemplate variable directly and passed to node.tpl.php. Providing this theme function allows people to theme this directly.
Comment | File | Size | Author |
---|---|---|---|
#13 | submitted_0.patch | 2.51 KB | RobRoy |
#8 | submitted.patch | 2.51 KB | drumm |
#5 | drupal.submitted_1.patch | 2.16 KB | zirafa |
#2 | drupal.submitted_0.patch | 2.22 KB | zirafa |
drupal.submitted.patch | 1.74 KB | zirafa | |
Comments
Comment #1
drummThis will have to be called from the defualt theme_node() over in theme.inc.
Why would the node object passed to that ever be empty?
Comment #2
zirafa CreditAttribution: zirafa commentedI guess you are right, there shouldn't be any reason that node would be empty. Will change.
Is this the section that needs to be changed in theme.inc?
Change it to:
Or am I misunderstanding? If so, I've submitted a revised patch with the changes.
Comment #3
zirafa CreditAttribution: zirafa commentedComment #4
eaton CreditAttribution: eaton commentedThe code is nice, the solution is zero-impact, and it lets us control something that is a pita to override currently. Three cheers! Shouldn't:
be
Or am I missing something..?
Comment #5
zirafa CreditAttribution: zirafa commentedWow, that's a dumb mistake. Updated patch.
Comment #6
zirafa CreditAttribution: zirafa commentedComment #7
drummChanged !a and @b to words.
Changed $object to $node.
Changed around the logic on theme_node(). $submitted wasn't set and I think we always want this.
Comment #8
drumm.
Comment #9
zirafa CreditAttribution: zirafa commentedLooks good and is easier to read now, too.
Comment #10
zirafa CreditAttribution: zirafa commentedWas this ever committed?
Comment #11
eaton CreditAttribution: eaton commentedNope, it wasn't. But it should be. ;-)
This is a small but extremely useful improvement for themers, and it breaks no existing theme code.
Comment #12
merlinofchaos CreditAttribution: merlinofchaos commentedMuch +1 from me. This should definitely go in. Because this isn't a bug or a task we'll probably have to prod the committers to give it attention.
Comment #13
RobRoy CreditAttribution: RobRoy commentedThere was an undefined $object->created in there when it should have been $node->created. Looks good now.
Comment #14
Steven CreditAttribution: Steven commentedI think we need to step back and look at things from a little further.
Changing that ugly "Submitted by" line is probably one of the first things I do in any of my themes... and I'm sure plenty of designers out there do too. With this patch, you have to create a special submitted.tpl.php file or create a theme override in template.php. That is too much work for such a simple and common tweak.
Why not get rid of $submitted completely and just paste in the literal code in the node.tpl.php? That's where it belongs, and where themers will most easily find it.
Also, that non-sense of
t('!title by !name', ...)
vst('by !name')
really needs to go. Having two different t() strings for the same thing is bad and only leads to inconsistencies. It is also in theme_node(), the one themable function which is going to be overrided in 99.9999999% of all cases.Comment #15
eaton CreditAttribution: eaton commentedI'm not sure I agree. Consolidating this bit of code into a theme function is simple and straightforward: overriding it via mytheme_foo() {} is easier than overriding it via the phptemplate_variables function, and it prevents needless bloating of the node.tpl.php file. Nothing prevents themers from sticking custom code in node.tpl.php now, but $submitted is a well-defined and often-used variable now.
Keeping it as is, that's one thing. Making it a theme function, that's better... But I don't see how *removing* the $submitted variable entirely accomplishes anything other than breaking existing themes needlessly?
Comment #16
Steven CreditAttribution: Steven commentedYou misunderstood. I meant replacing
print $submitted;
withif ($submitted) print t('Whatever goes here');
, right in the node.tpl.php. Much easier to edit.Comment #17
RobRoy CreditAttribution: RobRoy commentedLet's just do both. Get the theme('submitted') in there so if I have 10 different "node-type.tpl.php"s I can just do an
in all 10 files and one change to my template.php's phptemplate_submitted() will change all of them.
And if I want to customize it in my theme (or the theme designer wants to have it customized) I can just replace print $submitted with t('Whatever goes here'). True, I'll have to look up theme_submitted to see what to put in there, but it's still pretty easy as far as edits go.
Comment #18
Steven CreditAttribution: Steven commentedHaving to look up the theme('username') and format_date() calls is far from easy, while inserting $submitted is trivial.
Plus, if you have multiple node-type.tpl.php files, that is because you derived them from one and the same node.tpl.php file, and you probably made that change early in the process.
Comment #19
zirafa CreditAttribution: zirafa commentedThis will break a lot of themes. But I think this is fine if we provide smaller variables for theme('username') and format_date.
something like:
$user_name = theme('username');
$date = format_date($node->submitted);
That way themers can do the following directly in node.tpl.php:
And allows themers to really play around with the formatting much more. Steven is this what you were getting at?
Comment #20
jetsetter CreditAttribution: jetsetter commentedZirafa et al:
I am dealing with wanting to simply not have a clickable author link in the middle of my theme development, and your proposed change to the node.tpl.php:
> Submitted by
print $user_name
onprint $date
Is exactly what I was looking for before I realized I would have to go to much more trouble to change this. Here's a +1 for that idea.
Comment #21
coreb CreditAttribution: coreb commentedMoving out of the "x.y.z" queue to a real queue.
Comment #22
RobRoy CreditAttribution: RobRoy commentedShould be 5.x at minimum.
Comment #23
dmitrig01 CreditAttribution: dmitrig01 commentedNo more stuff goes into 5.x
Comment #24
PanchoStill not fixed - I guess this will be for D7...
Comment #25
kbahey CreditAttribution: kbahey commentedAlready fixed.
Duplicate of #146386.
Comment #26
omnyx CreditAttribution: omnyx commentedHi all - I hope this is related to what you're discussing.
I have two regions (two blocks) next to each other and I use each to occupy exactly 1 node (news node). But those two nodes have text of different length - I would like to have the $submitted info to go to the very bottom of the region/block.
It doesn't look nice to have submitted/read more of one node not in line with that of another, if they are sitting next to each other.
an example: www.theonion.com see how the recent news tab (to the middle left of the screen) has the two dates aligned regardless of the text length.
I assume this is a theming issue. Could anyone know what I could do about it?
thanks a bunch
Comment #27
foresttb CreditAttribution: foresttb commentedhello.
i need to change the username and instead use a profile_displayname (added extra).
just for the particular template(amity_island) is needed.(by modifying node.tpl.php -> echo $submitted)
how may i do that?