Rather than using a node to redirect to another one, I would implement hook_menu() to define a new menu callback that renders the other node, or redirect to the other node.
The alternative would be implementing hook_node_view() to add the other node to the node being viewed (when it is the correct one). For example, the following code would work.

function mymodule_node_view($node, $view_mode, $langcode) {
  if ($node->nid == $node_to_alter) {
    $node->content['my_module_additional_content'] = node_view($the_other_node);
  }
}

This is the approach followed by Drupal where, instead of using the PHP filter (which would make a node editable only from Drupal.org administrators), a custom module is used to add content to specific nodes.

A node that redirects to another node would create problems because:

If you are doing the redirect when rendering the node, you would create problems with all the functions that render a node. The assumption is that a node is rendered when it is going to be visualized, but that is always true, as (for example) node_search_execute() renders the node while executing a search for a set of key words. There are other 10 functions that call node_view(), including the one rendering multiple nodes; all of them would have a problem, if the user is redirected in the middle of what they are doing, which means PHP stops its execution as exit() is being executed.
If you are using the PHP filter to execute PHP as node content, that is not suggested to do. If you need to dynamically render a node content, you should implement a module which could be implement an input filter, or other hooks, depending from the needs.
If you are using a custom module to redirect the users when the node is being loaded, or rendered (e.g. implementing hook_node_load(), or hook_node_view()), you would have the same problem I described first. Plus, as you are already using a custom module, then you can implement one of the solutions I have proposed.

As for other suggestions:

hook_menu_alter() is used to alter the existing menus. For the nodes, the menu callback is the one associated to node/%node, which is invoked for every node. It is possible to use this hook to alter the page callback with a different one that first check which node is being viewed, and then redirect the users to the other node. In this case, there would not be problems, as the function is called when the node is being viewed, not when a node is being loaded, or being rendered in memory.
IMO, it would be a sub-optimal solution. I would rather implement hook_menu() to define a new menu callback.
The Path redirect allows to set static redirects from the UI. This doesn't help if the intent is having a dynamic redirect, which seems the case here.
The Rules module can be useful, but I would rather use it if you need it for more than what you are trying to achieve here. It is a better solution that enabling the PHP filter module to execute PHP code inside a node body, but it would probably require you to write PHP code that is executed through eval(), which should generally be avoided.


How can I retrieve parameters from the path?

If this is Drupal 8, you can simply do:

$foo = \Drupal::request()->get('guide');


ahah_helper or ctools for ahah in Drupal 6?

You're better of using ctools in D6. Also all the ctools ajax implementation is whats in Drupal 7 known as the Ajax Framework


Procedurally:

if ($field_items = field_get_items('node', $node, 'field_charity_reference')) {
  $referenced_node = node_load($field_items[0]['target_id']);
  $title = $referenced_node->title;
}

Or OO'ly with the Entity API module:

$node_wrapper = entity_metadata_wrapper('node', $node);
$title = $node_wrapper->field_charity_reference->value()->title;

If you go the OO route this post will probably come in handy


Views: Use like operator in exposed search filter (Search: Search Terms)

When you set a new filter in views on a field (for example node title), you can set the Operator to contains which is the equivalent of SQL LIKE.
You can also expose the filter and the operator to the visitor.
If you want to see the SQL query in the preview, check the option Show the SQL query in view setting.

Instead of Search: Search Terms, use Global: Combine fields filter; it will allow you to search multiple fields using the operator you want.


XMLSitemap- Is it OK to add nodes both by content type and menu?

There is no harm in adding both by menu and by content type (I have tested this before).  In my experience, paths will not be duplicated.

If you also add by content type, then that priority will be used, even if it is lower than the one you have set for the menu.  Also, the last modification date will be used; it doesn't get used when you add by menu.  The XML Sitemap module also checks node access rights, so only ones visible by anonymous will end up in the sitemap.

If you add by menu, the module will not output links that the anonymous user doesn't have access to.

I don't recall explicitly testing paths that exist in multiple menus, though.


Views - using "admin/" in path gets me to the home page

Configure the view to have /admin/my-archive as the URL and then access it via /gestione/my-archive. Rename Admin Paths works using hook_url_inbound_alter() and hook_url_outbound_alter() which means that internally the path is still admin/*.


Is it possible to preserve image quality when uploading images?

There's two solutions to this. The easiest is:

Upload images with a "jpeg" extension instead of a "jpg" extension. For whatever reason, images with a jpeg extension are not mangled by Drupal.

However, the best solution if you have control over your hosting environment is:

Install the imagemagick module.


Placing user login and user menu at the bottom right when this is not supported by the theme

Never directly use the Bootstrap theme, create a subtheme from one of the starterkits inside your theme folder (they have readme files inside the starterkits with more info and relevant links depending on which method you prefer to use), and do all your work in the subtheme. This way you can auto-update the bootstrap theme, without loosing all your customisations.

Next step would be to create your own region (for example Footer right) in the info file of your subtheme:

;;;;;;;;;;;;;;;;;;;;;
;; Regions
;;;;;;;;;;;;;;;;;;;;;

regions[navigation]     = 'Navigation'
regions[header]         = 'Top Bar'
regions[highlighted]    = 'Highlighted'
regions[help]           = 'Help'
regions[content]        = 'Content'
regions[sidebar_first]  = 'Primary'
regions[sidebar_second] = 'Secondary'
regions[footer]         = 'Footer'

regions[footer_right]   = 'Footer right'

regions[page_top]       = 'Page top'
regions[page_bottom]    = 'Page bottom'

Next create the region in your page.tmpl.php file. You should override the one used in the Bootstrap theme, with a duplicate you make in your subtheme: YOUR_SUBTHEME/templates/system/page.tpl.php. (Copy the file you have in YOUR_SUBTHEME/bootstrap/system/page.tpl.php)

Go to the footer section in this page.tpl.php file, it should look somewhat like this:

<?php if (!empty($page['footer'])): ?>
  <footer class="footer <?php print $container_class; ?>">

    <?php print render($page['footer']); ?>

<?php endif; ?>

And add your new region where you would like it to go (for instance like this), and use the Bootstrap markup to align your content to the right:

<?php if (!empty($page['footer'])): ?>
  <footer class="footer <?php print $container_class; ?>">

   <?php if (!empty($page['footer_right'])): ?>

      <?php print render($page['footer_right']); ?>

   <?php endif; ?>

    <?php print render($page['footer']); ?>

<?php endif; ?>

Make sure to clear your sites cache when you're doing changes to template files like these. If all is fine, your new region should appear in "structure > blocks", and you should be able to add your login blocks to it.


Okay, I don't know how I missed this.

/** @var \Drupal\group\Entity\GroupType $group */
$group = GroupType::load($groupKey);
$plugins = $group->getInstalledContentPlugins();
foreach ($plugins as $key => $plugin) {
  $bundle = $plugin->getEntityBundle();
}


Custom VBO action fails silently / works with AJAX error in Views Admin

The malfunction was due to the VBO form appearing inside another form. I changed the page callback to be a regular function (not form builder) that loads the block view and actions are working.


What is required to get a custom module to appear in uninstall list?

For Drupal 6, you needed to install/uninstall schema using hook_install and hook_uninstall.

This is not necessary for Drupal 7.

Module will appear in uninstall list if both of these conditions are met:

module implements hook_schema OR hook_uninstall in its .install file.
module was enabled once and now is in disabled status.

If the only purpose of hook_uninstall is to uninstall the schema, you do not need a hook_uninstall function. For variable_del(), etc: you need.
If you have any of these and module has data in the site already, you will see the uninstall check box.


Drush does not download modules correctly

Drush will put downloaded modules in the current directory if it cannot bootstrap a Drupal site.  Run drush status to determine whether or not the Drupal site you think you are operating on is recognized by Drush.  You might need to use the --uri option to specify the name of the folder that contains the settings.php file, or set up a Drush alias file.


How to use Rules to populate reference product after creating a Commerce product?

Despite the limited information in your question, you should be able to create such rule (using the Rules module) like so:

Use a Rules Event that is related to "When Commerce product is created" (something similar to "After saving content"?).
Add a Rules Condition to make your referenced product field become available to use in a Rules Action. This condition can be either of those alternatives:

"Entity has field".
"Content is of type".

Add Rules Action "Set a data value" for your referenced product field.


How to “filter” out one specific user in a view?

In your view filter out the user:

Add relationships: Node revision: User
Label: user
Require this relationship: (checked)
Add filters: User: Name
Relationship: user
Is not one of: manager


How to remove the Themekey module after its Installation failed?

Use Drush drush pm-uninstall themekey or Drupal Console drupal module:uninstall themekey to disable themekey from the command line.


Edit node link in view redirects to false URL

I ended up including the node ID and generating the edit link myself, with the catch that I can't hide the field for underprivileged users because it can never be empty (just prints an empty string in that case). It's an acceptable solution but I'd prefer to se the built-in method.


Custom page template for specific node - template inheritance

Templates are chosen based on the other that they are in the $variables['theme_hook_suggestions'] array.

So if you have a list:

page.tpl.php
page--node.tpl.php
page--node--1.tpl.php
page--node--edit.tpl.php

Then it will look from the bottom up and use the first template it finds.

From Drupal 7 Template (Theme Hook) Suggestions:

  When the page is actually rendered, the last suggestion is checked. If it exists, that suggestion is used. Otherwise the next suggestion up is checked, and so on. Of course, if none of the overriding suggestions exist, page.tpl.php is the final suggestion. This also explains why page--front.tpl.php, if it exists, overrides any other suggestion for the front page: it is always the last suggestion for the page designated as the front page.

