texts: Change a div content after click on another div

texts:
I would like to achieve, if is possible, change the content of a div with another content of the same type. For example I have two nodes whose content type are "news" but i want them to render on the same page after clicking on their links.

Tried to achieve with jQuery but i have an undefined error.

This is my code:

  $(document).ready(function() {
    var selector = '.title-noticia a';

    $(selector).click(function(e) {
      e.preventDefault();

      $.ajax({
        url: $(this).attr('href') + '?ajaxrequest',
        success: function(data) {
          $('.region-content').replaceWith(data);
        }
      });
    });
  });
})(jQuery);

But it doesn't seem to work, is there any way to achieve that without the use of AJAX links API? (It's to slow for me).
Thanks in advance!!!

UPDATE 1:

After some research, i managed to make it work (on the console), but the content doesn't replace on the page view.

This is my new code:

(function ($) {
  Drupal.behaviors.mybehavior = {
    attach: function (context, settings) {

      $('.title-noticia a').click(function(e) {
        e.preventDefault();

        $.ajax({
          url: $(this).attr('href'),
          type: 'post',
          data: {
            view_name: 'articulos_actualidad',
            view_display_id: 'page_2'
          },
          dataType: 'json',
          success: function (response) {
              $('.region-content').replaceWith(data);
              Drupal.attachBehaviors(); //Check on the console
          }
        });

      });
    }
  }
})(jQuery);

But the only result i have is:

XHR finished loading: POST "http://www.example.com/somerenderedpage".

So it literally works but i cannot see the results on the page.

Hope you can help me. Thanks!

UPDATE 2:

I will post what i want to achieveI have a headache :) trying to make it work. What i want to achieve is to display the content of the selected link on a div. So i made a graphic so you can understand.

When i click on link 1, i want to display on the main div the content of the link 1, the same with link 2, 3 and X.

Is there any way to achieve that? tried with jQuery AJAX but the performance is poor, the same programatically making an ajax call.

I know i can do something like an slideshow but with content, but i cannot figure it out. Could you lend me a hand please? I will appreciate it. Thanks!


texts: Find and display lowest value from one field in a node type

texts:
I have a Drupal 7 website that tracks values associated with "Content Type A". I have another content type, "Content Type B", which is a part that is associated with Content Type A. Any A item may have one or more B items associated with it:

A-101 (B-201 B-202 B-203)

A-102 (B-301)

Each B item has a field that shows its total number of available uses (its limit, if you will). This is a static integer field. Each A item has a field that shows "aggregated uses" of that item, based on a third content type: "Content Type A-Usage". The "aggregated uses" field in A uses Views and aggregation to add up the A-Usage items referenced/linked to that A item.

I need to take that aggregated A-Usage value and subtract it from the "B-available uses/limit" value, and then display that result in a view or a CCK field.

So let's say A-101 has an aggregated usage of "100", and B-201 has a limit of 500 uses. I need to display the remaining uses for B-201 (400, in this case) in a view or CCK field.

One step further, I also need to take into account the remaining uses for B-201, B-202, and B-203, and pluck the lowest value from those remaining uses and display it in a view/CCK field. Let's say B-201 has 400 remaining uses, B-202 has 350 remaining uses, and B-203 has 100 remaining uses. The view/field in question would simply display "100", as that is the lowest remaining value of those B items.

I'm hoping someone can point me in the right direction, or provide some type of php snippet or guidance to help me accomplish these tasks. Views would be my method of choice, as much of the site's pages are already compiled using Views.

Thanks!


texts: Entity "changed" timestamp is not incremented on $entity->save() only on a form submit; feature or bug?

texts:
Anyone know why the changed timestamp is not updated when you save an entity programmatically (e.g. $entity->save()) but it is updated when you (for example) use the node form to edit the entity.

Is this intentional? If so, why?

If not, I'll open an issue on D.O.

Thoughts?


texts: When no terms are chosen as filters in a view all results are returned

texts:
I have a view with exposed filters that are taxonomy terms. These are multiple select.

When none of the options are selected the nodes are not filtered by that vocabulary so everything is returned. But what I need to happen is only noes not tagged with any of those terms be shown. Can this be done?


texts:
I am migrating a Drupal 7 project from one PC to another and I did the following steps

  1) Copy pasted the root folder into D:\XAMPP\htdocs    2)
  Imported the database of that project into phpmyadmin (had to increase
  max_file_uploads to 20 in php.ini)  3) reset admin password
  by referring https://drupal.org/node/1023428  4) updated the
  password in settings.php  5) cleared cache in the imported db
  (by deleting the content of cache and cache_* tables)

Now I am able to login but the admin panel is blank, When I click Dashboard, Content, Structure, Appearance etc. nothing appears

No error is console.

PS: this is the first time I am using Drupal, so in-depth instructions is much appreciated

Edit

After @Randell's suggestion I had set display_errors to on and error_reporting to E_ALL. Still no error appears anywhere

Edit
From watchdog the last two rows;

Second-Last row

  uid : 1 Message : Session opened for %name. location :
  http://localhost:81/mysite/user referer :
  http://localhost:81/mysite/user

Last Row

  uid : 0 Message : Attempting to re-run cron while it is already
  running. location : http://localhost:81/mysite/users/admin
  referer : http://localhost:81/mysite/user


texts: How to add UNION with pagination in drupal 7 query?

texts:
My query is like :

$query_club = db_select('club_members','cm');
$query_club->fields('cm',array('first_name','last_name'));
$query_club->group_by('cm.uid');

$query_network = db_select('network_members','nm');
$query_network->fields('nm',array('first_name','last_name'));
$query_network->group_by('nm.uid');

$query_club->union($query_network, 'UNION');
$result = $query_club->execute()->fetchAll();

And its giving me correct result.

I want to add here pagination,

$query_club = $query_club->extend('PagerDefault')->extend('TableSort');

But its not working. Can any one help me out


texts:
Whenever I delete a field I get WSOD with following error:

  Drupal\Core\Field\FieldException: Attempt to create a configurable
  field of non-configurable field storage variations. in
  Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (line 315
  of core/modules/field/src/Entity/FieldConfig.php).

This site was created by taking a minimally setup site and using Features, I migrated over bundle configuration from another site. Features can't do this without continually failing due to dependency errors. For many of these errors; the only solution was to delete the yml file causing the issue. My guess is that Features has somehow corrupted my site, but:

the field is deleted despite the crash (as far as I can tell)
this issue occurs even for fields and bundles which existed prior to any Feature modules being enabled
this issue occurs even for new bundles and new fields that I create after Features migration has been done
the bundles which were migrated using Features all appear to work correctly in as far as I can add new fields and I can add new entities.

I have done cache rebuild, run cron and run db update.

Also of note: the original site which the configuration was migrated from runs as a multisite on the same docroot. This means it has the same composer installed version of Drupal 8.8.1 as well as all the same modules and same versions of those modules as the site which does not work. The original site has no issues deleting fields.

EDIT

4k4's comments below led me to this Commerce issue: https://www.drupal.org/project/commerce/issues/3100553

but still no luck. After "completely" uninstalling Commerce i still get his error when trying to delete a field:

  Drupal\Component\Plugin\Exception\PluginNotFoundException: The
  "commerce_product" entity type does not exist. in
  Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of
  core\lib\Drupal\Core\Entity\EntityTypeManager.php).


texts: Problem Migrating SQLite to MySQL using DBTNG module

texts:
I need to convert a Drupal site that uses SQLite so it'll use MySQL instead. After some research I've found the DBTNG module which does seem to fit the bill, however every time I try to migrate the dbs I get the following error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'An User Name' for key 'name'

Please note that I have a large number of users in my site. When I tried to remove the aforementioned user and tried migrate again, I got the same error referring to a different user.

Any ideas on how I can get this to work?


texts: Is there a way to have a d7 multi-site build with the same database, header, footer, sidebar but when a sub-domain is called it will display a different content type.


texts: Set entity reference revision field value?

texts:
How do I set entity reference revision value for a field? I have two fields, field_test_entity_reference and field_test_entity_revision. field_test_entity_reference is of field type entity reference and field_test_entity_revision is of type entity reference revision. Both are referring to the same content type. I have created a node of this content type and its id is 7747. I am trying the below code and it sets value correctly for the field which is of type entity reference but not for entity revision version.

$node-field_test_entity_reference->target_id=7747;
$node-field_test_entity_revision->target_id=7747;
$node->save();


texts: How to hide horizontal tabs on page load?

texts:
I have installed the field group module for horizontal tabs, so I can put several nodes in a tab via rendered node.

The question is simple:

How can I hide these tabs on page load?
I want to show the links but only when the user clicks on it, the tab shows up.

Thank you for your collaboration.

Gael


texts: Remove the image style from node--type.tpl.php

texts: Is there a way from a node--'type'.tpl.php template to remove the image style of an image field?


texts: How can I apply logic in user registration welcome emails?

texts:
I am trying to put some logic into user registration welcome emails. Simple "if-then" logic, based on tokens.

The tokens I use show up as expected, but both twig and php code gets sent as plain text.

Can I somehow make twig or php code execute before the email is sent to the new user?

UPDATE, to make the question more specific:

I have token module enabled.

I am trying to add this logic to the welcome email sent to new users at "/admin/config/people/accounts":

{% if [user:field_marketing_package] == "Yes" %}

Marketing selected

{% endif %}

The [user:field_marketing_package] field is filled out at user registration.

I would like to add logic like this. If I have the above twig code in the message, it just gets sent as plain text and does not execute.

Twig or php or any other solution is fine as long as I can include the token in the if statement.

Can you point me to the right direction?


texts:
I am using Drupal 7. I want to sync my Drupal website roles on 2 websites on the same top level domain, as in, one is example.com, the other is other.example.com, how can i achieve this? Bakery module does not seem to share user roles, and i want to avoid sharing databases across my sites since it works but not recommended.

Basically, i want to reduce loading time on my main site and push my payment system (which contains many modules) to a new Drupal install so that when the payment is made on the slave site, the user role is updated on the slave site which is in turn captured on the main site. How can i achieve this?


texts: Get nodes of a particular content type attached to a group

