How to use Rules to assign user badges to users with sufficient User points? I want users on my sites to have badges assigned to them. I have user points,user badges, and rules module. User points is working fine. I have created a badge. Now I want that whenever a user's total points is greater than, say 50, he or she is assigned a badge. So, I went about to create a rule. However, I was not able to find any event, condition, or action for this. Please advice

Note: I tried to assign badges directly to users by going to their profiles and assigning them badges...however when i try to do so i get the following error:"My_Badge" is not a valid badge. Try using the autocomplete function (requires javascript). What is this?

Which version of User Badges are you using?

According to the module page "The 7.x version is NOT suitable for production yet." so if you want to use it you will probably need to do some manual debugging at the very least.

This user had the same issue you are seeing and they said uninstalling and reinstalling the latest 2.x dev worked for them.


Prevent WYSIWYG inline images from showing in Teaser Display Is there an easy way to stop inline images placed through the WYSIWYG editor from showing on a teaser display? Obviously if I use the summary field the problem is solved, but the client may not be conscious enough to always do that. I am currently outputting a featured image through an image field on the teaser display, so when the inline image also shows up it not only blocks the teaser text, it looks pretty weird.

Perhaps you could try https://drupal.org/project/advanced_text or https://drupal.org/project/smart_trim?

I think they both have the ability to strip html from teasers.


Use dropdown in views exposed filter on text fields with node->title? I followed this link to transform my exposed filter from textbox to  dropdown list.

Use dropdown in views exposed filter on text fields with entity not node?

I make it work with a custom textfield.

I have problem to use the module with node title.

My code till now is:

<?php

function views_dropdown_form_views_exposed_form_alter(&$form, &$form_state) {
global $user;

// Only alter forms with the necessary field
if (isset($form['title'])) {

// Build a query to get all node ids having the specified field
$query = new EntityFieldQuery();

$results = $query->entityCondition('entity_type', 'node')
                  ->entityCondition('bundle', 'rapporto_di_lavoro')
                  ->propertyCondition('uid', $user->uid)
                  ->propertyCondition('title', 'NULL', '!=')
                  ->execute();

// Attach the field values to the nodes
$ids = array_keys($results['node']);
print_r($ids);
print('
');
// Add a default so the filter is optional
$options = array('' => '<select>');

// Buld the options array based on the query results, overwriting duplicate entries
$query = db_select('node', 'n')
            ->fields('n', array('title'))
            ->condition('n.nid', $ids, 'IN');
$options = $query->execute()->fetchAll();

$op = json_decode(json_encode($options), true);
print_r($op);
print('
');

// Attach the field values to the nodes
//$nodes = $results['node'];
//field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id));
// Buld the options array based on the query results, overwriting duplicate entries
//foreach($nodes as $nid => $node) {
  //$value = $node->field_cognome_l['und'][0]['value'];
  //$options2[$value] = $value; }

//Alter the field
$form['title']['#type'] = 'select';
$form['title']['#options'] = $op;
$form['title']['#size'] = 1;
}
}

I feel close to solution but I miss something.

On the picture I print four arrays.

Only the 4th was working when I tested the module with a custom field,

so probably I need to transform the 3rd array into the 4th.

I solved the problem, here the code:

<?php

function views_dropdown_form_views_exposed_form_alter(&$form, &$form_state) {
global $user;

// Only alter forms with the necessary field
if (isset($form['title'])) {

// Build a query to get all node ids having the specified field
$query = new EntityFieldQuery();

$results = $query->entityCondition('entity_type', 'node')
                  ->entityCondition('bundle', 'rapporto_di_lavoro')
                  ->propertyCondition('uid', $user->uid)
                  ->propertyCondition('title', 'NULL', '!=')
                  ->execute();

// Attach the field values to the nodes
$ids = array_keys($results['node']);
// Add a default so the filter is optional
$options = array('' => '<select>');

// // Buld the options array based on the query results, overwriting duplicate entries
$query = db_select('node', 'n')
            ->fields('n', array('title'))
            ->condition('n.nid', $ids, 'IN');

$results = $query->execute()->fetchAll();

foreach($results as $id => $node) {
  $value = $node->title;
  $options[$value] = $value;
}

// // Alter the field
$form['title']['#type'] = 'select';
$form['title']['#options'] = $options;
$form['title']['#size'] = 1;
}}

I hope could help someone :)


How can I insert block content between page fields? My page content type has two entity reference types that reference other content types.

Hero
Quotes

The hero displays at the top of the page and I want the Quotes at the bottom of the page.

In between these two pieces of content I have custom blocks and views that I wanted displayed.
How can I have the Hero and the Quotes nodes below other custom content?

Using Template files
You can create a template file .html.twig for your content type or specific node.
Download and enable Twig tweak module:

Twig Tweak module provides a Twig extension with some useful functions
and filters that can improve developer experience.

And then on your twig template put:
{{ content.field_refhero }}

{{ drupal_view('view_name', 'block_1') }}

{{ drupal_block('block_id') }}

{{ content.field_refquotes }}

Alternatively, you could use the following modules
Display Suite

Display Suite allows you to take full control over how your content is
displayed using a drag and drop interface. Arrange your nodes, views,
comments, user data etc. the way you want without having to work your
way through dozens of template files.

Panels

The Panels module allows a site administrator to create customized
layouts for multiple uses. At its core it is a drag and drop content
manager that lets you visually design a layout and place content
within that layout. Integration with other systems allows you to
create nodes that use this, landing pages that use this, and even
override system pages such as taxonomy and the node page so that you
can customize the layout of your site with very fine grained
permissions.


Search for page title I want to search for page name.

I have a title of page news and events. if i search event. i want news and event page will come on search results. when i click on that news-events page will open.

Any idea how to do this?

Take a look at this one: https://www.drupal.org/project/search_by_page

Hope this is what you require.


A module for displaying the author and the title I am quite new to coding and Drupal.
I need to create a module which should display the author name and the title in a tabular view. I am lacking my time to do this task.

Can anyone help me finding a solution?

Like Andy said your best bet is to use Views. I'm afraid with any thing in Drupal there comes a learning curve.

From what I can gather you either want:

a) The username and title of the content your viewing displayed in a tabular view

or

b) A tabular view of all authors and their titles on a single page.

Views will do both of these with some configuration. I can't give you the exact configuration because there isn't enough information but this should get you going.


How add custom node in a View (Nested View)? Currently I have simple view that is used on the main page. In includes nodes of custom type. That's great. But now I need to do something different.

Consider I have following structure:

-----View-----
-------Node 1--------
-------Node 2--------
-------Node 3--------
-------Node 4--------
-----End View-----

But I want to have the structure like that:

-----View-----
-------Node 1--------
-------Node 2--------
-------Node 3--------
---------View Nested in the node ---------
------------Nested Node 1-------------
------------Nested Node 2-------------
---------End Nested View ---------
-------Node 4--------
-----End View-----

So I need nest another view in a top level node.

How can I implement this?

Is there any way to do this using core functionality?
Otherwise I need to change the content of a node before data is passed to a template, but I don't which hook to use?

Please suggest how to deal with this task.

You can use the Views Field View to show the Nested Nodes (that should be a kind of Node Reference)

  There are a lot of cases in views where you want to embed a list
  inside each row. One example could be, you have a list of groups, and
  for each groups you want to list the first and last name of all of
  their members.

For modify the content of a node you can use the template_preprocess_node() maybe you will need to Check content type of node in preprocess hook.


Pathauto: Custom punctuation replacement Instead of having Pathauto replace punctuation in the path alias with a default separator ( dash for example ), or remove it, can we somehow specify a custom input to replace with?

For example, " could be replaced with inches

You can use hook_pathauto_alias_alter().


Organic Groups - How do I set a default role for new group members? I have created a custom group role with some custom permissions and I am trying to find a way to allocate this role to group members by default. Ideally I would like every member of every group to be allocated this role, and be able to remove this role from a user if I no longer want the particular user to have my custom permissions.

I believe OG User Roles had this functionality and user roles were put into core organic groups for 7 but I am not sure if this default roles functionality was also implemented?

I found a solution to this by using og_role_grant within hook_og_membership_insert and hard coding my role in there. This works by granting the role to a user who has just been added as a member of a group.
If I had more time I would create myself a form in the backend so it wouldn't be hard coded but for now this seems to work fine.

function MODULENAME_og_membership_insert(OgMembership $og_membership) {

  if('user' == $og_membership->entity_type && is_numeric($og_membership->etid)){
    $roles = og_roles($og_membership->gid);
    foreach($roles as $key => $value){
      if ('ROLE_NAME' == $value) {
        og_role_grant($og_membership->gid, $og_membership->etid, $key);
      }
    }
  }
}


How to switch from using a theme function into using a template? there's a part of a page that I want to theme, and it's currently themed by a theme function (theme_hook). How do I change it to use a template instead? Does it have something to do with hook_theme_registry_alter?

If it is that hook, I checked the variable passed in hook_theme_registry_alter and I'm not sure what exactly to alter. Do I just add a 'template' key? Or do I have to also unset something? How does it know whether to use a template or theme function anyway?

I'm in Drupal 7 by the way.

As described in the documentation for hook_theme(), the property that you need to provide in order to use a template file instead of calling the theme function is template.

  template: If specified, this theme implementation is a template, and this is the template file without an extension. Do not put .tpl.php on this file; that extension will be added automatically by the default rendering engine (which is PHPTemplate). If 'path', above, is specified, the template should also be in this path.

As you are altering the theme function implemented from another module, you are probably interested in setting also the path property.

  path: Override the path of the file to be used. Ordinarily the module or theme path will be used, but if the file will not be in the default path, include it here. This path should be relative to the Drupal root directory.


