Exporting webform information programmatically

You might have to create your own.
It would probably be worth submitting back as a new module too.

All you would have to do is implement hook_menu() to add your menu callback.
In hook menu you can set access arguments to make sure no one case use it unless they have a particular permission.

You can add your own custom permission using hook_permission().

Then the callback function could use webform_get_submissions() to load the submissions for a given webform and return them using drupal_json_output()

You could pass in a webform nid argument either via the url, using something like 'get-webform-submissions-json/%node' as your menu path, which would automatically validate the nid and load the node for you. For more information on that see http://drupal.org/node/224170
You could also just pass it in as a query parameter and use $_GET['nid'] in your callback function, however then you need to validate it yourself.


node_load() Performance and alternatives

First i would make sure that using node_load() does slower your script. If you are sure it really does you can either:

1- Create an index_audio  table with a nid and use_audio columns.
You could update this table on node creation/update/delete. Then
you can just query this table to make sure a specific node does have
audio attached to it. I would use that solution only if i you have to
intensively make such a check
2- Directly query your field table with your nid as etid, in your
instance : field_data_field_efe_audio table see if it returns
FALSE or some actual data


How to create a role without some permissions an "Authenticated User" has?

I don't think you can do that. The authenticated is the mimialist role with the lowest permissions.

You give it the Minimal permissions then make other roles with added permissions to the authenticated.


Restrict text format use to a particular node/edit URL

You can't achieve that in config, since text formats are configured per field instance, but not as granular as for to get to the node level.

You'll need too implement a hook_form_alter(), and then check the url to find out if you want to allow the format or not. Something like this:

function mymodule_form_alter($form, &$form_state, $form_id) {
  if ($form_id == 'node_type_form_to_alter' && (current_path() == 'node/%nid/edit')) {
    // Enforce desired text_format here, by altering $form array.
  }
}

That's what I would do for that case. You can take the opposite approach, and implement the same form_alter, but instead of enforcing it on a particular URL, just making sure that it's not available unless the url is the one you want to target.

Hope it helps.

EDIT: To enforce the format, you need to find the field you want to alter, inside the $form array. Wysiwyg fields use the 'text_format' when declaring the field through Form API (example here).

So, you have to find the desired field, and change the '#format' property (as in the example), to the machine name of the text format you want to use. Also, you'll see a 'format' propery in the element array. You might want to change that too if you want avoid certain formats from appearing in the dropdown widget.

I recommend you use xdebug to see the structure of the $form variable inside the hook_form_alter() implementation. Alternatively, enable the devel module, and stick a "dpm($form);" in that function, to render the structure on screen when visiting the node form.


This error message is shown when you try to install Drupal, but the Drupal install script detects that there is already a populated (i.e. not empty) database present in the database pointed to by settings.php.

Here is how you set up an empty database to hold Drupal (provided the database is named "drupal").

$ mysql -u root -p
Password:
mysql> DROP DATEBASE drupal;
mysql> CREATE DATABASE drupal;
mysql> GRANT USAGE ON *.* TO drupal@localhost IDENTIFIED BY 'password';
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
    -> LOCK TABLES, CREATE TEMPORARY TABLES ON drupal.* TO drupal@localhost
    -> IDENTIFIED BY 'password';
mysql> quit
Bye
$

This will create an empty database named "drupal", belonging to a database user named "drupal", with the passord "password". (Choose a more obscure password than "password".)

Then delete settings.php and copy default.settings.php to settings.php.  Do not edit it. Make sure the directory where settings.php lives and settings.php itself is writable by the web server.  That will make the install script create a new settings.php with the correct values during the install.

After doing all this: Start again installing Drupal.

After installation is complete, change the permissions for settings.php and its directory back to safe values.  Check that there are no warnings in the Drupal status report.


Show audio file but require registration - suggestions for approach?

You could create a views block for the anonymous user.

1) add a content path field

2) Under Rewrite results, rewrite the content path field and use it's token.

Ex:

Note: (the ?destination= tag, will send them to that page after registration).

3) Change the view access from permission to role and select anonymous user.

4) Add a contextual filter of nid(node ID), select provide default value, select content ID from url.

Then you could use panels, a block, or a view block, then just give it a role of authenticated and put your player there.


On the "Date attributes to collect", uncheck "hour", "minute" and "second". These options are available on the "DATE FIELD SETTINGS" group of the field configuration screen.


Canonical URL for Front Page - without path

Alright - after extensive poking around the issue was that I added Canonical URLs as a [current-page:url:absolute] to the GLOBAL settings rather than the Content.

This meant that the GLOBAL Front Page override was overridden by the other elements.


Programmatically adding fields to node submission form

Add something like this to your hook_form_alter().

$form['#submit'] += array('mymodule_another_submit_handler');

Create that function and save your values from $form_state['values'].

function mymodule_another_submit_handler(&$form, &$form_state) {}

Where are they supposed to go? You might try to fire the submit handler of the other form so you wouldn't have to write so much code.


How to remove subdir from base URL after installing site with Composer on a shared host?

Me and my collegue managed to find a working solution.

In our public_html folder we created a .htacess file with the following lines.

RewriteRule ^$ web/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [L]

We edited the .htaccess file in ~user/public_html/web.

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /web

In the ~/user/public_html/web/sites/default/settings.php file, we added this code at the bottom.

if (isset($GLOBALS['request']) and
'/web/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME')) {
$GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
}

We also changed trusted_host_patterns setting as well.

# will allow the site to run off of all variants of example.com and
# example.org, with all the sub-domains included.

$settings['trusted_host_patterns'] = array(
  '^DOMAIN.com$',
  '^.+.DOMAIN.com$',
  '^DOMAIN.com/web$',
  '^.+.DOMAIN.com/web$',
);

As I said, this is most likely not the correct way to do it, but it worked for us.


How to view a user's personal data after the user performs a login?

