drupal-7

Adding HTML to Drupal closure?

情到浓时终转凉″ 提交于 2019-12-03 16:52:56
To add javascript, you can use: drupal_add_js And similar for css: drupal_add_css But what if I just want to add html at the end of my page. I.e. Add a div with some text in it at the end of the page? A lot of suggestions here work if you want your alteration to be theme-based, but if you want this to come from a module, using a block region, page template or page prepocess won't cut it, because you're tying the alteration to the theme. From a modular standpoint, the following options are best: hook_footer() -- http://api.drupal.org/api/function/hook_footer/6 :: my_module_footer() should

drupal: Form API, dynamically hide or show fields based on input

↘锁芯ラ 提交于 2019-12-03 16:46:09
问题 I'm building a form module. One of the early fields is a set of radio buttons. By default the first button is selected. Next I'll have a series of select boxes. One needs to be visible, the others invisible. Then as the user selects a different radio button I want different select boxes to show or hide. How can I hide the field and label by default and show it later dependent upon which radio button (or another select box option for that matter) is chosen? 回答1: You can use the #states

Drupal 7: Modifying menu HTML output?

若如初见. 提交于 2019-12-03 15:34:03
问题 I am trying to modify the HTML output in a Drupal 7 theme that I am creating. Basically, instead of the < li >s containing just plain < a >s with text, I want to include some additional HTML inside the < a >. I know that it's possible to modify the HTML created by the menus in Drupal. I can see the following call in page.tpl.php: <?php print theme('links__system_main_menu', array( 'links' => $main_menu, 'attributes' => array( 'id' => 'main-menu', 'class' => array('links', 'clearfix'), ),

Drupal 7 - Insert taxonomy into node object

岁酱吖の 提交于 2019-12-03 15:24:49
I have a script which successfully creates new nodes. But I'm having trouble setting the taxonomy before saving. I believe in Drupal 6 I would use this method. $cat1_tid = taxonomy_get_term_by_name($data[$i]['cat1']); $cat2_tid = taxonomy_get_term_by_name($data[$i]['cat2']); $cat3_tid = taxonomy_get_term_by_name($data[$i]['cat3']); $node->taxonomy = array($cat1_tid, $cat2_tid, $cat3_tid); I think in Drupal 7 I would do this (my field name is Catalog) $node->taxonomy_catalog['und'][0] = array($term1Obj, $term2Obj); taxonomy_get_term_by_name doesn't seem to return the correct object to insert

How do I get PagerDefault queries to work correctly with Drupal 7?

拜拜、爱过 提交于 2019-12-03 14:13:03
I'm running the following code: $query = db_select('taxonomy_index', 'ti') ->fields('ti', array('nid')) ->condition('ti.tid', $term->tid) ->condition('n.status', 1); $query->join('node', 'n', 'n.nid = ti.nid'); $query->extend('PagerDefault')->limit(2); $nids = $query->execute()->fetchCol(); but the pager does not work: every item from the query is returned, as if the call to PagerDefault is completely ignored. I am outputting theme('pager') further down in the output so that's not the problem. This is not the only example of this failure that I have, in several other projects similar queries

Drupal 7 hook_node_view add a form to the content of a node

若如初见. 提交于 2019-12-03 13:10:16
function example_module_node_view($node, $view_mode, $langcode) { $f = drupal_get_form('example_module_form', $node); $node->content['data_collection_form'] = array('#value' => $f, '#weight' => 1); } Why doesn't the form display? Am I doing something wrong? The form object is being populated. I can do #markup => 'Something' and it works. The return from drupal_get_form is actually a render array itself so you could just do this: $f = drupal_get_form('example_module_form', $node); $f['#weight'] = 1; $node->content['data_collection_form'] = $f; If you do want to do it the other way though the

Upload multiple files in Drupal 7

主宰稳场 提交于 2019-12-03 12:23:45
The Image Field only allows one file at a time to be uploaded. Is there a module that enables multi-upload in Drupal 7? Comparation of upload modules: http://groups.drupal.org/node/155764 I use this modules: Multiupload Filefield Widget and for images Multiupload Imagefield Widget If you just want to upload multiple files per node, you can edit the image field settings to allow that. Go to Home » Administration » Structure » Content types » [Content type] » Manage fields then edit the Image field. If you want to upload multiple files at once, it looks like Plupload is your only real option. Or

Eclipse syntax highlighting: trying to specify it for a new file extension, and it's not working

点点圈 提交于 2019-12-03 11:02:14
I'm working with Eclipse/PHP and just starting with Drupal 7, which needs me to use PHP files of extension .test. So I'm trying to add the ".test" extension to the list of files that Eclipse recognises as PHP. I've done this two ways: (1) By specifying it in Preferences-General-Editors-File Associations, and (2) By specifying ".test" in Preferences-General-Content Types (as described in How to manually specify syntax highlighting for a specific extension in Eclipse? ). The trouble is, nothing happens - my xyz.test file opens just fine with the PHP editor, but no syntax is highlighted (and yes,

Add Table Join, Where, and Order By to Views Query in views_query_alter()

别说谁变了你拦得住时间么 提交于 2019-12-03 08:39:09
I am trying to modify the query for Views in Drupal (Views version 3, Drupal version 7). What I want to do is change the query prior to running such that it LEFT JOINs a table in which I have weights assigned to the nodes. If I was to write the query I want in SQL, it would look like this: SELECT a.nid, a.title, a.description FROM node a LEFT OUTER JOIN node_weights b ON a.nid = b.nid WHERE b.uid = $uid ORDER BY b.weight DESC This query works like a champ when I run it in the query analyzer. So, now I need to make it work in my module. I've seen multiple approaches detailed on various blogs

How to remove /drupal from URL in Drupal 7 when installation is in the associated sub-directory

*爱你&永不变心* 提交于 2019-12-03 08:31:16
In Drupal 6 I was able to successful install Drupal in a subdirectory called drupal and then reference the site without having to use example.com/drupal. In Drupal 6 to get this to work I did the following: - Created an .htaccess file in the root directory where /drupal was created. The file contents was: Options -Indexes RewriteEngine On RewriteRule ^$ drupal/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ drupal/$1 Updated the drupal/sites/default/settings.php file to have the $base_url defined as: $base_url = 'http://example.com'; When I try and