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
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
3answers
22k views

How to get rid of Deadlocks and Lock time out type issues?

I read multiple blogs, tried to google, it but didn't find any satisfaction from any solution. I have the following issues : PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found ...
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
12k 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
18k 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
24k 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
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 ...
16
votes
3answers
15k 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
6answers
17k views

How can I run PHP code without writing a module?

I need to attach a field to some bundles. A PHP snippet will do the job for me, so I don't need a module.The below snippet is what must be executed : $field_name = 'field_custom_image'; // Create the ...
16
votes
9answers
8k views

Is there a way to hook on cache clearing?

For a big institution website, with heavy caches, I'd like to generate caches as soon as possible, so that no user may arrive on cache generation... I have a cron set all minutes that does it, by ...
16
votes
7answers
7k 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
12k 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
11k 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 ...
16
votes
3answers
25k 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. ...
16
votes
1answer
11k 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
11k views

How to logout all active users?

Instead of putting my site in "maintenance mode" I would like to put it in a complete "readonly mode". There is a module for that, however, it only prevents "node add and edit". I would like to ...
16
votes
4answers
13k 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
2answers
22k 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
726 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
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
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
9answers
9k 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 ...
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
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 ...
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
10k 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 ...
16
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.
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
25k 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
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
5answers
31k views

Add JavaScript at the bottom of a page

How can I add JavaScript scripts to bottom of a page, in my template?
15
votes
2answers
22k 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("...
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 ...
15
votes
7answers
12k views

theming checkout pages in Drupal commerce

how do I theme the cart and checkout pages in Drupal commerce? I have set content, account, billing, and payment parts. Is there any --.tpl.php file to create?
15
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') ...
15
votes
5answers
7k views

reseting the hook_update_n status of a module

I'm extending a module I've previously written and it needs some schema changes which I implement in hook_update_N. I've updated the module's version from 7.x-1.0 to 7.x-1.1 and implemented the ...
15
votes
2answers
9k views

Views exposed filters without “Apply” button

I have created a view with exposed filters of term select list. How can I make the select list to work directly on selecting an item, instead of clicking on the "Apply" button?
15
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 ...
15
votes
1answer
8k views

Difference between Field and Field Instance?

When we go to the path /admin/structure/types/manage/article/fields and use the Add new field option or the Add existing field option, does that create a field, create a field instance or attach a ...

1
3 4
5
6 7
528