Module Views automatically replace underscores in css classname to hyphens? The situation is like this: I created an article list block with Views, and I want give the list row a custom css classname, ex it's called "focus_img", but when I saw the output, "focus_img" was converted to "focus-img" automatically. How can I turn off this annoying feature? I don't get it, why it made this change, I just need it output what I want..

It's by design... Views module is cleaning class in views_plugin_style.inc..

  /**
   * Return the token replaced row class for the specified row.
   */
  function get_row_class($row_index) {
    if ($this->uses_row_class()) {
      $class = $this->options['row_class'];
      if ($this->uses_fields() && $this->view->field) {
        $class = strip_tags($this->tokenize_value($class, $row_index));
      }

      $classes = explode(' ', $class);
      foreach ($classes as &$class) {
        $class = drupal_clean_css_identifier($class);
      }
      return implode(' ', $classes);
    }
  }

Below statement is converting _ (Underscore) to - (hyphens)

$class = drupal_clean_css_identifier($class);

If you see documentation of drupal_clean_css_identifier by default filters replaces _ with -.


Making terms as a list format This is my layout http://www.gorgeoushentai.com/content/saber-marionette-j-2
If you look at the genres section it shows them as a div class and I want it as a < li > . How can I make it a list format? I can't find where it's printing the terms in the templates. This is for drupal 7

The template file you're looking for is field.tpl.php. The naming suggestions for this template are explained fairly well here and here - although they aren't in the documentation and I haven't tested them. So the steps you need to take are:

Copy the .tpl.php file from modules/field/theme
Rename it so it
targets only the field type you wan't ('list_text' I think in your
case).
Change the divs into ul/ol and li as required.


Permissions Administration Module Is there a working module for Drupal 7 to restyle admin/people/permissions/list to add more usable controls? Some serious boons to building a large site with lots of permissions:

Incremental search/filtering of shown permissions
Add/Remove/Toggle all permissions for a role (globally, or per module — one column, or part of a column)
Grant/Revoke/toggle a permission to all roles (one table row)
Collapsible/tabbed groups

Something like Module Filter, but meant for permissions administration, would be ideal.

I've tried a couple of modules, but haven't had much luck with them. E.g. the stable version of Permission Select from 2009 (!) fails to do anything, while the development version at least adds its checkboxes (but clicking on them does nothing).

Short of writing my own module and/or hacking something in jQuery, is there some understated gem of a module out there I should be using for this?

See the Fast Permissions Administration module; it is like the Module Filter module, but for permissions.

  This module is here to alleviate frustration when trying to manage permissions in Drupal. By providing a better permissions interface hopefully a few innocent keyboards and mice can be saved.

You can filter on the module name with @module, or permission@module:

  Module filtering:
  You can also filter on the module a permission belongs to using the @ symbol: permission@module.

  For example, if you want to show only permissions that contain the word admin for the comment module you would enter: admin@comment.


How can I translate this domain model into the desired front page I am quite new to Drupal and CMS alltogether and have some problems choosing the right way to setup my site to achieve my desired result. What I want to do is to create a page for my basketball club to read about upcoming games and practices and get some game reviews.

Domain Model:

So I have a team entity type which represents the different teams in my club. Each team has some reviews, games and standings associated to them.

I think about representing each entity type as a content type and setup the relationship by using entity references.

Is this the common way to do this are is there another recommended way?

FrontPage:

And now I want the front page to look like this ("conceptually"):

I want a row for each team, containing the latest game review, the standings and the upcoming games. Of course I want only those related to the team to show up in the given row.

And I honestly have no clou how to approach this? How would you do this?

Best regards,
Marco

Your best bet is probably Views. It can be set up to do exactly what you want. There are hundreds if not thousands of tutorials on how to use it.


Use a different confirmation url on completed webform submission in email confirmation link When a user submits a webform submission, they get redirected to a confirmation page, in my case its node/40. Now if they also have to click on an email confirmation link, it also sends them to the same confirmation url node/40.

How can you set a different confirmation url for the one in the email?

There is actually a Set the redirect URL field in the "confirmation" email page setting which i totally missed. See below:


How to trigger an email to someone who opens an account but never signs in? Assume a user visited your site and signed up for an account, but such user never did Sign in to your site anymore.

Is there any way to generate mails to such visitors, for letting them know about your products and services?

Yes there is a way to use the Rules module for this (as the tagging of your question seems to indicate), as detailed below ...

Step 1 : Create a Rules Component to send an eMail

Create a Rules Component  (say "Rule1") for sending an eMail that corresponds to the eMail you have in mind "... for letting him know about your products and services ...". This Rules Component itself will not do anything on its own. Instead it will be used in a subsequent step.

Have a look at "Step 2" of my answer to "How to send an email to an author on a specific date using date field specified in a node?" for an example of such Rules Component.

If you have multiple types of eMails in mind, then create 1 such Rules Component for each of them.

Step 2 : Schedule an eMail reminder

Create a rule (say "Rule2") which uses Rules Event "After saving a new user account" to schedule the execution of the Rules Component created in Step 1, e.g. X days after the new account was created.

Have a look at "Step 3" of my answer to "How can I set a reminder for a specific user to be triggered on a specific date?" for an example of how to schedule the execution of a Rules Component. More specifically the part in the Rules Action that starts with "schedule" (for this ignore the part with "schedule_delete").

If you have multiple types of eMails in mind (e.g. 1st eMail after X days,  2nd eMail after Y days, 3rd eMail after Z days) then schedule the execution of all these Rules Components right away. Or create a chain whereas the 1st Rule Component (for after X days), will schedule the 2nd Rule, etc.

Attention: if you're planning for multiple eMails, you should use some 'convention' to identify the scheduled eMails. E.g. by using an "identifier" (within "schedule") that is not just "[account:name]", but instead something like (e.g.) "[account:name]-1", "[account:name]-2" and  "[account:name]-3".

