How to create a view with group by node title and no grouping on nid

If you display nodetitle as a link it won't show as a duplicate. Uncheck 'display as a link' in fieldsettings of title and you should be good to go.

I imported your view, made this change, created a duplicate titled page and my view showed duplicate results immediately grouped by title, displaying the nodecount of that title.


Drupal 6 Can I use subdomain, for the dev instance of a site and use multiple site configs

Short answer is: if example.com exists in the sites folder and a settings.php file is inside it, that file will be selected to serve any request directed to *.example.com.

Long answer is:
let's say an url such as "an.example.com/something" is requested and such request reaches Drupal, here is what happens:

Does a settings file exist in a folder named an.example.com.something (inside the sites/ folder)?
Does a settings file exist in a folder named example.com.something?
Does a settings file exist in a folder named com.something?
Does a settings file exist in a folder named an.example.com?
Does a settings file exist in a folder named example.com?
Does a settings file exist in a folder named com?
Serve the default website.

If at any point of the process the answer to the question is yes, then that file is selected as the settings file.
Of course it will work with more complex subdomains and also more complex paths, as well as port numbers. Have a look at the official Drupal documentation on multi-site and at the conf_path() function for more details.


Can you retrieve the Omega breakpoint settings?

For anyone interested in the answer to this, it's retrievable but if you want to use it for adding your own stylesheets in at the same breakpoints (like I did) you have to do it in the template.php file

This is what I did

$theme = alpha_get_theme();
$layouts = $theme->grids['alpha_default']['layouts'];
$keys = array_keys($layouts);
for ($i = 0; $i < 3; $i++) {
    return $layouts[$keys[$i]]['media'];
}

This will return (or print, whatever you want it to do) the media-queries/breakpoints to use for your own sake.


How to pass value generated in the form submit function to another function?

You can store that information in the user session. There is always a redirect after a form submission so you need to persist it somewhere because PHP is a stateless.

Simply add your data to $_SESSION['yourmodule'] and then in the mainpage() function check if something is there and display it.

If that information is not temporary and must be there on the next visit too, persist it in the database in a custom table.


Whenever new user registered, how to make them active based on some condition automatically

Using PHP on admin end is not recommended. If you are interested in custom module here are the pointers

Implement hook_user_presave : Invoked when a user is created or updated.
Make sure your code inside presave hook is conditional for new account created but not updated. You can use in_new property of account object

if ($account->is_new) {...}
Use Entity Field query to find a node with email id of current account being created
if you found a result then Set $edit['status'] as 1.


You want to modify a user_register variable and set it to 0.
You can set it in code:

variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);

by drush:

drush vset user_register 0

or directly in database (note that in variable table are stored serialized values):

UPDATE variable SET value = 's:1:"0";' WHERE name = 'user_register';

but this requires cleaning cache.

DELETE FROM cache_bootstrap WHERE cid = 'variables';


I don't think Drupal has a function for that specific case - at least not one that I've come across.

Obviously lots of ways to accomplish it though. Without writing your own function, my thought was to make use of the format_string() and url() functions.

$args = array(
  '@arg_1' => 1,
  '@arg_4' => 19,
);
$path = format_string('node/@arg_1/edit/something/%arg_4', $args);
$url = url($path, array('absolute' => TRUE)); // I used absolute here because
                                              // your example has an absolute
                                              // path. It shouldn't be
                                              // necessary though.
print $url // Prints `http[s]:[domain.com]/[base_path]/node/1/edit/something/19`

Of course, you could take that a step further and use the l() function to create an actual link, but I'm not sure what your exact use case is.


You can install drush to latest version or specified version.
I prefer drush 7, you can make this, first uninstall the current version of drush of your server.

i use debian, then i install with

sudo apt-get install drush

and you need remove

sudo apt-get remove drush

and later install again with composer

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo ln -s /usr/local/bin/composer /usr/bin/composer

sudo git clone https://github.com/drush-ops/drush.git /usr/local/src/drush
cd /usr/local/src/drush
sudo git checkout 7.0.0  #or whatever version you want.
sudo ln -s /usr/local/src/drush/drush /usr/bin/drush
sudo composer install
drush --version

and ready to use drush version 7


If a simple sign up you are looking for, have you tried Entity Registration? https://www.drupal.org/project/registration. Works similar to Signup module


Where is $page['sidebar_second'] rendered? I want to edit the style of the  listing of the recent comments

I think you have to look in how theme works in Drupal. However, as per your question, $page['sidebar_second'] is the variable that stores the region "sidebar_second".
This region doesn't have any specific styles and this goes for all the other regions as well. If a block is created in your system it needs a region to be displayed. So The blocks are always assigned to the desired regions.

If you want to style the block then you have to find the candidate files via devel & devel_themer module and then in the theme directory have to create the file and style. Also if you are not wiling to do that then write a overriding css for your theme that will override the styles like,

.class-name {
   padding: 15px !important;
}

But I would recommend not to use !important unless its really needed.


"Notice: Undefined index: und in include()"

The line that is causing that error message is the following one.

<?php if (($type == "article") && ($node->field_add_taxonomy_tag_articles[$node->language][0]['tid'] == 26)): ?>

'und' is the value for the constant LANGUAGE_NONE, which is used for $node->language, when the node is language-neutral.

When you want to obtain the value of a field, you should use field_get_items(), as in the following code.

<?php $items = field_get_items('node', $node, 'field_add_taxonomy_tag_articles'); ?>
<?php if (($type == "article") && ($items[0]['tid'] == 26)): ?>


REST API Guzzle POST gives timeout but the same call works if I run it on the server cli

Okay turns out it was xdebug. I had to allow more simultaneous connections in the PHP Debug settings of PHP Storm.


How do I make rows of views blocks on a basic page reacting collectively to an exposed filter?

Views Attachments Displays have the option to inherit the exposed and contextual filters from the Views displays they're attached to. So you can try to create one Views Page Display with some of your results, then create as many Attachment Displays (not Block Displays) as you need and attach them to the Page Display.

I haven't tried the Layout Builder with different Views displays like that, but I think it may work to rearrange them a bit.

I think you could also have Views Blocks (that are on the same Views) share the same Exposed filter settings (don't override them), and use the Exposed filter in a block option where you place the exposed filter part of Views as a block in a theme region instead of always appearing it automatically above the Views results.

You may also want to check out the Views Global Filter module that affects all Views exposed filters once a user chooses one option.


Commerce equivalent of Signup, Pay Per Node, etc

Here are a few links that might get you started.  Drupal commerce is a lot more powerful than Ubercart, because everything is fieldable you should be able to make your event signup product include any fields you wish to collect.  I'm not sure what you mean by print-on-demand fundraiser but hopefully this gets you heading in the right direction.

http://vimeo.com/31459435

http://mustardseedmedia.com/podcast/episode51

~Mark


How to insert value to user entity custom field while creating new account?

The hook_ENTITY_TYPE_insert in case of entity user expecting Drupal\user\UserInterface instance not Drupal\Core\Entity\EntityTypeInterface

change your hook to:

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function MYMODULE_user_insert(Drupal\user\UserInterface $user) {
  $user->set('field_custom_referral', '3');
  $user->save();
}


Problem with Aggregate CSS files option and tmp directory

As per Drupal PHP requirements, safe mode should be off.

It will interfere with file uploads and possibly email sending as well.

You'll probably find you need, in all the .htaccess places with:

Options +FollowSymLinks

to change to

Options +SymLinksIfOwnerMatch

In any case, if you can't disable PHP "safe mode" which, according to php.net is deprecated

  Safe Mode
  This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP
  5.4.0.

and the other options don't work - you may need to consider using another webhost.


Is it possible to include extra arguments when migrating via command line?

In the URL below you can find Dush arguments for migrations. Following the documentation you need --idlist argument.

See here https://www.drupal.org/node/1561820

Hope that helps.


Is it possible to render a twig template for "later use"?

Normally you don't render twig templates directly, but build the content in a render array and use the render service:

public function nodeExportPdf(NodeInterface $node) {
  $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
  $build = $view_builder->view($node, 'full');
  $html = \Drupal::service('renderer')->renderPlain($build);
  ...
}

This will use the node template configured for the view mode you specify in the view builder. In this example full, but probably you want to create a custom view mode for the pdf.

When you are in a controller you get the route parameters in the function arguments. How to build the route for this see https://www.drupal.org/docs/8/api/routing-system/using-parameters-in-routes


How come my views suddenly take full width?

Though it is cut off in the screenshot you have above, the spitfire.jpg image is forcing that cell to 968px wide (968x478) which is larger than your main cell.

This is more a CSS question than a Drupal one so to bring it back to Drupal, I would recommend that you create an image style for this imagefield so that all images are resized according to the width of your main cell. Check out the image module documentation for guidance on how to create styles, you would then just need to tell views to use your new style for your view. Alternatively, you can use one of the existing styles (ex. thumbnail, small, medium, large) to have views display an image that would fit on your page:


How do you perform a rules action by the quantity of a specific commerce product?

The quickest way to do this is with another custom action. Since you already wrote your own module, this shouldn't be a problem.

In your my_module.rules.inc file, do something like:

function my_module_rules_action_info() {
 return array(
  'my_module_loop_based_on_qty' => array(
    'label' => t('Execute a loop based on a quantity'),
    'parameter' => array(
      'quantity' => array(
        'type' => 'integer',
        'label' => t('Quantity added to cart'),
      ),
    ),
    'group' => t('My Module'),
  );
}

function my_module_loop_based_on_qty($qty) {
  // Loop based on the $qty variable
}

Provide whatever other parameters you need for the function as well. You can then pass it the quantity when you create the rule. That other rules action you already wrote can just be wrapped in a helper function that is then called by this new action.


tb mega menu is not showing in bootrap theams in drupal7

I have refer you to below links :

LINK1
LINK2
LINK3


Does the Transliteration module alter the existing URLs?

The Transliteration module doesn't update anything on its own. It's the Pathauto that controls that. Just enabling the Transliteration won't do anything.

Pathauto module has a setting for what happens when an entity is updated (/admin/config/search/path/settings). This means that when you edit existing content Pathauto may change the alias depending on your settings.

You can set it to Do nothing. Leave the old alias intact. This way you'll be able to edit old content without the alias being automatically changed.

If you need to use some other Update action setting you'll have to remember each time when editing an "old" node to untick the option Generate automatic URL alias and use the "old" alias manually.


How to disable multiple cardinality for a custom field

Just alter the cardinality selection with this hook and provide only one value:

function <my_module>_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#field']['type'] == '<my_field_type>') {
    $form['field']['cardinality']['#options'] = array(1);
  }
}


