Download & Extend

"Edit meta tags" permission for each content type

Project:Nodewords: D6 Meta Tags
Version:6.x-1.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

Is it possible to disable the Meta Tags fields from the node edit pages on specific content types? I've searched and I can't seem to find the option or any documentation explaining how.

The idea is that a specific content type will ultimately never been seen as a node view. Think of it like a utility node type. Thus there is no need for the meta tags interface. The field's presence however might encourage admins to add them even though they'll never be seen.

Any suggestions? Am I missing something obvious?

Thanks for all that you do! Its a great tool!

Comments

#1

Title:Disable fields by content type?» Allow to disable the meta tags by content type
Project:Nodewords: D6 Meta Tags» Extra meta tags modules
Version:6.x-1.12-beta4» <none>
Category:support request» feature request

It is not possible to disable the meta tags basing on the content type. I will probably re-implement the feature, but it will be handled by an extra module.

I am moving the report to the project that will implement such feature.

#2

Fair enough. Thanks for letting me know Kiam.

#3

Project:Extra meta tags modules» Nodewords: D6 Meta Tags
Version:<none>» 6.x-1.x-dev

This module is not maintained anymore. This feature should be implemented in Nodewords, if it's considered worth implementing it when there is already a module with the same purpose.

#4

Status:active» needs review

I didn't see a module with the same purpose.
(The Meta tags Node Type module provides default tags per content type, but does nothing with en/disabling the per-node edit controls for certain types.)

So here's a patch. I think the natural place for this setting is in nodewords_ui.module.

(I pretty much stole the code from upload.module. Default behavior isn't changed, i.e. things are enabled if the used variable isn't set.)

AttachmentSizeStatusTest resultOperations
822952.patch1.02 KBIdlePASSED: [[SimpleTest]]: [MySQL] 0 pass(es).View details | Re-test

#5

rerolled against latest -dev

AttachmentSizeStatusTest resultOperations
822952-5.patch1.17 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 822952-5.patch.View details | Re-test

#6

meh... still learning to cope with the test bot... reroll with different path prefix...

AttachmentSizeStatusTest resultOperations
822952-6.patch1.2 KBIdlePASSED: [[SimpleTest]]: [MySQL] 0 pass(es).View details | Re-test

#7

roderik,

Beautiful! 8-) Just what I needed.

3 problems though:

a) It doesn't work against the -dev version I have... and I'd think I have the newest of that UI module file.

b) You use 1 and TRUE for the same value. I think you should use 1 or TRUE in both places.

c) Maybe the name should use the $form_id variable instead of 'nodewords_' . $form['type']['#value'] ?

<?php
function nodewords_ui_form_alter(&$form, $form_state, $form_id) {
 
$bool = (
    isset(
$form['type']) &&
    isset(
$form['#node']) &&
   
$form_id == $form['type']['#value'] . '_node_form'
 
);
  if (
$bool) {
    if (
variable_get('nodewords_' . $form_id , TRUE)) {
     
$node = $form['#node'];
     
$form['nodewords'] = nodewords_tags_edit_fields(
       
_nodewords_ui_get_node_metatags_type($node),
        !empty(
$node->nodewords['metatags']) ? $node->nodewords['metatags'] : array(),
        array(
         
'fieldset' => TRUE,
         
'tag options' => array('content type' => $form['type']['#value']),
        )
      );
    }
  }
  elseif (
$form_id == 'node_type_form' && isset($form['identity']['type'])) {
   
$form['workflow']['nodewords'] = array(
     
'#type' => 'radios',
     
'#title' => t('Meta tags editing'),
     
'#default_value' => variable_get('nodewords_'. $form['#node_type']->type . '_node_form', TRUE),
     
'#options' => array(t('Disabled'), t('Enabled')),
     
'#description' => t('Enable editing of meta tags on node forms, for this content type.'),
    );
  }
}
?>

Thank you.
Alexis Wilke

#8

a) indeed. -dev is moving fast.

b) I prefer using 1, not TRUE, in the nodetype edit page - because that's the variable value which will eventually get saved.

IMHO it's a matter of preference whether to use 1 or TRUE in the 'if' statement up there. I changed it to 1 now.

c) you're right; it's better to take longer variable name to prevent collisions with other types.

However, you can't just use nodewords_TYPENAME_node_form; that doesn't automatically get saved. (Note the absence of any 'submit' code here...)
I changed it to 'nodewords_ui_type_TYPENAME' now.

(Adding blocker tag from #957860: Per-content type permission to control access to Nodewords fields for each content type, which I'll set to duplicate.)

AttachmentSizeStatusTest resultOperations
822952-8.patch1.23 KBIdlePASSED: [[SimpleTest]]: [MySQL] 0 pass(es).View details | Re-test

#9

Status:needs review» reviewed & tested by the community

Good point about (c). The auto-save is a good idea. 8-)

My idea was that you could otherwise just use $form_id. But that's okay either way.

Thank you.
Alexis

#10

Status:reviewed & tested by the community» needs work

+++ nodewords_ui/nodewords_ui.module 2010-11-09 03:43:23 +0000
@@ -27,7 +27,8 @@
-    if (!user_access('administer meta tags') && !user_access('edit meta tags')) {
+    if (!variable_get('nodewords_ui_type_' . $form['type']['#value'], 1) ||
+        (!user_access('administer meta tags') && !user_access('edit meta tags'))) {
       return;
     }

What happens when someone requests being able to disable them per vocabulary? Can we rename this variable to nodewords_ui_node_type_[NODETYPE]?

Also, this is missing handling of renaming the variable if the node type changes via node_type_save(). Also missing uninstall of variables.

+++ nodewords_ui/nodewords_ui.module 2010-11-09 03:43:23 +0000
@@ -44,6 +45,16 @@
+  elseif ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
+    $form['workflow']['nodewords_ui_type'] = array(
+      '#type' => 'radios',
+      '#title' => t('Meta tags editing'),
+      '#default_value' => variable_get('nodewords_ui_type_' . $form['#node_type']->type, 1),
+      '#options' => array(t('Disabled'), t('Enabled')),
+      '#description' => t('Enable editing of meta tags on node forms, for this content type.'),
+    );

Please just make this a simple checkbox as per the Drupal UI standards is this is only an enable/disable option.

Powered by Dreditor.

#11

Is this still ok for 6.x-1.13 or should it be promoted to v6.x-1.12?

#12

Let's focus 1.13 on better node/content type support?

#13

subscribe

#14

Subscribe, definitely keen on this feature

#15

+1

#16

+1

#17

Subscribing +1

#18

subscribing +1

#19

subscribing + 1

#20

subscribing + 1

#21

De-tagging, will review priorities after the next stable release.

#22

Title:Allow to disable the meta tags by content type» "Edit meta tags" permission for each content type

Updating the title to be more relevant. This is definitely relevant to #945676: Allow defaults to be defined per content type.