If nothing happens (i.e. if such newly created user never logs in, you have your desired eMails in place for being sent after X (and or Y, and or Z) days.

Step 3: Cancel eMail reminders when user logs in

Create a rule (say "Rule3") like so:

Use Rules Event "User has logged in".
Add a Rules Condition using "Data value is empty" to check if account:last-login is actually empty. If that's the case, it implies this user logs in for the very first time, which is exactly what you are interested in. Because from then on, you don't want to send the scheduled eMails anymore.
Add a Rules Action to delete (cancel) the scheduled eMails. Have a look at "Step 3" of my answer to "How can I set a reminder for a specific user to be triggered on a specific date?" for an example of how to delete (cancel) the planned execution of a scheduled Rules Component. More specifically the part in the Rules Action that starts with "schedule_delete" (for this ignore the part with "schedule").

Attention: if you're planning for multiple eMails, you should use some 'convention' to identify the scheduled eMails to be deleted (cancelled). E.g. by using an "identifier" (within "schedule") that is not just "[account:name]", but instead something like (e.g.) "[account:name]-1", "[account:name]-2" and  "[account:name]-3". And of course make sure these identifiers match with the convention you've used in Step 2 (to schedule those eMails).


Using Fieldgroups with Entity Registration Module I'm using the Entity Registration module to create event signup forms.  I've got my first event registration form up and running and now want to group some of the fields into fieldsets.

I have the Field Group module installed, and have used it to group my fields into fieldsets (via Manage Display):

The effect I want to achieve is something like this:

However the fieldsets are not showing on the registration form or in the markup:

According to Field Group module, it should work with any entity:

  Fieldgroup will, as the name implies, group fields together.  All fieldable entities will have the possibility to add groups to wrap their fields together.

I've searched the Entity Registration issue queue, but can't find anything relating to this.  Has anyone managed to get fieldsets working with Entity Registration?

You need to add corresponding group to add steps in it. See image.


How to make a theme depend on a module? My theme requires multiple modules to be install before it is fully functional. How can one set module dependency in a theme, so that when a user enables the theme, it will also enable the required modules? So far, I tried to specify the dependencies in the .info file of the theme, however, no success:

dependencies[] = some_module

Any help is much appreciated.

As far as I know, this functionality doesn't exist yet (up to Drupal 7).

A feature request is already created at https://drupal.org/node/474684 (for Drupal 8).


Download Views CSV automatically Daily I have a bunch of views/reports built for my client. The reviewers then click download csv for the excel file. They asked if the views could download themselves daily to a folder.

Is that possible? And could you share links or knowledge how to handle this. I have been trying to figure it out.

Note: Right now the user is downloading CSV's from Drupal 7, an install of Moodle 1.9 in a Drupal 6 Shell and Survey Monkey. After they download and combine using Excel, the user creates reports that way for the users we have come to our events. Being a Front-end developer, coding is not my strength.

Maybe you want to consider the Forena module (disclosure: I'm a co-maintainer of it) ... Here is a quote from that page:

... built of the idea of using SQL to get data out of a database and use XHTML and CSS to format it into web reports.
It is designed to leverage existing knowledge of HTML, CSS, SQL and JavaScript to help you create rich interactive web reports.

Here is another quote from Reasons for considering Forena, related to the "CSV" in the question here:

Reports created by Forena (combined with SVGGraph and mPDF) can be saved (exported) as PDF documents with embedded graphs. Other supported formats for saving a report are CSV, XLS, DOC, HTML, etc.

My answer to "How to retrieve data directly from a Drupal database" contains like a 1 minute summary to explain the typical (about 3) steps for creating:

a connection to an external database (typically by an admin).
a custom SQL query (typically by an admin).
a custom report (either by an admin, or by just any regular user who is either familiar with creating what is called 'FRX files', or otherwise using the WYSIWYG report editor).

These steps (without any PHP coding involved ...) are like the equivalent to writing the PHP coding as included in the question there.
For an online demo (prior to installing/testing Forena), refer to these links:

Reporting samples, about data stored in some SQLite database, and including things like drill down reports, creating charts (using the PHP SVG Graph library), etc.

Forena Documentation, which you also get in your own site after installing the module). It contains topics such as (incomplete list):

Module installation and administration, a kind of getting started guide.
WYSIWYG Report Writing, using a report editor to facilitate the creation of reports.
Site Building, topics about integrations of Forena with other Drupal modules.
Forena hooks, to use it in other (custom) modules.


Contact Form with drop-down subject (bonus: auto-selected based on GET/POST) I have a number of services on my site and I want them to all direct to the contact form. Now, this is where it gets tricky- I want the subject to be a dropdown selection of all services provided and, if possible [bonus], based on the link clicked (GET/POST).

Alternatively:
I would also be open to a contact-form jquery popup modal box that I could tailor for specific services.

Any help is greatly appreciated and I thank you in advance.

You can try hook_node_view() to pre-select default value of webform component on the base of referer.

function yourmodule_node_view($node, $view_mode){
    if($node->nid == [nid of webform]){
            global $base_path;
            $referer = $_SERVER["HTTP_REFERER"];
            $start = strpos($referer, $base_path) + strlen($base_path);
            $ref_local_path = substr($referer, $start);
            switch($ref_local_path){
                    case 'service_1_path':
                            $node->content['webform']['#form']['submitted']['<component_name>']['#default_value'] = 'option_1';
                    break;
                    case 'service_2_path':
                            $node->content['webform']['#form']['submitted']['<component_name>']['#default_value'] = 'option_2';
                    break;
            }
    }
...

If you are looking to do it via JS/JQuery that is another solution.


Is the "Count content views" settings related to the "Discard access logs older than" option? My question is related with statistics module to know the "most popular" content.

I have enabled the Statistics module (Core Drupal). As you already know, to get this statistics is necessary enable the option "Count content views" in "Access log settings"; also, in "Access log settings," I saw the option, "Discard access logs older than" necessary to set time to log statistics.

According to your experience, are these statistics related with the interval of time indicated in the "Discard access logs older than" option, or are statistics of all "content views" since that statistics module was enabled?

According the code of statistics.module (line 54), the behavior expected is only add one value per visit, and nothing about use an interval of time to calculate some value; but in the "Access log settings" page it seems that this interval of time is related with the option "Discard access logs older than." Are the most popular articles tied to this interval of time?

According my review, I confirm that "Most popular" default statistics (Drupal 6), give the "most popular" "al time" since "Count content views" option was enabled.

So, I reviewed several modules like Statspro, Visitors, Quickstats, Reports and Radioactivity, and I chose Radioactivity to solve this. Radioactivity give results, per day, very close to Analytics.


Custom line item total calculation I have looked for the solution for weeks, but I have not found any. It must be very trivial that I missed.

I'm adding a line item field in addition of the default unit price and quantity called "length" in the cart view and Order. I would like to get the new calculated line item total = price * quantity * length.

Solutions that I have found so far change the line item unit price, which is not desirable.

How can I do this?

The line-item unit price is used throughout commerce and the total order amount is based on the line-item total value (quantity * unit price). There is no way to circumvent this behavior.

Better would be to add another price field to the line-item Price per length-unit. Hide the default price field and calculate the sales price as you've found in other answers.

Basically this is a pricing rule in Store > Configuration > product pricing rules where you add the event Set the unit price to a specific amount to a calculated value.


Show current week items is views I want to create a view which shows all items of the current week based on the publication date.
The week starts on Sunday and ends on Saturday.
I tried the relative date filter in the Views module with 'between last Sunday and this Saturday'
This works. But on Sunday, it shows all the items of the past week, so, on Sunday, the view is not correct.
Could anyone help me with an solution?

The key is using -1 second So

first solution: Use this values

next sunday - 1 week

and

next sunday  - 1 second
Second solution  based on you told on question :

last sunday
  and
  this sunday - 1 second


Is there a way to upload file in database instead of in filesystem via webform? When files are uploaded via webform, the attachment is stored in filesystem. Is there a way to store the attachment in database blob field?

You could read the field and write the contents in the database. This could be done in a custom submit handler to the webform form.


Adding Node to Entity Reference List (Via Rules) Throws EntityMalformedException I'm using rules and I'm trying to add a reference to an updated node to an entity reference on another node. I am getting the following exception.

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7633 of /var/www/html/mysite/includes/common.inc).

I found another post that states - "EntityMalformedException: Missing bundle property on entity of type node." means that Drupal does not recognize your entity as a valid one. In the entity info listing, there is a mapping from "bundle" to "type", for nodes.

Either your $node doesn't have a ->type, or Drupal no longer has the type registered. The type could have been removed, either from the UI, or by disabling a feature, and possibly in more interesting ways as well.

My question is - How can I go about debugging this and correcting the problem. I have Devel installed and I have debugged issues before I just need a little guidance to help me get to the bottom of this / or post the issue to whatever module has caused the error so the maintainers know about it.

Thanks very much and have a great day!

Okay I've fixed the error and whilst I'm not 100% sure this was the issue I think it had to do with the fact that the new node had not been saved prior to my attempting to assign it to the other node. Hence it had no node id, hence the error - I think.


Please tell me what drupal table the block php visibilities settings is stored at Within a block I have configured under the "Visibility settings" and "Show block on specific pages" I have put in PHP code that determines where this block is displayed within a page or not via a returned true or false.
I have it working correctly but then I added additional restrictions within the PHP but I must have put in a syntax error that caused the site to go down saying "Temporarily Unavailable".

I need to be able to change the PHP code back to the working version but I don't know what drupal table the block PHP code is stored.  Please tell me what drupal table the block php visibilities settings is stored at.

The php code should be stored in the pages field of the block table, and it should not be serialized.

The visibility field can have one of three values:

BLOCK_VISIBILITY_NOTLISTED (0),
BLOCK_VISIBILITY_LISTED (1), or
BLOCK_VISIBILITY_PHP (2).

In the case of the first two, the pages field will contain a text list of the notlisted or listed pages for the block. in the case of the third, the field will contain the php code.


Open Public Distribution on IIS 8.0 and SQL Server 2012 R2 I am having some issues on installing Open Public distribution (openpublic 7.x-1.2) on IIS 8.0 and SQL Server 2012 R2 without Web PI.
Have any one tried it before in such way ? Is it possible ?
I can install "standard" distribution on IIS 8.0 and SQL Server 2012 R2 without Web PI, without any major issue.

This is the issue I am experiencing during installation of Open Public distribution:

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows.
Path: http://endri.net/install.php?profile=openpublic&locale=en&id=1&op=do
StatusText: OK
ResponseText: Home | Drupal @import url("http://endri.net/modules/system/system.theme.css?0"); .... Home Installation tasksChoose profile(done)Choose language(done)Verify requirements(done)Set up database(done)Install profile(active)Configure siteVerify Apps supportInstall AppsFinished Status message You can now configure the CAPTCHA module for your site. SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Procedure or function dbo.CONCAT has too many arguments specified.

and

Warning: file_put_contents(temporary:///.htaccess): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_create_htaccess() (line 494 of C:\inetpub\wwwroot\includes\file.inc).

I have solved, the issue is at this file on this location:

C:\inetpub\wwwroot\profiles\openpublic\modules\contrib\comment_notify\comment_notify.install

the statement on line 24

$comments_select->addExpression("MD5(CONCAT(:salt,c.mail,COALESCE(u.mail, u.init), c.uid,c.name,c.nid,c.hostname, c.cid))", 'notify_hash', array(':salt' => $salt));

should be replaced with

$comments_select->addExpression("MD5(CONCAT(CONCAT( CONCAT(:salt, c.mail) , CONCAT(COALESCE(u.mail, u.init), c.uid) ),CONCAT( CONCAT(c.name, c.nid) , CONCAT(c.hostname, c.cid) )))", 'notify_hash', array(':salt' => $salt));

because "Drupal 7 driver for SQL Server and SQL Azure" drops the SQL Server stored procedure CONCAT and creates a new one with only 2 parameters.


Limit amount of content creation per anonymous user In my site anonymous users has access to create one type of content and all data the site stores is user IP address.

How do I limit lets say e.g. 2 nodes creations per IP in 12 hours? And when limit is reached, they get some message instead of creating another node until 12 hour range pass?

Because now some of anonymous users are just abusing and spamming the node creation which is unlimited by default.

UPDATE: I tried using Node Limit, but it doesn't really work. When I load a page with the form which has the limit set, it doesn't load the page and that's a home-page of the site and form is displayed as Form Block via Panels. So instead of a home-page I get redirected to node/add/ and page not found.

You could do it custom with hook_node_access and the Flood API.

e.g:

/**
 * Implements hook_node_access
 */
function MY_MODULE_node_access($node, $op, $account) {

    // Get node type, can be string or node object
    $type = is_string($node) ? $node : $node->type;
    if ($type == 'type_of_interest') {
      // Check flood limit for anon users node creation
      if ($op == 'create' && user_is_anonymous()) {
        // Ensure checked only once per page request, node/add path only
        $access_checked = &drupal_static(__FUNCTION__);
        if(empty($access_checked) && arg(0) == 'node' && arg(1) == 'add') {
          // Record the access check for drupal_static
          $access_checked = TRUE;
          // Check create_node limit of 2 per 12 hours
          // Note, you could make the threshold and window config variables.
          if(!flood_is_allowed('create_node', 2, 43200)){
            drupal_set_message(t('There is a node creation limit of 2 nodes per 12 hours. Please try again later.'), 'error');
            return NODE_ACCESS_DENY;
          }else{
            // Register the node create event to test against for 48 hours
            // Note, you could move this somewhere else to ensure the node is actually saved, e.g hook_node_insert
            flood_register_event('create_node', 172800);
          }
        }
      }
    }

  return NODE_ACCESS_IGNORE;

}


Add fields to form dynamically with ajax and retrieve values I am trying to add a combination of text field and a select box to a form dynamically using Drupal 7 Ajax, when i click on a button.

But i have 2 issues here:

I am not able to add more than 1 set of fields in the form with Ajax
After i submit the form, i am not able to retrieve the values of the form. They are empty. I have the fields as "name_1", "select_1", "name_2", "select_2", etc.

I want to know if there is any way to solve it, with / without using a fieldset.

My custom module code:

function my_form_form($form, &$form_state, $no_js_use = FALSE) {
  $form['#tree'] = TRUE;
  $form['add_more'] = array(
    '#type' => 'button',
    '#value' => t('Add More'),
    '#href' => '',
    '#ajax' => array(
    'callback' => 'ajax_simplest_callback',
    'wrapper' => 'names-fieldset-wrapper',
  );
  $form['names']['name_1'] = array(
    '#type' => 'textfield',
    '#title' => t('Name 1'),
    '#attributes'=>array('id'=>'name_1', 'name'=>'name_1'),
  );
  $form['names']['select_1'] = array(
    '#type' => 'select',
    '#title' => t('Select 1'),
    '#attributes'=>array('id'=>'select_1', 'name'=>'select_1'),
    '#options'=>array('1'=>'One', '2'=>'Two', '3'=>'Three'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  $form['#submit'][] = 'my_form_add_more_submit';
  return $form;
}
function ajax_simplest_callback($form, &$form_state) {
  if (empty($form_state['num_names'])) {
    $form_state['num_names'] = 1;
  }
  else {
    $form_state['num_names']++;
    $form_state['rebuild'] = TRUE;
  }

  for ($i = 1; $i < $form_state['num_names']; $i++) {
    $form['names']['name_'.$i+1] = array(
      '#type' => 'textfield',
      '#title' => t('Name '.$i+1),
      '#attributes'=>array('id'=>'name_'.$i+1, 'name'=>'name_'.$i+1),
    );
    $form['names']['select_'.$i+1] = array(
      '#type' => 'select',
      '#title' => t('Select '.$i+1),
      '#attributes'=>array('id'=>'select_'.$i+1, 'name'=>'select_'.$i+1),
      '#options'=>array('1'=>'One', '2'=>'Two', '3'=>'Three'),
    );
  }
  return $form['names'];
}

function my_form_add_more_submit($form, &$form_state) {
  print_r($form_state['values']);
  exit();
}

Dont set any field #required to true.

 $form['markup'] = array(
        '#type' => 'markup',
        '#prefix' => '
',
        '#suffix' => '
',
    );
 $form['markup']['myfield'] = array(
        '#type' => 'textfield',
        '#size' => 12,
    );


Can't change theme on view in Drupal I have just create a view with a page as a display. There is a theme option under the advance setting. I change the theme and save the setting. However the theme I saw didn't change at all. Can anyone advise what went wrong? Actually, I look at the them option again, it didn't being saved even I have saved.

I think you're misunderstanding what the theme link in the advanced section of views. It is meant to help themers choose the right template file, show which template file is being used and get quick access to the default template code.

In order to change the theme on a specific Drupal page, take a look at the ThemeKey module.


How to get GD2 generate PNG8 when resizing PNG8 images I have an image field which accepts jpg, jpeg, png. I've chosen the Image style: Medium on the display of that field. That style is configured at /admin/config/media/image-styles/manage/medium and it simply scales the image to 600px width.

On /admin/config/media/image-toolkit I can see that GD2 is being used.

My problem is that if the original image on that field is PNG8, the rendered thumbnail (by GD2) is PNG24. This results in much larger file for no reason.

Shouldn't GD2 respect the fact that the source is PNG8? Is there a way to fix this?

GD2 indeed doesn't check what palette size is the source image. From GDToolkit.php:

// Always save PNG images with full transparency.
if ($this->getType() == IMAGETYPE_PNG) {
  imagealphablending($this->getResource(), FALSE);
  imagesavealpha($this->getResource(), TRUE);
}

The only way I could hack PNG8 in there was:

// Always save PNG images with full transparency.
if ($this->getType() == IMAGETYPE_PNG) {
  imagealphablending($this->getResource(), FALSE);
  imagesavealpha($this->getResource(), TRUE);
  imagetruecolortopalette($this->getResource(), TRUE, 256); // ← hardcoded 256 hack for PNG8
}

I couldn't find a way of determining the palette size of the source image. So by leaving that hack of mine in there the risk is that PNG24 source images will be saved in the styles/ directory as PNG8 files.


How can I set a reminder for a specific user to be triggered on a specific date? How can I set a reminder for a specific user to be triggered on a specific date (in a Drupal 7 site)?

Example: I want to remind the user regarding particular event such as hepB vaccination day.

Any suggestions?

Rules module
Use the Rules module together with Rules Scheduler (a sub-module of it), as explained in the 3 steps below. These steps are based on a date field which is added to the user profile, so that for each user you can indicate an appropriate date.
Step 1: Create a field to store the appointment date
Add a field to the "user" entity with machine name (say) field_next_appointment. Allow only 1 date (to store the "next" appointment), but don't make it required.
Step 2: Create a Rules "Component"
Here is the Rules Component to be created (in Rules export format, just import it in your own environment via copy-paste, which you can do using the "Import rule" link located at admin/config/workflow/rules):
{ "rules_send_email_notification" : {
    "LABEL" : "Send eMail notification",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
    "ACTION SET" : [
      { "mail" : {
          "to" : [ "user-to-notify:mail" ],
          "subject" : "Friendly reminder about your upcoming event",
          "message" : "This is a reminder about the upcoming event that you have an upcoming event on [user-to-notify:field_next_appointment] ...",
          "from" : "[site:mail]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Obviously, the Subject and Content of the eMail may need review / tuning, while you might also want to use some other From eMail ID.
Step 3: Create a "Rule" using the Rules Component
Here is the Rule to be created, in Rules export format (just import it in your own environment via copy-paste, which you can do using the "Import rule" link located at admin/config/workflow/rules):
{ "rules_on_new_user_event_registration" : {
    "LABEL" : "On new user event registration",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "user_update" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "account" ], "field" : "field_next_appointment" } }
    ],
    "DO" : [
      { "schedule_delete" : {
          "component" : "rules_send_email_notification",
          "task" : "[account:name]"
        }
      },
      { "schedule" : {
          "component" : "rules_send_email_notification",
          "date" : {
            "select" : "account:field-next-appointment",
            "date_offset" : { "value" : 259200 }
          },
          "identifier" : "[account:name]",
          "param_user_to_notify" : [ "account" ]
        }
      }
    ]
  }
}

Note that the above rule refers to the Rules Component from the previous step.
Also note the machine name of field_next_appointment in this rule, which is the field's machine name created in Step 1 (if in step 1 you used another machine name, then also replace the machine name field_next_appointment in this rule with the machine name of the field created in Step 1 (if you don't have such field yet, or the field names don't match, then the import of the above rule might not work).
The schedule_delete that is part of this rule is to ensure that previously "scheduled" reminders will get removed when updating the data field (so that it only triggers 1 reminder, and with the most recent date).
Step 4: Further tuning and enhancements

The date_offset (=259200) in the above rule corresponds to "3 days in advance", which may need review / tuning.

If needed, you could also use the Field Permissions module to set field-level permissions to edit, view and create fields on any entity.

Instead of just sending an eMail (as in the Rules Component), you could replace that by a more advanced option using the Message module (which has great integrations with the Rules module also). Here is an quote about that module (from its project page):

... enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.

Note: Using Rules to send an email X days after a user registers also contains quite some details that may help you.
Date Reminder module
There is also the Date Reminder module. Here is a quote about this module (from its project page, bold markup added here):

... allows a registered user to request an email reminder to be sent at a specified time before an event. Generally these would be calendar events, but any node type that has a CCK datetime can support reminders.

However I think that module is not going to answer your question, because:

it's the user who has to request such reminder (in your question you want to set a reminder to a specific user).
these reminders are related to some node, while your question is related to a user. You might possibly work around this by creating some extra node type (like "Appointment"?), though that seems like overhead.


Can forms be added to a page of quick tabs? I want to create a page of quick tabs with some node editing pages, webforms and some admin pages as well regular static pages which just display information without any editing.

Is that possible?

Should be possible via custom code. You can read up on how to build quicktabs programmatically here:

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

For the node editing pages you will want to use the example for Custom contents (HTML or renderable Array) on that page, where you get the form using the core function drupal_get_form('node_BUNDLE_form') and add it as the "renderable array".

For the webforms you could try to work with the Callback tab type, or again by loading the webform and building the render array.

For the static content i'd recommend to use nodes as this is always better than hardcoding things, so use the Node tabs type.


How to migrate a value into a field attached to a taxonomy_term (from CSV using YML) I'm trying to migrate a CSV file of taxonomies (cities) into Drupal 8. The CSV has a code and the city name, for example:

City_Code,"Name"
1234,"CITY A"
5678,"CITY B"

I have the following as my current migration, which is working, and importing the city names. My problem is I also added a field with the machine name field_legacy_id to my term (Drupal 8), which I would like to populate with the OLD City_Code for reference later.

langcode: en
status: true
dependencies: {  }
id: cities
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: null
label: 'My Import'
source:
  plugin: csv
  path: /path/to/data.csv
  delimiter: ','
  enclosure: '"'
  header_row_count: 1
  keys:
    - City_Code
  column_names:
    0:
      City_Cd: City_Code
    1:
      Name: Name
process:
  vid:
    plugin: default_value
    default_value: city
  name: Name
  field_leagcy_id: City_Code
destination:
  plugin: 'entity:taxonomy_term'
migration_dependencies: null

The field_legacy_id seems to be ignored and I can't figure out how to get the migration to populate the field value. Thanks.

Edit: This is the field attached to the taxonomy.vocabulary.city:

langcode: en
status: true
dependencies:
  config:
    - field.storage.taxonomy_term.field_legacy_id
    - taxonomy.vocabulary.city
id: taxonomy_term.city.field_legacy_id
field_name: field_legacy_id
entity_type: taxonomy_term
bundle: city
label: legacy_id
description: ''
required: false
translatable: false
default_value: {  }
default_value_callback: ''
settings:
  min: null
  max: null
  prefix: ''
  suffix: ''
field_type: integer

Looks like the field name is misspelled?

  field_leagcy_id: City_Code


Metatags not generated for views pages I have installed the metatag module but it only works on the node pages and does not generate tags for the views pages.

I have also tried the metatags_quick module which provide the metatags per path but it also did not generate tags on the views pages.

Any other module which will be useful for views pages or any other method?

We use metatags_quick for our websites with no problem. You must make sure you've checked the tickbox "Use path-based meta tags" in admin/config/search/metatags_quick under the fieldset GLOBAL SETTINGS (it might be collapsed by default)


Override Domain-Restricted Content in a View I have a site running Domain Access, which is restricting content to the domain it was created on. Using Domain Views, I've created two types of views:

views displaying content for the current domain.
views displaying content for all domains.

However, #2 displays as #1 for anyone without the "Administer Content" permission. How can I set this up so anonymous users on one.mysite.com can see linked content on two.mysite.com ?

In addition, when they click links to other domains, I want them to be transfered to the other domain to view the content.

How can this be done?

I posted this on the Domain Access issue queue as a support request and got this helpful answer:

You can only accomplish #2 under three conditions:

The content is marked "Send to all affiliates"; or
The view is a page marked as a Special Page Request (which disables Domain Access rules); or
The view is set to ignore node access control -- this is an advanced Views configuration.

Option 3 can create security issues if you are using other node access modules.

To make the content link to the appropriate domain, use Domain Source, which lets you specify a canonical URL for each node. If you don't use Domain Source, the canonical URL is calculated for you.


How can I schedule in advance an update to a node, to occur at a given time? In a situation where I know that a specific change to the content of a specific node will need to be made on a specific date and time, is there any way to automate that change so that I do not need to make the change manually specifically at that date and time, but rather can prepare it in advance?

The Scheduler module allows for scheduling publishing and unpublishing nodes, and I am basically looking for some (hopefully lightweight) way to achieve a similar effect to the content of a node.

This is for Drupal 7 (though compatibility with the upcoming Drupal 8 is definitely a plus). Ideally it will also handle the components on Webform nodes (one of the things I want to be able to do is replace the list of options in a "select" component).

This could be done with a Rules Schedule:

  The Rules module allows site administrators to define conditionally
  executed actions based on occurring events (known as reactive or ECA
  rules). It's a replacement with more features for the trigger module
  in core and the successor of the Drupal 5 workflow-ng module.

specifically this functionality: Flexible scheduling system that allows scheduling any component / action.


Drupal can't create image styles for files located in theme directory I have an image located in sites/all/themes/mytheme/images directory.
I'm displaying it programmatically with attached image style like:

  $style =  array(
    'style_name' => 'my_style',
    'path' => drupal_get_path('theme', 'mytheme') . '/images/' . $filename,
    'width' => 30,
    'height' => 30,
    'alt' => $alt,
    'title' => $title,
  );

  return theme('image_style', $style);

First error: 404:

  "NetworkError: 404 Not Found -
  http://j.dev/sites/default/files/styles/my_style/public/sites/all/themes/mytheme/images/img.png?itok=qsTbAc8I"

Log report:

  Source image at public://sites/all/themes/mytheme/images/img.png not
  found while trying to generate derivative image at
  public://styles/my_style/public/sites/all/themes/mytheme/images/img.png.

I'm sure that img.png exists in sites/all/themes/mytheme/images

File permissions:

sites/all/themes/mytheme/images: 777
sites/default/files/styles/my_style: 777

core module Image Style allow only images from

public:// file system (sites/default/files).

For using image styles with any other images, you should install the Imagecache External module.

  Imagecache External is a utility module that allows you to store external images on your server and apply your own imagecache (D6) / Image Styles (D7).


How to add a block to a region in html.tpl? I'm using Drupal 7.

I have a custom template html--custom.tpl.php.

I have a custom block that contains the main menu. This block is enabled in the header region of block admin.

Up to this point, everything but the menu block prints.

How can I print the custom block in the header region of the html.tpl file?

You should make a new theme region similarly to how the header section works and add your block through the block admin into your new region. Rather than trying to get a block to come out in any other way

See this for more: https://www.drupal.org/docs/7/theming/assigning-content-to-regions


How do I change template file for the user registration form? I want to use a different template file for the registration form, but I don't want to use page--user--register.html.twig because in this case I should rewrite all the page structure. We had user-register.tpl.php in Drupal 7, but I couldn't find the theme name in Drupal 8.

I found the solution here: http://www.foreach.be/blog/how-manipulate-forms-drupal-8
and the file name for overriding the user register form is:
form--user-register-form.html.twig


fatal error when i want to disable apachesolr module I see an error when i want disable apachesolr module.
what should i do?

Updated:

Point from @kiamlaluno is correct, the apachesolr_stats has apachesolr listed as a dependency. Therefore, in order to disable the apachesolr, you should first disable the apachesolr_stats (and possibly other dependent modules).

I suspect that this issue comes from cached blocks, when I look at the trace you posted. Try to clear the cache and/or disable the apachesolr_stats block before trying to disable the apachesolr module.

Original:

You should try to disable the apachesolr_stats module first.
If you are using drush, this would be the command:

drush dis -y apachesolr_stats

If you don't have drush, you can also use MySQL/PHPMyAdmin commands, here are some links with examples:

Disabling modules:
https://www.drupal.org/node/157632

Clearing cache:
How do I clear cache using an SQL query?  [if that answer works for you, you can upvote ;) ]
https://www.drupal.org/documentation/clearing-rebuilding-cache

Good luck!


how to change output html of variable $output on file views-view-field--field-image.tpl.php dpm($output) ->  on file  views-view-field--field-image.tpl.php so how to I can add

 =>

You kind of answered yourself already.

open the views-view-field--field-image.tpl.php file, look for that  and add what you need.

however, use the file you can find inside your theme folder ( usually named templates or tpl), not inside the view module.

if you can't find it in there, copy it from the view module. In this case clear the cache for drupal to register the new file.

Always and only edit the .tpl of your themes.


Date picker in views for Drupal 6 Is there any way one can display date pickers as filter for a drupal 6 view?

Yes, just use Date-Filter (node) and expose as Popup. I assume you have the Date module (6.x-2.9 in my case) and Date Popup module installed and set your Datepicker on admin/settings/date_popup...

In Views it probably won't work in the preview, but on the view itself it will.


How can I render form elements? In Drupal 6, I am using the following code.
$rows[] = array(
  array('data' => drupal_render($form['collected'])),
  array(
    'data'=> drupal_render($form['count']) . drupal_render($form['submit']),
    'colspan' => 3
  )
);

In Drupal 8, I am trying to use the following code, but I see the HTML markup of $form['count'].
$rows[] = [
  ['data' => \Drupal::service('renderer')->render(($form['collected'])],
  [
    'data' => \Drupal::service('renderer')->render($form['count']) . \Drupal::service('renderer')->render($form['submit']),
    'colspan' => 3,
  ]
];

In Drupal 8+, you do not need to use a separate theming function as was required in Drupal 6. You can put the form element directly into the table without rendering, and Drupal will handle that on the back-end. It's much simpler:
$row = [];
$row[] = [
  'data' => [
    'something' => $form['something'],
    'something_else' => $form['something_else'],
  ],
];

$rows[] = $row;


Purpose of "rows" when adding Long Text field When adding a Long Text field to a content type, I am asked to supply the number of rows for the field. What is the purpose of this?

This seems like it has something to do with how the data is stored in the database. At first I thought it was required because I was using a SQLite database that stores everything in a flat file, so I switched to a MySQL backend. However, the field is still required.

Rows control the height of your text area for editors. It does not change how the data is stored in the database.


How to add web app icon png to root document folder? To specify an icon for the entire website (every page on the website),
  place an icon file in PNG format in the root document folder called
  apple-touch-icon.png

Exactly how do I do this in Drupal 8?

Yes, my site adds lots of different touch icons to the html.html.twig template in an assortment of different sizes for Android, Apple, and MS Tiles but all this does not have precisely the effect I want for my web app. For further info see Apple docs here.

place an icon file in PNG format in the root document folder called apple-touch-icon.png

Literally that - put a file called apple-touch-icon.png in your web root. Drupal doesn't affect static files, it won't interfere.


Send private message - Subject and message filled in I'm using the module Privatemsg to give users the possibility to send messages to other users on the website.

What I would like to do is:

A button on the detail page of node with type equal to Proposal, and when a user clicks on it a, they redirect to the page messages/new where the subject and message is already filled in.

Now I just have a static button on the detail page that doesn't do anything. But how can I create the functionality that they redirect and 2 form parameters are already filled in?

One way to do this is to use the Prepopulate module.  This solution is not specific to Privatemsg.

As the module page notes:

  For example, the following URL,

  http://www.example.com/node/add/blog?edit[title]=this is the title
  will automatically fill the Title field on a new blog post with the
  words "this is the title". Any field can be prepopulated this way,
  including taxonomy and CCK fields. You can prepopulate more than one
  field at a time as well.


Where is body field label stored in database Due some caching problems I can't immediately change field label via /admin/structure/types/manage/page/fields. So I thought that I will able to do it from mysql but I can't find it. Any help?

Please note, that I have developement state here /admin/config/development/performance - no caching at all, no compressing

The field label, together with all other settings are stored as a serialized array in the field_config_instance table.

Manually changing a serialized array is usually a bad idea, it can destroy the data in there if you don't know what you are doing.


How to display current pages the media entity is referenced during deletion? We are using Media Entity module that provides a Document media bundle. On our Article content type, we have created an Entity Reference field to Media that is set to Document media bundle.

When you click Delete on this Document media entity, you are taken to a Are you sure you want to delete the media <media name>? page for confirmation (not sure of the official name, but let's call it Confirm Deletion page). On this page we would like to display all the pages where this media entity is currently being referenced.

How would we display the list of nodes that are referencing the media that content editors are attempting to delete?

Additionally to the comment, here's the snippet we used based on the entity_usage module in a hook_form_alter():

  $object = $form_state->getFormObject();
  if ($object instanceof ContentEntityDeleteForm) {
    $entity = $object->getEntity();
    $usage_data = \Drupal::service('entity_usage.usage')->listSources($entity);

    if (!empty($usage_data)) {
      $count = 0;

      foreach ($usage_data as $usage) {
        $count += count($usage);
      }

      $form['usage_warning_message'] = [
        '#type' => 'container',
        '#markup' => t('This content is used in @count places.', [
          '@usage_url' => Url::fromRoute('entity_usage.usage_list', [
            'entity_type' => $entity->getEntityTypeId(),
            'entity_id' => $entity->id(),
          ])->toString(),
          '@count' => $count,
        ]),
        '#attributes' => [
          'class' => ['messages', 'messages--warning'],
        ],
        '#weight' => -100,
      ];
    }
  }


How to render input fields in a custom page template page Running into a development wall here. How does one render form/fields in a custom page?

e.g.

I've created a custom page called page--node--add--article.tpl.php (a custom page to style the editing of the article content type) though I cant render any individual input/forms as part of my overall site design.

All I can do is do  <?php print render($page['content']); ?> which loads the entire content and does not allow me to style between the different fields.

Objective: Split the article creation into two DIVs for a mobile theme that gives me a part one and then via jQuery fade (or slide) to the part 2.

You can customize your form using #prefix and #suffix in hook_form_alter(). They will add wrapper HTML markup into your form and then you can customize them with your custom CSS and JS attached to the form.

Here is an example code:

function MYMODULE_form_alter(&$form, &$form_state, &$form_id){
    if($form_id == 'article_node_form'){
        $form['title']['#prefix'] = '
';
        // more fields here
        $form['body']['#suffix']  = '
';

        $form['field_1']['#prefix'] = '
';
        // more fields here
        $form['field_5']['#suffix'] = '
';

        // attach additional css/js to this form page for your customization
        $form['#attached']['css'][] = drupal_get_path('module', 'mymodule'). '/mymodule.css';
        $form['#attached']['js'][] = drupal_get_path('module', 'mymodule'). '/mymodule.js';
    }
}

You can also add additional HTML using #markup.

$form["unique_id"] = array(
    '#markup' => "
some html
"
);


Can't get computed field to work This is the code:

$number->field_max['und'][0]['value'];

$array = array(
    "7mm Shorty over 7mm Jump" => 10,
    "7mm Shorty over 5mm Jump" => 14,
    "7mm Jump" => 13,
    "5mm Shorty over 5mm Jump" => 16,
    "5mm Shorty over 3mm Jump or 7mm Shorty over 3mm Jump" => 19,
    "5mm Jump" => 19,
    "3mm Shorty over 3mm Jump" => 20,
    "3mm Shorty over 2mm jump" => 24,
    "3mm Jump" => 24,
    "2mm Jump" => 27,
);

foreach ($array as $i) {
    $smallest[$i] = abs($i - $number);
}
asort($smallest);

$closest = key($smallest);

$suit = array_search($closest, $array);

$entity_field[0]['value'] = $suit;

$display_output = $entity_field_item['value'];

I want it to display the value closest to the number entered in the field_max field.

In response to various comments and other answers, here is some code that ought to work:

$number = $entity->field_max['und'][0]['value'];

$array = array(
  "7mm Shorty over 7mm Jump" => 10,
  "7mm Shorty over 5mm Jump" => 14,
  "7mm Jump" => 13,
  "5mm Shorty over 5mm Jump" => 16,
  "5mm Shorty over 3mm Jump or 7mm Shorty over 3mm Jump" => 19,
  "5mm Jump" => 19,
  "3mm Shorty over 3mm Jump" => 20,
  "3mm Shorty over 2mm jump" => 24,
  "3mm Jump" => 24,
  "2mm Jump" => 27,
);
$smallest_value = PHP_INT_MAX;
$closest_value = -1;
foreach ($array as $val) {
  if(abs($val - $number) < $smallest_value) {
    $smallest_value = abs($val - $number);
    $closest_value = $val;
  }
}
$entity_field[0]['value'] = $closest_value;

After this code is done, $closest_value should be set to the value closest to the initial value.  You can output this however you like.  In the display value field, there should be something like $display_output = $entity_field_item['value'];


How to use the Drupal flashcard module? I am not very familiar with Drupal modules.

I am using Drupal 7, and installed the Flashcard module. I enabled it, the flashcard-cycle module, and the libraries module; I also added the jquery plug-in as \sites\all\libraries\jquery.cycle\jquery.cycle.min.js.

I am getting the flashcard content type in structure/content types, but I don't know what else I have to do.

I need further instructions about what I need to do in order to use the flashcard module.  What is my next step?

Go to this content type's "Manage  fields" page and add new field with "Flashcard" type. Set number values you want (I think you will need Unlimited). Go to "Manage display" page and change your new field formatter from "Default" to "Cycle". Create a new node with a couple of Flashcard pairs.


Any suggestions for a adobe indesign like body field? I'm on d7. I am looking for any suggestions on modules that can give me the functionality to have a field that acts like adobe indesign. (For the purpose of this explanation I am going to call this my "canvas" field) I would like for my canvas field to be a container that holds text/images/videos/audio instead of just text like a body field would. I would like to provide my users with the ability to write some text in a something like a text box and be able to resize and position it where they want in the "container" field along with images etc. Does anyone have any suggestions? Even a combination of modules or something to get me started would be very appreciated. Thanks.

The WYSIWYG module http://drupal.org/project/wysiwyg will allow you to offer a rich text editor for your users. You can combine that with the Media module http://drupal.org/project/media to embed media files. It won't be like indesign exactly but will allow users to have some freedom with the content.


How to know current active installation profile like standard/minimal etc. on existing drupal site? I have installed minimal installation profile. Is there any entry in database where profile name is mentioned, current active profile.

I wanna get the profile name which is get installed in existing site.

If you go to /admin/reports/status, under Drupal if you see something written after Drupal version, that's your installation profile. If there is nothing, that means it is Standard profile.


After adding data to nodes using hook_node_load(), will this data be saved in the cache? When using hook_load() or hook_node_load() to add information to the node object, is it possible to have this data stored in the cache? I'd like to add several different pieces of data and it would be difficult / impossible to get this data in one database query, however, if it's caching the data with the rest of the node object, it should be fine. How do I do this if it doesn't already?

thanks!

First of all, you generally don't want to implement hook_load() and hook_node_load() for the same node type. So just FYI.

Secondly: There's a bunch of different caching you could mean... The caching you implement depends on why you need it.

If you trace back the functions that call hook_node_load(), you end up at NodeController::attachLoad(). It just invokes the hooks and then bails to its superclass, DrupalDefaultEntityController. Basically this means that node itself doesn't do any caching.

This gives you a few options:

1) Come up with your own caching system for your own subset of the node's data, which means that you have to mark all nodes using it as uncacheable, since you're caching a little bit of it.

2) Install EntityCache. :-) EntityCache does what you'd do anyway but does it for the whole node entity at the entity layer.

BUT... If the real problem we're solving here is to have a next and previous reference per node, then you want EntityReference, which lets you set that up as fields, and which can then be used with Views and whatnot, for free, without coding anything. :-)


Drupal 7 Views 3 Contextual Filter - preview works as expected, the actual page not, why? Background:

Drupal 7.2, Views 7.x-3.0-rc1

I have a view with a single Contextual Filter, 'User: Full Name'. ('User: Full Name' is a field added to the user, stores the full name of the user, like 'Peter Jackson Junior'.) In this filter's settings, under 'More', 'Case in path' is set to 'Lower' and 'Transform spaces to dashes in URL' is enabled, because the format of the path would be like this: 'site/team/peter-jackson-junior'. 'No results behavior' is set to 'Global: Text', contains 'No such user'. So the result of the view would be the profile of the user that has full name equals to argument in url.

Problem:

On the view settings page, when I test it through the preview, it works perfectly, I enter 'peter-jackson-junior' and it returns the profile of 'Peter Jackson Junior'. But, when I would like to see it in practice, and enter the url 'site/team/peter-jackson-junior' (this is actually also shown on the view preview area) in the browser url bar, I get back
'The requested page could not be found.'.

Actually, if I 'provide default value' 'when the filter value is not in the url' that is 'fixed', like 'another-full-name' it works on both the preview and the actual page (so 'site/team' gives back the profile of 'Another Full Name'), but 'site/team/another-full-name' gives back 'The requested page could not be found.' again.

Question:

What could be the problem? Could this be a bug?

Found the answer to the problem...

There are path aliases to nodes that were deleted before, and accidentally those aliases look exactly like how the view with arguments should look like. So, there were an alias of 'team/peter-jackson-junior' to 'node/xyz', this overridden the path to the view, but 'node/xyz' was deleted and so it is natural that it gives back 'The requested page could not be found.'.


Display all nodes with identical field value to current node BACKGROUND:
Site is using content types which are auto-created through Rules, called CT-A and CT-B. CT-B represents a full URL, and CT-A represents that URL domain. CT-A is always created via Rules only once, the first time a content type CT-B is created. Both content types share a field (field_domain) specifying the domain. The original content is user entered, so it isn't possible to predict the value of field_domain in advance.

ISSUE:
I need to display a simple 'related content' type view in CT-A, showing all nodes of type CT-B which match the value for field_domain. The value for field_domain cannot be pre-defined, and needs to be provided program / systematically, either by being taken from the field in the node, or as a token (same difference).

APPROACHES:
I am assuming the answer is in Views. Specifying a value for field_domain doesn't work, because the value changes based on user entry. I've tried Global: Field Comparison, but it doesn't seem to be possible to compare both the current node's field_domain and that same field in the nodes displayed in Views. I have tried using Views Panes to pass the argument for the current node's field_domain into the pane display, but it also didn't return results. I have seen various Contextual Filter PHP solutions, but they also don't seem to work (the most promising one is https://www.drupal.org/node/1006484#comment-4990312 , but this returns the following error: https://www.drupal.org/node/829250).

Taxonomy hasn't worked, because of the auto-create nature. It doesn't seem to be possible to create unique TermID by passing values in Rules - the Term name will be the same, but the TermID is different, and Views judges the Term based on its ID. It isn't possible to auto-create a Term Vocabulary in Rules due to a bug with assigning the machine name.

Entity Reference also has problems with the auto-create nature. I haven't figured out a way in Rules to reference the two types according to field_domain value, and not sure if there is one.

Search API Tried this approach (compare the search index) suggested in the link below, but again it doesn't work unless you have a predefined value for field_domain, as it requires setting the value manually.

The most obvious approach seems to be "Views filter display all nodes with same field value. But despite being obvious, this doesn't seem to be easily possible. Perhaps there is a non-Views way which I haven't considered?

Related questions to this (all seem to be unsolved):

[apologies, I'm limited by reputation...but there are at least 4 open questions in related questions to the right which are still unsolved]

Throwing it open...seems like a few people have run up against this problem. Any new ideas out there?

The way I've always handled this is to build the view in question using the "field value to match" as a Contextual Filter. For the Contextual Filter's settings, choose "Provide default value", for the type choose "PHP Code", and for the "PHP contextual filter code", load the current node and grab it's field value,

$node = menu_get_object();
return $node->field_domain['und'][0]['value'];


How do i create node directly from my own module with data of my tables I need create a node from one table of my Database of drupal with all rows that it have.

That is, I need to extract data from my table and insert them automatically and make it appear as a node. Everything from my own module (That is, when I turn on my module see my table data were converted to node).

I thought of 2 solutions for this. The first is to create the content type in my drupal site and from my module implement "form_submit". (Can you do this?).
The second (which I am trying to do) is to create my type of content and form from my module. And since I can do the integration and transformation node me on my table.

Does anyone can help me on how I can do this? A code example of how to extract data and insert them into my form and make a submit directly?

thanks

From the information you provided I would handle this the following way:

Create a custom content type via the GUI with all the fields that you need.
Create a custom module and register a path via hook_menu(). I would set 'page callback' => 'drupal_get_form', 'page arguments' => array('mymodule_create_content_form') and 'access callback' => 'mymodule_admin_restriction'. mymodule_admin_restriction would be a function to allow access to user 1 only. mymodule_create_content_form would be a custom form builder function with just a submit button.
In the form submit handler I would then write code to extract data from the database and create new nodes from it. The easiest way to get data out of your database would probably be with db_query().
For programmatically creating nodes you could use either node_save() or drupal_execute(). The first one is a quicker option while the second one more closely mimics normal node creation by invoking additional hooks. You should be able to find a solid amount of information about them on the web (for example here, here and here).

This approach should be fairly good to get started with. Once you get the whole thing working without errors (in your development environment) you could move the code to your module's install file's hook_install() and maybe even programmatically create the new content type there if needed.


Drupal 7: How may I customize the user profile? And how do I add to it profile2 fields? The profile under user/n will only show the profile picture and the username.

I´m using an Omega subtheme.
I´ve copied and pasted the default user-profile.tpl.php file, deleted everything and  added these two lines, hoping that one of them would work:

print drupal_render(field_view_field('profile2', $profile['main'], 'field_nombrecompleto1'));
print $field_profile_nombre_completo['value'];

The second line refers to the original core profile field, and the first one refers to the imported field (I´ve imported using the migrate module in D6, before I´ve upgraded to D7).

None of the fields gets printed out.
I´ve added this at the top of the template:

print "<pre>";
$vars = get_defined_vars();
print_r($vars);
print "</pre>";

And nothing happend. So I´ve added that code to the top of my page.tpl file, and it appeared the whole list of variables.
At the very top it prints:

[template_file] => sites/all/themes/liga/templates/page.tpl.php

And at some points it actually recognizes the (core profile) field:

    [content] => Array
                                (
                                    [content] => Array
                                        (
                                            [system_main] => Array
                                                (
                                                    [field_profile_nombre_completo] => Array
                                                        (
                                                            [#theme] => field
                                                            [#weight] => 0
                                                            [#title] => Apellido y Nombres
                                                            [#access] => 1
                                                            [#label_display] => hidden
                                                            [#view_mode] => full
                                                            [#language] => und
                                                            [#field_name] => field_profile_nombre_completo
                                                            [#field_type] => text
...

I´ve then deleted everything at my user-profile template and printed just XXXXXX and it didn´t printed out. It stills print the profile image and the username.

Now I have two issues here:
How to customize the profile template (user-profile.tpl.php) because it´s not recognizing the file inside my theme folder, and how to print profile2 fields information inside the user profile.

Hope anyone can give me some insight or clue.
THANKS!!!

Rosamunda

I don´t know if I should respond to my own question, because after two days not only I didn´t received any answer (which isn´t bad in itself, because nobody "has" to answer), but I´ve received a minus one point, without ANY explanation at all, wich I think is rude.

Anyway, as I´ve found by myself the problem, and other people maybe has the same issue, and as a good citizen, I shall say that the it was the "Display Suite" module.

That module, wich is installed in more than 45.400 sites, was the only reason my Drupal installation didn´t recognized the user-profile.tpl.php file.

I´m going to read more carefully DS readme, tutorials ans screencasts out there because it´s a more complex module than I thought it was. But people should know that it does that (at least right out of the box, in a D7 installation with some core profile fields, Profile2 installed, and without any tweaks in the default configuration).

Cheers.

Rosamunda


Show first view result, but show next result when the view's cache is cleared I'm trying to show a featured image on my homepage.
This image will be pulled in by a view that returns 1 result.
I then change the caching of the view to 1 day.

What I would like is for each time the cache resets the view to return the next row.

Day 1 - image 1
Day 2 - image 2
etc..

I can add the sort criteria: 'Global: Random'. But then you have the chance that some images might be shown on consecutive days and that some are hardly ever shown.

I would have used some scheduling mechanism for node publish and unpublish instead of using views chache.

Some thing as schedule a node A to publish today and unpublish tomorrow, node B is unpublished today and will be published tomorrow, meanwhile the view will always pick the published nodes.

Node scheduling can be handled by scheduler module.


With Commerce Product taxonomy term view, is there a way to have page title set to the translated term title? The only way to have the taxonomy term name in the title of a taxonomy term Commerce Products view page I've found so far is the example view in the estore theme (I still don't get how tid which should stand for Term ID becomes the title field value):

The problem is that the title shown is not translated on multilingual sites when the term definitely has a proper translation. Is there any way to show that title translated?
For some reason there are no Product: Has taxonomy term ID as there is Content: Has taxonomy term ID in the default taxonomy term view that is displaying the title translated.
AFAIU {{ arguments.tid|t }} is not the way because it will go through a different subsystem.

I had to workaround it in code by modifying an example posted by djg_tram:
/**
 * @file
 * Workaround for taxonomy term title not being i18zed.
 */
use Drupal\views\ViewExecutable;
use Drupal\taxonomy\Entity\Term;

/**
 * Implements hook_views_pre_render().
 */
function exposed_filter_workaround_views_pre_render(ViewExecutable $view) {
  $view_id = 'products';
  $view_display = 'page_category';

  if ($view->id() == $view_id && $view->current_display == $view_display) {
    $lang_id = \Drupal::languageManager()->getCurrentLanguage()->getId();

    $term_id = $view->args[0];
    $term = Term::load($term_id);

    $term_translated = $term->getTranslation($lang_id);
    $view->setTitle($term_translated->label());
  }
}


Users get a new password detect forced logout I want to create a rule:
When the user changes the new password, the system should force the user to log out and then use his new password to login.

I know the event to choose after updating an existing user account.
The next part is to be added in the ELEMENTS PHP source code to detect it?

I have tried this code. It fails, the user can no longer change the new login password.

function mytheme_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id =='user_pass'){
    $form['#submit'][] = 'mytheme_password_redirect';
  }
}
/**
* Redirects user after password reset form is filled
*/
function mytheme_password_redirect(&$form, &$form_state){
  $form_state['redirect'] = 'user/lougout';
}

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


Using views_embed_view and jquery I'm calling a block in a template like so:

echo views_embed_view('sessions_by_track', 'block_1');

where the block is actually a view display. It's set to output html lists, and I want to do some jquery stuff to it, including hiding certain elements until something else is clicked on.

Here's what the list code looks like:

Big Picture

      Partnering for Success

      The Shopper Economy

I have a scripts.js file that looks like this:

$(document).ready(function() {
  alert('test');
 $('li.views-row').hide();
});

The alert works; the hide doesn't. However, when I run that line in Firebug's console after the page has finished loading, the hide does work. So it seems that the view renders after the document.ready fires. I seem to recall reading something about this before, and there was a solution, but of course now that I need it I can't for the life of me find it. What do I need to do to get around this?

Edited to add: Drupal 6, Views2

Edited again to add: I've also tried this: in template.php added this function:

function mobile_jquery_preprocess_page(&$vars, $hook) {
  $vars['embedded_sessions'] = views_embed_view('sessions_by_track', 'block_1');
  $vars['scripts'] = drupal_get_js();
}

and then calling it in my page template like so:

print $embedded_sessions;

Same result.

Edited yet again to add that I've tried adding a new region to my template, assigning the block to that region, and then printing it with print $mobileContent; in the page template. Same result - the alert runs on load, but the hide does not. The hide runs just fine in Firebug's console, so I know the selector is OK.

Edited once more for @tim.plunkett

To a file called scripts.js, located in sites/all/themes/mobile_jquery/scripts, I added this (right now there's nothing else in the file):

(function ($) {
  console.log('behavior triggered');
  // Store our function as a property of Drupal.behaviors.
  Drupal.behaviors.myHomeHideLists = function (context) {
    // Find all the li items inside context that have our desired class
    $('li.views-row)', context)
      // hide them.
      .hide();
  };

}(jQuery));

In template.php, I added this (based on this answer):

function mobile_jquery_preprocess_page(&$vars, $hook) {
  $vars['embedded_sessions'] = views_embed_view('sessions_by_track', 'block_1');
  drupal_add_js(drupal_get_path('theme', 'mobile_jquery').'/scripts/script.js', 'theme');
  $vars['scripts'] = drupal_get_js();
}

The console.log does get triggered and printed, but the list items that match the selector do not get hidden.

Drupal provides a specific way to add JS to a page, to ensure that it is run whenever content is loaded into the DOM. This way, it will run after the document is loaded, but also after AJAX operations.

They're called Drupal behaviors.


jQuery code is loading content in an unpredictable way I've got a view of teasers; each teaser has 3 clickable  elements:

"morelink" toggles an extra row in a table.
"noderef"  loads the referenced node into a div.
"ajaxview" sends the node id as an argument to ajax load a view into a
. This view contains  a view of teasers which in turn each have 3 clickable  elements thus creating a nested view of teasers which in turn each have 3 clickable  elements.

This is the JavaScript code.

Drupal.behaviors.morelink = function(context) {
  $("a.morelink").click(function (e) {
    e.preventDefault();
    $('.xtrarow').eq( $('a.morelink').index( $(this) ) ).toggle();
  });
}

Drupal.behaviors.ajaxview = function(context) {

    $("a.ajaxclick").click(function(){
    var nid = $(".mynid").eq($('a.ajaxclick').index( $(this) )).val();
    $('.container').eq($('a.ajaxclick').index( $(this) )).load(Drupal.settings.basePath + 'myajax/' + nid);
    return false;
});
}

Drupal.behaviors.noderef = function(context) {

    $("a.nrefclick").click(function(e){
      e.preventDefault();
    var nref = $(".mynref").eq($('a.nrefclick').index( $(this) )).val();
    $('.container').eq($('a.nrefclick').index( $(this) )).load('node/' + nref );
    return false;
});
}

This is the HTML code.

<input type="hidden" class="mynref" value=<?php print $node->field_noderef[0]['nid']; ?> />
<a class="nrefclick" href = "<?php print url('node/' . $node->field_noderef[0]['nid']); ?>">

<a class="morelink" href = "<?php print url('node/' . $node->nid); ?>">

<a class="ajaxclick" href="<?php print url('myajax/' . $node->nid); ?>">

The behavior is erratic: The "morelink" works consistently and is fine; the ajaxview works intermittently, and seems to load ok for the first few clicks, but once you've clicked a few, the JavaScript stops working.

Can anyone spot the problem?

Here's what worked in the end;

Drupal.behaviors.ajaxview = function(context) {
  $('a.ajaxclick:not(.ajaxview-processed)', context)
  .addClass('ajaxview-processed').each(function() {
    $(this).click(function(e){
        e.preventDefault();
      $index = $('a.ajaxclick').index($(this));
      var nid = $(".mynid").eq($index).val();
      var toLoad = Drupal.settings.basePath + 'myajax/' + nid;
        xhr = $.ajax({
        url: toLoad,
        success: function(data) {
          $('#content').html($('.audioforumtable', data));
          Drupal.attachBehaviors(context);
        }
      });
    });
  });

 $('a.nrefclick:not(.ajaxview-processed)', context)
  .addClass('ajaxview-processed').each(function() {
    $(this).click(function(e){
        e.preventDefault();
      $index = $('a.nrefclick').index($(this));
      var nref = $(".mynref").eq($index).val();
      var toLoad = Drupal.settings.basePath + 'node/' + nref;
        xhr = $.ajax({
        url: toLoad,
        success: function(data) {
          $('#content').html($('.audioforumtable', data));
          Drupal.attachBehaviors(context);
        }
      });
    });
 });
}

I changed the container to content because it worked better for what I need but the problem seems likely to have been the lack of the Drupal.attachBehaviors(context) . Thanks to Baysaa for steering me in the right direction!  I will vote your answer up when I have enough reputation points.


Is the database table "field_revision_body" used in a core module or can I just drop it? I recently installed the revisioning module and now im cleaning it up and uninstalling it, but it seem to have created a bunch of field_revision_field_ tables in my database. Since it creates another table for every field you have, it creates alot of mess. I uninstalled the revisioning module, but these tables still stayed. I was wondering if I can just drop these? Also i see there is a field_revision_body table, but i dont know if it was generated by the revisioning module. So im asking if anyone knows what this table is used for? I tried deleting it, but i get an error when editing a node. So it must be used for something.

Both tables (field_data_* and field_revision_*) are added and used by the field SQL storage module in core. The existence of both tables make it possible to store revisions of field data. There's no way to use that storage system without both data_* and revision_* tables.

So don't delete it :)

There are modules out there defining alternative storage systems without using revision tables (e.g. Field SQL norevisions) but I'm not sure how difficult it would be to convert an existing database to use that system.


How to show Numeric keyboard while entering in textfield? I am creating a custom form field with text-field type. That will accept only numbers, so I want to display only numeric keyboard instead of alphanumeric keyboard. How can I achieve that?

I tried using Elements module but I don't want to use extra features of this module.So I am searching for code snippet. Is there any way to do it in a custom way?

First, create a module named html5_form_element. Then you need to set up the following

Implement hook_element_info() to tell Drupal about your element type:

/**
 * Implementation of hook_element_info()
 */
function html5_form_element_element_info()
{
  $types['number_input'] = array
  (
    '#input' => TRUE,
    '#theme' => 'number_input',
    '#theme_wrappers' => array('form_element'),
  );

  return $types;
}

Next implement hook_theme() to define the theme for your input type:

/**
 * Implementation of hook_theme()
 */
function html5_form_elements_theme()
{
  $theme = array
  (
    'number_input' => array
    (
      'render element' => 'element',
    ),
  );

  return $theme;
}

And finally, create the theme function that will theme your element:

function theme_number_input($variables)
{
  $element = $variables['element'];
  $element['#attributes']['type'] = 'number';
  element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength'));
  _form_set_class($element, array('form-number'));

  $extra = '';
  if ($element['#autocomplete_path'] && !empty($element['#autocomplete_input']))
  {
    drupal_add_library('system', 'drupal.autocomplete');
    $element['#attributes']['class'][] = 'form-autocomplete';

    $attributes = array();
    $attributes['type'] = 'hidden';
    $attributes['id'] = $element['#autocomplete_input']['#id'];
    $attributes['value'] = $element['#autocomplete_input']['#url_value'];
    $attributes['disabled'] = 'disabled';
    $attributes['class'][] = 'autocomplete';
    $extra = '<input' . drupal_attributes($attributes) . ' />';
  }

  $output = '<input' . drupal_attributes($element['#attributes']) . ' />';

  return $output . $extra;
}

Clear your caches, and you can now use '#type' => 'number_input' in the Form API.


Views block: Displaying a content block on profile page (/user) with user's chosen tags as contextual filter I have a block on the user's profile page that filters content based on the supplied tag as an argument/contextual filter. Users on my site can add tags to their profile (with an autofill field pulling from the free-tag taxonomy) -- these tags are topics that they want to "follow." I would like this block to display content that is tagged with the tags they've personally chosen. thanks in advance!

I have found a solution to this. Using a user view instead of a content view was the way to go for me. Then adding appropriate relationships on the teaxonomy term.

I used the these directions:

Create a user view.
Add a contextual filter on user: uid. If no filter value is present, build a default value using the currently logged in user. (This will give you exactly one user object in your view -- the logged in user.)
Add a relationship, using the relevant taxonomy reference field on the user accounts. This will bring you information about the "interest" term for the logged in user.
Add another relationship, called "term: nodes marked with term" (or something like that). This will bring you information about all nodes marked with the interest term for the logged in user.

From this article:
https://drupal.org/node/1111722

Hope it helps!


Uploading an image with JSON:API; getting "Access denied" I'm attempting to upload an image with JSON:API.
I have added an Image field (not a media field) to the user entity.
In Postman, I get a session cookie for testing.
Then, in accordance with Flow 2 in the JSON:API upload file documentation, I configure my request:

I added image data as a binary to the request body.
However, when I send the request, I get the following error:
    "title": "Forbidden",
    "status": "403",
    "detail": "The current user is not permitted to upload a file for this field. The 'administer users' permission is required.",

I don't know why it is saying I need administer users permission.
When I log in as the same (authenticated, non-admin) user and then go to the user edit page, I can edit the image field (save a new image, remove the existing image) without any problem.  So why am I getting a permissions error in JSON:API?  I thought JSON:API permissions were supposed to be exactly the same as in the Drupal UI.

I wasn't able to get it working with Flow 2 in the docs; I kept getting a Needs "administer users" permission error (which is incorrect; users have permission to edit the field).
So instead, I used Flow 1:
POST /jsonapi/node/article/{uuid}/field_image HTTP/1.1
Content-Type: application/octet-stream
Accept: application/vnd.api+json
Content-Disposition: file; filename="filename.jpg"

[… binary file data …]

This requires the user to already be created, which is OK for my user case, but may not be the case for everyone.
Additional notes

I had to turn off the popular Filefield Paths module for my image field because it breaks JSON:API.

I had to uncheck Alt field required in the image field settings; if you leave the alt field required, you get this nasty error:
  "detail": "The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\\Core\\Cache\\CacheableResponse.",


Manual setup of user's language I need to switch user's language programmatically. The issue is I don't want it as an url part, and unable to switch it even with the regular language switcher block.

What I've try:

admin/config/regional/language/detection: Disable url, Enable Session
Now the Language Switcher core block adds ?language= to the current path. But this setting does not persist between pages, and does not appears in the session.
manual setup of $_SESSION['language'] does nothing
\Drupal::languageManager()->setConfigOverrideLanguage($language_manager->getLanguage($langcode)) does nothing

Drupal version is 8.beta2

I don't really understand your use case correctly, but probably you need to implement a language negotiation manager. See an example at /core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationBrowser.php.

If you also need to change the url for adding language, or changing how the links in language switcher work, you may need to override some more methods. See an example at /core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php.


How do I update configuration/database after a core update? This may seem like a dumb question to some of you, I'm sure. After having worked with Drupal from version 6, I'm now for the first time using Drupal 8 and -- after some initial difficulties -- have actually come to enjoy the new development process (using Composer and Configuration Management etc.). However, I'm still failing to understand the indended workflow, after having completed a core update in my local installation. Here's my understanding, so far:

In case of simpler modifications -- like, say, having created a new content type -- I usually call drush cex on my local Drupal site, then transfer the contents of the sync directory to my staging (or production, if I'm feeling venturous) site (using FTP) and go to Configuration > Development > Configuration Synchronization to apply the changes. (Note that I can't call drush cim at this point, as I'm not able to use the terminal in my staging/production site.)
If any content has been created for that new content type in my local site, I transfer that content to staging using the Deploy module.

So far, that's working pretty well. However, how am I supposed to proceed, after having completed a bigger update that involves non-trivial modifications to the database?

Say, I'm performing a core update: composer update drupal/core --with-dependencies
I will then perform the necessary database updates locally, either by calling drush updatedb or by visiting update.php in a browser.

But then what?

Say, I'll upload all the new files via FTP to the staging site. Clearly, I cannot also copy the local database to the staging site, because the contents would be overwritten. So, I need to import the new configuration to the staging site... but accessing Configuration > Development > Configuration Synchronization to update the database will probably result in an error, exactly because the database has not been updated, yet.

This is where I'm stuck. I suspect, there's a piece to the puzzle that I'm missing, but what is it?

Updating Drupal 8 roughly goes like this. First in a local instance of your site:

Run composer update drupal/core --with-dependencies to update core. (Updating all dependencies including contrib would be composer update --with-dependencies.)
Now apply database updates by either drush -y updb or by visiting /update.php in your browser.
Next export the config that may have changed now by either drush -y cex or from your Drupal back-end in the browser.
Git commit and push the updated composer.lock file and the updated config files.

Next on your live site you roughly do the same, but now import the config at the end.

Git pull the updated composer.lock and config.
Run composer install --no-dev to update the files.
Run drush -y updb or visit /update.php to apply the database updates.
Run drush -y cim or visit your admin settings to import the updated config that now should match the one you exported locally earlier.

For a more advanced deployment flow, for example flushing cache and activating the maintenance mode, see my other answer on Order of drush commands for automated deployment?


How to set a field's 'translatable' property When I create a new field type in Drupal it seems to be automatically assigned a 'translatable' property and it's not always right. For example, I would expect a Long Text field type to be marked as translatable = TRUE, but for some reason it's coming in as FALSE sometimes. However, body is TRUE.

Is there a place where this property is exposed in the UI and changeable?

I have the i18n module installed and enabled.

Entity translation exposes a checkbox which allows to set the translatable property.

It also provides a user interface to actually use field translation, there isn't much you can do with translatable fields without that module anyway.


How to convert an HTML website with stylesheets to Drupal 7 nodes? I have a question. How can I convert a site with a few stylesheets.css file for the layout into Drupal 7. I'm not so worried about the content of the site, that is not so much. But I would like the layout to be converted to a drupal 7 theme. How can I do that whitout making a hole new theme my shelf. I'm just a beginner with Drupal and want a quick resulte.

Thank you for your help.

What you are looking for to avoid creating a whole theme from scratch is known as a starter theme.  Starter themes are special themes designed to not work as themes by themselves, only to be used as foundations for a theme you build on top of them (the latter is known in Drupal-speak as a sub-theme). I.e. starter themes are theme framworks that "reset" the CSS, so that you can rebuild the CSS without having to think about inherited styling.

Pick the starter theme that looks like it best suites your needs, and build on that.

As for stater themes: Zen is the one that most people use. The other one I will recommend is Basic.  It is a stripped down fork of Zen. As a bonus, both are responsive by default.


SWF Tools install/ setup of media players I'm trying to get any of the mp3 players in the SWF tools to work they all say (under /admin/settings/swftools/handling):

JW player: Missing flash_media_player/player-viral.swf
1 pixel out: Missing 1pixelout/player.swf
etc. for the other players...

I followed the download link and tried putting the downloads under /SwfTools/Shared -- and in the players direct folder e.x. /sites/all/libraries/mediaplayer4/player.swf.  But, the missing file warning isn't going away which is preventing me from being able to activate any of the mp3 players.
I just wanna get these media players working.  Anyone come across this situation?  Thank you.

Figured it out.  As you said chellman the version matter greatly.  I had to go under:
/admin/settings/swftools/flowplayer3 and under plugins I had to change the Player File from the default to flowplayer-3.0.7.swf.  Than you have to manually create the directory /sites/all/modules/swftools/shared/"flowplayer3" where you add the plugin.  So, there it is!


What's the best way to create a content type with multiple fields that link to an external URL? I have a content type named "News Clip" that has four fields; Title, Description, Image, URL.

In my display, I want the Title and Image to link to the URL value.

Drupal has the concept of linking these fields to "Content", but that means the node itself.  I want them to link to the URL.

I use Display Suite for my other content types and would like to avoid having to use a field template.

Is this possible?  How?

Thank you.

I usually set the fields to "hidden" under the "manage display" tab, and then print the fields however you like with a block view.

Just place that block view to appear on that content type only, and with a contextual filter to get content ID from URL.

You can also use the Title module to replace the title from the content type, which you can then hide and display in the same block view.


Generating  with the form API I  have a heavily themed form to integrate, whose structure is shown below. I am just about there for the most part except for the submit.

 <form action="#">
   <fieldset>
     <legend>Authentification</legend>
       Courriel*
       <input type="text" name="email" id="email">
       Mot de passe*
       <input type="password" name="password" id="password" class="last">
       Forgot password?
       <button type="submit" class="clearfix">Login</button>
   </fieldset>
 </form>

I have tried many different combinations, turns out button_type has no effect on core. So I used this hack, hoping it would fix my issue. Alas, it only changes the 'type' attribute (obviously), and not the element itself. The button type can hold other elements, in this case the span is needed to hold a background image, it needs to be in a span to stretch as the text in the button is dynamic.

Does anyone have a clue as to how I can generate the following line of markup using the form API?

<button type="submit" class="clearfix">Login</button>

As an addition, just in case someone runs into the same trouble as I did - when using the #markup or #prefix/#suffix trick on a form's actions group, the submit callback function won't be called at all, unless a submit type element is present. My workaround was like this:

$form['actions']['submit'] = array
(
    '#type' => 'submit',
    '#value' => '',
    '#attributes' => array( 'style' => array( 'display: none' )), // hide the input field
    '#submit' => array( 'my_callback_for_the_form_submit' ),
    '#prefix' => '<button type="submit" class="btn btn-primary">Add <i class="fa fa-plus-square-o">',
    '#suffix' => '</i></button>',
);

That way you can use custom HTML for submit action groups.


Pass argument to view block within a minipanel I am having a panel page, within the panel page there will be multiple minipanels in each row.
The mini-panels have 2 views both which displays content based on the argument passed.

Basically the all the minipanels are same. The views within are also same. Only the argument passed change. But I am not getting how to pass argument.

See the below picture for detail.

In the end we'll have something like this. A repeated series of same panels and views with different contents.

I am not able to find out whats wrong.

I just solved the exact same thing on my site, so writing it up here for future reference.

Your views:

Create these as content panes
Contextual filter = Content: thas taxonomy term id (in this case)
Argument input (under "Pane settings" in the view) = "Input on pane config"

Your mini panels

Context -> Required context: taxonomy terms
Content -> (Your views) -> Settings -> "Term id" (probably named differently) = %taxonomy_term:tid

Your main panel

Context: Add taxo term id. You will have to add each term id you will want to use as a context here.
Content -> (Your mini panels) -> Settings, select the term you would like to use on that instance of the mini panel:


How to filter nodes using date field I have a content type of "Class" that has a date field attached to it field_class_date.

When a node of the type "Class" is viewed, I would like to display links to other classes that are on the same day of that particular class.

I tried doing this with views, but couldn't quite figure it out.

To solve this, (1) I placed code in node--class.tpl.php which retrieved the current class date

$date = entity_metadata_wrapper('node', $node)->field_class_date->value->value();

Then, (2) I modified that value to get the start of the day and the end of the day ($start and $end) in the following format: Y-m-d H:i:s

(3) Perform a query using EFQ to grab a list of the nodes that share the same date:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'class')
  ->fieldCondition('field_class_date', 'value', array($start, $end), 'BETWEEN')
  ->fieldOrderBy('field_class_date', 'value', 'ASC');
$result = $query->execute();

(4) Loop through each result and create the content I want to display later in node--class.tpl.php

foreach($result['node'] as $i) {
  $node = node_load($i->nid);
  $date = entity_metadata_wrapper('node', $node)->field_class_date->value->value();
  $name = entity_metadata_wrapper('node', $instructor)->field_class_instructor->value();
  // Build a string of output that I want to display later in the $content array
  $classes_today = etc...
}

(5) Finally, I added the $classes_today string to the $content array:

$content['more_classes']['#prefix'] = '
Classes on this Day:

';
$content['more_classes']['#markup'] = $more_classes;
$content['more_classes']['#weight'] = '4';
$content['more_classes']['#suffix'] = '
';


Entity reference and associated data Assuming I have two distinct entities A and B, with B having an Entity Reference field to A, how can I associate other data (=other fields) with the Entity Reference?

For example, assume that A is "Political parties" and B "Politicians", and I'd like to store a date range field for the politician's membership in said party.

You can create a paragraph type (paragraph module replaces field collection in Drupal 8) which contains a reference to your entity type A and a (or more) date and in your entity type B, have a reference to this paragraph.

You can also create a custom field which contains a reference to your entity type A and a date if you want have particular behavior (for example, don't allow users to sort items and sort them automatically by date).