Prevent users editing node titles - drupal

Is it possible to prevent a user from editing the title of a node on the node edit screen?
One of the things I really detest about Drupal is the rigidity of the title & body field in each node.

Two ways you can do this:
1) Write a hook_form_alter function to set #access to FALSE. This is really quick if you're familiar with writing modules, but if not, you'll probably prefer:
2) Use Automatic Nodetitles to hide the title field completely, create a standard text CCK field to replace it, and then use Content Permissions (which comes with CCK) to restrict access to the new field.
(Also, while the title field is indeed a pain to hide, you can hide the body field just by setting the label to blank.)

Expanding on the tip of hiding the body field, if you use CCK and turn on Content Permissions, you can set field-level permissions, and have a "body" field that shows / is editable however you set role permissions.

If anyone is still interested in drupal7, you can use [title module][1]
[1]: https://www.drupal.org/project/title and turn title to a text field, you then can use [field_permissions module][1]
[1]: https://www.drupal.org/project/field_permissions and set it up however you like by creating a custom permission. The combination of these two module is really flexible.

Related

Drupal 7 use custom layouts created by Panels module

I have recently installed the Panels module. It allows me to create custom layouts for my contents. Now, what i wish to do is, choose these template layouts while creating/editing a certain type of component so that when viewed that content appears in the selected layout.
Hope I made myself clear. Please excuse me if this topic has already been discussed. If so, providing me the link of the post will be helpful enough. Actually I am sort of a newbie in Drupal and more so in the Panles module. So not really sure if my requirement is feasible in the first place.
Thanks in advance...
You can do this by adding a field in your Content type for example of type List (text) > Select list. Each list item will represent a Panels display.
Then create a Panel display variant to override the node template (/node/%node) where you have to add the Selection rules: "YOUR List(text) field". So each variant will display if user selects the connected list option.
If you want to see the selected display online without clicking the Save button you will need probably an ajax effect.
Understanding your question here I'll try to break it down. In order to use a panel layout for node add/edit you can chose to create the layout under /admin/structure/panels
Then you create a new variant. In the variant's [context] tab you'll add the context rule "Node add form", don't worry about the edit form aspect. The Node add form will cover the edit form and the additional contextual rule is to target a specific node. Then you can customize your layout and add in all the form fields in the content tab. Don't forget to add in the node submit button. Now after you've created more than one variant you can enable, disable and order them as you like which covers the specific layout for node type.
The panels layout will order it as you like. If you want control the theming from a non-administrative theme perspective you can disable general admin theme forms in /admin/appearance by unchecking "Use the administration theme when editing or creating content" at the bottom or targeting specific node types by creating a module and having:
<?php
/**
* #file
*/
/**
* Implements hook_admin_paths_alter().
*/
function disable_admin_theme_paths_alter(&$paths) {
$paths['/node/add/node-type-name-here'] = FALSE;
}
Assuming your module's name is disable_admin_theme.

Fb like share box in drupal website

I am making a drupal website and have a content type "quotation". The standard way of taking input in drupal is going to the create content in the menu which is not very user friendly considering your normal user.
I want to have an option to create content (i.e quotation) like in facebook, twitter or any other social networking site. A share box where someone can type in his status and can directly create content.
Also, I have two vocabularies associated with my content type and I want to accommodate them as well while using minimum space. So, how should I go about the problem.
Is there any module in Drupal which can help me in doing so or I have to write Jquery code myself.
two vocabularies associated with my
content type and I want to accommodate
them as well while using minimum
space.
Lol, sounds tough. If you want to use minimal space you'll need to simplify the workflow, ie, remove a vocabulary or 2.
You can also do something like this:
$('#node-edit').focus(function (){
// set your node form vocab to display:none and then show them when user actually uses the form
$('.vocab-wrappers').show();
// set your node form buttons to display:none and then show them when user actually uses the form
$('#node-form buttons').show();
});
To hide the vocabularies/buttons until the user is editing the content.
To get a facebook like effect, I suggest you use: http://drupal.org/project/formblock
This should get you the form and the ability to place it anywhere.
You can use form alter to hide certain parts of the form, or a form alter module, there's various options if you look in drupal modules.
http://drupal.org/project/nodeformcols
You also want http://drupal.org/project/auto_nodetitle to make the title optional, and hidden from the form.
Lastly, theme the node form in CSS/JS, making the texarea smaller and whatever other stuff you would like, recommend setting display:none on the field labels.
This should give you the correct idea for making a decent facebook-like form setup.
This should be possible:
http://drupal.org/node/464906
I've never tried it myself though.