How to include a patch to a JS library? I'm using the Superfish library in my Drupal 8.7.x project. I included it in composer.json like this:

 "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        {
            "name": "mehrpadin/superfish",
            "version": "2.1",
            "type": "drupal-library",
            "source": {
                 "url": "https://github.com/amclin/Superfish-for-Drupal.git",
                 "comment": "use amclin because of pull request 29",
                 "type": "git",
                 "reference": "c11a5ac10f8c99f809858c0384a4c415411778ce"
            },
            "require": {
                 "composer/installers": "~1.0"
             }
         }
    ]
.....

Now I found a patch to a problem I have, so I'd like to apply the patch to the JS file automatically. Much like the way I can apply patches to Drupal modules.
Specifically this one:

https://www.drupal.org/files/issues/smallscreen_patch.diff

Any idea how to do that?

As Kevin already mentioned: it can be done using 'composer-patches' in a similar way to patching a Drupal module.

The mentioned patch contained more than I wanted to patch, so I downloaded the patch and added it to a local 'patches' directory. Also, the patch uses a path that starts at 'libraries', while the patch configuration starts one level deeper.

So the patch configuration becomes:

....
patches {
    "mehrpadin/superfish": {
        "Fixed nested UL accordion functionality": "./patches/smallscreen_patch.diff"
    }
}
...

And the patch itself is changed from:

diff --git a/libraries/superfish/sfsmallscreen.js b/libraries/superfish/sfsmallscreen.js
index 9765fed..f5722a9 100644
--- a/libraries/superfish/sfsmallscreen.js
+++ b/libraries/superfish/sfsmallscreen.js

to

diff --git a/superfish/sfsmallscreen.js b/superfish/sfsmallscreen.js
index 9765fed..f5722a9 100644
--- a/superfish/sfsmallscreen.js
+++ b/superfish/sfsmallscreen.js


How to pass custom variables into drush site-install? I'm installing drush profile via:

drush site-install my_profile --db-url=db.url --account-name=admin --account-mail="admin@example.com" --site-mail="admin@example.com" --site-name="My Site"

But how I can pass some variables into my_profile to initialize them with default values?

In example I'd like to set specific file_public_path and file_private_path as some module fails to install because of the folder misconfiguration.

You can add any additional settings you wish to pass to the profile in the following format (the key is in the form [form name].[parameter name]):

drush site-install my_profile install_configure_form.site_default_country=FR my_profile_form.my_settings.key=value
drush site-install my_profile install_configure_form.date_default_timezone="Europe/London" update_notifications.update_status_module=1
drush site-install my_profile variables.file_public_path="sites/default/files" variables.file_private_path="sites/default/private/files"

Then you can handle the variables in your profile code by either implementing hook_install_tasks or hook_install_tasks_alter where you can access $install_state array which have information about the current installation state of your profile and your variables which can be accessed in $install_state['forms'].

In example (when set from drush via variables.X="Y"):

foreach ($install_state['forms']['variables'] as $name => $value) {
  variable_set($name, $value);
}

For file_public_path and file_private_path, it's not enough only to pass the variables, but you should prepare the directories as part of the installation script, e.g.:

file_prepare_directory($install_state['forms']['variables']['file_public_path'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_prepare_directory($install_state['forms']['variables']['file_private_path'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_prepare_directory($install_state['forms']['variables']['file_temporary_path'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
drupal_static_reset('file_get_stream_wrappers'); // clear static cache for stream wrappers

This was implemented in drush as part of Site Install: allow passing additional form parameters feature request.

Please note that above feature it's only supported on Drupal 7 and above.


Change content in page.tpl.php depending on the page I am creating a custom Drupal 7 theme and I have an image slider within page.tpl.php, I want to be able to change the images that it is cycling through depending on what page it is on.

I'm using the Views module with Views Slideshow.

If anyone can point me in the correct direction I will be very thankful.

Cheers,

Luke

As you're already using a View to create your slideshow, could you not simply use an argument to change the View output based on URL? I would need to dig into the specifics of your site to help further, but that seems like the easiest thing to do - no custom functions necessary.


Add an imagestyle to a template twig Im using the Aegan theme, and it uses it's own slideshow. Now I'd like it to use a specific image style, that formats the images according to my presets.

The code in the page.html.twig looks like this

{# Include a slider. #}
  {% if slider %}

        {% for slide in slider %}

            {% if slide.description %}

{{ slide.description | raw }}

            {% endif %}

        {% endfor %}

{% endif %}

The style is called aegan_slide (don't really know where I can find it. But how do I apply my custom style to this code?

If you don't use sub themes of Aegan, you need edit file aegan.theme

Add more use class at top:

use Drupal\image\Entity\ImageStyle;

Replace code line 53->73

if ($slideshow_path && $show_slideshow) {
    $vars['slider'] = array();
    for ($i = 1; $i <= theme_get_setting('slideshow_count', 'aegan'); $i++) {
      $fid = theme_get_setting("slide_image_{$i}", "aegan");
      if (!empty($fid)) {
        $file = \Drupal\file\Entity\File::load($fid[0]);
        $uri = $file->getFileUri();
        $image_path = file_create_url($uri);
      }
      else {
        $image_path = THEME_PATH . "/images/slide-{$i}.jpg";
      }
      $vars['slider'][] = array(
        'name' => !empty($fid) ? $file->getFilename() : "slider-{$i}",
        'url' => theme_get_setting("slide_url_{$i}", "aegan"),
        'src' => $image_path,
        'description' => theme_get_setting("slide_description_{$i}", "aegan"),
      );
    }
  }

with

if ($slideshow_path && $show_slideshow) {
    $vars['slider'] = array();
    //replace large with image style you want
    $image_style = 'large';
    $image = ImageStyle::load($image_style);
    for ($i = 1; $i <= theme_get_setting('slideshow_count', 'aegan'); $i++) {
      $fid = theme_get_setting("slide_image_{$i}", "aegan");
      if (!empty($fid)) {
        $file = \Drupal\file\Entity\File::load($fid[0]);
        $uri = $file->getFileUri();
        $image_path = $image->buildUrl($uri);
      }
      else {
        $image_path = THEME_PATH . "/images/slide-{$i}.jpg";
      }
      $vars['slider'][] = array(
        'name' => !empty($fid) ? $file->getFilename() : "slider-{$i}",
        'url' => theme_get_setting("slide_url_{$i}", "aegan"),
        'src' => $image_path,
        'description' => theme_get_setting("slide_description_{$i}", "aegan"),
      );
    }
  }


How do I configure cron in Drupal 6 In my GoDaddy control panel I have scheduled it to run this script every day:
/web/cgi-bin/php5 "$HOME/html/my_site/cron.php

However I cant figure out how I create tasks that will be run when cron.php is run. I have gone through all the documentation and can't find this anywhere (The D6 video tutorial link seems to be down).

For example how would a go about deleting the contents of a temporary folder?. Do I just add some PHP using the unlink command to the cron.php (in which case drupal is not really involved) or is there some setting page that I havent discovered that allows you to create tasks?

Use hook_cron, and implement your functionality in it. This functionality will get executed when the server will ping cron.php.

You just need to set specific time period on which cron will be executed.


How does the Search synonyms module work? I've just activated the search synonyms module for D7, but I don't get how it works at all. Where do I set synonyms, I've tried editing forms or check the settings, but I can't find any new input where synonyms could be added. Also I could not find any documentation for the module. Probably me overlooking things but some help would be greatly appreciated.

Jasper, I had a look at the code in the module. There is only one function in the module, and I don't think the module does what is says in the description on the Drupal project page.


How to stop redirecting to newest URL after updating a node I have setup 2 aliases for each node of a content type called "property". The first alias is like example.com/texas/village-apartments and the second is example.com/texas/corp/village-apartments.

When you go to the second URL (the one with "corp") you see different pieces of information on the page, different buttons, menus and other items that do not really belong on a non-corp page.

Pathauto handles creating the first alias (without "corp"), then I manually created the corp aliases by going to admin/config/search/path/add and added each one.

This all works fine except for when I go to edit the node and add text or a picture or whatever. When I click save, I am redirected to the URL with corp and of course see different menus, blocks, etc.

Is there any way to configure things so that I am redirected back to the same URL path I was on when I clicked 'edit'?

Tim

There's no easy way. You might have to make your own module with code something like this:

function mymodule_node_presave(){
  $GLOBAL['dont_redirect']=true;
}
function mymodule_drupal_goto_alter(&$path){
  if ($GLOBAL['dont_redirect']==true){
    $path = "";
  }
}


How are field tables named? I am looking at my Drupal 7 database, and I think that I see the following pattern:

Fields that are defined programmatically are stored in tables named field_data_fieldname
Fields that are defined via the UI are named field_data_field_fieldname.

I don't find this convention documented anywhere. Did I take it right?

Any field created with the core Field UI module has its name prefixed with field_.
Any field created programmatically is named exactly as the module creating it wishes, without the prefix.
The field data tables are named directly from the field names

Yes, you have it absolutely right.

It's worth noting that the data is also stored in field_revision_foo, regardless of whether you're using revisions or not. The field_data_foo tables will always contain the most up-to-date data whether revisions are enabled or not.


Multisite or multiple sites setup with Open ID server I am working on a project where I have a basic site with a sets of modules and configurations. Currently when I get a new client for this project in order for him/her to use their own site, I setup a subdomain, load a basic DB and copy the basic site files over.

This setup has work for me, but now I am having to deal with more clients and the manual process will just make it hard to manage and maintain. Ideally I will love to have it a single set of files will connect each user DB and I don't care if instead of subdomains (they are nicer) I have to use sub-directories.

What will be best for this setup multisite or multiple sites, and will it make sense to have a centralize account (open id) server?

  Note: I was thinking in register the users in a single place and then they can login into their private sites using this centralize
  account system. Otherwise each site will have to have a user 1 account
  with a password to be manage for each site.

Thank you

I think multisite would work well if you're keeping all of the same code.  I know you can do it with subdomains (or even completely different domains) using the sites.php file, I'm not so sure about sub-directories.

Have a look at the Features module which will allow you to import all of your standard settings as a single module on new sites.


Show menu items with limit access to anonymous users I have a website that uses Private module in order set the access to the content, and of course some of my pages have menu items. Now if I set a page to be private, only users with proper permission could see that, which is great and what I wanted.

But I am having a bit of issue with the menu items, they disappear if the content assigned to them are not public (ie the page assigned to them is Private), this is OK but I would like to be able to still show those items in the navigation, so if user clicks on them, it will take them to the login page asking them to enter their details in order to see that particular page.

So basically I would like to change the behavior of the menu items the way that they will always be visible to anonymous and registered members of the website but when you click on them, you will be either able to see the page (if you are logged in) or be redirected to the login page (if anonymous)

I found this solution which is not the best one for me since I have many pages like that so I am looking for a better approach. I have even tried Menu item visibility module but that didn't help either!

How do I achieve this please?

Luca

Your problem is quite common.

Here is discussion how to implement such trick in Drupal 6 and 7 and 8: http://drupal.org/node/300607

  Drupal 6 (and 7) removed the ability to display menu items the user doesn't have access to. However, in some cases it is desirable to show a menu item even though the user doesn't have access to the menu item. For example, if you use an authentication mechanism that tries to acquire authentication when a 403 would be displayed, you still want to display the menu item so that users get a chance to provide credentials to log in.

Solution for Drupal 7 can be found here: http://drupal.org/node/300607#comment-4450062

If you prefer ready module - you can download it here https://github.com/systemseed/always_visible


Front page as link in Views This is pretty straight forward. How do I print a link to the homepage as field in Views?

I have added a global text field with html code Home but this is just the path to the root & my website is installed in a subdomain.

Using D7 and latest Views module.

it should work this way:

create the global text field, with the text as the link text -

then rewrite the results, and output as a link using <front> as the path -


Composer generated installation can't be completely cloned I have a Drupal 8 installation where I removed all Composer generated folders from the root .gitignore, so that I can make a complete clone of the installation. The problem is that module folders which contain a .git folder themselves remain empty in the cloned folder. What am I missing?

This is perfectly explain on https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md

In short, that's because git kind of treats folders with a .git as submodules.

The composer.lock file exists to be able to re-install an exact copy with the same commits of dependencies and so on. Or another option is building .tar.gz, containers or similar packages that can be used for efficient deployments.


How do I manage a mix of menu and custom breadcrumbs? I have a site where I need breadcrumbs to be generated in a couple of different ways:

Based on the menu path (Menu Breadcrumb)
Based on custom rules (was thinking Custom Breadcrumb but it doesnt exist anymore)

How can I effectively enable breadcrumb rules for nodes that I don't want Menu Breadcrumb to control? Do I have to create my own Breadcrumb builder class? Can I blow away $breadcrumb in hook_system_breadcrumb_alter and do new Breadcrumb() to do exactly what I want?

Do I have to create my own Breadcrumb builder class?

Yes, there are many places where you can modify breadcrumbs, but this is the only straightforward way. The custom breadcrumbs should have a priority higher than 1010 (the priority of the breadcrumb builder of Menu Breadcrumbs), so that nodes that follow rules you put in applies() of the BreadCrumbBuilder class can't be controlled by Menu Breadcrumbs.

  How do I set the priority (asked in the comments)?

The priority is set in the service definition, example from the Menu Breadcrumb module:

menu_breadcrumb.services.yml:

services:
  menu_breadcrumb.breadcrumb.default:
    class: Drupal\menu_breadcrumb\MenuBasedBreadcrumbBuilder
    arguments: ['@config.factory', '@menu.active_trail', '@plugin.manager.menu.link', '@router.admin_context', '@title_resolver', '@request_stack', '@language_manager', '@entity_type.manager']
    tags:
      # The priority must be higher than core taxonomy builder (priority: 1002)
      # see https://www.drupal.org/node/1495510
      - { name: breadcrumb_builder, priority: 1010 }

(which is also where you have to look when you want to override an existing breadcrumb builder, you can see here what was considered concerning the taxonomy breadcrumbs)


Accessing fields in views twig template I've got a content type article. I display them on a view blog.

I'm customising the display via views-view-fields--blog.html.twig. I'd like to display the author and date fields (they are configured in the view). The other fields display fine, but how do I access those two?

    {{ fields.field_image.content }}

        Posted by {{ ??? }} | {{ ??? }}

{{ fields.title.content }}

{{ fields.body.content }}

I've added both node created and node changed fields to my views before, this is how I output them:

Date Created: {{ fields.created.content }}
Date Modified: {{ fields.changed.content }}

I assume user would work the same way. It will render in whatever way the view field is configured.

For example: {{ fields.uid.content }}


Formatting looks OK in input field using CKEditor but does not appear on page when published Formatting looks OK in input field using CKEditor  but does not appear on page when published?

CKEditor is installed and working OK    but the formatting is not applied to the published text

anything obvious I might be missing ?

If CKEditor is applying the styles correctly but the display of these styles is not showing up after a save, I think you may need to check out the 'Text format' you're using for that CKEditor profile.  It should appear directly under the CKEditor in a drop-down.

After you see which text format you're using, check the configurations of that particular text format here: <your site>/admin/config/content/formats.

Make sure, when you check the settings, that the 'Limit allowed HTML tags' checkbox isn't checked, which may not allow certain html tags to be displayed.  Look through all the options there and make sure there isn't something else that could be messing up your display.

Let us know if text formats end up being the issue.


Drupal Multilingual Emails We have a multilingual website set up and functioning fine.  The next step was to setup translations for the default Drupal account emails (e.g. Welcome, Account activation, Account blocked etc).  This is also done - and our client can go in and add translations for each of these.

The issue is - the client is asking; seeing as these are default Drupal emails, have the translations already be done for each language?

We have the l10n_update module pulling down translate updates to core and each module - but the account emails are not receiving translates.

Does any one know if these emails have already been translated? Can anyone provide some insight? We've searched and haven't come across anything

thanks

If you installed the Internationalization Module, you should have a sub-module called "Variable translation". If enabled, go to admin/config/regional/i18n/variable and choose the variables which you would like to translate.

In your case this would be the ones in the "User Emails" tab. Once checked and activated go to the user e-mail page (admin/config/people/accounts) and click on the different language links at the top of the page to translate.


Is there any way to clone a content type My site has a lot of different content types, they all have the same fields, the only difference is the name of the content type. Is there any way to clone those content types other than create them one by one. Thanks.

No need to clone content type. I had the same issue but I handled it this way, create all of the common fields and then create one more extra field of type list and you can call it Field Type, this field is a list of content types. When you are entering content, you only need to select an item from list to distinct among content types.


How to fetch manual flate rate token on replacement pattern How to fetch manual flate rate token on replacement pattern

I added Flate Rate cost manually on orders, but I don't find this token on REPLACEMENT PATTERNS. How to fetch this token for my invoice?

here screenshot that I did

You would need to two things to make this happen:

How to programmatically create a custom token. And you'll definitely want to read the API docs on the relevant hook function.
How to get at the line item given an order.

Let's assume your token has an $order object inside the $data variable. The next step would be to use entity metadata wrappers to pull in all the information, including line items.

<?php
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
  $line_item = $line_item_wrapper->value();
}
?>

Your shipping line item is in there. dpm($line_item); to find it and then construct your token output.


how to use an entity query to make a sortable table I need to use an entity query such as this:

$query = \Drupal::entityQuery('node')
->condition('type', 'blog_post')
->sort('field');

$nids = $query->execute();

to make a table that is sortable in a custom module .  I found instructions on how to do this with a normal query , (below) how can I make this work for this entity query

  $header = array(
  // We make it sortable by name.
  array('data' => $this->t('Name'), 'field' => 'name', 'sort' => 'asc'),
  array('data' => $this->t('Content')),
);

$db = \Drupal::database();
$query = $db->select('config','c');
$query->fields('c', array('name'));
// The actual action of sorting the rows is here.
$table_sort = $query->extend('Drupal\Core\Database\Query\TableSortExtender')
                    ->orderByHeader($header);
// Limit the rows to 20 for each page.
$pager = $table_sort->extend('Drupal\Core\Database\Query\PagerSelectExtender')
                    ->limit(20);
$result = $pager->execute();

// Populate the rows.
$rows = array();
foreach($result as $row) {
  $rows[] = array('data' => array(
    'name' => $row->name,
    'content' => '[BLOB]', // This hardcoded [BLOB] is just for display purpose only.
  ));
}

// The table description.
$build = array(
  '#markup' => t('List of All Configurations')
);

// Generate the table.
$build['config_table'] = array(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $rows,
);

// Finally add the pager.
$build['pager'] = array(
  '#type' => 'pager'
);

return $build;

}
}

EntityQuery doesn't appear to have the extend() function that this example relies on, so much of what's happening in the example will need to be done manually.

You can get the sort parameters from the request object

$sort_field = \Drupal::request()->query->get('order');
$sort_order = \Drupal::request()->query->get('sort');

With those, you can update your query to something like.

$query = \Drupal::entityQuery('node')
  ->condition('type', 'blog_post')
  ->sort($sort_field, $sort_direction);
$nids = $query->execute();
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);

Then use $nodes to build your $rows array as in the example.


Tabs: invalidating cache tags does not lead to a rebuild of the tabs I have a custom route defined with a custom access check. Apart from some more checks one of the rules for accessing the path is that a specific custom entity exists. The access check does the following:
  public function access(AccountInterface $account) {
    if ($entity_does_not_exist) {
      return AccessResult::forbidden()->addCacheTags(['my_unique_cache_tag']);
    }
  }

In my custom entity class I defined the postSave and postDelete methods to invalidate this tag every time an entity is created or deleted:
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage, $entities);
    foreach ($entities as $entity) {
      \Drupal::cache('render')->invalidate('my_unique_cache_tag');
    }
  }

  public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);

    if (!$update) {
      \Drupal::cache('render')->invalidate(ParliamentPeriodCCController::getCacheTag('my_unique_cache_tag');
    }
  }

My problem is that my custom route is used as a secondary tab in my_module.links.task.yml. What I found out so far is that the tabs are rendered in a block which really gets my unique cache tag (as I see in cache_render table - this is why I defined  \Drupal::cache('render') above - \Drupal::cache() did not work neither) but it seems it never gets invalidated. When I enter a page where the secondary tab was not created because no entity exists it is still not shown when I create the entity afterwards. But when I delete the entry for the block from cache_render it is rendered correctly.

Two suggestions to improve caching:

Even if you don't want to make a decision to allow or deny access you can return a neutral result to add cache metadata.

The custom cache tag can be replaced by the list tag ENTITY_TYPE_list, which is invalidated automatically when entities are added or deleted.

The resulting code:
  public function access(AccountInterface $account) {
    if ($entity_does_not_exist) {
      return AccessResult::forbidden()->addCacheTags(['my_entity_list']);
    }
    return AccessResult::neutral()->addCacheTags(['my_entity_list']);
  }

postDelete() and postSave() are no longer necessary.


How do I get the public file URI for a media file from jsonapi? I have an audio file that is stored as Media of type Audio.
Now I want to get the link to that file that is usually displayed to site users via jsonapi.
For example, when the media entity is rendered, this is the link:
<audio controls="" controlslist="nodownload"> <source src="/sites/default/files/coolstuff/audio/apples-bananas-pears.mp3" type="audio/mpeg"> </audio>

This /sites/default/files/coolstuff/audio/apples-bananas-pears.mp3 path is what I want to get from jsonapi.
However, when I look at the output of /jsonapi/media/audio, all the URLs look like this:
http://mysite.com/jsonapi/media/audio/d741b59c-9617-4a24-a2e8-99005a76507b?resourceVersion=id%3A31"

None of them have the public-facing URI.
The documentation gives this example for a "article media entity reference field_image url, uri by including references":
http://example.com/jsonapi/node/article/{{article_uuid}}?include=field_image&fields[file--file]=uri,url

I have media entity references, so I tried the same on my site:
http://mysite.com/jsonapi/node/MY_CONTENT_TYPE?include=field_ref_media_audio&fields[file--file]=uri,url

However, I do not get the regular media URI, just the jsonapi one.
How can I get the media public file URI (/sites/default/files/coolstuff/audio/apples-bananas-pears.mp3)?

Here's the correct path:
http://mysite.com/jsonapi/node/MY_CONTENT_TYPE?include=field_ref_media_audio.field_media_audio_file&fields[file--file]=uri,url

This results in a value for uri such as:
"value": "public:/sites/default/files/coolstuff/audio/apples-bananas-pears.mp3",


Assign role based on purchased products I'm using the Drupal Commerce, Checkout redirect and Auto assign role modules.

When a checkout is completed by an anonymous user on a Drupal Commerce website a Drupal account will be created.

If there is only one product everything is ok, but what happen when there are many products?

How can I make it so that:

If a user buys "Product 1" I will be auto-assing a role "Role 1"
If a user buys "Product 2" I will be auto-assing a role "Role 2"

Could anyone solve this question?

I needed something similar: user purchased an item (points) and depending on the purchased product a value (points) should be added to the user profile. The rule below is ready to accept (loop through) multiple products/lineItems. In my case I only need the first one:

 "value" : [ "commerce-order:commerce-line-items:0:line-item-id" ],
        "limit" : "1"

First I fetch the purchased products (line items) by property (line_item_id). The result is an array (list of purchased products).

Next you need to loop through this array/list and add the desired action to the individual/current purchased product. If you need a condition (product 1 -> role 1) you can use conditional rules. It is an awesome rules addon that lets you insert IF conditions within loops (so you dont have to create a component that checks the product).

{ "rules_purchasing_points" : {
"LABEL" : "PURCHASE Points",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_payment" ],
"ON" : { "commerce_payment_order_paid_in_full" : [] },
"DO" : [
  { "entity_query" : {
      "USING" : {
        "type" : "commerce_line_item",
        "property" : "line_item_id",
        "value" : [ "commerce-order:commerce-line-items:0:line-item-id" ],
        "limit" : "1"
      },
      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
    }
  },
  { "LOOP" : {
      "USING" : { "list" : [ "entity-fetched" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "data_convert" : {
            "USING" : { "type" : "decimal", "value" : [ "list-item:line-item-label" ] },
            "PROVIDE" : { "conversion_result" : { "conversion_result" : "Conversion result" } }
          }
        },
        { "component_rules_set_points" : {
            "recipient" : [ "site:current-user" ],
            "sender" : "1",
            "points" : [ "conversion-result" ]
          }
        },


What module name do I use for drush dl? I'm trying to install the Delete All module on Drupal 7 via Drush, but whenever I type drush dl delete-all I get the following error:

  No release history was found for the requested project (delete-all). [warning]

I thought it might have been related to case sensitivity, but trying other names like Delete-All and DeleteAll gave me the same error. Is there anything I'm doing wrong here, or is something wrong with my installation of Drush/Drupal?

Try:

drush dl delete_all

You have to check the project URL:

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

And use the last part, the project machine name.

The delete-all string is the drush command provided by this module.


Include referenced term's custom fields in node view with content display I have a taxonomy term reference field in a node (D8).

I have a content (node) view that needs to use a content display rather than fields.

The term is selected, but not the custom fields that have been added to the vocabulary (see the query, below).

The display settings for the vocabulary have all the fields being displayed.

I thought perhaps there was a relationship that I could add that would result in the fields being selected. The only applicable option is for Taxonomy term, which I have added. It results in the taxonomy_term_field_data being joined, but not the custom fields.

Do I actually need to hook the query before execution to add joins for the additional fields?

SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, taxonomy_term_field_data_node__field_tags.tid AS taxonomy_term_field_data_node__field_tags_tid
FROM
{node_field_data} node_field_data
LEFT JOIN {node__field_tags} node__field_tags ON node_field_data.nid = node__field_tags.entity_id AND (node__field_tags.deleted = '0' AND node__field_tags.langcode = node_field_data.langcode)
LEFT JOIN {taxonomy_term_field_data} taxonomy_term_field_data_node__field_tags ON node__field_tags.field_tags_target_id = taxonomy_term_field_data_node__field_tags.tid
WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('article'))
ORDER BY node_field_data_created DESC
LIMIT 1 OFFSET 0

The Default Content View mode is controlled through the Manage display page of the related Content Type.
Check that page and make sure that the Taxonomy Term reference field is set to Rendered entity and not Label or some other option.
The Rendered entity option will make sure that all the Vocabulary fields set to be displayed for terms will also appear under Content rendering of the Content type.


Making new variable for a theme function shows an error notice I am trying to make a new variable for a theme whose name is ntheme. I have defined the following function in template.php.

function ntheme_gnu_preprocess(&$variables) {
  $variables['disclaimer'] = t('Comments are unaythorized. The views expressed are those of the comment author.');
}

I used $disclaimer in the comment-wrapper.tpl.php template file.

<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if ($content['comments'] && $node->type != 'forum'): ?>
    <?php print render($title_prefix); ?>

<?php print t('Comments'); ?>

    <?php print render($title_suffix); ?>
  <?php endif; ?>
  <?php print render($content['comments']); ?>
  <?php if ($content['comment_form']): ?>

<?php print t('Add new comment'); ?>

    <?php print render($content['comment_form']); ?>
  <?php endif; ?>

<?php print $disclaimer; ?>

I get the following warning.

  Notice: Undefined variable: disclaimer in include() (line 39 of C:\wamp\www\drupal\sites\all\themes\ntheme\templates\comment-wrapper.tpl.php).

What am I doing wrong?

You should use THEME_preprocess_comment_wrapper(&$variables) to alter comment wrapper variables.


Formatting text below an image I'm a total newbie. I'm building a site which includes images, such as photographs, with text captions under them.

Recently (?!), some of these text captions have broken and slipped, with the first words appearing to the left of the image and the rest still below it where they should be. I've tried monkeying with the margin width, but that doesn't seem to be the problem.

Any clues?

There are many possible reasons how the code wound up being like that. If you could remove the inline styles for margins, height and width and instead add the class "img-responsive" to the image it would render in a more "standard" and expected way on the page. Alternatively you could add

width: 100%; height: auto;

to the inline style, but that would only be a "emergency" solution and not be considered good practice.

However it would probably be best to cleanup the markup so that the caption lives in a div or span with a class name of caption. Why are you not making use of the default caption option in Drupal? If you look at or install a "clean" version of Drupal 8 and create an article and add an image you can see how the caption works. It generates this markup:

This is my nice caption


How to let user create entity objects I am in learning phase of Drupal and ofcourse the Entity API. I have created new entity named Projects. Goal is to make a project management system for software services providers. I am actually trying to figuring out the mechanism for workflow. I have a entity now. How would i let the user with role Manager add a new project and a user with role Developer can add updates to it like status, files attachment etc.

I need a basic overview so that i can use Drupal to build application rather than a content based website.

Thanks alot

First off, we should define CRUD permissions for your entities in a correct manner. We will have to implement hook_permssion to define each of our crud permissions similar to the following:

function myentitymodule_permission() {
  return array(
    'view my entity' => array(
      'title' => t('View my custom entity'),
    ),
    'create my entity' => array(
      'title' => t('Create my custom entity'),
    ),
    'edit my entity' => array(
      'title' => t('Edit my custom entity'),
    ),
    'delete my entity' => array(
      'title' => t('Delete my custom entity'),
    ),
  );
}

The implementation of these newly created permissions should reside in your hook_menu implementation that is responsible for creating the CRUD pages you need.

function myentitymodule_menu() {
  $items = array();
  $items['my-entity/add'] = array(
    'title' => 'Add my new custom entity',
    'page callback' => 'myentitymodule_add_page',
    'access arguments' => array('create my entity'),
  );
  $items['my-entity/%entityid'] = array(
    'title callback' => 'myentitymodule_page_title',
    'title arguments' => array(1),
    'page callback' => 'myentitymodule_page_view',
    'page arguments' => array(1),
    'access arguments' => array('view my entity'),
  );
  $items['my-entity/%entityid/view'] = array(
    'title' => 'View',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['my-entity/%entityid/edit'] = array(
    'title' => 'Edit',
    'page callback' => 'myentitymodule_page_edit',
    'page arguments' => array(1),
    'access arguments' => array('edit my entity'),
    'weight' => 0,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );
  $items['my-entity/%entityid/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('myentitymodule_delete_confirm'),
    'access arguments' => array('delete my entity'),
    'weight' => 1,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_INLINE,
  );

  return $items;
}

Notice the "access arguments" key of each new page defined in the above function need the array keys of your hook_permission implementation. Please note that you will have to create appropriate page callbacks that (should) reside in inc files in order to do things like render the entity view page and render the creation, edit and deletion pages. These callbacks should (at least) take the ID of the entity as an argument.

If we were to compare your custom entity to that of the node entity, the ID that is used for nodes is the nid. That's why pages like node/321/edit exist and use "321" as that ID argument. I think you want to accomplish more or less the same thing.


Allow user to change term, for views and taxonomy I have a view which displays a content type in a grid and is working fine.

The content type has a taxonomy field - so when a node is created the user selects a taxonomy term from a list (Hierarchy) - it is then displayed on the node once posted.

In my view I have added 'Content: Has taxonomy term' under 'Filter criteria' but i'm not sure how to get it to work. On the block the user sees I would like them to be able to type a term into an auto complete field which will then change the content which is displayed in the view. I have chosen 'Auto Complete' as the selection type in my filter criteria section and I have ticked the box which says 'Expose this filter to visitors'. The view is working and is displaying content but there is no option presented to the user to change the filter term.

How can I do this please?

Thanks

You've done everything right. However, there's a kind of a usability problem with Views, Blocks and Exposed Filters. You can include the exposed filters within the views block by editing the View, then changing "Use AJAX" to yes. Specifically:

Advanced > Other > Use AJAX: Yes


custom module to display content (nodes and fields) from another database we are trying to somehow show fields from nodes existing in a different drupal database than the default.
Eg. in the site the module is installed (drupal2) we have the following settings.php

$databases = array (
  'drupal1db' =>
  array (
    'default' =>
    array (
      'database' => 'drupal1db',
....
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'drupal2db',
...

is there a way to override views so that it displays content with specific type "eg news" from the drupal1db and/or from both the databases?

Thank you

Absolutely you can use a different db for a view. First create a custom module use hook_views_data() in a .views.inc file to define the fields of the external db. Once you have defined the fields and cleared the cache you will be able to select a different base table for your view.

With some custom coding and db_set_active() or views relationships you should be able to use both.

EDIT: Assuming Drupal 7.


How to render translated node body in two languages? I use entity_translation to translate node body field, so in a fully loaded node object body is an array of 2 languages ('en' and 'ru').

For specific node type I would like to render body in both languages one after another:

  Russian version of node body

  English version of node body

so switching between translations will not be needed.

What hook can I use to achieve this?

In implementation of hook_node_load() body is an array of 2 languages, but in hook_node_view_alter() body already contains only the current language value.

When using node_load() in hook_preprocess_node, it retrieves the node object from cache and its body has only one (current) language value.

I found a solution: call field_attach_view with the required language.

/**
 * Implements hook_preprocess_node().
 */
function MYMODULE_preprocess_node(&$vars) {
  if ($GLOBALS['language']->language == 'ru') {
    $original_langcode = 'en';
    $content_original = field_attach_view('node', $vars['node'], $vars['view_mode'], $original_langcode);

    // need to check if languages match, it may be a language fallback
    if ($content_original['body']['#language'] == $original_langcode) {
      $vars['content']['body_original'] = $content_original['body']
    }
  }
}


DrupalGap response is HTML instead of JSON I want to build a restful service to communicate with my Android app.

System: Drupal Commons with Drupal 6
Module for restful service: DrupalGap
Test tool: Poster plugin for Firefox

I do everything like in the tutorial from Tyler, but I got my login screen as HTML, instead of correct login; I can't get the system connect states as anonymous user. If I am already logged in so the login functionality says "you alread logged in" and the system connect state shows correct data.
The Views module has a setting to enable "Views API Mode" to wrap JSON in HTML, but this setting is disabled and so this can't be problem.

Does anybody know a solution for my problem?

If I follow the installation instructions for DrupalGap on a fresh Drupal 6 site, everything works out of the box. I can also access the DrupalGap demo site.

We found the solution for our problem.
Under admin -> settings -> commons uncheck the box "Force users to login".
Now it is possible to get json responses from connect and login actions.


Get/modify taxonomy term info in node edit form field? How do I modify the taxonomy terms that are listed as a field in my Node edit form?

I need to be able to hide/unpublish/disable my taxonomy terms.  Since there is no way to "unpublish" taxonomy terms the way you can unpublish a node, I have created a boolean field in my taxonomy term that holds its status (enabled/disabled).

I would like to use the value of this boolean field to determine whether or not to add a warning text in the taxonomy term name (eg. Termname [DISABLED]) so that users choosing that taxonomy term are properly warned.

If it matters, I'm currently using the select list widget.

I know I can look up each term in hook_field_widget_options_select_form_alter since the tids and term names are available in the $element, but I hope there is a solution which won't require me to re-load/re-fetch the term from the database again.

I know I can look up each term in
  hook_field_widget_options_select_form_alter since the tids and term
  names are available in the $element, but I hope there is a solution
  which won't require me to re-load/re-fetch the term from the database
  again.

Unfortunately I think you will have to load them again and do the hook_field_widget_options_select_form_alter. There are a lot of functions to load taxonomy information which might be helpful and some of those probably have caches and were used in building the node form so the cache is already primed.

Is your concern around performance or code complexity?


Issues with updating modules on Drupal 7 I have a Drupal 7 website that I upgraded from Drupal 6 awhile ago. I am trying to upgrade some of the modules that have had updates since then, but I am having issues doing so. When I click the "Continue" button on the "ready to update" screen, I receive the following unformatted text on a blank white background:

  Installing updates

  Status message

  Operating in maintenance mode.Go online.

The url of the page is example.com/authorize.php?batch=1&op=start&id=4206

I checked the error logs in Drupal, and there are a few errors reports:

  Notice: Undefined variable: finished in _batch_process() (line 344 of
  /home/mysite/public_html/includes/batch.inc).

  Notice: Undefined variable: old_set in _batch_process() (line 339 of
  /home/mysite/public_html/includes/batch.inc).

  Notice: Undefinedvariable: old_set in _batch_process() (line 338 of
  /home/mysite/public_html/includes/batch.inc).

  Notice: Undefined
  variable: old_set in _batch_process() (line 337 of
  /home/mysite/public_html/includes/batch.inc).

  Notice: Undefined index:
  init_message in _batch_progress_page_js() (line 136 of
  /home/mysite/public_html/includes/batch.inc).

  Notice: Undefined index:
  error_message in _batch_progress_page_js() (line 135 of
  /home/mysite/public_html/includes/batch.inc).

  Notice: Undefined index:
  title in _batch_progress_page_js() (line 127 of
  /home/mysite/public_html/includes/batch.inc).

Any ideas on what might be causing this and how I an fix it?

I have encounted this in the past and usually you get a module that causes an issue with AJAX.

What I would suggest is to update modules manually (download from drupal.org, extract and upload then run update.php) or via drush one by one.

If you are doing multiple modules at once this can happen quite often.

Also make sure you have Overlay module disabled as for some odd reason this can cause the same error.

Your best bet is to update modules one by one to isolate which module is causing the issue.


Bulk update got slower after conversion of database tables to InnoDB After I converted the database tables to InnoDB engine from MyISAM, I noticed some operations became very slow, especially on updating multiple nodes in bulk for administrative work. Front end performance seems to be good.

I have tried configuration settings suggested in these articles without any luck: MySQL > YourSQL, and MySQL Performance Blog.

My test script would load 25 different nodes (node_load()) and save them right away (node_save()) in a loop. This script runs for 2 seconds on the server with MyISAM engine; after DB conversion to InnoDB, it now takes 13 seconds.

It also takes much longer to restore InnoDB database from a SQL dump of 500MB; 20 minutes (InnoDB) vs. 2 minutes (MyISAM).

Is this what I should expect from InnoDB engine?

New to InnoDB engine, I'd like to know what I might still be missing in configuring and optimizing InnoDB.

Thanks for the nice tips. I tried most of the suggested InnoDB tuning tips and it was not enough to remedy my problem.

Here is how I was able to fix my issue. This may be a special case that is isolated to my situation, but I hope that this could help other developers who are in a similar situation.

When I ran node_save() in a loop with 25 different nodes, it took 2 seconds with MyISAM and 13 seconds with InnoDB.

I captured 80 some database queries generated by node_save() in a single loop. Some of them came from running node_load(), which is needed before node_save(). I used devel module's feature of database query info collection. I put the queries side by side. The same queries from InnoDB were slightly faster than MyISAM especially for simple SELECT queries, which took majority portion of all queries.

I identified an INSERT query from InnoDB side that took more than a 0.5 second when total 80 queries took 0.6 second. The query was from notifications module, whose hook implementation was fired every time a node was saved.

I narrowed it down to the table notifications_fields in the query and decided to create an index on the table for the column value. And that made all the difference. After creating an index on value, saving 25 nodes now took only 0.2 seconds (down from 13 seconds), even ten times faster than MyISAM's! (BTW, creating index on MyISAM table also made it run ten times faster than before)

In this case, I have to admit that InnoDB's under performance gave clue to find out that an index was needed. I would not have found out about the index with MyISAM because it was relatively fast enough to hide the situation.

There have been several cases like this that adding indexes improved site performance quite a lot. However, actual application and result from it can differ in different sites. Back to my case with notifications_fields table, adding another index on field column -- hoping to strech performance boost -- ruined the effect and actually made it slow again. So one needs to be careful with adding indexes and understand that one fix on a site may not work the same way on another site.


Cron Run resulted in Fatal Error Message Using Drupal 6.22
PHP 5.2.17
PHP memory limit - 150M

Last time I ran Cron was 2 weeks 19 hours ago

I am experiencing no errors with the site but opted to run Cron manually and received the following error message

Fatal error: Allowed memory size of 157286400 bytes exhausted (tried to allocate 7680 bytes) in /home4/xxx/public_html/xxx/includes/theme.inc on line 1078

Is this an error message I need to be concerned about?
If yes, How do I fix it?
And...Is running Cron a necessity, if the site is functioning fine everywhere else.

Whatever cron is doing, you'll need to allow it more memory for it to succeed. You can find out about increasing PHP's memory_limit at http://drupal.org/node/207036

However, it looks like you already have memory_limit set to a high value for a small site.


New line item every time an item is added (avoid grouping) How can I avoid grouping of the same items (products configured identically) to be grouped in the same line item with a quantity count?

I want every single item, even if an identical already exists in the cart, to be its own line item with its own ID.

I tried several rules that fire when a new product is added to cart, when a line item is updated, tried duplicating, re-adding... even tried a timestamp field which would be different for every time a user adds an item, which should result in a new line item being created - but this is just too much of a hack for me.

Is there any clean way to create a new line item for every item in the cart?

You can just toggle the setting on your Add to Cart form display formatter to turn off combining like items in the cart.


help me understand the drupal way to develop this module Coming from a pure HTML, JS, PHP background to drupal 7.x has been a tough transistion, currently I have some code that I would normally use pure JS/PHP to code but I want to make this section managable through the drupal CMS and I'm not totally sure how I would do this. I believe I should be creating a module, but I don't understand how I would create the admin interfaces.

The end result should be structured like this:

The admin can create 1 or more sessions all of which will be displayed in a drop down.
Each session will have 1 or more topic listed once selected
Each topic will have 1 or more files listed under it

For example:

Session 1

Topic 1

File 1
File 2

Topic 2

File 1

Session 2

Topic 1

File 1

So assuming I create a module and have that module display the data how then do I create the admin page the will allow a user to create 1 or more sessions, with 1 or more topics under each and 1 or more files per topic per session. In pure JS and PHP this is pretty simple and straight forward, in Drupal hell it doesn't seem so easy :(

Yes it would be easier to develop as you have in your example. To make it so that anyone can update let's try to do it a Drupal way. This way may not be the quickest/easiest but it will give you an idea of Drupal and make it easy to update the content.

There are many distros that help make Drupal easier I would suggest Panopoly to start with. Or you can use core and install the modules as you go (I will probably miss several modules that I am just really used to always being there that are actually contrib).

1. Custom Content Type
Create a 'sessions' CT and add the fields and fieldset that you need i.e. 'Read it' and 'Do it'. You can use file fields and field_collections.

2. Create View Use the Views module to create a view of Content Type: 'sessions'. You can create an exposed filter for the drop down.

3. Create a Basic Page and add the view block to it (personal preference to suggest views block and not views page for expandability, etc.).

No code this way all GUI. The user would just have to create new content of this type and it would appear on the page.

Tip: Use Features to save your work and provide an exportable default.


How do I add the number of rows shown in a view to a menu link? I want to add the number of rows shown in a view to a menu link, something as follows, for example.

  Companies(29) | Products(152) | Customers(522) | Orders(9888) ..

How can I achieve this?

You can do this with a view, assuming each item is a content type.

Create a new view of Content as an unformatted list of fields. Under 'Advanced' set Use Aggregation to Yes.

Under fields delete the title field, and add Content:Type and Content:NID.

Configure the Content:Type field as no label and "group by" under Aggregation Settings. Under 'Rewrite Results' check 'Output this field as a link', set it to replace spaces with dashes and to convert to lower case. In the path enter something like "list/[type]", depending on your desired target.

Configure the Content:NID field as no label, and add the prefic " (" and the suffix")". Set it to 'Count' under Aggregation Settings.

Use CSS to have both fields float:left; to line them up.

You can leave the view unsorted or sort by Content:NID->COUNT or by Content:Type. You should leave the filter for Published nodes, and you can add a filter to restrict the content types which will appear.

Then place the block where you want the menu to appear.


Unable to edit body field One of my content editors reported having trouble editing

However, I have allowed this group to edit any content of this node type.

I'm not seeing any separate permissions for fields. How might I over come this?

You also need to grant permissions for the text format that the body field is using, e.g.


Reusing a node form in a separate page I have a module, and I want to have a page defined in hook_menu, that shows the add form for a specific content type, with some modifications to the form.

So far it's working, and even saving the new node, but only with the default values I'm setting in the code, i.e. it's not picking up anything the user types into the form. I checked and $form_state['input'] contains the inputted values, but $form_state['values'] doesn't, so the new node gets saved wrong.

Here's the relevant code:

function mymodule_menu() {
  return array(
    'admin/content/myadd/%' => array(
      'title' => 'my custom add page',
      'page callback' => 'mymodule_node_add',
      'page arguments' => array(3),
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
    ),
  );
}

function mymodule_node_add() {
  module_load_include('inc', 'node', 'node.pages');

  //I'm doing a print here instead of returning because I'm calling this page
  //in an AJAX popup, so I don't want the whole page to output, only the form.
  print render(drupal_get_form('mymodule_node_add_form'));
}

function mymodule_node_add_form($form, &$form_state) {
  if (!isset($form_state['node']) {
    global $user;
    $node = (object) array(
      'uid' => $user->uid,
      'type' => 'mycontenttype',
      'language' => LANGUAGE_NONE,
    );

    //this is setting a default value
    $node->myfield = array(LANGUAGE_NONE => array(array('value' => arg(3))));

    $form_state['build_info']['args'] = array($node);

    $form = drupal_build_form('mycontenttype_node_form', $form_state);
    $form['actions']['submit']['#submit'][0] = 'mymodule_node_add_form_submit';
    //there's a lot more customization of the form here, like adding fields, etc.
  }

  return $form;
}

function mymodule_node_add_form_submit($form, &$form_state) {
  //here's where $form_state['input'] is correct but $form_state['values'] isn't.

  $node = node_form_submit_build_node($form, $form_state);
  node_save($node);
  $form_state['values']['nid'] = $node->nid;
  $form_state['nid'] = $node->nid;
  $form_state['redirect'] = 'some/other/page';
}

So, am I doing something wrong here? Should I be concerned about form ids being wrong? (my form's id is mymodule_node_add_form, but the actual form might output mycontenttype_node_form), would this affect me?

function mymodule_node_add() {
 module_load_include('inc', 'node', 'node.pages');

  //I'm doing a print here instead of returning because I'm calling this page
  //in an AJAX popup, so I don't want the whole page to output, only the form.
  $form = node_add($node_type);//You need to pass content type here. THat's it.
  print render(drupal_get_form('mymodule_node_add_form'));
}


How to create a menu from content type fields found on a node? I have a content type with 4 text areas I would like to make into 4 separate "pages" by creating a menu dynamically based on fields.

Is this possible? Reason I'd like to do this is to create a single content type a person creates with the necessary fields and then has a menu created dynamically from these fields if they contain data.

The only other option I can think of is creating multiple content types and then combining them.

You could build this with the Field Group (https://drupal.org/project/field_group) module, which will allow you to group your content fields into horizontal tabs, vertical tabs, accordions and more. By default, groups with only empty fields will be hidden, i.e., they will not display in the "menu".

While this would not create separate pages, your use of the word in quotes makes me think this would be an acceptable answer.

There is a decent tutorial at https://www.youtube.com/watch?v=5GU_tb4K-f4.


How can the Feeds module fetch a file from a dynamic URL? The feeds module does fine importing a source file (CSV, in my case) from an external URL. However, I'm trying to schedule Feeds to pull in a report every X days. I need Feeds to fetch at a dynamic URL,
say:
www.example.com/report/%start-date%/%end-date%

I'm guessing this would use the Token module, but aside from that I'm not sure what to do.

As I know Feeds doesn't have something like that, its maybe a feature that you can propose on they issue list.

A workaround its to create a small module that will work as a proxy for your dynamic address.

You will have something like that :

<?php

function proxy_menu() {
  $items = array();
  $items['proxy-url'] = array(
    'title' => 'Proxy for danymic url',
    'page callback' => 'proxy_get_contents',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK
  );
  return  $items;
}

function proxy_get_contents() {
  $url = 'http://www.example.com/report/%start-date%/%end-date%';
  $request = drupal_http_request($url);
  if ($request->code == 301 || $request->code == 304) {
    return $request->data;
  }
}


Installing Bootstrap theme using Composer I am new to using Composer.

How can I install a theme, say https://www.drupal.org/project/bootstrap using composer

I've tried:

composer require drupal/bootstrap

But didn't work.

I also tried:

composer require twbs/bootstrap

Installation was completed successfully but I couldn't see the theme appearing at Drupal admin page.

What is the standard way to extract the name of the theme or module to be used with composer require?

That is because every Drupal package is at drupal/ - twbs is not in the Drupal packagist. You have to add that to composer to get that to work as Clive said.

It is not in the composer.json file out of the box.

You need to add that, and then do:

composer remove twbs/bootstrap because this is NOT a Drupal ready theme.

After adding the repository to composer.json, then you can do:

composer require drupal/bootstrap

Also, not every module or theme has a composer.json file yet. Bootstrap for Drupal does, and thats where you can determine what the package name is if you are unsure.

http://cgit.drupalcode.org/bootstrap/tree/composer.json

I believe modules/themes have to provide this file in order to work with composer (including the repository addition in Clives answer).

Here is one of my projects composer.json, for example. Note the addition of the repositories and Drupal packages URL.

{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0+",
    "require": {
        "composer/installers": "^1.0.21",
        "wikimedia/composer-merge-plugin": "~1.3",
        "drupal/search_api_solr": "1.0.0-beta1",
        "drupal/search_api": "^1.0@beta"
    },
    "replace": {
        "drupal/core": "~8.2"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },
    "repositories": {
        "drupal": {
            "type": "composer",
            "url":  "https://packages.drupal.org/8"
        }
    },
    "extra": {
        "_readme": [
            "By default Drupal loads the autoloader from ./vendor/autoload.php.",
            "To change the autoloader you can edit ./autoload.php."
        ],
        "merge-plugin": {
            "include": [
                "core/composer.json"
            ],
            "recurse": false,
            "replace": false,
            "merge-extra": false
        },
        "installer-paths": {
            "modules/contrib/{$name}": ["type:drupal-module"],
            "themes/contrib/{$name}": ["type:drupal-theme"]
        }
    },
    "autoload": {
        "psr-4": {
            "Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
        }
    },
    "scripts": {
        "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
        "post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
        "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
    }
}

The lack of the packages repository in composer.json is a small, easily missed and often overlooked thing. Hopefully it will be added in a future release.


entity_load() not listing custom fields. I created the custom field for existing entity, I can see those fields listed on 'field_info_instances()' . And I also have data in those fields, but I can't see those fields listed on the entity object returned by  entity_load().

This is how I am installing the fields

/**
 * Implements hook_update_N()
 */
function dashboard_update_7002() {

        field_create_field( array(
            'field_name' => "dashboard_url",
            'type' => 'text',
            'cardinality' => 1,
            'entity_types' => array('manufacturer'),
            'translatable' => TRUE,
            'locked' => true,
        ));

        field_create_instance(array(
            'field_name' => "dashboard_url",
            'entity_type' => 'manufacturer',
            'bundle' => 'manufacturer',
            'label' => "Dasboard URL",
            'required' => FALSE,
            'widget' => array(
                'type' => 'text_textfield',
            )
        ));

    }
}

After banging my head for a while, I found the solution. On the module where that entity was defined 'hook_entity_info()', 'fieldable' property was missing which is set to FALSE by default. Therefore none of the fields were being attached to that entity.


new domain url for multi sites linked to sub domain drupal install Because my drupal install is not in the root of document but in a subdomain, everything is a little more difficult for setting up multi-sites.

I found a way of adding multiple subdomains successfully to the subdomain containing drupal install but now that I am wanting to add a new domain url pointing to same IP obviously it keeps wanting to direct to document root and if I set it up in virtualhosts what happens is it makes it so you have to go to URL example.com/drupal/install.php which obviously I don't want because I want it to 'appear' as other multi-sites in the exact url not path to drupal folder.

Do I need to use a symlink for this to work? See I have two domains pointing to the ONE IP but as I have the drupal core in a SUBDOMAIN of the main IP then the second domain name doesn't want to follow the same rules as the other subdomains running off drupal core subdomain and direct from vhost to html/drupal and APPEAR in subdomain url. Rather the second name url is following the path LITERALLY and so I can never install anywhere but path to drupal folder.

So completely stuck on what to do from here. How can I make my second domain url POINT to the subdomain root drupal install and not the root of IP which is static?

So finally figured this all out.

If like me you are weird and want to use a Sub-domain for your main drupal install and then create multi-sites from that you can just add your virtual hosts to the custom conf file or wherever you keep that.

I found that to do away with .htaccess in favour of the /etc/httpd/conf.d/custom.conf file as well as httpd.conf on linux vps.

BUT if you want to add a new domain directing to same IP it will obviously keep searching for doc root,so even if you add the Drupal folder direction in virtual host it will just go there and not install at your actual URL.

So you need to create a symlink in this case and then add that directive to your virtual host. so it would be something like /var/www/html/drupal/nameofmysite.com  which would be a symlink to the actual folder in sites folder of subdomain.


How to get attached files outputted by views for given node id (programatically) I am working with a module.
I have a node id. That node id is a page and it has 2 or more view blocks on it. The results of views are lists of nodes with file attachments.

I need to get all the files attached to the nodes outputted by the view on this particular page.

I work in a module file and I can supply the nid of type page where these views sit.

I could not find much help so I decided to ask for what would be the best way to approach this.

I am new to Drupal so I will appreciate a great explanation on how to approach this.

I thought I'd come back and explain my solution. It involves a series of loops through the following: getting regions available for current nid, then the blocks displayed on that nid, then loading each view that has blocks on that nid to obtain access to the fields. I can't provide any code but in theory that's what it involves.


Views exposed sort handler with asc + desc + inactive I have a view with the following sort handlers:

price (exposed, asc/desc, default=asc)
stock (desc)

I would like to have a third option for price so that it can be inactive/asc/desc, with "inactive" being the default.

So by default it sorts by stock availability (or any other sort handlers I may configure in the future), and only if the user chooses "cheapest first" it will sort by price.

(I am going to use Better exposed filters to display the sort options as links, but this is secondary)

Things to learn:

If more than one sort option is exposed, then only one of them will be active at a time.
The first of all exposed sort option will be active by default, the others will be inactive by default.
The non-exposed sort options will always be active. But if you put them below the exposed sort options, they will have a lower priority, obviously, so you might not see the effect.
One field can be used multiple times. E.g. one time exposed, another time not exposed.
BEF can be used to re-label the options.
BEF can be used to hide some sort options, by leaving the label empty.

Example sort configuration:

stock, exposed, descending.
amount, exposed.
stock, descending. (not exposed)

Then in the BEF settings, "Advanced sort options", "Rewrite the text displayed":

Stock Desc|No sort
Stock Asc|
Price Asc|Cheapest first
Price Desc|Most expensive first


Upload File Processing Background Is it possible when uploading a file to a node for it to upload as a background process? Ideally what I would like to do is to be able to upload files in the background while being able to continue navigating through the website. When the uploaded files are complete a notification appears on the website to say that the upload is complete or an email is sent.

After having a look in the Contrib Module space, I would say no, it's not possible. The main problem as you probably already know: A file upload will break if you navigate away from the page.

However, if you have lots of time to invest in implementing this, I could imagine the following workaround: You could ajaxify your whole Drupal website, e.g. with ajaxify so that some outer elements of your page will persist while your navigation is taking place and your content is rendered inside a "content" element. You could then process the file upload in e.g. an iframe that resides outside of your "content" area.

Hope this helps!


D7 Rules - User Profile Field in Send Email Action I'm using D7 with Rules 7.x-2.7. I am trying to create a Rule that will email and BCC all users of a particular role when a node of a certain content type is created. I've added the event: After saving new content of type..., and the action: Send mail to all users of a role. What I'm now trying to do is pull in the user profile data to populate the email body. Something like:

Hi [user-field-firstname],

A new announcement has been released. Please log in to your profile and browse to http://examplesite.com/user/[user-id]/announcements.

regards

I've been unsuccessful thus far. I've tried to add another action of Fetch entity by Id, but could find any decent selectors in the data selector. Any advice for me, please?

I might try the Rules Token module (if you haven't already). It might contain what you need


how does links__system_main_menu() work? How does the below code work at a high level?

print theme('links__system_main_menu', array(
  'links' => $main_menu,
  'attributes' => array(
    'id' => 'main-menu-links',
    'class' => array('links', 'clearfix'),
  ),
  'heading' => array(
    'text' => t('Main menu'),
    'level' => 'h2',
    'class' => array('element-invisible'),
  ),
));

Drupal renders the array argument you passed by looking up a suitable theme hook for links__system_main_menu.

The meaning of the argument should be documented in the module that provides the theme hook.


using drupal sessions during hook_boot When a user calls the front page of our site we want to check the country from which the user is surfing and redirect the user directly to the country specific front page.

We chose to use the hook_boot() callback to implement this.

Now we have the problem that we want to save the state "is_redirected" into a global variable that will still be available when the redirected page is loading and is calling our hook_boot() again in order to prevent redirect loops.

We thought about using session management, so we loaded the drupal session code with

include_once(DRUPAL_ROOT . '/includes/session.inc');

The question is now, what is the next step after loading session.inc, do we have to call "drupal_session_initialize()", add a custom entry into the superglobal $_SESSION variable and this custom entry + our session will be available after the redirect?

Thank you in advance!

hook_boot() is invoked too early to use the session, as Drupal has not yet initialised the session. Furthermore, hook_boot() has been removed from Drupal 8. hook_init() is not invoked for cached pages, but there is a trick to avoid the page is cached: Call drupal_page_is_cacheable(FALSE) in hook_init().

The function that actually stores the current page in cache is drupal_page_set_cache(), which contains the following code.

  if (drupal_page_is_cacheable()) {
    $cache = (object) array(
      'cid' => $base_root . request_uri(),
      'data' => array(
        'path' => $_GET['q'],
        'body' => ob_get_clean(),
        'title' => drupal_get_title(),
        'headers' => array(),
      ),
      'expire' => CACHE_TEMPORARY,
      'created' => REQUEST_TIME,
    );

    // Restore preferred header names based on the lower-case names returned
    // by drupal_get_http_header().
    $header_names = _drupal_set_preferred_header_name();
    foreach (drupal_get_http_header() as $name_lower => $value) {
      $cache->data['headers'][$header_names[$name_lower]] = $value;
      if ($name_lower == 'expires') {
        // Use the actual timestamp from an Expires header if available.
        $cache->expire = strtotime($value);
      }
    }

    if ($cache->data['body']) {
      if (variable_get('page_compression', TRUE) && extension_loaded('zlib')) {
        $cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP);
      }
      cache_set($cache->cid, $cache->data, 'cache_page', $cache->expire);
    }
    return $cache;
  }

When drupal_page_is_cacheable() returns FALSE, the page is not cached; drupal_page_is_cacheable(), when called without arguments, returns the value of the parameter passed to the function in a previous call.

As hook_init() is invoked before drupal_page_set_cache(), calling drupal_page_is_cacheable(FALSE) causes the current page not to be cached.

I would call drupal_page_is_cacheable(FALSE) strictly when necessary, which in you case means when you are sure you need to set $_SESSION['is_redirected'].

Notice that a page is served from the cache when there isn't any session enabled. The function called to get the page from cache (_drupal_bootstrap_page_cache()) contains the following code.

  // If there is no session cookie and cache is enabled (or forced), try
  // to serve a cached page.
  if (!isset($_COOKIE[session_name()]) && $cache_enabled) {
    // …
  }

If then you need to clear the cache for the front page, you can use the following code.

cache_clear_all(url('<front>', array('absolute' => TRUE)),  'cache_page');

The other alternative to hook_boot(), and hook_init() I can think of is hook_exit() which is called also for cached pages. The only reason I would not use it is that it is invoked after the current page is rendered, which means that when you redirect the user to a different page, the user would wait for two different pages to be rendered (the one rendered before the redirect, and the one to which the user is redirected).

If you are going to use hook_exit(), you need at least to call drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); if then you need specific functions, you need to change bootstrap phase, such as with drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) when you need a function defined from another module.

Remember that with hook_boot() you cannot call functions defined from other modules, as they are not yet loaded; you can only use PHP functions, and a very strict number of Drupal functions, which at least includes the functions defined in bootstrap.inc.


translate menu item using entity translation I am kind of confused and really need some guidance
Is there a way to translate menu items using entity translation?(One item for all languages)
Thanks

With Drupal core alone, user-defined menu items are not translatable. The Menu translation module, part of the i18n package, allows users to select a translation mode for each menu.
LINK


How to programmatically import a feed? I'm using Drupal 8 and creating a feed entity like this:

//...
$feed = \Drupal::entityTypeManager()->getStorage('feeds_feed')->create(array(
            'type' => 'my_feed',
            'uuid' => \Drupal::service('uuid')->generate(),
            'title' => 'RSS feed',
            'uid' => $uid,
            'status' => 1,
            'created' => time(),
            'source' => $form_state->getValue('rss_feed_url'),
          ));
$feed->save();
//...

That works fine!
But how can I execute the import after saving the new feed entity?
I've tried the following:

// Batch starts and returns "This webpage has a redirect loop"
$feed->startBatchImport();

// Returns an error: "Call to undefined method Drupal\feeds\FeedImportHandler::startCronImport()"
$feed->startCronImport();

How can I import the feed items after creating the feed entity?

This is working for me. Note: You will need to know the numerical $id of your Feed from the D8 DB table feeds_feed. In my case it is 1 so $id = 1.

use Drupal\feeds\Entity\Feed;

function mymodule_cron() {

  /**
   * Runs single feeds on cron
   */

  $feed = Feed::load($id);
  if (!$feed->isLocked()) {
    $queue = \Drupal::queue('feeds_feed_import:' . $feed->bundle());
    if ($queue->createItem($feed)) {
      // Add timestamp to avoid queueing item more than once.
      $feed->setQueuedTime(REQUEST_TIME);
      $feed->save();
    }
  }
}


Expose Date Filter instead of Start & End Dates I have a content type event with start and end dates marked. I have create a view with exposed filter, where in users can choose a date and see the event on those days. Right now, view is only allowing me to choose start and end dates. This way if an event is between March 1st - March 10th, there is no way for user to filter and see the events for say March 5th. Technically event being from 1st-10th is also present on March 5th. How can I expose a filter where in user can get events by any date.

Below is what I have now:

But I want like below:

I've been trying to solve a similar problem: creating a membership list per a specific date (based on "membership date" field with start and optional end date elements). Here is my current solution - hope it helps!

Environment
 1. I use VIEWS, RELATIONS and the PARTIAL DATES module and added a partial dates range field type to the Relation between a person and the organisation. This allows multiple memberships and "fuzzy" start and end dates if exact data is unavailable (i.e. "member since 1995"). You can probably put the date range field directly on your event node, and you may be able to use the standard date field if you don't need to allow for "fuzzy" dates.
Note that the Partial date range field automatically calculates timestamp values for "from" and "to" dates.

In the view, I added 2 exposed filters
 - "partial_date_timestamp_to" >= selected date
 - "partial_date" <= selected date
I also added 2 non-exposed filters to allow incomplete nodes to be shown (since membership data is not always perfect) you might not need this if your events always have complete, valid start and end dates.
So my filter criteria now reads: (partial_date_timestamp <= selected date OR partial_date_timestamp is empty) AND (partial_date_timestamp_to >= selected date OR partial_date_timestamp_to is empty)

It works, but entering the desired date in timestamp format isn't very user-friendly. Next step is to get desired date from user by a more comfortable method, then convert the result for the view filter.


How to sum vote values from a single field? I use a single field Vote Results: Value (with some relationships and contextual filters) which outputs the amount of votes every node has, in a list, like this:

5
3
4
2

However, I want it to look like this:

14

I tried to use the aggregation SUM on the field, but it didn't change.

Solved it by removing the sort criteria. Stupid mistake... :)


how a module is installed? I was successfully able to install the Nivo_Slider.
But I want to have proper understanding on how module installations work.

My question is:
Why doesn't the simple module installation of Nivo_slider do the job?
Why do I manually have to copy and paste something (look at the first step from here? Isn't that the whole purpose of module installation? Some other modules just get installed by copy and pasting the tar.gz file.

The Nivo Slider module relies on libraries that have a different license from the module itself. To work around this aspect, the Nivo libraries are distributed apart from the module. Consider this explanation from the licensing page at Drupal.org:

10. Can I write a "bridge module" to interface between Drupal and another system or library?
That depends on the other system.
It is possible to distribute a module that communicates with a 3rd party system over HTTP, XML-RPC, SOAP, or some other wire protocol, that leaves the 3rd party system unaffected.Examples of such systems include Flickr, Mollom, or certain legacy systems.
It is possible to distribute a module that integrates with a 3rd party PHP or JavaScript library, as long as the library is under either a GPL or GPL-compatible license. Examples of compatible licenses include BSD/MIT-style "permissive" licenses or the Lesser General Public License (LGPL). The Free Software Foundation maintains a list of popular GPL-compatible licenses.
It is not possible to distribute a module that integrates a non-GPL compatible library with Drupal, because it would be a derivative work of both Drupal and that other library and would therefore violate either the GPL or the license of the other library. Please be aware that includes some open source licenses that are incompatible with the GPL for one reason or another, such as the PHP license used for most PEAR packages.
If you wish to contribute a bridge module to a Drupal Git repository, please do not check in the 3rd party library itself. Doing so creates a fork of that 3rd party library, which makes it more difficult to maintain and only serves to waste disk space. Instead, provide detailed instructions for users to download and install that 3rd party library for use with your module. If you believe that your module is a special case where it really does need to be included in a Git repository, usually only because you need to make substantial modifications to it in order for it to work, please file an issue with in the Licensing Working Group issue queue first to discuss it.


Gmap Error "Javascript is required to view this map" when embedding the node in another node In my drupal 6 site, I use finder embedded in a node, to search for another node.
When user select a result the node is loaded in the same page.
The final structure is

parent node

finder embedded
parent node description

resulting node

Everything works fine, except that the Map loaded in the resulting node is not displayed.
I get this error "Javascript is required to view this map".
Obviously I've checked what's wrong, and I've seen that the required JS are missing (gmap.js, marker.js, etc..).

How can I force GMap to load js if they are missing?
Why do you think this is happening?

UPDATE

The problem is related to Ajax.
If I take the same scenario and hit Enter instead of Find, the request is made without using Ajax and the map is shown correctly.
Using the Find button (Ajax request) the problem persist.

Any solution?

GUnload is part of the Gmap API. Are you loading the Gmap js files served by Google?

The error would happen if the JS file from Google is:

Missing.
Has not been parsed when the code giving the error is executed.

To give a more thorough answer more details are needed.

Update

The Gmap module is a bridge to the Gmap JS API that Google has created. The actual Gmap JS API is not included in the module itself but is served by google. It's included using the following line:

drupal_set_html_head('<script src="'.
  check_url(url('http://maps.google.com/maps', array('query' => $query))).
  '" type="text/javascript"></script>'
);

The error you are getting, it is caused by the lack of the above JS file, or because it's loaded after the gmap module JS code is run.


site returns 404 on every request, except / After my site is moved from a shared hosting plan to VPS (dreamhost), all request returns:

  Not Found

  The requested URL /index.php was not found on this server.

  Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

For example.com/, it does returns some content. Any other requests (e.g. example.com/install.php) returns 404.

Rewrite settings are as default:

RewriteEngine on

# RewriteBase /

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

What should I check?

Update:

If I request example.com/? or example.com/?q=user, it returns:

  Site Temporarily Unavailable
  We apologize for the inconvenience. Please contact the webmaster/ tech support immediately to have them rectify this.

  error id: "bad_httpd_conf"

Check to make sure that the directory containing Drupal on your server can read the contents of your .htaccess files (the AllowOverride directive in your httpd.conf controls what will be processed). In my experience, AllowOverride None set for that directory or a parent directory is the most common culprit  (remember: directives are inherited).