You might be able to use the Forena module (disclosure: I'm a co-maintainer) to build custom queries to retrieve the data directly from such database (of which its format can be MS SQL, MySql, Oracle, some PDO compliant database, etc). Think of those custom queries as standard SQL statements that fit your requirements (to retrieve the data). And combine this with the creation of some custom reports.

Those reports can then be shown in an appropriate page (with a specific path), or you could show them in a block, by using Forena's integration with the BEAN module.

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


How do i deactivate "Your comment has been posted." after user posted a comment

you can add a custom submit handler to the comment form using hook_form_alter():

function yourmodule_form_alter(&$form, &$form_state, $form_id){
  if( $form_id == 'comment_form' ) { // find and use the actual form ID
    $form['#submit'][] = 'yourmodule_your_custom_comment_submit_function';
  }
}

Then in that submit function check to see if the message exists using drupal_get_messages():

function yourmodule_your_custom_comment_submit_function(){
  $message = drupal_get_messages('status', false);
  if( $message['status'] == 'Your comment has been posted' ) { // Or what is the actual message
    drupal_get_messages('status');
  }
}

This is for Drupal 7 but these functions exists in older drupal versions. Check api.drupal.org for details.


How to programmatically require a field using Inline Entity Form

I'm not sure if this will work out of the box for you, but I wrote this module https://www.drupal.org/project/require_on_publish to solve a similar problem. You might be able to borrow some of the ideas in there around adding constraints to custom fields to achieve your desired functionality.


How can I register a image_style theme function in my module which only works in my theme's template?

You need to use hook_theme_registry_alter() to replace the callback function for the image_style theme. Something like this should do it:

function MYMODULE_theme_registry_alter(&$registry) {
  $registry['image_style']['function'] = 'mymodule_image_style';
}


Search API view - Displaying items that doesn't meet Facets criteria

Might be wrong place, but my query is related to retrieving improper data. I am using facet to filter the result its working fine. But if I use solr slop to retrive data all the  record are proper and then try to filter the record using another facet Sector then the result displayed in location facet is improper. e.g

Initially search for England, it retrieves all data of England record include location, Sector Cont type data.Location details are displayed in location facet block. But when I do deep filter using Sector facet(sector records are within location searched I.e. England) I get records from Scotland location too.. Scotland location is listed in the location facet along with England. Not knowing what is going wrong afteer using Solr slop as without it all the data retrieved is proper.


Drupal Views: Create 3-Column Home Page with Taxonomy Terms

You can do that easily with your bartik theme.
You can use Panels and page manager with views.

It's not easy to use but it's worth it. There is a great screencast series in nodeone.se.

To be short:

In views: you'll make a content pane (not a block or page)
With panel you can retrieve all the information from this pane and choose your layout and where you want to put all your fields inside it.
In your case you can make 3 content pane, each one with a specific taxonomy. After that you'll choose in which columns you'll want to put them.


How do I actually change the site name on a localized site?

The key to translating the configuration entities and objects is the core module config_translation (Configuration Translation).

This provides extra routes for every form that edits site settings or config entities, which allow editing the translations of translation-enabled config strings.


can't programatically update line item on drupal commerce order

Recently I've updated some other line item fields on commerce_add_to_cart_submit() via this code:

$line_item = commerce_line_item_load($lit_id);
$line_item->field_product_options[LANGUAGE_NONE][0]['value'] = $size;
commerce_line_item_save($line_item);
entity_get_controller('commerce_line_item')->resetCache(array($line_item->line_item_id));

I hope this will help someone.


Is it possible to export organic groups global roles using features?

There is a issue for this in the organic groups queue.  features integration for organic groups permissions and roles.  You may also want to install strongarm and see if that helps you store the configuration settings that are stored as variables.


user ability to hide one column only on view

Found the answer here http://siripong-computer-tips.blogspot.com/2011/12/hide-table-column-drupal-view-w-jquery.html

View 3 on drupal 7 produces html like this

    Example
    howto
    dynamically
    show/hide

      table column
      Drupal
      Views
      jquery

go to view edit page
Displays -> Page Details -> Page Settings -> Footer
add the following code

Show columns
<form>
<input onclick="toggleVis(this, '.views-field-title')" type="checkbox"> Title
<input onclick="toggleVis(this, '.views-field-body')" type="checkbox"> Body
</form>

using Jquery to toggle hide the column


Problem sorting events by Term Reference

It would seem like your link is simply rendering the taxonomy term usage page (that comes standard with Drupal). What I would recommend is creating Views with Contextual Filters (the filter could be the name of the taxonomy term, in this case nursing-home).

Once you have your Views with Contextual Filters built (with a set link, such as /events/) then you can simply rewrite the result of the term field (i.e. display it as plain text and then rewrite) using tokens for the machine name of the term and provide it as a link.

Does this make sense?


Whatever your employees are, if you can create a view of them (and you say you can), you can use Viewfield module.

  Viewfield provides a field that holds a reference to a View and renders it whenever the entity containing the field is displayed.

Exactly what you want to do, without any snippets of PHP.

Specifically, you need to use this capability:

  Administrators may supply a common value that will be used for all entities in a content type.

Just set viewvield to display "employees" view for all organization nodes, and filter views by whatever association between employees and organizations you created, using contextual filters.

Viewfield has built-in passing mechanism, token-based on node / content type configuration side. It can pass node id, author, creation date and any field value you have. On the Views side, these will be contextual arguments as usual.

Benefit over blocks: it will work no matter how and where node is displayed - display configurable just as any other field. You don't need do care to alter block configuration if you want, for example, change path from /node/50 to /organization/drupalangels. Blocks may get left behind. Viewfield will simply continue to work. Also, you can place it directly between other fields without any problem, should the need arise.

Of course for each his own, Viewfield is not flawless either. Blocks was always faster for me to configure, for example. And bit easier to theme. I just found the bit of extra time at first configuration worth it in the long run. For short and fast project, for a client that does not pay well and don't want you to manage site after it's done, it might be not worth to bother.


How to use the LOWER function in a Drupal query?

You can use LIKE instated of LOWER.

OR write something

$query->where('LOWER(n.blog_title) = :page', array(':page' => $page));

Refer Using SQL functions in conditionals in Drupal 7 db_select()


How to export the log messages in .csv file?

You can use phpMyAdmin to export the watchdog table (or select entries) in csv format which excel can read.

If you do not have access of database, you can use Views, Views Watchdog and Views data export modules to accomplish this.


Doing a quick search on Google I found this answer to a similar question: https://stackoverflow.com/questions/7905169/when-did-google-search-start-sending-x-frame-options-sameorigin

I hope it helps.

Best regards,
David.


How do I create and set fields in multiple nodes using a rules loop

Create a sub-rule which does the node creation and call it from within the loop.  This should provide enough separation to keep the nodes from interfering with each other.  Also, use "Save entity" action to lock the new nodes in place during the loop, instead of at the end of the rule.


How do I migrate users passwords from Drupal 6 to Drupal 7?

To update the md5 password to the hashed one I needed to use user_hash_password() and concact an 'U'. Here is the script that I used to make it work.

<?php
        require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
        $res = db_query('select * from drupal.users');

        if($res) {
                foreach ($res as $result) {
                        $hashed_pass = user_hash_password($result->pass, 11);
                        if ($hashed_pass) {
                          $hashed_pass  = 'U' . $hashed_pass;
                          db_update('users')->fields(array('pass' => $hashed_pass))->condition('uid', $result->uid)->execute();
                        }
                }
        }

Then I ran

drush scr <name_of_the_script_file>

And it worked.


How does Drupal generate form ID for a form?

user_profile_form is defined in user.pages.inc file in user module directory.

The id of the form is the function name which generate the structure of the form in Drupal System. When we call drupal_get_form, it call function name to build the form array.

There is a function drupal_prepare_form in form.inc in includes directory of the Drupal root.

  drupal_prepare_form function prepares a structure of the form array
  and adds required elements, executes any hook_form_alter functions
  and optionally inserts a validation token to prevent tampering.

Code Snippets to generate form id:

if (!isset($form['#id'])) {
    $form['#id'] = drupal_html_id($form_id);
  }


Multisite with some shared content and some different content

You don't really want a multi-site at all by the sounds of it. You're looking for Domain Access

  The Domain Access project is a suite of modules that provide tools for
  running a group of affiliated sites from one Drupal installation and a
  single shared database. The module allows you to share users, content,
  and configurations across a group of sites such as:

  example.com
  one.example.com
  two.example.com
  my.example.com
  thisexample.com <-- can use any domain string
  example.com:3000 <-- treats non-standard ports as unique

In fact, the ORIGINAL use case for Domain Access was for magazine sites (from the documentation), so it should fit your needs perfectly!


Set a main-menu item as active with custom code

If you simply want to add the 'active' class to a menu item you could do it in the code before printing the menu.
If you want the menu item to also act like an active item you could use menu_tree_set_path() that was supposedly added in Drupal 7.9.

In earlier versions and Drupal 6 I used this:

function mymodule_init() {
  $item = menu_get_item($_GET['q']);
  $item['href'] = 'node/1';
  menu_set_item(NULL, $item);
}

However both options just add the 'active-trail' (not 'active') class(es), but that should suffice in most cases.


How to rebuild everything that can be rebuild during module development?

drush cc all

Catches most of it. Registry/files[] changes can be tricky, but should work as well in most cases.

Node access records are not rebuilt by that, that wouldn't make sense to me. Unless working on a node access module, you don't want to have that rebuilt, as there could possibly be many nodes which means that this process could take a very long time.


Remove features without lose functionality

You can use the Features Tools Module to disable a features module while leaving the functionality that was provided by the feature in place.

Instructions provided by autopoietic here.

  First BACKUP YOUR DATABASE
  backup your feature (files) if you would like to use it again.
  Once installed, go to the 'recreate' page for a feature, uncheck all of the features
  components
  In order to save the elements to the DB you need to go to the admin/build/features/unlink
  page, check the element you need to import and submit.
  Now click on the 'Safe autocreate' button to recreate and replace the feature with an empty
  version.
  You can now disable the module without affecting your site configfuration.

These instructions note that "if you are using D6 there is an extra step" which I have added (step 4 above).


I've found that at the moment, there is no example more helpful than the Plupload module.  It integrates with the Plupload_widget module and extends the FileWidget from core and also has a lot of comments that I wish core would have included, explaining what the core file widget does.


drupal 7 display user info for current user

When you create the view, at the very first screen, you have the option to select the entity type on which you want to create the view. (thank J.Reynolds)

Then in Fields add Field Name, Role, Image
In Fileter Criteria add filter User : current

It's all !


Is there a reason why I shouldn't be able to upload more than 95 items on to an image field?

Solution is to increase upload_max_filesize and post_max_size in your php.ini. Because POST data can be truncated if it exceed specified limits.
This can happen when you upload lot of images and send them all in one big POST.

Other way to fix this - is automatically upload image via AJAX request just after user select it - try JavaScript code from How can I automatically upload images on file selection rather than pressing the upload button?

Also try to increase max_execution_time in PHP settings. PHP may be lack of time to upload and save all 95 images during default 30 seconds.


How to hide specific term/field value on the node?

Each term has a level. So if you want to show only the terms from level 2 (London, Paris) you could loop over your terms, check the level and hide if its not 2. If you need to have individual rules for hide / show, then you could add a field to the term where you can save a value to show or hide and use this in your loop.


Migration query works but migration fails due to sourceid not being found

The relevent part of the error message is "'drupal_8.map.sourceid1' isn't in GROUP BY". Let's look at the query as executed:

SELECT sca.price AS price,
map.sourceid1 AS migrate_map_sourceid1, map.source_row_status AS migrate_map_source_row_status
...
GROUP BY price

SQL requires that all columns being selected be part of the GROUP BY. The SqlBase class has determined that your source query can be joined directly to the migration's map table, and thus performs the join as an optimization, adding the map table fields to the columns returned. However, it doesn't add them to the GROUP BY. There's an issue for that: https://www.drupal.org/node/2844595. For now, you can set

ignore_map: true

in your source plugin's configuration to prevent the join and it will work.


If you need to peek, say into user->data, which is seralised data array, just use drush sqlc to bring yourself to an sql command line, then type:

 select uid, name data from users where uid = <whateveruidyouwant>;

This works for any data, and if you are brave you can even edit the serialized data via command-line but is not recommended unless you know what you are doing.


How can I alter the HTML output of the default 403 and 404 error messages without hacking core?

Implement a custom module providing the 403/404 markup as a page callback. Note that access can be granted to anybody by setting the access callback in the menu router items to TRUE.

After enabling the custom module, you simply set the error pages in Configuration » System » Site information to the paths you defined in your hook_menu implementation.

/**
 * Implements hook_menu().
 */
function acme_menu() {
  $items['acme_404'] = array(
    'page callback' => 'acme_404',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['acme_403'] = array(
    'page callback' => 'acme_403',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Page callback for custom page not found.
 */
function acme_404() {
  return filter_xss(variable_get('acme_404_markup', 'custom 404 markup'));
}

/**
 * Page callback for custom access denied page.
 */
function acme_403() {
  return filter_xss(variable_get('acme_403_markup', 'custom 403 markup'));
}


See How to delete a content type, programmatically? for the easiest way for your use case. This works for any config entity that doesn't already explicitly depend on your module (those are uninstalled anyway).

The nice thing about that approach is that the user will be informed on the uninstall confirm age that this stuff will be deleted.

To delete using the API, node types are entities, so you delete them like all others: NodeType::load('id')->delete()


I guess my first question is how many nodes are you looking to update. If it's a relatively small amount, you should just use VBO (per the article you referenced). That is the easiest contributed module method of updating multiple nodes.

However, it is possible for you to create your own module (i.e. custom_node_update) and run the node_mass_update upon form submission (as recommended by the API documentation). This will be especially useful if you are updating a large number of nodes because it will batch it appropriately, however, you'll be required to write some custom code.

Does this answer your question?


D7: function calls too early (before DOCTYPE) and mess my page

You need to return your HTML string as the page callback rather than outputting it directly...otherwise what your doing is incompatible with the the Drupal theme system, and is why you're getting the problem you're getting at the moment.

Without seeing all of your code its impossible to debug this completely but suffice to say that in whichever page callback function you're calling display_container() you want to do this instead:

// Start the output buffer
ob_start();

// This will perform the echo to your new local buffer, not the screen buffer.
display_container();

// Get the temporary buffer content into a variable.
$output = ob_get_clean();

// Return the page callback to Drupal as normal
return $output;

If you're in a block view (which I seem to recall you might be from one of your previous questions) that last line would be:

$block['content'] = $output;

The other, perhaps simpler method here, would be to simply change your display_container() function to return the string rather than output it directly:

public function display_container(){
  $container = "
";
  $container .= "
";
  $container .= "

\n";

  return $container;
}


Is possible to sort a views field that is generated by custom views handler?

For a Table display, use the style options to make the field sortable.


The short answer: you don't generally access the database in Drupal.  Drupal serves as an intermediary between you and the database, and if you access the database directly more than likely you are going to cause yourself many problems in the long run, especially in the beginning when you're not very familiar with Drupal.

For more, see Understanding Drupal and the Structure Guide on Drupal.org.


Unique form per user with custom form class

Your updated post shows the issue. The issue here isn't the form, it's the underlying storage method. You are using configuration, which is for site configuration, ie configure how the site as a whole works. But you want to save values per user, not for the whole site.

What you are looking for is having a form used by all users, saving the submitted values for the user, rather than for the site.

I would suggest using the user.data service. This service lets you save data for users. You can user UserData::set() to set values, and UserData::get() to get values. Get the values in the form definition to get the default value, and set the values in the submit handlers to update them with the current values.

As a side note, if you were creating a form for configuration (which you're not), you would want to extend ConfigFormBase, which it doesn't appear you were doing, based on your code.


Drag and drop no longer working on my drupal 7 site after workbench acess install

Try selecting a newer (or older) version of jQuery using "jQuery Update"


Here's my take on it:

The PHP docs says about eval:

  Its use thus is discouraged

It is always, let me emphasize that again, always, bad to use the PHP module (technically eval, but the PHP module makes a dangerous language feature much worse).

Details discussed in this question: What are the downsides of using PHP Filter code in blocks, nodes, views-args, etc?

The link provided by Clive claims

  Sometimes eval is the only/the right solution.

It is possible that this is true, some times, but during quite a few years of professional development, I have never stumbled across a real need for it, in PHP or other languages.

Personally, I've taken it to the level that my servers disable the functionality on the php level itself, with disable_functions = eval.

With that said, on a small personal website, it's likely of less consequence than on a large enterprise one, and there are cases where it's at least not completely horrible to use it.


Sure see this great blog post titled WYSIWYG Module + CKEditor: Taming the Beast by Fuse Interactive. I am not affiliated with the company nor the author of it -- it's simply a great resource.

Linked in those blog comments is a link to the CKEditor Configuration Options documentation, which is what you'll end up altering to make this happen.

In the blog post they supply their own config settings for the editor in javascript. I believe you can set all these values in hook_wysiwyg_editor_settings_alter, the settings for the Styles look like:

  { name : 'Float Right', element : 'div', attributes : { 'style' : 'float:right;' } },
    { name : 'Float Left', element : 'div', attributes : { 'style' : 'float:left;' } },

Where this defines a style called Float Right that wraps the selected text in a div with some inline styling. I believe you can easily assign classes instead of inline styles as well.

This should be a huge jumping off point for you to figure it all out. Best of luck!


How can I let users enter the cck value once and then protect the field from editing?

I think the link below will be helpful to you..

Code snippet: How to set the disabled or readonly attribute of a CCK field

Check this link and let me know if in case of any query.

Thanks.


You can do this by using any of these below modules :

Facebook Connect
Simple FB Connect
Drupal For Facebook


Views PHP Field - Comparing two date fields

You might need to add the $absolute parameter in your call to DateObject::difference(), in order to be able to get the sign:

$difference = $start_date->difference($end_date, 'days', FALSE);

According to the DateObject::difference documentation, the $absolute parameter:

  Indicate whether the absolute value of the difference should be
  returned or if the sign should be retained. Defaults to TRUE.


How to remove any data "http_proxy" module added or changed?

Uninstalling the HTTP proxy module appears to not uninstall its configuration. So the proxy configuration is likely still in place in your case. I assume that the reason the HTTP proxy module does not remove the configuration is that it doesn't explicitly "owns" the configuration: it exposes hidden settings from Drupal core.

There is an issue about this reported in the http_proxy issue queue: https://www.drupal.org/node/2592461


How can I make a field appears when you check on a checkbox?

You can use #states from FormAPI that drupal provides.
Below is the link
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#states

Below is the code from drupal form api

$form['email_canceled']['settings'] = array(
    '#type' => 'container',
    '#states' => array(
      // Hide the settings when the cancel notify checkbox is disabled.
      'invisible' => array(
       ':input[name="email_canceled_toggle"]' => array('checked' => FALSE),
      ),
    ),
  );


Allowing authenticated users to create files through Service/Restful

Make sure "Save file information" is set for authenticated users


How do I show all the images in my public:/images/ folder?

Firstly get fid of the images and then put it in the function below Like i did:-

$file_load=file_load($fid);
$url=$file_load->uri;

$url retrieve you image path where you have uploaded your image.
Like:- public:/images/image_name

Use this fuction to display your image. image_style

$variables= array(
'style_name' => 'style_name',
'path' => $url,
'getsize' => FALSE,
'attributes' => array(
 'width' => '100',
 'height' => '100')
);

echo theme('image_style',$variables);

Note :-if you are using drupal theme('image_style',$variables) function to display image.then put url like public:/images/image_name in path given above.else you are using  to display image then use below code.

Or You can also do this.

$file_url=file_create_url($url);
echo '<img src="'.$file_url.'"'>;

Hope this will help you.


You can use Postman, a Google Chrome browser app that allows you to POST, GET, PATCH, and DELETE to any site (for testing purposes), to generate the code for you:

After completing the 3 steps shown in the picture, you need to perform 1 more step:

Then paste the code into your custom module.

PS: I believe you can delete the postman-token line in the headers.


I don't know the problem, but after adding the  following piece of code in my database.ini of oracle directory and changing my calling method prepare('-----') to oraclePrepare('-------') I am able to access the stored procedure with parameters. I got the reference from here

Check for the oraclePrepare('-------') method in database.ini. If it is not there then add following lines in the DatabaseConnection_oracle class.

code Added in DatabaseConnection_oracle class of oracle's database.ini:

 public function oraclePrepare($query)
 {
     return parent::prepare($query);
  }


Unable to access site after deleting an entry from the database

You can try installing the views in a similar configuration to your current site, on another install, and then copy that row from the database in that install to your current site.


Solved it !

Explanation :

A file with a name like 'file.xxx' was present at the root of the site. I removed it and everything started to work.

I then put back an empty file named 'file.txt' at the root of the website, and the same error rose again.

It can happen more often than it seems. In my case, I downloaded a patch for the  filefield module which was named file_something.patch and forgot to delete it after applying. Easy to do, easy to forget, hard to remember once you've moved on to something else.

Bottomline : keep your webroot clean of anything not Drupal or you're in for trouble. Can't believe I lost two days with such a simple problem.

Thanks to Mohammed Shameem for his try, and to anyone who gave this a thought.


Call to a member function label() on a non-object in entity module

It looks like this is a bug in the Entity API module.

An issue with exactly the same error message was reported here to do with the Profile2 module (which uses Entity API pretty heavily).

The upshot of that post is that the problem is an Entity API bug, details of which you can see at: Load reference field when building contents.

As you can see from the above there are patches available to fix the problem. The most recent patch that passed testing was on the 16th November 2011.

When you look at the Entity API module's latest stable release you can see it's date sas the 10th November 2011. This means that the patch probably hasn't made it into the stable version yet, so won't have been fixed in your version of the module.

There are two things you can do:

Upgrade to the dev version of the Entity API module (of course the usual amount of caution should be taken and you probably won't want to do this for a live site).
Apply the patch to the entity.controller.inc file that seems to have solved the problem for other users.


What is the basic use of the breakpoints.yml file?

There is no way to use the breakpoints defined in a breakpoints.yml file in CSS without pre or post-processing. Since we don't use processors for styling in core, the breakpoints are still hard coded in the CSS files. In a custom theme you are however free to use tools like Gulp or Grunt and it would theoretically be possible to use the breakpoints.yml input for your CSS generation.

Currently the breakpoints.yml is mainly interesting for JavaScript (JS). Have for example a look at the Toolbar module in core. The breakpoint info is added to the 'drupalSettings' JS object in 'src/Element/Toolbar.php' like so:

$breakpoints = static::breakpointManager()->getBreakpointsByGroup('toolbar');
if (!empty($breakpoints)) {
  $media_queries =  array();
  foreach ($breakpoints as $id => $breakpoint) {
    $media_queries[$id] = $breakpoint->getMediaQuery();
  }

  $element['#attached']['drupalSettings']['toolbar']['breakpoints'] = $media_queries;
}

Then in JS the run-time settings as defined above are read in.

var options = $.extend(
  {
    breakpoints: {
      'toolbar.narrow': '',
      'toolbar.standard': '',
      'toolbar.wide': ''
    }
  },
  drupalSettings.toolbar
);

Later an event listener is added per breakpoint so that 'something' can be done when the screen size changes.

for (var label in options.breakpoints) {
  if (options.breakpoints.hasOwnProperty(label)) {
    var mq = options.breakpoints[label];
    var mql = Drupal.toolbar.mql[label] = window.matchMedia(mq);
    mql.addListener(Drupal.toolbar.mediaQueryChangeHandler.bind(null, model, label));
  }
}

In the event of a change different actions can be undertaken per breakpoint.

Drupal.toolbar = {
  mediaQueryChangeHandler: function (model, label, mql) {
    switch (label) {
      case 'toolbar.narrow':
        model.set({
          isOriented: mql.matches,
          isTrayToggleVisible: false
        });
        break;

      case 'toolbar.standard':
        // Logic
        break;

      case 'toolbar.wide':
        // Logic
        break;

      default:
        break;
    }
  }
};

Note: the code examples are taken from the Drupal Toolbar module and stripped. Use as inspiration, not as functional code.

A good explanation about using JS mediaQueries in general can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries


Export the config and open the view mode in a text editor or run this drush command from the command line:

drush cedit core.entity_view_display.node.[content-type].default

Then remove the field settings you think could break your view mode and import the config again or exit/save if you used the drush command.


Global site variables to be used in node fields and menu item

Try the Custom Tokens extension to the token module. Here is a quote about it (from the module's project page):

... gives the user the ability to create custom tokens for specific replacements that can improve other modules relying on the Drupal 7 token API or, for Drupal 6, the Token module.
Versions 7.x-1.x and previours relied on PHP evaluation to build custom tokens.
The new 7.x-2.x relies on input filters. While still allowing for PHP tokens through the D7 core PHP filter module, administrators can permit only HTML or plain text custom tokens.


How to run alterRoutes on particular condition ? Does it run on cache clear and not on normal Request?

Yes, it runs only on cache clear. You have to implement the dynamic behavior inside of the controller. By extending the core user controller you can call the parent method in case the dynamic condition doesn't apply:

class UserCustomController extends UserController {

  public function resetPass(Request $request, $uid, $timestamp, $hash) {
    if (!...) {
      return parent::resetPass(Request $request, $uid, $timestamp, $hash);
    }

    // return the redirect you want
  }

}


You need to change the html structure for this. Open page.tpl.php then remove the header section from there.


Change a paragraph link field title at runtime

This worked for me

function MYTHEME_preprocess_field(&$variables, $hook){
  $element = $variables['element'];

  /* Translation modifier:
   * The call to action paragraph is used on almost all pages and translations
   * doesn't work with paragraphs at all. So we need to detect if we are in a US
   * translation and change out the spelling of certain words.
   */
  if(is_us_translation()){
    if (isset($element['#field_name'])) {
      if ($element['#field_name'] == 'field_link') {
        $str_to_check = strtolower(trim($variables['items'][0]['content']['#title']));

        if(strpos($str_to_check, 'enquire') !== false){
          $variables['items'][0]['content']['#title'] = 'Inquire';
        }
      }
    }
  }
}


Custom submission handler doesn't save the node

Use [] syntax instead of Array() and switch the order ... that should work.

Credits: Shawn Matthews.


Send notification e-mail after new content was added

Rules is best for this, it depends on Entity API.

Simple download and enable them from Admin -> Modules
Now follow Admin -> Configuration -> Workflow -> Rules
Click on Add new rule
Define name e.g. "New content email notification" , select 'After Saving new content' from React on event select box and hit the Save
On the next page, event is already defined, No condition is required to define here, Head on to Action section and hit Add action
Enter recipient email address in the To field box
Populate Subject and Message, From fields. (A number of Replacement pattern are available to include in the text)

e.g. New content [node:title] added by [node:author] of type [node:type] on [node:created].

Hit the save
On the settings fieldset, make sure to check Active check box.


Using a file extension (.htm) in Views contextual filter path

Why not use the redirect module (or just plain ol' .htaccess 301 redirects) to redirect /section/file.html to /section/file ?

I understand the client doesn't want URLs to change, but doing a proper 301 redirect would preserve any SEO rankings they are trying to retain.


Can I handle calculating/charging for shipping after order placed?

Yes, because Drupal Commerce 2.x and most payment gateway modules tokenize credit card details by default for the sake of reusable "stored payment methods." From a customer experience standpoint, you might want to offer some sort of estimated shipping amount, but so long as you're communicating that shipping costs will be calculated and confirmed with the customer prior to charging, there's not technical reason you could not charge the full amount during the fulfillment process.


CSS still requiring clearing cache after following steps to switch caching off

Written by @Clive in the comments

  Are you using chrome? Asset caching got way more aggressive recently
  for some reason, if you're using it try opening the Network tab in dev
  tools and selecting "Disable cache"

This solved me the problem.


Can't get id/name of view in hook_preprocess_views_view_unformatted

This is the only way I could get view id (not sure why)

function THEMENAME_preprocess_views_view_unformatted($vars){
  $view = $vars["view"];
  //works
  $id = $view->id();
}


Unusual renewal of subscription products

I've not used UC Recurring Payments and Subscriptions before properly, but if each payment is a fully fledged order then I imagine you could use Conditional Actions to look at the date compared to the initial purchase date and give a discount if that is within the three years. The coding effort is then just creating a new condition using hook_ca_condition() which is not hard, and then after that setting up the pricing rules in the CA interface.


sudo wget http://files.drush.org/drush.phar
sudo mv drush.phar /usr/local/bin/drush
sudo chmod +x /usr/local/bin/drush
# test drush by executing:
drush status

Note_1:  For possible future releases --- If there will be non-Ubuntu version of WSL you might need to download the wget Linux utility to use it for downloading drush.phar.

Note_2: To those who have yet to install WSL - See this thread.


I'm looking for a way to force the migration to process entries with identical keys

You can do this with drush migrate-import --update. See the migrate_tools module.


Looks like you are getting a javascript error in your superfish.js file.

Uncaught TypeError: Cannot read property 'msie' of undefined

The $.browser method has been removed as of jQuery 1.9.

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

As stated in the Upgrade Guide you can try using the jQuery Migrate plugin to restore this functionality and let jQuery Tools work or you can use an earlier version of jQuery for your site (1.8 for example)


Form filter by field on entity_autocomplete

The core autocomplete feature expects the label of the returned matches contain the id of the referenced entity like Superuser (8) which is parsed by the drupal.autocomplete behavior and submitted through the actual form input. The easy solution its to ensure that your response returns the expected values. But you can always implement your own. See Drupal\entity_reference\EntityReferenceController to see how the core implenents it.


Commerce Kickstart demo: How do I change the region for the blocks Main Menu and Secondary Menu?

Menus are printed in the region--menu.tpl.php @ profiles/commerce_kickstart/themes/commerce_kickstart_theme/templates .

You can see the settings for the same in the link admin/appearance/settings/commerce_kickstart_theme

If you would like to change the positions of menus, then disable the Main Menu & Secondary menu in above link settings as shown in screenshot and enable the blocks using Blocks page.


How to resolve error Font-awesome library could not be found?

You need to download FontAwesome and move files into the /libraries directory. It is explain in the documentation of the module here

And you had a clear warning message explaining that. You could have read the README.txt


Hover a trimmed views field for full text?

Hate to answer my own bounty question but this works exactly as I want it.

I found a great way to do this with beautytips module. My field is an address (field_address). Add field_address to views and do rewrite->trim with ellipsis BUT exclude from display. Add the same field again this time rewriting the output of the field with:

[field_address]

(I have "Add beautytips js to every page" enabled in the beautytips settings)

+1 zhilevan's answer which is also a very good solution but is sadly missing the roll-back/rollup/close option which would mean very long tables with a few read mores open!


Is there an existing module to bulk delete user content but not user?

I'd suggest to try out Rules module for this, you've got an event: "User has logout", grab the entities from that user, loop them and delete them.

Here's a exported rule that would do it (change the number of entities to suit your needs)

{ "rules_test_logout" : {
"LABEL" : "test_logout",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_logout" ],
"DO" : [
  { "entity_query" : {
      "USING" : { "type" : "node", "property" : "author", "value" : [ "account" ] },
      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
    }
  },
  { "LOOP" : {
      "USING" : { "list" : [ "entity-fetched" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [ { "entity_delete" : { "data" : [ "list-item" ] } } ]
    }
  }
]

}
}


Honestly, I think that the module Domain Access would meet your needs more than Organic Groups would. A friend of mine recently created a site matching exactly your criteria.

  Module Package includes:

  Domain Alias 6.x.2 and higher only by bforchhammer. Allows you to
  specify subdomain aliases and domain name patterns for domain entries
  so that multiple hostnames are matched on a single domain entry.

  Domain Configuration -- Allows you to change select system variables
  for each subdomain, such as offline status, footer message and default
  home page.

  Domain Content -- Provides a content administration page for each
  subdomain, so that affiliate editors can administer content for their
  section of the site.

  Domain Navigation -- Supplies a navigation block with three themes.
  Creates menu items for each subdomain, suitable for using as primary
  or secondary links.

  Domain Path -- Enables custom path aliases per domain.

  Domain Prefix -- Provides a user interface for enabling select
  database table prefixing for use with subdomains. The Drupal 5 version
  is not fully functional on pgSQL, but Drupal 6 version is.

  Domain Settings -- Exposes domain-sensitive variable settings to most
  configuration forms. Requires Domain Conf.

  Domain Source -- Allows editors to set a primary source domain when
  links are written to content from other domains.

  Domain Strict -- Forces users to be members of domains in order to
  view content. This is a sample extension module that uses the API.

  Domain Theme -- Allows separate themes, theme settings and colors for
  each subdomain.

  Domain User -- Allows for the automatic creation of subdomains for
  registered users.

  Domain Views by mrichar1 and nonsie -- Provides Views integration for
  Views 5.x.1 and 6.x.2 or higher.


For FILTER HTML go to:

/admin/config/content/formats/filtered_html

add <button> to the limit allowed HTML Tags list.

If you use FULL HTML the button should work.
If not try
go to:
/admin/config/content/ckeditor/edit/Advanced (for Filter HTML)
/admin/config/content/ckeditor/edit/Full (for Full HTML)
Then under Advanced Content Filter, select disabled.


I have a similar issue! However, I am able to print specific field values in view-view-field.html.twig by using the syntax {{ view.field.[filed_name].original_value}}.
In my cause it was {{ view.field.title.original_value}}.

The issue I have is the each title is coming up 4 times! I don;t know how to fix. I also overrode views-view-fields.html.twig to add my own HTML wrapper outside the loop:

      {% for field in fields -%}
        {{ field.separator }}
        {%- if field.wrapper_element -%}
          <{{ field.wrapper_element }}{{ field.wrapper_attributes }}>
        {%- endif %}
        {%- if field.label -%}
          {%- if field.label_element -%}
            <{{ field.label_element }}{{ field.label_attributes }}>{{ field.label }}{{ field.label_suffix }}</{{ field.label_element }}>
          {%- else -%}
            {{ field.label }}{{ field.label_suffix }}
          {%- endif %}
        {%- endif %}
        {%- if field.element_type -%}
          <{{ field.element_type }}{{ field.element_attributes }}>{{ field.content }}</{{ field.element_type }}>
        {%- else -%}
          {{ field.content }}
        {%- endif %}
        {%- if field.wrapper_element -%}
          </{{ field.wrapper_element }}>
        {%- endif %}
      {%- endfor %}

which is rendering well on the page, but I cannot get rid of multiple title issue. Any suggestion would be greatly appreciated.

Here is a screenshot of how my page looks now:


How can we synchronize Nodes from Staging to Production Server

For Node changes, you can use node export  module to migrate node between drupal installations. for Tracking Configurations changes there is another module configurations , i haven't tried yet. Be sure cos the module release is still in dev


Let users choose from pre-defined user set options for creating a node

I find using a custom form always seems to be more work then just using the one Drupal provides to add nodes. Even if they are not quite what you want hook_form_alter makes it easy to modify them to suit your needs.

I would create an unpublished node for each of my 'presets'. This way it is easy for an administrator to update the preset values, but normal user won't be able to see them.

Then using hook_form_alter I would add a selectbox to the top of the node add form allowing the users to choose between any of the presets. You could add an #ajax property to the selectbox that rebuilds the whole form.

Again in hook_form_alter if $form_state['values']['yourselectbox'] is not empty then you can load the values from that node and populate the form with them.

As an example (none of this code is tested but I think should be almost right):

function mymodule_form_alter($form, &$form_state, $form_id) {

    $templates = db_query("SELECT nid, title FROM node WHERE type='my_type' AND status=1")->fetchAllKeyed();
    // TODO: Should maybe add a field to control if this node is a template or not?
    $default_template = 0;

    if(!empty($form_state['values']['templates'])) {
        $default_template = $form_state['values']['templates'];

        $selected_template = node_load($default_template);

        // if your fields have multiple values you will need to loop here
        $form['other_field_1'][LANGUAGE_NONE][0]['#value'] = $selected_template['other_field_1'][LANGUAGE_NONE][0]['#value']
        $form['other_field_2'][LANGUAGE_NONE][0]['#value'] = $selected_template['other_field_2'][LANGUAGE_NONE][0]['#value']

    }

    $form['#prefix'] = '
';
    $form['#suffix'] = '
';

    $form['templates'] = array(
        '#type' => 'select',
        '#title' => 'Template',
        '#options' => $templates,
        '#default_value' => $default_template,
        '#ajax' => array(
            'callback' => 'change_template_callback',
            'wrapper' => 'whole_form_wrapper',
            'event' => 'change',
        ),
    );

}

function change_template_callback($form, $form_state) {
    return $form;
}

See the examples module - it has loads of good stuff on forms and ajax.


How to set to Webform's fields a 'Number of values' setting like in default content types?

Webform Addmore

  Webform Add More enables selected fieldsets to be initially hidden and
  progressively shown with an Add more button, mimicking CCK multiple
  fields. The approach was proposed by Bartezz, and code originally
  implemented by span and kranklin 1. This module adds a checkbox
  setting to webform fieldset components to select which should have Add
  more functionality, as well as an advanced setting to override the
  button label per Webform.


How to hide a views result item based on role?

Assuming you added Taxonomy term: Name as the field, which you want to hide.

Add this to your theme's template.php file.

function mytheme_preprocess_views_view_fields($vars){

  $global user;

  if ($vars['view']->name == "name_of_view" && strip_tags($vars['fields']['name']->content) == "Term Name" && in_array('role name', array_values($user->roles))){
    $vars['fields']['name']->content = NULL;
  }

}

change mytheme to your actual  theme name.
change name_of_view to your view name.
change Term Name to the name of the term.
change Role Name to the specific role name.


How to add pagination (pager) to field collection module?

After trial and error, I found the perfect solution to provide Paging to the content created by Field Collection module. This can be done by Views module.

You need to create the View of the your content which you have created using the field collection.

Important Part: In the Views setting as described in the following snapshot in the section of Multiple Field Setting, you need to uncheck the Display all the values in the same row. Because by default it is checked so Views considers your entire content in single row, so pager of views considers it as only one item. But if you uncheck, your each field set considered as single row and so Pager of the Views module will calculate accordingly. Hence unchecking this setting in Views and providing pager in the Views module will solve the issue.

Hope this will help others.


In which table should I save the value of system_settings_form in Drupal 7?

If you use system_settings_form function your data will be saved in 'variable' table.
To get saved data you may use variable_get function.

To show saved value in form

       function mycustom_form($form, &$form_state){
         $form = array();
         $form['position'] = array(
           '#type' => 'textfield',
           '#title' => t('Position for the magnifier'),
           '#options' => array('left' => 'Left', 'right' => 'Right','up'=>'Up','down'=>'Down'),
           '#default_value' => variable_get('position', ''),
           '#required' => TRUE,
         );

         return system_settings_form($form);
       }

If you want to use saved data from your form in the javascript, you may use next code

drupal_add_js(array('myModule' => array('position' => variable_get('position', ''))), 'setting');

Then this data will be available in javascript in Drupal.settings.myModule.position variable


You could store the last updated timestamp in the session on login, and then check it on each page load to see if it's within your parameters:

function MYMODULE_init() {
  // Only proceed if there's a timestamp in the session. Otherwise defer to
  // hook_user_login() to take care of setting that.
  if (user_is_logged_in() && isset($_SESSION['MYMODULE_point_check_timestamp']) {
    // If the timestamp is more than 24 hours ago, award more points.
    if (REQUEST_TIME - $_SESSION['MYMODULE_point_check_timestamp'] > (60 * 60 * 24)) {
      award_points();
    }
  }
}

function MYMODULE_user_login(&$edit, $account) {
  award_points();

  // Track the time points were awarded.
  $_SESSION['MYMODULE_point_check_timestamp'] = REQUEST_TIME;
}

function MYMODULE_user_logout($account) {
  // Clean up.
  if (isset($_SESSION['MYMODULE_point_check_timestamp'])) {
    unset($_SESSION['MYMODULE_point_check_timestamp']);
  }
}


How do I let users view, edit or delete their own contents?

You can set these permissions at People > Permissions. Take a look at the 'Node' section. Also, a very practical module for specific cases is Field Permissions.

  The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.


Hide local tabs in specific content type

Have you tried Tab Tamer ? If you're using D7 a port in on its way.


Assuming you have a variable containing the entire structure that you have added.

Try

$taxonomy['8942']->field_report_group['und'][0]['tid']


How to force rendering by the site theme instead of the admin theme?

Based on the comment by @MrD, I found a working solution.
I implemented a custom theme negotiator based on this information:

Blog post: Dynamic theme switching in Drupal 8
Blog post: Choose your theme dynamically in Drupal 8 with theme negotiation
Drupal Answers: How can I programmatically change the active theme?

I needed to change the theme for the admin content page, so here is the code I used:
mymodule.services.yml
  MYMODULE.theme.negotiator:
    class: Drupal\MYMODULE\Theme\ThemeNegotiator
    tags:
      - { name: theme_negotiator, priority: -20 }

Here, I used a low priority to ensure my code runs first.
MYMODULE/src/Theme/ThemeNegotiator.php
<?php

namespace Drupal\MYMODULE\Theme;

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;

/**
 * Select the correct theme for various routes.
 */
class ThemeNegotiator implements ThemeNegotiatorInterface {

  /**
   * {@inheritDoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    return $this->negotiateRoute($route_match) ? TRUE : FALSE;
  }

  /**
   * {@inheritDoc}
   */
  public function determineActiveTheme(RouteMatchInterface $route_match) {
    return $this->negotiateRoute($route_match) ?: NULL;
  }

  /**
   * Select the theme for special cases.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The currently matched route.
   *
   * @return bool|string
   *   The theme name to use (string) or false (bool).
   */
  private function negotiateRoute(RouteMatchInterface $route_match) {
    $route_name = $route_match->getRouteName();
    if ($route_name === 'system.admin_content') {
      return 'MYTHEMENAME';
    }
    else {
      return FALSE;
    }
  }

}


Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1 no such table:

Unfortunately you've gone down the wrong path by deleting your existing site. Hopefully you have a backup you can restore from...

Drupal 8 isn't an update, it's a brand new system; you need to migrate your D7 site to it.

The docs are here, they should contain everything you need


I'd add a new field called Display Name (or similar), then then use hook__user_format_name_alter() to load in that field, and change the display name to use the field value instead of the user name.

Here's the change record for D7 -> D8, where it used to be hook_username_alter(): https://www.drupal.org/node/1408514


XML Sitemap Last Modified Date on a View

The short answer is: No.

How are you including the views in the sitemap? I assume that you are just putting in custom paths? Without writing custom code, the only thing you can do for the custom path is to change the change frequency to a realistic amount. Don't exaggerate the frequency too much, or crawlers will start ignoring it.


How to include media documents in search

As I understand, you want to search by Media entities/records.

If you use the standard Search module from Core, then it impossible.

But you can install the Search API module, configure the search server (search server can use current drupal Database or Apache Solr, or smth other).

In the Search API you can create indexes and include the documents into the index.

To display a page with search results you can use a Views module (using content from Search API index) or you can try to use the Search API Pages module


Change "Add new node" and "Add existing node" button labels in inline entity reference forms

Turns out this is really easy. Under "Manage form display" in your content type, make sure that the widget is set as Inline entity form (simple or complex) and check "Override labels" then define your node type label.


javascript aggregation disables the font-your-face module and views-slideshow on the main page

It turned out the problem is with the fields slideshow module and its use of js/jquery libraries.
I've realised that JS error happens  after calling some slideshow libraries, so i googled for aggregate js / field slideshow.
As per https://drupal.org/comment/7874537#comment-7874537 , I used the 2.1.x version of the imagesloaded library and everything worked nice afterwards.


How do you programatically determine who submitted a webform?

@beltouche: It should be noted that this YAML source creates a webform that internally stores the displayname property.  As a result the identified user is stored wherever the webform submissions are stored.  I now assume this is as designed.  It seems to me that the prepopulation of a webform using something like {{ user.displayname }} is best accomplished by using a block/webform hybrid content type.  Am I on the right track with this thinking?


How do I add the Arab League flag as language?

You can't add a flag as a language, if you can add a new language go to YOUR_SITE/admin/config/regional/language/add choose the new language if your language is not listed you can add a Custom language (See at the bottom of the page the collapsed option).

And if you want to use a flag for your language you can install the Language Icons module. Then go to the folder (in your server) YOUR_SITE/sites/all/modules/languageicons/flags and add the flag for your new language, you need to use as a name YOUR_LANGUAGE_CODE.png


I don't think you want multisite. If you're concerned about environment spinup time, create a drush make file with the modules and settings you want. You can even generate one online.

You could also use a development environment like Pantheon or Kalabox or Acquia Dev Desktop, or another distribution to get started.


How to export complete products data to csv file

Try Views Bonus Pack module too. You can see an option "Data Export" while adding a display in the view.


Contextual links for programmatically embedded views

Views does this by wrapping the render array output with the views_add_block_contextual_links() function. It checks if the display plugin has contextual links associated with it. If the $display_id is a block then it will have the contextual links.

  if ($view = views_get_view($name)) {
    if ($view->access($display_id)) {
      $output = $view->execute_display($display_id);
      // Before returning the block output, convert it to a renderable array
      // with contextual links.
      views_add_block_contextual_links($output, $view, $display_id);
      $view->destroy();
      return $output;
    }
    $view->destroy();
  }

You already understand the $name and $display_id. The output from this needs the render() function. You can put this in a function that is called in TEMPLATE_preprocess_node(), for example, and then use print render($embedded_view) in the node.tpl.php template.


On export Managed_files With Features No UUID Added

I end up creating module for handling assets exporting via Features either as custom field or not. Here is write up
http://margotskapacs.com/2014/04/handling-artifacts-for-custom-module-in-drupal/


If you go to admin/config/media/file-system what is your public path set as?

If your public path is set as sites/default/files then I think your code is generating the following link:

  http://yourdomain/sites/default/files/sites/all/themes/glossy/logo.png

Try changing your $img_url to the following

  $img_url = drupal_get_path('theme', 'glossy') . '/logo.png';

On another note, is the block rendering at all (just without the image)?  Your implementation of hook_block_view looks incorrect.

I think it should be more like the following:

/**
 * Implementation of hook_block_view().
 */
function glossy_helper_block_view($delta = '') {
  $block = array();

    switch ($delta) {
      case 'glossy_footer_sublogo':
              $img_url = 'public://sites/all/themes/glossy/logo.png';
              $style = 'footer_sublogo';

              $block['subject'] = ''
              $block['content'] = "",

              );
       break;
    }

  return $block
}

Edit

Change $img_url as I previously mentioned, but rewrite your block content as follows:

$block['content'] = '';

There aren't any quote marks around the image URL that is being returned by the function.


Looks like you have media installed twice. Once as part of your installation profile (or distribution) and once as a 'loose' module. Which I suppose occurred because there was a security update and you did not want to wait for the distribution to update.

Make a backup and remove /sites/all/modules/media. That should solve it.


How to change Title field label and description for Custom Content Entity

I managed to change the label using the following:

$form['name']['widget'][0]['value']['#title'] = $this->t('Artwork Title');

Hope this helps someone else.


Entity Tokens + Date Field + Custom Format... unable to use spaces

In this commit to Date module, token integration was removed, because field tokens aren't working yet.

The error you got it reproducible with an older copy of Date module, but doesn't seem to be related at all to Automatic Nodetitles, just Date/Token.

I would wait until the above Token issue and the Date issue Re-Add Field Token Support are committed.


When should I use behaviors? Can I attach them to any DOM node?

The attach function of all registered behaviors (all properties of the Drupal.behaviors object) will be invoked when behavior should be added to elements, either when the DOM is ready (ie. page load) and when elements are added to the DOM. The detach function will be called when behaviors should be detached from elements: just before elements are removed from the DOM, moved in the DOM or a form is submitted. The context parameter will always be a parent of the added/removed/moved/submitted elements, the single added/removed/moved/submitted element itself or the whole document element. The settings parameters will be the settings for the context, usually the Drupal.settings object as set by calls to drupal_add_js() from PHP. For detach, the trigger parameter will contains the kind of event that triggered the call: 'unload' (elements removed), 'move' (elements moved) or 'serialize' (form is being submitted).

The attach (and detach) functions of a behavior can be used multiple time over the same portion of the DOM tree. So the same element could be processed multiple time by the same code. It is up to the code itself to avoid processing (ie. binding event handlers, altering CSS styles, etc.) multiple times for the same elements. The easiest solution for this is to use the jQuery Once plugin (which is provided by Drupal 7) like this:

$(selector).once('behavior-name').doSomething();
$(selector).once('behavior-name', function(){ /*do something*/ });

Since a behavior is being attached/detached to/from a context, the context object can be used to restrict your jQuery queries to only the affected element or DOM subtree, like this:

$(selector, context).doSomething();

Putting all this together means the base pattern to process and add behaviors to elements on the page should looks like this:

(function($) {
  Drupal.behaviors.doSomething = {
    attach: function(context, settings) {
      $('div.something', context).once('do-something').doSomething({
        param1: settings.something.param,
        param2: 'something else'
      });
    }
  }
})(jQuery);

You can manipulate thhe Drupal.behaviors object tree, but be careful to avoid breaking other behaviors. I common usage is to use your behavior object (ie. Drupal.behaviors.myBehavior) to store information extracted from the elements during attach and consumed by event handlers.

If you write code that dynamically add or remove elements to the DOM, you should invoke Drupal.attachBehaviors or Drupal.detachBehavior on the (closet) parent element of the added/removed elements.


Add custom submission buttons to navigate through different wizard pages

I used another more durty way. I just hide pages which must be skipped

function my_module_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id)
{
  if (!isset($form['#webform_id']) || $form['#webform_id'] != 'my_form') {
    return;
  }

  $pages = &$form_state->get('pages');

  if (some_statement) {
    $pages['skipped_page_name']['#access'] = FALSE;
  }
}

but it works only in forward direction. And if user clicks "previous page" it may cause unexpected behaviour. So you also need "show" pages again on each step:

$pages = &$form_state->get('pages');
foreach ($pages as &$page) {
  $page['#access'] = TRUE;
}


Change the formatting of a label in Drupal 7

Something is odd about this as you say your labels are in lower case but they are being rendered in all caps.  I would view it with Firebug / Chrome Web Inspector to make sure there is not a higher level selector in your CSS that's transforming it to all caps in which case you would have a tough time going back to title case if your selector does not override the one thats making it all caps.

At any rate you can't transform all caps back to titlecase but you could with jQuery:

https://stackoverflow.com/questions/3471157/css-text-transform-capitalize-on-all-caps

Also see this for reference, http://www.w3.org/TR/CSS21/text.html#propdef-text-transform

"capitalize
Puts the first character of each word in uppercase; other characters are unaffected."

But before you go an add some JQuery, I would take a serious look at your CSS with Firebug to make absolute sure that something is not transforming it to all caps in the first place.


How can I use the core link field widget with title and URL in a custom form?

I think you have to create two seperate form fields to do this in Drupal 8.

You can use textfield for the title and url for the URL field, like this:

$form['cta_title'] = [
  '#type' => 'textfield',
  '#title' => t('CTA Title'),
];

$form['cta_url'] = [
  '#type' => 'url',
  '#title' => t('CTA Url'),
];

return $form;

Another solution is to pull the widget out from an entity display. There is a guide how to do that here, https://www.webomelette.com/how-render-entity-field-widgets-inside-custom-form-drupal-8.

Basically you load the entity display,

$entity = $this->entityTypeManager->getStorage('node')->create(['type' => 'article']);
$form_display = $this->entityTypeManager->getStorage('entity_form_display')->load('node.article.custom_form_display');

And then you pull out the widgets and add them to your form,

foreach ($form_display->getComponents() as $name => $component) {
  $widget = $form_display->getRenderer($name);
  if (!$widget) {
    continue;
  }

  $items = $entity->get($name);
  $items->filterEmptyItems();
  $form[$name] = $widget->form($items, $form, $form_state);
  $form[$name]['#access'] = $items->access('edit');
}


Whatever you are unhappy with, with Drupal's default robots.txt, delete it, and install RobotsTxt to provide an UI to let your SEO person edit the robots.txt according your needs.

  Use this module when you are running multiple Drupal sites from a
  single code base (multisite) and you need a different robots.txt file
  for each one. This module generates the robots.txt file dynamically
  and gives you the chance to edit it, on a per-site basis, from the web
  UI.

Look what I found. This duplicate issue on drupal.org robots.txt: add wildcarded paths for multilingual sites leads to this open issue Fix path matching in robots.txt, which actually could need your input.

But basically some commenters seem to recommend exactly what you came up with, wildcarding the path prefix.


How to include a custom menu in page.tpl

Try this

<?php
 $menu = menu_navigation_links('menu-your-custom-menu-name');
 print theme('links__menu_your_custom_menu_name', array('links' => $menu));
?>

You can also add to template.php

function THEME_preprocess_page(&$vars) {

$menu = menu_navigation_links('menu-your-custom-menu-name');

$vars['custom_menu'] = theme('links__menu_your_custom_menu_name', array('links' => $menu));

}

the variable $custom_menu is available in the page tpl


Is there a way to create custom page in panels with path "/search"?

If you have Search Module enabled, you should see built-in search node panel page.


Redirect to page after Simple News subscription

You do as follows:

  use Drupal\Core\Url;

function MODULENAME_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'FORM_ID') {
    foreach (array_keys($form['actions']) as $action) {
        if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
          $form['actions'][$action]['#submit'][] = '_redirect_submit';
        }
    }
  }
}
/**
 * Add redirect to user after subscription.
 */
 function _redirect_submit(array &$form, FormStateInterface $form_state) {
    //If you know route name you can do like this
    $form_state->setRedirect(ROUTE_NAME); // example as "user.admin_create" redirects to user create page
    // If you have path do like below.
    $destination = "INTERNAL_URL";
    $url = Url::fromUri('internal:' . $destination);
    $form_state->setRedirectUrl($url);
 }


You're using the wrong var name. In your preprocess function you're using $variables['image'] = $prod_image; to set the var. Whatever element name you use in the the $variables array will be the name of the var in the template. So in your case it should be:

<?php if($image):?>
    <?php print render($image);?>
<?php endif; ?>


Creating a view of child groups in Organic Groups

Answering my own question: it was as simple as adding the 'Content: Parent group' filter. For some reason I'd added a relationship I didn't need, which I was using on the filter. In fact you don't need any relationships at all. You can delete the 'OG membership: OG membership from Node' relationship from the default 'OG Extras Groups' view.


As far as I know, organic groups would work great for this. You can easily just hide links to the group frontpages.


SearchAPI Autocomplete - Pass in contextual filter to alter query

I ran into the same issue.
You could save your data in a session in hook_init or hook_boot.

/**
 * Implements hook_init().
 */
function hook_init() {
  $arg = arg();
  if (isset($arg[2]) && $arg[0] == 'taxonomy' && $arg[1] == 'term' && is_numeric($arg[2]) ) {
    $_SESSION['last_term'] = $arg[2];
  }
}


How to show a secondary vertical axis to the right of a chart when using charts module?

See the answer here: https://www.drupal.org/node/2208461 (Courtesy of Quicksketch)

It is now incorporated in the (brand new) Charts community documentation, within Use sub-charts to create dual-Y-axis charts, which details the 4 steps to create such charts.


Is there a way to create an openlayers map that adjusts size with an adaptive layout?

Oy. Okay. After poking around even more I found a much, much better solution, and now the whole question seems silly.

When setting up a map to display the data (in Administration >> Structure >> OpenLayers >> Maps), just set map width to "auto." Then it mods all on it's own. One display (block or page), and you don't even need to add any extra css to the container. It just responds. Somehow I completely forgot that auto width was an option when building the map. Super easy!


Auto approve an user after registration (Services)

Jose - Make sure you have "Require e-mail verification when a visitor creates an account" unchecked in your Drupal admin under /admin/config/people/accounts

Also, there seems to be a bug in the services module that doesn't set the password correctly if you send it through the REST service. If you apply this patch, you should be able to set the password and the user should be able to log in right away.

https://drupal.org/files/issues/user_create-2198005-1.patch


Notice: Undefined index: highlighted in include() (line 124 of page.tpl.php

If I am correct highlighted is a region name and you might have not defined it in you theme info file which is why it is throwing this error.

Give me more details of your info file and your page tpl file so that I can guide you in a better way.


One click download button for webform submissions

I have added a "Quick Download" button with my custom module.

Create a custom module.
Add this in the hook_menu in your .module file.

$items['node/%webform_menu/webform-results/quick-download'] = array(
    'title' => 'Quick Download',
    'page callback' => 'generic_webform_results_quick_download',
    'access callback' => 'webform_results_access',
    'page arguments' => array(1),
    'access arguments' => array(1),
    'file' => 'includes/webform.report.inc',
    'weight' => 7,
    'type' => MENU_LOCAL_TASK,
);

Create a file includes/webform.report.inc in your module folder and add the below function.

function generic_webform_results_quick_download ($node) {
    module_load_include('inc', 'webform', 'includes/webform.report');
    module_load_include('inc', 'webform', 'includes/webform.export');
    $export_info = webform_results_export($node, 'delimited', array('delimiter' => ','));
    $export_info['exporter'] = webform_export_create_handler($export_info['format'], $export_info['options']);
    webform_results_download($node, $export_info);
}

Clear CMS cache, go to the "Results" tab of the webform, you will see the "Quick Download" option. This downloads the data in CSV format.


Retrieving jsonp data with callback function

You can create a custom function called jsonp_decode with one argument to convert JSONP format to JSON format and return decoded JSON

function jsonp_decode($jsonp) {
  $jsonp = preg_replace('/^.*?\(/', "", $jsonp);
  $jsonp = preg_replace('/\);\s*$/', "", $jsonp);
  return drupal_json_decode($jsonp);
}

Then you can pull the "Name" from the result set as the following code:

$request = drupal_http_request('http://[local]/TemplateManager/GetRenderingStrategies?Wizard=false&callback=jsonCallback');

$names = array();

$items = jsonp_decode($request);

foreach($items as $item) {
  $names[] = $item['Name'];
}

var_dump($names);


Reloading a page from selecting a taxonomy term from a views filter

No need for contrib modules: it's all in Views.

So firstly you'll need to add a Filter criteria in your View.

Add
Select the term field (Topic in my case)
Configure extra settings: Dropdown
Configure filter criterion: Expose this filter to vistors

Secondly you'll need to enable AJAX submits.

Advanced > Other > Use AJAX > Yes

There are a couple of contrib modules that may be useful however.

Chosen for very long select lists
Better exposed filters if Select lists aren't good in your case


How does Drupal find contributed modules and themes?

Based on the error message you are getting, "failed to open dir: Permission denied in file_scan_directory()," I would assume that directory access settings are in fact not correct. The user running your webserver can apparently not open sites/all/modules. The best way to check this is to actually switch to the user running the webserver and try to open the directory. A common example would be a user named "apache" for the apache httpd.

On a Linux/OSX system one would often run the following command to accomplish this, though it could vary if your distribution already has a default shell for the user, or supplies a different one from bash. The example is from ubuntu, assuming you are using a normal user account with sudo privileges.

sudo su apache -s /bin/bash

How to do this in Windows I don't know, though I assume it's possible.


Is there a drush command to set permissions to true on ALL modules for administrator?

You need to look this Permissions API

$ drush help perm-grant
Grant permissions to a role.

Examples:
drush perm-grant --roles="Admin"          Grant all permissions provided by the Node module to the Admin role.
--modules="node"
drush perm-grant --all-modules            Grant all permissions to Admin role.
--roles-="Admin"
drush perm-grant --roles="Editor,Copy     Grant "administer nodes" to Editor and Copy Editor roles.
Editor" --permissions="administer nodes"
drush perm-grant --all-roles              Grant "administer nodes" permission to all roles.
--permissions="administer nodes"

Options:
--all-roles                               Grant the permissions to all defined roles.
--roles                                   Comma-separated list of roles to grant permissions to.
--permissions                             Comma-separated list of permissions to grant to a role or roles.
--modules                                 Comma-separated list of modules providing permissions to grant.
--all-modules                             Grant all defined permissions to a role or roles.

$ drush help perm-revoke
Revoke permissions from a role.

Examples:
drush perm-revoke --roles="Admin"         Revoke all permissions provided by the Node module from the Admin role.
--modules="node"
drush perm-revoke --all-modules           Revoke all permissions from the Admin role.
--roles-="Admin"
drush perm-revoke --roles="Editor,Copy    Revoke "administer nodes" from the Editor and Copy Editor roles.
Editor" --permissions="administer nodes"
drush perm-revoke --all-roles             Revoke "administer nodes" permission from all roles.
--permissions="administer nodes"
drush perm-revoke --reset                 Revoke all permissions from all roles.  Requires confirmation, use with
                                           caution.

Options:
--all-roles                               Revoke the permissions from all defined roles.
--roles                                   Comma-separated list of roles to revoke permissions from.
--permissions                             Comma-separated list of permissions to revoke from a role or roles.
--modules                                 Comma-separated list of modules providing permissions to revoke.
--all-modules                             Revoke all defined permissions from a role or roles.
--reset                                   Revoke all defined permissions from all roles.  Requires confirmation,
                                           use with caution.


How do I suggest broken link fixes to a Drupal module project page description?

Basically, you want to report documentation bug, because project page is maintained by module maintainers, and it's entry point to all other documentation.

You need to log in
Go to the module page
In the right sidebar, you will have section "Issues for [module name]"
Enter issue queue by clicking any link in this section, for example open bugs.
On the page "Issues for [module name]", click "Create a new issue"
Set the Component field to "Documentation" (unless maintainers defined better fitting component option for your purpose)
Fill all the rest as needed


Turns out you can apply something like so:

$qt_project['content']['content']['tabs']['tablinks']['backers']['#options']['html'] = TRUE;

thanks to comment on drupal forum

cheers


I suggest you clear you cache and if not getting worked  I suggest install image style flush module and flush all your image styles.

Easiest way to flush image styles in Drupal 7.

  Image style flush Overview

  This module will allow Drupal to flush all image styles at once or
  flush each image style individually right from administrative
  interface. Features

Flush all image styles
Flush each image style individually

  Known problems

Private file image styles can't be flushed with this module.


getting error when doing the composer install

I think the composer error messages are really opaque: Took me the whole day to figure this one out. And stil am not sure how to debug the composer related problems (and I have read all the drupal documentation, lots of composer documentation, so maybe I am just losing IQ points lately...)

Error 1: composer install

I had the same problem on composer install (Clive removed my earlier remark) and thought the culprit was

remove drupal/drupal No version set (parsed as 1.0.0)

Couldn't figure out why that would happen: Added all modules neatly with require bladiebla and had no problem updating core to 8.6.4

Site was running smoothly

Error 2: install module

Trying to install backup_migrate resulted in the error

The package is not available in a stable-enough version according to your minimum-stability setting

Which I also did not understand because my minimum stability was dev and the backup_migrate version was a stable one

Trying different things to find out where the problem originates did not bring any solution

composer install
composer update
composer diagnose
composer why
composer give me a break
etc

Is supposed that one of the modules I required conflicted with another one, but how to find out which one..... (any hints on how to debug these composer message are welcome)

SOLUTION (in my case)

In the end I simply did this

starting point

drupal 8.6.4

minimum stability dev

php 7.0.3

actions

remove core, modules/contrib, vendor, composer.lock
in composer.json:

2.1 start with (in my case)

    "drupal/core": "~8.6.0",
    "composer/installers": "^1.0.24",
    "wikimedia/composer-merge-plugin": "^1.4",

2.2 in the following require part require all advised highest version for all modules you use (so go to the drupal mordules site en copy the advised composer require statements)

   "drush/drush": "~9",
    "drupal/backup_migrate": " ^4.0",
    "drupal/backup_db": " ^1.1",
    "drupal/draggableviews": " ^1.0",
    "drupal/pathauto": " ^1.0",
    "drupal/token": " ^1.0",
    "drupal/anonymous_redirect": "^2.2",
    "drupal/ctools": " ^3.0",
    "drupal/calendar": " ^1.0",
    "drupal/geolocation": "^2.0",
    "drupal/views_taxonomy_term_name_depth": "6.x-dev",
    "drupal/views_templates": "^1.0",
    "drupal/paragraphs": " ^1.5",
    "drupal/devel": "^1.2",
    "drupal/webform": " ^5.0",
    "drupal/social_login": " ^2.83",
    "drupal/disqus": " ^1.0",
    "drupal/address": " ^1.4",
    "drupal/leaflet": " ^1.0",
    "drupal/geofield": "^1.0",
    "drupal/geophp": "^1.0",
    "drupal/geocoder": "^2.0",
    "drupal/geofield_map": "^2.20",
    "drupal/google_analytics": "^3.0",
    "drupal/video_embed_field": "^2.0",
    "drupal/better_exposed_filters": "^3.0",
    "drupal/addtoany": "^1.10",
    "drupal/typed_data": "^1.0",
    "drupal/rules": "^3.0",
    "drupal/honeypot": "^1.29",
    "drupal/field_group": " ^3.0"

run
composer install
go to your site and run www.domain.ext/update.php

That resolved my problem


Disclaimer screen when adding new content

One way to accomplish this would be to make a small custom module utilizing hook_form_alter().  Substitute "example" with your module name to implement.

example.module

/**
* Implementation of hook_form_alter()
* Add Disclaimer Message to Article Create Form
*/
function example_form_article_node_form_alter(&$form, $form_state) {
  if (arg(1) == 'add') {
    drupal_set_message('Legal Disclaimer: By filling out this form you are agreeing.','warning');
  }
}

example.info

name = "Example module"
description = "Adds a disclaimer to node/add/article page."
package = Example
core = 7.x

Or if you want a popup, you could instead use drupal_add_js and a little Javascript

example.module

/**
* Implementation of hook_form_alter()
* Add Popup Disclaimer to Article Create Form
*/
function example_form_article_node_form_alter(&$form, $form_state) {
  if (arg(1) == 'add') {
    drupal_add_js(drupal_get_path('module', 'example').'example.js');
  }
}

example.js

// if user agrees continue, else redirect
if (!window.confirm('Legal Disclaimer: Press OK if you agree.')) {
  window.location.href='http://example.com';
}

Of course this is all pretty simple and ugly.  One could combine both approaches and using CTools Modal or JQueryUI build a prettier dialog.  With JQueryUI you might do:

example.js

// if user agrees continue, else redirect using JQueryUI
// requires JQueryUI loaded (you can use [drupal_add_js()][5] for this too).
(function ($) {
  $(document).ready( function() {
    $("

Legal Disclaimer

Do you agree?

").dialog({
      resizable: false,
      height:140,
      modal: true,
      buttons: {
        "I Agree": function() {
          $( this ).dialog( "close" );
        },
        "No Way": function() {
          $( this ).dialog( "close" );
          window.location.href='http://example.com';
        }
      }
    });
  });
});


How to programmatically delete a display from a view

This is how you do it. It is how it is done in views_ui_edit_view_form_submit() when you delete a display via the admin UI:

unset($view->display[$display_name]);


Creating folders for images using Tokens module

Since Token does not yet have support for field tokens, I would choose a temporary convention that makes sense to you. Once that feature is added, you can use FieldField Paths to reorganize your files.


How should I link (public) files to nodes?

UPDATE: I missed the 8 tag

Drupal 8.x

UPDATE 2:

So this got trickier. The only way I was able to accomplish it was using these steps:

Add a field to the node, I called mine "Media"
Instead of selecting "File" from the dropdown list, I selected "Other" under reference, and "File" on the next page, this creates an entity reference field rather than a file field.
Add a file through file/add
In your node, start typing the filename of the file you've added
In the body field, enter this token: [node:field_media-formatted:0:entity_reference_entity_view:default]

The token inserts the rendered entity for the reference field into your content, you can edit how it looks (for images e.g.) through the display settings for file types (May require the File Entity module), so you can display a link rather than a rendered file.

Someone pointed out in a thread I saw a couple of months ago:

  Drupal 8 is stable with exactly 0 contributed modules installed

That said, moving to Drupal 8 with requirements that fall outside of the scope of core may be premature for someone who isn't prepared to develop their own solutions yet, and this particular solution may change since parts of it rely on contributed modules.

Hopefully this will be an appropriate answer in the future

Very similar to how it would be handled in Drupal 7, but because of module availability there are some tweaks. The modules you would need are Token, Token Filter, and File Entity Browser.

The steps are the same as below essentially, but I think the token may use the underscore instead of a dash: [node:field_files:0:url].

Also, once the Token module is installed you can see a list of tokens at admin/help/token.

Drupal 7.x

There are several mechanisms available to achieve this. If you are using a wysiwyg editor (such as CKEditor), they sometimes have plugins available to allow you to add files directly into the content, but based on what you've stated you need, I think possibly the Media, Token, and Token Insert modules would be a good place to start.

The media module provides a file browser and upload mechanism that works with the core Drupal file system, making it possible to reuse files easily in different pieces of content.

The Token module extends Drupal's core token mechanism, and the Token Insert module allows you to use tokens in text fields.

The basic steps would go something like this:

Install all 3 modules, make sure you have the core File module enabled.
Go to the "Manage Fields" page for the content type you plan to use these files in and add a "files" field.
Add the files that would be used in your article to the files field, either through uploading or using the file browser.
Reference the files by index in a token in the text field, a list of available tokens are available here.

This is untested so may require some tweaking, but if the machine name for your file field is "field_files", the link in the text area would probably look something like this:

Read More

That would print the link for the first file that is attached to the node.

There will, of course, be some configuration pages you will have to go through for the media module and field settings, but it's hard to give you any direction on those since they are all very much dependent on your particular installation.


Your code works fine for me so I'd check the following:

Make sure the module's installed and enabled.
Make sure the module is definitely named zillow (the module file should be called zillow.module, info file zillow.info, etc).
Make sure you've cleared Drupal's caches.

I realise these might be obvious solutions but as I say the code works for me so I can only guess your hooks are not being called for one of the reasons above.


Your link code worked for me when I tried it on a random page so it's hard to tell what could be wrong from the information you provided. Generally a better way for creating links in code would be the l function:

<?php print l(t('Add album'), 'node/add/review/' . arg(1)); ?>

Drupal will handle the use of admin overlay automatically if it's enabled. Another thing I noticed is that adding arg(1) for nid at the end of node creation pages serves no purpose generally. If it's used by a module or custom code for something then it's a different story though.


Assessing admin when site is not hosted in the root of the domain

Our solution was to create a virtual folder mysite and host the site as
www.mysite.com/mysite

After that the proxy was pointed to the new virtual folder.  This made the admin work correctly.

This is not a satisfying answer as it still leaves unanswered how to control the admin form urls


In Drupal 7 you can use the below code to get all the comments of a node using node ID

 $nid = 2;
 // you can get nid
 // $node = menu_get_object();
  //  $nid = $node->nid;
    $comments = db_select('comment')
              ->fields('comment', array('cid'))
              ->condition('nid', $nid, '=')
              ->execute()
              ->fetchAssoc();
    foreach($comments as $comment) {
        print your comments here
    }

Also you can check below links
https://api.drupal.org/api/drupal/includes%21common.inc/function/entity_load/7
https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_get_thread/7

In Drupal 6 you can use the comment_render() ;


Error while altering js file Undefined index: scope in drupal_get_js() (line 4309

Just got into this function too to alter "folder/js_file.js" and the issue causing the

  Notice: Undefined index: scope in drupal_get_js() (line 4309 of
  [DRUPAL_DIR]\includes\common.inc).

error is that there are times when the hook is called but "folder/js_file.js" is not yet in the array w/c just adds

[folder/js_file.js] => Array(
  [data] => [your_custom_js],
)

to the array but the scope, type, and other attributes are not there. So we first need to check if the array key exists like so:

if (isset($javascript['folder/js_file.js'])) {
  $file = drupal_get_path('module', 'mymodule') . '/your_custom_js.js';
  $javascript['folder/js_file.js']['data'] = $file;
}

That solves it. :)


Getting a true http address from file object's uri (Drupal 7

There's a nice in-built function, file_create_url():

  Creates a web-accessible URL for a stream to an external or local file.

e.g.

$url = file_create_url($file->uri);


Hook for csv export view - flag exported items

Views Data Export isn't transactional and so if you're looking for something, you'd likely need to wrap up Views Data export with your own code that loops over the results and sets the flag then.


Force nodes created by Feeds module to be published even if nodes are unpublished by default

Implement hook_nodeapi() for the 'presave' operation to set the node status to published if there is a new one created by Feeds:

function MODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op === 'presave' && empty($node->nid) && !empty($node->feeds_node_item)) {
    $node->status = 1;
  }
}


How do I display a taxonomy term if another term is active for a node?

It was actually quite easy! No custom-coding required. I just added the token for the other vocabulary to the URL alias pattern, and it now appears, when it's present. When not present, the regular URL is formed.

So now the new pattern is [node:field_post_category:entity]/[field_focus_area:entity]/[node:title]

Drupal is great!


The Page Cache and Dynamic Page Cache store complete pages, but Drupal also uses the Render Cache to store page fragments (e.g. the teaser display of each node).

To disable the render cache, set it to use the null backend as well:

$settings['cache']['bins']['render'] = 'cache.backend.null';