Hide "Authoring information", "Menu Options" and "Publishing Options" in node creation form

I want to hide these fieldsets in a Drupal 6 site for some content types (not for all of them), because these options are unnecessary and confusing to the end user.
How can I do this?
Thank you!
NodeFormCols sounds like the module your after. As well as hiding fieldsets, you can control the order they will appear in, and whether or not they should be collapsed.
As well as that the "Hide publishing options" module allows you to pick which checkboxes to hide within the publishing options fieldset.
If you are talking about when editing a node, this is related to permissions, so those fieldsets will only be displayed according to the user who is editing the node.
If you want to hide them, you could use hook_form_alter to alter the $form array. You have to be careful about this, so it wont be impossible for users to edit the those sections of the node.
Go to Site Building ->Themes ->Select the particular theme and CLICK "Configure" link. You can see various settings, in which you go to Theme-specific settings ->Node Settings ->Author&Date
Make the changes you need and its done!
(This will be easy if we are using a contributed or custom theme)
Check out the Simplify Node Add module.

Creating a custom content type in drupal

i tried to create a custom content type in drupal but unnecessary features like Title, Menu settings, and Revision Information, URL aliases come with it which i don't really want ..coz it doesn't mean anything to the user..
how can i hide all those things, just preserving the fields(say only 3 fields from CCK) that i want only for this custom content type??
thanks..
You can automatically generate titles using the auto_nodetitle module, which also enables you to remove the title field from the node submission form.
As others have mentioned above, most of the other form elements don't appear to non-admin users anyway.
With auto_nodetitle module, you can hide it, not remove it. Then, simply assign a title like "your-content-type-nid", so it will be different for each node (nid will be different).
That would be a better title than an empty one.
You will need to do a combination of things to do what you want. One of those is to add the module auto_nodetitle suggested by others. You can hide the "Body" by removing the "Body field label" from the edit screen for your custom content type. Lastly is that you will have to do the right settings for your CCK fields.
If you have CCK fields you want them to be able to edit and others you do not want them to edit, you will need to enable the Content Permissions module in the CCK section of the modules admin page. Once you've done that, you can go to the role permissions page and set what roles have access to which fields. While permissions can potentially hide CCK fields from the user, you can also control what fields are in the teaser, node, and RSS views via the "Display fields" section of your content type editing screens.
Menu settings, revision info and URL alias type info is admin stuff. If you create a new user that doesn't have admin permissions, I'm pretty sure they won't see it.
Can try some thing like below using hook_form_alter.
function my_module_form_alter(&$form, $form_state, $form_id) {
if($form_id='company_node_form'){
$form['menu']['#prefix'] ='<div style="display:none">';
$form['menu']['#suffix'] ='</div>';
$form['revision_information']['#prefix'] ='<div style="display:none">';
$form['revision_information']['#suffix'] ='</div>';
$form['author']['#prefix'] ='<div style="display:none">';
$form['author']['#suffix'] ='</div>';
$form['options']['#prefix'] ='<div style="display:none">';
$form['options']['#suffix'] ='</div>';
}
}
You might want to try the NodeFormCols module. It does several handy things, among them is to add a Manage Form button which allows you to hide most fields in an input form.

drupal edit attachment field of a node

I have a content type named Properties, users can create the content types
I have file cck field in the content type (properties), now I want to add the attachments to the or edit the attachments field only in a block or panel for the particular property.
Not showing all the fields when user try to edit the content type.
I have heard that this is possible in panels using contexts.
Thanks in advance
Not sure I understand what you want here, but it sounds like you want to change the visibility/editability of fields based on role and display.
To change the visibility and/or editibility based on role, use something like this
http://drupal.org/project/field_permissions
To change it based on display, use the "display fields" tab on the content type edit form.
I think this is what you are looking for
http://drupal.org/project/editablefields

Resources