I actually had the same problem with a Drupal 8 site.

I know this is unlikely to sound like a problem, but I can think of at least one situation (the situation I am in!) where it is.

We have the CMS setup so that the admin interface is in the users preferred langauge (a request by the client) so they can copy-paste translated content in whilst keeping the admin interface in a language they can understand.

However this creates confusion, as \Drupal::languageManager()->getCurrentLanguage() returns the langauge the admin system is using, not the lanuage the content is in.

The easiest way I found around this was to do the following:

$node = \Drupal::routeMatch()->getParameter('node');
$currentLanguage = $node->langcode->value;

(if anyone is curious as to why $node->langcode->value works, this question has some good answers: How to get the property of a content object in Drupal 8)

This literally gets the current node you've viewing, and then the language the node is displaying in.


In Drupal 8 how do I get the image path from a twig node template?

Ok, after writing this question a similar one showed up and I think I found the solution:

{{ file_url(node.field_hero_image.entity.fileuri) }}


Add an extra to the price of the product

We've covered this concept before in our "pizza store" tutorial, though it appears the video may not be online any more: https://drupalcommerce.org/videos/tutorials/customizable-products-pizza-store

The steps would be the same, though. I'd basically add a price field to the taxonomy vocabulary and then include the upcharge in the price field for the options the customer is selecting. Rather than using this taxonomy as a product attribute, you'd put it on the line item type as a custom line item field. Then you'd create a pricing rule that evaluates the fields on the line item type to look for a value in the upcharge price field and adds that amount to the unit price of the line item.

This is about as in depth as I can go on StackExchange. To learn how to use any of those particular features outside of getting this recipe, you should find real-time support at a local meetup or else in the Drupal Slack #commerce channel.


Set up Drupal to use alternative nodes for different incoming urls?

You could use the mod_rewrite features in your site's .htaccess to redirect before Drupal even gets started. This would increase performance vs. using JavaScript.

Implementation details:

https://stackoverflow.com/questions/5151385/redirect-on-the-basis-of-referer-http-referer-htaccess

More about Drupal's .htaccess:

http://drupal.org/getting-started/clean-urls

Contents of Drupal's .htaccess:

http://drupalcode.org/project/drupal.git/blob/HEAD:/.htaccess


How to check a checkbox by default in forms api

See below example...

$options = array();
$options["1"] = "One";
$options["2"] = "Two";
$options["3"] = "Three";
$options["4"] = "Four";

$form['ios'] = array(
  '#title' => t(''),
  '#type' => 'checkboxes',
  '#description' => t(''),
  '#options' => $options,
  '#default_value' => array("1", "2", "3")
);


Blank page when trying to add new content

There was something wrong with my database. I had to delete it and reinstall my backup.


According to this post by the Drupal Security Team, it is not considered a vulnerability:

Disclosure of usernames and user ids is not considered a weakness

  Drupal's philosophy

  Usernames are an important part of online identity. Having a public username helps other users of a site to know the identity of the person they are interacting with in a forum or a blog. Drupal is primarily intended to be used for sites where identity and interaction are key elements so it is reasonable for that information to be public.

Of course, it will vary by site, depending on what that information allows other users to see.


Different theme of Media module audio player in Firefox and IE and chrome

If I am not mistaken, these are the native displays for the HTML5 <audio> element in different browsers. I don't think the Media module has anything to do with it, it probably only displays the markup without adding any theming.


How can I set up an a SQLite memory database to improve PHPUnit test speeds?

On Linux, we use sqlite://localhost/dev/shm/test.sqlite where /dev/shm is memory mapped


Creating a relationship between taxonomy lists

There are other ways to do this, in Drupal there are always other ways.  But before you try to implement a solution, ask the question 'what will I want to do with the information besides a direct look up' of say Corvette, year, motor size.  As soon as you find something else you want to include, say various models in a year - coupe, convertible, etc.- or information on colors, performance, displacement, maximum this and that,  you will find yourself redesigning that taxonomy again.  Drupal is a Content Management System and is entirely contained in the database.  Instead of laying out a taxonomy, work on the design of your database.  When you have a good structure for that, start creating fields and use the Views module to generate the content in whatever form you desire. Views is basically a UI for database queries with some great Drupal flexibility for assembling and displaying the content.

I hope this is helpful. By the way, Drupal is complicated.  It is very powerful and has a bit of a learning curve.  That's why this site has been successful.  Three months ago, I couldn't even spell Drupal, now I can :)

As you get going, come back to this site for more help.


how to hide articles page from home page in drupal

you have to untick "Promoted to front page " on structure / content types / your content types / publishing options, for every content type you have.


Helper to get the raw value of a node field?

The only thing I know is field_get_items().

Your function makes a lot of assumptions that don't work for a core function.

Not all fields are prefixed with field_, only those created through the UI. body for example not.
Some fields have multiple values, your function only returns the first.

If you want a function that makes these assumptions, you could write a simple wrapper for field_get_items() that takes care of that.


How do I create a hidden field programatically?

I don't follow the example 100%, but to answer the question - in D7 you can set '#type' => 'hidden', '#value' => 'foo' or just do '#my_custom_key' => 'my custom value' and it will be available to you in the submit handler (or elsewhere, such as hook_field_attach_submit()).


Can admins create new accounts without passwords?

There is a module that does this.

Check out Generate Password.

It introduces this additional setting in Configuration » People » Account settings:

  Users may enter a password on registration. If left empty, a random password will be generated. This always applies when an administrator is creating the account.

Then, when creating the account, leave the password field empty, but make sure you also check this checkbox on the "Add user" page:

  Notify user of new account

The result of these two settings is that the module generates a random password when the administrator creates an account, and the user is sent an email with a notification about the account and prompted to set a password in the one-time login link that is included in the notification.

If you want to learn how it is done, read the source code.


How can I customize the display of messages sent with privatemsg?

I've just implemented the Privatemsg Panels plugin with the D7 Patch through the pm_existing_pages plugin and it's working quite well! Here's how it all goes down for Drupal 7:

Grab the master branch of the privatemsg_panels module and upload to your modules directory
Patch Manager is super handy - install it and run the panels_privatemsg7.patch file to upgrade the module to a 7.x branch (or patch by hand or drush or eclipse etc)
Optional: Install PM Existing Pages and add override the default /messages/ path with a new panel. Of course you could create a new panels page just as easily.
Add content to your panel - Privatemsg should be a menu item now:
Create a nice little custom link block from the instructions over here - might be useful for your particular view!
Optional: override privatemsg-view.tpl.php for a more custom layout. I haven't quite got this far, will try to remember to update this when I give it a shot.

Edit - Adding info!

Overriding privatemsg-view.tpl.php works great, just remember to clear the cache after you add the file to your theme folder.
Take a look at the Privatemsg Theming Documentation. All of  the functions that start with phptemplate_ can be overridden by your own theme. Example: drop this into your template.php file

function YOURTHEMENAME_privatemsg_list_field__participants($variables) {
    $thread = $variables['thread'];
    $field = array();

    if ($thread['has_tokens']) {
        $message = privatemsg_message_load($thread['thread_id']);
    }
    if (!isset($message)) {
        $message = privatemsg_message_load($thread['thread_id']);
    }

    $participants = _privatemsg_generate_user_array($thread['participants'], -4);

    $field['data'] = theme('user_picture', array('account' => $message->author));
    $field['data'] .= '
'. _privatemsg_format_participants($participants, 3, TRUE).'
';

    $field['class'] = 'privatemsg-list-participants';

    return $field;
}

This will add a user picture to the recipients field! AWESOME! Just remember that each overridden fuction expects to have 3 things returned: a field, a header theme pattern, and a field theme pattern - the documentation explains it better than I can ;)
The functions at the Privatemsg Theming Documentation starting with theme_ can be overridden using a function YOURTHEMENAME_form_alter() hook. If you add this function to your template.php, drop dsm($form_id); dsm($form); in to get a better idea of exactly what form you're working with.
Looking to change column order around? It's easier than you might think - check out the drag-and-drop column order at /admin/config/messaging/privatemsg

There has been a bit of discussion about how to add custom columns to the output but I'm not there yet.. I'll have to point you at the Privatemsg Issue Queue for that one.

Good luck!


Group Views results by split year (academic, fiscal, etc.)

Use Grouped Exposed Filter

Using a Grouped Exposed Filter for the Authored on field is the quickest and easiest way to filter out by academic year.

When you Expose a Filter, you can choose between Single filter and Grouped filters:

If you choose Grouped filters you can define your own items for the Exposed filter. In your case two academic years would be configured like this:

I haven't included time but you probably should to make sure that content created on July 31 and August 1 doesn't get exluded. Maybe something like 2017-08-01 00:00:00 and 2018-07-31 23:59:59 would work.

Add as many entries as you have academic years. Then when viewing your Views results choose the appropriate academic year option:

I've noticed grouped filters have some bugs in D8 when dealing with taxonomy terms, but I haven't noticed any problems with AuthoredOn field.

Contextual Filter Content: Created year + month

If you include this Contextual Filter and choose to Display a summary:

you get links of months and years you click through to see content posted within those dates:

If that alone isn't enough maybe that can inspire you to create a similar custom Contextual filter with a bit more logic inside to do the same but for a configurable set of periods.


Depends on your understanding of reasonable. Until hierarchical select or similar modules become available you could save the parent terms programmatically on node save - the code probably wouldn't exceed 30 lines or so, especially when you don't have many taxonomy fields where you want to do this.

You can access a term's parents with the following code utilizing TermStorage:

