Setting a default value for the title field of a configured content type

Hello,
This is my firts attempt at writing code for a special need I have. I could use some help.

The issue: I have created a contenttype (Machine name: clubwedstrijd) via the core functions in Drupal 7. I now need to set a default value for the title of the content type.

As I could not find easily how to configure this, and as I wanted to get some first experience with writing a (small module), I gave it a go. I looked at the doc, and thought I could use the hook_form_FORM_ID_alter. I used the example they gave to start from. But, It does not work. Here is what I did

module: default_title

//function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
function default_title_form_FORM_ID_alter(&$form, &$form_state, $form_id) {

  // Modification for the form with the given form ID goes here. For example, if
  // FORM_ID is "user_register" this code would run only on the user
  // registration form.
  
  IF (form_id=='clubwedstrijd') {

  // Add a default value
  $form['title'] = array(
     '#default_value' => 'enter club number',
  );
  }
}

I also made a .info file

name = Default Title
description = Adds a default title to a given node type
package = Default Title
core = 7.x

Drupal 7, Zen 7 sub theme - Phantom menu appears in Nav block when all menus are disabled

I'm working on creating a Zen 7 sub theme and the menus are behaving strangely.

I have disabled all of the menus (including the main menu); nothing is enabled in the Navigation bar, etc. Yet there is a menu appearing in the Navigation Bar block, but no "Configure" option with the little gear icon. It's clearly fed from the main menu, and Chrome Element Inspect on the menu there gives me the following:

Rate widget in Views

I have a View listing 8 photos and I want to be able to rate each one of them. For some reason I can't get Views and Rate integration to work and can't find relevant enough information from Google (maybe due to freshness of D7?)

This is my View (So I have in Relationship Node:Vote Results and then as a Field I have Vote results: Value) I can't get either the result nor the widget to appear in my view. Am I doing something wrong? Also, from Relationship Node: Vote Results I can't get to choose anything else but Normal vote in Vote tag. Shouldn't I be able to choose the actual vote tag which I set up?

Also, I'd like to have a lot of completely similar pages with the same 8 photos, but different votes. What would be the best way? To clone the pages?

Query:

SELECT node.nid AS nid, node.title AS node_title, 'node' AS field_data_field_kuva_node_entity_type, value AS value
FROM
{node} node
LEFT JOIN {votingapi_cache} votingapi_cache_node_points_vote_average ON node.nid = votingapi_cache_node_points_vote_average.entity_id AND (votingapi_cache_node_points_vote_average.entity_type = :views_join_condition_0 AND votingapi_cache_node_points_vote_average.value_type = :views_join_condition_1 AND votingapi_cache_node_points_vote_average.tag = :views_join_condition_2 AND votingapi_cache_node_points_vote_average.function = :views_join_condition_3)

#default_value and select forms doesnt seem to work

Im a novice at php, so I dont know if Im doing something wrong in php or drupal but all I know is that when I have a select form element #default_value seems to be ignored. Here is what my code looks like for the select form

Ubercart attributes doesn't appear with node

Hi,
I have problem to display product attributes with node. I can see my custom attribute in object $node in hook_node_view() $node->attributes and see it is set to be displayed. But it is not rendered with node. (I don't see it in $node->content array but I am not sure whether I should see it there).
Could anybody help what could be wrong?

Image upload widget gives error when required field is not yet filled in

Hi,

I'm setting up Drupal 7 as a blog tool. On top of the default blog content fields, I've added a mandatory category field (from a taxonomy vocabulary) and an image field for which I've selected the default upload widget.

When I upload an image with the default Ajax widget, I get an error when the category isn't selected yet. This error doesn't appear when I select a category first.

Is there a way to bypass this check? It's obviously only useful when I post the entire form, not when I just upload the image and then fill in the rest of the form.

Pages

Subscribe with RSS Subscribe to RSS - Drupal 7.x