Does Boost work together with Google analytics? This may be a stupid question, but can the Google Analytic module still track users and count page visits etc. if I use Boost module to speed my site up?

Is there anything I should be aware of? Are there any settings I must do in robots.txt for example? (Other than the line Disallow: /boost_stats.php which should be entered according to the instructions).

I am not a Boost expert, but I know Google Analytics. Google Analytics is client-side JavaScript, so as long as your pages render the Analytics code along with everything else in the HTML, you should be fine. Boost should have nothing to do with it.


Is it possible to organize template files? As I've gotten more familiar with Drupal, I've been utilizing template files more and more. However, the naming conventions for template files make them difficult to organize. Is it possible to organize template files into different directories within the primary templates directory? I'm using Drupal 7.

If it isn't possible, are there alternative methods to organize template files?

Thanks!

Is it possible to organize template files into different directories within the primary templates directory?

Yes, absolutely. Drupal will recursively search the root and every subfolder in your theme for .tpl.php files.

Stick them in whatever structure suits you, Drupal will find them.


Retrieving menu item using REST I am looking for a way of getting menu items for a menu i.e(Main menu) via rest, enabling the Menu resource and trying /entity/menu/{menu}
gives me only dataset of the menu i.e

{
  "uuid": "57e695a4-2af8-43ac-9300-b989ecbb2d87",
  "langcode": "en",
  "status": true,
  "dependencies": [],
  "id": "main",
  "label": "Main navigation",
  "description": "Site section links",
  "locked": true
}

but I need the menu links associated to that menu too.
which is the most suitable approach ?

There is still no native way within Drupal core to expose config entities via REST. There are 2 contrib modules which claim to allow retrieving menu items via REST, neither of which I have used.

REST Menu Items

Allows you to specify maximum and minimum depth in the request.

REST Menu Tree

Returns the menu tree. Not yet covered by Drupal's security advisory policy.

Update 28 March 2017

REST Menu Items works as advertised but check the issue queue for any outstanding bugs. For example, currently the alias for a menu item isn't returned.


How can I display an entire page at a specific path/url in a block? I am using the HomeBox Module which outputs a page with a "Dashboard" like functionality. However I would like to be able to take this functionality from the page and turn it into a block, so that I could then add this functionality to any node/content type I would need.

What I have tried:

Nodes In Block, Node Blocks, Node As Block modules - these modules would do the trick if the page outputted by HomeBox was actually a proper node. In actual fact it cannot be edited as a node and so the additional options the above modules provide are not available in the page edit form.

Views module - when creating a View, I have tried filtering only by the url/path to show everything from the particular HomeBox page url. However this doesn't seem to be possible in Views. Since the page can't be tagged with taxonomy, isn't a content type, and (as far as I know) doesn't have a node id; by specifying the url and showing the page inside a View I could then make a block display and be done. But there doesn't seem to be general path/url filter in Views.

Does anyone have any suggestions as to what else I should try?

If you do something like this...

D6:

$foo=menu_execute_active_handler('path/to/the/homebox/page');

D7:

$foo=menu_execute_active_handler('path/to/the/homebox/page', FALSE);

...$foo should include either all of the html or a renderable array of the path/page content in question so in theory you could then stuff that in a block, either via a custom module or (ick) using the standard block interface and the (double ick) php input filter.

MORE THOUGHTS:

My basic thought above was to try to get to the menu handler for the page/path in question with as little custom code as possible.  But, if you look in the HomeBox module, all it is doing for each page/path is calling homebox_build() along with a page argument that is easily crafted up.  So, if you are comfortable with coding, you could write a custom module that uses that function within its block hooks to create the content.

Also, not sure about any css/js that would be needed but that could be hand crafted I suppose if necessary.


Taxonomy exposed filter I am working with Drupal 7.
How do I limit a taxonomy drop-down exposed filter to only display the terms used by nodes in view results?

I understand that the list is populated before the views takes place, but this means that I am often left with tags that display nothing ( since they are hidden with my view).

Views Hacks does this with Views Selective Exposed Filters:

  Views Selective Exposed Filters

  On list and checkbox exposed filters, you can specify the filter
  option "Limit list to result set" to only display values that are
  actually returned in the view's results. The filter option "Further
  limit list to active filters" restricts the displayed values to view
  results obtained by applying exposed filter values.


Is it possible to wrap the fields of a view inside a  and ? UPDATE: Colin is right but I'd like to go over what I did to accomplish this.
I added a views-view.tpl.php template and where it said

<?php print $rows; ?>

I wrapped it like this

    <?php print $rows; ?>

I also wanted to prevent each row from being wrapped in a view so I also added a views-view-unformatted.tpl.php template and replaced

<div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>

with just

<?php print $row; ?>

I'm trying to have a view that starts with a

then contains all the content of my view like so

image

image

image

and then ends with

However I'm having a lot of trouble. Header and footer does not work because it starts and closes it in it's own div. I tried hiding all the contents and doing a global text field like so

[image]

However that gives each item it's own nav and closes it right after each one.

Is wrapping the entire comments in the  and  tags possible in drupal?

You will need to add a View template to your theme, take a look at Views template files to give you an idea of how to accomplish this


How to use panels for embeded nodes? I use Inline Entity Form to embed nodes within nodes.*

When editing these nodes, the embedded nodes appear as one block within Panels, so I cannot re-arrange the fields inside the embedded nodes:

I would like to split out the nodes into separate panes. I would also like to be able to re-arrange the fields in each embedded node using Panels drag-and-drop interface, as in this mock up:

How can I achieve this?

Mini Panels lets you get the first child node only.
Views Context gets all the embedded nodes. However, it will lump similar fields together. (e.g. all the image fields will be displayed in one pane).

*(Embedding nodes within  nodes is useful as each separate node can hold a group of fields. The effect is similar to Field Collection, but there are extra advantages such as being able to share content between nodes).

Try using user568458's solution, but instead of displaying fields in the view, display a "fully rendered node" and set the view mode to a custom view mode.

To customize a view mode, and then configure the layout of a custom view mode, use Display Suite module.

See this about view modes.

If you activate Display Suite's sub module Panel View modes, you can then use the Panels module interface, instead of Display Suite for layouts.

EDIT
I just went to do this myself and discovered that this feature has disappeared in the latest version of Display Suite!