texts:
I want all the nodes of content type 'Site Address' attached to a group. I have written the following code. It doesn't seem to work.

$gid=$form_state['values']['group_id'];
$query = db_select('node', 'n')
        ->condition('n.status', 1, '=')
        ->condition('n.type','site_address','=')
        ->fields('n', array('nid'));
$query->join('og_membership', 'ogm', "ogm.gid = :gid AND n.nid = ogm.etid AND ogm.entity_type = 'node'  ", array(':gid' => $gid));   $result=$query->execute()->fetchAll();

dpm($result);


texts:
I am working in a project that requires the use of organic groups and I was wondering is there is a way to setup a "global" drupal role that will give the users with that role access to all groups as managers.

Note: This managers might not be the user that created the group.


texts:
I'm seeing an interesting anomaly (?) I'm trying to get to the bottom of. I've set up a view with an exposed filter Search: Search Terms. I am trying to mimic the result set offered by standard drupal search module, but am finding interesting results based on the score.

When I search for "term1" (no quotes) in both standard site search, and within the view:

result set is similar, but not the same.
actual score returned for items in sitewide search, and views search are different.

So I guess, my question really is "where is the search modules' results score coming from, and how can I recreate it within a view?"

I should add I am not using any special search modules at all, just core search module.

Core search sql, as viewed from devel:

SELECT i.type AS type, i.sid AS sid, SUM((45.0578814438 * i.score * t.count)) AS calculated_score
FROM search_index i
INNER JOIN node n ON n.nid = i.sid
INNER JOIN search_total t ON i.word = t.word
INNER JOIN search_dataset d ON i.sid = d.sid AND i.type = d.type
WHERE (n.status = :db_condition_placeholder_0) AND( (i.word = :db_condition_placeholder_1) )AND (i.type = :db_condition_placeholder_2) AND( (d.data LIKE :db_condition_placeholder_3 ESCAPE '\\') ) GROUP BY i.type, i.sid
HAVING (COUNT(*) >= :matches)
ORDER BY calculated_score DESC
LIMIT 10 OFFSET 0

From the created view:

SELECT node.title AS node_title, node.nid AS nid, node.type AS node_type, SUM(search_index.score * search_total.count) AS score, 'node' AS field_data_body_node_entity_type, 'search_test:page' AS view_name
FROM
{node} node
LEFT JOIN {search_index} search_index ON node.nid = search_index.sid
LEFT JOIN {search_total} search_total ON search_index.word = search_total.word
WHERE (( (node.status = '1') AND( (search_index.type = 'node') AND( (search_index.word = 'test') ))))
GROUP BY search_index.sid, score, node_title, nid, node_type, field_data_body_node_entity_type, view_name
HAVING (( (COUNT(*) >= '1') ))
ORDER BY score DESC
LIMIT 10 OFFSET 0


texts: How to set files public directory programmatically?

texts:
I have standalone script for adding some files to Drupal nodes. It is in main Drupal directory. It is multisite enviromnent. I know how to choose database and I am sure that I am choosing proper database, but my files lands in sites/default/files but I want them in sites/domain/files. I am getting public files path by

drupal_realpath('public://')

It returns sites/default/files.

All other things are correct and file data lands in proper database.

I checked site (admin/config/media/file-system) that database I am using and this path is set to site/domain/files...

Is there any chance to set public path programmatically? So file_copy will use proper path.

EDIT

The reason that I am asking is that my hooks: hook_file_presave doesn't invoke and I am thinking that is because public path problem. (All required module are enabled)

In single site env script works ok.

Probably the only solution is to create module, but it strange it isn't works.
I wanted to stay away from creating modules for long running task because it's take longer and Batch API is slower that good old CLI. All my previous scripts worked with multisites.


texts: Getting the image URL from a field_image on a node

texts:
So I have this Node:

object(Drupal\node\Entity\Node)[1862]
  protected 'values' =>
    array (size=17)
      'vid' =>
        array (size=1)
          'x-default' => string '7' (length=1)
      'langcode' =>
        array (size=1)
          'x-default' =>
            array (size=1)
              0 =>
                array (size=1)
                  'value' => string 'en' (length=2)
      ... (more fields)
      'field_image' =>
        array (size=1)
          'x-default' =>
            array (size=1)
              0 =>
                array (size=5)
                  'target_id' => string '1' (length=1)
                  'alt' => string '' (length=0)
                  'title' => string '' (length=0)
                  'width' => string '150' (length=3)
                  'height' => string '120' (length=3)

Now the field_image has an array with x-default and some basic image data. How do I show the image, or create a link to the image inside the Twig template?


texts: Display a list of a user's Organic Groups

texts:
While searching, I've found a lot about how to programmatically add things to groups, but I'm wondering if there is a function that will take a parameter identifying the user and return a list of their groups.

Is there a function that takes user info and returns a list of groups for OG in Drupal 7?


texts:
If I am using the Libraries API module to add a javascript library in my module, is it possible to have the library load in the footer instead of the header?

If not is there an alternative method?


texts: IMCE browser just won't work (403 error)

texts:
I've installed IMCE to the CKeditor 4.54.4 in Drupal 7.41 (all in latest versions) and configured it both from editor appearance and file browser settings.

Seemingly I did all by the book and there are no errors in the status report.

I flushed all caches and switched to the full-html text editor format.

I then clicked on the CKeditor image icon, and there on "browse files" button created by IMCE.

Than I got an error (translating this from Hebrew): "The page is not reachable" (403 error). The path of the window, if it helps is:

imce?app=ckeditor|sendto%40ckeditor_imceSendTo|&CKEditor=edit-body-und-0-value&CKEditorFuncNum=155&langCode=en

Maybe you have an idea?


texts: I am developing a site, in which my client has only access to sites/default/files path(their company allows only this path as public) today i got a new requirement that theme files such as css and js needs to be editable by admin , so they want theme files in sites/default/files/themes/site-theme. Is this achievable ? if so please give me any ideas on this .


texts:
I succesfully get user name, surname and date to render in comment.html.twig like this

function MYTHEMENAME_preprocess_comment(&$variables) {
    $comment = $variables['comment'];
    $variables['user_name_comment'] = $comment->getOwner()->field_first_name->value;
    $variables['user_surname_comment'] = $comment->getOwner()->field_last_name->value;
    $variables['created'] = \Drupal::service('date.formatter')->format($variables['comment']->getCreatedTime(), 'conference_date');
}

In node template i got field_picture to render like this

$variables['author_picture'] = $node->getOwner()->field_picture->entity->url();

But i can't get my field_picture from user to render in comment twig file. I try to show the author's picture of every comment.

Any ideas?


texts: How do I create custom content types in drupal?

texts:
I need to create a content type that is similar to a textarea, but I need to do some server side formatting before it can go out to the page.

I want a user to be able to input a chunk of text, then if it's a link of a certain type, leave it be, if it's not a link, create a link of sorts out of it with some server side (PHP) magic.

Can this be done in Drupal? Can someone point me in the right direction?


texts:
I'm using the S3FS module to use an AWS S3 bucket as my sites/default/files directory.
When I upload images they are successfully uploading to the bucket.
I edit a node and include the same images via ckeditor in page content and save my node but when I view the page the images fail to load. The network tab shows 503 errors against the images I am trying to display. I attached a screen shot below:

When I inspect the node content I find that each of the images src is a relative path and when I right-click and open in a new tab, it attempts to open the image using the website domain rather than a S3 url.
Can anyone help me understand and resolve this issue?
**UPDATE: **
I added the following to settings.php in an attempt to correct the domain of the images but it did not have the desired effect:
$conf['s3fs_root_folder'] = 'https://s3.eu-west-2.amazonaws.com/my.test.bucket';
$conf['s3fs_domain'] = 'https://s3.eu-west-2.amazonaws.com/my.test.bucket';

I haven't information describing the various settings effects so the abouve was a guess.


texts: Display field collection items together with nodes in view sorted by date

texts:
I would like to create a view, which would list all the events of an organization (please look at the mockup). The problem is, that some of the are part of longer series, so I had to group them somehow. So now I have 2 content types (Event and Series of Events), the latter contains Field Collection field with multiple instances, which is used for sub-events. (Please see the scheme)

I use common date field for "Event" nodes and "Sub-event" field collection items, but I can't sort by it, because for "Sub-event" I would need to use relationship, which disables sorting of events.

So my question is: How would you create something like this?

I am using Drupal 7, Wiews 7.3 and latest version of Field Collection.

For better understanding of my problem, please look at following images (sorry, I can't post images because I'm new here):

Scheme

Mockup of view


texts:
I'm developing a custom module with an image field.

Where can I set the following HTML attribute to my custom field?

<input type=file
       accept="image/*"
       capture=environment>

I have created the image field and i'm able to process some OCR with an external library uploading the image but I need to use webcam instead and I can't find the way to set the "capture=enviroment" tag to my input form in the field widget file.

Thank you


texts: Why would single-use (harcoded) tokens not validate in the Message module, when the dynamic version does?

texts:
In the Message module, why does the following dynamic token validate nicely [message:field-message-content:body] but the single-use (harcdoded) token does not @{message:field-message-content:body}

Basically changing [token] to @{token} doesn't work.

Note: I know I have to create a new message and just can't change the template on the fly to back-propagate existing messages.

For reference from the module's readme.txt:

  Tokens

  "Dynamic" tokens   When defining a message type, it is possible to use Drupal tokens in any of the   message fields, in order to inject
  certain content into the field on the fly.   E.g. Entering the string
  "[current-date:short]" to the message text will   display the current
  request time instead of the token.   E.g. [message:user:mail] will be
  replaced with the message author's username   (When displaying the
  message).   If the message has fields (e.g field_node_ref), its
  contents will accessible   by the token system as well under
  [message:field_node_ref].   (For instance:
  [message:field_node_ref:title]).   This relies on "Entity token"
  module that ships with Entity API.   Enabling "Token" module is also
  recommened, as it provides more tokens   and shows a token browser in
  the message type creation page.
  "Single use" tokens   The single-use tokens are similiar to the dynamic tokens, excepet they're   being replaced by their content as
  the message is created; Meaning this   content will not get updated if
  it's reference gets changed.   E.g. "@{message:user:name}" - Will be
  replaced by the message author's name   (When creating the message).
  You can use this for example when you know the user's name is not
  going   to change, so there is no reason for re-checking all the time
  the user   name -- hardcoding it makes more sense.