Because you have custom code (I'm assuming your code here) that adds a tempalte suggestion to the end of that like this:

$variables['theme_hook_suggestions'][] = 'page__custom_page';

Then that suggestion is added to the end of the list, so will override all previous ones if it is present.

If you want to have different template precedence then you have to make the hook suggestions array use that order.

There are a number of ways you can do this and it depends what you want to achieve as to how you want to do it.

If you want your template to be last in the template precedence (first in the array) then you can do this:

array_unshift($variables['theme_hook_suggestions'], 'page__custom_page');

Other than that you can also use other PHP array manipulation functions to insert your suggestion in the middle of the array, or you could add your suggestion to the end, then add other suggestions after it again (it doesn't matter if a suggestion is in the array multiple times, the first time it is checked it will be used).


How to perform a page redirect after submitting node with conditions?

Solution for option A:

Below is a sample of a rule (in Rules export format) that should allow you to specify a Rules Condition related to a specific value selected via a selection list (and when a new node is created):

{ "rules_new_node_with_special_optionlist_value_a" : {
    "LABEL" : "New node with special optionlist value A",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_optionlist" } },
      { "data_is" : { "data" : [ "node:field-optionlist" ], "value" : "A" } }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "A new node got created with option list value = Advanced" } }
    ]
  }
}

Some more details to further explain the above above sample:

The Rules event I'm using is "After saving new content" (replace this event by whatever fits your case).
In my case I have a selection list field with machine name field_optionlist.
This field actually has 2 possible values, like so:

A (=Advanced).
B (=Basic).

As a sample, I decided to use as condition "The selected value must be Advanced".
If that value is selected, then (as Rules Action), a message is shown like A new node got created with option list value = Advanced. Feel free to change that to whatever Rules action, this is how I often "unit test" new rules I write. In your case you want to make it a redirect to your URL A.

The "clue" to make this rule work is the condition Entity has field. That's also what is mentioned in the Rules UI when you're adding a "data comparison" condition: somewhere it says "The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type')".

Note that I've not added a Rules Condition here about selected content types, that's probably an extra condition you might want to add also. But if the selection list field is only used for the content types you're interested in, then the Entity has field condition should be sufficient already.

Solution for option B:

Clone the rule you created for option A into a similar rule, this time to check for the value of "B", and to perform a Rules Action to redirect to your URL B.

With those 2 rules in place, your disered logic is implemented, and you don't need the "Conditional Rules" module either.


How to display an image in a report created with the Forena module?

1. Display an image with a hardcoded path

The body of a Forena report is an XHTML file, which you can edit using the WYSIWYG report editor (ie the layout tab). So if you just add an image tag with a path pointing to your image, you can display such image anywhere in your report.

2. Transform the hardcoded image path into a Skin configuration option

Using Report Skins, you can use the technique of Defining skin configuration options. This allows for defining arbitrary variables that can be referenced in reports using the skin data context.

For example, assume you define a variable in the skin like so:

imagepath = path/to/image

Anywhere in your report, you can then refer to the token {skin.imagepath}.

3. Create a separate data block

If it makes sense for this specific question, you might want to consider just creating a separate (additional) data block related to the image to be displayed. That way you just retrieve the relevant data (row) from your file_managed table (as in your question), and surround it with whatever HTML markup you'd want.

4. Available FORENA hooks for adding reporting extensions

Yet another option might be to use some of the available Forena hooks. Here are some of them that may help you:

hook_forena_data_alter
hook_forena_parameters_alter

Disclosure: I'm a Forena co-maintainer


you can change a position of menu and search block from structure > block link and assign it to * custom made region *, also use custom css can fix your problem.

also you can Demonstrate  the all region of theme from admin/structure/block/demo/bartik

hope this will help you


It sounds like your problem is that you have delete a field on your node, which makes Drupal rename the table storing the field data to field_deleted_data_ID. The error you are getting is that one of such tables is missing, and the delete fails since the query to delete the data creates a SQL error.

I know of two ways to solve this.

Recreate the table deleted.
Delete the field info from field_config and possibly field_config_instance.


How to inspect a variable when testing with `drush test-run`.

Call DrupalTestCase::assert() passing the message to show.