Bummer :(

However, you can still utilize Display Suite to a lesser degree... Sorry


Drupal 7: notify user module recommendation I'm trying to figure out what the best solution to a project requirement is. The basic premise is that a site needs to have a notify user feature - similar to how Facebook works.

A listing in the site will appear showing the number of notifications (similar to this site actually, on the top left).  A sample notification would be: another user commented on your node.

Another possible notification would be "a node was created in a subscribed taxonomy term".

I've been looking at the Notifications  module,  but I'm not convinced it can do what I need it to do.

Has anyone ever built a solution to this problem?  Or am I looking at a lot of custom work?

For the record: The Notifications module will not do what you want.  But worse, the D7 port is in alpha and hasn't progressed since 2011-Dec-04, there are 217 bugs in the issue queue and no maintainer in sight. Its maintenance status is listed as "Seeking new maintainer".  In other words, this yet another abandoned Drupal module. Unless you're prepared to adapt and maintain this yourself - stay away.

There is a survey page for notifications modules, but it only confirms that what is called a "Notification" module by Drupal developers provides email notification, which is not what you want.  The type of notofication you want tend to be referred to as "flags" by Drupal developers, so you want to search for "flags" in addition to "notifications".

To get on-screen Javascript notifications (similar to Facebook and Stack Exchange), my suggestion for a starting point is to see whether you can combine the Flag module, the Message module and the Rules module to do what you want.  But to get these three modules combined to produce the desired effect will not be trivial.

An alternative solution (first mentioned in a comment by Nigel Waters), you could use the Message module to create the activity stream. Then use Views to generate the stream applicable to the currenly logged in user. And finally use the Menu Badges module to display the number of notifications.

You may also want to read: How to create a basic message - notifications system displaying a real time message counter badge?


Subdomain with shared database for users: subdomain not accessing primary database I've successfully set up a multisite Drupal installation. I now have:

www.example.com --> main site
sub.example.com --> a secondary site

However, I want the users to be shared. I know about shared databases and prefixes, but according to the comments in the settings.php, you can also use the prefixes to access a different database. I'd like to choose that root.

So my main site goes to the primary database, the subdomain goes to the secondary database, except for the users.

This is relevant section of the settings.php of my subdomain:

$databases = array (
    'default' =>
        array (
            'default' =>
                array (
                    'database' => 'secondary_database',
                    'username' => 'username',
                    'password' => 'password',
                    'host' => 'localhost',
                    'port' => '',
                    'driver' => 'mysql',
                    'prefix' => array(
                        'default'   => '',
                        'users'     => 'primary_database.',
                        'sessions'  => 'primary_database.',
                        'role'      => 'primary_database.',
                        'authmap'   => 'primary_database.',
                        ),
                ),
        ),
);

My primary database already has many users, but when I log into my secondary site, I only see my admin user. Also, I cannot log in to my subdomain with any user of my primary database.

So my conclusion is that the subdomain is still using its own database.

Both databases are on the same server and I've given the username/password for the secondary database access to the primary database.

There are also no errors in the log.

Any suggestions on what I'm missing?

I would advise to look into the answers of this question. One solution is indeed a specific setup in settings.php, however all your sites need to make use of the same database when using that option. E.g.:

$databases['default']['default'] = array(
  'driver' => '[Your database engine]',
  'database' => '[Your database name]',
  'username' => '[Your username for the access to the database engine]',
  'password' => '[The password for the access to the database]',
  'host' => 'localhost',
  'prefix' => array(
    'default'   => 'main_',
    'users'     => 'shared_',
    'sessions'  => 'shared_',
    'role'      => 'shared_',
    'authmap'   => 'shared_',
  ),
  'collation' => 'utf8_general_ci',
);

The solution above uses the same database for all sites, but different table prefixes. So in the example above most tables will be prefixed with "main_", but the users, sessions, role and authmap tables will be prefixed with "shared_". For your additional sites, you will use a different prefix for 'default' (maybe 'site2_', 'site_3', etc.) but the same 'shared_' prefix.

(all credits to zdecibel & Dalin for the example & explanation above)

Another option is using the Domain Access module, which is developed for this kind of purposes.


How to design a page created using Views I have created a page with help of the Views module, and it is perfectly doing the job.
I need to design the page on my own.

How can I do this?

The easiest way to style a page generated by views is to simply edit the CSS.

If you need more control over the markup generated you can use Semantic Views to clean up and improve the generated HTML.

Another simple solution is to manually add a template: there's a "Theme" section in the Views UI (just above where you set the Path and Menu Item). There you can select the best template to use (views-view--YOURVIEWNAME--page-1.tpl.php or something similar) and copy & paste the default template code.

Then, create a file with the same name in your Templates directory (views-view--YOURVIEWNAME--page-1.tpl.php or something similar) and past the code there.  You can now edit the template as if it were any other!

If it isn't getting recognized by the View, don't forget to go back to the "Theme" section in Views UI and click "Rescan template files" to make sure it's found!


How to use Rules' "set data value" with image fields? I would like to be able to create an entity using Rules, and then populate the image field of the entity with an image file using "set data value".

When populating text fields using "set data value" it is quite straight forward since you can either use tokens or input any text you desire. The trouble is, how do you reference the image that has been uploaded to the server? There is no appropriate token available for it.

What is the best way to achieve this?

I do something similar on my site; though the solution will vary according to where you are getting the image file from.

On my site, I first use a "Download a file from the internet" action to fetch and save the image file I want.  When you are setting up this action, be sure to scroll all the way to the last fieldSet on the page - Provided variables - and make a note of the machine name there(or change it to something more memorable)

Next add a "Set a data value" action, and use the machine name from above as the Value.

[edit] I have just realised - while looking down my module list - that the "Download a file from the internet" Rules action is provided by a module, here is a link:- https://www.drupal.org/project/rules_download


How to get the field settings in drupal 7 Here is the scenario.

I have a taxonomy term reference field, which is referenced to a taxonomy vocabulary, for example it is associated with category vocabulary. Now I need to fetch the vid of the category vocabulary which is associated to that particular field.

or is there a way to fetch the field settings in drupal 7?

You can use a combination of field API and taxonomy API functions to get this info:

$field_name = 'field_FIELD_NAME';

// Get the field info
$info = field_info_field($field_name);

// The link to the vocab is stored as it's machine name
$vocab_machine_name = $info['settings']['allowed_values'][0]['vocabulary'];

// Load the vocab by machine name
$vocab = taxonomy_vocabulary_machine_name_load($vocab_machine_name);

// Finally, get the vid
$vid = $vocab->vid;


Tag to show Related Content Type and Term I have Content A and Content B
Both share the same taxonomy tags i.e interests i.e football, sport, tennis

When someone clicks on tag
i,e term "sport"

I want it to show
All Content A with "sport" Terms tags

Not All Content A and B with Sport Terms tags

How can I do this please?

Many Thanks for your help

You could create two separate vocabularies each with the same terms in it, then make one vocabulary available to content A and the other vocabulary available to content B.

An alternative is to use views: https://drupal.org/project/views

With Views you can list items of a Content type with certain tags associated with it on a page.

E.g. I have two content types News & events both are categorized by term group. I only want display all News items so I use Views to only show content type News.


How to check if a scheduled Rules action set has already been scheduled? I'm using the Rules Scheduler (sub-module of the Rules module) to schedule an email reminder based on a date field set in the content type. So a user can request a reminder email on a specific date, to update that content.

However, if I invoke the Rules Action on node update, then I end up with lots of emails scheduled for that date.

How can I make sure that the rule is only scheduled once for the given date?

The answer to this is simple.

In the action of the rule that calls the schedule component evaluation, in the Identifier section, set a unique value, such as:
reminder-[node:title]-[node:nid]

This value will be a unique identifier of the scheduled task. Scheduled tasks with the same ID will simply be replaced. Problem solved.


Zurb vs. Bootstrap themes: About performance I'm trying to decide to use Foundation or Bootstrap as a base theme for a redesign, but even if Foundation have a lot of strengths (native sass support as I've read), it seems that it is waaay bigger than Bootstrap.

Zurb compressed file is about 585.16 KB while Bootstrap is 103.27 KB.

Bootstrap is being used by way more people, but that doesn't necessarily mean that it's better. Any insight about their performance?

I've read several articles about their performance, but none about their "Drupal versions" of each theme.

So, my question is: Does a much, much bigger base theme impacts into performance?

It seems that it does, but I've read somewhere that Bootstrap and Foundation are almost equal in terms of performance. How can that be?

The Drupal Bootstrap is just a wrapper for the Bootstrap Framework. When you download that, the compressed size increases by about 200 Kb.  However, I don't think size is a good metric for theme performance.

Foundation has a very limited number of UI elements, it just gives you the foundation to build your own theme upon. Bootstrap provides almost every UI element you can think of. If you want to design your own CSS carefully, to give your site a personal design, go with Foundation.  If you just want to do rapid prototyping or to have  a responsive site up quickly and with little effort, go with Bootstrap.

As for performance, I haven't spotted any clear differences between these in the context of Drupal. Btw.: I don't think the Drupal versions should differ from those on other platforms, as most of the code is the same for all platforms. The Drupal versions are just wrapped to fit into Drupal's theme system.


Listing all terms of a taxonomy in twig template How can I list all terms of a particular taxonomy in a twig template?

Build a view for the list of taxonomy terms and use the module Twig tweak:

<dd>{{ drupal_view('view_name', 'page_1') }}</dd>


Achievement Popup notification doesnt appear on cache page I am using achievement module on site , it shows a popup notification when a particular achievement is reached . However due to caching (Authcache for authenticated user) , the popup doesn't appear .

The only way I could thought of is to prevent the site from grabbing the cached page ( from cache_page) when the criteria for showing pop is satisfied .

Any pointers on how can it be done ?

Thanks ,
Murali

There is custom module which triggers the pop up :

   function geld_achievements_pks_response($user_id) {

   $current_count = achievements_storage_get('forum-node-count', $user_id) +      5;
   achievements_storage_set('forum-node-count', $current_count, $user_id);

   if ($current_count == 25) {
       achievements_unlocked('Level 1', $user_id);
       }

Thanks everyone for helping on this issue . I finally got it working by a small hack . Authcache does'nt render page from cache if there are outstanding drupal messages . so when the condition for popup is met i , put drupal_set_message('!', warning) . The next page is avoided from cache to display the drupal message ( which I hide by css ) and the pop up . subsequently on clearance of messages the autcache begins fetching cache until the next condition of pop up is met .


Matrix pricing structure for ubercart? We sell hosting and domain name registrations. My problem is with the hosting where you have, for example: "Shared Hosting" with Package A and Package B. Prices are as follows:

|           | Package A | Package B
| 3 months  | 5 USD     | 15USD
| 6 months  | 8 USD     | 20USD
| 12 months | 14 USD    | 30USD

Now, I can add two attributes, one for "package type" and another for "period". So you can choose, for example, package A for 6 months. The problem is, ubercart doesnt quite work like that. It would ADD an amount, depending on what you choose, when I need fixed pricing for a specific combination. Woocommerce does this beautifully.

How do I do it with Ubercart and Drupal 7?

If I'm understanding correctly, I'd recommend doing "Shared Hosting - Package A" as one product, and "Shared Hosting - Package B" as another, rather than a single product called "Shared Hosting" that has two attributes. (You can add the time period as a single attribute to each product.)

You can still style the matrix as you have done above (on a pricing page) and include links to purchase at the bottom of the column for each package.


Calling form validation function from new button I've attached a Process button on the node edit form. But on clicking it - in it's validation function form_set_error is not working.

In my form_alter I've this code:

$form['buttons']['process'] = array(
            '#type' => 'submit',
            '#value' => 'Process',
            '#validate' => array('disavow_process_validate'),
        );

        $form['#validate'][] = 'disavow_validate';

So on pressing "Process" button validator function disavow_process_validate is called with $form and &$form_state. But form_set_error and assigning values in the $form_state are not working as working in the normal validation function disavow_validate

What could be the problem?

See below example which works perfectly...

function drup_custom_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == "page_node_form" && arg(2) == "edit") {
    $form['buttons']['process'] = array(
            '#type' => 'submit',
            '#value' => 'Process',
            '#validate' => array('disavow_process_validate'),
    );
  }
}

function disavow_process_validate($form, &$form_state) {
  form_set_error('title', 'Something wrong here !');
}

Please update what you are trying to do inside validate function..


Dynamic Page Cache not working for my controller? I have a module that defines route /x and assigns it the controller ViewNodes::show. This takes no parameters and the show method simply returns a nearly blank render array:

[
'#theme' => 'view_nodes',
'#cache' => ['tags' => ['node_list'], 'max-age' => Cache::PERMANENT, 'bin' => 'render'],
'#pre_render' => [[$this, 'buildNodeListView']]
];

The buildNodeListView then takes care of doing all the expensive logic and SQL queries to build the array. This all works fine and the page displays as expected, but devel's WebProfiler shows the SQL queries for building the render array are still being executed even when they should have been cached. This suggests buildNodeListView is always being called, which means #pre_render is always being called, which means the render array is always a miss. Am I mistaken here?

The route shows up under "bin dynamic_page_cache" and is always marked as MISS. And in the HTTP headers, there's always X-DRUPAL-DYNAMIC-CACHE: UNCACHEABLE

Is there something I'm doing wrong, or things I should check to further debug this? My settings.local.php has

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

and

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

They're both commented out so the caching should be enabled. The Dynamic Page Cache module is also enabled. And my routes do not have the "no_cache" option.

You need cache keys

'#cache' => ['keys' => ['key1', 'key2', ...], ...]

