Questions tagged [7]

Version tags should be used for questions that apply to a version only, not to merely say what version a site is using.

Filter by
Sorted by
Tagged with
17
votes
5answers
9k views

How to programmatically list member entities of an Organic Group?

How can I programmatically get a list of member entities of an Organic Group? (I know how to get a list of group members using Views — I'd prefer to do this using the Organic Groups API, but haven't ...
17
votes
2answers
12k views

How can I detect when a node is changed from 'Published' to 'Unpublished'?

In hook_node_update(), I can easily tell the 'status' of a node (whether it's published or not) after it's been updated. However, is there an easy way to check to see if the updated node was ...
17
votes
3answers
27k views

Views exposed filter to search multiple fields [duplicate]

To my knowledge there hasn't been an option in drupal 7 to create a single exposed filter in a view which searches multiple fields, while in previous versions there existed modules to do just that. ...
17
votes
5answers
17k views

How I can delete all node/field revisions?

I have a drupal 7 sites, where it keeps node and field revisions. I keep revisions for the case where by mistake a new faulty version is saved and I want to revert back. But, now I want to clean and ...
17
votes
5answers
15k views

Add JavaScript files to the administrative pages

How do I add JavaScript/CSS files in every administration pages, using a module?
17
votes
9answers
25k views

How can I create a view of child nodes based on the menu relationship?

Say you have the following pages in a menu tree: Projects Project One Project Two Project Three I'm looking for a way to create a view that will be embedded in the Project (parent) page that will ...
17
votes
7answers
6k views

Change the input format for 3000+ nodes

I have a lot of nodes that need to get their input format changed - I could do that by hand, but then I won't be done before Christmas 2014. Where is Drupal storing that information? How can I ...
17
votes
1answer
14k views

How to programmatically create new user with custom fields?

I want to create user with some custom fields. I have created extra fields through config > people > site information > manage fields and fields like first name, last name, city etc. I want to create ...
17
votes
4answers
28k views

Adding extra fields to Site Contact Form

This seems strangely difficult to me. What I thought would just be a case of adding extra fields a bit like adding fields to Content Types. But no. I can't locate any facility to add say a phone ...
17
votes
4answers
13k views

How to use a views contextual filter OR?

After browsing the net and SE for a while it appears to me there is no good solution to combine 2 contextual filters with OR (rather than the default AND). This post mentions a PHP hack and this post ...
17
votes
4answers
5k views

How to hide “Manage Fields” and “Manage Display” tabs

I'm making a website with Drupal 7, and I was looking through the permissions for Taxonomies. I wanted to give the website maintainers a central place to manage the vocabularies and add terms, sort ...
17
votes
3answers
19k views

How to remove certain meta tags?

How can I remove these tags from my pages in Drupal 7? <link rel="shortlink" href=" .... " /> <meta name="Generator" content="Drupal 7 (http://drupal.org)" /> <link rel="canonical" ...
17
votes
2answers
5k views

How to create a hook?

How can I create my own hook (similar to the ones Drupal core creates) for other Drupal modules to utilize?
17
votes
2answers
25k views

Understanding Drupal's session management and user authentication

I have a requirement where, I have to replace the default user authentication with the authentication of a central server i.e. SSO server. By debugging Drupal I came to know that all the session ...
17
votes
3answers
6k views

Drupal 7 & jQuery — the $ dollar sign

If I'm not planning on using any JS libraries other than jQuery, is there any reason to need Drupal's call to jQuery.noConflict() which removes $ as an alias for jQuery? Assuming there is no need for ...
17
votes
3answers
4k views

What's the fastest method/implementation for an Ajax callback?

I have a map which loads markers via ajax on various/numerous map events. Currently, I define a custom page callback for my hook_menu() item which prints my json/js. Since my page callback does not ...
17
votes
9answers
10k views

How can I remove items from the allowed values list of a select field that has data for the values?

I've created a content type that has a list / select option field, and I've entered the key|value pairs as necessary for the select list to function. Data has been entred, and it's been decided that ...
17
votes
5answers
8k views

How to Filter view by comparing 2 fields. If field-a < field-b

I have a product content type that has 2 price fields. I want to create a view that shows all products where price-A is less than price-B. I was hoping I could just add a filter and select price-A ...
17
votes
3answers
3k views

How to handle / cleanup obsolete aggregated css / js?

I'm only using Drupal 7 built in CSS / JS aggregation, however the files folder where the css.gz and js.gz files live are filling up at a fairly rapid pace, and while I'm sure it'll be a while before ...
17
votes
1answer
5k views

How to expose non Drupal tables in Views?

I wonder what is the best way to allow the Views module to access external tables not in Drupal? I tried the Data module, but it doesn't allow for a datetime datatype.
16
votes
3answers
16k views

How to programmatically remove a field from a node?

How does one remove a field from a node programmatically? I have a migration in hook_update_N that moves the contents from a a field into a custom table. After that migration, I want to remove the ...
16
votes
7answers
8k views

How can a module detect when the “access denied” page is output?

How is it possible for a module to detect when Drupal is outputting the "access denied" page? I know how to do it with Drupal 6; I need to know how to do it with Drupal 7.
16
votes
2answers
12k views

Override html.tpl.php per node type

In my template.php file for my theme I have tried the following: function media_preprocess_page(&$vars, $hook) { if (isset($vars['node'])) { // If the node type is "blog" the template ...
16
votes
5answers
13k views

After deleting all nodes, how do I reset the node ID to start from 1 again?

I generated tons of dummy content for testing, and then deleted them all. As nid is auto-increment, newly created node will have a nid of last created nid +1. How can I make nid start from 1 again?
16
votes
7answers
8k views

How can I get more than 10 search results on one page in Drupal 7?

By default search page shows only 10 results. How can I change it to display unlimited number of results?
16
votes
2answers
23k views

How to publish unpublished nodes programmatically

I have some unpublished nodes, for which I have their node IDs. How can I programmatically publish them? Is it correct to achieve it in custom module using a query like the following? db_query("...
16
votes
5answers
32k views

Add JavaScript at the bottom of a page

How can I add JavaScript scripts to bottom of a page, in my template?
16
votes
3answers
6k views

Can TableSort be used without a query?

In my module, I'm using TableSort for some of my tables, but I also have some tables that are generated by code, so not directly linked to a query. These tables are also created with theme('table') ...
16
votes
1answer
12k views

How can I concatenate two fields in a view?

I have a view set up to use the unformatted list type. I'm pulling in about 10 different fields, but would like to concatenate two of them onto a single line in the display. Is this possible? Example:...
16
votes
4answers
14k views

Properly bootstrap drupal for standalone PHP file?

This is what I have right now: <?php define('DRUPAL_ROOT', '/var/www/clients/client1/web15/web'); include_once(DRUPAL_ROOT . '/includes/bootstrap.inc'); drupal_bootstrap(...
16
votes
3answers
19k views

Removing main content block on frontpage

I'm new to Drupal 7 and I'm looking to replace the frontpage's default main content block with an equivalent block generated from Views (gaining more control over the block in doing so). I have ...
16
votes
3answers
14k views

Given a File ID (fid) how can I get the HTML that represents that fid?

I'm looking to do something like this $fid = 15; $file = (array)file_load($fid); $content = drupal_render($file); echo $content; file_load() drupal_render() And specifically this fid is from the ...
16
votes
2answers
23k views

How do I alter the form submission handler?

For some reason I need to replace some characters (if exist) in every single textfields in any form just right before they stored in database. In other words I need a hook in which I could get all ...
16
votes
5answers
7k views

How to restrict access to the site during development?

I am creating a new Drupal 7 based site. The development will be on a server that is publicly accessible. I am working in a multi-site environment. I would like to totally block access to the site ...
16
votes
1answer
730 views

Drupal calling “is_dir” over 4000 times?

After having troubles on loading time of a very important Site I installed XHPROF and looked over the statistics to see where I can improve my code. I found something interesting that i don´t ...
16
votes
4answers
19k views

Is there a common nginx conf for Drupal 7 sites?

I've taken a look at Perusio's drupal-with-nginx repository and while I think it's impressive how extensive it is, it may be a little too advanced for me at the moment, plus I have several Symfony2 ...
16
votes
4answers
16k views

Best practice for third-party PHP class-based library

I am currently working on a module that requires a third-party PHP library, which is essentially a single PHP class. Normally, I would place it in an includes/ subdirectory and add files[] = ...
16
votes
2answers
2k views

Best practices for implementing custom caching?

For every instance of every type of entity, I generate a number of caches, named something like: [module_name]__[entity_type]__[entity_id]__[string_depending_on_where_the_cache_came_from] Now ...
16
votes
4answers
24k views

Advanced menu theming in Drupal 7

I've cruised around the web and it is not at all obvious how to theme custom menus. I've looked for hours and have not found one single post that illustrates the process, from start to finish, of ...
16
votes
6answers
12k views

Update all nodes with a default field after adding a new field to the content type

I have an existing content type with a number of nodes. I have just added a new boolean field with a default value of "off." However, until I re-save each node the default value is not set, so a ...
16
votes
1answer
24k views

How do I override the default page.tpl.php?

I have one page in my D7 website with significant deviation from the rest of my pages. In this page I will only display a limited number of regions and in a different layout. What is the best way to ...
16
votes
1answer
1k views

Is there a way to do concurrent editing?

Is there a MediaWiki-like method for supporting concurrent editing of text bodies in Drupal 7? If no feature currently exists, what are some decent PHP diff libraries that could be wrapped up by a ...
16
votes
2answers
3k views

How to implement field formatters for entity properties

I created a custom entity using Entity API that has certain properties defined in hook_schema() and also declared in entityPropertyInfo(), a class extending EntityDefaultMetadataController. So far so ...
16
votes
2answers
11k views

Change $form_state in AJAX callback

I am creating a form which uses the form API '#ajax' attribute, and I need to make changes to $form_state when the AJAX-enabled button is pressed. Here's what I've got: Inside my form builder ...
15
votes
2answers
13k views

How to get All options of a 'select' field?

How can I get all options for a cck field? For example, There is a field with 3 options in allowed values, like option1, option2, option3.Is there any function which receive the field name and ...
15
votes
4answers
26k views

How do I get the raw URL as a field in Views?

In views I need to return the raw url that is provided as the href value to the title field (when as a link) or the Content: link value. I thought originally I could choose Content:link and strip the ...
15
votes
2answers
6k views

Need a simple Google Maps solution; lost in the labyrinth of modules

First of all, let me just state that I don't care which version of Drupal I'd have to use (6 or 7). I have experience with both versions I just didn't need to work with Google Maps till now. The ...
15
votes
1answer
14k views

How do I update core to only include security patches?

I have a old Drupal 7 installation and I would like to update my Drupal 7 to the latest release, but I know for a fact that some of my custom module will break on the latest update. All I want ...
15
votes
7answers
14k views

Which newsletter module will fit my requirements?

I'm trying to implement a newsletter for my users to subscribe to and I'm noticing that there are a lot of different newsletter modules out there. I'm was looking for one that will easily allow me to: ...
15
votes
3answers
2k views

How to implement a reputation based system with badges in Drupal similar to StackExchange sites?

Earning badges on StackExchange is, well, fun. But aside from that it promotes quality interaction from users and helps weed out spam (I have never seen a spam post on the site). I have a community ...

1
3 4
5
6 7
530