Note: There is nothing in the error logs. Essentially when I use the dynamic token, it works and if I change it to a hardcoded token, then it doesn't. Basically changing [token] to @{token} it no longer works. I know I have to create a new message and just can't change the template too.


texts:
I'm trying to run Drupal 8.0.5 on Apache 2.4 behind an Nginx reverse proxy (both on the same host). However, I'm running into problems w.r.t. trusted_host_patterns, i.e. I'm getting The provided host name is not valid for this server..

In Apache, the HTTP Host header doesn't contain target host of the original request but the reverse proxy (since I'm using mod_remoteip). However, I have set up Nginx to pass on the Host header value of the original request in the X-Forwarded-Host header:

proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host   $host;
proxy_set_header X-Forwarded-Port   $server_port;
proxy_set_header X-Forwarded-Proto  $scheme;
proxy_set_header Forwarded          "for=$remote_addr;proto=$scheme";

I have also told Drupal that it's running behind a reverse proxy:

$settings['reverse_proxy'] = TRUE;

/**
 * Specify every reverse proxy IP address in your environment.
 * This setting is required if $settings['reverse_proxy'] is TRUE.
 */
$settings['reverse_proxy_addresses'] = ['127.0.0.1'];

/**
 * Set this value if your proxy server sends the client IP in a header
 * other than X-Forwarded-For.
 */
# $settings['reverse_proxy_header'] = 'X_CLUSTER_CLIENT_IP';

/**
 * Set this value if your proxy server sends the client protocol in a header
 * other than X-Forwarded-Proto.
 */
# $settings['reverse_proxy_proto_header'] = 'X_FORWARDED_PROTO';

/**
 * Set this value if your proxy server sends the client protocol in a header
 * other than X-Forwarded-Host.
 */
# $settings['reverse_proxy_host_header'] = 'X_FORWARDED_HOST';

/**
 * Set this value if your proxy server sends the client protocol in a header
 * other than X-Forwarded-Port.
 */
# $settings['reverse_proxy_port_header'] = 'X_FORWARDED_PORT';

/**
 * Set this value if your proxy server sends the client protocol in a header
 * other than Forwarded.
 */
# $settings['reverse_proxy_forwarded_header'] = 'FORWARDED';

Hence I don't understand why the hostname validation still fails. If I disable mod_remoteip then both Host and X-Forwarded-Host contain the original target host, and in that case hostname validation succeeds. It seems that Drupal fails to use X-Forwarded-Host instead of Host.


texts: More than one image leads to no images displaying

texts:
I am running Drupal 7 with the 'Simple Corporate' theme by Devsaran.

I am trying to display several images on my front page with links attached to them. I tried using Image Link Formatter and although I seemed to have it all set up OK, no images displayed with or without links. So I have tried to fall back on using HTML in the body of the page but I am coming across some strange behaviour. If I put in one linked image, e.g.:

The image appears and clicking on it opens the link in a new page, as you would expect. However, if I add a second image, e.g.:

then nothing appears at all. Commenting out the second link has no effect, but removing it entirely allows the first image to reappear.

Does anyone know what's going on?


texts: Re-creating Blocks Page for Content Authoring?

texts:
I'm using Drupal 7.14, and the biggest complaint I get from people new to Drupal is visualizing where the content goes once its created.

It got me thinking of some clever/native ways to do this with the base installation. I looked into the Overlay module that the administrators have access to, then Blocks page, then Context page, and none seem to provide an easy to use interface for doing what I want. I remember the Themer module in Drupal 6 highlighted the regions in the Blocks page when you're moving components around, and my question begs whether or not this can easily be re-created somehow?

Now I'm familiar that Drupal 8 + Sparks helps with content authoring a bit, I've seen the demo's where users can edit content on the page/layout, but it still doesn't allow for adding new ccks, nodes to a specific region on a page.

I'm not sure this is an appropriate D.SE question, but has anyone heard of a module, or can think of a way to provide a GUI for users to attach their newly created content to the specific region in a theme, most preferably when they are creating the content?


texts: Why would I want to use Universally Unique IDentifier (UUID) in Drupal?

texts: I see that a lot of people are using Universally Unique IDentifier (UUID). What is it? And, why do I want to use it with Drupal?


texts:
I understand this to be two declarations of the same function, which is not allowed. But how to fix this?

Everything was fine until I started to enable the MailChimp module, then the backend has this fatal error:

Fatal error: Cannot redeclare casa_views_post_execute() (previously declared in /home/kansascasa/public_html/sites/all/themes/casa/template.php:26) in /home/kansascasa/public_html/sites/all/themes/casa_m/template.php on line 80

This is the code:

    function casa_views_post_execute(&$view) {
    watchdog('theme', print_r($view->result[0], true));
  if ($view->name == 'programs2' && !empty($view->result)) {
    //drupal_goto('node/' . $view->result[0]->nid);
  }
}

Second one:

function casa_views_post_execute(&$view) {

}

What is the fix for this? Appreciate your help in advance.


texts: Search button text not showing in a Bootstrap sub-theme

texts:
I'm using a sub-theme of the Bootstrap v8.x-3.1 theme.

By default the search button shows the search icon.

In the theme settings you can un-check 'Iconize Buttons' which I expect would show the 'Search' text instead of the icon, however it shows an empty button... no text or icon.

How do I get the button to show 'Search' text instead of an icon?


texts: How to use Computed_field as a product of an existing one?

texts:
I would like to have a field (field_result) that would display a number that is the result of the product of an existing field (field_1) on the same content type (let's call it book) and a fixed number (let's say 3.5).

My idea was to use the Computed Field module in order to display the result. After reading its Community documentation I managed to do the following:

That's what I achieved so far:

I configured field_result to accept only one value and save it on the database.
I set its value as follows:

$field_1 = field_get_items($entity_type, $entity, 'field_1');
$entity_field[0]['value'] = $field_1[0]['value'] * 3.5;
I set its $display_output as follows: $display_output = $entity_field[0]['value']

Unfortunately when I edit the node and save it I get the following notice:

  Notice: Undefined index: value in eval()

and the field displays 0.00 as a result.

What am I doing wrong?


texts:
I am copying this question from https://stackoverflow.com/questions/25900553/unable-to-add-field-on-drupal-7-view as I can't see a move option sorry.

This has been driving me crazy, so let me explain why.

I am building a Drupal 7 site using kickstart commerce, I have been adding fields to the view for checkout, cart and orders fine.

But all of a sudden it seems to do nothing. Let me explain further.

In the edit view page, I click on Add to add the field I want.

I then find the field I want to add and then click on 'Add and Configure fields'

Then normally I would be able to configure the field, however that has now stopped.
Instead I just get the loading symbol  and then nothing no configure pop-up or the field added.

I dont understand why this suddenly stopped working, I have cleared the cache and disabled non-required modules, no luck. The fields are configured/added in the same way apart from being different the method they were created in was the same, I have deleted the fields and re-created them still no luck.

Has anyone had this with Drupal 7 or can give me some indication which direction to go in next, thanks in advance.

As I stated on the stack overflow question, its not a relationship things as fields configured the same way are able to be added. Existing fields can be removed and added ok.

If I rename to something like test it still fails to add.

I have checked modules that were installed after i noticed the issue, the only one i could see was context disabling this had no effect.