$this->assert(TRUE,
  t('Variable content: @variable', array('@variable' => var_export($variable, TRUE))
);

This is similar to the code used by DrupalTestCase::assertIdentical(). The difference is that in your case the first argument is TRUE because you are just outputting the content of a variable, which never fails.

protected function assertIdentical($first, $second, $message = '', $group = 'Other') {
  return $this->assert($first === $second, $message ? $message : t('Value @first is identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
}


How can I Display 'Items per page' in pager instead of the exposed form

In Drupal 7 under PAGER click on "Paged, xx items", then look at the Pager options window


In the File Entity module, what is the difference between "Manage display" and "Manage file display"?

Manage display is the core page to manage the display of fields for various view modes.

The Manage file display tab is provided by the File Entity module; the page callback for that tab is file_entity_file_display_form(), whose description is:

  Form callback; presents file display settings for a given view mode.

So the difference is that display settings that relate to the file entity module have been separated out from the core Manage Display form, on a per view-mode basis, and that extra tab is where you set them.

As noted in the comments this is covered in a lot more detail as part of a broader question


alphabetize the taxonomy term page without views

The taxonomy module uses the taxonomy_term_page function to build the page that list the nodes attached to a term. But the function that really do the query is the taxonomy_select_nodes that is called by this previous function.

Remember: Never hack core

So you can implement a custom module and use the hook_menu_alter to rewrite the page callback for the taxonomy/term/%taxonomy_term path using a new function based on the taxonomy_term_page to call your custom taxonomy_select_nodes function that perform the changes you need to order the nodes that way.

You'll need to do something like this:

function mymodule_menu_alter(&$items) {
  // Rewrite the taxonmy term page callback
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'mymodule_taxonomy_term_page';
}

After that you'll have to implement the mymodule_taxonomy_term_page function in order to be able to make the changes you need on the taxonomy_select_nodes() call:

function mymodule_taxonomy_term_page($term) {
  # code...

  if ($nids = mymodule_taxonomy_select_nodes($term->tid)) {
    # code...
  }
  # code...
}

Finally:

function mymodule_taxonomy_select_nodes() {
  # code...
}

You'll must JOIN the node table to build the query in the mymodule_taxonomy_select_nodes function because the taxonomy_index table doesn't have the node title.

Notice that will change the behavior of all taxonomy term pages.

For more info about how to create a custom module see http://drupal.org/node/361112.


You can with '#type' => 'password' in  your form.

Ex:

$form['social_sec'] = array(
  '#type' => 'password',
  '#title' => t('Social Security'),
  '#description' => t('Please enter your social security number'),
  '#size' => 9,
  '#maxlength' => 9,
  '#required' => TRUE,
);

If you want this as a field in a node's form, then you will have to use hook_form_BASE_FORM_ID_alter and alter an already existing field.


Think you're looking for $_SERVER['HTTP_HOST']. Also see $base_path, $base_url, $base_root


What is the recommended jQuery and jQuery UI version?

There is usually a difference between the front end, and backend.
Some of the core displays rely on an older version of jquery.
If you install the jquery_update module, you will be able to select different versions for front end and back end - and it will tell which is the default version for Drupal Core.


How to override custom block methods in drupal 8

Your other module can implement hook_block_access().

The example code in Drupal core looks like this:

function hook_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {

  // Example code that would prevent displaying the 'Powered by Drupal' block in
  // a region different than the footer.
  if ($operation == 'view' && $block
    ->getPluginId() == 'system_powered_by_block') {
    return AccessResult::forbiddenIf($block
      ->getRegion() != 'footer')
      ->addCacheableDependency($block);
  }

  // No opinion.
  return AccessResult::neutral();
}

Since it's a hook, you would have to replace the word "hook" in the function name with the machine name of your module, and place this function in the .module file.


how can i specify in my migration not to migrate unpublished content?

You could try using the skip on value plugin.
Untested, but probably like:
process:
  status:
    plugin: skip_on_value
    method: row
    not_equals: true
    value: 1
    source: status

Should only import published content.


Page not found for a node that does exist?

You cannot write a node using a single drupal_write_record(). Depending on how your content type is defined you will need to write to several tables. But you don't need to know the precise details because the right way to create a node is to use node_save() as Ahmed mentioned in his comment.


How to redirect all 404s to the same path on a different server

Here is small trick:

Enable module PHP Filter, add PHP filter to administrator

Create a node can use php filter, add code: (We are using header here, not use drupal_goto because handle 404 workfollow of Drupal will redirect to the node first.

<?php
  $url = drupal_get_destination();
  header('Location: http://other.example.com/' . $url['destination']);
  drupal_exit();
?>

Config Drupal using 404 page is the node you was create.


How to find if file was successfully uploaded to webform

I wouldn't recommend doing this with javascript, you should use a PHP function to inform the client-side of success.

However, if you insist on doing it,  you could (in theory) just create a new AJAX call to the location wehre you expect the new file to be.   If it errors,  it means it wasn't uploaded.

$.ajax({
    url:'http://www.example.com/yourfile.jpg'
    error: function()
    {
        //file not there.
    },
    success: function()
    {
        //file is there
    }
});


Bad request with Acquia Dev Desktop2 overriding installation

As an alternative solution, I tried to add the following setting setting to httpd.conf.

<IfVersion> = 2.4.25>
 HttpProtocolOptions unsafe
</ IfVersion>

'Bad request' message is solved.
The reason was that ServerName contained underscores.


Indexing all pages of a website in Google

The XML sitemap module will generate a file which can be submitted to google, and other search engines to tell them about all of your content.


Image link in views exposed filter gallery

Try  the Colorbox module; it is great and very configurable, and it has also an image-format option for the Views module.


Add node reference to Product field with rules

You rule seems to be using the Conditional Rules module ... which does not play well with saving entities like your rule seems to be doing.

You should rework those parts of your Rules Actions to performing equivalent Rules Components. After doing so, you have taken away a possible reason why your rule does not seem to behave as you would expect ... and possibly also solved your issue. For more details on that, refer to the answer to "What's the alternative to using the Conditional Rules module?".

Debugging is the art of taking away all possible reasons why something doesn't work as you'd expect it to work ...

PS: I'm assuming this question is about D7.


How to print id of user whose profile I visit rather than id of  logged in user?

If you add this to the user-profile.tpl.php template, it will show the UID of user account being viewed.

<?php echo $account->uid;?>


Why does loadMultiple load 1000 nodes 9.2 times faster than loading each node one by one?

It's likely that when you are loading individual nodes, you are loading the entity type manager, then for each node retrieve the storage, do a query to get the node data, and build the node. With the multiple process, some of the DB queries are likely combined, and the processing will be in a batch rather than having to run through the code multiple times.


Rewrite Results -> Output as Link: How do I get this to work?

Don't the instructions for the link field tell you that you can use tokens in the URL?  I do not have a view with a text field handy, but here is a screenshot from a view where I make a custom link for the title field:

Scroll down to the Replacement Tokens and expand that field.  One of the options should be something like [field_fileSymLink].  Then you should be able to use something like http://apollo.tbc.iit.edu/~spaceweather/[field_fileSymLink] or maybe just /[field_fileSymLink].


General template (node.tpl.php) being used instead of specific template (node-article.tpl.php)

Are you using Drupal 7? If so, you should just leave node.tpl.php as it was originally and call your customized version node--article.tpl.php.

If you are using D6 you are naming the file right, you should just leave a copy of the original node.tpl.php in your subtheme folder.


right sidebar doesn't shrink in zen responsive theme

Inspect the right sidebar element in your browser. Then select

<section class="region region-sidebar-second column sidebar">

in the DOM and it should give you the width as a percentage. This is proof that the sidebar is responsive. Now drag the browser window smaller and observe the media query changing at breakpoints and the percentage should also change. At mobile breakpoint the sidebars should be 100%.

Now look in your sub theme's sass/layouts folder for the file _responsive.scss

You will see snippets like this

$zen-column-count: 3;
...

#content {
          @include zen-grid-item(2, 1);
        }

        /* Span 1 column, starting in 3rd column from left. */
        .region-sidebar-second {
          @include zen-grid-item(1, 3);
        }

This is where the sidebar width is set in relation to the content area. In the above case it is 1 column wide starting at column 3. As there are a total of 3 columns it is 1/3 the total width.

You can change it here if you have compass set up and working and properly watching the folder for changes.


Is cache_form table making a site faster by any way?

The cache_form table holds forms that have been loaded by the system for your visitors. Eg, if a person went to a form before the form has expired, it exists in the form_cache by default.

Sometimes forms can bypass the form_cache if they are required to be rebuilt on every page request, such as with Ajax requested forms, or external services.

If you have a Shopping Cart driven application the cache_form may contain stuff added to your visitors cart -- which they have not purchased yet (I'm not sure if commerce stores cart entries in a separate table), but in general be wary of clearing the form cache because some of your visitors state may be lost.

Expired forms should be cleared by the system on cron run.


How do users can login automatically through URL when they click on the link received in Email

Try the Login one time module

  Login one time provides the ability to email one-time login links to users. You can also choose the pages they will land on.

Another module is urllogin

  This module provides a way to transparently log users into the web site when they follow a link. The primary use is for mass email where users are send individualized URL’s which take them to a page on the site, in a “logged in” state. Every effort has been made to minimize the potential security risks.


How to set different themes for multiple domains

I got an solution that my colleague suggested through a contrib module.
But, not yet used it perfectly for themes.

Steps for getting it are as follows -
1. go to

  www.github.com
  and sign up for free.
  2. Take a git clone of the
  https://github.com/agentrickard/domain.git
  in modules folder in your drupal code base.
  3. Extend the module and try it out.


Drupal Feed importers: Update Node values without needing to include all values in Feed

You want to stick with the Update existing nodes to retain your existing content fields here.

The simplest way to prevent overwriting is to remove whatever mappings that aren't available in your CSV. If you have different CSVs with different available columns, cloning your current CSV feed importer and remove the columns from the new importer should accommodate different data update sources.


I'm not sure what is the purpose of this, now in Drupal 8 Guzzle is available to creating external and internal request.

$this->httpClient->get($href)->getBody(TRUE);

The httpClient is a service in Drupal 8  api.drupal.org/api/drupal/core%21core.services.yml/service/http_client/8

you need inject this service in your class.

if you need read the Route properties like callback, permissions, etc. you need use the routeProvider service.

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Routing%21RouteProvider.php/class/RouteProvider/8

maybe more information about that problem help us to understand what is the best way to porting for Drupal 8

UPDATE:

Thinking a little more, you want to make a sub-request?

something like https://gist.github.com/dmouse/4976461875a27689d155


Form #after_build is not working for PHP 7x

There are only 2 args to an after build method, the element and the form state.

Just remove the extra one and it’ll work:

function change_pic($element, &$form_state)


How do I add an edit button on each row of a "tableselect" form element?

Check out http://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_admin_nodes/7

In particular, take a look at the lines that contain "operations". You need to set up a new element in $header to contain a column for the "operations", and then add at least one operation inside $options for each row.

You could either manually add a link to the edit with l(), or you could use module_invoke('node_operations') - again, an example of that is shown in the API.


Rules: Send mail to author when value in date field has passed

Assuming you are using Drupal 7.

You need to enable the Rules Scheduler module, it comes with Rules.

Then for Rule event use After saving new content.

Add condition, content is of type: Contest

Exit out of your Rule, and now create a Rule Component of Data Type: Node

Add condition, content is of type: Contest

Action Send E-mail.

Now exit the component and go back to your rule, for action, schedule rule component, and use your end-date field for schedule evaluation date.

I highly suggest you watch Introducing Rules Scheduler and I am sure my answer will make more sense to you.


Views argument to match single date with date range field

It's a known bug, please see Multi-day events don't show up on day view of spanned days.


Why does DRUPAL_BOOTSTRAP_PAGE_CACHE phase come before DRUPAL_BOOTSTRAP_DATABASE?

Inside of _drupal_bootstrap_page_cache() the key bit of information is this bit of code

  if (variable_get('page_cache_without_database')) {
    $cache_enabled = TRUE;
  }
  else {
    drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
    $cache_enabled = variable_get('cache');
  }

The call to bootstrap DRUPAL_BOOTSTRAP_VARIABLES will also bootstrap DRUPAL_BOOTSTRAP_DATABASE because it's before variables inside of drupal_bootstrap()

What this means is if your cache doesn't require a database connection (like memcache or filecache) then you can speedup page cache hits by not connecting to the database. The linked article talks about this.


If you have Colorbox installed, you can install Colorbox Node & Overlay which will let you create a colorbox node link with a colorbox-node class (e.g. My Node).

In your theme's node preprocess function, you can add that class to the read more link:

/**
 * Implements hook_preprocess_node() in your theme's template.php
 */
function MYTHEME_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'teaser') {
    $variables['content']['links']['node']['#links']['node-readmore']['attributes']['class'] = 'colorbox-node';
  }
}

You'll need to adjust your theme's stylesheet rules to hide the non-body fields (and other styling as necessary), but it will work.


Adding a wrapper to contain tables using grouping field in views / display suite

You can add classed to your regions within Display suite:

Add CSS classes to regions
Now that you have defined regions you can define custom CSS classes for them.

Go to Administration > Structure > Display Suite > CSS Classes (admin/structure/ds/classes)
Enter custom class names in the fields "CSS classes for regions” (one per line). You can provide a human friendly class name by using a pipe ("|”), e.g.,:

class_name_1
class_name_2|Class two
extravagant|Extravagant
subtle_emphasis|Subtle emphasis

Click "Save”
Go to Administration > Structure > Display Suite (admin/structure/ds/layout) and choose "manage display” for the desired entity.
Choose the tab "Custom classes” to assign the classes to the regions
Click the tab "Extra classes for regions”. Assign the defined classes to the regions.
Click "Save”
You can check the source code of your web page to see the new classes and start styling them in your CSS.

From Manage displays.

You can use above steps to add a class to your Display Suite region. Depending on how Views renders the View, explore the DOM to see if you need to select additional classes.


For external data, should I create custom table or new entity type?

It's really up to HOW you are going to use it. Just listing it? Will you extend it with new fields? How likely will be problem be more complex in the future?

Custom entity is a definitely good thing: it's not just about views, but lot more (entity hooks/events for example). Don't worry about performance yet, since you didn't mention anything that could be dangerous.
Still regarding simplicity the table solution would be still a winner.


How to create media image entities like an image field?

Sounds like exactly the use case Inline Entity Form was built for:

  Provides a widget for inline management (creation, modification, removal) of referenced entities.


How do I get the currently logged-in user?

How do I get the currently logged-in user ID in the controller class?

Controllers have a currentUser method:
public function filtrer($firstLetter='', $nbr_ligne='') {
  $current_user_id = $this->currentUser()->id();
}


What is the correct way to organise and separate functions in a Controller into their own files?

There are a few things that you can do.

As already suggested by Jaypan, you can have as many controllers as you like, grouped by whatever makes sense for you. You can also have a base classes/hierarchy and re-use code through that
You can define services and also static classes/methods to extract re-usable logic (or also not-reusable logic). I'd say that's the 1:1 replacement for functions in include files. Services are defined in a yourmodule.services.yml and you can use dependency injection to make each service self-contained with explicit dependencies to other systems, so that you can also write (unit) test for that code.
You can also use Traits, a relatively new PHP feature that basically allows you to put a few methods into a separate file and include it in one or several classes where you can use them internally as if they were defined on that class. Kind of like a base class except that you're not limited to a single trait, you can have as many as you want.


Let Gmap center on the users geolocation, but still load all the node markers onto the map

I can clarify after my comment on your question is addressed but if I had to guess I would say you are using an nid contextual filter to center the map?

If so, that is why you aren't getting other nodes.

Alternatives are:

Add the Global: Null contextual filter and pass the nid through that. The null contextual filter will not affect results at all.
Keep using the nid contextual filter, but check the "Exclude" checkbox in the "More" fieldset of the filter. This will mean all nodes except the given nid will be displayed, but the given nid can still be used to center the map.

Use whichever method gives you the functionality you want.


How can I exclude API keys, passwords, and so on from configuration management?

You can't exclude specific keys easily from being exported.

However, you simply can not store the real keys there in the first place, and rely on local overrides through settings.php only, e.g.

$config['yourmodule.settings']['smtp']['api_key'] = '24ztsgfet';

And in the UI, you just store "dummy" or any other string. Note that there's currently no indication that a value is overridden in the backend, it will however display only the value that's actually stored in config, not overrides.


No. The menu router system only understands % as placeholder within / characters as an argument to pass through to the callback function that will render it. It won't understand prefix-%-postfix other than its literal value. The underlying function, arg(), that the Views Content ID from URL contextual filter relies on to retrieve an argument relies on this system so it wouldn't be able to pull the argument.


If you're familiar with Drupal's hook system, you can do this via hook_block_view_alter


Best way to learn something new about your project is not to ask "what is going on" but do own investigation. Try to debug as much things as possible. You can start by enabling Theme debug mode This is great feature implemented as of version 7.33

As Drupal documentation states:

  As of Drupal 7.33, Drupal core has a theme debug mode that can be enabled and disabled via the theme_debug variable. Theme debug mode can be used to see possible template suggestions and the locations of template files right in your HTML markup (as HTML comments).

Place $conf['theme_debug'] = TRUE; variable in your settings.php file and use Developer Tool (F12) in your browser or any other tool that can help you see source HTML markup.

With theme debug mode you will be able to see all template suggestions and what tpl file was chosen to rendering. If your tpl file is really rendered you should see something like:

<!-- BEGIN OUTPUT from '(...)/views-view--travel-extras-hotel-carousel--block.tpl.php' -->

This way you will discover the cause and learn something new about your Drupal project.

Remeber to clear cache (at least theme registry cache) after each change connected with template files. This assures that your theme "knows" about tpl file. The same applies to preprocess or hook functions.

Remove mytheme_preprocess_views_view - try to solve initial problem first.


My problem is not due to webforms but to a rule that is triggered when a webform is saved. The condition I put in the rule needs to be fixed, in order to run only for a specific webform.


hook for db insert function on custom table

No, there's no hook invoked for db_insert.

If you have a custom table, though, you're probably controlling the insert code yourself, in which case you can invoke your own:

db_insert()->(...);
module_invoke_all('mymodule_foo_insert', $some_contextual_data);


How i can create VIEW table using Drupal hook_schema()

hook_schema() is only used to return a structured array representing your module's database tables. You can't execute a query from it. Well, you physically can, but you shouldn't.

Since hook_schema() is used on install, your code to create the View should be in hook_install(), and the code to remove it should be in hook_uninstall()


This is indeed most likely an access issue. However, I don't think it's something with Apache Solr but more with some of the additional modules you might have enabled. Can you list them with the versions here?

Also, as mentioned above, disable apachesolr access and rebuild your permissions. Check if it is still the case?


Proxying a subdirectory to a remote site

Drupal should be able to install into a sub-directory and "just work" without fiddling around with it. This question already answers this particular sub-directory issue:

How to get Drupal 7 installed in a sub-folder / sub-directory properly?

Try re-installing a fresh installation into the sub-directory. Can you login? The .htaccess of 2.site.com should have nothing to do with the issue at hand regarding 1.site.com.

The reason for your problem is likely something along the lines of a clean-url issue fighting against your configurations. A fresh install will be the easiest way to resolve this particular issue.

Regarding this line:

  and I'd like only that subdirectory to go to an arbitrarily named
  server with a drupal install at, say "https://2.site.com"

The domain merely points to a directory. The domain ISN'T an actual file location. As such, this particular line doesn't seem to make any sense. If the issue is not resolved by simply clearing out and reinstalling Drupal in the sub-directory at hand, please re-state your question by providing more information, describe where these sub-directories are in the system root relative to each other and then describe which directory each domain points to. Don't describe domains AS directories because they aren't directories - they're pointers.


What are recommended filters for using Pagespeed along with Drupal 7 (and Advagg enabled)?

Every site is different. I recommend extensive testing. http://www.webpagetest.org/ is one of the better sites for testing the frontend and seeing what options are best for you're site. Be sure to test more than just the frontpage & look at the connection view; using the bundler you can adjust this a little bit, try a bundle of 1 or even 10. Point is you'll need to experiment to get the best results. The modifier has lots of things you can do to tweak things; deferring the js is one of the better options in my opinion.

I've heard that google pagespeed has a +-20% difference; it works better or worse depending on various factors. Give it a try and be sure to test!

Work on inline css is being done btw: https://www.drupal.org/project/css_delivery


A module that allows user to create content anonymously, then if they register, assigns the content to them

You should use Create and Register module.

  This module creates a "lazy registration" which means that the user creates the content first and after this logs in or registers to the site.


I tried many different ways of loading the user, using the session as the starting point. In every singe scenario it fell down.
So in the end I used as much of the Drupal scaffold as I could, and copied the relevant bits from the relevant classes and functions in order to control the loading of a user record in an ajax handler that exists outside of Drupal's page space.
It uses the cookie to load the session, retrieve the user id, details and roles and create an account object before setting the bootstrapped Drupal kernel current user to the account object.
We deal with access control at a higher level (relying on \Drupal::currentUser() and leveraging $user->isAuthenticated() for example) so this script gets up to a consistent point in both contexts (inside Drupal, and non-drupal pages inside the domain) for user management etc.
<?php

/**
 * @file
 * Bootstraps the Drupal kernel and loads the user for the incoming request via cookie
 */

use Drupal\Core\DrupalKernel;
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\UserSession;
use Symfony\Component\HttpFoundation\Request;

function _find_autoloader($dir) {
  $autoloadFile = $dir . '/vendor/autoload.php';
  if (file_exists($autoloadFile)) {
    return include_once($autoloadFile);
  }
  elseif (empty($dir) || $dir === DIRECTORY_SEPARATOR) {
    return FALSE;
  }
  return _find_autoloader(dirname($dir));
}

// Immediately return if classes are discoverable (already booted).
if (class_exists('\Drupal\Core\DrupalKernel') && class_exists('\Drupal')) {
  return \Drupal::service('kernel');
}

// Load autoload
$autoloader = _find_autoloader(empty($_SERVER['PWD']) ? getcwd() : $_SERVER['PWD']); // defined in start.inc
if (!$autoloader || !class_exists('\Drupal\Core\DrupalKernel')) {
  print "This script must be invoked inside a Drupal 8 environment. Unable to continue.\n";
  exit();
}

const MAINTENANCE_MODE = 'update'; // Don't bother theming

if (PHP_SAPI == 'cli') { // CLI won't have a cookie, stop now
  return;
}

$request = Request::createFromGlobals();
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel->boot();
$connection = $kernel->getContainer()->get('database');

// Get session id from session cookie
$sid = reset($_COOKIE);

// Get uid from sessions, get user from uid
$query = $connection->queryRange('SELECT uid FROM {sessions} WHERE sid = :sid', 0, 1, [':sid' => Crypt::hashBase64($sid)]);
$uid = (string)$query->fetchField();
$values = $connection->query('SELECT * FROM {users_field_data} u WHERE u.uid = :uid AND u.default_langcode = 1', [':uid' => $uid])->fetchAssoc();

// Get roles from uid, and set account
if (!empty($values) && $values['status'] == 1) {
  $rids = $connection->query('SELECT roles_target_id FROM {user__roles} WHERE entity_id = :uid', [':uid' => $values['uid']])->fetchCol();
  $values['roles'] = array_merge([AccountInterface::AUTHENTICATED_ROLE], $rids);
  $account = new UserSession($values);
  \Drupal::currentUser()->setAccount($account);
}


Associate webform submissions with the user created

I would recommend checking out the available hooks provided by the Webform module: http://cgit.drupalcode.org/webform/tree/webform.api.php

It looks like hook_webform_submission_insert() will be your best bet, with that you should be able to not only programmatically create the user at that point, but then update the submission with the newly created user id.

function my_module_webform_submission_insert($node, $submission) {
  // Create new user.
  // Retrieve new user id.
  // Update webform submission with new user id.
}


How to implement arbitrary editable content areas

Take a look at the Panels and Panelizer modules; they'll provide the basic building blocks you need for the kind of layout and editing experience you want.

They'll let you create arbitrary layouts (Panels comes with a few...creating new ones is easy) and embed panes of content including just custom HTML (called a custom content pane) at arbitrary URLs or, using Panelizer, by customizing individual nodes on a per-node basis.

Use the Fieldable Panels Pane (FPP) module, or the Bean module, to let you define fieldable components that can be placed into a layout using Panels or Panelizer.  So you could create an "image" FPP that has a field for a user to attach an image.  You would then control the actual rules for how that image is output, and the markup that surrounds that image, by configuring the view modes for that FPP.  Rinse and repeat for all the different sorts of elements you want users to be able to create.


Disable 3rdparty hook from custom module once

You could implement hook_module_implements_alter() to avoid a hook implemented by a module is invoked. The problem is that Drupal saves in cache the list of modules implementing a hook, but you can change the list of hooks implemented by modules back to the original one.

function mymodule_implements_alter(&$implementations, $hook) {
  if ($your_condition && ($hook == 'page_delivery_callback_alter')) {
    $old_implementations = &drupal_static(__FUNCTION__, array());
    if (empty($old_implementations)) {
      $old_implementations = array_merge(array(), $implementations);
      unset($implementations['menu_trail_by_path']);
    }
  }
}

function mymodule_exit() {
  $old_implementations = &drupal_static('mymodule_implements_alter', array());
  $implementations = &drupal_static('module_implements');

  if (!empty($old_implementations)) {
    $implementations['page_deliver_callback_alter'] = $old_implementations;
  }
}

This code works only in the case hook_exit() is invoked, which is normally done in drupal_page_footer().

You should be sure mymodule_implements_alter() is executed after the implementations made from other modules, in order to preserve the changes done from other modules.


What is causing Unknown field error in EntityFieldQuery API?

The code above seems right only problem here might be the machine name of the field is not same as the one given in
->fieldCondition('field_referee_id', 'value', '1', '=');
or the field might be multivalued field, for multivalued field in place of '=' 'IN' should be used.


Even adding something as simple as drupal_set_message doesn't result in a message being displayed.

That's the  expected behaviour - in the logout hook, you're still inside the authenticated user's session. Once they're logged out, you're not any more. So messages intended for that user are no longer there, because that session has been destroyed.

You should implement a logout/token expiry resource in your API, and invoke that in the logout hook. Then you don't need to remove the token held in local storage, as it will not be valid any more.


How to load all information Currency properties by currency code?

As a currency is just an entity you can do the following:

$currency_code = 'AUD';
$entity_type_manager = \Drupal::service('entity_type.manager');
$currency = $entity_type_manager->getStorage('currency')->load($currency_code);
ksm($currency); //check out what's available

//eg get sign
$sign = $currency->get('sign');

Good Luck


Here is a script I wrote for different time consuming tasks to run on a multisite installation

The file has to be in your sites folder.

The script will loop through all folders (except all and default) to run the command choosen on every sites based on their settings.php file

#!/bin/bash

# Get all Drupal sites
sites=`find . -maxdepth 1 -type d -print | grep -v '/all$' | grep -v '/default$' | grep -v '\.$'`

echo "Choose the commande to execute : "
echo "1. update"
echo "2. put sites offline"
echo "3. put sites online"
echo "4. clear all cache"
echo "5. clear css+js cache"
echo "6. clear specific cache"
echo "7. install specific module"
echo "8. disable specific module"
echo -n "Input [1,2,3,4,5,6,7 or 8] ? "
read choice

if [ $choice -gt 6 ] ; then
  echo -n "Extension (module/theme) name ?"
  read ext
fi

# For each site, execute the command
for site in $sites
do
  echo ----------
  echo $site
  cd $site
  if [ $choice -eq 1 ] ; then
    drush updatedb
  elif [ $choice -eq 2 ] ; then
    drush vset --always-set maintenance_mode 1
  elif [ $choice -eq 3 ] ; then
    drush vset --always-set maintenance_mode 0
  elif [ $choice -eq 4 ] ; then
    drush cc all
  elif [ $choice -eq 5 ] ; then
    drush cc css+js
  elif [ $choice -eq 6 ] ; then
    drush cc
  elif [ $choice -eq 7 ] ; then
    drush pm-enable -y $ext
  elif [ $choice -eq 8 ] ; then
    drush pm-disable -y $ext
  fi
  cd ../
done


thinking the fastest way to do this one is hook_node_insert() ...
see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_ENTITY_TYPE_insert/8.2.x

if i am following what your saying, you want to set the value of 'field_section' the newly created taxonomy term in tags? if so the following will get you started ..

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function YOURMODULE_node_insert(EntityInterface $entity) {
  $type = $entity->bundle();
  if (!empty($type) && $type == 'blog_entry') {
      $field_tags_terms = $entity->field_tags->referencedEntities();
      // Your selected term id.
      $field_section_id = $entity->field_section->target_id;
      if (!empty($field_tags_terms) && !empty($field_section_id)) {
          foreach ($field_tags_terms as $term) {
              $term->set('field_section', $field_section_id);
              // or
              // $term->field_section->appendItem(['target_id' => $field_section_id]);
              $term->save();
          }
      }
  }


Calendar - Adding relationship to contextual date filter

As J. Reynolds suggested some settings in the Calender Entities must be set. Changing the relationship fixed my problem.


I don't know if it will help you, but the way I solved a similar problem was by using Google Search, which indexes the rendered page.


Drush Remote Aliases Line Wrapping Different Than Local Line Wrapping

I'm surprised no one has brought this up before.  Perhaps it has come up, but I do not remember an incident about it.  In any event, Drush does not pass the COLUMNS information to remote servers, so the remote side defaults to wrapping at 80 columns.

I added a commit to the master branch (Drush 7), 17c18fb331, to do this.  I'll also open an issue to discuss backporting to Drush 6.

UPDATE:

I also committed this fix to the Drush 6.x branch.  https://github.com/drush-ops/drush/issues/662


Problems with Contextual Filters & Menu Tabs

I am doing something similar, I think, but it is driven by Taxonomy Menu.  For what it is worth (for any other researchers), I have set a contextual filter and a relationship:

Contextual filter settings:

And my relationship (see 1st screenshot) setting is just default:


Fatal error after subtheming Commerce Kickstart Admin Theme

PHP requires all function names to be unique*, you'll need to rename the functions in your sub-theme to my_admin_subtheme_FUNCTION_NAME, e.g. my_admin_subtheme__preprocess_page(&$vars).

You might want to consider clearing the template.php file completely and only copying the functions you need when you find you need them.

That is unique in a namespace, but that is another subject - see http://php.net/manual/en/language.namespaces.php.


How do I setup multiple sites with one database in Drupal 7

Yes it is possible to setup a multiple sites in Drupal 7 using one database.

All though its not optimale. compared to the other option to run it in different databases.

Drupal multiple sites tutorial

Complete tutorial on setting up sites in Drupal 7

Hope it helps :)


It was related to my nginx config and fast cgi params

using apache instead of nginx temporarily fixed he issue


The best for your case is Media. You can use a existing library or you can upload a new image and many other stuff.


You can do this with the following:

Create a new View to display the Taxonomy Terms for Brand

In the Views UI, add a new Relationship Taxonomy term: Content with term, and uncheck "require this relationship".
Add a new Contextual filter : Content: Nid and choose the just-created relationship as the relationship. Provide default value > Content ID From URL under When the filter value is NOT available.


You might want to try a module like Ultimate Cron that allows you to run individual cron jobs, outside of cron.php. This will allow you to use kint() and see the output.


Quick Tabs

  The Quick Tabs module allows you to create blocks of tabbed content,
  specifically views, blocks, nodes* and other quicktabs*. You can
  create a block on your site containing multiple tabs with
  corresponding content.

Make 3 view blocks of each, and then create a quick tab of views and enable ajax so the other tabs load only when they get clicked.


Gray overlay and no dialog when clicking Image button in CKEditor

After discovering that the Image button works fine in the default "Advanced" text format, which I did not modify, and which doesn't have the Media button added, I started investigating differences.

Turns out that if I disable the Picture module in Editor Appearance > Plugins, things work.

I just don't know what I'm giving up by disabling this. I would like images to be responsive. :-(


How may I allow users to embed a view within a CKEditor text field?

As far as embedding a view into CKEditor, you can use a formula with Token Embed Views and or Token Insert:

https://www.drupal.org/project/token_embed_views
https://www.drupal.org/project/token_insert


How do I add the content type token in the page title?

Short answer: Simply insert the [node:content-type] token.

Longer answer:

The Page Title module modifies the title that appears in the <title> tag (which also displays in your browser's title bar. Just to clarify, this is separate from an individual node's title.

In the module configuration page, you will only see the raw token names displayed. The Page Title module will convert those tokens to human readable values on an actual node or "page". View the source of one of your nodes and check the <title> tag to see the actual values.

This module relies on the Token module in order to operate.

You can also get the Entity API module (and enable the Entity Tokens submodule) to get even more tokens that weren't picked up before.

Also: Be aware that the project maintainer has identified an issue with Fusion based themes. If your site falls into that category, temporarily switch to another theme such as Bartik to test out the page title module.


hook_node_view() shouldn't be used for access checks, there's hook_node_access() for that sort of situation:

function MYMODULE_node_access($node, $op, $account) {
  $type = is_string($node) ? $node : $node->type;
  if ($type == 'abc' && $op == 'view') {
    return $account->uid > 0;
  }
}

That'll handle the access check for the node gracefully, and shouldn't stop cron running halfway through.


If something is deprecated then that means there is always an explicitly documented replacement and a change record with code examples.

https://www.drupal.org/node/2549139.

In this case it's the EntityFieldManager/entity_field.manager service. But neither entity.manager nor entity_field.manager provide just field names, both provide a list of field definitions.

As always, share your code and you get more specific answers.

One thing you need to be aware of in regards to labels is that there are field storages (fields in 7.x terms) and fields (field instances in 7.x). A single field storage (= unique field name) can exist on different bundles/node types with different names. So one approach to do what you want would be to start with the field map for your type, then loop over the bundles for each field to get the field definition and that label.


Fresh install of COD: Anonymous users get "Access denied" on homepage

The permission required is View published content.

It turns out the content access module has a lot of different permissions that can be assigned to roles and this one is not selected by default for anonymous users.

This is a really easy permission to miss. It sits deep within nodes permissions and if you use the search facility for words like view or access you won't get it in the search result. Heck, if you search View published content it isn't returned.


How to create a sequence of nodes to work as a "tour" through a site?

Custom Pagers

  Custom Pagers allows administrators to define context-sensitive
  previous/next pagers for any node type. The list of nodes to be cycled
  through is generated by a user-selectable view, and each pager can be
  displayed above or below the node body or in a sidebar block. This
  makes it possible to duplicate the paging functions of forum.module
  and book.module, as well as more complex stuff like comic strip
  navigation. Requires token.module and views.module.

and Nodequeue

  The Nodequeue module allows users to collect nodes in an arbitrarily
  ordered list.


How reset $form_state on ajax call for get real value in submit?

Thank to @4k4 for the solution posted here :

How do I change the default value of a field with AJAX?

For my problem, this is how i add this feature :

$form['containerGeneral']['livraison']['adresseComplete'] = array(
          '#type' => 'container',
          '#prefix'=>'
',
          '#suffix'=>'
'
      );

      $form['containerGeneral']['livraison']['adresseComplete']['nom_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['prenom_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['pays_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['adresse_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['adresse2_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['cp_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['ville_livraison']['#tree']=true;

      if($form_state->getTriggeringElement()['#name']=="mes_adresses")
      {

          $_SESSION['compteur']++;

          $listAdresse = $this->adresse_service->getUserAdresseById($form_state->getValue('mes_adresses'));

          $key = $_SESSION['compteur'];

      }

      $form['containerGeneral']['livraison']['adresseComplete']['nom_livraison'][$key] = array(
          '#title' => 'Nom de livraison',
          '#type' => 'textfield',
          '#required'=>true,
          '#placeholder' => 'Nom',
          '#default_value' => $listAdresse['nom'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['prenom_livraison'][$key] = array(
          '#title' => 'Prénom de livraison',
          '#type' => 'textfield',
          '#required'=>true,
          '#default_value' => $listAdresse['prenom'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['pays_livraison'][$key] = array(
          '#title' => 'Pays de livraison',
          '#type' => 'select',
          '#options'=>$this->taxonomy_service->getTermsByVid('pays_livraison'),
          '#default_value' =>  $listAdresse['pays_livraison'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['adresse_livraison'][$key] = array(
          '#title' => 'Adresse de livraison',
          '#type' => 'textfield',
          '#required'=>true,
          '#placeholder' => 'Adresse de livraison',
          '#default_value' =>  $listAdresse['adresse'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['adresse2_livraison'][$key] = array(
          '#title' => 'Adresse de livraison',
          '#type' => 'textfield',
          '#default_value' =>$listAdresse['adresse2'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['cp_livraison'][$key] = array(
          '#title' => 'Code postal de livraison',
          '#maxlength'=>5,
          '#type' => 'textfield',
          '#placeholder' => 'Code postal de livraison',
          '#default_value' => $listAdresse['code_postal'],

      );

      $form['containerGeneral']['livraison']['adresseComplete']['ville_livraison'][$key] = array(
          '#title' => 'Ville de livraison',
          '#type' => 'textfield',
          '#placeholder' => 'Ville de livraison',
          '#default_value' =>$listAdresse['ville'],
      );

Don't forget to set $_SESSION['compteur'] to 0 on submit and to set it to 0 on form load.


File Transfer failed, reason: Unable to change to directory

Try executing your chown command recursively, and also assign an explicit user and your web server's group, like so: sudo chown my_user:www-data sites/all/* -R where my_user is your id and www-data is your web server's group. This will recursively apply ownership to your entire directory tree.

It might also be worth pointing out that you mention assigning ownership and privileges to sites/default, but your error messages indicate that the problem is in sites/all. :-)

In my experience, failed uploads or updates are almost always due to incorrect ownership.


Disable all notice errors on a drupal 6 site

Its not so much a Drupal 6 question, but a PHP question.

In your settings.php file I sometimes do the following on my Drupal 7 sites:

// Drupal Bootstrap is overriding even htaccess values for this. I want the
// notices but not for them to display in production.
ini_set('error_reporting', 'E_ALL ^ E_NOTICE');


Help to understand and fix this entity error message

Looking at the code of the Entity module, I noticed that the $info['parent']->entityInfo() method is the one defined in entity.inc, and it returns the value obtained from entity_get_info(). The reason you are seeing that error is that there is a module defining an entity type and which forgets to define the label for its bundles. The core modules always define the label for their bundles.

  /**
   * Set up the object instance on construction or unserializiation.
   */
  protected function setUp() {
    $this->entityInfo = entity_get_info($this->entityType);
    $this->idKey = $this->entityInfo['entity keys']['id'];
    $this->nameKey = isset($this->entityInfo['entity keys']['name']) ? $this->entityInfo['entity keys']['name'] : $this->idKey;
    $this->statusKey = empty($info['entity keys']['status']) ? 'status' : $info['entity keys']['status'];
  }

  /**
   * Returns the info of the type of the entity.
   *
   * @see entity_get_info()
   */
  public function entityInfo() {
    return $this->entityInfo;
  }

The Rooms module should give a value for the label property for its bundles, or the Entity module should not assume the label is always given. I don't see anything that says the bundle label is always present, even though I suspect it is a required property.


How to do a Library Override in my theme for dialog.ajax.js

Looks like you're just missing the core/ prefix:
libraries-override:
  core/drupal.dialog.ajax:
    js:
      assets/js/dialog.ajax.js: false


Taxonomy terms language depending - why all languages are visible?

I have set the vocabulary to Translate. Different terms will be allowed for each language and they can be translated. and duplicated each brand for each language and then updated each node - with setting term for particular language.

In my opinion this is workaround, but I couldn't find other solution.


How to create a form on settings o settings page

My solution is for Drupal 7.

To add two textfields to the settings you have to implement the following hook:

function themename_form_system_theme_settings_alter(&$form, &$form_state) {

  $form['theme_settings']['socialmaintenaceurl'] = array(
    '#type' => 'textfield',
    '#title' => t('Social maintenance URL'),
    '#default_value' => theme_get_setting('socialmaintenaceurl'),
  );
  $form['theme_settings']['maintenaceurltext'] = array(
    '#type' => 'textfield',
    '#title' => t('Maintenance URL text'),
    '#default_value' => theme_get_setting('maintenaceurltext'),
  );
}

You have to replace themename in the function name with the name of the theme.
The declaration of the input elements is based on the Drupal 7 Form API (https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7).

It is an array, which will be rendered according to the information you provide. Normally, keys starting with # are information to control the render process. For example: If you choose a different #type it gets a different widget/appearance in the form.

The $form['theme_settings'] should place the two new fields into the existing theme settings group.

If you want, you could ship default values for your two fields. You only need to add a few lines in you themes .info file:

settings[socialmaintenaceurl] = https://twitter.com/test
settings[maintenaceurltext] = Get the latest news on Twitter

I am not sure, if you need quotation marks around them, but I think in the .info file you dont need them.

To get these values in another file, you would need to use

theme_get_setting('maintenaceurltext')
theme_get_setting('socialmaintenaceurl').


Add attribute to all textboxes in the site

You'll want to use hook_field_widget_WIDGET_TYPE_form_alter() for this. The following will add the "my-class" class to all textfields:

/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 */
function test_field_widget_text_textfield_form_alter(&$element, &$form_state, $context) {
  $element['value']['#attributes']['class'][] = 'my-class';
}


How to set up Apache solr search for Book Specific search

If you are familiar with views this can be done with the following steps.

We have a contributed module for apache solr views, by installing this module you can change the views module to apache solr views i.e you can route the queries from database queries to apache solr.

Working example :

Step 1:

Download and install the apache solr views module.

Once the module is installed the following steps is equivalent to creating a normal view with an exposed filters.

Step 2:

Create a new view I have named book search (I have created a normal menu  for the book search and added in the views path configuration i.e : " Path: /apachesolrfilters ", you can create a stand alone page or add it to any existing blocks), add fields and filters,

Fields : I have added content title, body & content type
Filters: I have added  Content: Published (Yes), Content: Type (exposed) & Content: Title (exposed)

Configure the filter content type to show only the book types book1 & book2.

Save the view and clear the cache.

Screen shot:


Drupal compress (gzip) files attached to pages. How to turn it off?

The question here is one of Apache configuration, rather than Drupal.

I'd suggest checking out the Apache mod_deflate documentation, which contains sample configurations to disable/enable compression in a variety of circumstances.


Yes, I crated a cron.sh script and uploaded it on my server with the following content:

#!/bin/bash
# run drupal cron
echo "Start"
START=$(date +%s)
echo "Running Drupal Cron"
wget -O - -q -t 1 "http://<your-domain>.com/cron.php?cron_key=<your-key>"
END=$(date +%s)
DIFF=$(( $END - $START ))
echo "Total Time: $DIFF seconds"
echo "End"

I went into the GoDaddy hosting account and entered the cron command:

bash /home/content/00/00000000/cron.sh

NOTE: You will need to know the path of the location where the script resides on the server.  If you are using ssh you can get the path by typing "pwd" in the ssh command line.


Should a fresh install of Drupal have failing tests and what to do with the failing tests?

All tests are run on every patch that is posted on drupal.org, fully automated. Nothing is commited unless all tests are passing (It happens that something is commited that breaks the tests (for example if the tests only fail sometimes or the fail was not triggered on the patch for some other reason. However, development comes to a complete halt in such cases until the tests are working again.

But, these automated tests are run on equally configured, highly tuned linux servers (they currently run all of the core tests in ~40 minutes, I'm not going to ask how many hours it took you :)).

So, what is possible is that your system is somehow configured differently, uses different version of PHP, MySQL, the OS or something else. The tests should of course pass on every supported environment, so what I would recommend is creating a core issue, list the not-working tests (including the exact failures, e.g. with screenshots) and a detailed description of your set-up including your versions of PHP, MySQL, Apache, OS, extensions and so on.

I know that DamZ does regularly run all tests on different setups, including PostgreSQL, Windows and so on and I'm pretty sure that most except the Linux/MySQL env still have known failures. Edit: The site for this is on http://drupaltesting.org/, but it looks like it's been broken (the test environment, not the tests) for a few months now..


Attaching Conditional widget on Drupal Field

You should create another field for the year and use e.g. Conditional fields module so that year field appears only when a specific option is selected.

Generally speaking, you should use form API states processing, and the Conditional fields provides UI for that.


Users get a new password detect forced logout

All is correct except 'user/lougout' should be 'user/logout'.


In Yosemite not able to generate the styles folder, I upload the project in a ubuntu test server, and it works

Probably not a permissions problem: the default php GD library on yosemite comes without png support, so drupal can't generate png images (like the default sample.png). You can very easily install another version of php.


How to set the node ID to start with 100,000?

To make node IDs start from 100000, in a new site (which I assume doesn't have any nodes created yet), all that's needed is to run this SQL statement (assuming you're using MySQL, PostgreSQL or SQLite):

For MySQL or SQLite:

ALTER TABLE node AUTO_INCREMENT = 100000;
For PostgreSQL, and inspired by the accepted answer to "Reset auto increment counter in Postgres", it should be something like so:

ALTER SEQUENCE node_nid_seq RESTART WITH 100000;

Change the 100000 value in this SQL to any other value (like 123), to make node IDs start from that other value (like 123).

Caution when applying such change in an existing site, whereas the new node ID (like 123) is less then the highest node ID used already in your site. Because in that case you may get all sorts of effects you may not want/like ... Though in a new site (as in this question here) those effects don't apply.


How to get entity from transliterated argument in URL?

Short answer:

You can't do what you are asking.

Why is that?
While transliterating is a pretty simple procedure that follows a very specific number of steps:
- Replace every character with the corresponding-transliterated version
- If the resulting URL exists, add a -{Insert Number here} at the end until you find a URL that does not exist

reversing the transliteration is not that easy. Think of the extreme case where 5 different nodes/terms/entities have the exact same title. Their transliterated paths would be: /common-title /common-title-0 /common-title-1 /common-title-2 /common-title-3.

In this case, how do you know which transliterated title corresponds to each entity? Creation date (first one created gets the smallest index)? Besides the fact that this is extremely complex to predict, there may still be problems if a path was updated manually or one of the entities was deleted and a new one was added.

Long answer:

Even though what you are asking is not feasible, you can use a number of different approaches in order to solve the specific problem that you are facing.

Possible Solution 1:
You can use the current_path function. This will return the unaliased path of the currently viewed Drupal page. I am not exactly sure how the panels' pathing system works, but there is a very good chance that you will get something with the term id in it (that's what you need in your hook, right?).

In order to investigate this further in your code, assuming you have devel installed, you can do something like:

dpm(current_path());

Possible Solution 2:
If the above-mentioned solution does not work, you will need to do some more digging in order to figure out which variables are available. Something that can get you started is a simple:

dpm(get_defined_vars());

Depending on the results that you will get, you may be able to find the term name somewhere in the defined variables and use taxonomy_get_term_by_name() function to retrieve the tid.


the right url will like domain/endpoint/services_url If you need to get any view the url will be like

domain/endpoint/viewname?display_id=block_id

More details found here


You know that only 17 sites currently report using this module? And that last revision is reported to be from 2013-Oct-27? So it is old thing, and hardly used. I advise caution.

This bugreport suggest that all you need to do is to have focus anywhere on your page, and it will work... except when you hit the bug itself.


Notice: Undefined index: #value in element_validate_integer_positive()

It sounds that apache user doesn't have the permissions to write in the temp directory which is set in the Drupal's file system settings.

I'd suggest you to check first the status reports on admin/reports/status. If you have any problems with your installation, it would be listed there.


How to import Nodes and Node Location data using Feeds module?

Yes, definitely go with feeds except I would go with location module instead of geofield personally as it has direct support from the location_feeds module for mapping in all the relevant details. Its possible that you may need to do two seperate feeds (one for importing the node information and one for the location information) but you can make sure they "come together" by using the same GUID field from your feed on each one. The easiest way is to try :) Set up a dummy file first with only 10 imports.


How to use Taxonomy Facets together with Apache Solr Multisite Search ?

A little patch that solve the issue

Index: apachesolr_multisitesearch.module
===================================================================
--- apachesolr_multisitesearch.module   (révision 32470)
+++ apachesolr_multisitesearch.module   (copie de travail)
@@ -331,6 +331,10 @@
             return apachesolr_date_facet_block($response, $query, 'apachesolr_multisitesearch', $delta, $delta, t('Filter by post date'));
           case 'hash':
             return apachesolr_facet_block($response, $query, 'apachesolr_multisitesearch', $delta, $delta, t('Filter by site'), 'theme_apachesolr_breadcrumb_hash');
+
+           //syg on ajoute un retour pours toutes les autres facets
+          default:
+            return apachesolr_facet_block($response, $query, 'apachesolr_multisitesearch', $delta, $delta, t('Filter by %field', array('%field'=> $delta)));
         }
       }
       break;


Yes, you should use hook_menu_alter
Create new module and add hook_menu_alter

function my_module_menu_alter(&$items) {
    // Unset core path
    unset($items['comment/%']);
    $items['your/pass/here/%node'] = array(
        'title' => 'Add new comment',
        ...
      );
}

But link "comment/reply/%nid/%cid" is used by Drupal for replies to other comments (where %nid - node id and %cid - comment id you are replying to). Use another path.


"drush config-split:export" returns "Not enough arguments (missing: 'split')."

In order to use config-split:export with Drupal 9, make sure you go to admin/config/development/configuration/config-split. There you should see if you already have a split configuration and use machine name: drush config-split:export [machine_name]


How to provide custom template declared inside my theme .theme file as variable inside page twig template

Presume you have something like:

HOOK_theme($existing, $type, $theme, $path) {
  return [
    // mycustomtheme.html.twig
    'mycustomtheme' => [
      'variables' => [
        'var1' => NULL,
        'var2' => NULL,
        'var3' => NULL,
      ],
    ],
  ];
}

You can preprocess the page.html.twig theme and add your theme output as a variable:

function HOOK_preprocess_page(&$variables) {
  $var1 = 'foo';
  $var2 = 'bar';
  $var3 = 'baz';
  $variables['content']['customcontent'] = [
    '#theme' => 'mycustomtheme',
    '#var1' => $var1,
    '#var2' => $var2,
    '#var3' => $var3,
  ];
}

And then you should be able to print it on page.html.twig:

{{ content.customcontent }}


User resetting password, week later needing to reset it again

Here are some suggestions/things to check based on your description:

If the user passwords on production are reverting after a recent deployment, check to make sure that your settings.php file on production doesn't point to the development instance's database (you may be inadvertently repointed production to a backup copy/development copy of the database by pushing changes in settings.php).
Check to see if your site is utilizing a password management module.  If so, doublecheck/resave expiration settings (as well as if any security/recommended updates are available). Common password management/expiration modules include:

Password Policy
Force Password Change

Check to see if there are any custom rules (either using Rules module or programmatically implemented with a custom module) in place that force a user to reset password after a set duration/period of time/number of logins.
Check to see if the site's user accounts are tied to an external user account provisioning/login system such as LDAP or a Single Sign On service (as well as if any security/recommended updates are available). If one of these are in place, then you may need to check password expiration policies at the account provider. Examples SSO service modules for Drupal include:

Janrain - integration with the commercial Janrain service
Google Apps Authentication
SimpleSAMLphp Auth - integration with the open source library SimpleSAMLphp
HybridAuth Social Login - integration with the HybridAuth library
Bakery - SSO among Drupal installations on the same parent domain
Account Sync - provides SSO functionality and account info synchronization among Drupal installations.


You could use field_group nad field_group_table

  Fieldgroup will, as the name implies, group fields together. All fieldable entities will have the possibility to add groups to wrap their fields together. Fieldgroup comes with default HTML wrappers like vertical tabs, horizontal tabs, accordions, fieldsets or div wrappers.


How do I get the index number of currently displayed slide of a Views Slideshow into the jQuery Cycle's "Before" advanced option?

Looking at the JS code for views_slideshow_cycle:

case "before":
  var beforeValue = advancedOptions[option];

  beforeValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(beforeValue);
// transition callback (scope set to element to be shown):
function(currSlideElement, nextSlideElement, options, forwardFlag)
  settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
    pager_before_fn(currSlideElement, nextSlideElement, options);
      eval(beforeValue);
  }
  break;

Your code isn't actually executed within the scope of the before callback, it's executed afterwards. The variable that the module provides is named options rather than opts, hopefully that will resolve to what you need and the change should be as simple as:

alert(options.nextSlide + " of " + options.slideCount);


Why can't I output the style tag in my twig template?

I've done it to print a background color like this in a paragraph template

<div class="container color-{{ content.field_text_color[0] }}" style="background: #{{ content.field_card_color[0] }};">

And it just worked fine. Can you give us the full template maybe we can figure out why it doesn't work.


Using a drush alias with Elysia Cron - alias permission missing

You could try drush @main --user=1 elysia-cron to force the active user to be the site admin when elysia-cron runs; however, all of the cron methods should be API calls, and therefore should not care who the active user is.  Note also that the error message that you quote above simply means that part of the Drupal bootstrap is failing for you; this is not a permissions issue (because Drush does not need permission to log on as a user -- it just does it), but is indicative of some other problem.

Run drush status with your cwd set to your site, and run it again vi drush @main status from a different working directory, and compare the output, esp. vis-a-vis the Site URI line.  Also run in --debug mode both times, and look for any other differences in the output.  If you have set root and uri in your alias, it pretty much should run the same both ways.


hook_menu implementation page not found error drupal 7.10

Try adding a 'title' to your return array.

I noticed that the D7 menu documentation lists 'Title' as required:

"title": Required. The untranslated title of the menu item.

Now there is a comment on the doc page that claims it is not required.

But That comment is from March 20, 2011.

Perhaps the title is now finally required in a more recent release.

Edit:
Your code from comment:

/** * Implementation menu(). / */
function misite_menu() {
    $items = array();
    $items['a/main'] = array(
             'title' => 'main',
             'page callback' => 'main',
             'description' => t('Main front page'),
             'access callback' => TRUE, );
    return $items;
}

/* * Implementation hook_theme(). */
function misite_theme() {
    return array( 'main' => array (
        'template' => 'main',
        'variables' => array('title' => NULL),
        ),
    );
}

function main() {
    $path = drupal_get_path('module', 'a');
    $title = t('');
    $build['mainelement'] = array( '#theme' => 'main',
                                                '#title' => $title, );
    $output = drupal_render($build);
    return $output;
}

Several observations.
1) I think your inclusion of hook_theme could be causing needless grief. Try getting an example of hook_menu working independent of hook_theme.

2) I wouldn't use 'main' as a page callback name; it may not be conflicting with another function elsewhere but I don't think it is a good idea regardless.

Try this:

function misite_menu() {
    $items = array();
    $items['a/my_main'] = array(
             'title' => 'my_main',
             'page callback' => 'my_main',
             'description' => t('Main front page'),
             'access callback' => TRUE
            );
    return $items;
}

function my_main() {
    $output = 'HERE I AM';
    print($output);
}

Then navigate to a/my_main and see if you can see "HERE I AM". If you can then you know your hook menu is working and that your problem is in your hook_theme.


Unable to set Drupal environmental variables using Drush alias

The 'variables' entry in a Drush alias file, or in $options['variables'] in a drushrc.php file will only affect Drush code execution; it does not in any way change the variables table in the database, or affect that way that Drupal runs from the webserver at all.

If you would like to change the values in the database, after sql-sync you could run:

drush @opendoor_stage vset site_name 'My Drupal siteSSSSSSSSSSSSSSSSSSSSSSSSSSSS'

See also sync_enable.drush.inc, which will enable modules and set permissions after every sql-sync operation.  If you often needed to set variables after every sql-sync, you could extend this code to call vset based on the values of entries in the site alias.

POSTSCRIPT:

You might also want to consider using $conf['site_name'] in the destination site's settings.php file rather than change the database value.  This is what most folks do.


How safely allow untrusted users to use img tag?

The default "Filtered HTML" text filter that ships with Drupal do not allow the <img> tag because image tags can contain attributes that allow for XSS attacks.

If you want to allow images, but also want to prevent untrusted users from using images as a vector for XSS attacks, you need to install and enable the WYSIWYG Filter and configure it to allow images, but disallow all unsafe image attributes.  You use this filter instead of the "Filtered HTML" text filter, not in addition to it.

To create a new text format, navigate to Configuration → Content authoring → Text format and click on Add text format. Select a name for the format (e.g. call it «Wysiwyg»). Enable it for all user roles. Below, I am going to show you how to fine tune the attributes allowed for this text format.  It may be a good idea to also enable the filters Convert URLs into links and Correct faulty and chopped off HTML.

If you use all three filters, make sure the filter processing order is the following:

WYSIWYG Filter
Convert URLs into links
Correct faulty and chopped off HTML

Now configure the WYSYWYG filter:

To make sure that no insecure markup emerges from your editor, you must create a white-list for the Wysiwyg text format. My recommended white-list for HTML elements and attributes is below:

a[!href|target<_blank|title],
div[align<center?justify?left?right],
p[align<center?justify?left?right],
img[src|alt|title|width|height], @[class|style],
h2,h3,h4,h5,h6,
br,span,em,i,strong,b,
u,s,strike,
blockquote,pre,address,sub,sup,
ul,ol,li,hr,br,
table,tbody,caption,tr,td

Creating a white-list of HTML elements and attributes and inserting it into the HTML elements and attributes in the Filter settings for the WYSIWYG Filter is not sufficient. You also need to whitelist the properties that is going to be allowed. By default, all properties are disallowed. To allow images and text to be styled and scaled, check the following properties:

The screen shot above  shows (the part of) the WYSIWYG filter configuration screen with tick boxes that allows the img attributes it is safe to allow untrusted users to use.

Disallow all other attributes.  Attributes that is disallowed will be stripped from the renderable version of the entity by the filter when the entity is saved after editing.

The screen dump below show the entire configuration screen I've used for my setup of the WYSIWYG filter.The text is too tiny to be readable, but I hope it gives you a rough idea about of it is configured.

After configuring the WYSIWYG filter, press Save configuration.

After creating the Wysiwyg text format, allow non-trusted users to access it, and make it the default by moving it to the top of the list of text formats, as shown in the screen shot below.


There are a number of ways to do this, but this answer focuses on the considerations for handling things programmatically in custom code.

The <title> variable (for the browser title bar) is calculated as part of the "html" theme template, while the <h1> title variable (printed at the top of the page) is calculated as part of the "page" theme template. So in this regard if you implement some preprocess logic on the "page" output, you can remove the title from the page display while still keeping it intact for the browser bar. This is of course in contrast to more heavy-handed approaches, like calling drupal_set_title(), which impact static variables that may apply on a more global scope.

The trick to this is that, in most cases, your "page" template title is not actually initiated as a theme variable until template_process_page(), which runs after any preprocess functions. So you may not see a "title" variable within the scope of your own theme_preprocess_page(). The appropriate snippet from template_process_page(), where the title is added, is just:

if (!isset($variables['title'])) {
  $variables['title'] = drupal_get_title();
}

Given this background, you could manipulate the title variable direct by either:

Setting $variables['title'] to an empty string within your theme_preprocess_page() (based on whatever conditions your desire). This way it will be set and therefore won't get filled-in via the template_process_page() code that runs later, but it will still be empty when page.tpl.php template renders things.
Implementing a theme_process_page() function, which will run after template_process_page(), that unsets/nullifies the title variable set there.

You could also avoid touching the title variable itself altogether by just setting a boolean flag, like $show_title, in a (pre)process function. Then you would need to modify your page.tpl.php template with a very basic boolean check of $show_title that only prints the title <h1> if TRUE. That method is discussed in this post.

With any of these options you isolate your primary conditional logic, which can be as detailed as you want (should you discover new title visibility needs later), within the theme preprocessing layer. This will help keep things more maintainable for the long run.


Increase upload file size by content type

It sounds like the content type "story" has a 3MB limit set on that file field.

You can increase that limit by browsing to "example.com/admin/structure/types" and select the "Manage fields" tab (for the "story" content type). Find the field in question (the file upload field) and edit it. You should find a setting for the maximum upload size there.

If you'd like to learn more about fields, and specifically file fields, check out this Drupal.org resource and and this one as well.

Now, the other thing you will need to review is your .htaccess file. There are a couple of php flags you will want to review:

php_value post_max_size
php_value upload_max_filesize

Review the .htaccess file first because no matter what setting you set for your file field on the content type "story", it will be overridden by the setting in the .htaccess file.


4095 Selectors Limit on IE. How to split the Drupal 7 CSS compressed files?

Lets say your my_theme.info have

stylesheets[all][] = css/my_theme_1.css
stylesheets[all][] = css/my_theme_2.css
stylesheets[all][] = css/my_theme_3.css
stylesheets[all][] = css/my_theme_4.css

And you don't want to aggregate these files in a single one (exceed IE limit 4095 selectors)(also I assume that is already minified by Brunch)

Remove the above lines from your .info or comment out.

Then add an html preprocess function (on the main template.php or if you have an html.preprocess.inc file)

function my_theme_preprocess_html(&$variables) {
  drupal_add_css(drupal_get_path('theme', 'my_theme') . '/css/my_theme_1.css', array('preprocess' => FALSE));
}

The drupal_add_css will add the css but 'preprocess' => FALSE will prevent Drupal to aggregate them.

(It's a bit hacky but it works)


View poll *results* as anonymous user doesn't allow access

Stumbled upon the same problem when I wanted to redirect some anonymous users to see only the results of a poll depending on what email address pattern they entered in a form before. So I thought sending them to node/%nid/results would be fine and somehow it also worked AS LONG AS for testing purpose I didn't vote before (as other anonymous user with allowed email address pattern). Then the IP got stored somehow and when accessing the poll node you automatically get the results view presented WHILE AT THE SAME TIME the node/%nid/results URL gets unavailable.


Ok, so this problem was being caused by the language prefix in our paths in conjunction with aliases. drupal_get_normal_path was returning aliases instead of node numbers, and it returned nothing when the path had a language prefix. Also found that the substitute function drupal_lookup_path only works for aliased paths. The final code replaces line 634 of search.module:

$path = drupal_get_normal_path($match[1]);

becomes

$clean_url = preg_split('!(^[a-z]{2})/!i', $match[1])[1];
if ($non_aliased = drupal_lookup_path("source", $clean_url)) {
  $path = $non_aliased;
} else {
  $path = drupal_get_normal_path($match[1]);
}

The search_node_links table is now being populated properly and the "What links here"/Backlinks views are working correctly.


How do I access the configuration variables present in settings.php through my code?

You can only override configuration values in settings.php, you cannot introduce new configuration. So the values you have tried to set there cannot be accessed, unless you happen to have configuration named test.uid. But I suspect that probably does not exist.


Search block not showing if not logged in

You have to go to the Administer › User management section, under the search module area, you need to give the necessary permission to the user that needs to see the search form. If you want everyone to view this Search Module check the box corresponding to anonymous and authenticated users.

From https://stackoverflow.com/a/17027332/1795426


Drush tries to export config for modules I deleted months ago

When you removed the modules I would guess you didn't uninstall them first. The simplest approach is probably going to be to put the code back by whatever means you originally installed them, in the same location, then uninstall them via the admin panel or drush before removing the code again. That way the core code will fire that deletes the config.

It is possible that a module may break the uninstall process, in which case this is a trickier problem but best to go down the simplest route first.


Remove/Hide the block if the View is empty?

I had the same behavior with "empty" fields. Unless you don't hide the fields themselves, the design/ markup still renders.
Solution for me was to filter for fields being "NOT NULL".
(Maybe it depends on the "fences"-module i have installed, too. Not sure, because not tested ...)


How to redirect "relationships/received" to "user/[requestee:uid]/relationships/received?

If you want to redirect to the current user profile page, you could try using the redirect module with redirect_token

Use tokens in "To" paths in Redirect module.

Then you can redirect from http://example.com/relationships/received to http://example.com/user/[user:uid]/relationships/received


Pasting text from GoogleDocs into D7 Body field causes imagestyle error?

You may have better luck exporting the Google Doc to "RTF" format first then copy + pasting that format into the article body.

You could also try the "Paste without formatting" option, such as Ctrl+Alt+Shift+V or Ctrl+Shift+V but would need to re-add the formatting (headings etc..) with that approach.

There may also be some WYSIWYG toolbar options to paste with various formatting options (paste from word, paste as plain text etc..)


How to create a an image gallery with a short description below each image

Creating an Image Gallery Of images in nodes.

Add a content type to be used for the image gallery.
Add the image field
Add one node per image with the description in the body field.
Create a view of the type content
Add the fields Title, Image, Body (In this order so that they are displayed in that order itself
set the format to grid.

Now when you visit the page you should see the gallery as you wanted.