$parents = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($termId);

Then you only need to go recursively through the tree and grab all parents (if your terms can have more than one), get their ids and set them in the node you want to save.


Storing additional data with a node reference

Have you looked at CCK3 for Drupal 6? It's not stable yet, but the package does contain the Multigroup module which may be exactly what you need. A 'multi group' is a group of cck fields which can be repeated just like normal multi-value fields can. This means that you can group a node reference field with a text field and repeat that combination as many times as needed.

If you decide to give it a try, I recommend that you create a test site first to check if Multigroup and the rest of CCK3 is stable enough for your use case and to make sure that it doesn't interfere with other modules you need.


Get page title of view and panel page via url

For pannel you can pass the page title in url
let say xyz/page_title
then add content to panel and choose New custom content in the body field your code will somewhat look like

<?php
  $title = arg(1);
  drupal_set_title($title);
?>

check screenhot for better understanding:

For views its a simple 2 step process
step1: Set the view path to take the title as wildcard
i.e. your view path will be view_path/%

step2: now change the title field on views to use the title wildcard by changing it to %1 as this is the first argument in the url

hope it helps you :)


Uploading files to two separate locations

I very much suggest a solution which actually shares the files/ directory.
My primary recommendation here is some dedicated hardware. To avoid marketing for anyone in particular, I just recommen you read, on Wikipedia, SAN and FAN.

If hardware is out of the question, then we have good experience with NFS for direct sharing. Samba on the other hand has proven to be to slow.

There is also a "native" Drupal solution called Storage API which can do a lot of neat things with your files, but I don't think your particular needs can be solved out of the box, but would require some extra coding.

I would only use some type of syncing as a last resort, but here's a really basic bash-script you could cron run. The major part of this script is a safeguard so it will refuse to start if it's already running.

#!/bin/bash
LOCK_FILE=~/.lockfile

if [ -f "${LOCK_FILE}" ]; then
  PID=$(head -n1 "${LOCK_FILE}")

  TEST_RUNNING=$(ps -p ${PID} | grep ${PID})

  if [ -z "${TEST_RUNNING}" ]; then
    echo $$ > "${LOCK_FILE}"
  else
    exit 0
  fi
else
  echo $$ > "${LOCK_FILE}"
fi

rsync -az local_files/ username@host:/remote/path/to/files
rm -f "${LOCK_FILE}"

exit 0


Is it possible to Insert a view in a content type in drupal 7?

The Entity Views Attachment module is the successor of the Views attach let you attach the output a view to the content of any entity.


How to lock distros so they can only be used on 1 URL?

I see 2 possible approaches (there might be others):

Include "something" that requires an API key, whereas 1 such key can be used on 1 URL only.
Offer a "hosted" version only, which uses your distribution. That way you don't have to ... "distribute" the distribution.

PS: Drupal is GPL, so before creating something that is based on Drupal, make sure you do understand the legal aspects of GPL ...


Escaping CSS digits, 0 is removed from CSS aggregated files

I think the code is valid.
Anyway due to lack of time i decided to ad an "id" to the class. So the html is now

Text

And the css
.iconleft.id-109,
.iconleft.id-112,
.iconleft.id-110,
.iconleft.id-111,
.iconleft.id-120 {
  background: #B0CD00;
}

This is working for me.
But if somebody knows why aggregation removes the "0" please let me know.


Multiple template pages when creating new pages

Option 1:

The simplest "core" way to do this, is to create two separate content types.  For this example, let's call one One Column and the other Two Column

You can now create two different node template files:

node--one-column.tpl.php
node--two-column.tpl.php

Now you can customize those two template files to display the content however you wish, and it would depend on what you want to accomplish with each of these.

Option 1a:

If you decide to go with option 1, using Paragraphs to allow your users to add multiple fields into the columns could be well suited to your needs.

Option 2:

Another option is to use Display Suite which has the similar idea of creating multiple template files, but here you can choose the display method on a per node basis (via Display Suite Extras)  Also since you are using Bootstrap, there is a nice add-on called Display Suite Bootstrap Layouts that provides layouts for you to use.

Option 3:

Panalizer allows you to use "Panels" on a per node basis, which could help you solve this problem. There is also a Panels Bootstrap Layouts module as an add-on.

Option 4:

I believe Panopoly can do this as well.

Summary:

There are many different ways to do this, but you will have to try them out to see which works best for you.  The options above are probably the most common so I'd start there.  If you need anything more specific for your needs, there is always a way.


Taking check box option and turn into select list

you could do that in your module, try to implement hook_node_view and get the values of the node variable, and then do your changes.

Im pretty sure you dont want to save those values from the select list, just show it in an another matter, no?