and this is not the dynamic page cache, it is the standard render cache which will take care of this.


How can I invoke a drush hook on a remote alias? I have a local dev environment and a test server environment.  Both are running the exact same code.

In a custom module, I added a drush hook to extend the sql_sanitize command in order to ensure all private user data is removed from the development database.

From a directory within my local environment, I can invoke drush like this:

  drush sql-sanitize

And my custom drush hook is run properly.

However, when I invoke drush from the same location but targeting my remote server environment (Pantheon, if it matters, and I checked their documentation, but didn't see any relevant notes):

  drush @mytestserver sql-sanitize

sql-sanitize resolves, but the custom drush hook is not called, even though the module containing the hook is enabled locally and on the test server.

I tried invoking the command from a directory outside my local dev environment, but again sql-sanitize resolved without the custom drush hook being called.

How can I execute the drush hook in a remote environment from my local machine?

I have tried both Drush 5.9 and 6.4.0.

If I understood correctly, we had a similar problem with drush < 6.4, drush was not passing the alias to the remote server if root and uri where not specified.

One way to solve it is to define $conf['root'] and $conf['uri'] in your local alias, the other is to use drush 7.


Moving data from a Drupal 6 site to a new Drupal 7 site This is not an drupal 6 to 7 upgrade question, at least not in the way it's conventionally asked or done. I have an ill pressflow 6.17 site with loads of not necessary modules, configurations, etc, which I need to convert to Drupal 7 (Pressflow 7 doesn't seem to be round the corner as work on Drupal 8 has just started) so this will be a new site with its own set of modules and configurations but with the same data as the old site. I don't want anything from the Pressflow site to creep into the Drupal 7 site except for content; I don't want the views, imagecache presets, etc. I am looking to get advice on just moving the data (content) from Pressflow to Drupal 7 site; therefore, the usual upgrade process will not work for me.

I have used the migrate module before for an ASP to Drupal migration and it works great, but it's also kind of messy with source tables residing in the same database, and since task at hand is to move data from one Drupal version to another I am hoping for a much simpler/quicker technique.

What would be the best/quickest way to move content and only content (including ratings, comments) from Drupal/Pressflow 6 to Drupal 7 site (except migrate and table wizard, not that they don't fit the bill).

[UPDATE] - I am currently investigating nate's approach when he migrated his site from drupal 5 to 7. It might work for me; I will update.

I think the approach you are looking at is good. You may need to reconsider your requirements slightly.

Move content but not upgrade.
Move some content which is provided by modules (which need to be upgraded).
Move content which is provided by modules but not the modules themselves.
Not use Migrate or table wizard.
Do so in the best way.
Do so in the quickest way.

I think many of these requirements are mutually exclusive.

The best approach I can see, is to clone your existing site. Turn off everything you don't want in the D7 site. Then consider your upgrade options.

A Drupal install is a complex interaction of code configuration and content. it is difficult to completely consider one without the others.

update

You could look at migrate Drupal 2 Drupal for migrating your content.


how to extract values of field collection using Entityfieldquery? I have created a content type 'customer' in which I have a field collection named 'field_group'. The field collection has 2 fields namely:

  Title
  Name

The Customer content type and group field collection are of entity type 'node' and the 2 fields in the group are of entity type 'field_collection_item'. I want to query the database to get the values of the fields in the group for this particular content type. I used to following query to get the field values of the group.

    $query = new EntityFieldQuery();

    $query->entityCondition('entity_type', 'field_collection_item')
          ->entityCondition('bundle', 'field_group');

    $result = $query->execute();

$nodes = entity_load('field_collection_item', array_keys($result['field_collection_item']));

But the above entityfieldquery retrieves all the values of entity type field_collection_item. But I want only the values of content type 'customers'. Can anyone tell me what's wrong with the above query?

An EntityFieldQuery can only refer to one type of entity, it cannot represent any relationships between entities. If the entity_type in your query is a field_collection_item, then that's the type of entity that the query will return. The EntityFieldQuery has no concept of the fact that your field collections are related to nodes, or anything else for that matter.

To get the entities related to the field collections you'll have to run another EntityFieldQuery. I haven't used field collection before but I would guess the logic would look something like this:

$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'customer')
  ->fieldCondition('field_name_of_collection_field', 'name_of_field_collection_column', array_keys($result['field_collection_item']));

There are things that need to be changed in that code (the name of your field collection field, the column name for the field collection relationship) but it should get you started.

Actual example of the two-query approach:

function get_species_country($id_country) {
    $inner = new EntityFieldQuery();
    $inner_r = $inner->entityCondition('entity_type', 'field_collection_item')
                     ->fieldCondition('field_species_country', 'target_id', $id_country, '=')
                     ->execute();
    if(!empty($inner_r['field_collection_item'])) {
        $keys = array_keys($inner_r['field_collection_item']);
        $query = new EntityFieldQuery();
        $species_r = $query->entityCondition('entity_type', 'node')
                      ->entityCondition('bundle', self::$bundle)
                      ->fieldCondition('field_species_countries', 'value', $keys)
                      ->execute();
        if(!empty($species_r['node'])) {
            $ret = node_load_multiple(array_keys($species_r['node']));
        }
    }
    return $ret;
}

In the example above:

field_species_countries - Name of the field collection
field_species_country - Actual field inside the field collection

Limitations: I think this has some limitations because the second query contains ... WHERE field IN (1, 2, 3 ...). For MySQL this is limited by max_allowed_packet


How to check the remaining capacity for an event when using the Registration module? I am trying to create a Rule (using the Rules module) that fires off an email when the capacity of registrations for an event get full. We have set this up using the Registration module.

I set this rule up like so:

Event = Upon new registration.
Condition: Data comparison - registration:count.
Action = email author.

In the manage registrations tab the registration-count is always 1 for each user. So I wonder how I can check the capacity for the event to trigger the email.

I have tried to search for information and try many scenarios, however not finding one that works.

I would like some idea(s) or path to a solution I am not thinking of.

The Rules module is a very flexible framework and it has a comprehensive api. While you may be able to accomplish your task using just the UI you may find it easier implement one or couple of hooks to alter your existing condition, or perhaps, add a new condition to be used. For example,

/**
 * Implementation of hook_rules_condition_info().
 * @ingroup rules
 */
function yourmodule_rules_condition_info() {
  return array(
    'yourmodule_condition_example' => array(
      'label' => t('Compare two users'),
      'arguments' => array(
        'user1' => array('type' => 'user', 'label' => t('First user to compare')),
        'user2' => array('type' => 'user', 'label' => t('Second user to compare'))
      ),
      'module' => 'user',
    ),
  );
}

If you decide to go this way, you may want to check https://drupal.org/node/298533


How do I re-arrange the $node->taxonomy array back into a hierarchical tree? In a node I'm creating, there is a hierarchical select widget. The widget saves the 'deepest' term in a given taxonomy.

These terms come out in the $node->taxonomy array in tpl files.

I want to build the tree right back up to the last parent. How do I do this? What is the algorithm? I have a complete sphagetti mess that's not even worth posting here, right now. I have a feeling there's recursion involved somewhere, but I'm missing the specifics - pseudocode please?

I don't know of an API function that can do this but the following code should help:

$tid = 4; // Your term id

// Grab all of the parents of this term (including the term itself)
// in reverse order.
$parents = array_reverse(taxonomy_get_parents_all($tid));

$tree = array();

// Get a reference to the root of the array. This reference will be updated
// in each iteration of the loop to refer to the array of children added to
// the term.
$ref = &$tree;
foreach ($parents as $term) {
  // Add the current term to the relevant root/children array.
  $ref[$term->tid] = $term;

  // If the current term is NOT the original child term, we add an array of
  // children to the term and update the array reference to point to it.
  if ($term->tid != $tid) {
    $term->children = array();
    $ref = &$term->children;
  }
}

By the time that loop has run the $tree variable will be a hierarchical representation of the original term's parents, with each child term in the children key of it's parent term object.

I've only tested this on terms that have a single parent; if you've got terms with multiple parents I think you'll struggle to get this to work.


What hook to use changing image field description I wonder how I can alter the description of the custom image field. I can't use hook_form_alter. I couldn't find the variable. Please advise. Thanks!

e.g

The alternate text field is added by image_field_widget_process(), which is the process element function added by image_field_widget_form() (an implementation of hook_field_widget_form()). To alter it, you can add your element process function with hook_field_widget_form_alter().

function mymodule_field_widget_form_alter(&$element, &$form_state, $context) {
  if ($context['field']['type'] == 'image' && $context['instance']['widget']['type'] == 'image_image' && !empty($context['instance']['settings']['alt_field'])) {
    foreach (element_children($element) as $delta) {
      $element[$delta]['#process'][] = 'mymodule_field_widget_process';
    }
  }
}

function mymodule_field_widget_process($element, &$form_state, $form) {
  // Verify the element is accessible to the currently logged-in user.
  // Differently, it will not be visible to the user, and it is useless to alter the description, or the title.
  if ($element['alt']['#access']) {
    // Use $element['alt']['#title'] for the title.
    // Use $element['alt']['#description'] for the description.
  }

  return $element;
}

The reason I would use hook_field_widget_form_alter() instead of hook_form_alter() is that the first has direct access to some information the latter doesn't get, such as the settings for the field instance, and the field settings. In this case, I can access $context['instance']['settings']['alt_field'] to check if the field requires the alternate text field.

If you are going to use hook_form_alter(), remember that:

A field could have more than one widget, if the user is allowed to enter multiple values.
When its #access property is set to FALSE, a form element is not accessible to the currently logged-in user; in that case, it is useless to change any other properties for the form element, as it will not be shown to the user.


How to popup a dialog when a checkbox is unchecked on webform? I have a checkbox in Webform. By default, the checkbox is selected. I'd like to popup a message dialogbox if the user uncheck the checkbox. How can that be done in Webform?

$('#checkbox-id').click(function(){
  if(!$(this).is(':checked')){
    alert('You unchecked the checkbox');
  }
});


How can I change Menus depending upon domains (url name)? I want to change main menu items depending upon domain and sub domains url in a single site.

I could have done it easily with roles, but issue w.r.t anonymous users. How would I show or not certain items in the main menu?

This is how I would do it:

Create a main menu per site
Create a context condition plugin for domain names
Create a context per domain
Create a context per site and place the menu block in the navigation region for each context

Profit

If you need to put the same links in multiple menus, check out the multiple node menu module.


Conditionally run a view if another view has no results I have a client who has an Upcoming Events view. However, when there are no upcoming events, he wants to show another view (Past Three Events) which shows the past 3 events. Basically he doesn't like it when the page doesn't show any events so he wants to show something.

I thought of attaching another block of the Past Three Events to the bottom of the main view (Upcoming Events) and then using jQuery to hide it if the main view (Upcoming Events) is populated.

But I was hoping that someone knows a more elegant solution where perhaps either I can conditionally run a view (perhaps using EFQ which I know nothing about) or somehow adjust views to combine 2 queries in one.

When editing the view, under Advanced > No results behavior select Global: View area. Select the view you wish to show if the first has no result, and check if you want the replacement view to inherit the contextual filters of the first.


Can I run bulk update for URL aliases at command line? I have over 30,000 nodes, and bulk update is painfully slow. Is there another way to run this?

You can also use Drush for the bulk update, see this article.


How do I get at the raw file name of a File entity in a Twig field override? This is my first effort at Twig development so please bear with me. I have a vanilla Drupal 8.1 site with a content type that contains just the body and a File type field called field_fichier_svg. This will contain SVG files (surprise!) and I want to override the Twig field rendering so that I can get the raw file name and wrap an "img" HTML tag around it.

I have successfully installed kint, and have overridden the field template with one called field--node--field-fichier-svg--icon.html.twig (the field is used in a content type called "icon") and this works.

I have also succeeded in running kint() and getting the output.

But none of the attempts I have made at getting the value of the field function. In the snippets below you can see the three different attempts I have made.

1) Try to identify the class that handles file entities and use that:

{%
  set classes = [
    'file'
  ]
%}

2 & 3) Loop round "items" and try different things which I have tried to interpret from the kint output (kint does work by the way)

{% for item in items %}

  {{kint(item.content)}}
{% endfor %}

In all cases the "src" attribute is just blank.

To make it a bit more manageable I tried putting

{{dump(item.content|keys)}}

and I get this:

array(5) { [0]=> string(6) "#theme" [1]=> string(5) "#file" [2]=> string(12) "#description" [3]=> string(6) "#cache" [4]=> string(11) "#attributes" }

Then I tried

{{dump(item.content['#file']|keys)}}

and I get this:

array(11) { [0]=> string(3) "fid" [1]=> string(4) "uuid" [2]=> string(8) "langcode" [3]=> string(3) "uid" [4]=> string(8) "filename" [5]=> string(3) "uri" [6]=> string(8) "filemime" [7]=> string(8) "filesize" [8]=> string(6) "status" [9]=> string(7) "created" [10]=> string(7) "changed" }

but if I try

 {{item.content['#file']['filename']}}

I just get nothing

to get the filename you can use this:

{{ item.content['#file'].filename.value }}


ubercart 2 views - filter by order total weight I use Ubercart 2 with Ubercart Views. I'd like to filter orders based on total weight.

It's possible to add total weight as a field, however it is not possible to add this field as a filter. I tried Views PHP Filter using $row->weight but this filter is not picked up (it filters $row->title ok). How can I filter by total weight?

My solution was to add custom php filter and add:

$ord_weight = db_result(db_query("SELECT SUM(qty * weight) FROM {uc_order_products} WHERE order_id = '$row->order_id'"));


Changing which content appears at which parts of site I would like to make different divs in the template, that show up at different parts of a site: eg. div#1 shows at pages from Menu-01 + it's sub-menus; div#2 shows up at pages from Menu-02 + its' sub-menus, div#3 at Blog pages, and so on.

How can this be achieved? Coming from the Wordpress world it is something like

<?php
if ( is_category ('1') ) {
//something for category 1
}
if (is_page ('6') ){
 // something for page 6
}
// other functions for descendant checks possible with custom made checkers in functions.php
?>

In Drupal I only found the front page check

drupal_is_front_page()

But I've found no other types of checkings with this method.

Any help please?
Thanks.

There is many ways to do this:
- you might use the arg() values and act based on that

        if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'YOUR-CONTENT-TYPE') {
               // do something
         }

or you can use template_preprocess_node function in your theme, and act based on the node values.


Symfony2 authentication I am currently developing a website using the framework Symfony2. I am nearly at the end of its development, and just the "security" part is missing (authentication and authorization). What I would like is to use Symfony2 core bundle to authorize the user but I want to use my Drupal database to get the authentication of the user.

I have previously used the module Services 3 with a REST server to get the user information and to authorize him/she to go on my website (which was flat php coded). Now, I want to make something robust and secure, so here my question, do you know a method for getting the authentication from the Drupal website and then authorize the user via Symfony core bundle?

Here are my 2 thoughts about it:

-> Fetch the user data ($username & $password) using the REST server and a query made in my custom UserProvider (Symfony Doc) and then leave Symfony makes the authentication using the Drupal's password encoder. But here the problem is that when you fetch the user data using the REST server, you get everything but the password.

-> Get access to the Drupal database using Doctrine as usual in my application and fetch the user & pass from it. Then use the Drupal's password encoder to check this result.

To conclude, I am really far to be an expert on this kind of stuff, so I would really appreciate your help.

You can use a custom User Provider in Symonfy and then use the Service Module from Drupal to login via a REST interface


Image gallery where I can insert images and video I'm new to Drupal and is looking for at image gallery, where I can insert images and video, does such exist?

I have tried to search around, but unfortunately without any luck.

There are a ton of ways ...

You can create your own view, see Flickr-like responsive photo gallery for Drupal 8

Or go for a module like juicebox, or a simple colorbox or (my favorite) photoswipe gallery. These modules use an image field (with multiple values), and then offer a display for the field. For videos you need to make a view using their handlers, not sure which suppports what now ..

You can go further and further .. fe. by using the media_entity (now in core ! media 2.0) with slick_media (more like a slideshow) etc. - see here https://drupal-media.gitbooks.io/drupal8-guide/content/

It really depends on your needs.


How do I print full path? My current code works:

<img src="<?php print $base_url . '/' . drupal_get_path('theme', 'lapost'); ?>/images/cart-template-logo.png" />

But if you check in source it prints only /sites/all/themes/lapost/images/cart-template-logo.png

It works if you load image on-site, but it also gets sent to email and when mail arrives it gives dead image shortcut, because the path is missing the www.webaddress.com part.

You can use the url():

$imgurl = drupal_get_path('theme', 'YOURTHEME') . '/images/image.png';
$final_url = url($imgurl, array('absolute' => TRUE));

This will provide a url like http://example.com/sites/all/themes/YOURTHEME/images/image.png


Drupal 7 IE8 Crashes on website load I just setup a new website, and when I test it in IE8 the browser totally crashes. I tried to scale the site back to almost nothing and it still crashes. It is using the Zen starter kit theme. When I load the main Zen theme it is fine.

http://vento.websitewelcome.com/~getgggco/

I've had similar issues with this, but unfortunately there can be a number of causes. Here are some things to check:

Do you have any modules that utilise flash installed? There are some issues with certain versions of Flash player that show up on 64-bit versions of Windows with IE8. If uninstalling modules that use Flash fixes the issue, then at least you know more about the problem.
Do you have CSS optimisation/aggregation turned on? If yes, try turning it off, then see if IE8 still crashes. There is a bug of some sort in the Drupal CSS optimiser, that means that if a CSS page the site is requesting returns a 404 error, then turning aggregation on will crash IE8. If you can, load up the site in another browser and use developer tools (like Firebug, etc.) to see if any of the CSS files are not being loaded. It is probably a good idea to check this regardless of whether you have turned on CSS optimisation.
Do you have JavaScript optimisation/aggregation turned on? If yes, try the same steps above, but for your JS files. Sometimes complicated JavaScript files cause IE8 to crash too.

Since you say it's a new site, I'm guessing the problem might be related to #2. Best of luck.


Views Exposed Filter conflicting with default search When I'm on a page with an exposed filter and then go to type into the default search, clicking the search button brings me right back to the exposed filter.

For now I am hiding the search block on that page but I would like them to both be on the page.  Is there anyway to fix this?

Not sure exactly what you have tried so far, but Can you check if Views: Better Exposed Filters can help you with this ?


How can I reduce the file sizes of the original versions of uploaded image files? I have a Drupal 7 site that allows users to upload pictures of themselves.  While the pictures aren't using much space on the server's filesystem now, I am worried that if my membership grows substantially I will have to add more space to cover all the images.

Right now, I allow users to upload images up to 10 MB in size.  I want to leave this limit high if possible because many of my users are not technically skilled and they do not know how to resize their images.

At the same time, the largest resolution that will be used on the site is 1024x1024.  So, I have configured the core image field to automatically scale down the images to 1024x1024.  This significantly reduces the file size.

Are there any other ways to automatically reduce the size of uploaded images?  Please note that I am talking about the original files, not image styles.

Interesting question - this should be a standard option on community distributions to avoid the space issue you raised but you're right that the focus seems to be on image styles as a solution..

Two ways to handle this

More custom way would be to add a hook_form_alter to your form that would add a submit handler to resize the image file after uploaded to the correct size -- if you are able to do image styles than your server already has the image libraries needed to do this.
An easier way would be to use an uploader that can be configured to do this work for you on the upload. One example is the plupload module / widget which has a clientside resize option during the upload (also saving bandwidth)

resize

Enables plupload to resize the images to clientside to the
specified width, height and quality. Set this to an object with those
parameters.


How do I find the search block form ID? I added some search block in my theme, and I placed each of them in a custom place.
I want to edit each of theme by using function hook_form_FORM_ID_alter for this purpose.

  Provide a form-specific alteration instead of the global
  hook_form_alter().

  Modules can implement hook_form_FORM_ID_alter() to modify a specific
  form, rather than implementing hook_form_alter() and checking the form
  ID, or using long switch statements to alter multiple forms.

How can I find each search block form ID? How can I edit them in ThemeName_form_search_block_form_alter() to add special classes to each of them?

I used the Devel module for this purpose, but It seems that for the Devel module, all those forms have the same ID (search_block_form).

This is the code I used.

function ThemeName_form_search_block_form_alter(&$form, &$form_state, $form_id) {
  drupal_set_message(kint($form));
  $form['keys']['#attributes']['placeholder'][] = t('Search');
  $form['actions']['submit']['#attributes']['class'][] = 'my-class';
}

The first thing to do is extend SearchBlockForm so you can give it a custom ID. Put code in mymodule/src/Form/MymoduleSearchBlockForm.php

namespace Drupal\mymodule\Form;

use Drupal\search\Form\SearchBlockForm;

class MymoduleSearchBlockForm extends SearchBlockForm
{
  protected $formIdentifier;

  public function setFormIdentifier($formIdentifier)
  {
      $this->formIdentifier = $formIdentifier;
  }

  public function getFormId()
  {
    $form_id = 'search_block_form';
    if($this->formIdentifier)
    {
        $form_id .= '-' . $this->formIdentifier;
    }
    return $form_id;
  }
}

Then you can call your form like this:

$form = \Drupal::service('class_resolver')->getInstanceFromDefinition('Drupal\mymodule\Form\Mymodule\SearchBlockForm');
$form->setFormIdentifier('some_custom_value');

return \Drupal::formBuilder()->getForm($form);

The key line of code here is this one:

$form->setFormIdentifier('some_custom_value');

If you pass a different value each time you generate the form, each form will get a different form ID. The form ID will be:

search_block_form-some_custom_value

Which will then be available in hook_form_alter with a $form_id of search_block_form-some_custom_value


Preprocess a views template I Have a template in my cart_template module called views-view-table--commerce-cart-form.tpl. Is there a way to create a preprocess function for that template.

What I have tried : hook_preprocess(&variables, $hook), but doing dpm($hook) display a lot of weird names like : block, page, views_view ... etc. which doesn't indicate when the function gets called for my template.

In general, every .tpl.php file has an equivalent preprocess function for it.  And, in general, the preprocess function and template files have the same name (in the Drupal sense).

The function you want is template_preprocess_views_view_table().  You can place this in a module, or in your theme.  Just name it accordingly.

Look at the default preprocess function for how the $view gets pulled out and/or dpm($variables['view']).  You will likely need to examine it to limit the function to just the view/display you need.

You can also try implementing MYMODULE_preprocess_views_view_table__commerce_cart_form() to limit to just that instantiation, but I don't recall if the Views module will do this.

The Theme Developer module can also help out tracking down what preprocess functions get called for each .tpl.php file.


"Expand all menu links" Menu Block selection shows all menu items in block not just active trail items I have a menu block that I have setup with Initial visibility level = 2 and Number of levels to display = Unlimited. When I check the "Expand all menu links" checkbox and view my menu block it is displaying ALL menu items at visibility level 2 VS the menu items in the active menu trail.

What's the be way to display only the active trail menu items without going into each menu item and setting them as "Show as expanded" individually.

I'm using Drupal 8 and a customized Bootstrap theme

Found a patch that does the trick:
https://www.drupal.org/project/menu_block/issues/2811337


How to send an email 1 minute after a node is created or updated by using a scheduled Rules Component? So far, I've used Rules to unpublish a node 2 minutes after it is created or updated (testing for now). Now, I'm trying to send an email reminder to the node author 1 minute after the node is created or updated. So far, this is what I've done:

Create rules component >> action set "send email":

Scheduled evaluation date: node:changed
add offset: 1 minute
User node reminder: node:source:author (i also tried node:author).

Create new rule "schedule email publishing":

Event: After saving new content
Condition 1: content is of type: advertisement
Condition 2: content is published
Action: Schedule component evaluation: Rules Component: send email.

What am I doing wrong?

There are a couple of things in your Rule and Rules Component that are either wrong, or should be simplified, such as:

the scheduling part of it belongs in your Rule, not in your Rules component.
nowhere you have an "identifier" for the task to be scheduled (each scheduled task requires an identifier).
all your Rules Component should have to do, is to send an eMail to "some user" (= the node author in your case), indicated by a parameter of the component.
what should happen if the same node is updated twice in say 30 seconds?

Read on for an example of a Rule and Rules Component to achieve what you're trying to do.

Step 1:

Here is the Rules Component to be created (in Rules export format, just import it in your own environment via copy-paste):

{ "rules_send_email_notification" : {
    "LABEL" : "Send eMail notification",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
    "ACTION SET" : [
      { "mail" : {
          "to" : [ "user-to-notify:mail" ],
          "subject" : "Friendly eMail reminder (Subject)",
          "message" : "Friendly eMail reminder (Message body) ...",
          "from" : "[site:mail]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Obviously, the Subject and Content of the eMail may need review / tuning, while you might also want to use some other From eMail ID.

Step 2: Create a "Rule" using the Rules Component

Here is the Rule to be created, in Rules export format (just import it in your own environment via copy-paste, after you changed (twice) the machine name article to advertisement to fit your case; then change the rule from inactive to active):

{ "rules_send_email_reminder_to_node_author" : {
    "LABEL" : "Send email reminder to node author",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : {
      "node_insert--article" : { "bundle" : "article" },
      "node_update--article" : { "bundle" : "article" }
    },
    "IF" : [ { "node_is_published" : { "node" : [ "node" ] } } ],
    "DO" : [
      { "schedule_delete" : {
          "component" : "rules_send_email_notification",
          "task" : "[node:author]-[node:nid]"
        }
      },
      { "schedule" : {
          "component" : "rules_send_email_notification",
          "date" : "+1 minute",
          "identifier" : "[node:author]-[node:nid]",
          "param_user_to_notify" : [ "node:author" ]
        }
      }
    ]
  }
}

Note that this rule refers to the Rules Component from the previous step. And it also includes an extra Rules Condition that the node must be published (similar to the Rules Condition in your question).

The schedule_delete that is part of this rule is to ensure that previously "scheduled" eMails will get removed when updating a node multiple times during a very short period like 20 seconds. That way it only triggers 1 eMail, and related to the most most recent update (imagine you add some extra data from the node content to the message body, in that case you don't want to eMail outdated information, right?).

Also important is the identifier you use for these scheduled tasks. In this case I used [node:author]-[node:nid] (= "author", followed by a "-" and then the nodes's "nid"). That way you have a unique task identifier for every node of each author.

Step 3: Review your timings

Rules Components scheduled for execution using Rules Scheduler, will actually be executed "next time cron runs" (after the scheduled date/time has arrived). So make sure to actually run cron and be patient enough for cron to have run.

Example: if you want to send the eMail after 1 minute, but cron only runs every 60 minutes, and the last cron ran 5 minutes ago, then you'll have to wait another 55 minutes before an attempt will be made for the eMail to be delivered.


Adding a taxonomy term translation changes the original language value! I have an issue when I try to add a translation of a taxonomy term using the site UI. The original language value changes to the translation value that I added.

How can I prevent that from happening?

You need to make sure it is translatable in the language settings.

Go to:

/admin/config/regional/content-language

Make sure that taxonomy term is checked in the custom language settings.  If not, check and save.

Then find the Taxonomy section in the form.  In this section, make sure that your vocabulary and fields you want translatable are checked.  Include the show language on edit option as well

Once you have done that, go to:

http://www.solarwindsmsp.test/admin/structure/taxonomy

And create translations for the vocabulary for each language you want.

Also edit the vocabulary settings and make sure there is a default language specified for new terms.

Next, if you have existing terms, you need to edit the term and set a default language in the dropdown.  E.g. english instead of not specified.

Once you do this, you will get a translate option on the edit / delete dropdown in the list.  Select translate to add additional languages.


Drupal 7 CKeditor always saves Array I am developing a custom module with some entities inside. I created a form to edit them and I would like to use CKEditor in one of the fields.

I can see and use the CKEditor, but when it's time to save, it always saves the value 'Array'. You can find the code I am using below:

$form['description'] = array(
        '#type' => 'text_format',
        '#format' => 'full_html',
        '#title' => t('Content'),
        '#default_value' => $entity->content,
        '#weight' =>2,
        '#required' => FALSE,
    );

I'd say CKEditor changes the value before sending the form POST but I am not sure.

Any ideas?

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

For a normal textarea:

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

For a WYSIWYG:

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


how to create a sub menu accordian using api I'm trying to develop an accordian sub menu, See image below. I've tried using the menu block module but i've found it a litte tricky to format. I'm wondering how can get an array of menu items base on a parent. So, say the submenu below were all children of /aboutus/ how would the php look? I'm using drupal 7

Try the jQuery Menu module. It was somewhat easy to style -- all I had to add was CSS.

Jquery menu uses simple, cross browser compatible jquery to transform your multilevel menus into click and expand menus. Yes this module is similar to dhtml menus and active menus, but it is different in a couple of key ways.

Unlike dhtml menus (which requires you to click twice on a link to actually follow an expanded link) Jquery menus separates the link from the expanding mechanism (there is a small plus symbol that you click instead to expand the menu). This makes for a more natural navigation.
Unlike active menus, which makes ajax calls to fill in the lower level menus when you click the plus symbol, Jquery menu creates the menu in full on the initial page load. I personally have used active menus for several months and have found that those ajax calls sometimes fail, and are not as stable as jquery.
Unlike Active menus which transforms all menus into active menus once the module is turned on, Jquery menu only creates a jquery block for the menus that you specify. To chose which menus you want to be active you just have to visit the admin page at 'admin/settings/jquerymenu' .
Jquery menu is easily themable. Since the jquery menu blocks only use a small number of styles, and don’t use the default list styles, overriding it with your own css is easy. Also the important display elements are contained in themable functions so you can tinker with the layout if you like.


How to disable the page title output of main content? I want to output the page title in the 'title' block and not with the main content output. I'm using the Bootstrap theme for Drupal 8.

I've enabled the title block and placed it in its own region but now I've got two page titles being displayed.

I've spent two days and have tried everything to disable the title that is output with   {{ page.content }} in the page.html.twig template.

I do not want to hide it via CSS.

Can the page.content title be disabled?

The title is probably listed in the content type's manage display list.

Edit the content type and hide the title field.


update node field without node be updated I want to update a field of node programmically,I did it with below code

$node = node_load($nid);
        $node->field_share_counter['und'][0]['value'] = intval($node->field_share_counter['und'][0]['value']) + 1;
        node_save($node);

but after update with this method the node will be update,I mean in content show that this node recently update, I want update custom field without the node updated.also I know db_update is suitable for update a field of table in db but in here I dont know how achieve this job.

tnx

I found this http://timonweb.com/how-insert-and-update-only-specific-fields-your-entity-drupal-7 and it is useful and final solution is :

$node->field_share_counter['und'][0]['value'] = intval($node->field_share_counter['und'][0]['value']) + 1;
        //$node->field_product_description[$node->language][0]['value'] = 'This is a very nice and useful product. Buy it now! We want your money!';

            // Get the numeric id of your field by passing field name
            $info = field_info_field('field_share_counter');
            $fields = array($info['id']);

            // Execute the storage function
            field_sql_storage_field_storage_write('node', $node, 'update', $fields);

            // Clear field cache
            cache_clear_all("field:node:$node->nid", 'cache_field');


Ajax Multiple Callbacks is not working for first callback? I have been trying to load the data to other select list field from the first select list callback.

I want to change the two select list variables based on the first select list on changes, please refer the below sample code for understanding.

function example_form_alter(&$form, FormStateInterface $form_state) {
     $form['field_example']['widget']['#ajax'] = [
      'callback' => 'example_ajax_callback',
      'wrapper' => 'example-company-wrapper',
      'event' => 'change',
      'progress' => [
        'type' => 'throbber',
        'message' => t(''),
      ],
    ];

function example_ajax_callback(&$form, FormStateInterface $form_state) {
  $first_callback = example_company_form_trigger(&$form, FormStateInterface $form_state);
  $second_callback = example_company2_form_trigger($first_callback, $form_state);
  return $second_callback;
}

function example_company_form_trigger(&$form, FormStateInterface $form_state) {
return $form['field_example1'];
}

function example_company2_form_trigger(&$form, FormStateInterface $form_state) {
return $form['field_company2'];
}

When the ajax callback is calling, the second callback (example_company2_form_trigger ) is only working, the first callback(example_company_form_trigger) is not working.

I am facing this issue while returning the form.

Could anyone please help me to sort out this issue?

You don't need multiple ajax callbacks, you need multiple ajax commands.

First wrap each form element in a separate div container and then return for each one an ajax command from the same callback:

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;

...

  function example_ajax_callback(&$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();
    $response->addCommand(new ReplaceCommand('#example-wrapper1', $form['field_example1']));
    $response->addCommand(new ReplaceCommand('#example-wrapper2', $form['field_example2']));
    return $response;
  }


Custom Views Relationship with Custom Entity I have custom entity with just a base table and it is referenced with the node with its field field_a. Now I want to create the relationship between these two entities (node and my custom entity). I can get the result working but I am not getting the node fields listed in the views field section.

// Base table for custom entity is "clinical_trial_research_sites"

function clinical_trial_views_data_alter(&$data) {
 $data['clinical_trial_research_sites']['node'] = array(
    'title' => t('Clinical Trial'),
    'help' => t('Field Reference Appear in Location Content type.'),
    // Information of the referenced table!!
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'label' => t('Location'),
      'base' => 'field_data_field_site_comp_code', // node field table name
      'base field' => 'field_site_comp_code_value', // field column name of node field
      'relationship field' => 'site_comp_code', // This is referencing field in my custom entity
    ),
  );
}

I can get the sql working , inner join working but views is not listing all the fields of the node as I want to display the some of the fields from the nodes too!!. I think I am missing some information to tell the views that realtionship is not only field table but with the node as a whole!!

I fixed it by copying some of the code from the entityreference.
I have to use a different views handler for this relationship  and add other attributes to that relationship

function clinical_trial_views_data_alter(&$data) {

  $data['clinical_trial_research']['clinical_trial_research_sites'] = array(
    'title' => t('Clinical Trial Research Sites'),
    'help' => t('Field Reference Appear in Clinical Trial Research Sites.'),
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'label' => t('Clinical Trial Research Sites'),
      'base' => 'clinical_trial_research_sites',
      'base field' => 'study_num',
      'relationship field' => 'study_num',
    ),
  );
  // The reference field in the node entity is not entity reference , its just a basic text field
  $data['clinical_trial_research_sites']['site_comp_code']['relationship'] = array(
    'handler' => 'views_handler_relationship_entity_reverse',
    'field_name' => 'field_site_comp_code',
    'field table' => 'field_data_field_site_comp_code',
    'field field' => "field_site_comp_code_value",
    'base' => 'node',
    'base field' => 'nid',
    'title' => t('Referencing entity'),
    'help' => t('Field Reference Appear in Location Content type.'),
    'title' => t('Location'),
  );
}


entity_reference autocomplete: Allow multiple target_types I'm creating a new custom entity and would like the ability for my entity_reference autocomplete field to be able to allow selecting from any arbitrary set of entities.

For example, let's say I would like the available autocomplete options to draw from:

two node types (page, my_custom_node)
users
the terms in the Tags taxonomy vocabulary

Can anyone lend me insight as to how this might be accomplished? I'm a somewhat experienced Drupal 7 developer, but Drupal 8 has been quite an uphill climb for me and I'm afraid that not all of the new concepts are clear enough to me yet to accomplish this task on my own.

Thanks!

entity_reference fields do not support multiple target types, never have, also not in Drupal 7 :) So you can't have an autocomplete for that as it couldn't be stored then.

However, you can use https://www.drupal.org/project/dynamic_entity_reference, which stores entity type and ID in a field and the default widget it provides is a combination of select and auto-complete field to select the type and the specific entity.


Node access to anonymous user Is there any way to make some nodes accessible to anonymous users in drupal and rest of the nodes content accessible to only authenticated users . I have a site which offers questions for practice . I want to keep some nodes(questions) accessible to anonymous users to see a sample before they can decide to be a premium user .
Any pointers on this is highly appreciated .

Regards
Meenakshi

Try Content Access module Content Access

   This will allows you to manage permissions for content types by role and author.this will allow you to manage permission for node that you want to access to anomyous and authenticated users.


Undo/redo drupal console generate:plugin:block? I ran drupal console generate:plugin:block and made a mistake.  I'd like to run it again, but I get this error:

 'block' entity with ID 'my_block' already exists.

I've removed the source file that the command created, but this error still persists.  I'm guessing the block was added to the site's actual configuration.  How can I undo/overwrite it?

I think I found the answer myself:

 drupal config:delete active block.block.my_block

(For my specific case)  Good luck finding the configuration name.  There's no listing from the console.  I had to export the whole damn thing to a directory and grep for it.


How to attach block to page provided by logintoboggan I have the logintoboggan module installed. By default, Anonymous users will be presented with a login form along with an access denied message when they try to access a page which they do not have the permissions to. Please, how can i attach a block to this page?

Thanks

One option would be to redirect users to login when access is denied.

another may be to create your own Access Denied page, and then attach a login block to that URL.

To create your own Access Denied page, first create the page as you would with any other content,  then navigate to: /admin/config/system/site-information


Is it possible to define a FieldFormatter as a service I need the 'language_manager' service inside a custom FieldFormatter. I'd prefer not to use \Drupal::service('language_manager').

Is there a special tag for FieldFormatters, or any other method to define it as a service?

You don't need to define your FieldFormatter as a service. FieldFormatters are instantiated inside the FormatterPluginManager's createInstance method (FormatterPluginManager::createInstance) which calls a create method on the formatter plugin object, passing a $container object as a parameter.

But this happens only if your FieldFormatter implements the \Drupal\Core\Plugin\ContainerFactoryPluginInterface. From then on, you are able to inject the service inside your FieldFormatter.


Multi vendor products, single store? How can I create products in Drupal8 eCommerce, which are from different vendors, but I'm handling it trough a single store ?
(Vendors should be invisible to the end customer).

I want in addition to keep track internally (for my own accounting purposes) which item from which vendor was sold, so I can reimburse the specific vendor.
Is there a way to put/attach "out-of-bound" info to products and eventually orders ?

I'm still in research phase, experimenting with Drupal. Is such thing possible ?

Yes it is. In the end even unlimited with custom code ..

To easily limit the access for a vendor to only his products, each one would need one or more product types, then you can apply the right permissions. Also I would add the vendor/user as a reference (field) to that product type.

There very good shipping methods, applicable for different countries etc.


What exactly is a theme? I am an experienced programmer in various languages, and also have experience with web development. I am new to Drupal, and as with any new platform there is sometimes a language barrier. I've read drupals small documentation on theming on their site, but I just want to make sure I'm wrapping my head around this correctly.

The way I understand it, a theme in Drupal is a site's skeleton, the basic HTML and CSS. If that's true then I at least have that part right. Where I'm losing it is where does the theme stop, and web design/content development start? For example, what exactly should I expect when I download a Drupal theme/template, should I be editing the theme directly to add my images and text, or is there specially created modules for that I'm just not seeing? Is it common practice to sub theme or just edit the theme directly?

Just as structured programming revolutionized system building, modern web sites have strived for a conceptual structure. Today we try as far as possible to separate information, process and presentation. Think of the three as a venn diagram of overlapping circles: content, function, and theme.

Images and text are information, and the core and modules necessary to work with them are function.

The theme is the look and feel, the overlap is your information architecture. In Drupal, you can retain the same function and information, and completely change the presentation by changing the theme.

Think of it as structured programming taken to the next level.


How to save each array values in next line? I am having a requirement that, automating the contributed module configurations via hook_update. I have a text area, where i need to mention different URLs with one  URL/line. For reference look into the image:

To achieve this I have to use variable_set(); function.
I tried something like below but not able to get all the values displayed.

$test = array('abc/*','xyz/*','ijk/*');
variable_set('boost_testing', $test);

This code is setting only first row, it will not come to next row.

So please suggest something I can do by using <br> or \n so that i can display each values next row. Any help will be appreciated.

You should pass paths as a string instead of array:

$test = "abc/*\nxyz/*\nijk/*\n";
variable_set('boost_testing', $test);

Remember to use double quotes for the $test string.


Restrict menu item to certain roles in TB Mega Menu I am currently using TB Mega Menu on D7 to configure my main menu. One of the main menu item is accessible to both anon & authenticated users.I would like to have a block attached to this item as a drop down but it should be accessible only by certain roles - not all authenticated users. I have enabled block visibility restrictions for this block by the user roles I want. But I am still able to view this block as part of the menu as an anon user. How do I restrict this?

A possible workaround solution would be to create another menu all together and give the block menu access to the role that you need and exclude this role from your original menu.


Can you export and import templates for multi-site use? Is there a way to take a form built on one site, save it as a template, and use it on another site? Currently all themes and modules are shared so I assumed the Webform Tempaltes would be available on all 3 sites but they are not. Is there a way to do this? This is running on Drupal 8 btw.

If it's Drupal8 you can:

save webform as a webform template
export/import the source file.
 You can copy it and the paste to the new webform on the other site. It will duplicate an identical webform for you.


Print module PDF attachment I have a custom module that provides a path that sends an email (mimemail) with a pdf attachment generated from the print_pdf module that comes with the print module.
Here is what my HOOK_mail function looks like.

function custom_send_email_mail($key, &$message, $params) {
  $node = $params['node'];
  $user = $params['user'];

  $message['subject'] = t($node->title.' attached');
  $message['body'] = 'Hello '.$user->name.'

Please find '.$node->title.' attached.';
  //$message['params']['attachments'][] = $attachment;

  module_load_include('inc', 'print_pdf', 'print_pdf.pages');

  $attachment = array(
    'filecontent' => print_pdf_generate_path($node->nid),
    'filemime' => 'application/pdf',
    'filename' => $node->title.'.pdf',
  );
  $message['params']['attachments'][] = $attachment;

}

The problem I have is that the pdf versions of pages use a template file, which works fine when navigating to the pdf version url, ie. /printpdf/nid but when getting the pdf file string with the (silly named) print_pdf_generate_path() function, it does not use the template file.

It seems it was a silly mistake on my behalf.

My module defined a custom path to send the email and the theme files for the pdf were in the admin theme folder, so I had to set my path to use the admin theme for the email theme files to be found.
I did so by implementing HOOK_custom_theme.

function custom_send_email_custom_theme() {
  return variable_get('admin_theme');
}

I will leave this question up as the code may help someone in the future (and maybe me if I need to send an email with attachments again :) )


How to configure XHProf on windows? With the help of Lorenzo Alberton tutorial, i get XHProf installed for drupal 6 on linux server. Now i need to get it installed on windows but i found that XHProf cant be installed on windows. Additionally, at drupal.org XHProf, is available for drupal 7 onwards. If anyone has installed XHProf for drupal 6 on windows then please share.

I just finally installed the XHProf profiler under Windows7 x64 - PHP 5.3.x. Assuming that you have a functional PHP environment, this checklist should work for you too:

Download the pre-compiled XHProf 0.10.3 - PHP 5.3 VC9 NTS binary.
Paste the downloaded dll file to PHP extensions directory.
(You can find the directory path in extension_dir directive of php.ini file.)
Append extension=php_xhprof.dll directive to the php.ini.
Restart the web server and searchphpinfo() output for XHProf. found? done!
You might also want to use XHGui fork instead of the built-in UI.


Is there any Menu Module to show thumb image, content tile when mouse over on menu item I want to create a main menu bar for my drupal blog, like shown in image

Means, when i mouse over on the menu item, it should show, node thumb image, content title.

is there any modules available to do this. I tried in google to find like this modules, no luck. Please any one give suggestion how to do this.

This can be done using Views Module and MaxiMenu.

Edit: you might also need the Menu Views Module and potentially Nice Menus Module to achieve the perfect style you want.

I have not tested this but a Coworker built a client's dropdown menu with images this way, So i know it is possible. I just personally haven't done it =-)

I hope this gets you close!


Print Primary and Secondary Menu Links separately I have a main menu with primary, secondary and tertiary links. The primary links will be positioned top right of the page. I want the sub menus (secondary/tertiary links) to print in a separate wrapper that will span the width of the browser. I cannot use absolute position because I need the sub menu to push down the content below it when I hover over the primary links. How can I do this with templates?

Check out the theme_menu_link and theme_menu_tree hooks.  You can add them to a custom theme, and they give you full access to the links as they are built.

Take a look at the following line in theme_menu_link:

if ($element['#below']) {
  $sub_menu = drupal_render($element['#below']);
}

If you add a test to check if the link being tested is top tier than you can change the $element['#below'] to suit your needs. checking for top tier is as simple as

$element['#original_link']['plid'] == 0

The parent link id of top tier elements is 0, so this works out.
Then, if it is top tier and has links below it, add a theme wrapper that will allow you do what you want it to.  For example:

if ($element['#below']) {
  if ($element['#original_link']['plid'] == 0){
    $element['#below']['#theme_wrappers'][] = 'my_custom_theme_wrapper';
  }
  $sub_menu = drupal_render($element['#below']);
}

I am seeing the original theme wrapper is menu_tree__main_menu.  If you want to completely replace it use you should unset that one, then set a new one as mentioned above.

If you want some pointers on theme wrappers check this post.


Get gid of group node How do I get (in PHP) the gid of a node that is a group?

The group_audience field is present but empty, and I can't seem to populate it; presumably it is because that node is the only group, and it cannot itself be a member of the group it defines. (Why not is another issue that won't matter if I can just get the gid.)

Note that the entity id is the gid in the current OG 2.x version(s) (there is some confusion around the change from earlier OG versions where GIDs were NOT entity ids)

From

  ... the group ID is the identifier of the entity. if i have a group which is a node the group ID will the be node ID. If i create a group which is a user the group ID will be the user ID and if i have a group which is a taxonomy term the group ID will the term ID.

Use og_is_group to determine if the node in question is acting as a group.


How to add css and js file in custom module I created a custom module in drupal 8. And I am trying to add js and css file in
my_module.libraries.yml file using this

lrv_key:
  version: 1.x
  js:
    js/lrv.js: {}
    dependencies:
      - core/jquery
      - core/drupalSettings
  css:
    theme:
      css/lrv.css: {}

But it doesnt work.

To understand how to correctly define a library, see how Drupal core defines its library, for example the ones defined in core.libraries.yml.

jquery:
  remote: https://github.com/jquery/jquery
  version: "3.2.1"
  license:
    name: MIT
    url: https://github.com/jquery/jquery/blob/3.2.1/LICENSE.txt
    gpl-compatible: true
  js:
    assets/vendor/jquery/jquery.min.js: { minified: true, weight: -20 }

jquery.cookie:
  remote: https://github.com/carhartl/jquery-cookie
  version: "v1.4.1"
  license:
    name: MIT
    url: https://github.com/carhartl/jquery-cookie/blob/v1.4.1/MIT-LICENSE.txt
    gpl-compatible: true
  js:
    assets/vendor/jquery.cookie/jquery.cookie.min.js: { minified: true }
  dependencies:
    - core/jquery

jquery.farbtastic:
  remote: https://github.com/mattfarina/farbtastic
  # @todo Ping @robloach or @mattfarina to retroactively create this release.
  version: "1.2"
  license:
    name: GNU-GPL-2.0-or-later
    url: https://github.com/mattfarina/farbtastic/blob/master/LICENSE.txt
    gpl-compatible: true
  js:
    assets/vendor/farbtastic/farbtastic.js: { minified: true }
  css:
    component:
      assets/vendor/farbtastic/farbtastic.css: {}
  dependencies:
    - core/jquery

The dependencies key is not a sub-key of js, nor css, but it is at the same level of the js and css keys.
Keep in mind that the dependencies key defines the dependencies of the library from other libraries.

I would rather use the following library declaration.

lrv:
  version: 1.x
  js:
    js/lrv.js: {}
  css:
    theme:
      css/lrv.css: {}
  dependencies:
    - core/jquery
    - core/drupalSettings

A .libraries.yml file just defines the libraries, which aren't automatically loaded, since the definition doesn't say to Drupal when they should be loaded.
To load your library, for example in hook_page_attachments(), you use code similar to the following.

function mymodule_page_attachments(array &$attachments) {
  $attachments['#attached']['library'][] = 'mymodule/lrv';
}

The name of the library is mymodule/lrv because it is defined as key lrv (the one I used in the code I shown) in the file mymodule.libraries.yml (the one you seem to use).

See Defining a library and Attaching a library to page(s).


If statement for page template in node template file Is it at all possible to check for a page template NID before outputting some text in a custom node template file?

I have a custom node template file and I am using that data in a custom page template file. I have checked in the past the NID of a node using the following that that works:

          if (($node->nid) == '25732') {
            print views_embed_view('lead_view',"page");
          }

Now I want to check whether the page template file is 1234. I tried using $page, but I don't think that is right.

          if (($page->nid) == '1234') {
            **Stuff here**
          }

you can do this like

if(arg(0) == 'node' && arg(1) == '1234'){
**Stuff here**
}


How do I theme the teaser? As shown in the picture, I have the teaser view of a taxonomy term (Virtual Tour) which shows the node title, the node summary, the submission date, and an image added in an image field.
What I would like to achieve is to let the image float to the left of the summary. Is there a way to achieve it?

You should already have a template suggestions available like :

<!-- FILE NAME SUGGESTIONS:
   * node--2--teaser.html.twig
   * node--2.html.twig
   x node--BUNDLE--full.html.twig
   * node--BUNDLE.html.twig
   * node--teaser.html.twig
   * node.html.twig
-->

Make sure you have settings.yml set to twig.config: { debug: true ... and you will see the suggestions in the source.
You can set suggestions for any hook like:

function MODULE_theme_suggestions_node_alter(array &$suggestions, array $variables, $hook) {
 $node = $variables['elements']['#node'];
 $type = $node->bundle();
 $view_mode = $variables['elements']['#view_mode'];

 $suggestions[] = 'node__'.$type;
 $suggestions[] = 'node__'.$type.'__'.$view_mode;
}


how to include external php file in drupal 8 I want to merge two xlsx file and download merged file in drupal 8. So i used a PHPExcel library for doing so.

But i am not able to include a PHPExcel.php file in custom controller for that. I used require_once, module_load_include() but does not work for me.

How can i include it . please help.

require_once DRUPAL_ROOT.'/'.drupal_get_path('module','custom').'/src/Controller/PHPExcel.php';

or

module_load_include('php', 'custom', 'src/Controller/PHPExcel');

$file1 = 'ford.xlsx';
$file2 = 'toyota.xlsx';
$objPHPExcel1 = PHPExcel_IOFactory::load($file1);
$objPHPExcel2 = PHPExcel_IOFactory::load($file2);

foreach($objPHPExcel2->getSheetNames() as $sheetName) {
$sheet = $objPHPExcel2->getSheetByName($sheetName);
$sheet->setTitle($sheet->getTitle());
$objPHPExcel1->addExternalSheet($sheet);
}

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="ford-toyota.xls"');
header('Cache-Control: max-age=0');
header('Cache-Control: max-age=1');
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel1,
'Excel2007');
$objWriter->save('php://output');
exit;

and error is :

Fatal error: Class 'Drupal\custom\Controller\PHPExcel_IOFactory' not found

I am not sure from your question which phpexcel library you are using, so there are potentially different answers, here is one:

1. On Packagist

If like in the case of mvlabs/mvlabs-phpexcel you would do the following:

on the command line:

composer require mvlabs/mvlabs-phpexcel

Then in the file where you are wanting to use it you can simply add a "Use" statement (as per this answer):

use ExternalPackage\namespace\Foo;

Drupal 8 does an auto-include and is "aware" of all the PHP libraries inside the vendor folder.


How can I include a .inc file before hook_node_access runs? I'm currently including a .inc file in hook_init(), but now need to call a function from that include inside of hook_node_access(). I've just discovered that, because hook_node_access() runs very early on, my file is not included. I then tried to do it inside of hook_boot() because the documentation suggests that it runs sooner, but it's still not available to me. I'm temporarily including the file in my .module outside of any function via a simple

require_once DRUPAL_ROOT . '/sites/all/modules/...

but would prefer not to do it this way.

First, using the require include to load your file is perfectly sound, I think. Alternatively, you could add the include to the .info file of your module and allow it to be loaded on every page.

However, to answer your question: We could implement hook_hook_info() from a custom module and add node_access as a group for hook_node_access(). Now, in our module itself, we can have our access callback in a mymod.node_access.inc file.

This is probably not recommended as we are dabbling with core (in a small yet unreliable way) with no real value at all but is a way by which you could do it.

Once you have done this, I'd suggest running the entire Drupal core test suite once (at least node module's) to make sure that we are okay.


Getting the logged in username and email in a view Im trying to get the logged in users username and email adress to display in a view is that possible?

Yes. Just create a view with base table of (user). Then add your fields of username and email. Then add a contextual fileter of uid and set a default value for logged in user.


Views Infinite Scroll and back button issue I am using Views Infinite scroll module, Drupal 7. When i click on an item and go to next page and then click Browser back button, it takes me back to the start of the page.

When i click browser back button, i want the user to go back where he clicked/ or where he was on the previous page

Can somebody suggest any solution to this? Or any other module that can be used? Or an jquery script that would help?

I am badly in need of help.Thanks in advance!

Try to use GD Infinite Scroll module.

  Provide an administration to use the infinite scroll jQuery plugin :
  auto-pager on custom pages using pager. You can use autoload on scroll
  or a load more button. This module is designed to works on any page
  with pagination (views, search results, heavily customised page, ...)


How do I avoid unwanted users create accounts? I am using Drupal 7 and use the User verification module for blocking (prohibiting) unwanted users in our site, but a user is creating an account every second.

How can I stop that from happening?

Is it possible to first send an email to the users, with a verification link  included? When that link is clicked, users will be registered on the site.

It depends on what kind of control over user accounts you want.  By default Drupal allows visitors to register new accounts.  If you want to disable that, you can set Who can register accounts? to Administrators only at /admin/config/people/accounts.


Single field output with Views I am having a view of users, in that I have added a field "Status" which is from the core Drupal 7 to display the user which are "Active" or "Blocked".

What I am trying to achieve is that:

I should get a clickable link to the field value status, assuming if its "active" Achived, here I have just rewritted the output "user/[uid]/edit?destination=admin/people" checked with Use absolute path itself in the View.
When I click on it I should only get a page with only value of "Status" where I can change the status of the clicked user; here I am stuck, any idea how can I achieve this?

Have you tried using the Views Bulk Operations (VBO) module? This allows you to perform operations on entities from your actual View page.

I've never used it with Users before, but I've managed to use it to Publish / Unpublish nodes from my own custom View's page.


Captcha doesn't work for my site I'm using Drupal for my site, and I activated the CAPTCHA image for the login of the administration user. However, it doesn't work.

I don't see the CAPTCHA image, which is replaced by a placeholder.

Why does this happen? Do I need to fix something in the settings?

May you tell me how I can, at least, skip this verification to be able to log in, and remove the CAPTCHA for my account?

The issue was because the PHP GD Library was not installed in my machine...  So I installed the GD Library using sudo yum install php56w-gd and the things working good actually.

Note that to access to admin page (my aim) we can deactivate the captcha module using  this command : drush dis captcha


Where to add track_changes option in migrate_d2d class I have an ongoing migrate_d2d migration where I will need to be able to
detect changes on a node by node basis, and I would really like to be able to
use the functionality in the Hash source rows to detect changes feature to
do that.  However, I can't find where to add that option so that the hashes
are generated. I've tried this is my class (that overrides
DrupalNode6Migration):

$this->sourceOptions['track_changes'] = TRUE;

but the option isn't added and used. According to this referenced post on this feature, I should add it in my source constructor, but that
part is handled by migrate_d2d in the abstract DrupalMigration class. Do I
need to go down to that level to create my class just to access this
property, or is there a way I can add it from my class that overrides
Drupal6NodeMigration?

It seems you want to synchronize sites.
http://timonweb.com/using-hash-value-trackchanges-to-detect-source-data-changes-in-migrate-for-drupal-7
If you follow on this example you have mentioned above, Filter nodes by the update time these are changed after you deployed at last. You use MigrateSourceSQL. So you able modify a query.

If you want to synchronize sites, use the module: services or feeds.


Why Drupal 7 takes too time in connecting to mysql db? - measured with xdebugger i have drupal 7 on localhost (core i7 - 12gb ram etc)
on Nginx with APC and mySql on windows7.

standard installation with standard theme and a bounch of new modules. about NO content.

The problem is that the homepage take ever 1,5 sec to load (without APC 3 secs).
i installed XDEBUGGER and with winCacheGrind i discovered that 75% of the time is lost in DB connections. Self: 2ms, Cumulative:1007ms

i tried almost anything i found on google... also i ported db engine to MyISAM... mySql is configured with my-HUGE.ini file... so it can take any resource from the computer.

How could i solve this?

1,5sec for any loggedin user is too much time... on the hosting this time will be greater as i won't have a so big dedicated server...

This is a good group for you to join on groups.drupal.org
http://groups.drupal.org/drupal-windows

Looking at this post it sounds like the issue you are describing: http://groups.drupal.org/node/242443.

  Make sure that your Drupal settings.php connection string uses the IP
  address of your MySQL server (e.g. 127.0.0.1 for your local Windows
  machine), not 'localhost'.


taxonomy term path using two different vocabulary I have a "destination" vocabulary and a "category" vocabulary.
Is there a way to change the taxonomy term path of the "category" terms to include the "destination" terms in front?

i.e. destination_term/category_term/term_title

I tried using tokens but I can't figure out how to add a different vocabulary in front.

UPDATE

Here's the situation:

I have a travel site with a main portal going to 4 different destination pages (all view pages), each set with a term reference from "destination" vocabulary. Then I have a content type for  Categories, set with a term reference from "category" vocabulary (restaurant, activities, etc).

I actually have two problems:

I can't seem to have a "destination" path preceeding the "category", which I need to make blocks appear in the right place. (the only way that I found to do this is by cheating and adding a hidden destination term in my category voc. but that means I would have to copy/repeat the "category" voc. 4 times with a different hidden "destination" term in each. That doesn't make much sense now does it? I'm sure there's a better way. Anyone?
The other problem is that except for the above part, I am able to make the paths and breadcrumbs appear the way it should (with the help of Pathauto, Taxonomy Menu & Taxonomy Menu Trails modules), but when I get to the actual content, there's nothing in the breadcrumbs anymore (the url path shows up ok though)! Any suggestions?

Any help is greatly appreciated.

For your content type, you could set a content path pattern (admin/config/search/path/patterns) that looked something like this:

[node:field_destination]/[node:field_category]/[node:title]

This would put the destination term in front of the category term for your content nodes.  However, there is no good way for you to put the destination term in the path to the category vocabulary, because there might be zero, one or many content type nodes for any given category, and you have no good way to relate these two terms.