All out of ideas, Google has been no help either :-(

A further update to my question I just updated to the latest commerce kickstart(commerce_kickstart-7.x-2.17) and this did not help at all.
The issue still remains.


texts:
I am using Field Collection Views in Drupal and everything works fine, except Sorting. I am able to rearrange the Field Collection items in Edit form using both drag-and-drop also manually using Row weights option.

I would like the the Field Collection View results to be sorted by this Row weight, could you please guide how I could acheive this.


texts: How to get the site url in views custom output

texts:
I want to print the site url in views field with a custom output, I tried [site:url] token, It doesn't work.
I already have entity token and entity_token enabled in my site.
Is there a way to do that with or without tokens?


texts: Additional fields for my entity from another table in views

texts:
I have table of my entity with structure:

=====================================
eid | myfield1 | myfield2 | myfield3
=====================================

And also an additional table with primary key being foreign key to my entity id:

==========================
eid | myfield4 | myfield5
==========================

I would like to expose values in my second table to view of fields, of my entity, but I don't want to join second table with first, every time, but only if I will use one of its fields.

I believe it should be doable with views_join class modifying a query at handler level, but is it possible on hook_views_data_alter() level?

Is it possible to do this transparently - so I wouldn't need to add any relationship to view (just like the field values are pulled from fields tables - yes, you can think a bit about it as about creating fields alternative ;) ) ?


texts: Feed import of CSV file only in imports the title and nothing else. It also has paragraph fields

texts:
I'm trying to import a small subset of my data to test out how well it would go first before importing 20k records. I'm using the latest feeds module with the paragraphs feeds importer (https://www.drupal.org/sandbox/shaney/2862236). For now I'm only importing:

guid
title
field_client
field_award_status (paragraph field under"award")
field_award_name (paragraph field under "award")

The only successful import is the title, but nothing else shows up. Below is a preview of my csv data and my feed mapping settings. What could I be missing?


texts:
I have a node type that contains a field with several data items (read also).

I need to display 4 items related to the viewed article. The default is to display the field which gives the titles but we also need the images of that articles.

I created a view to get the nid from the contextual filters and panels sends it. Then a relationship with the read also field [require relationship, delta => 1]. It shows the title and image but it also shows the title of the current viewed node as block title which we don't need.


texts:
Trying to use some Twig variables (simple strings) in a template that I created from a custom module. Using the Devel and Kint modules I can see the info under Iterator contents with:

{{kint(transaction[0])}}

I just can't get the template to print it out on the page.

I tried this:

$ {{transaction.amount }} total donation

and

$ {{transaction[0].amount }} total donation

Either way comes up empty. Not sure what I'm missing here. It works in other modules just fine. Maybe I'm too high on the Twig templates? I don't understand the tree structure very well. I created a template called transaction.html.twig.

This is what my controller looks like.

This is the .module file. It's passing over from the controller to this theme which then passes it to the twig file. At least this is how all the tutorials tell me to do it. I create this same thing on another module and it works fine.

function touchdownclub_theme($existing, $type, $theme, $path) {

 return array(
    'touchdownclubtransaction' => array(
      'variables' => array(
        'transaction' => NULL,
      ),
       'template' => 'touchdownclubtransaction',
    ),
  );
}


texts: Choose specific format for hms field token

texts:
I'm using a token to include an hms field in an email sent with Rules. I'd like to include the hms field in the format m:ss, but it's displaying as seconds.

I've tried enabling the custom display setting "Tokens" in the Manage Display tab for the specific Entity containing the field, and choosing the m:ss format there, without luck.


texts: Need advice on how to coordinate Drupal installations on my site - Drupal 7

texts:
I'm using Drupal 7. The main website of my current site does not run on Drupal, but it has a community that does. In other words, Drupal is installed in the path http://example.com/community. I'm now going to be adding Ubercart. The store pages which will use this, however, will be located on the subdomain http://store.example.com. I'm trying to figure out the best way to handle this and am looking for both advice on what is possible and recommended.

I may soon have Drupal run the entire site from the main domain http://www.example.com, meaning that I'd move the current installation to that root rather than leaving it in the subdirectory \community. Not sure if that changes things.

As I see it, my options are:

Two separate installations of Drupal, two separate databases. BUT these databases would need to interact. Hard to say now what data one must be able to get from the other, but one critical thing would be that Users's register an account in Ubercart and that account info would need to be transferred over to the database for the installation running the root domain.
Two separate installations that share a single database.
A single installation that somehow covers both the root domain and the subdomain.


texts: Add language filter at admin/structure/block/block-content

texts:
I'd like to add a language selector in the form that filters.
I've added it though a hook form alter:

$form["#info"]["filter-language"] = [
  "operator" => "type_op",
  "value" => "language",
  "label" => "Block language",
  "description" => ""
];
$language_options = [];
foreach (\Drupal::languageManager()->getLanguages() as $lang_code => $language) {
  $language_options[$lang_code] = $language->getName();
}
$form['language'] = [
  '#type' => 'select',
  '#title' => t('Block language'),
  '#options' => $language_options,
];


texts: How to display comments and comments form on custom node pages

texts:
I am new developing my first ever site in drupal. Along the line, due to the requirements of the project I had to create custom node pages (template files) instead of the default ones in drupal. For example my site has content type 'Article' and the template file for that is page--node--article.tpl.php. In page preprocess, I switch to the right page template with this code

if (isset($variables['node']->type) && !empty($variables['node']->type)) {
  $variables['theme_hook_suggestions'][] = 'page__node__' . $variables['node']->type;
}

Now, my problem is how to display comments and comments form.  The drupal print render($content['comments']); is not working. I have installed Devel and I can see the comments and comments_form variables in the back end under the Render tab but I do not know how to access and display comments on the front end either by using these variables or another means.

Please help.

EDIT
After digging into variables available on the page I was able to get the form to show using

print render($page['content']['system_main']['nodes'][$node->nid]['comments'])

but when I try to submit a comment an alert comes up saying OK and the comments  cannot be found when i check in the back end to approve. Any thoughts pls


texts: Migrating from Drupal 7: source database does not contain a recognizable Drupal version

texts: After looking at this issue, it appears to be my schema_version. How and what do I need to change about the table to get it recognizable as a Drupal version?


texts:
I have a PHP file that does some task in consistent intervals.

I have placed that PHP file inside a custom module folder, but I found that Drupal functions like drupal_set_message() are not available inside the PHP file.

How do I include Drupal functions inside this PHP file?
How do I set up this php file to be run as a cron job?


texts: How to change the view mode programmatically?

texts:
I want to change the view mode of node programmatically. I used hook_preprocess_node(&$vars) and set the view mode:

function moduleName_preprocess_node(&$vars) {
      // if conditions to apply particular view mode
      $vars['view_mode'] = 'teaser';
      $vars['elements']['#view_mode'] = 'teaser';
}

But this is not working as expected. Am I missing something here?


texts: Fatal error: Cannot redeclare THEMENAME_preprocess_page()

texts:
In D7, we have two copies of the same Bootstrap Agency base theme modified to show on different URLs using ThemeKey.

This works, but whenever a new module is installed, the site crashes and we see the following in the Apache error log:

PHP Fatal error:  Cannot redeclare bootstrap_agency_preprocess_page() (previously declared in /sites/all/themes/bootstrap_agency_minimal/template.php:13) in /sites/all/themes/bootstrap_agency/template.php on line 13

This is actually a very similar issue to this , I just couldn't comment on the above and Clive's answer wasn't all that clear to me. Is it better to merge the two functions or rename one of them - as the 2nd answer suggests? And what does merging entail?


texts:
I am new to Acquia.

I have got access to the backend of drupal live instance. I cannot login to stage or dev instance.

Should a new user be created for every instance separately?
What should I do to login to the dev and stage instance?

Currently I am using Acquia Dev Desktop to pull the files locally.

What should I do to get access to the other 2 instances? Please advise.


texts: What can not be done by the Panels module without using the Panelizer module?

texts:
Is there anything that can not be done by the Panels module without the Panelizer module?

I'm just starting to learn Panels module and I faced Panelizer.

Note: I installed and applied this module but the Edit in-place that was selected has gone. Is there any conflict?


texts: Is there a Drupal module that implements a (+/-) button with a counter textbox at the side?

texts:
Can you implement a (+/-) button with a counter textbox at the side with Drupal like a shown below?

A very simple way of implementing this, like using an existing module, is much welcome. I am also open for answers implementating this using hard coded scripts.


texts:
I am wondering how to retrieve the actual data of a field instead of the tid on a node.
Googling around I found a solution to a similar problem, by constructing a query on my own. However, it is usually the case that a function already exists for this. Do you know how I can achieve this?

What I get is something like this

field_category (Array, 1 element)
  -> und (Array, 1 element)
    -> 0 (Array, 1 element)
      -> tid (String, 2 characters ) 18


texts: When you have multilingual content not in the Original language

texts: Bilingual content is fine, but what do you do in Drupal 8 when you have content only in a secondary language. I've got a site in English & Japanese, with pages mostly in English (Original language), but some pages only in Japanese.


texts: Maintenance Page -> Show a specific block

texts: How to make a block available on the maintenance page (e.g. jQuery Countdown) ? Is it about setting right permissions?


texts:
I have a page which list some products in a particular category and I have passed taxonamy term as contextual filter. Here is an example of my url: www.example.com/prod_category.

I want to show breadcrumb in my page like home > prod_category where prod_category is category of product. I have used Custom Breadcrumbs module but couldn't find a solution.


texts: How to add filters to a custom entity type listing page

texts:
I have a custom entity type and a list of entities of that types shown on a standard listing page.

But I need to have some filters similar to what we have on a node list page

How could I do that ?


texts: How to? Partial string stored with CCK text field, end users enter the full string in a views exposed filter

texts:
I could really do with some pointers...

My scenario is as follows. I have a CCK content type called Part. It has a field called chassis, set to accept unlimited values.

Each part will fit all vehicles where the partial chassis entered on the node matches in some way to the full chassis of the customers car. I say in some way because having spoken to the suppliers there isn't say "the stored chassis will match the first 8 of the full chassis", they say it can be random...

So i am really at a loss... How could I go about providing this search functionality?

Or am I looking at this the wrong way? In terms of my approach...

Many thanks to any kind soul who may help me move forward in the right direction...


texts:
I work with the OpenID Selector; everything is OK, but nothing happens when I click on "Facebook."

I work with the Drupal for Facebook module; this works fine, but with the OpenID Selector just it's just select the facebook icon.
Another issue is when a user log in to my website and needs to log out; the user is still logged in with the service he used.


texts:
I am using Drupal 8.

I have a content type of Browse that has a bunch of paragraphs that can be inserted into each field_region. Inside field_region_iv_d I have a reference entity field that just references the Blog content type. So when creating the Browse Content you can click on the field_region_iv_d field and then select add blog and you just start typing the title of the blog and it auto completes.

So now on the actual Browse page if you are viewing the page. Where the region_iv_d is supposed to display I need all of the referenced blogs to display in this spot. I can not for the life of me figure out how to get this to display. I could possibly have this setup wrong. Maybe I need to use a twig field template? Maybe I need to add some special preprocessor code? I have tried a ton of different preprocessor code and was unable to get this results that I am looking for.

Here is general view of my setup.

content type = Blog

content type = Browse
|___ field: Region D  - field_region_iv_d - Entity reference revisions

Paragraph Type = 'Blog Block - blog_block
|_ field: Blog Reference - field_blog_reference - Entity reference
|_ Manage Display: Blog Reference - (Label)Above - (Format)Rendered Entity

Twig Template: paragraph-blog-block.html.twig


texts: Change Default Value of XML sitemap enable/disable flag

texts:
Is there a way to change the default value of a node's XML sitemap enable/disable flag for the XML sitemap module?

The default is disabled.  I have a large old site that I want to have completely site-mapped by the module. The documentation I can find says I need to edit every node to enable -- there has to be an easier way.

Barring that, is there a Drush command available for it?


texts: Manually update core from 7.0 to 7.78 in one fell swoop

texts:
I have recently become an admin for a site that has not been updated since 2011. there are broken links (internal links to the site's blog go to page not found, index error.) I think this is due to a bug, so I want to update the software. However this would be a manual update of Drupal Core and I'm wary of doing anything that might mess up the site's code, not being a coder myself.
Should I go somewhere in the middle of the 7.x updates, or should I go straight to the latest one? What issues may arise from my site from updating to the most recent available?


texts: Paypal Instant Payment Notifications - Add a role but not as a subscription upon purchase

texts:
Here's my use case: I have a Paypal "Buy now" button that I have created using Paypal's Website Payments Standards utility.  This provides an Instant Payment Notification when a user successfully makes a purchase.

What I would like to do is automatically give a user a role upon a successful purchase.  I installed the lm_paypal module, but it is a full-featured subscription solution which I don't need; all I want to do is give users a specific role.  (It's impossible to configure lm_paypal to simply give a user a role; it wants to turn the role into a subscription, but my use case is not a subscription.)

At worst, I can just add the role to user accounts manually when I receive payment, but I'd like to find a way to do it automatically.


texts: Why is the WorkflowType in Drupal 8.5 Content Moderation so large?

texts:
I would like to create a custom WorkflowType in Drupal 8.5.  I looked at the Content Moderation source, and it is a massive set of code.  I don't mind coding, but is all the source for Content Moderation specific to a WorkflowType or is it a lot of boilerplate?

What I really want to know is if that massive amount of code is required for a new WorkflowType, as in created from scratch?

As an example, if I had a doctor's office.  The patient needs surgery, but that surgery requires lots of approvals in the workflow.  Each state may have its own content type or a simply approval of an existing content type instance.

A simpler one is an employee wanting time off.

I don't know another way to ask other than this specific question.

I have looked here,

https://www.drupal.org/docs/8/core/modules/workflows/overview

"In order to create workflows you need to install a module that provides a workflow type."

https://api.drupal.org/api/drupal/core%21modules%21workflows%21src%21Entity%21Workflow.php/class/Workflow/8.5.x

and,

http://cgit.drupalcode.org/drupal/tree/core/modules/workflows/tests/modules/workflow_type_test

I was able to get the test module to work.  It does not seem as large.


texts: How to create node in hook_node_insert without triggering it recursively

texts:
I have a situation where I need to create node(s) in hook_node_insert for certain dates.

Details: There is a content type with date field (start and end-date enabled). The requirement is to create the node with same contents for those many dates.

For example, if the date is from Mar5, 2014 to Mar8, 2014. I need to create node with Startdate & Enddate: Mar5 for one node and Startdate & Enddate: Mar6 for the next node and so on till Mar8 is assigned as start & enddate for the last node.

I got stuck with infinite loop. How do I solve this?


texts: How to postpone access check to theme hooks?

texts:
I am trying to hide only a few fields for non-authenticated users, so I would like to bypass access check and check the permission in theme's template files and hide these fields accordingly. I am using Nodeaccess to control each node's permissions.
How could I bypass the permission check before theme_preprocess_node is called? I think after that I could use nodeaccess_node_access to check the permission manually.
update
I found it easy to bypass the permission check by implement the hook_node_access and return NODE_ACCESS_ALLOW for all, but I cannot use Nodeaccess to check permission later, module_invoke('nodeaccess', 'node_access', $node, $op, $account) returned nothing (NODE_ACCESS_IGNORE).


texts: How does one change the machine name of a Feature?

texts:
I have created a feature with a typo in the machine name. I've tried just search/replacing instances of the misspelling with the proper spelling in all files within the feature's directory, but when I do that it disappears from the list of available features entirely. (Yes, I drush cc all'd.)

How can I change the machine-readable name of this feature?

Using Drupal 6, btw.


texts: Module weight not being respected in order of execution

texts:
Trying to do something fairly simple, using the Panopoly distro.

Basically, I'm trying to implement hook_wysiwyg_editor_settings_alter(). Within the Panopoly distro, the panopoly_wysiwyg module also implements the hook.

So if I have this structure,

/profiles/panopoly/modules/panopoly/panopoly_wysiwyg
/sites/all/modules/contrib/wysiwyg_button_order
/sites/all/modules/custom/my_module

No matter how I set the module weights, the hook fires in the order

sites/all/modules/contrib
sites/all/modules/custom
profiles/panopoly/modules/panopoly

Within the directory, execution is in alphabetical order. I've tested this by moving my_module into sites/all/modules/contrib and profiles/panopoly/modules/panopoly.

Is this a bug in Drupal? Am I missing something? I've tried to use hook_module_implements_alter() but that doesn't fire at all.

If I call modules_list(), it shows the modules in the expected order, but the hook doesn't fire in that order.

Any ideas?


texts: How to add HTML class to main menu list?

texts:
Theme Developer shows me that I need to use theme_links()

I can use this function, but I want to alter markup for main menu only.

I've tried funtion names: mytheme_links__menu_main_menu or mytheme_links__system_main_menu

but it seems that these function aren't invoked.


texts: What is the best way to forward visitors to my homepage to an external site but leave the backlinks accessible?

texts:
Maybe not distinctly a Drupal question, I have an older Drupal 7 site that I want to leave up for backlinks, but any new visitors I want to redirect to a new external website.  So domain.com would redirect to newdomain.com but domain.com/node/6 is still accessible.

Update: Server is nginx and I don't have access to server settings and routes.


texts: How to use Views contextual filters with a hierarchical taxonomy path in the URL

texts:
If I have a multi-level taxonomy, and the URL for each Term contains information about its parents in each URL component, how can I set up a View to show the content for each Term?

Example of the taxonomy:

News » UK » Politics » Government
News » UK » Health

Example of the matching URLs:

mysite.com/news/uk/politics/government
mysite.com/news/uk/health

I've tried the all the obvious combinations of contextual filters I can think of, but I can only get it to pick up the first part of the URL component (/news) but not the actual term being viewed ('government' or 'health' in these examples).

System info: Drupal 7, Views 7.x-3.7, Pathauto 7.x-1.2


texts: Customize Search Result Snippet to use Teaser

texts:
I would like to customize the output of each search result item printed on the search result page. Right now it automatically prints a portion of the content of each item, but I'd like more control. I would like to specify what fields to display in the search result. For example I'd like to output field_image followed by field_mytextfield. Rather than whatever Drupal is doing to output the trimmed content of the result.

I'm using a template to customize the output already

{{ title_prefix }}

        {{ title }}

{{ title_suffix }}
{% if snippet %}

{{ snippet }}

{% endif %}

However I don't seem to have access to what is inside snippet, and I'm not sure how to directly access the fields of the result. I'd like to use the content type's teaser as the result display but I'm not sure how to use that.


texts:
I am little bit familiar with Drupal but have no idea how to approach this problem. I want to create a menu in the following style with straight continuous lines for each tab.

                  ----- sub1
                 |
    tab1---------|----- sub2
                 |
                  ----- sub3

How can I do it?


texts:
In my drupal-based project, we make a difference between laptop users and tablet users: Laptop users can skip some fields when registering, whereas tablet users have to fill in all of them. The trick is easily done by hiding or showing those fields from the signup form with jQuery and Modernizr. And I say trick, because it works, despite some of those hidden fields being marked as required, they are still allowed to signup without filling on them.

The problem comes when users forget their password and request a link to create a new one.
When they get to the screen of "Enter new password and confirm it", users who have initially signed up via laptop (i.e., not filling on some of the required fields), cannot continue because they get the error "Fields X and Y cannot be left blank", or sth similar.

I want to disable these 2 fields from being required for Drupal (not from the signup form, where I have already "hidden" them), but I am not sure how to proceed. Where should I do this?


texts: How to render a Get Locations map programmatically?

texts:
I'm using Get Locations module and the getlocations_fields submodule. I have a content type where I created a "Getlocations Fields" field, this way I can select locations when adding/editing content. I have multiple nodes which contain locations.
Now I would like to display one Get Locations map from given nodes (I have some node ids) programmatically. (I know there's Views integration, but I have a complicated task.)

What is the appropriate way to do this? I haven't found the right method yet, I don't know how Get Locations module's API works.

Hmm, maybe inspecting "A map in your own module" (https://drupal.org/node/2061951) and getlocations_fields_field_formatter_view() in getlocations_fields.module is a good start.

OK, I created a block output as per "A map in your own module". Now I need to collect the content of $latlons array. Do you know how to retrieve these data from entities with Get Locations API?

On admin/config/services/getlocations, you can configure different map markers for taxonomy terms if you "Enable Markers for Terms (Select Vocabularies enabled in a Term reference field)". I set a term reference field for my content type, and this way the NODE appears with the given marker. I would like to keep this behavior, "querying" the Get Locations field's data with markers for a given node, and display that appropriately. But I can't figure out how.


texts: Why creating the front page doesn't work?

texts: I created the file named page--front.tpl.php, which is empty, in the Garland theme and set the front end to it. I still can access the front page: why?


texts: How to fetch felter value from url to show block?

texts:
I have created a block in drupal 7 using better expose filter.. I need to fetch all filtered value from url and need to show block data according to filtered value.
For example: mydomain.com/your-view-path?field_a=valuea&field_b=valueb


texts:
i have a site with menu items and i want to make the item link to any block i want for example :

i have "About me" item in the menu and i want this item to link to a block that user can find it at the bottom of the page if he click on it will directly takes him down to the block.
any suggestion please to do that ?

i add an ID for the block by block_attributes module


texts:
I'm in the process of developing a website for vehicle cargo boxes and adventurous vehicle accessories, and the client has requested a fit guide.

What I need is a jumping off point:  Do I build a taxonomy list of vehicle makes/models/year first and then ask vendors such as Yakima and Thule for their products? Do I ask the vendors first for their products and incorporate the vehicle list later?

I'm ultimately looking to host all vendors products within the site itself, and not have any iFrame solutions or link to vendor cart solutions.

I've searched for days now and have found multiple pre-built databases for vehicle's but am still wondering where to start...


texts: Why is hook_menu_local_tasks_alter called twice?

texts:
For some reason, Drupal is calling hook_menu_local_tasks_alter twice. This results in either a) doubled tabs or b) really annoying code trying to determine if my custom tabs have already been added.

Can someone help me figure out what's going on here? Why would it be called twice? I'm using PathAuto, is this maybe a redirect issue?


texts: How to add a submit button in an HTML table?

texts:
I need to call the gh_cart_prove when the BUTTON is clicked.

function gh_view_categories(){
  $a='
';
  $a.='
';
  $a.=''.'Categoria:'.'	';
  $a.=''.'Soglia minima:'.'	';
  $a.=''.'Tot attuale:'.'	';
  $a.=''.'Crea ordine'.'	';
  $a.='
';
  $query = db_select('uc_product_classes', 'u')
    ->fields('u', array('name','soglia', 'totattuale'));
  $result = $query->execute();
  while ($record = $result->fetchAssoc()) {
    $idUser=gh_get_user_id($record['name']);
    $a.='
';
    $a.=''.$record['name'].'	';
    $a.=''.$record['soglia'].'	';
    $a.=''.$record['totattuale'].'	';
    $a.=''.'<button onClick="gh_cart_prove($idUser)">BUTTON</button>'.'	';
    $a.='
';

  }

  $a.='
';

  return ($a);
}

The button appear but it not works. the function is correctly declared.
How can I resolve this problem?


texts: How to test if a variable is been sanitized?

texts:
I have been doing coder review, and the coder module is showing this complain:

Line 111: Potential problem: drupal_set_message() only accepts filtered text, be sure to
use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized.
drupal_set_message($message);

So my question is if there is a way to test if the variable been sanitized ?. In the past, the coder module have show me false positive, that is why I'm asking how to check if is been sanitized or not.

I have check the entire project and does not have check_plain(), nor  filter_xss().


texts: How do I programmatically populate a field if another one is empty?

texts:
I have a CSV feed running and it currently works perfectly. The client now wants to populate a certain field with a sub-string of another field if the first field is empty, on import. I can't see a way to do that with the normal feeds field mapping or tamper.

How can I achieve this?


texts: Rules parameter description to appear in different lines

texts:
I want the description of a Rule to appear in two lines. In the description field I have tried '' and '\n\r' but without any use.

  $items['my_custom_action'] = array(
    'label' => t('Some Label'),
    'triggers' => array('any'),
    'named parameter' => TRUE,
    'parameter' => array(
      'par1' => array(
        'type' => 'list<text>',
        'label' => t('Select an option'))),
        'options list' => array('1' => t('Option1'), '2' => t('Option2')),
        'description' => t('Line1') . '<br/>' . t('Line2'),
        'restriction' => 'input',
      ),
    ),
    'group' => t('My own group'),
  );

Please let me know how I can make the description appear in two lines.

It has to be simple. May be I am missing something basic :P


texts: Add a remote image programmatically to media module with rules

texts:
I use rules and the media module and would like to add remote images
like http://upload.wikimedia.org/wikipedia/de/6/61/Weingarten_Zentrum1.jpg
programmatically with php.

I found this post but I still have no idea what exactly to do..
How to programmatically add image from external URL using media module?


texts:
Can I add a wysiwyg field in Views so that users can write and post text on my page?

Would I need to enable this as a block?

I have installed ckeditor and views already.


texts: Change some charachter in All field before saving node

texts:
I want done a action (change some charachter) on every field in saving node.
I know for specified field can use hook_node_presave ,but I want do this on all field in all content type (proximity 300 field  and 40 content types) with out specify one by one .
Have drupal api for hook_filed_presave or something like it?

This is work for specified field

function custom_changes_node_presave($node){

    if ($node->type ==='designer_background_images'){

        $filename =$node->original->field_db_image['und']['0']['filename'];
        $uri       =$node->original->field_db_image['und']['0']['uri'];

        $filename    = str_replace (" ", "_", $filename);
        $uri        = str_replace (" ", "_", $uri);

        $node->original->field_db_image['und']['0']['filename']= $filename;
        $node->original->field_db_image['und']['0']['uri']       = $uri;

        //field_attach_presave('node', $node);

            // And the actual field change for the given node (e.g. entity).

        //field_attach_update('node', $node);

        // echo "<pre>";
            // print_r($node);
        // exit;
        // print $node->original->field_db_image['und']['0']['filename'];
        // print $node->original->field_db_image['und']['0']['uri'];
    }
}


texts: How to get node url of selected language?

texts:
I have a node with an array of multiple languages.

 [19] => Drupal\node\Entity\Node Object
        (
            [in_preview] =>
            [values:protected] => Array
                (
                    [vid] => Array
                        (
                            [x-default] => 19
                        )

                    [langcode] => Array
                        (
                            [x-default] => en
                            [ca] => ca
                        )

I'm getting its url as:

$options = array('absolute' => TRUE);
$link = \Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $key], $options);

print($link) is giving me http://test-d8.local/en/node/19 where as I want url of "ca" language not "en" language. i.e. http://test-d8.local/ca/node/19

Is there any way that gives node translations of particular langcode?

This line $language = $entity->get('langcode')->value; is giving me the value of chosen language from select list.


texts: Add a Button within the content type overlay window for the url link

texts:
There is any way to add a button into the content type for example Article as show in the below figure

there is any module for adding the button within the content type in drupal 7.


texts: How to incorporate the body field back into a content type from which it has been previously deleted?

texts: I am on D7. In the past, I have deleted the body field from a certain content type in my project. Now, the problem is that I want the body field back into this same content type, but cannot find it in the list of existing fields in my project to be added to the content type. How can I add the deleted body field back into the content type? Is it possible? It is important to say that I don't want its content back. I just want the regular Body field with the original ID body, instead of creating a "field_body". Thanks.


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

I know I can create custom pages via the UI, but this doesn't work for me because I need to deny access to all published pages to anonymous users.

Notes:

I believe the default 403 and 404 messages come from lines 2624 and 2653 on common.inc. This is what is generating my output at the moment - I assume. I don't think I can use a node for my output instead because anon users don't have permission to view published content.
I wanted to alter/override the default 403/404 messages outputed by common.inc. I can't redirect to a node because anon users don't have permission to view nodes.


texts: Can we configure Devel module to pick up images for the image field of a content type only from a specific directory containing images?

texts:
A Yes or No question.
Using Drupal 7.43. Devel module generates polycolor image content of a content-type which has an image field. But I need only a few specific images on my contents of that content type and I need Devel module to pick up images from a specific directory on my system(in the same drupal environment directory) and then randomly associate them with contents. Can this be done by changing Devel's configurations? Suggestions are welcome for alternative solutions to this problem.


texts: How do I override menu items with my own implementation?

texts:
My specific use case is this: I don't want users accessing the user/%user/edit menu. This is awkward because it's quite embedded in Drupal, e.g. forgotten password system. I want the drupal form for admins, but I want a different form for end-users because I do not want to expose certain user fields to them, and because some updates they may need to do need to be handled by an external database, so changing them in Drupal is unhelpful.

Using hook_form_alter() is not really going to cut it; it really does need to be quite a different form.

I had planned to override the user/%user/edit path by using my own module. This would then check if the accessing user was an admin, and if so, present the stock form, but if not it would drupal_goto('client/updates'); but this doesn't work; my module's page callback never gets called.


texts:
What I’m looking to do:

Content type has an field (addable; unlimited entries to this field)
In that field you select from a list of (mostly external) links.
Each link is a sentence - has a title and pre/post text.

So a piece of content displays a number of formatted links, and these links can be pulled into a view elsewhere.

How could I build that list of links? (content type, field group, taxonomy with link as the name, haven't been able to figure out something that works)


texts: How to theming attachment views? I don't get nothing when I add elements to the tpl

texts:
I'm trying to theming the attachment glossary view

I have create the new tpl files for the elements I want to theming, but I don't get nothing.

I have clear cache several times, and also clean apc.

Any idea how to theming attachements?

Oskar


texts: How to display article metadata in a custom div?

texts:
Metadata (publication date, author's name...) is normally displayed in the "Content" part between the "articles" tags. I have created a new region "titre d'article" in which I would like them to be displayed with the title of the article.

I was able to add the title block when the blocks were formatted. For metadata, I created a "Post metadata" view with a "custom text" field to display them.

But when I create a block with this view and add it to my region, it displays metadata for all published articles when it should display for the read-only article.

I don't know what I'm doing wrong. Yet I had already done it and it worked. I have to do it again because I'm going to lose the data from my old computer.

So basically, I want to hide or delete the default position of the metadata (that I can do easily) and display them in a custom div created using a region.

Please tell me if there's any mistake in what I did.
Or if there's another way to do it more simply, I'd be delighted.

Thanks to help me


texts: Cache_render table grows extremely fast, is there a way to remove the url.query_args cache context from ALL pages?

texts: I'm noticed on a clean Drupal installation, the cache context url.query_args is present on ALL requests, that cause one entry on cache_render table per each request (if we change some query params, think about analitycs queries), and that table grows extremely fast. I don't know if this is necessary for ALL pages. Can I disable this behaviour from a config? Is this neccesary for Drupal to work properly?


texts:
I have a User Profile page that loads specific taxonomy terms (associated with a user account and its form, user_profile_form) to filter specific content with. I've tried to implement these forms independent of any user profile form logic, but its troublesome to work around this logic.

This is further compounded by the fact that all this behavior is essentially split across a ctools_wizard form, since this component ties in a multi-page/multi-form process.

Is there a way I can load in these specific fields, inherited from user_profile_form, into a new form and have those changes save within that form, or is there an entirely separate approach to use here?


texts:
I'm new to writing modules.

I would like my custom module to perform a task whenever the main page is loaded and no user is logged in, like when a user enters the url to my page, then the page loads and does something. I searched for a while now, but can't find the hook for this

What i tried was this:

function mymod_menu() {
  $items = array();

  $items['/'] = array('page callback' => 'mymod_do_it');

  return $items;
}

But this does not work. At the moment despair is joining me with this.

Any help would be very appreciated.

Thank You!


texts: How can I get uploaded files sent to webforms to be attached to an email?

texts:
In Drupal 8, uploaded image files sent to a Webform are uploaded to a private area.
The image files are referenced in the email that is sent to the administrator for that form, but unless they are logged in and access the email through the webforms results interface, they cannot see the file. It appears as a broken image in the HTML email.

I've installed SwiftMailer and Mail System modules per https://www.drupal.org/node/2837024 but installing and enabling the modules has not solved the problem.


texts: Is there a date / time format that only shows minutes if they are non-zero?

texts:
I want a time/date format in a View that renders like this when a time ends in :00
Sep. 16, 2017 - 2pm

BUT, renders like this only if minutes are present:
Sep. 16, 2017 - 2:30pm

Currently, I use this format: M. d, Y - g:ia but I need a way to make those zeros disappear when an event starts at the top of the hour.


texts: hook_field_attach_presave not saving - user profile field

texts:
EDIT: As per a suggestion below, I tried using hook_field_presave, but couldn't access any parameters of the field. I then tried hook_field_attach_presave, but my alterations aren't being saved. My current module code is :

function module_field_attach_presave($entity_type, $entity) {
  $field = $entity->field_user_location;
  $locality = $field['und'][0]['locality'];
  $locality = ucwords(strtolower($locality));
  dpm($locality);
  }

The transformation is present when Locality prints out via dpm, but the transformation is not saved to the field itself. Any idea why?

ORIGINAL: I'm using an AddressField field in my user profiles, but I'd like to make sure that the cities that users enter are correctly capitalized. How can I do this?

I'm assuming it's some implementation of str_replace, but I don't know what to do with it.


texts: Multi country page - avoid repeating content

texts:
I have a site that has several pages, and it will be available in 2 primary languages: Spanish and English.  However, in Spanish I'm creating other languanges:

Spanish - Argentina
Spanish - Colombia
Spanish - Peru
Spanish - Chile
...

The question is:  I don't want to repeat all the content for the Spanish speaking countries, but change 2 or 3 pages instead:  And mainly that's because I want to replace the country name in some pages.

What would be the best way to create country-specific versions of the site without duplicating all the content for each Spanish speaking country?  Thanks!

NOTE:  Would creating a 'language neutral' page a good idea?  And then create the English version and the changed Spanish versions when necessary?  Not yet sure what 'language neutral' is for.


texts:
I created a Drupal 7 site on my localhost. I installed some modules, created some content types and fields, changed some preferences, etc. and also entered some real test data. (I want this data to be preserved when I will copy the site to the production server.)

When the first alpha release will be ready I am going to copy the site to a production server in Internet.

I like the idea to make the software behind my site open source. This way I could be able to receive patches from other developers. (And also the possibility exists that somebody may use my engine for his other site.)

How to manage development of my site?

If it would be a framework, I would be able to do it with SVN or Git for all files + database change scripts. But Drupal also has an admin interface, which I don't know how to put under version control.

Also, how to release an open source package? I need include there some database creation script. Should I just export my DB? (only structure no data?) and put some SQL script into my .tar.gz?

Detailed description of deployment of an open source package for Drupal would be welcome.

Also: Could anyone explain how to use "Features" package in this situation?


texts: Reference start date and end date for date field

texts:
I'm trying show some text when it falls between a certain date, but I am having trouble referencing the start date and end date of the date field.

My code is:

$now = time();
$date1 = strtotime($date1);
$date2 = strtotime($date2);
  if ( $now >= $date1 && $now <= $date2) {
  echo 'This is a new video';

     } else {
  echo 'This is an OLD video';
     }

But it is not working because I do not think I am getting the value of the date in $date1 & $date2. My drupal field (named field_time) is set up as a Date (UNIX timestamp). I used the Devel Module to see where the start and end dates are held and it told me "date1" and "date2".

But my code above isn't referencing the field, so im suspicious. Am I referencing the correct date strings above?


texts: How can I list the current user's posts?

texts: How can I list all posts of the current user? I know I should use Views, but how do I do it?


texts:
Sorry, unrecognized username or password. Have you forgotten your password?

The error above shows even though I have inputted correct credentials in my site(192.168.5.141/doc_monitor). Below are the steps I have tried to solve my problem.

Reset my password in Drupal users table using md5 hash.
Verify mod_rewrite is enabled. mod_rewrite module is loaded as I can view it in phpinfo()
Verify RewriteBase rule in my .htaccess

RewriteBase /doc_monitor
Repair/Truncate sesssions table.
Set (doc_monitor)drupal files to 777 permission.
Run update.php
Clear browser cache and drupal table cache;
Truncate flood table.

I always restarted my Apache in every changes I made. Anymore suggestions? I dont know what to do anymore.


texts:
I work on site that is drupal 7.20, I am sure previous team that worked on this project patch core in some places,I want to find all of patched they did, is there any way to find all patched they did?
one of my idea is find a clean drupal 7.20 core and compare it but I am not sure this is good solution


texts: User picture on multi site / multi database setup

texts:
I have an unusual problem that doesn't appear to have a workable solution....

We have a multi-site setup that has a shared database for taxonomy and the users tables and it's related tables.

Each site then has it's own core database with content, permissions and file_managed.

We would like to keep the file managed table unique to each site, as the amount of images and video's expected will be significant over time.

This leaves us with one small issue in that the "picture" field in the user table is referring to a FID from the file_managed table. If I set my profile picture when on site 1, it works great. If I visit site 2, the same user table will return a FID from that site, which could and usually would be a completely different picture.

Has anyone had any experience in getting around this situation? We don't want to go down separate users for each site, and we don't want to have one file table for all sites.

Ideally I'd like to be able to hard code a url for the "picture" field in the user table, but I'm not sure if this is possible?

Any help is very much appreciated.


texts:
I need to build quite feature rich set of tools for file & media management both for embedded and stored files in a new D7 project. Media will be added to both fields and in the WYSIWYG and File manager is a must.

In the past I have always been working with a combo of CKeditor, IMCE, CKeditor Link, FileField Sources.

However there seems to be a lot of buzz around TinyMCE via the WYSIWYG module and Media modules. In short what am I missing out on with these new projects? They seem to have a big overlap on the above and was wondering if people have experience with both...

Should I be looking to change my toolset to WYSIWYG / Media combo?


texts: I'm using Redis and need one dynamic page to be excluded from being cached. How can I do that?


texts: Profile Completeness reminder to the user

texts:
Hi i need to send an mail reminder to the user whoever not been completed the profile information. Is there any module available  for this? or how do i do this?

Can we do this using rules?


texts: Experiencing an entity error related to a deleted drupal commerce product

texts:
One of my clients has managed to disable, delete (he's not sure) one of his products because it was out of stock.  Issue is the title still appears in the product listing and when you click on the product it produces this error:

  EntityMetadataWrapperException: Unknown data property field_images. in
  EntityStructureWrapper->getPropertyInfo() (line 335 of
  /home3//public_html/client_sites/.com/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.wrapper.inc).

The product display is not listed in the backoffice (kickstart) but its dependent product variations (field images) are still active.

Cannot see anyway of fully removing this product, unless going into the database is required.

You help would be most grateful


texts: How to make edit node display all the nodes menu links

texts:
I have a site with a lot of content and some of it is linked in multiple menus (for example: one in the footer menu and another in a submenu of a page).

By default, Drupal displays the first menu link for the node when editing it, is there a way to have it display all menu links for it, and also allow adding multiple links?

I haven't found any modules that solve this issue, and my googling as so far turned up nothing helpful, so any and all help is greatly appreciated.


texts: EntityMetadataWrapperException when accessing empty entity body. How can I test if body is empty first?

texts:
The following call

$body = $entity->body->value->value();

throw the following error

EntityMetadataWrapperException : Unable to get the data property value as the parent data structure is not set. dans EntityStructureWrapper->getPropertyValue()

when the body is empty.

How can I prevent it?


texts: How to add custom CSS in bottom of the page

texts:
Is there any function/way to add/include module custom CSS in the bottom of the page or after the closing body tag or in the footer? It is an auto-generated css and I can not add this css into library folder.

Right now I have included in _module.html.twig file, Below is the code which I used,

 $build['#cssFile'] = '/' . $cssPath;

<style media="all">
 @import url("{{cssFile}}");
</style>


texts: How do I get all Access check list while accessing a page?

texts:
How do I get all Access check while accessing a page?

Example: If I am accessing http://www.example.com then how many "permission check/access check" is executing.

Like: For viewing all available blocks, Nodes, links etc.


texts: Caching strategy for a page that varies by IP

texts:
I've created a custom cache context that determines if a request comes from in my campus network or from outside my campus network:

class NetworkContext extends RequestStackCacheContextBase implements CacheContextInterface {

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('Network');
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    if (Util::requestFromCampus($this->requestStack->getCurrentRequest()->getClientIp())) {
      return 'oncampus';
    }
    else {
      return 'offcampus';
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return new CacheableMetadata();
  }

}

This custom cache context is registered in my module's services file and given the name "network".

I have a custom controller action that returns some data that varies based on if the user is on campus or off campus:

public function myCustomAction(Request $request) {
  $build = [];

  $build['my_data'] = [
    '#theme' => 'my_custom_theme_function',
    '#rawdata' => $this->fetchData(Util::requestIsFromCampus($request->getClientIp()));
  ];

  // Add some cache metadata that indicates this render array varies
  // based on the user's network. We can't effectively use cache tags
  // here since the data is retrieved from an external service and we
  // don't know when it's updated. Instead, expire the result after
  // one hour.
  $build['#cache'] = [
    'max-age' => 60 * 60,
    'contexts' => [
      'network',
    ],
  ];

  return $build;
}

Here's what I've found:

Internal Page Cache won't work here:
The Internal Page Cache module, to my knowledge, doesn't support cache contexts at all. It will store the entire page result for ALL anonymous traffic. If the request that warmed the cache for this page happened to be on campus, off campus users will also see that result, despite their cache context being different. This means I have to tell Internal Page Cache to not cache this page. One way is to add the "no_cache" option to the routing definition, which is what I've done.

Dynamic Page Cache DOES work, but not when I have the "no_cache" option set. I've found that dynamic page cache DOES support cache contexts entirely, so it will correctly vary the response by my custom cache tag! However, I can't keep Dynamic Page Cache working while also turning off Internal Page Cache, because the mechanism to disable one will disable both.

My questions:

Is there a way I can disable internal page cache for a page but NOT dynamic page cache?
Is using the dynamic page cache appropriate here, or am I using it incorrectly? I looked into auto placeholdering but that seems to be for things that are highly dynamic, but my cache context is not. It's either "yes" or "no".


texts:
I am using drupal7 with menu icon module. I added a image on Home menu. but this is not showing.
Here is my link

I am unable to rectify the problem.


texts: How to remove 'By term' and 'View' tab being displayed at top of pages?

texts: On a Drupal 6 site, I have these annoying 'View' and 'By term' tabs being displayed on all node types. I am wondering how to remove/disable both of them?


texts: How to put Inline Entity Form in another form (without widget)?

texts:
My end goal is to put the Inline Entity Form inside of a custom widget, and have it submittable without submitting the parent form inside of which it has been placed.

I'm not sure how to do this programmatically.  I looked for an example in the tests/ subdirectory of IEF, and found a form like this:

$form['inline_entity_form'] = [
  '#type' => 'inline_entity_form',
  '#entity_type' => 'node',
  '#bundle' => 'ief_test_custom',
  '#form_mode' => $form_mode,
];
$form['submit'] = [
  '#type' => 'submit',
  '#value' => t('Save'),
];

But if I take this code and put it inside an existing form via hook_form_alter or a custom widget, it will submit the entire form, when in reality I just want it to save the values for the reference.  I also tried to experiment by putting a rendered form into an iframe, but it wouldn't load the form code inside it.

$form = \Drupal::formBuilder()->getForm(\Drupal\user\Form\UserLoginForm::class);

$ief = [
  '#type' => 'inline_entity_form',
  '#entity_type' => 'node',
  '#bundle' => 'article',
  '#default_value' => \Drupal\node\Entity\Node::load(1),
  '#form_mode' => 'default',
];

$element['inline_entity_form'] = [
  '#type' => 'inline_template',
  '#template' => '',
  '#context' => [   // Tried the above with & without |escape
    'ief' => $form, //<--tried both $form and $ief here.
  ],
];

Is there any example of doing this that I can look for, or any suggestions or which direction to look?


texts: How do I assign variables from BlockBase object?

texts:
I want to create a Block-Module for drupal 8 (beta 12). To display the Content I want to use a twig-template (mytest-block.html.twig).

But the Twig-Template needs some Data to Display, So I need a Method to assign Some Variables from MytestBlock.php to the Template.

I know how to assign Variables from mytest.module, but I have no idea how to assign Variables from the Block-Plugin MytestBlock.php.

Or is it possible to access the instance of MytestBlock.php and therefore call a method which would return the variables as an array?

My MWE-Module consists of following files:

mytest/
├── mytest.info.yml
├── mytest.module
├── src
│   └── Plugin
│       └── Block
│           └── MytestBlock.php
└── templates
    └── mytest-block.html.twig

File Content mytest.info.yml:

name: mytest
description: A Testmodule
core: 8.x
package: Custom
version: 0.1
dependencies:
    - block
type: module

File Content mytest.module:

<?php

function mytest_theme() {
    return array('mytest_block' =>
        array('variables' => array('test' => 'hello')));
}

function template_preprocess_mytest_block(&$variables) {
    $variables["test2"] = "hello2";

    //a call to get_variables() would also be an option, e.g.:
    //$variables = array_merge($variables, $A_INSTANCE->get_variables());
}

File Content mytest-block.html.twig:

Template
{{ test }}
{{ test2 }}
{{ test3 }}
{{ test4 }}

File Content MytestBlock.php:

<?php

namespace Drupal\mytest\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;

/**
 * Provides a Test-Block
 *
 * @Block(
 *   id = "MytestBlock",
 *   admin_label = @Translation("My Testblock"),
 * )
 */
class MytestBlock extends BlockBasMytestBlock.phpe implements BlockPluginInterface {
  public function build() {
    return array(
        '#theme' => 'mytest_block',
        /*here I want to assign some variables: e.g.:
         * test3 = hello3 */
    );
  }

  public function get_variables() {
    retrun array("test4" => "hello4");
  }
}

In this example, only test and test2 are assigned, but I want, that test3 and test4 are assigned too.


texts: How to add Drupal Coupon discount for selected category or item only?

texts:
Project:    Commerce Coupon
Version:    7.x-1.0-beta7

Hi,

We are using drupal percentage coupon module for our websites and its very good.We have a request from customer where they need to exclude coupon discount for selected item/category.Reason they have a category which is having already discounted items.So now they need a feature where they can exclude coupon applying for those items.

Can we do this with existing module?

Thanks


texts: Drush and MAMP3: cannot connect to database

texts:
I've just updated to MAMP 3.1, and am running Yosemite 10.10.3 (public beta).  Since updating, I cannot perform any commands using Drush.

I have:

sim-linked from /var/mysql and also /var/lib/misql into /Applications/MAMP/tmp/mysql/mysql.sock
Tested the connection to the database using Sequel pro;
Tested the connection using a standard PHP script.

In both 2 and 3 above, I used the direct path to the MAMP socket, and also the one in /var/mysql/mysql.sock

So can anyone think of a reason why this won't work?


texts:
I am trying to prepopulate the following fields on a commerce add-to-cart form and then hide the email field:

Recipient name: (textfield) = field_recipient_name
Recipient email: (email field) = field_recipient_email

So far i have been able to pre-populate these fields using views, panels, and prepopulate modules. My challenge is this:

If the email field is already prepopulated with a value, hide this field from the user who intends to buy a gift for the recipient, otherwise the field should be exposed so that user can manually enter the email of the gift recipient. Thanks


texts: How do I grab multiple commits from a different release branch?

texts:
I am currently a maintain a module on Drupal.org. I had high hopes of working on a 8.x release, however I ran out of time and made extra commits in the 7.x-2.x branch.  Now my git repository looks like something below:

  7.x-2.x     x - x - x - x - x - x - x
                       \
  8.x-1.x               x

How do bring 8.x-1.x up to speed with the 7.x-2.x.  What commands do I need to run.  I thought I would ask the question here as Drupal.org is a little bit unique in how it organizes its repositories.


texts: Add Google Analytics JS file to every page

texts:
We use Google Analytics on each of our sites for our own reporting. We have implemented GA using the Google Analytics module, and everything works as expected.

However, I'm also part of a large organization that wants to start collecting analytics (using GA) on all of its sites. I've been given a .js file that I just need to add to the head of every page.

Should this be added in each site's theme or added to the GA module somehow?

Thanks for taking the time to look...


texts: How to get a taxonomy custom image field URL value

texts:
I've created an image 'field_term_preview' field on the taxonomy vocabulary and trying to get this URL in my custom module:

$terms =\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, 0, null, true);

foreach ($terms as $term) {
    if ($term->getName = 'Term with preview')
    {
        foreach ($term->getFields(true) as $field)
        {
            if ($field->getName() == 'field_term_preview')
            {
                var_dump($field->getValue());
            }
        }
    }
}

This code shows only target_id, alt, height, etc.

How to get the URL to the preview image?


texts: How to enable/disable Billing Information in Commerce depending on the payment method

texts:
Till now, I have been using only PayPal checkout on my Commerce site, and I have configured the checkout flow so all of the customer's information is collected over on PayPal's site.

However, I am now trying to add Stripe as an alternate payment method.  I need to collect the customer's billing info on my site when using Stripe, so I need to add Billing information to the checkout pane.

Goal

Show Billing information if the customer selects Stripe as the payment method.  If the customer selects PayPal, do not show Billing information.

I looked through the various commerce events and actions available in the Rules module, but I couldn't find anything that is helpful for this case.


texts:
How do you set and retrieve a cookie from a custom form in Drupal 7?

I am trying to set and retrieve a cookie containing form_state in a custom form. The form is a multi-step form. My intention is to allow a user (anonymous or registered) to navigate away from the form and return either in the same session or later and pick up where they left off.

I had considered using setcookie, but I cannot figure out how to inject setcookie into the top of the html from the form.

I have done some searching for other methods, but have not came up with anything.


texts: Create an order as administrator user and let users continue with the checkout

texts:
I am using Drupal 7 and the Drupal Commerce module. I need the ability to create an order as administrator user and let users continue with the checkout.
What I have tried:

Get the order ID and send the link to the user (for example,  http://example.com/checkout/1234/payment). It redirects to front page.
Use the Mail order link https://github.com/sjsam/Drupal-MOPL.
Use the module Commerce Checkout URL, which sends the link but doesn't work.

Do you have any idea?


texts: How do I trigger group membership was granted for a user - Group module

texts:
I try to use group module in d8.

1. I created a new group type named test

2. I added 2 group as demo with admin is default group_membership.

3. in group 1 (name okok) I edited and added new user to group.

4. When I click the add member, the site redirect to another add form:

I enter the user as normal.
then click save button.

5. The result is User was added into that group.

So, What I wonder is how to know an user:

Was added to a group.
Was removed from a group.

Because I want to call another service every time that action/event was executed. For example, I want to log in to the watchdog like:

"User A has been added into group X"
"User B has been remove from group Y"

Is there any way to trigger that action/event in code.

Thanks for all your helps.


texts: How can I take control of the rendering of a file entity when inlined in text?

texts:
There are excellent instructions for how to allow embedding Media into text fields here Setting up WYSIWYG and CKEditor to include Media Browser / Embed Media button.

Now I'm trying to control the output of that embedding process, specifically I'm trying to render a text field for a caption next to an image. I started out by adding a new view mode to the file entity with hook_entity_info_alter, configured this View mode to display the correct fields, and thought that would output as expected.

However, this by itself does nothing unless "File display" settings are also added, and I can't seem to figure out how to make them respect field settings. I've done a fair amount of debugging and hacking by now, and can't get this right. I could fill the question with a great deal of more details, but given that I can't make heads or tails out of the problem, it's unlikely to be very useful.

The question How do I control the file appearance using File Entity? is definitely related, and possibly even a duplicate, but as this one concerns specifically inline media, it may be different enough that open this separate question.


texts: Drupal 7. Webform textarea with a html editor

texts:
I am using drupal 7.56
I used the webform module to create a custom form which contains a textarea.

I want to add a html editor to my textarea.

I tested webform_html_textarea but it's not what I need.

How can I configure CKEditor module for this issue?


texts:
I'm using the method below to query the database within a custom module but it doesn't seem to be the 'Drupal' way of doing things. Is there a better way?

$sql = "SELECT field1, field2 FROM {tablename} WHERE field3 = $var1 AND field4 = $var2";
$result = db_query($sql);
$num = $result->rowCount();
if ($num != null) {
  foreach($result as $line) {
    // Do something
  }
}