You need a Date filter. If you have the Date module enabled, you can activate the Date Popup widget to allow users to easily select dates. (The popup may only work on the Page display, e.g. http://yoursite.com/archive)

Choose the 'Date: Date (node)' filter.  Set the Operator to 'Is Between' and set the value type to 'An offset from the current time'. Using your example, you can use '-4 months' for the Min value and 'now' for the Max value.

Finally, click 'Expose' to show the date filter to your users.


New Modules Not Listed at admin/build/modules

Check the following:

Are the uploaded modules correctly unpacked? No .tar or .zip endings?
Does the problematic module contain its .info file and are you sure the module is D6 compatible?
Is the module placed into the correct folder where you keep all contributed modules?


That should prove easy to do with Views PDF. It is easily customisable compared to other PDF modules.
However if you're planning yo do complex reports that is one thing drupal doesn't excel in.


Check access to entity for logged in user in Drupal 8

You can check annotations of those entities and find access handler.

e.g.

/**
 * Defines the Private Message Thread entity.
 *
 * @ContentEntityType(
 *   id = "private_message_thread",
 *   label = @Translation("Private Message Thread"),
 *   handlers = {
 *     "view_builder" = "Drupal\private_message\Entity\Builder\PrivateMessageThreadViewBuilder",
 *     "views_data" = "Drupal\views\EntityViewsData",
 *     "access" = "Drupal\private_message\Entity\Access\PrivateMessageThreadAccessControlHandler",
 ...

As you can see, there is access handler. Now you know how it works.

  protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
    if ($account->hasPermission('use private messaging system')) {
      switch ($operation) {
        case 'view':
          if ($entity->isMember($account->id())) {
            $messages = $entity->filterUserDeletedMessages($account);
            if (count($messages)) {
              return AccessResult::allowed();
            }
          }
          ...


Why do I get PDOException SQLSTATE[42S22] Column not found 1054 Unknown column 'tn.tid' in 'on clause'"?

The error you get is caused by the fact you don't use tn as alias of any database table.

The code I would write is the following one.

$tid = arg(2);
$query = db_select('node', 'n');

$tn = $query->join('taxonomy_index', 'ti', '%alias.nid = n.nid');
$th = $query->join('taxonomy_term_hierarchy', 'th', "%alias.tid = $tn.tid");
$th1 = $query->join('taxonomy_term_hierarchy', 'th1', "%alias.tid = $th.parent");
$th2 = $query->join('taxonomy_term_hierarchy', 'th2', "%alias.tid = $th1.parent");

$query->condition('n.type', 'product')
  ->condition(
    db_or()
      ->condition("$tn.tid", $tid)
      ->condition("$th1.parent", $tid)
      ->condition("$th2.parent", $tid)
  )
  ->fields('n', array('nid'))
  ->extend('PagerDefault')
  ->limit(1);

$query->join() is really doing an INNER join; if you need to make a LEFT OUTER join, then the code is the following.

$tid = arg(2);
$query = db_select('node', 'n');

$tn = $query->join('taxonomy_index', 'tn', '%alias.nid = n.nid');
$th = $query->addJoin('LEFT OUTER', 'taxonomy_term_hierarchy', 'th', "%alias.tid = $tn.tid");
$th1 = $query->addJoin('LEFT OUTER', 'taxonomy_term_hierarchy', 'th1', "%alias.tid = $th.parent");
$th2 = $query->addJoin('LEFT OUTER', 'taxonomy_term_hierarchy', 'th2', "%alias.tid = $th1.parent");

$query->condition('n.type', 'product')
  ->condition(
    db_or()
      ->condition("$tn.tid", $tid)
      ->condition("$th1.parent", $tid)
      ->condition("$th2.parent", $tid)
  )
  ->fields('n', array('nid'))
  ->extend('PagerDefault')
  ->limit(1);

As side notes:

$query->join(), and $query->addJoin() returns the alias they used
In the conditions passed to $query->join(), and $query->addJoin() %alias is replaced with the table alias the method is using

SelectQuery::addJoin() avoids conflicts between aliases using the following code.

  $alias_candidate = $alias;
  $count = 2;
  while (!empty($this->tables[$alias_candidate])) {
    $alias_candidate = $alias . '_' . $count++;
  }
  $alias = $alias_candidate;

  if (is_string($condition)) {
    $condition = str_replace('%alias', $alias, $condition);
  }

Writing code similar to the one I used, you are sure not to cause any conflict between aliases, and it is useful in the case the code is changed successively, or part of the query is populated from a function.
In this case, the join part could have written as follows, and it could still work correctly.

$tn = $query->join('taxonomy_index', 'tn', '%alias.nid = n.nid');
$th = $query->join('taxonomy_term_hierarchy', 'th', "%alias.tid = $tn.tid");
$th1 = $query->join('taxonomy_term_hierarchy', 'th', "%alias.tid = $th.parent");
$th2 = $query->join('taxonomy_term_hierarchy', 'th', "%alias.tid = $th1.parent");


Sounds like Bakery module would meet the requirements for you. It will handle single sign-on between Drupal sites on different sub-domains.

As far as performance goes, Bakery is used by drupal.org when you switch between https://www.drupal.org, https://groups.drupal.org, https://assoc.drupal.org and others.

What it doesn't do is to switch between different domains like drupal.org and drupal.com. Bakery also doesn't sync user information, if you have user fields.

For more advanced features like SSO between Drupal and non-Drupal, look at CAS module, or some of the other single sign-on solutions.


I would see how these projects approached this popular scenario & go from there as opposed to starting from scratch:

https://www.drupal.org/project/recruiter
https://www.drupal.org/project/drop_jobs

[edit]...So I decided to try both those out as I was thinking about simple data modeling and how to communicate it best. There's a demo linked on the recruiter distro but decided to use https://simplytest.me/ which is great in case you haven't heard of it.

The drop_jobs broke but the recruiter distro worked and it provides facets which is probably the way you should go too so people can just refine their search to their needs - the trouble with trying to do it in just views alone is you start with a big list of data and provide options from the boundaries you know, e.g. salary bracket, but if there's nothing in the one they choose then you'll end up with no results.

The benefit of using facets is by default it will only display the available facets, and you can have things like facet counts. You can display all the facets so you get things like $10k-$20k(0) if there aren't any, but at least the user doesn't have a fruitless search.

See http://dgo.to/facets


"Language neutral" is not available for content

In Drupal 8 LANGUAGE_NONE (neutral) has changed to LANGUAGE_NOT_SPECIFIED, LANGUAGE_NOT_APPLICABLE and LANGUAGE_MULTIPLE.

I usually use LANGUAGE_NOT_SPECIFIED where I used to use LANGUAGE_NONE in Drupal 7.

Berdir mentions that all those new options makes no difference to how content is displayed, but they let you treat differently to content on your site if you'd wanted to in views, custom code, ...


Using Entity Reference Module you can set up a view that pulls in a list of entities and then use that view to select the nodes. Steps:

Create a view of employees
Add a contextual filter to the view for has term reference
Save view.
Add entity reference filed and select use view to show results.

Hope that helps


Is it possible to add menu tab in any menu group?

Just change

'type' => MENU_NORMAL_ITEM

to

'type' => MENU_LOCAL_TASK

and clear the caches.

The MENU_LOCAL_TASK option will make the menu item render as a tab in the user/% group. If you want to control the tab order you can use the 'weight' key in hook_menu().


About What is the best way of using Drupal as a front end to an existing web application?: I leave it to others to decide if it would be the "best" way, but "a" way to do so is to continue to use your existing web application for maintaining the data of it, and then use Drupal as a frontend to actually visualize those data (read only operations).

Assume the DBMS involved is some type of PDO compliant DBMS, e.g. MySql (the question currently does not provide details on that). So similar to what is described in Python Web Application Development Using Flask and MySQL. In that case the Forena module would be a perfect fit to get the job done, i.e. build reports and/or charts about data stored in your existing web application. Here is a quote about Forena:

  ... built of the idea of using SQL to get data out of a database and use XHTML and CSS to format it into web reports.

Possible DBMSs that could fit this approach are the Drupal DB itself (of course), but also MySQL, Oracle, MS SQL, Postgress, Sqite, anything PDO compliant.

The advantage of this approach is that you get lots of Drupal features avilable, while the "bacckend-part" of your application continues to be the applicationn you already have (you don't loose the investements made in that).


Webform: how to wrap each form field with a div?

You're correct in thinking to use the #prefix and #suffix attributes.  Webform components are stored in the 'submitted' part of the form array.  To add a surrounding div to each textfield and select, you can do the following in hook_form_alter:

if ($form_id == 'webform_client_my_form_id') {
  foreach($form['submitted'] as &$field) {
    if($field['#type'] == 'textfield' || $field['#type'] == 'select') {
        $field['#prefix'] = '
';
        $field['#suffix'] = '
';
    }
  }
}

To find out your form id, you can add a watchdog statement:

watchdog('My Module', "Form Id: $form_id");

Then check the dblog at /admin/reports/dblog.

This link may also be helpful: https://drupal.org/node/1558246


It seem to be a bug. I run into the same problem today, so I created an issue on the search api queue Stemmer is not working properly on indexing or on search. Please check that issue and elaborate if necessary.


This answer probably is too late, but for the sake of other South African users coming across this question: I have a sandbox module for using Paygate as your payment gateway. It is developed for Drupal 7 Commerce and it's currently live on a few websites I've worked on.

You can get the module here, but you'll need to know how to use git to download it.


var node = {
                title: "Sample Location",
                body: {
                    und: [{
                          value: 'Sample Body'
                          }]
                },
                field_location_type: {
                    und: [{
                          latitude : '37.4861987023',
                          longitude : '-122.2312',
                          country_name : 'United States',
                          province : 'CA',
                          city: 'My City',
                          postal_code : '12345',
                          name : 'Place Name',
                          }]
                },
                type: 'location',
                language: 'und',
            };

This sets a variable 'node' for Javascript. CCK field is "location_type". All the other parameters are being inserted into the node (city, postal_code,...) , but the Lat/Lon is still not being posted. I suspect that it may be because a node can have many 'locations'. Any help here would be great.

Take a look at the debug log: admin/reports/dblog for the json interaction. You need to turn on Services Debug "Debug mode enabled" located at admin/structure/services/list/api where 'api' is the endpoint.


Showing a message (perhaps using a redirect) after a Fileds form is submitted in Drupal 7

You can setup Rules to display a message when ever a node of the specific type is created. There is an interface for creating Rules you want

Event: Creating a new node
Condition: The node is of the chosen type
Action: Display a message

Alternatively you can use code with hook_form_alter, and add a submit handler to the node submit of the specific type, where you use drupal_set_message to display the message. This can be done faster (if you know how to create modules for drupal, and it requires less resources (is faster in execution) than the Rules solution.


Twig: "for" does not display variable content without first displaying all variable content

In Twig you could re-use the pre render callback for each single node, see Cycle comments on field--comment.html.twig, but since you are responsible for the content of the twig variable you can do this when preparing the variable by replacing viewMultiple() with multiple view():

foreach ($related_nodes as $node) {
  $variables['related_nodes'][] = \Drupal::entityTypeManager()
    ->getViewBuilder('node')
    ->view($node, $view_mode, $current_node->language()->getId());
}

Then in Twig you can use a normal loop:

        {% for rel_node in related_nodes %}

{{ loop.index }} - {{ rel_node }}

        {% endfor %}


The Field module shows an error when I call drupal_get_form()

Solved this issue when I upgraded to drupal 7.10, but I had to create a node object in the page callback function.

function mymodule_leg_node_form(){
    global $user;
    global $language;

    $node = new stdClass();
    $node->uid = $user->uid;
    $node->type = 'leg';
    $node->language = $language->language;

    $form = drupal_get_form('leg_node_form', $node);
    return $form;
}


Is it possible to use theme_table on each key of array?

After few minutes, I realized it was so simple.

$rows[] = array('data' => array($row));

where $row wasn't array, it is array key.


Get node form inside preprocess_views_view_fields()

You can get nid (node id) from $vars as like following:

$vars['row']->nid

You can also check the $vars to view the structure of the object as like following:

dpm($vars);

To use dpm(); you have to install devel module.


OR condition in Views Contextual Filters

Drupal 7:

If using D7, then consider module Views Contextual Filters OR (which only has a dev version today). Excerpt from its project page:

  ... provides a views plugin which modify query to support OR conditions for contextual filters.

A few issues on Drupal.org that may be of some help:

Using OR in filters breaks contextual filters.
Views AND/OR Contextual filters two ways.

There is also this comment in the support forum.

StackOverflow.com contains yet another approach to consider as an alternative.

Maybe you should look at Alter a Views query to use "OR" through the user interface also (it might help to change change your mind about the Views Contextual Filters OR module anyway). Because 3,855 reports installs of that module is not nothing, right?

Drupal 6:

If you're still using D6, then maybe module Views OR is what you are looking for? Excerpt from its project page:

  By default, each record in a view must match all filters. Sometimes records need to be included if they match one or more filters in a list of alternatives. Views has the ability to combine filters only with AND. If one filter is false, the combined list will be false. Views Or adds the ability to combine blocks of filters with OR. If one of the filters in the block is true, the combined block will be true.

Note about the "my website is too big" ...

That's perfectly understandable. But that also implies that you should really invest in setting up some kind of testing / staging environment where you have like a mirror of your production environment. So that in THAT environment you can safely experiment / review / finetune what's needed, without impacting your production environment. And after you found the fix in that environment, you should have a process in place to actually MIGRATE it to the production environment ...

A pretty forward (simplistic) approach to this is to transform your existing production site into a multi site setup, whereas you do not change anything to the production site version, but you just add 1 (or more) sites like 'test', 'QA', 'User Acceptance Testing'. These extra sites mostly use the same code base (as production), but with their own copy of the Drupal database. And code changes (or extra modules to be added), first go in site specific subdirs. After they get approved, they are "promoted" to the "all" subdir.


Custom field in XML with Views RSS module

You need to implement a hook_views_rss_item_elements() invocation if you're wanting to add a custom item element. For example:

/**
 * Implements hook_views_rss_item_elements().
 */
function MYMODULE_views_rss_item_elements() {
  $elements['my_element'] = array(
    'title' => t('My Element'),
    'description' => t('Provides a my_element to an item element in Views RSS.'),
  );
  return $elements;
}


To create a view from a database table instead of using hook_views_data you can use Views Custom Table module:

View custom table module provide you functionality to integrate your custom table data to views, and access all it's column in views. This module use hook_view_data to add custom tables in views.

it's easy just follow the 7 steps in How to use section in module page.


How can you add a template for a custom confirmation page URL?

This would be a nice starting point:

/erlendsays.module

<?php

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter().
 */
function erlendsays_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  array_unshift($form['actions']['submit']['#submit'], 'store_doublecheck_form_result');
}

function store_doublecheck_form_result(array $form, FormStateInterface $form_state) {
  Drupal::request()->getSession()->set("webform_result", $form_state->getValues());
}

/**
 * Implements hook_theme().
 */
function erlendsays_theme() {
  return [
    'doublecheck_form_result' => [
      'variables' => [
        'form_result' => NULL,
      ],
      'template' => 'doublecheck_form_result',
    ],
  ];
}

/erlendsays.routing.yml

erlendsays.doublecheck_form_result:
  path: '/doublecheckformresults'
  defaults:
    _controller: '\Drupal\erlendsays\Controller\DoublecheckFormResultController::index'
    _title: 'DoubleCheck Form results'
  requirements:
    _permission: 'access content'

