Would anyone know how to add 'Authored by' field to Create Story page, so that users which do not want to create user account can still post stories etc. and add their nickname to be included in Submitted by field in the node content itself.
Right now, as i see it i can only change the Authored by field as admin, and it checkes the validity of user name before applying the change. So in order to acomplish my goal i would need to:
-Make the 'Authored by' field visible only to users that are not logged in
-Remove the validity check for entered name, since it will not exist, as its only used for anonymous users.
I would greatly appreciate any help on this topic from anyone who has any knowledge in regards to this :)
Comments
CCK
Create a new content type, or edit an existing one. Add a text field for the author. Turn off the default "submitted by" and, in a custom template, print the new text field instead.
Thanks for suggestion. I've
Thanks for suggestion. I've tried CCK, but the results are quite unsatisfactory unfortunately.
Can anyone please advise me if its possible to add a custom field that directly changes the "author" variable for the given node?
_
Since the actual node author is really just a uid I'm not sure how you would do this-- since by definition, your users won't have userids.
CCK really is the best way to
CCK really is the best way to do this. Since your users will be anonymous, their userid will be 0, and the author of the node (in drupal) will always be Anonymous User. What you need to do is create a new Field using CCK for the Nickname, called Authored By or whatever you want. Then you need to edit the .tpl file for that node type ( node-node_type.tpl.php ) . Remove the bit in there about the Author (that is the Drupal author, which is anonymous). Then you can print the authored by field you have by something like this:
print $node->yourfieldname[0]['value'];
Hope that helps!
Leighton
Allright, much appreciated.
Allright, much appreciated. Will see how it works out. Thanks for the input :)
SOLVED
Allright, ive solved the issue by adding a CCK field called "Authors name", and by editing node to query the database for that field, using the node 'vid' and to print out the given name as a nonclickable link in the standard "Submitted by" form.
After alot of poking around, ive stumbled upon theme_node_submitted function in node.module which calls theme_username.
Changing theme_username didnt work very well, so i took the direct approach and have changed the theme_node_submitted function
I added a check for UID, when in case its other than 0, it proceedes as usual and prints user name, but if the UID == 0, then the custom user name is retrieved from database.
code added looks like this:
so now the whole function looks like: