Pierre Buyle
  • Member for 10 years, 9 months
  • Last seen more than 1 year ago
3 answers
54 votes
18k views
Is it possible to replace more than one form element (wrappers) triggered by only one #ajax trigger element?
Accepted answer
75 votes

Instead of returning the HTML of the single element to update, your ajax callback can return an array of ajax commands. So it can return two ajax_command_replace to replace each element. function ...

View answer
3 answers
42 votes
49k views
how to send variable from .php file to .js file?
Accepted answer
70 votes

You should use drupal_add_js() in your module, there is no need to output the variable in your .tpl.php: drupal_add_js(array('YOURMODULE' => array('testvar' => $testvar)), array('type' => '...

View answer
13 answers
50 votes
21k views
How do I hide nodes that shouldn't be directly accessed from users and search engines?
32 votes

The Rabbit Hole module provides this feature. Rabbit Hole is a module that adds the ability to control what should happen when an entity is being viewed at its own page. Perhaps you have a ...

View answer
2 answers
14 votes
8k views
Changes in the way Drupal 7 handles JavaScript and jQuery
Accepted answer
28 votes

I think you misunderstood the changes. JavaScript code should be wrapped in (function ($) { ... })(jQuery); to allow usage of $ as shortcut to jQuery. This is to allow jQuery to play nicely with ...

View answer
2 answers
9 votes
20k views
How do I add JavaScript to a site?
Accepted answer
23 votes

The Managing JavaScript in Drupal 7 guide provides the information to add JavaScript to Drupal. The techniques presented there apply to both themes and (custom) modules: Add a scripts[] = somescript....

View answer
8 answers
12 votes
14k views
How to theme the views exposed form?
Accepted answer
22 votes

Theming Views' exposed form is hard because it doesn't behave like most forms and use its own label mechanism. So, you can't simply use a form_alter hook to add #prefix and #suffix to elements. But ...

View answer
2 answers
30 votes
5k views
How are drush and jenkins used together for continuous integration?
Accepted answer
21 votes

For my projects, I use a build script made of Drush commands in a Jenkins job. I use my Phing Drush Task project to run Drush from a Phing build script. This allow me to leverage the existing Phing ...

View answer
4 answers
17 votes
28k views
Adding extra fields to Site Contact Form
Accepted answer
20 votes

Expecting forms fields to be configured like content types is an over-generalization. Content types are for content (text, image, etc.) of the website, and more specifically, in Drupal, for nodes (the ...

View answer
2 answers
17 votes
5k views
How to create a hook?
Accepted answer
20 votes

You don't actually create hooks. You use helper functions such as module_invoke_all(), module_invoke() or drupal_alter() to invoke all functions matching the expected name pattern. The invoked ...

View answer
2 answers
17 votes
25k views
Understanding Drupal's session management and user authentication
Accepted answer
17 votes

Drupal supports external authentication. There are many alternatives authentication modules for Drupal, such as OpenID (included in core), OAuth Connector, or LDAP. Learn more about how Drupal ...

View answer
5 answers
37 votes
28k views
Is there a Drupal API function to get the list of nodes by type?
13 votes

There is no such API for Drupal 6. The closest you can do is to properly query for all node ID for the content type then load each one using node_load() but this will require n+1 queries and is not ...

View answer
13 answers
50 votes
21k views
How do I hide nodes that shouldn't be directly accessed from users and search engines?
12 votes

One option may be to never publish the node but have the consumer page ignore their publication status. So in your example, your "About" view may just ignore the publication status of your "About-xxx" ...

View answer
1 answers
6 votes
7k views
How to add id to a block
Accepted answer
12 votes

You will not be able to add an id or class attribute to the block in your hook_block_view implementation. At this stage you are not yet dealing with the markup of the block itself but only the markup ...

View answer
5 answers
11 votes
20k views
hook_preprocess_page(): how to tell a views page?
Accepted answer
12 votes

views_get_page_view() finds out what, if any, page view is currently in use. If it returns NULL, then the current page is not a views' page. But using drupal_add_js() and drupal_add_css() in a ...

View answer
2 answers
4 votes
4k views
What is a front page in drupal ($is_front)?
Accepted answer
11 votes

$is_front is set on any template from _template_preprocess_default_variables() (itself called from template_preprocess()). It uses the result of the drupal_is_front_page() function. ...

View answer
1 answers
3 votes
5k views
Image Styles Generate
10 votes

A derivative image is generated on the fly when served over HTTP. When the derivative image is requested in HTTP, if the file doesn't exists, the HTTP request is handled by Drupal. Drupal will use the ...

View answer
2 answers
2 votes
2k views
How to create a module wide variable that refreshes every page load?
Accepted answer
9 votes

The variable_set() and variable_get() functions are made to set/get a persistent variable. So they should not be used to persist data within a single page request. The drupal_static() function is made ...

View answer
2 answers
3 votes
3k views
How to change default registration form?
Accepted answer
9 votes

In Administration » Configuration » People » Account settings, uncheck the Require e-mail verification when a visitor creates an account. option. This will allow user to directly enter their password ...

View answer
5 answers
15 votes
16k views
How can I setup multiple database connections?
8 votes

In addition to retrieving a database connection to the external database using Database::getConnection(), you can also use dependency injection in your code to retrieve the connection as a dependency ...

View answer
2 answers
5 votes
5k views
Class Autoloading
Accepted answer
8 votes

Drupal 7 maintains a code registry and uses it for its classes autoloader. To populate this registry with your module's classes, you should add their files to the files[] entry in it's .info file: ...

View answer
6 answers
4 votes
3k views
How to find/download latest drupal version via bash?
8 votes

For all your command line and script needs there is Drush. To download the latest Drupal 7 with it, you simply do drush pm-download drupal

View answer
1 answers
4 votes
5k views
Add additional button to login form
Accepted answer
8 votes

You cannot alter a form from a theme's template.php file. You need to create a custom module for that. In this module, you can alter the login form in an implementation of the hook_form_alter() or ...

View answer
2 answers
1 votes
3k views
extend('PagerDefault') doesn't call pager_default_initialize
Accepted answer
8 votes

As documented on the See the Extenders page on drupal.org: To use an extender, you must first have a query object. From the query object, the extend() method will return a new object that should be ...

View answer
3 answers
8 votes
8k views
How to inject configuration values into services?
Accepted answer
7 votes

You can use a factory for your app.mailer service. The factory take cares of retrieving the configuration for the service. The service can stay decoupled from the configuration service and does not ...

View answer
1 answers
3 votes
3k views
How to post xml data in drupal_http_request? I have curl code of it
Accepted answer
7 votes

Seeing how drupal_http_request() is used in _xmlrpc(), something like this should do it. // The path to send the request $url = "http://example.com/API_PATH_HERE"; // Example of valid xml code; $...

View answer
2 answers
3 votes
5k views
Drupal 7 - databases other than mysql
Accepted answer
7 votes

Out of the box, Drupal supports MySQL (or an equivalent such as MariaDB), PostgreSQL and SQLite for its main database. With additional drivers it also supports Microsoft SQL server and Oracle Database....

View answer
2 answers
6 votes
6k views
Call Drupal PHP function from Javascript?
7 votes

To get data from Drupal's database and/or produced in PHP, you need a page callback (in a custom module) that output the data without the full layout rendering. This is easily doable by printing the ...

View answer
1 answers
6 votes
4k views
Drupal 7 with Mongodb
7 votes

You currently cannot use MongoDB for all your data. The MongoDB module clearly states what it can store in your mongodb: Cache, Field storage, Session, Watchdog, Lock, Block and Queue. This cover most ...

View answer
4 answers
6 votes
15k views
How can I create user profiles in drupal 7?
Accepted answer
7 votes

In Drupal 7, users accounts are fieldable entities like nodes. From Administration » Configuration » People » Account settings, you can add fields and configure their display on the user page (ie. /...

View answer
2 answers
6 votes
5k views
How to prevent displaying the theme on a custom page callback in hook_menu()
7 votes

You can use the delivery callback property of your menu entry to specify the function to be used to render the results of your page callback. The default delivery callback is drupal_deliver_html_page. ...

View answer
1
2 3 4 5
8