/erlendsays/templates/doublecheck_form_result.html.twig

TODO: print the form result.

/erlendsays/src/Controller/DoublecheckFormResultController.php

<?php

namespace Drupal\erlendsays\Controller;

use Drupal\Core\Controller\ControllerBase;

class DoublecheckFormResultController extends ControllerBase {

  public function index() {
    return [
      '#theme' => 'doublecheck_form_result',
      '#form_result' => \Drupal::request()->getSession()->get("webform_result"),
    ];
  }

}


How can I edit metadata and custom fields for an embedded image using Media Module in a WYSIWYG in D7

After a tremendous amount of research and trial & error, I was finally able to figure this out. The "trick" is to make sure you click the "override in WYSIWYG" checkbox on the file field at /admin/structure/file-types/manage/image/fields/field_caption


Approach to create headless drupal with login

I'd recommend you look at OAuth 2.0, which more or less standardizes the process of how to get to a valid login state/token.

I used https://www.drupal.org/project/simple_oauth recently in a project, which depends on the oauth2 component of the phpleague, which comes with great documentation: https://oauth2.thephpleague.com/. And the module itself also has a lot of documentation and whole video series on how to configure and use it.

OAuth2 provides 5 different ways to handle what it calls a grant, based on whether your client is an API, another website, a 3rd/1st-party client and so on: https://oauth2.thephpleague.com/authorization-server/which-grant/

E.g if you're OK with the user entering his password then you can just use the password grant, if you don't want that, you can use the oauth/authorize page which then redirects the user back to the app and so on.


Link “My Workbench” is no longer visible

I posted an answer on this question:
Link "My Workbench" no longer visible

In order to have it appear in the admin menu. You need to give access to:

"Use the administration pages and help"

Because the My Workbench link is child of admin: /admin/workbench


You should also make sure you do have a graphical library (like php-gd) installed on your server: check /admin/config/media/image-toolkit (D7).


Verify a node with a given node ID exists

If you don't want to load the entire node then you can use entity query:

$values = \Drupal::entityQuery('node')->condition('nid', $id)->execute();
$node_exists = !empty($values);

This will be much more efficient because it only asks for the ids and not all the node fields.


Instead of returning the string you want to use as output, print it using code similar to the following one.

print $output;
module_invoke_all('exit');
exit();

$output is the variable containing the output you want to show.
While the module_invoke_all('exit') call is not strictly necessary, it notifies other modules that Drupal is terminating. There are modules that implement hook_exit() to do their job, and they will not work, without that call; their purpose is to write something in a Drupal variable, or in a database table, and they don't interfere with the output your are producing.

The reason why it is necessary to do this is the code used by index.php, which contains the following:

$return = menu_execute_active_handler();

// Menu status constants are integers; page content is a string.
if (is_int($return)) {
  switch ($return) {
    case MENU_NOT_FOUND:
      drupal_not_found();
      break;
    case MENU_ACCESS_DENIED:
      drupal_access_denied();
      break;
    case MENU_SITE_OFFLINE:
      drupal_site_offline();
      break;
  }
}
elseif (isset($return)) {
  // Print any value (including an empty string) except NULL or undefined:
  print theme('page', $return);
}

drupal_page_footer();

If you return a string, it is passed to theme('page'), which renders the page as you are noticing; if you return nothing, then both is_int($return) and isset($return) are FALSE, and the relative code is not executed.

The equivalent for Drupal 7 for the code I wrote for Drupal 6 would be the following one:

print $output;
drupal_exit();

drupal_exit() contains already the call to module_invoke_all('exit').


Panels in-place editor won't show in panels even after setting renderer

Solved!

It seems to me that there are two types of renderes for panels:

The first is the global renderer that indeed I've changed to "Panels in-place editor". The second is each Panel's own or Specific renderer.

My problem occurred because for some reason, My Panel's own renderer wasn't affected from the global one, and stayed "Standart". I have no idea why that happen (might be a bug)...

Anyways, to change your Panel's own renderer just go to it's Panel.page\Panel.node and click on the tab "Edit" located on it's top. Thus when you edit the Panel itself you could choose it's own renderer and Problem should be solved by then.

All luck, Ben.


The modules that in that list are followed by "(missing)" are the modules that are not present in the Drupal installation, and that are required from the module you are trying to install. Just install them, and you will be able to install the Booking Time Slots module.

The trick is understanding which modules you need. Since the modules are not found on the server, what the module page shows is not the module name, but the short name of the module capitalized.

The list of the modules that site needs is the following:

Entity API
Entity reference
Features
Hierarchical Select
Opening hours

As you see, the module pages says that the Opening_hours module is missing, but the module name is Opening hours, while opening_hours is the short name of the module, the same used in the URL for the project page. Join https://drupal.org/project with opening_hours, and you get the complete URL of the project page for the module you are looking for: https://drupal.org/project/opening_hours.

The list of modules is shorter because there are modules that are sub-modules of modules already listed as requirements.

The Opening hours module then depends from the following modules:

Date Popup (part of the Date module)
Tipsy


How to remove id="node-[nid]" with Display Suite?

Below code is quoted from template.php of Tao.

/**
 * Implementation of preprocess_node().
 */
function tao_preprocess_node(&$vars) {
  $vars['hook'] = 'node';

  $vars['classes_array'][] = 'clearfix';

  $vars['attributes_array']['id'] = "node-{$vars['node']->nid}";

  ...

The ID is added by this line.

$vars['attributes_array']['id'] = "node-{$vars['node']->nid}";

You can override it by implementing the same hook function in template.php of your custom child theme.

/**
 * Implements hook_preprocess_node().
 */
function mytheme_preprocess_node(&$vars) {
  unset($vars['attributes_array']['id']);
}


You can use this approach to include a file in .module

function module_name_init(){
    module_load_include('inc', 'module_name', 'includes/common');
}

and place common.inc file in includes folder in your custom module.Now write your php code here.


How can I set a different theme basing on the language currently used for the page?

you can check the current language with the languageManager (docs here)

Drupal::languageManager()

and then you can set a different theme with the theme service

\Drupal::service('theme_handler')->setDefault('test_theme');

Hope it helps,


How to add webform to existing content type?

Go to Content type edit page : /admin/structure/types/manage/[ContentTypeName]. There you can see the webform under the Menu Settings. Just enable it from there. Adding screenshot :


autocomplete taxonomy field depend on another taxonomy field

I hope this is a drupal site on development state.

If it is possible to you, I recommend you to create just one taxonomy vocabulary, where Animal type are parent terms of Breeds terms as a tree:

Cat

Curl
Bengal

Dog

Afghan
Akita

Then you can use Simple Hierarchical Select or Hierarchical Select, where you can allow users to select a parent term first and then childs.

Hope this help, if you need help with views filters or things like that I can help you :)


Why does Drupal store the uploaded files for a content node even if the content is not created?

I have discovered that the files are physically stored, and also in the database, there is an entry in the table file_managed with the field status with the following indication and value : 0

A field indicating the status of the file. Two status are defined in core:
temporary (0) and permanent (1).
Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.

I have manually changed the timestamp of the uplodaded file, run the cron, and the file dissapears. Obviously there must be a confident time, because if not, files in contents still being update could have the risk of being deleted. My fault for not thinking of this last point.


How to get the part of URI and pass it to as a argument?

Probably what you want to do, is to make some logic for the route name instead of the path.

So the user profile page has the route named entity.user.canonical which has the path /user/{user}. So if you compare on the route name, you will get all user profile pages. This also makes it very easy to limit your selection so you can do something different for the user edit page etc/

Anyways to get the current route you can do

$variables['current_route'] = \Drupal::routeMatch()->getRouteName();

\Drupal::routeMatch() is a shortcut for the current_route_match service.


Making user reference field in Drupal 7?

Another alternative to References is the Entity Reference module. It can do user reference fields as well.


Will removing the X-Drupal-Cache header break anything?

X- headers are optional, and are not allowed to be officially required, except in the same family of products. You can search Internet for some bizarre examples. My favourite is X-PoweredBy: Unicorns and X-hacker: If you’re reading this, you should visit ******.com/jobs and apply to join the fun, mention this header.

That said, it may not be required, but it may still be used. If your hosting company provides caching and load balancing, it may use this header to know that page came from Drupal's cache and thus there is no need to use that data to repopulate cache server's storage. It can be also used to track statistics. and of course you are using it to test if cache works OK on production, aren't you? All these uses will get impossible if you will remove this header, or rename it without coordination with other users. Site should be served OK, but in specific circumstances there is a risk of worse performance and crippled debug/analytic options. Maybe you can afford that risk. Maybe not.

TL;DR You need to ask anyone who might be using it, not us.


I was able to pull the order value using the following code

$order = uc_order_load(intval($_SESSION['cart_order']));

if ($order)
{
   $amt = round($order->order_total,2);
}


How to properly filter a form's data against XSS?

There's a huge issue with your implementation: it's destructive. Let's say a user writes about HTML, uses common comparison symbols or just uses the evil emoticon for despair: <o>. Changing data will make it harder for the user to later edit his post, it might even remove parts of it. Let's respect the user effort of typing into a textarea and hitting 'Save'.

So, what to do about XSS? Well, XSS is not dangerous in your database, it is only dangerous when displayed in a browser. So relax about saving it and worry about displaying it. Default formatters for text fields will use the text format settings to apply filters. Make sure the text formats available for your user are safe. And if you're writing your own formatter, don't forget to filter the output (preferrably by respecting the text format settings).

See https://drupal.org/node/28984 and https://drupal.org/documentation/modules/filter for more on this topic.


How to use a webform key more than once.

Why do you need form_key twice in the $form on the page? Simply add a custom submit handler to the form and create whatever custom $form_state or values you want to pass on to the remote API ... and let webform store the data as it wants seperate from what you send to the API.


Hierarchy in entity reference view display

I just came across this question, because I had the same issue. The solution I've found is to use a Relationship; no extra modules required.

Add a Relationship and choose "Parent Term". Check on "Require this Relationship" in the dialog box.
In the "Filter Criteria" section of the view, add the "Term" field (NOT the "Parent" field*). If you want, you can choose to show the hierarchy in a dropdown, in prep for choosing the term in step 4.
Choose the created Relationship in the "Relationship" field of the filter dialog box.
Choose the Parent term in that same filter dialog box (to use your example, say "Category A").

Now your view should output only the children of that parent term. (Again, using your example, if you chose Category A, your view would output:

Category A1
Category A2

*there is a "Parent" field in the Filter field options, and it seems intuitive to use that, but using that only outputs the top-level hierarchy of the Taxonomy, even when combined with an AND with the Taxonomy field. Maybe a bug?


Trigger a function after saving content type

There are some hooks you can use to do this, but they are all fired before the data is recorded in the database.

Have a look at hook_node_insert(), hook_node_update() and hook_node_presave(). The two first ones are fired only on insert or update, the last one every time.

After, another way to do so, is to add your own submit method on node_form, using the hook_form_FORM_ID_alter() (hook_form_node_form_alter()), which will be fired after the node is properly saved in the database.

If I were you, I would use a setting page for my module to set the content types to use.


Drupal 7: Edit/delete is not working on the custom module

You are using an Auto-Loader Wildcard in your menu item definition for admin/structure/course/edit/%course. This wildcard defines the prefix for the load function of your module. In your case course_load() will be called which returns a course object from a datasource.

If the function is not found it will fallback in any of your parent menu items. In your case it is admin/structure/course.

This could be an example of you load function

function course_load($course_id)
{
    return db_query("SELECT * FROM {course} WHERE course_id = :course_id", array(
        ':course_id' => $course_id
    ))->fetchObject();
}

Your course_edit_form doesn't receive an array of courses but 1 course object as third argument.

function course_edit_form($form, &$form_state, $course)
{
     // $course is here your Course object


How to create a single View with 2 different, optional contextual filters?

You can create a view with a context filter for username and a context filter for usermail.

Then check the input of the user, if it is a email adress. If it is a email you can redirect to the view and set the context filter for the username to "all" and the context filter for the mail to the user input.

If it is no mail adress you can set the context filter for the usermail to "all" and the context filter of the username to the userinput and redirect to this path.


How to programmatically manage taxonomies?

A simple way to set this up would be a cron hook.

function hook_cron

  Perform periodic actions.

  Modules that require some commands to be executed periodically can
  implement hook_cron(). The engine will then call the hook whenever a
  cron run happens, as defined by the administrator. Typical tasks
  managed by hook_cron() are database maintenance, backups,
  recalculation of settings or parameters, automated mailing, and
  retrieving remote data.

  Short-running or non-resource-intensive tasks can be executed directly
  in the hook_cron() implementation.

  Long-running tasks and tasks that could time out, such as retrieving
  remote data, sending email, and intensive file tasks, should use the
  queue API instead of executing the tasks directly. To do this, first
  define one or more queues via a \Drupal\Core\Annotation\QueueWorker
  plugin. Then, add items that need to be processed to the defined
  queues.

As mentioned a better way for D8 would be to use the queue API.

Or try the dev version of Feeds, which can do this without code:

https://www.drupal.org/project/feeds


I managed to override it. I found out that 'taxonomy_term_uri' is defined in taxonomy.module's taxonomy_entity_info() function, so I added a hook that alters it:

function MODULE_entity_info_alter(&$entity_info) {
    $entity_info['taxonomy_term']['uri callback'] = 'MODULE_taxonomy_term_uri';
}

function MODULE_taxonomy_term_uri($term) {
    // change the path...
    return array(
        'path' => 'taxonomy/term/' . $term->tid,
    );
}


What to do when translation imported using Locale has an inappropriate translation?

Go to  Administer -> Site building -> Translate interface -> Search (d6) or Configuration -> Regional and language -> Translate interface -> Translate (d7). You will see a search box. Simply search and edit string you think should be edited.


Views expose filter of start and end dates

Add the filter like that :

Start Date >= Filter's Stat Date

End Date <= Filter's End Date


You need to add the behaviors like this:

Drupal.attachBehaviors($('.ajax-container'));

So looks like in your case it would be:

Drupal.attachBehaviors($('.brick-filter-test'));

This should do the trick

$.get('/brick_filter/test/', function(result){
  element.innerHTML = data;
  Drupal.attachBehaviors($('.brick-filter-test'));
});


"Manage Display" for taxonomy term does not allow management of the name field

Why is the name not manageable as part of the display?

Because it's a 'property' of the entity, not a 'field' as such. The 'Manage display' tab is really a 'Manage field and pseudo-field display' tab, it doesn't take properties into account.

This is completely standard and is inline with all core entities. For example, if you check the display settings for one of your node types, you'll notice the 'Title' isn't available there either.

  Is there some way to manage the taxonomy term display including the name?

The simplest way is to manage it with templates, as you've already suggested (and again, exactly how it would be done for all other core entity types).

You could always implement hook_field_extra_fields() to expose the term name as a pseudo-field on the display forms; but bear in mind you'll have to link up the logic to hide the titles from the template file yourself, as the core taxonomy module doesn't have that functionality.

I think Add entity properties to "Manage Fields" form is a relevant D.o discussion, there's even some sample code to get you going.


around the top of your .htaccess file you have

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(|~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
  Order allow,deny
</FilesMatch>

just remove 'Tag', new code should look like this

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(|~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Template)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
  Order allow,deny
</FilesMatch>

you can replace this lines with new one that I provided above...


How to add page argument in hook_menu for dynamic callback function?

You are creating a new menu for new group. It will be better to use dynamic arguments.

$items[CONFIG_GLOBAL_ADMIN_PATH . '/groups/%'] = array(
  'description' => 'Some Group Description',
  'page callback' => 'drupal_get_form',
  'page arguments' => array('myModule_group_settings_form', 3),
  'access arguments' => array('administer site configuration'),
  'file' => 'myModule_group.admin.inc',
  'type' => MENU_LOCAL_TASK,
  'weight' => 1,
);

and In your function :

function myModule_group_setting_form($form, &$form_state, $key) {
  $groups = group_load_by_type('community');
  $value = (isset($groups[$key])) ? $groups[$key] : NULL;
  if (!$value) {
    drupal_set_title($value->title);
    // Whatever you do with $value->title;
  }
  else {
    drupal_not_found(); exit();
  }
}


Exporting comments only from one drupal site to another

Assuming you are using Drupal 7.

Use the Views module and create a table view of node comments.

Add fields: Node ID (nid), Comment ID (cid), Comment Title, Comment Body, Commment Author, Created Date.

For export, use Views Data Export and export the CSV file.

For import, use the Feeds module + Feeds Comment Processor and import your CSV.

Checkout this Feeds Video Tutorial (this is for nodes, not comments, but it will give you an idea on how feeds with the CSV import works).

--

Exporting MySQL tables approach:

Never done it like this, but if I were you, I would look for all the tables that have the name comment, export those and import.

Note sure if it will work as simply as that, but worth a try.


How to change the saving order of field_collection fields

The only way I could solve my problem was to handle the logic in the form_validate function.
Unfortunately, I couldn't update the field collection from there... this is why I added a validation function for my field collection:

/**
 * Implements hook_field_widget_form_alter().
 */
function MYMODULE_field_widget_form_alter(&$element, &$form_state, $context) {
  // Add custom validation hooks for Field Collections.
  if ($context['field']['field_name'] == 'field1') {
    array_unshift($element['#element_validate'],
'MYMODULE_field1_validate');
  }
}

Then I could insert my logic there:

/**
 * Custom validate function for field_assignments.
 *
 *  @see MYMODULE_field_widget_form_alter()
 */
 function MYMODULE_field1_validate($element, &$form_state, $form) {
    if (...){
       form_set_value($form["field1"][LANGUAGE_NONE][0]['field_to_change'], array(LANGUAGE_NONE => array(0 => array('value' => 123.456))), $form_state);
    }
  }


How to disable webform Results tab in webform without uncheked Access all webform results?

The Webform access callback, webform_results_access(), for the submissions tab is structured so evoking the built its hook hook_webform_results_access() can't override Access all webform results permissions check.

However, a custom module could override the tab's access callback with your own custom logic:

/**
 * Implements hook_menu_alter().
 */
function MYMODULE_menu_alter(&$items) {
  $items['node/%webform_menu/webform-results']['access callback'] = 'MYMODULE_webform_results_access';
}
function MYMODULE_webform_results_access() {
  $result = FALSE;
  // @TODO: Add access logic
  return $result;
}


How can I create a custom ajax callback command?

It seems like you have a namespace error(s). The error happens in a file you didn't mention RegionWidgetType.php. It's trying to use Drupal\Core\Ajax\ReadMessageCommand which as I understand it is something you made. Which means that the namespace should definitely not be \DrupalCore\... for the auto load to work.

The name space of your custom files should be Drupal\MODULE_NAME\folder\structure


i18n-Frontpage: inconsistent links to non-default language

What eventually worked for me:

Disable the module "admin_language"

I tried many different configurations of this module but it just kept on giving me English content on the German Frontpage. Views however displayed the correct language.

Should I report this bug to the module maintainers?


This depends the implementation. If the super-fish functionality is already included in a theme (Example: Danland, Danblog), there is most probably already a .css section in the style sheet or a separate .css file related to superfish. If you modify these files, they might be overwritten if you make an update. Thus you optimally make the modification in a local file (local.css in our Example) by copying and modifying the css code.

If you install superfish separately you find all the instructions in the readme.txt of the module:

"How to style

If you know CSS, even basics of it, designing won't be a big challenge.

Here are some tips and tricks:

A) Always use a DOM inspector utility (such as Firebug).

B) Set the "Menu delay" option to a very high number such as 99999999. This will give you enough time to work with sub-menus.

C) If you are not using the built-in styles, set the "Style" option to "None".

D) Utilise the "Simple" style as reference; add the newly-created CSS file either to your theme CSS or as a new CSS file under the styles directory in the Superfish library (probably "sites/all/libraries/superfish/style"); putting it in the styles folder will automatically add it to the styles list in the block configuration."

More information can be found in the Superfish documentation at http://drupal.org/node/1125896"

i.p. 4. within the Installation section

"Upgrade users need to delete the module folder (sites/all/modules/superfish) before uploading the new one. Also, if having any modified CSS files, just move them from sites/all/modules/superfish/css/extra to sites/all/libraries/superfish/style"


Send a mail automatically with content/attachment using webform using rules

Pieter - I think this answer can be helpful. You would use MIME mail to add attachments and send rich emails.


Drupal 7: Variables in external file access

If I have a module called foo, I put all of my includes in a subdirectory called 'inc/' and then use this

<?php

require_once(dirname(__FILE__) . "/inc/constants.inc");
require_once(dirname(__FILE__) . "/inc/class.FOO.inc");
require_once(dirname(__FILE__) . "/inc/class.BAR.inc");

in foo.module.  If doing Drupal 7, you may also want to take a look at the files directive for .info files:

  Drupal now supports a dynamic-loading code registry. To support it,
  all modules must now declare any code files containing class or
  interface declarations in the .info file, like so:

files[] = example.test

  When a module is enabled, Drupal will rescan all declared files and
  index all the classes and interfaces that it finds. Classes will be
  loaded automatically by PHP when they are first accessed.

EDIT TO ADDRESS COMMENT

Even if you aren't doing this in a module, you should really abstract out the constants into a module that provides getter functions and/or a static class and/or a singleton with getter functions.

Another option is to bail on includes, and use variable_set / variable_get, preferably in conjunction with a module settings form.


You can use jQuery for the this purpose. Simply use mouseover event on the  announcement DIV. Write a jQuery function to hide this DIV using .hide method of jQuery. like this.

$(document).ready(function() {
$("#announcement_div_id").hover(function() {
$("#announcement_div_id").hide();
});
});

Here announcement_div_id is the id of the div which you want to hide.


You can create slideshows using Views Slideshow module. You can add thumbnail images below the main slide image. There is a setting already there in views slide show settings.

See this : Create an Image Slideshow with Drupal using Views


How do I programmatically know the jQuery version using a script or a hook?

you can use this code to get all installed modules list

module_load_include('inc', 'update', 'update.report');
$available = update_get_available(TRUE);
$data = update_calculate_project_data($available);
dpm($data);  // provides installed modules details as an array
dpm($data['jquery_update']['existing_version']); // provides jquery_update module existing version


Drupal 7 completely offline, avoid Boostrap via CDN


Getting the actual on/off value from a radio button instead of 1/0

Try not to mix up the concept of an input's value and its label. They're two different things.

The value of a boolean field can only be, by definition, 1 or 0. It's a boolean after all. The label for the options can be anything.

To load the labels associated with those values, you'll need to load up the field definition:

$info = field_info_field('field_sex');
$allowed_values = $info['settings']['allowed_values'];
$label = $allowed_values[$wrapper->field_sex->value()];


Conditionally Hiding / Stopping a view from display

I would use a block, then create a tpl.php file for the block and inside it put

<?php

$view = views_get_view('view_name_of_subcategory');
$view->set_display('block_1');
$view->execute();
        // results are now stored as an array in $view->result
$count = count( $view->result );

if ($count = 0) { print views_embed_view('view_name_of_products','block_2' }
else { print $view->render(); }

?>

Replace block_1 & block_2 with your actual machine name, you can find it here (see picture)

PS if ($count = 0) does  not work try if ($count = null)


Privatemsg overwrites page title for custom code. How do I correct it?

I guess the private message form sets the title directly. A simple way round it might be to cache the current title before you render the form, then set it back again afterwards:

$stored_title = drupal_set_title();
print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject));
drupal_set_title($stored_title);


The module will continue to be listed on the /admin/modules page as long as Drupal detects it on your filesystem within /sites/all/modules, /sites/default/modules, or another folder under /sites if you're running a multi-site setup. Just because the module is listed there doesn't mean it is enabled and running on the site.

Uninstalling modules is usually done the way you described it in the first line of your post. You go to /admin/modules to disable modules, then onto /admin/modules/uninstall to uninstall them. If the developer of the module did it correctly, you shouldn't have to do anything more than that. You will still see it listed in the modules page because it is still on your filesystem

I wouldn't recommend manually deleting anything out of the database unless you know exactly what it is that you're doing. You could mess things up When you disable and uninstall modules through the Drupal interface (or Drush), there are certain hook functions that get called which should remove data from the database.

What I would do is first is locate the module folder containing MailChimp. Ensure that you only have it in one place. If you had the module in different folders and only delete one, it will still be listed on the admin/modules page.

If you don't see it in those folders, re-install it. Then properly disable and uninstall it again the way you described WITHOUT touching the database yourself. This will probably undo any damage you could have caused in the database and ensure  that the data in the database is properly cleared out. Afterwards, delete the module folder from the filesystem and it should be gone.


Views Infinite Scroll doesn't hide pager

To hide the pager, I just set the display: none in the CSS.


Putting aside the general design of your application, you are right to use drupal_alter to provide a hook.

However, you are missing the correct hook implementation function name.

It should be:

drupal_alter('retrieve_login_extra_params', $params);
// ...
function MODULE_retrieve_login_extra_params_alter(&$params){
// ...
}

You may also be interested in:

LDAP Integration
user_external_login_register


In theory yes. Windows is a bit more difficult because, windows.

But if you have Drush installed locally, and it's the same PHP version as you have on the server machine it should work. You will need to modify your DB credentials to reference your database by network accessible hostname or IP so that your machine can connect to the database on the server remotely.

Disclaimer: I've never tried this, but it should work. YMMV etc.

The more "right" way to do this would be to set up an ssh server on the windows box server, and set up Drush aliases to act against the remote server with Drush installed locally on the server and client.

I don't know how well that works on Windows but quick reading suggests it should be possible.


Field added to user profile does not appear in database?

The additional fields are stored in a separate table like field_data_field_first.


There is,just open Language name select list and  choose  last item Custom language ... .


You don't need to create a new field handler. You can replace the class of the existing field plugin. The plugin manager provides a hook to alter the plugin definitions:

/**
 * Implements hook_views_plugins_field_alter().
 */
function mymodule_views_plugins_field_alter(array &$plugins) {
  $plugins['geolocation_field_proximity']['class'] = 'Drupal\mymodule\Plugin\views\field\RangeProximityField';
}


Create view of child terms below parent term and how many nodes are tagged with those child terms

The problem with your question is that you want to use both Aggregated and Grouped data in the same Row.

Additionally you want to show more than one School in the same Views row, while the Title isn't a multi-value field, you're not linking Schools from Terms but Terms from Schools.

You can use an additional module to achieve that: Views Field View, although it may be performance heavy.

You can easily create a View that would display either one or the other case:

  City: New York No of Schools: 1
  City: Miami No of Schools: 2

To achieve that see my answer here: Create a Term Queue on views only instead of adding a Sorting criteria you add Content: Title under Fields and set it to Count Distinct under Aggregation settings.

Or this case:

  City: New York Name of School: School 3
  City: Miami Name of School: School 1, School 2

To achieve that follow that same procedure only don't use Aggregation and under Format select the City field as a Grouping field. You can achieve many different layouts with clever Format settings and overrides.

To combine these two views use the Views Field View module to insert the second View into the First one and use the City field as an argument that you pass to the second View.

So the first View would have a Contextual filter for the Country (the first level of Taxonomy), and the second View would have a City Contextual (second level) or something along those line, depending on your particular configuration.

You should first aim to build those Views separately and make the Contextual filters work, then use the Views Field View to combine them.

Another way to go about solving this is mentioned in the Answer I linked to: Use Views Summary to display Terms with node count, then when you click on the term it takes you to actual Views results page showing nodes for that term. This is a two-step process but it may be acceptable to your visitors and it's easy to set up.


Where is the documentation for the ACL module/api?

If you take a look at the ACL project page, you'll see that the following four client modules exist:

Content Access
Flexi Access
Forum Access
Image Gallery Access

You'll find plenty of examples on how to use the API in the source code of those.

The documentation for ACL are the comments embedded inside acl.module.  They are quite helpful when you try to create a client module.

P.S.: I am the maintainer of Flexi Access.  I can verify that ACL works as advertised.


Making sticky results in Search API Solr

Could you perhaps?:

Put a boolean field on your content (or make use of the 'promote to front page' field)
Make a view to arrange your search results
Group by that boolean (or 'promoted')

I don't know if 'promoted' is indexed by default, you might need to set that.


Non-CRUD resource action with Drupal 7 / Services 3

I got it. I don't have to use myhost.dev/endpoint/test/retrieve in the first example. It is posible to use myhost.dev/endpoint/test/Whateveryouwant. So i understand, i can use the retrieve action and it is not mandatory part of the resource path.


You should install Custom Search module as it does provide an option to open results in new tab or lightbox.

https://drupal.org/project/custom_search

Otherwise you can always look into using custom functions or js to achieve the same in your search template.

Updated Answer

Since you are using solr and search-result.tpl.php you should have a line like:

<a href="<?php print $url; ?>"><?php print $title; ?>

change it by adding target value like:

<a href="<?php print $url; ?> target='_blank'><?php print $title; ?>


Drupal 6 administration menu like the one on Drupal 7

Why not building your own menu with the most used functions and show it only for you? I do this all the time for D6 and D7.


Website returning 404 and not 403 for forbidden pages

I've found a workaround using the "redirect 403 to login" module. It is not yet in alpha for D8, but seems pretty stable.


In Drupal 7, some modules supply contextual links that allow privileged users to quickly perform tasks that are related to regions of the page without navigating to the Admin Dashboard. For example, when you hover your mouse over a block or node, links are displayed that allow you to make changes to the block or node.

According to drupal.org.


Add a configurable text before the webform

You don't have to create a block for it. There is markup type field in the webform module you can use it for display informative or configurable text in the webform where you like to show. You can also use HTML for this.

For Example

For more details, click here


