Drupal is up and running but how do I ...?

How do I pre-populate hook_form() fields?

How do I pre-populate hook_form() fields?... I have everything working within hook_form(), but I'd like to be able to pass two variables to page and have them be the initial values of the two associated input boxes.

Could it be hook_form_alter? If so, does someone have a clearer example. I'm confused.
http://drupaldocs.org/api/head/function/hook_form_alter

How do I filter the nodes displayed on the homepage? (say I just want to show stories)

I imagine it's pretty easy to filter nodes on the homepage, but I haven't figured it out.

Also, would it be easy to embed the nodes in another module? Say I want to create a homepage with different panels (like a news site) and the different panels display links to the most recent nodes (so one would have stories, another news, etc.). Is that a long explanation or no?

Thanks! I'm loving Drupal.

Jay

End Session on Browser Close

Hello,
V4.6. I am wrestling with settings.php in order to make sessions end when the browser is closed. I've searched throughout the forums and it seems that the consensus is to simply change cookie_lifetime to 0. ini_set('session.cookie_lifetime', 0); I have this set as such, but still find that I reenter the site logged in the next time I open a browser window. This is the full monte of the ini_set(s) that I have in the settings.php file:

how to include JavaScript code after node form?

I've used drupal_set_html_head() to include JavaScript in the head, but how does one do so AFTER a node form? I need to call a JavaScript function AFTER the node form loads to dynamically set some client side select input values.

customize default options display on content submission form per type of node?

Hi.

Perhaps someone has done this & I can avoid re-inventing the wheel. (Search has produced little, alas, and I'm only a very mediocre coder.)

I need to customize the content input form based on the type of node being submitted (I'm using flexinodes with customized tpl.php files). I am able to customize the content fields just fine using flexinode, but now I also need to fiddle with the default Drupal options form up top. Have a situation where submitters should not have access to options such as "publish" or "sticky to top of page" - I need each node type to have a fixed set of default options that are hidden from the submitter, i.e. unchangeable. In other words, the options will be rigid per node type, not per individual submission. The defaults appear to be "published" and "promoted to front page."

I'd normally just add a simple {display:none} to the .css for the .options < div >, but I need a slightly different set of options to be default and hidden for each separate type of node. One node's content needs to be published but not promoted to the front page, one needs to be published and sticky and promoted, etc.

The defaults appear to all be set via the same form in the node.module, which makes it harder - should I perhaps remove that form from the node.module entirely and add a modified version to each flexinode's tpl.php and then make that hidden?

T

PHP page snippet to add a role to the current user

Hi,

I am looking for some PHP code to put in a node that will add a specified role to the user who is viewing that node.

I found the following at http://drupal.org/node/28379:

<?php
$myuser = module_invoke('user', 'load', $user_uid);
$myuserroles = $myuser->roles[];
$myuserroles[] = 'newrole';
module_invoke('user', 'save', $myuser, array('roles' => $myuserroles));
?>

However it didn't work for me :( Could anyone help me out please?

Pages

Subscribe with RSS Subscribe to RSS - Post installation