How to bulk assign existing content to a group created with the Group module?

Step 1: Create a Rules Component

Have a look at this example of a Rules Component (in Rules export format):

{ "rules_assign_existing_content_to_a_group" : {
    "LABEL" : "Assign existing content to a group",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "TAGS" : [ "group" ],
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "node_to_assign" : { "label" : "Node to be assigned", "type" : "node" },
      "assigned_group" : { "label" : "Assigned group", "type" : "group" }
    },
    "IF" : [
      { "entity_is_of_type" : { "entity" : [ "node-to-assign" ], "type" : "node" } }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "node-to-assign:group" ], "value" : [ "assigned-group" ] } }
    ]
  }
}

This Rules Component will be used in the subsequent step.

Note that I've not added a Rules Condition here about selected content types, that's possibly an extra condition you might want to add also.

If you want, just grab (copy) the exported rule above, and simply import this Rules Component in your own environment.

After you did this, you can navigate to admin/config/workflow/rules/components in your own site, and then use the hyperlink "execute" to qa-test it in your own site. After you use that link, use the button that says Switch to direct input mode. Then you'll be able to enter some Node to be assigned. Use a similar technique to specify the Assigned Group and hit the Execute mode. The node you selected will be assigned to the group you specified.

After you're confident your rule works fine, move on to the next step below.

Step 2: Let VBO to the bulk of the work

This step is pretty easy ... Just create an appropriate view of all your nodes to be processed, and transform it into a Views Bulk Operations view. The clue to what you want VBO to do as an operation is ... you guessed it: Execute the Rules Component from Step 1.

If you're not familiar with how to do so, have a look at the video about Using Rules components with VBO". If you want even more, then also watch the subsequent "Using Rules components with more than one parameter" video.

Attention: to process many nodes at once is quite a challenge (memory requirements, etc). Therefor you might want to also watch the video about "More details about VBO settings" ... Before you are tempted to use VBO for processing them all at once ...


split/divide main content region to columns or create another custom layout

After hours of searching, I was lucky (and persisent enough!) to come across this: http://www.youtube.com/watch?v=gmX2jnH9Kdg which describes how to achieve what I am after using panels indeed. I feel covered by that excellent video. I can leave my Q up for anyone frustrated as to how to translate his/her layout to dynamic drupal code


It looks like you've tried alot of possible solutions with mixed success.

A method I'm not certain you've tried is to apply a patch to Features 2.x for Drupal7 that Provides a way to Import Views/true exportables back to the database.

This patch creates a new tab in the Features Admin area called Import if you select the items in the selected Feature to import back to the database, it will then attempt to import the exportable back to the database. Unfortunately as some users note in the thread -- you may not receive a confirmation message that it was successful or not. Recent versions of this patch may have addressed this lack of a status message -- I used this module months ago to move about a dozen features out of Features and back into plain/simple database configuration.

There is also discussion in the thread about Drush Ctools Export Bonus. But I found this module difficult to use and produced an error with (i think) field_group stuff at the time.


Theming custom block in twig file and render variables

You probably just need to define the available variables:

function my_module_theme() {
  return [
    'custom_block' => [
      'template' => 'custom-block',
      'variables' => ['my_variable' => ''],
    ],

  ];
}

You'll need to rebuild caches for the change to be picked up.


This can be done by using theme_pager in TEMPLATE.PHP (add it to your theme folder) . the code will be :

function theme_pager($variables) {
  if(arg(0) == "search" && arg(1) == "site") {
    $variables['quantity'] = 8;
  }
}


The Devel switch feature passes the login straight to the user module in devel_switch_user(); it doesn't give other modules the chance to intervene, and doesn't provide any context that would let you know how the login has been instigated.

I guess as a simple low-tech solution you could patch that function and set a session var before it invokes the login, something like

...
if (!$old_uid) {
  // Switch from anonymous to authorized.
  drupal_session_regenerate();
}

$_SESSION['login_from_devel_switch'] = TRUE;

$edit = array();
user_module_invoke('login', $edit, $user);
...

Then you can check for the existence of that session var wherever you need to prevent the profile from writing.


I think module_invoke() is correct and you can simply call that in your tpl file. However,

use

print $block['subject'];

print $block['content'];

instead of

print render($block);

Also

D6 and earlier:

$block = module_invoke('module_name', 'block', 'view', 'block_delta');
print $block['content'];

D7:

$block = module_invoke('module_name', 'block_view', 'block_delta');
print render($block['content']);

Refer

http://drupal.org/node/359021
http://drupal.org/node/26502

for more some more help.


While Rules components may successfully be created and used programmatically, as of Rules 8.x-3.0-alpha4 there is only minimal support for doing this in the UI. Adding these UI features is part of the last meta task needed to be completed before a beta version of Rules is released. You can discover the current status of these UI porting issues by reading the Rules issue queue at https://www.drupal.org/project/issues/rules


Fixing bad node that makes search not index, but completes cron

After some additional alterations I was able to isolate 3 nodes that were not presenting as broken, but once I accessed them with PHPmyadmin I was able to delete them from the list. Once I found them and removed them Cron began indexing once again.


Need to add a condition between two fields in a view

This can be accomplished through the Form API.  However, if you are a PHP novice, you would probably be better off using the Conditional Fields module.  Although this is still in dev (no official release) for Drupal 7, it does work.  (If you have security-related requirements, you should use Form API instead though.)

Basically, the module provides you with a UI for adding conditions to fields.  The example you give is the same given on the module's page, so this is one solution to your problem.


Ok, that was easier than I thought. When using WYSIWYG editors you have to save the info differently.

For a normal textarea:

$entity->content = $form_state['values']['description']

For a WYSIWYG:

$entity->content = $form_state['values']['description']['value']


After doing a file_save_upload() how do you resize the images?

print theme('image_style', array(
  'style_name' => 'your_style_name',
  'path' => $your_file->uri,
));

theme_image_style


change custom css class to block content

You can override the template for the block.

To see what the template should be you can use the following in your themes template file.

/sites/all/themes/YOURTHEME/template.php

function YOURTHEME_preprocess_block(&$vars) {
   var_dump($vars['theme_hook_suggestions']);
}

Also make sure you have a copy of block.tpl.php in your themes template folder.
You can get this by going to /modules/block/ and copying the file to /sites/all/themes/YOURTHEME/templates.

This is handy because you can copy the code from the default block template to your custom block template and make any changes you want there. If you were to delete your custom block template it will default back.

Heres more on template (theme hook) suggestions
http://drupal.org/node/1089656


Add more info to entityreference autocomplete widgets

Maybe take a look at the Entity Browser module: https://www.drupal.org/project/entity_browser

Or Content Browser, which is specifically designed for nodes:
https://www.drupal.org/project/content_browser

I haven't used it yet, but it's on my want-to-learn list. I think it does what you want.


Can I make a subdirectory in public:// viewable in Media module's UI?

I guess you can five a try to filedepot module if it helps you. Here is a quote about it (from the module's project page):

  ...  full featured Document Management module that has a google docs like feel. It fulfills the need for an integrated file management module supporting role and user based security. Documents can be saved outside the Drupal public directory to protect documents for safe access and distribution.


As I answered at  Limit Taxonomy Term references to special vocabulary  if you want to create a custom entity_reference field on custom entity type try something like

$fields['book_cat'] = BaseFieldDefinition::create('entity_reference')
   ->setLabel(t('LABEL'))
   ->setDescription(t('DESCRIPTION'))
   ->setSetting('target_type','taxonomy_term' )
   ->setSetting('handler','default' )
   ->setSetting('handler_settings',['target_bundles'=>['VOCAB_MACHINE_NAME'=>'VOCAB_MACHINE_NAME']] )
   ->setTranslatable(TRUE)
   ->setDisplayOptions('form', array(
       'type' => 'options_select',
       'weight' => -1,
       'settings' => array(
           'size' => '60',
           'placeholder' => '',
       ),
   ))
   ->setDisplayConfigurable('form', TRUE)
   ->setDisplayConfigurable('view', TRUE);

AND  about  setTargetEntityTypeId :(Doc)

  Sets the ID of the type of the entity this field is attached to.

and used when you want attach  field(s)  not  for referencing.


How do I add variables to a module's hook's existing render array and have them available as template variables?

According to template_preprocess_search_result you have the $result variable available, so if you've already injected your custom field into the result you can just use

print $result['photo'];

In the template file.

Or if you're absolutely set on just having a $photo var, you need to add it to the variables for the template:

function MYMODULE_preprocess_search_result(&$vars) {
  $vars['photo'] = $vars['result']['photo'];
}


In Drupal 6, the second argument of check_markup() is the value of the "format" field in the "filter_formats" table; it is a serial field, which means it can contain only numbers.

The documentation for the function doesn't specify what you should pass; it uses a phrase that could be misunderstood, but it doesn't talk of format name.

  $format The format of the text to be filtered. Specify FILTER_FORMAT_DEFAULT for the default format.

Looking at how the function is called in node_prepare(), I noticed the code that calls the function is the following one:

  if ($teaser == FALSE) {
    $node->body = check_markup($node->body, $node->format, FALSE);
  }

The content of $node->format is always a number, in Drupal 6.

In a standard installation of Drupal 6, without any extra modules installed, these are the values for the format ID to pass to check_markup():

Format ID     Input format
---------------------------
1             Filtered HTML
2             Full HTML
3             PHP code

To get the format ID knowing the name (e.g. "Filtered HTML"), you should use code similar to the following one:

$format_id = db_result(db_query("SELECT format FROM {filter_formats} WHERE name = '%s'", $format_name));

The format ID required from the function is different from a filter ID: An input format is a set of input filters that are used together to filter out or change what entered from users. What the modules implement are input filters.


How to list duplicate nodes, with views, based on compared fields with links

There isn't an easy, non-coder based way to do that with views. You could however create a view with the link field visible, and as a sort parameter as well. That way identical field values would show up next to one another. It'd be then the process of selecting the duplicate node (I'd suggest deleting the one with the higher nid) and deleting it.

Let me know if that makes any sense at all, or if you need a 5 minute proof of concept demo.