texts: Editing a node deletes body content reproducibly if Locale module enabled

texts:
I am experiencing a pretty serious problem leading to data-loss in D7. Editing any existing node leads to empty body content and newly created nodes have no body content whatsoever.
Update: The error is reproducibly linked to the Locale module (v 7.78), disabling Locale leads to normal behavior, enabling it leads to data-loss when editing.
However, Locale has been enabled for a long time, so I am suspecting one of the updates since May 2020 (last time new content was added without problems) introduced a bug or a failed database update. So, there might be a bug in Locale that only shows under certain circumstances, e.g. PostgreSQL, a site migrated from D6 or Locale activated after content was already created, ...
The following observations are with Locale enabled:
Tracking an existing node in Postgres shows the node body content in field_data_body before an edit.
After an edit, field_data_body has no entry with the entity_id. I can put back the data using SQL and then the body content is displayed. Newly created nodes never get an entry in field_data_body.
Therefore, I am suspecting something might be odd with HTML filtering (Filtered HTML, Plain text, ...) or the content edit form or language settings.
This is the original data of an existing node:
select * from field_data_body where entity_id = 745959;
 entity_type | bundle | deleted | entity_id | revision_id | language | delta |

    body_value               | body_summary | body_format
-------------+--------+---------+-----------+-------------+----------+-------+----------------------------------------+--------------+-------------
 node        | blog   |       0 |    745959 |      745959 | und      |     0 | The genome browser is not working TEST |              | 1

After editing:
select * from field_data_body where entity_id = 745959;
 entity_type | bundle | deleted | entity_id | revision_id | language | delta | body_value | body_summary | body_format
-------------+--------+---------+-----------+-------------+----------+-------+------------+--------------+-------------
(0 rows)

Also, the node.language and field language are different:
select nid, n.language as "node-language", b.language as "field-language" from node as n left join field_data_body as b on n.nid=b.entity_id  where nid = 745959;
  nid   | node-language | field-language
--------+---------------+----------------
 745959 | en            | und
(1 row)

Looks like it could indeed be a language setting conflict. When looking at the $form data, the values entered into body are found as such and only there.
So it indeed appears to be a language setting problem:

create a new Page node: node.language is initially set to "en", the site default, no body data entry is created or saved upon edit (in form_data_body)
In postgres, change node.language to "und"
The body content is now saved upon edit and displayed properly


texts: Change the width of the off-canvas dialog

texts: Layout Builder uses the off-canvas dialog. It comes out from the right side of the screen at a max width of 300px. We'd like to make it wider. I can do this with a powerful CSS rule, but is there a better Drupal way? Is there a setting I can't find?


texts: how can I enable fields for an entity in the admin ui?


texts: With enabling modsecurity_crs_41_sql_injection_attacks all submit form return forbidden 403

texts:
I installed and activated the module mod_security. then I enabled the modsecurity_crs_41_sql_injection_attacks.conf.

For each form, when I submit, I have an error 403 forbidden

Error log:

[Wed Nov 15 16:53:03.324516 2017] [:error] [pid 27760] [client] ModSecurity: Access denied with code 403 (phase 2). Pattern match "([\\\\~\\\\!\\\\@\\\\#\\\\$\\\\%\\\\^\\\\&\\\\*\\\\(\\\\)\\\\-\\\\+\\\\=\\\\{\\\\}\\\\[\\\\]\\\\|\\\\:\\\\;\\"\\\\'\\\\\\xc2\\xb4\\\\\\xe2\\x80\\x99\\\\\\xe2\\x80\\x98\\\\`\\\\<\\\\>].*?){4,}" at ARGS_NAMES:field_cl_address[0][format]. [file "/usr/share/modsecurity-crs/activated_rules/modsecurity_crs_41_sql_injection_attacks.conf"] [line "159"] [id "981173"] [rev "2"] [msg "Restricted SQL Character Anomaly Detection Alert - Total # of special characters exceeded"] [data "Matched Data: ] found within ARGS_NAMES:field_cl_address[0][format]: field_cl_address[0][format]"] [ver "OWASP_CRS/2.2.9"] [maturity "9"] [accuracy "8"] [tag "OWASP_CRS/WEB_ATTACK/SQL_INJECTION"] [hostname "www.d8.dev.xxxx"] [uri "/node/add/occlient/19784"] [unique_id "Wgxw738AAQEAAGxw91sAAAAO"]

Can anyone explain the cause?


texts: Use Views to display tabs such as, "Add User Relationship," "Send message," etc

texts:
In D7, is there a module that allows to display tabs similar to the following ones, in Views?

Add Relationship
edit
Messages
Send Private message

I want to add these tabs as views blocks so I can place them where I want.


texts: How to interruput ajax request but keep for next possible uses?

texts:
I want to add simple confirmation box for ajax delete action created via:
ctools_ajax_text_button

JS:

(function ($) {

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

            Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {

                if ($(this.element).hasClass(Drupal.settings.mymod.confirm_element_class)) {
                    return confirm(Drupal.t('Please confirm your action'));
                }

                return true;
            }
        }
    };

})(jQuery);

It works, but only first time. When I click delete link and choose Cancel option in modal dialog, next clicking doesn't trigger AJAX action at all on this link, so basically makes ajax action inactive.


texts: Drupal view preview links to origial content, but not full content

texts: My view presents a preview of truncated articles.  When the "title" field is clicked, you are brought to a "full content" page of that preview.  But the "full content only shows the title and body.  I need to also show the full "body image."


texts: Mulitple image upload field widget working on custom content nodes but not on user nodes

texts:
Using Drupal 7.39 and the MultiUpload FileField Widget module.

It works fine for articles, and custom content types I create, but it doesn't work for user fields. Even if I take the existing field from article, and add it as a field to user, it doesn't work.

You can select multiple images, and they show as "2 images selected", you click upload, and nothing happens.

Any idea why this is happening?


texts: Access fields in views-view Twig template

texts:
I'm trying to loop through rows in a views-view template, but I can't seem to kint or dump anything out to help me in doing so.

I've tried following various other answers, such as:

In Drupal 8 view.html.twig file how do I access the view content such as individual field title and/or field content?
How to get each field value in views-views-unformatted--view-machine-name.html.twig?

Again, without any success.

Usually I'd create a views-view-fields template, and access my fields via fields.title.content for example. I need to loop through them via the views-view template, as I'm needing to do some checks, taking into account values of some of the previous row's fields.

How can I access a rows fields when looping through rows in my views-view template?


texts:
I would like to add a confirmation page for downloads.
How can I achieve it?


texts: Node save slow with a field containing lots of paragraphs

texts:
I have a node (which uses revisions) that has a Paragraph field. It has around 80 Paragraphs referenced to it. When I save the node programmatically it's very slow. It seems like the slow down is happening in the preSave() of the Paragraph field. I'm wondering if every referenced Paragraph is being loaded when the node is being saved? And if so is this normal functionality?
Could it just be bad design by myself that I created a node that has a field with 80+ Paragraphs referenced to it? Or is it legitimate to do it this way?


texts: Is there a theme equivalent of hook_install()?

texts:
I want my theme to control certain block settings, like which elements of the system branding block are enabled. To me it makes sense for that to be code in the theme, not a module, because at the moment the only way I've found to access the config programmatically involves using the theme name.

/** @var Drupal\Core\Config\Config $config */
$config = \Drupal::service('config.factory')->getEditable('block.block.my_theme_branding');
$config->set('settings.use_site_logo', false);
$config->save();

Since this is a one off config change, I think it should only happen when the theme is installed/activated. It there a theme function/hook that behaves like hook_install does for modules?


texts: Default values for panelizer and fieldable panel panes

texts:
I have a template being applied to a node with a few different fieldable panel panes on it. I can create a new piece of content and it's page will load with the template applied and all of the FPP's right where they should be.

Say I make 10 pieces of content and they all have that same template. If I go to one of them and add something to an FPP on it and then save as custom that FPP will be modified the same way on all 10 pages. If I use the inline editor and remove the panel with content, save as custom, and then add that panel back it will be empty.

If I have a blank panels template and go to all 10 pages one at a time and add the FPPs to them and save them each as custom then the FPPs will stay unique.

I need to be able to load the complete template with the content panes already there but have them all be empty when the page is initially made.

Is there anyway to assign a panel a default value of nothing?


texts: Using behat to create nodes and testing user owns them

texts:
I would like to create a Behat test that confirms a user can only see content they own or are referenced in.  The struggle is that I can't figure out how to assign the content to created user.

Starting with something like:

Given users:
| name | status |
| test | 1      |
Given "Page" content:
| title | uid |
| A title | ?? |

I need to create several nodes to test, and it seems...odd... that I would need to do the entire steps (e.g. Then I go to register, then I go to node/add/page, ....).

How do I know the uid of the user created in the Given?


texts: What is wrong with this code returning error

texts:
I am using this function to return metatag on front page of my drupal site

<?php
  if ($is_front) {
    echo "<META NAME="KEYWORDS" CONTENT="Geek community,stuffs for geeks,geek contents,tech updates,electronics stuffs,tech geeks">";
    echo "<META NAME="DESCRIPTION" CONTENT="Get articles related to Drupal,wordpress,design tips,Electronics,Web designing,Linux and Programming.Join our Tech community where you can share and get answers for your queries.">";
  }
?>

But it throws the following error:

  Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /public_html/techiestuffs/modules/system/html.tpl.php on line 52

Anyone know what is wrong with this code ?


texts: How do I configure a site as SSO provider with Salesforce as IdP?

texts:
I need allow users to log in on a Drupal site using their Salesforce IDs.

I understand that the Salesforce site will need to be configured as an Identity Provider and will provide a SAML certificate. What I'm not clear on is what to do with the certificate and how to configure the Drupal site to accept the Salesforce user's credentials in the Drupal authentication process.

I found a question on this site, now deleted, where the answer was to use  the Salesforce Suite module. The Salesforce Suite module doesn't seem to come with this functionality, but instead seems to map and pull in Salesforce users and map them onto Drupal entities. I have also seen a number of modules with varying degrees of documentation and even one premium(!) module, but I'm still not sure which way to implement.

How do you configure Drupal for SSO?
What do you do with the SAML certificate provided by the IDP?
How do you manage the user roles?


texts: How to render form elements using form alter

texts: I need to render contact form field elements using form_alter function. When I print $content variable in tpl file, the contact form loads entirely, instead of that I need to render fields separately like drupal_render(drupal_get_form(form['name']))


texts: Persist session variables from drupal site to another domain

texts:
I have a drupal 7 website mydrupal7.com. Authenticated users can complete questionnaires and request reports based on their questionnaires. The questionnaire data is given a unique id which is linked with the user and sent to a custom PHP coded website at reportgenerator.com on the same server. The reportgenerator.com website generates the reports, which are graphically complicated.

The two websites work fine in themselves. It's linking the two that I have the problem with. I would like to use the user authentication of the mydrupal7.com site to say to the reportgenerator.com site "I am an authenticated user, this is a specific questionnaire I have completed, please generate the report." I would prefer the report generation to remain outside of Drupal - ie not a query that relies on data returning to Drupal for rendering, because of the graphically complexity.

I have tried sending session variables (ie this authenticated user, this completed questionnaire) from mydrupal7.com to reportgenerator.com, but they don't persist from the Drupal sessions table to the reportgenerator.com domain. A simple example is:

Code in mydrupal7.com page:
$toot = 67;
$_SESSION['toot'] = $toot;
echo "Toot = " . $_SESSION['toot'];
global $user;
print_r($user);

Output:
Toot = 67
stdClass Object ( [uid] => 1 [name] => admin [pass] => $S$Dl........ [sid] => jgae...... [ssid] => [hostname] => 127.0.0.1 [timestamp] => 1448263956 [cache] => 0 [session] => testuid|i:997;toot|i:67; [roles] => Array ( [2] => authenticated user [3] => administrator ) )

Code in reportgenerator.com page:
define( 'DRUPAL_ROOT' , 'R:/htdocs/udrupal');
require DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
global $user;
print_r($user);

Subsequent output:
stdClass Object ( [uid] => 0 [hostname] => 127.0.0.1 [roles] => Array ( [1] => anonymous user ) [cache] => 0 )

I'm doing something wrong, somewhere ...


texts: How do I delete content (nodes) that a user no longer has the right to create?

texts:
Suppose a user of my site has had the right (the correct role with sufficient permissions) to create content of a certain type.

If the right (role) is taken away from them, how could I make the users content automatically be deleted? (the deletion doesn't have to be instant, eg. once a day is fine) i.e the content will be deleted from the moment they no longer have permissions to edit it or create such content.


texts: @media queries with Akamai causing MySQL queries?

texts:
I hope someone can help me answer this question.

I'm developing a responsive site in Drupal 7 with the Omega framework and hope to use Akamai as a CDN. The whole site will be statically cached and serve 99.9% anonymous users.

However, someone told me that when a cached, anonymous user triggers an @media css query event during a screen re-size, it will cause Drupal to not cache properly in Akamai, and fire off a new MySQL query on every resize.

Is there any truth to this? Has anyone ever experienced anything like this? It doesn't make any sense to me ... I have not been able to test it out, primarily because I don't have Akamai yet. Any help regarding this rumor is appreciated.

Thanks!


texts: Can I refresh parent window through drupal_goto?

texts:
I am working within iframe but hoping to refresh whole page through drupal_goto. Is it possible to do it ?

Thansk


texts: mytheme_preprocess_field is not called on add/edit node

texts:
I have added the following function in my theme's template.php to test whether it actually gets called when adding or editing a node, but for some reason it is not!

function mytheme_preprocess_field(&$variables, $hook) {
    die('FINALLY!');
}

I have done everything I could think off, refresh cache (all of them), restart apache, restart server, no matter what I do, it is not called. As soon as I go to the frontpage, it is called.

Can someone give me some pointers where I might look next? Thanks!


texts: Unable to update head_title string in template_preprocess_html

texts:
I wanted to add some data to the page head title and created a template_preprocess_html function in my module.

I added a couple entries to the head_title_array and imploded the array back into head_title.

At first it looked like it wasnt working at all, but then I checked and in html.tpl.php the $head_title_array was updated.

My temp solution is to implode the array there before printing it but that's a little hackish for me.

Thoughts on where the title is being set or re-set to prevent it from being changed in template_preprocess_html?

Module code is aproximately:

function MODULE_preprocess_html(&$variables) {
  $head_title = $variables['head_title_array'];
  array_unshift($head_title, 'TEST');

  $variables['head_title_array'] = $head_title;
  $variables['head_title'] = implode(' | ', $head_title);
}

and in html.tpl.php:

<title><?php print implode(' | ', $head_title_array); ?></title>

I just noticed that the metadata module is storing variables in an array called metatag_set_preprocess_variable.  That might be the cause, I'll investigate further.


texts:
I created a .php page outside of Drupal. On that page I want to check if a user is logged into my Drupal site.

Is that possible?


texts: How to set absolute URL for images uploaded in CKEditor instead of relative URLs

texts:
I am using CKEditor to send HTML user emails. When I upload an image by using the image icon from the bar, the image src is a relative URL to the image. This is causing issues in the emails. If I use an absolute path to that image then images are rendering properly in emails. Can anyone suggest to me how can I make this change? I tried the below things:

IMCE image browser
This is having an option to use absolute URL's but it's not having an alt text option. If we try to add alt text for this imce browsed image again the src path will change to a relative.

Used https://www.drupal.org/project/ckeditor_config module and tried to add
config.baseHref = 'http://www.example.com/path/' but this also not working.

When i debug the code for editor module, I can see below code snippet is causing this

web/core/modules/editor/src/Form/EditorImageDialog.php
$fid = $form_state->getValue(['fid', 0]);
    if (!empty($fid)) {
      /** @var \Drupal\file\FileInterface $file */
      $file = $this->fileStorage->load($fid);
      $file_url = $file->createFileUrl();
      $form_state->setValue(['attributes', 'src'], $file_url);
      $form_state->setValue(['attributes', 'data-entity-uuid'], $file->uuid());
      $form_state->setValue(['attributes', 'data-entity-type'], 'file');
    }

In above code $file_url = $file->createFileUrl(); this is causing to add relative URL. When i try to change this with $file_url = $file->createFileUrl(FALSE); it works fine.
Can anyone help me in resolving this.


texts: Does Drupal cache db_query results for multiple users?

texts:
I am running into something strange and perhaps someone here can help me. I am trying to prevent two things from happening at once because the second attempt might be influenced by the first attempt.

The (simplified) code:

function save_my_thing($thing) {
  module_invoke_all('my_thing_presave');
    >>> INVOCATION

      if (!lock_acquire('mything_lock')) {
        // If  we cannot obtain a lock, wait.
        lock_wait('mything_lock');
      }

      $sql = "SELECT COUNT(*) FROM {my_things}";
      $count = db_query($sql, array())->fetchField();

      if($count >= 1) {
        drupal_set_message('already there','error');
        drupal_goto(drupal_get_destination());
      }

    >>> END INVOCATION

  drupal_write_record('my_things', $thing, array('tid'));
  dpm(db_query('SELECT * FROM {my_things} WHERE `tid` = ' . $thing->tid)->fetchAssoc());

  module_invoke_all('my_thing_save');
    >>> INVOCATION

      lock_release('mything_lock');

    >>> END INVOCATION

}

Above code works perfect if I request the function, wait for it to complete and then call it again. I end up on the page I came from with a visible error.

However if I call this function from two different windows before either of them is finished (as can occur in real life), the sql count returns 0 in both cases. The lock works, and using microtime() I can see the second call starts right after the first call releases the lock. The dpm() returns the inserted row, so the record is written before the lock is released. But SELECT COUNT(*) FROM {my_things} keeps returning 0.

The only thing I can think of now is some kind of fancy SQL caching layer that presents '0' to the second call for some reason, however I could find no such thing in the Drupal database code.

One more interesting thing is that when I move my lock from the custom invoking module to the main module, right before _presave and right after _save. It does work as expected. But then why doesn't this implementation work?


texts:
I have a view where I am displaying nodes using row style Node. I want to edit the way the Node row style.

I edited the file /modules/node/node.tpl.php and commented the line

print $picture;

just for testing.

I was expecting that the picture field of each node would vanish. But I saw no change in the view display. Why is this?


texts: Can db_select cope with mysql "case when" structures?

texts:
I have a complex mysql query with "case when" to combine values across multiple rows in columns. I'm currenty using db_query, but I would like to use the TableSort and Pager extenders. But (correct me if I'm wrong) those only work with db_select.

This is the query:

SELECT gsid, created_by_uid, difficulty, gametime, max(submitted_on), score, mission, name,
 ifnull(max(case when mission = 1 then score end),0) as mission_1,
 ifnull(max(case when mission = 2 then score end),0) as mission_2,
 ifnull(max(case when mission = 3 then score end),0) as mission_3,
 ifnull(max(case when mission = 4 then score end),0) as mission_4,
 ifnull(max(case when mission = 5 then score end),0) as mission_5,
 ifnull(max(case when mission = 6 then score end),0) as mission_6
FROM `game_sessions` m
INNER JOIN `users` u ON m.created_by_uid = u.uid
GROUP BY created_by_uid

The game_sessions table contains a row for each game mission that a user played. The game mission can be 1-6. This query gives me an overview with the maximum score for each mission per user (each row is a user).

Is it possible to rewrite this query using db_select? I'm using Drupal 7.


texts: Change aspect of node add form (not only via css)

texts: I need to recreate graphically the "node add form" (my client has passed me via PSD the final version of the node add's form design). Is there a way to manipulate the node add form design that is not the usual change using CSS?


texts:
Drupal demi-gods,

I have a scenario as follows in a "Reference data" content type

Code                 Description
NY                    New York
CA                      California
CO                       Colorado and so on

I want to have say an Address content type that references these state codes, simple enough, define a node reference for the content type, but in addition, i want to be able to hover over the drop down box of states, in the address content, and for Drupal to list the state in a hover text.

Can anyone tell me if there is any functionality that provides this, or does it require coding? If it does require coding, which file should I be modifying?

Thanks heaps, I've been struggling with this for a few days now.

Geoff


texts: How long after Drupal 6 is out of support will Pressflow 6 be supported?

texts:
We currently have a lot of D6 sites, and I'm wondering if Pressflow would make a decent "lifeboat" until I can get folks migrated to D7.

Obviously if PF6 goes out of support as soon as D6 does, than it won't be.


texts: flysystem error message. Driver is missing

texts:
In my Drupal 8 project, I want to use the Flysystem module in order to manage files directly on a remote FTP server.
I installed the module and all external libraries via composer.
I also edited settings.php and added the FTP schema based on the README file.
Everything seems to be right, but in the status report, I always see a "Driver is missing" error message.
I don't know what wrong. I searched the Drupal website and module issue page, but I found no solution or guidelines for FTP.
Does any body know how can we use the module with FTP?


texts: Search results are not displaying on top by relevancy

texts:
I have to use "Search API" module with configured on solr server and indexed.
The search results are displaying but "relevancy" content is not on top of the page.

Example #1:
Search key word: course in the page

Actual Result:
1) Test course
2) Test content in shedule page
3) Test page
4) Course in the page

Expected Result:
1) Course in the page
2) Test course
3) Test content in shedule page
4) Test page

Here I need to display first 4) Course in the page then display others.
I am used views for that search.
 Views Interface
Please post your suggestions!


texts: Set default value of a custom field attached to a Media file image field

texts:
I have set up a media image file field on a couple of content types, per the instructions given in the Media 2.x Quick Start Guide.

The image file field has a custom field I added (admin/structure/file-types/manage/image/fields).  This field has a default value.  I would like to be able to change the default value via a hook based on conditions determined at runtime.

While I have found that hook_form_alter is called when the Edit Image modal (AJAX) dialog is displayed (see diagram "Create a New Node and Upload an Image" in the above-referenced documentation page), I would also like to have the chance to alter the default value even if the user does not click on the "Edit" button.  Also, information about the fields attached to the image file field are not populated when hook_form_alter is called for the node create form for the content type that contains the image file field.

I considered hook_node_save, but by the time this hook is called, the file field has already been saved, and I can't tell if the user visited the Edit Image modal dialog or not.  For that matter, even changing #default_value in hook_form_alter will change the displayed value, even if the user has already visited the dialog before and selected a new, non-default value for the field.

Is there an elegant way to determine in hook_form_alter and hook_node_save that the user has already changed the value for the field?  Alternately, is there an earlier hook that can adjust the default value for these fields before either of these hooks are called?

Update:  I thought of a reasonable workaround. If I set the default value for the attached field to "I don't care", then I could calculate the dynamic default value at view time.  I'd rather not have an "I don't care" value, though, and would therefore still be interested in having this question answered.

Update 2: I am now happily running with the "I don't care" workaround deployed on my live site.  I would still be interested in an answer on how to elegantly set the default value for media file fields, though.


texts: Can't render a block due to recoverable fatal error

texts:
I had code to programmatically render a block.

$block = \Drupal\block\Entity\Block::load('bartik_search');
$block_content = \Drupal::entityManager()
  ->getViewBuilder('block')
  ->view($block);
return array('#markup' => drupal_render($block_content));

After updating to Drupal 8.2.x, I get the following error:

  Recoverable fatal error: Argument 1 passed to Drupal\block\BlockViewBuilder::view() must implement interface

How do I fix this error?


texts: Get file field alt text value using entity_metadata_wrapper

texts:
I'm trying to get the alt title of a picture using the entity_metadata_wrapper.

My code is as follows:

$file = file_load($image["fid"]);
$file_wrapper = entity_metadata_wrapper('file', $file);

The $image is one of the images i got by using

field_get_items("node", $node, "field_images")

If i try to get the alt text from the wrapper object, the result is null, although the alt text was set while creating the node.

var_dump($file_wrapper->field_file_image_alt_text);

outputs an EntityValueWrapper with type "text" and data "null".

var_dump($file_wrapper->field_file_image_alt_text->value());

returns null.

I don't understand why this is not working, is there any error in my thinking?


texts: How to remove the default cache tags on a block?

texts:
Here's what I'm noticing:

I set the cache array to what I want it to be in my block
It propagates up to BlockViewBuilder.php and gets put into the $build's content array
There is still a #cache array on the $build itself, which by default has three contexts:
array('languages:language_interface', 'theme', 'user.permissions')

I want to get rid of the languages and user.permissions contexts for my block, because they shouldn't affect its content and I don't want the two contexts to have inconsistent data, but setting my block's contexts won't affect the ones set by the top level $build object.  Is there a way for me to do that?

It looks like CacheableMetadata::createFromRenderArray() will try to merge the two #cache arrays, but from the way it's doing it, it seems it will grab unique values from the two arrays.  Is there a place where I can remove the bad contexts?


texts:
Is there any equivalent of var_export or var_dump available in Drupal, that would output variables directly to the console object (FF, Chrome - console.log() or console.info())?
I just don't feel like turning Devel & Themer stuff on and off every time I want to peek into variables...


texts: how to remove password confirmation field in user registration form?

texts:
I want to remove password confirmation field. Its ok if user enters the password only once. There is no need to confirm it again.

I am using this code

<?php
function dp_form_alter(&$form, &$form_state, $form_id)  {
    switch ($form_id)  {
        case 'user-register-form':
        $form['account']['pass']['#type'] = "password";
            break;
     }
  }

Please tell me where am I wrong. Its not working. :(


texts: Recurring order option on regular products using Drupal Commerce

texts:
I have a Drupal site that requires Drupal Commerce and the Commerce Recurring Framework (if I need to switch to UC, so be it). I have come up with a few options but due to vague documentation regarding CRF, I have more questions than answers. I will be uploading a product list using Commerce Feeds -- a CSV with a list of products and their attributes.

One of the options want to provide to customers is the ability to choose whether to automatically re-order products after 1, 3, or 6 months -- or just purchase the product once. Thus, the final order will be a mixture of line items referencing recurring products and regular line items. We need to split off the line items that reference recurring products and create a new master recurring order based off of that. I have come up with two options, but due to limitations in my knowledge of Drupal, I'm not sure if they are possible or how I can find out. These are the options that I've come up with:

Dynamically adding a "recurring" attribute to a line item/product using the value of a select list [1,3,6] that will cue Commerce Recurring Framework to see a "Recurring Product Type" item. I feel as though this would come through the Rules framework, but I'm not sure when I could interject this information or onto what node.
Dynamically creating a set of "Recurring Product Type" products based off of the products uploaded in the CSV. That is, for each product in the list, creating one regular product and three recurring products for 7, 14, and 21 that would reference the same information. Selecting from the dropdown would then actually reference different products. I feel as though this would be less desirable since there would be different SKU's, making stock control a little more complex.

If you have past experience or any idea of how to handle this situation, your help would be appreciated!


texts: Prevent loading certain script set in .info file in Drupal 6

texts: I have a theme with several template files using <?php print $scripts ?> to load a list of scripts set in the theme's .info file. What's the best way in Drupal 6 to exclude one of the scripts from being loaded in certain template files?


texts: How to hide the left tool bar of content type for non admin people?

texts:
I want to hide the left tool bar of content type also revision message box, as shown in attachement, for non admin people.

I have gone through following https://www.drupal.org/node/1276698 but it's only for particular content.

Please suggest me how to hide from all content.


texts: Which events are invoked when an order is removed or cancelled?

texts:
I have already an event subscriber class with commerce_order.place.post_transition defined. I need to remove nodes when an order is deleted or canceled.

What event could I use in that case?


texts:
I'm trying to setup a private folder for part of the files I need to make available in my Drupal 8 install and I'm having some trouble.

My public files are being served with no problem in sites/default/files. In this path, I also have a private folder (sites/default/files/private), which correctly shows up in Config -> media (not in red).

I have setup the .htaccess file for the public files root as indicated here for Drupal 7, and in the private root the same, but adding Deny from all at the bottom.

Now when I try to create some content with a file field that is set to private, is says that the file could not be uploaded and the message log shows:

  The upload directory private://2016-06 for the file field field_myfieldname could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.

But the 2016-06 directory is showing up, although empty.

Can anyone shed some light on why this is happening and how to fix it?


texts: select nodes title start with charachter

texts:
I want to have query with EntityFieldQuery that return me nodes with title start with A or B but has not obvious method to use or in property condition,
I dont want use db_select or db_query.
in this link not comes like but it work ,but  If I want use REGEX operator it return me error.

  $query=new EntityFieldQuery();
        $query->entityCondition('entity_type', 'node')
        ->entityCondition('bundle', 'product_display')
        ->propertyCondition('status', 1);
$query->propertyCondition('title', '^(B|A)','REGEX');


texts: Two Body/text areas for a multilingual site

texts:
When creating a new node, I want 2 body text areas, each one for one language (one in English, and one in German ).

How can I have 2 body areas when create a node?


texts: How to disable google fonts on administrative theme?

texts:
I want my Google fonts to show up in front end, but when enabled they also change in back end....(7 theme)...

How do I make them ONLY show up on front end Boostrap them but NOT in back end theme?

There should be a setting...but I can't find it! I am using the @font-your-face module.


texts: Rewrite markup of a field in twig template

texts:
I want to calculate dynamical a value and give it back in the markup without saving the newValue. I try this with:

 {% set content.field_my_field[0]['#markup'] = newValue %}

This doesn`t work!
The "newValue" is given from preprocess_node in the .theme file.
Should I rewrite this directly in the preprocess function? How?

Found a solution in preprocess_node. I tried to manipulate $variables['node'] instead of $variables['content']

function mytheme_preprocess_node(&$variables) {
    $variables['content']['field_my_field'][0]['#markup'] = $newValue;
}


texts: How to configure the Publication Date Module for 6x

texts:
I have a Drupal 6 site with a publishing workflow. I'm trying to set it up so that News articles have the Published date on them instead of the default, creation date. There's a Publication Module for Drupal 6. I've installed and activated that module, but am now at a loss for how to get this field into my News content type. I'm a non-programmer, so need to know using the Drupal interface, if that's possible.
Thanks for all your help.


texts:
I'm migrating my website to a new server and I'm facing a problem since then.
Files are identical, so I have no clue.

I want to access the global user variable in a subfolder, which is a custom php site.
Here is how I try to access it:

<?php
// require global settings
require_once 'globals.php';
require_once BACKEND_CORE_PATH . '/spoon/spoon.php';

// The domain to be used for session cookies
$cookie_domain = DOMAIN_COOKIE;
$base_url = DRUPAL_URL;

// require the bootstrap include
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

// Load Drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// get the Drupal user
global $user;

All includes are working fine, but when i dump the $user variable I get the following (while I'm logged in). At least I guess all includes are working since I got no errors.

object(stdClass)#14 (6) {
  ["uid"]=>
  int(0)
  ["hostname"]=>
  string(13) "XX.XXX.XXX.XX"
  ["roles"]=>
  array(1) {
    [1]=>
    string(14) "anonymous user"
  }
  ["cache"]=>
  int(0)
  ["session"]=>
  string(0) ""
  ["timestamp"]=>
  string(10) "1535128081"
}

Note: The XXX in the hostname is edited by me.
Someone has a clue why it isn't working?

If I dump $GLOBALS, i see all drupal info, but only users says i'm not logged in..

PS: This is Drupal 7


texts:
I am trying to attach a Jump Menu to a view, which is a list of users. I would like the Jump Menu to act as a filter for the view.

I've gotten the Jump Menu to do that, but for some reason only when the filters for the fields it uses, are exposed. This is visually confusing (you can filter the same thing with the jump menu and the exposed filters). When the filters aren't exposed, the Jump Menu does nothing.

Does anyone have any ideas as to why this happens?

Thanks!

Jill


texts:
I'm currently doing recruitment system by using drupal 7..
I want to reduce the user redirect activity, so i've installed the colorbox module and colorbox node module..
I have job vacancy list (in views) which i link the job vacancy (content:title) to the node.
The colorbox work perfect which it can display all the job details..

My problem is the colobox also include all the "block" in my website..

My question is how i want to make the colorbox show only the job details?

Thank you in advance..


texts: How to extract images from Statuses(Facebook style publisher) and display in seperate page?

texts: I am using statuses module in my project which is working fine for my requirement. but my new requirement is, i need to extract the user posted pictures(not user profile pictures) in statuses module and need to display in new page along with the author of images posted. If images are more than one it should shown like album or some slide show.


texts: How do you theme a content type's create/edit form?

texts: Like it says -- I've got a D7 content type whose editing form needs to be themed.  I did this all the time in D6 by registering theme functions in template.php and writing the associated theming functions, but things seem to have changed in D7, especially regarding what goes into template.php, or if D7 has shifted to using .tpl.php files for this, or whatever.  Is there any advice out there?


texts:
When I change the site name in admin/config/system/site-information it has no effect on the site name between the title tags. It always shows "Drupal" as the site name.

I'm using the Basic theme with the same implementation as in the core themes:

<title>{{ head_title|safe_join(' | ') }}</title>

I already checked the translations and the site name is also not hard coded in settings.php


texts:
I just started to learn and to develop a Drupal 7 site; therefore, I don't know Drupal very well.
How can I create the menu used in these two sites, http://www.honda.com.my/ and
http://www.toyota.com.my/index.html?


texts:
I need to classify and mark my content types.
As example I have three content types for group messages in OG, ten content types which used as UC products, etc.
So I need to add taxonomy and fields to my content types (NOT for nodes of content types, but to content types!) and then filter them. As example I could show only OG message types, or only product types, or only products which are clothes etc.
So I thing I need a module which turn content type to something like entity.

Is there any module which implements such feature?

It is hard to search such module, because if I search like "add fields to content types" I see results how to add fields to nodes of content types, which will be populated in node forms. But I need to add fields to content type form, to classify and mark content types, not nodes of content types.


texts: How to extend block.block.* schema configuration file

texts:
Someone know how to exend this schema located in block module in core, to add a new data type in mapping from my custom module?

The point is that I need to add a Boolean field for all the blocks in the block configuration page and store this value (0 or 1) in all the block configuration files, but the problem I have is when I import the configuration for those blocks that does not  import the boolean field.

I guess I'm missing declare a "data type" for this boolean field.

    block.block.*:
      type: config_entity
      label: 'Block'
      mapping:
        id:
          type: string
          label: 'ID'
        theme:
          type: string
          label: 'Theme'
        region:
          type: string
          label: 'Region'
        weight:
          type: integer
          label: 'Weight'
        provider:
          type: string
          label: 'Provider'
        plugin:
          type: string
          label: 'Plugin'
        settings:
          type: block.settings.[%parent.plugin]
        visibility:
          type: sequence
          label: 'Visibility Conditions'
          sequence:
            type: condition.plugin.[id]
            label: 'Visibility Condition'

I want to add this

   mapping:
    hide_for_campaign:
      type: boolean
      label: 'Blocks hidden in campaign page'


texts: Drupal 7 CKEditor while replacing from textarea media files are not rendering

texts:
I'm working with Drupal 7 + WYSIWYG module + CKEditor + Field Collection.

My issue is, CKEditor is not rendering the media files which is included through media browser.

Steps to reproduce:

Create field collection field with unlimited occurrence.
Add some text and audio/video/document file using media browser with media teaser setting.
Now click "Add another item" button.

That's it now new field will be added, but the previous field will only have the text you entered, the media will be gone.

When I debugged the field, I found the values in hidden textarea. When CKEditor tries to render the values, media elements are not rendering.


texts: How can I enforce maintenance_mode at all times in a specific environment?

texts: In Drupal 7, we could override the $conf variables in settings.php to force a site (e.g. development) in maintenance mode. In Drupal 8, this has changed to $config, but the maintenance mode variable is not part of the configuration anymore. How can I force system.maintenance_mode in a specific environment's configuration?


texts: Indexing image url in search api drupal 8

texts:
How to index the absolute image url instead of image uri in search api drupal 8.

Image field formatter renders the image url but there is no option to index the url part.


texts: Custom redirect for form-edit displayed in Views header

texts:
I have a content type called 'Checklist' which I bring forward using Views, in it's node-edit form.

I wrote PHP code within the header in order to do this, here it is:

<?php

    $view = views_get_current_view();
    $arg0 = $view->args[0];

    $nodeToLoad = $view->result[0]->nid; //I get the node to load from Fields within my view
    module_load_include('inc', 'node', 'node.pages');

    $node = node_load($nodeToLoad);
    dsm($nodeToLoad);
    $edit_page = drupal_get_form('page_node_form', $node);

    $edit_page['additional_settings']['#access'] = FALSE;
    $edit_page['buttons']['submit']['#submit'][] = 'redirect_submit';
    print drupal_render($edit_page );

    function redirect_submit($form, &$form_state){
        $form_state['redirect'] = 'www.google.com';
    }
?>

Now what I want is to add a custom redirect upon saving this particular form.

I've tried this to no avail:

    $edit_page['buttons']['submit']['#submit'][] = 'redirect_submit';
    print drupal_render($edit_page );

    function redirect_submit($form, &$form_state){
        $form_state['redirect'] = 'www.google.com';
    }

Is it possible to this within the Views header?

Notes:

I have also done this with the Rules module but I'd like to learn
if it's possible to do with PHP code in the Views header so I don't
split functionality in 2 parts of my project.
This can also be easily done using a custom hook but again, if it's
possible to do this within the Views header then that's the trick I'm looking
for.

Thanks.


texts: Multilingual content and single language admin interface

texts:
I want my site's content to be multi-lingual. I have a language switcher that can toggle between both the English and Spanish translations of a page. I want the administrative interface to always be in English, no matter whether you navigate to it from a Spanish or English translation of the page.

Here is my configuration at /admin/config/regional/language/detection:

Here is my configuration at user/1/edit:

My admin interface is always in English, but now my content is also always in English, no matter if I toggle the page to Spanish.

I have tried many settings, including the settings in Content language detection.

What is the correct configuration to achieve this?

/es/node/1

/admin/config/regional/language/detection/url

/admin/config/regional/language


texts: Dynamically creating menu links from a node's fields

texts:
I have to first, create a menu-like block based on the information in a content type. Below every link, there is a text area field from a content type (Conference) except for upcoming conferences and archived conferences. So basically, each link in the menu is a view that shows only one particular field from a node. I pretty much got that part down.

Next I needed the ability for these menus to be dynamically created whenever I created a piece of content. So the 8th annual conference should have a menu created due to the fields in the Conference content type being populated.

Does anyone know an approach to dynamically create these menus links when a node is added? The approach I took so far was trying to add arguments that could be used in the view based on the node ID.


texts:
I am using feed module to import form excel file, one of my field is  a incremental number 1,2,3,4,5 ,..... ' , I get it as 'GUID' in feed importer.
I want sort the result in views, I see the views get GUID as a string and sort it by string.anybody have idea how can I sort them as number ?
I want views sort GUID as integer not string

I test this but it return me sql error,

The sql query of first(top) test :

SELECT node.title AS node_title, node.nid AS nid, feeds_item.guid AS feeds_item_guid, 'node' AS field_data_field_model_node_entity_type, 'node' AS field_data_field_price_node_entity_type
FROM
{node} node
LEFT JOIN {feeds_item} feeds_item ON node.nid = feeds_item.entity_id AND feeds_item.entity_type = 'node'
WHERE (( (node.status = '1') AND (node.type IN  ('products')) ))
ORDER BY CAST(feeds_item_guid AS INTEGER) ASC
LIMIT 100 OFFSET 0

function mymodule_views_query_alter(&$view, &$query) {
if ($view->name == 'my_views') {
$query->orderby[0]['field']='CAST('.$query->orderby[0]["field"].' AS INTEGER)';
}

or I try

$query->fields['feeds_item_guid']['field']='CAST('.$query->fields['feeds_item_guid']['field'].' AS INTEGER)';

error of second try: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'feeds_item.CASTguidASINTEGER' in 'field list'


texts: entity_metadata_Wrapper and entity_create create a node for every field of the content type

texts:
There is a table with two columns title,body_value. I need to create a node for each row of this table. Table name is french. This is my code

$query = db_select('french', 'n')
      ->fields('n', array('title','body_value'))
      ->range(11,5)
      ->execute();

foreach($query as $item) {
    print "Row"."
";
    $title = $item->title;
    $body = $item->body_value;
    $values = array(
        'type' => 'article',
        'uid' => 1,
        'status' => 1,
        'comment' => 0,
        'promote' => 0,
        'language'  => 'fr'
    );
    $entity = entity_create ('node', $values);
    $ewrapper = entity_metadata_wrapper('node', $entity);
    $ewrapper->title->set($title);
    $ewrapper->field_body->set(array('value' => $body,'format'=>'full_html'));
    $ewrapper->save();
}

The problem is, after running this code 10 contents are created the five contents are repeated twice.

But when I run this code

foreach($query as $item) {
    print "Row"."
";
    $title = $item->title;
    $body = $item->body_value;
    $values = array(
        'type' => 'article',
        'uid' => 1,
        'status' => 1,
        'comment' => 0,
        'promote' => 0,
        'language'  => 'fr'
    );
    $entity = entity_create ('node', $values);
    $ewrapper = entity_metadata_wrapper('node', $entity);
    $ewrapper->title->set($title);
    //$ewrapper->field_body->set(array('value' => $body,'format'=>'full_html'));
    $ewrapper->save();
}

no duplicate content is created. Why this code creates a node for each column of the french table?

Thanks.


texts:
Inline Entity Form ships with two widgets as Inline entity form - Single value and Inline entity form - Multiple values when I use Inline entity form - Single value, I only get add entity form and when I use Inline entity form - Multiple values I get option to add/edit both.

what I was expecting to see to have both add/edit with Inline entity form - single values with only difference of not allowing to have multivalued field in this case.

Am I missing something?


texts: Panels 3: Custom form elements on node/%node/edit page

texts:
Is it possible to add custom form elements to node form, when the node form is rendered in panel?

I am using panel page node/%node/edit. When I add content to a region, I select Form and there I select node fields. How can I add some custom form element to region, so it will be part of node form?

I can edit node form with hook_form_alter but I do not know how to edit it when the form is generated in panel.

EDIT: the problem is I have panel layout with multiple regions and each field is  maually placed to some region. .
How can I place custom form elements (created with hooks) to panel region?

EDIT 2: For now, I  can attach to region only standard fields, created on "Manage fields" tab in content type. I cannot add custom form elements from hook to a panel region

thanks for advice


texts: Creating view using a field(checkbox) as Contextual Filter

texts:
I have a content type product.I want to create a page view of the products. The view should show only those products whose field featured (checkbox) is checked.

How do I use Contextual Filters for this ?

If the field was a taxonomy-term ,I would go to Provide default value -> Taxonomy Term ID from URL.

But, since the field is a checkbox I am not able to achieve this.

Thank you .


texts: I have 2 views. One view is displayed in the header of other view. Both views has its own block template. I need to get the sum of both views result count to display a no result message if sum is equal to zero. Is there any way to do it.


texts: How to integrate a custom one page php app into drupal 7?

texts:
I am trying to integrate a custom website into the drupal 7 system. On this website there is a lot of user interaction with buttons, database queries, ajax loaded elements, … . I need to get the the global user variable on this page.

My first question: What is the best way to integrate the webpage?

My first attempt was to create a content type (node—myPage.tpl.php):
I got permission problems using ajax, so I separated the code into two files (node—myPage.tpl.php and myPage.php). In the node—myPage.tpl.php I only included myPage.php. But now I have the next problem using ajax (for myPage.php). I cannot get my global user variable.

My second attempt was to create a custom module. So I created a callback page. But I think I have to make a renderable array. I want to avoid this because myPage.php has over 3000 lines of code. And I don’t think jquery ajax will work as it should.

Is there an easy way to integrate a custom website into the drupal 7 system with access to the drupal api (user variable, functions)? I also prefer to keep the custom page in a php file, not into database.


texts: Not seeing the "like it" button while it appears on localhost

texts:
In which used Wishlist module to create the "like it" button. On my localhost it is working fine, but not so on the production/testing server, where the button doesn't appear. The permissions on the server match the ones on localhost.

Why don't I see it on the server?


texts: How can I modify the $submitted variable for a custom node template?

texts:
I have a content type called "Blog post" (machine name = blog_post).

I've set up a custom node template that works properly called "node--blog_post.tpl.php"

I'd like my $submitted output to be "by User Name | Month, Day of Month, Year" (example - "by John Smith | November 2, 2016"

I've been working on this for 2-3 hours without being able to have any effect on the output, and have gotten to the point in my searching where the only links I'm finding that seem relevant are things I've already clicked on. I'm stuck.

I know there are multiple ways to do this, but I'm looking for how to make this happen using a theme_preprocess_node function in the template.php file. Not only because I've seen multiple posts saying this is the "best practice", but also to gain more familiarity with the template.php file itself & how it is used.

Any thoughts?


texts:
I have a virtual machine running with a standard install of Drupal 8 on windows. See Drupal VM

I want to install Drupal Commerce 2 on the VM.

Do i use composer like the Commerce instructions say (composer create-project drupalcommerce/project-base mystore --stability dev).

If so where? In de folder on windows that I installed the VM in, or in the part after i use vagrant ssh (vagrant@drupalvm:~$).

Or do i need to customize one of the .yml files and then do a vagrant provision?

Please help. (sorry if I am to noob)


texts: What will be my function name in template.php for particular .tpl.php

texts:
I have template.php and node--product.tpl.php files. What should be my function name in template.php to pass variable from template.php to .tpl.php

Here is template.php code

function mytheme_process_product(&$variables){  **//What should be my function name here**
$variables['temp_var']="This is demo Temporary Variable for Perticular Product .Tpl.php";
}

node--product.tpl.php

<?php print $temp_var; ?>

And my .tpl.php file name is node--product.tpl.php where product is my content type name.

Please reply.


texts: After enabling Commerce Cart Ajax module +/- feature of Commerce Extra module doesn't work

texts:
First of all, I installed Commerce Extra module and enabled "QUANTITY" feature, and everything worked like charm. Then I installed Commerce Cart Ajax module and did needed things to make this ajax module works on /cart page. It seems like everything works, but when I tried to press on "+" or "-" buttons - the value of text field with quantity didn't change. Also I noticed that when I clicked on these buttons the error("Uncaught TypeError: undefined is not a function") appeared in Chrome's console.

I use Drupal Commerce 7.x-1.9, Commerce Cart Ajax 7.x-1.0, Commerce Extra 7.x-1.0-alpha1

Many thanks in advance!


texts: Multiple choice question creation change checkbox to radio

texts: Using quiz module, I am creating Multiple Choice question. In that there is a check box to select the correct answer. Check box enables users to select multiple answers for a single question, but I want the users to select only one answer for a question. Is there any configuration to change that or can I change the check box to radio button. If so how can I change it to radio button? Should I change it in code base or is there any module available?


texts: Display all Nodes associated to a Taxonomy term?

texts:
I currently have a list of Taxonomy terms: Fruit, Meat, Vegetables..etc. And I would like to add a drop down to a content type that will display all nodes and only the nodes that are associated to a Taxonomy Term. I am currently using the Node Reference- Select List, but the list is growing and will eventually become unmanageable.

To Summarize:
In example, I select a Taxonomy term and then a "select list" displays only nodes that have been previously associated to that same Taxonomy term. I select Fruit and it displays oranges, apples, and lemon nodes only. Not... lemons, oranges, carrots, ribeyes...etc, in which, is my ever growing Node reference list now.

Thank you for any help you may lend.


texts: Bootstrap subtheme - theme_menu_link(array $variables) not reacting

texts:
I'm using the Bootstrap theme and I've successfuly created a bootstrap subtheme that I named bootstrapdreve

I've already overidded successfully two templates, but now I'm facing a problem I'm stuck for hours on.

I wanted to overide the bootstrap_menu_link theming function located in bootstrap/theme/menu/.
So I copied it into my

bootstrapdreve/template.php

and renamed it

function bootstrapdreve_menu_link(array $variables)

Before bringing my adaptations I set a dsm('test'); on first line:

function bootstrapdreve_menu_link(array $variables) {
  dsm('test');
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    // Prevent dropdown functions from being added to management menu so it
    // does not affect the navbar module.
    if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) {
      $sub_menu = drupal_render($element['#below']);
    }
    elseif ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] == 1)) {
      // Add our own wrapper.
      unset($element['#below']['#theme_wrappers']);
      $sub_menu = '
' . drupal_render($element['#below']) . '
';
      // Generate as standard dropdown.
      $element['#title'] .= ' ';
      $element['#attributes']['class'][] = 'dropdown';
      $element['#localized_options']['html'] = TRUE;

      // Set dropdown trigger element to # to prevent inadvertant page loading
      // when a submenu link is clicked.
      $element['#localized_options']['attributes']['data-target'] = '#';
      $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
      $element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
    }
  }
  // On primary navigation menu, class 'active' is not set on active menu item.
  // @see https://drupal.org/node/1896674
  if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
    $element['#attributes']['class'][] = 'active';
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '
' . $output . $sub_menu . "
\n";
}

... and nothing's displayed

I've followed the idea given by this subtheme preprocess functions inheritance post by creating this structure:

bootstrapdreve/theme/menu/menu-link.func.php

and by setting also a dsm('test'); at first line of code...

Still no message... and thus as I interpret it no execution of this function...

I don't understand why. Could you please help me find why this theming function overiding doesn't work ?

Rem.: There's no problem with the dsm(), I've tried to put one at top of bootstrapdreve/template.php and it works fine...

Rem. 2: I've offcourse cleared the cache at every modification I made


texts: Ajax button in list to delete row entry - submit function is called instead of callback

texts:
I have a themed table on a form. To delete entries in this table I render buttons for each row having a special idx and an ajax callback for each button.

The buttons are rendered perfectly, but when I click on the button, the standard submit routine is called instead of the assigned callback routine. Is there anything I missed?

// build header for table
$pheader = array('Name','Action');
// build data array for table
$aPersonsTable = array();
foreach ($aPersons as $key => $value) {
  $form_button['button'.$key] = array(
    '#id' => 'del-p-'.$key,
    '#name' => 'del-p-'.$key,
    '#idx' => $key,
    '#type' => 'submit',
    '#value' => 'Delete',
    '#submit' => 'delete_auction_person_ajax_callback_submit',
    '#attributes' => array('class'=>array('ajax-processed')),
    '#ajax' => array(
      'callback' => 'delete_auction_person_ajax_callback',
      'progress' => array('type' => 'none'),
      'effect' => 'fade',
    )
  );
  $deleteButton = drupal_render($form_button['button'.$key]);
  $row = array($value['dname'],$deleteButton);
  $aPersonsTable[]=$row;
}

$form['persons']['ptable'] = array(
  '#theme' => 'table',
  '#header' => $pheader,
  '#rows' => isset($aPersonsTable)?$aPersonsTable:null,
  '#disabled' => TRUE,
  '#title' => 'Users currently assigned',
  '#empty' => t('No users assigned yet!'),
  '#prefix' => '
',
  '#suffix' => '
',
);


texts: How to create multiple user account types in drupal 7

texts:
I want to customize the default registration process in drupal 7 like Paypal.

Users can choose their account types to register and  each account type has some corresponding fields to fill information.

For example in Paypal have 3 account types : Personal, Premier, Business

In drupal I only see 2 account types(anonymous and authentication), how can I add more ?


texts: Admin overlay forms not working after core update

texts:
I just updated my site from 7.0 to 7.18, the forms in admin overlays no longer work, this concerns any pages related to admin: www.mysite/admin/*

The forms always reset back to their previous values. Plus on the modules page when clicking 'save configuration', I am redirected from www.mysite/admin/modules to  www.mysite/admin/modules/list/confirm.

www.mysite/node/ overlay forms work fine.

Does anyone have any ideas?


texts: Why is Twig not outputting this correctly?

texts:
I have

function hook_theme_preprocess(array &$variables, $hook) {
    $variables['bla'] = ' AA <strong> BB </strong> CC ';
}

In my template I have:

{{ bla }}

The problem is, in some cases the  html is stripped. Even if I do this:

{{ bla | raw }}

This works fine on all pages where this template is used, except on the home page. On the home page, for some bizarre reason, it strips the HTML.

Any idea as to why there would be different behaviour depending on which page I am on?


texts:
Somehow I've got 2 users in my users table with the same email address (mine!).  I need to delete one of them.  One is user ID #1, the other is user ID #144.

When I use the advuser module to search for my email address, only one user (#144) shows up.  I select it and try to delete, but it's not successful - the confirmation screen says "No selections have been applied."  I'm guessing it's trying carefully to not delete user #1.

Additionally, I can't seem to change any account details in my own (user #1) account, it complains that "The e-mail address me@foo.com is already taken."

Not sure what to do next - am I safe to just do DELETE FROM users WHERE uid=144;?  Or will that create dangling references elsewhere?

I'm using D7, but I had this extra user before I upgraded from D6 too.


texts: What's the accepted way to add different prices to commerce products?

texts:
The standard model for an e-commerce system is to have an RRP price and sale price (and when relevant a cost price).

I know there are product pricing rules to apply discounts, but this is a pretty un-intuitive solution as it requires the adding of a new rule for every single product that needs a discount.

Plus 'discount' isn't the right way to look at this particular situation conceptually in my opinion. I don't want the users to have to work out what the discount should be when all they want is to set a static 'special offer' price. It also doesn't make sense to refer to the cost price as a discount of any kind.

What I'd like to have is 2/3 (or as many as I want to be honest) different price fields on the product to represent the different prices. The system would then obviously display the correct price at the correct time based on some sort of rule.

I know I can just add new fields to the product bundle but their relationship to the overall price of the product will obviously not exist until "something" happens.

This seems like a pretty standard use case...has anyone come up with a good solution? Code and UI solutions both welcome.


texts: How do I sort by taxonomy term parent, and then by post date?

texts:
I have the following taxonomy structure:

Locations

Group 1

Location 1
Location 2

Group 2

Location 3
Location 4

Group 3

Location 5
Location 6

Pieces of content are being posted to the site, and each piece of content has a location and a post date associated with it.  When the view is displayed, how can the results be grouped by parent term ID (group 1-3), and then grouped by post date within each group?

I've tried using the "taxonomy term: name" sort criterion, but then adding the "content: post-date" criterion seems to have no effect.


texts:
Drupal 8 introduced hook_post_update_NAME() which has some benefits over hook_update_n, for updating modules.

Each hook_post_update_NAME() should only run once, but sometimes I want to rerun it, like when I'm debugging the update hook during development. With hook_update_n, you can reset the schema version in the database.

How do you rerun hook_post_update_NAME()?


texts: How to include CSS3 Pie in my Drupal site?

texts:
I would like to use rounded corners on my Drupal site. I came across CSS3 Pie and would like to try it out. But where exactly do I include the code that I download? In the modules folder?

http://css3pie.com/download


texts: i understand how to get the webform-form-[nid].tpl.php naming convention to theme one individual web form - it works great. what i really need, however, is to theme a group of web forms based on something like a taxonomy term. how can i get ALL web forms tagged with, say, "3-column" to use just that one form template file? otherwise i'll have a separate template file for every individual web form that i need. is that possible? i'm using the 6.x version of webform.


texts: Problem sorting events by Term Reference

texts:
Hi I created an Event Calendar in Drupal 7.3 I have a content type set up with term ref everything works great when i click on an event I have at the bottom display the term Ref
you can see it here  http://www.ofmq.com/content/pain-falls-major-injury-mcalester

at the bottom of the Event there is a link to the term ref in this case it is Nursing Home
when you click it you get a list of all events that have Nursing Home as a term
my problem is how can I sort the list generated by event start date?
Any help would be appreciated
Cheers
DEW


texts: Class not found for a new module/service I am building. I am not sure how to debug

texts:
I am building a new service, an event subscriber in a custom module. My class which extends EventSubscriberInterface is not being found.

  [error]  Class
  Drupal\fivewire_commerce\EventSubscriber\fivewire_commerce_orderStateSubscriber
  does not exist

I am not sure why and am struggling to debug what I have done wrong.

My module is 'fivewire_commerce'.

/modules/custom/fivewire_commerce

I have created a file to delare my service.

/modules/custom/fivewire_commerce/fivewire_commerce.services.yml

services:
  fivewire_commerce.order_subscriber:
    class: Drupal\fivewire_commerce\EventSubscriber\fivewire_commerce_orderStateSubscriber
    tags:
      - { name: 'event_subscriber' }

And this is my class

/modules/custom/fivewire_commerce/EventSubscriber/fivewire_commerce_orderStateSubscriber.php

<?php

/**
 * @file
 * Contains \Drupal\fivewire_commerce\EventSubscriber\fivewire_commerce_orderStateSubscriber
 */

namespace Drupal\fivewire_commerce\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\state_machine\Event\WorkflowTransitionEvent;

/**
 * Event Subscriber MyEventSubscriber.
 */
class fivewire_commerce_orderStateSubscriber implements EventSubscriberInterface {

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents() {
        // Trigger after an order is made
        $events['commerce_order.place.post_transition'][] = ['onCompletedOrders'];
        return $events;
    }

    /**
     * Code that should be triggered when an order is placed.
     * This is the order state 'validation' according to our chosen workflow.
     */
    public function onCompletedOrders(WorkflowTransitionEvent $event) {
        $test =true;
//        if ($event->getToState()->getId() == 'validation') {
//
//        }
    }

}

And if I try to rebuild my cache I get:

  [error]  Class
  Drupal\fivewire_commerce\EventSubscriber\fivewire_commerce_orderStateSubscriber
  does not exist


texts: Putting items in multiple places in a menu

texts: I'm trying to set up a menu layout which has two links to /biblio; one under "Researchers", and one under "Staff". This is for convenience, as if you are looking under "Staff", the "Researchers" submenu is closed, and the "Staff" submenu isn't available to unregistered users. The problem I'm running into is that although I can have two links in different parts of the menu, when looking at the page it will always try to open the menu to only one of them. This means that if you are looking under "Staff", and you go to publications, suddenly you're in what seems to be a different location of the site. Any suggestions for how I can fix this?


texts: Config changes only propagated via manual form submit

texts:
My question is related to the Search API Drupal 8 module. I am modifying my configuration via config file updates. After I am installing my custom module, I can see my config reflected in the search index field settings via the configuration form. However, after I re-index I cannot find content via my newly defined fields. This works only, if I open the search index fields configuration form and submit it manually via webbrowser. No config changes - just hitting the save button.

Tried clearing the cache, entity updates, rebuild tracking information, rebuild the search index - nothing helps.

Can I implement anything into hook_install() from my custom module to propagate the necessary config changes properly to my database?


texts: Show repeating event just once in Views while sorting by date

texts:
When using repeat date API on a field, Drupal allows you to group events so they don't appear multiple times.

However, when sorting by date it seems like Drupal ALWAYS shows all of the entries no matter what.

How can this be avoided?


texts: How can I show an image in a view using the Search API Views integration?

texts:
I am using the Search API Views module; I have created an index of users, and on this site, there is an image field on the user profile with a single value (not a user picture, just a standard image field).

I am now making a view and trying to show the image from each user in a field of the view.  I added the Index User: Picture field, but when I do so, I have three choices for the display:

Show entity label (gives me the filename (image.jpg) with a link to the image)
Show entity ID (gives me the number of the entity)
Show complete entity (doesn't display anything)

I read this issue on images in Search API, which is marked as a duplicate of a fixed issue, but I don't understand how it is fixed or what I am supposed to display the image.

I want to show the image as a thumbnail in the view.  What's the easiest way to do this? (Given the filename, I imagine I could write a custom views template to print the thumbnail image as suggested in this question on Apache Solr Views, but it seems like there is probably an easier way (the linked Search API issue was fixed four years ago).


texts: create relation between two nodes using the relation module

texts:
I am using the relation module and i don't like the way the default relation blocks work(entity collector and relation add blocks).

SO I'm trying to write my own block for creating relation. I have a form which has two text boxes, where the user selects two different end points between which the relation has to be made. he then clicks on submit and the relation has to be created.

coming to the relation module, i see that it doesn't have an API for use. Also i looked at the existing relation creating blocks(entity collector and relation add), they load entities and not nodes. Can some one explain me how i load all the entities available. Also is there a way where I can get the entity from the node id ?

Thanks.


texts: How to prevent programmatically created blocks from caching

texts:
I've been working with Drupal 7 for a couple of years but am new to Drupal 8, and am just getting into building custom modules.

What I have built is a module that alters Drupal Commerce in order to make it work smoother for sponsoring children (so that it doesn't feel like you are buying children).

It does a couple of things:
1. If you add a second product to the cart, it deletes your old cart.
2. After clicking add to cart, it redirects you to an information page.
3. That page contains a module-generated block with a "continue" button that takes the customer to checkout.

The issue I am hitting is that the code which generates the checkout button block is getting cached, and is pulling an old, no longer existing order ID number.

Is there a way to prevent the block from getting cached, or a better way to programmatically set up a custom block?

Here is my code:

\src\Plugin\Block\ContinueCheckoutBlock.php

<?php
/**
 * @file
 * Contains \Drupal\commerce_custom\Plugin\Block\ContinueCheckoutBlock.
 */
namespace Drupal\commerce_custom\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Symfony\Component\HttpFoundation;

/**
 * Provides a 'Continue Checkout' block.
 *
 * @Block(
 *   id = "continue_checkout",
 *   admin_label = @Translation("Continue Checkout"),
 *   category = @Translation("Continue Checkout Custom Block")
 * )
 */
class ContinueCheckoutBlock extends BlockBase {
  /**
   * {@inheritdoc}
   */

   public function build() {

      $user = \Drupal::currentUser()->id();
        $connection = \Drupal::database();
    $user_ip = \Drupal::request()->getClientIp();
        $query = $connection->query("select * from commerce_order_item join commerce_order on commerce_order_item.order_id = commerce_order.order_id where uid = :user and state = 'draft' and commerce_order.ip_address = :user_ip order by commerce_order.changed asc limit 1", [':user' => $user, ':user_ip' => $user_ip]);
        $result = $query->fetchAll();
        $order_id = $result[0]->order_id;
    drupal_set_message($order_id);

        return array(
            '#type' =>'markup',
            '#markup' => 'Continue',
            '#cache' => array('max_age'=> 0),
        );
   }
}

commerce_custom.module

<?php

use Drupal\Core\Form\FormStateInterface;
use Drupal\commerce_order\Entity\Order;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation;

/**
 * Implements hook_form_FORM_ID_alter().
 */
function commerce_custom_form_commerce_order_item_add_to_cart_form_alter(&$form, FormStateInterface $form_state, $form_id) {
   $form['actions']['submit']['#value']='Sponsor';
   $form['#validate'][] = 'commerce_custom_form_validate';
   $form['actions']['submit']['#submit'][] = 'commerce_custom_cart_alter_redirect';
}

function commerce_custom_form_validate(array &$form, FormStateInterface $form_state) {

    $user = \Drupal::currentUser()->id();
    $connection = \Drupal::database();
    $user_ip = \Drupal::request()->getClientIp();
    $query = $connection->query("select * from commerce_order_item join commerce_order on commerce_order_item.order_id = commerce_order.order_id where uid = :user and state = 'draft' and commerce_order.ip_address = :user_ip order by commerce_order.changed desc limit 1", [':user' => $user, ':user_ip' => $user_ip]);
    $result = $query->fetchAll();

    $cart_count = $result[0]->quantity;
    $order_id = $result[0]->order_id;

    if ($cart_count > 0 && $order_id) {
        $order = \Drupal::entityTypeManager()->getStorage('commerce_order')->load($order_id);
        $items = $order->getItems();
        $order->delete();
    }
}

function commerce_custom_cart_alter_redirect(&$form, FormStateInterface $form_state) {
  $responce =  new RedirectResponse('/how-it-works');
  $responce->send();
}


texts: drupal multisite and symbolic links with various subdomains

texts:
i create two subdomains dev.example.com and dev1.example.com in cpnael admin and i create a drupal installation in public_html/dev/sites/ and i create two folders dev and dev1 inside of sites and your own database and the sites.php your settings are

<?php
$sites['dev.example.com'] = 'dev';
$sites['dev1.example.com'] = 'dev1';
?>

i create symbolink links in this way

  ls -s ~/public_html/dev ~/public_html/dev1

working good dev.example.com but no dev1.example.com

but in this way dev1.example.com/dev and working the other installation, how to make this work enter to dev1.example.com instead dev1.example.com/dev?

thanks


texts: How does Drupal handle update of multiple module bundles of features without breaking stuff?

texts:
Let's say I have modules A, B and C.

I create a feature and it makes them into a single module.

Then one day, an update makes A, B and C not compatible, or maybe one deprecated or something.

Then my feature is broken...

Drush installs fresh modules of the newest version automatically, is there a way to do a drush command that bundles the modules inside the feature module?


texts: Parameters or keys in $attachments['#attached']['html_head'][] in page_attachments

texts:
While debugging extra markup in head section I came across one attachment in adsense module.
It is

  $attachments['#attached']['html_head'][] = [
    [
      '#tag' => '',
      '#theme' => 'adsense_comment',
      '#comment' => 'adsense page-level ads: ads disabled',
    ],
    'adsense_ads_disabled',
];

What is this second parameter or key adsense_ads_disabled called? And what is it's role in modifying the template.


texts: What is the purpose of _field_sql_storage_columnname()?

texts:
While reviewing a patch, I came across an interesting function, _field_sql_storage_columnname(). And I couldn't help but wondering, why on earth do we have this function?

git blame unfortunately wasn't helpful, as it only lead me to a commit that cleanup up windows line-endings.


texts:
Is there a default Drupal 8 database persist function? Like as for Doctrine.

for($i=1;$i<100;$i++) {
    $query->persist();
}

$query->flush();

I want to collect first a lot of data and bulk send it to the database.

The code I am using now is the following.

$db = \Drupal::database();
foreach($response->customer_products as $itemCode) {
    $productNode = $this->loadObjectProduct($itemCode);
    $db->insert('customer_product')
           ->fields([
              'card_code' => $cardCode,
              'item_code' => $productNode->id()
           ])
       ->execute();
}

That requires too much memory, and it fires a lot of queries.

Is there some way to collect the queries and bulk-send it to the database?


texts:
I have a drupal 6 site. Recently I've set up a CDN (not using the module. manually, and more specifically Google PageSpeed Service) to serve my content which is cached by boost. What I've noticed that when cron is run, the boost cache files are not deleted. This happens probably because my real domain name - www.example.com points to the cdn, which internally uses a different cname to reach my server (origin.example.com). Unlike other CDNs, PageSpeed doesn't request pages from my server using the internal cname, but rather uses www.example.com.

So anyway, to make a long story short: when cron runs, it clears origin.example.com cache files and not www.example.com (and these are the files my visitors get). I should say also that this CDN doesn't support https, so I access the admin using origin.example.com.

So, any ideas....


texts: How do you change rules settings on the fly?

texts:
I want to be able to modify a rule based on a setting choice made by a user, but I don't want to expose the form for setting the rule that you see at

admin/commerce/config/payment-methods/manage/<payment_method>/edit/<action_id>

because it contains some sensitive information such as our company's secret key for connecting to the payment gateway.

I have figured out that this UI is governed by a rule, and this particular setting is stored in the rules_config entity in its data field.  I want to be able to directly manipulate this field, but I am unfamiliar with the format and do not want to mess up the entire rule.

Is there a way to do a entity_import and change the rule with the new settings on the fly?  It seems like all of the hooks are only for when the module loads/installs.


texts: Unable to install the XYZ module since it requires the A module

texts:
When running (right after site install) the drush cim -y command, the following error appears:

Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in Drupal\Core\Config\ConfigImporter->validate() (line 728 of /var/www/ifc_test/web/core/lib/Drupal/Core/Config/ConfigImporter.php).
The import failed due for the following reasons:
Unable to install the XYZ module since it requires the YAML
Editor module.
Configuration XYZ.conf depends on the YAML Editor module that will not be installed after import.
Configuration yaml_editor.config depends on the YAML Editor module that will
not be installed after import.

(XYZ is the name of the custom module.)

I have the yaml_editor contrib module physically under modules
There is a dependency declared in the configuration files above
I also added yaml_editor to the core.extension.yml file to make sure it should be installed

Why config importer not enabling the yaml_editor module? I mean, that's what dependency declaration is for. Also, I've got a couple of other modules which are not enabled after site-install, they will be enabled during the drush cim process.
Of course drush en yaml_editor -y solves the problem, however, it's part of a building process, and I don't want to just insert an extra line into deployment script, just because this strange thing is happening.
Any ideas why config management doesn't enable (installs) this dependency, and why it says: "that will not be installed after import"?


texts: Getting path alias on the base of term id

texts:
Foolowing is the code to display breadcrumb, it will display the results like this Parent1/Parent2/Parent3/..

$var1=taxonomy_get_parents_all("term_id");
for($j=sizeof(intval($var1)) ; $j>=0 ;$j--)
{
  print $var1[$j]->name."/";
}

Here I want to compute the path alias for each parent, any suggestions?


texts: What is the order of execution when a module is installed?

texts:
I have a question and I don't know how the execution order is established when a module is installed.

If I install a custom module, which one is installed first?

a)

1.- The config/install folder

2.- Hook install

b)

1.- Hook install

2.- The config/install folder


texts: Link to a different view mode from entity reference

texts: Created a entity reference field i CONTENT A and linking it to CONTENT TYPE B. It works fine and takes me to the linked FULL CONTENT. Is it possible to link it to a different view mode like a TEASER or other view mode.


texts: How to display date/ time of current user base on time zone?

texts: Is it possible to display date/time of current user in his/her profile page. It should be base on his/her time zone settings. How can I achieve this goal?


texts:
I have created a form that has a submit button.

$form['products_submit'] = array(
    '#type' => 'submit',
    "#id"  => "submit_first",
    '#value' => t('Submit'),
    '#ajax' => array(
                'callback' => 'products_submit_driven_callback',
                'method' => 'replace',
                'effect' => 'fade',
                'progress' => array('type' => 'none'),
            ),
            '#prefix' => '
',
        '#suffix' => '
'
    );

  return $form;

And I want to add an image inside the button, at the left of 'Submit' text. I tried to add the img tag inside the t function but it just showed the code and not the image. Does anyone know how can I manage this?


texts: Need help Converting a jQuery event to a Drupal Behavior

texts:
I have a Drupal 7 web site that is using jQuery animations to fadeIn div tags.  I need an event to capture a fadeIn when it is completed.  I have found a sample jQuery example that does what I need it to, but I have not been able to successfully convert it to a Drupal 7 behavior and I'm not quite sure what I might be missing.

Fiddle Example

Below is my Drupal JS file, fadeInEvent.js.

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

        var _old = jQuery.fn.fadeIn;

        jQuery.fn.fadeIn = function() {
            var self = this;
            _old.apply(this.arguments).promise().done(function(){
                self.trigger('fadeIn');
            });
        };

        jQuery('.tab-pane').bind('fadeIn', function() {
             alert('fadeIn Done.');
        });

    }
};

In the above JS code, I never get my alert that the fadeIn has finished on the item I have selected.


texts: How to pass the Body field from a View to Rules?

texts:
Context: using the Views Rules module to pass a number of items to an action-loop in a Rules component (Action Set).

In views (display: rules) I selected among others the Body-field to be used. This field appears to be an array of different things (value, summary, format), when I use the [body-from-view:value] in an action, it seems to be empty.

Question
I must have some settings wrong. What Data Type do I have to select in the Row Variables (Rules Settings) in the View for the Body-field? Or maybe I use a wrong Replacement Pattern in the Action?

Note: handling nid, email, title, date works very well, these have Data type like text, integer, date.


texts:
I'm trying to create a simple block that have some link fields. those links have some predefined values and after get any new values from the admin replace with values and then render that values to the theme:
my_module\src\Plugin\Block\MyBlock.php:

<?php

namespace Drupal\my_modules\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * @Block(
 *   id = "my_block",
 *   admin_label = @Translation("My Block"),
 *   category = @Translation("My Block")
 * )
 */
class MyBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    // set default link field value.
    return array(
      'default_LinkA_url' => ('http://www.LinkA.com/'),
      'default_LinkB_url' => ('http://www.LinkB.com/'),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    // Add a form field to the existing block configuration form.

  $form['block_LinkA_url'] = array(
    '#type' => 'url',
    '#title' => t('Link A:'),
    '#size' => 60,
    '#default_value' => $this->configuration['default_LinkA_url'],
  );
  $form['block_LinkB_url'] = array(
    '#type' => 'url',
    '#title' => t('Link B:'),
    '#size' => 60,
    '#default_value' => $this->configuration['default_LinkB_url'],
  );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
    // Save our custom settings when the form is submitted.
    $this->configuration['default_LinkA_url'] = $form_state->getValue('block_LinkA_url');
    $this->configuration['default_LinkB_url'] = $form_state->getValue('block_LinkB_url');
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    return [
      '#markup' => $this->configuration['default_LinkA_url'],
      '#markup' => $this->configuration['default_LinkB_url'],
    ];
  }
}

Whatsoever I try I can't get any result, and this code only show one link like below:
http://www.LinkA.com (a plain text only)

but what I want to achieve is some think like This:
Link A
This Link has Some CSS Style and Open in new page rater than being a plain text like above link.
I would be happy to hear what the problem is.


texts: Remove '-Any-' value from exposed filter term field

texts:
I have a view with an exposed filter field. This field always shows the -Any- value. The data shown is dynamic so I cannot select the values to show. I have to remove that option in some way.

I've looked at this answer but this is for a form and I'm trying to do this for a views page of type chart. Anyway, I can't even dpm the form name as is said in the example.

My view name is x_report_plus_feature_dashboard and the display is page1.

How can I do this? Thanks!

EDIT:

I was able to remove the '-Any-' value with the following code:

function HOOK_form_views_exposed_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'views_exposed_form') {
    unset ($form['field_MYFIELD_tid_selective']["#options"]['All']);
  }
}

But now I have a problem. When I go to the view, the data shown is still the same that was shown when -Any- was selected. For me it's ok to show the data for the first entry as default but how to do it?


texts: Creating a custom field with dynamic/virtual computed property value

texts:
I’m working on a custom field (Drupal 8) where the author selects a taxonomy term from defined list, but the display is of, or includes, a node that references said term. I already have a service that can retrieve the desired node based on the term id. I started with a custom FieldFormatter for entity references, and that does a reasonable job of displaying the node information as desired.

However, what I really need is to get that node information included in a jsonapi response. I’ve made a custom FieldType extending EntityReferenceItem figuring all I would need is to add a computed property value (See https://www.drupal.org/node/2112677, e.g.). The examples keep pointing to the use of a specialized class extending TypedData, but the EntityReferenceItem treats the main property as computed, and doesn’t use that.

I also read How to properly define and return simple array computed field property but I'm not sure it's addressing the same kind of thing nor is there quite enough detail there to help me implement a solution.

class MyField extends EntityReferenceItem { ...
    public function getValue() {
        $values = parent::getValue();
        $values['computed'] = 'foobar';
        return $values;
    }
}

my_module/config/schema/my_module.data_types.schema.yml -

# Schema copied and modified from the configuration of the Entity reference field type
# in docroot/core/config/schema/core.data_types.schema.yml
field.storage_settings.my_field:
  type: mapping
  label: 'My field storage settings'
  mapping:
    target_type:
      type: string
      label: 'Blah blah blah'
field.field_settings.my_field:
  type: mapping
  label: 'Another label'
  mapping:
    handler:
      type: string
      label: 'Reference method'
    handler_settings:
      type: entity_reference_selection.[%parent.handler]
      label: 'Yet another label'
field.value.my_field:
  type: mapping
  label: 'Default value'
  mapping:
    target_id:
      type: string
      label: 'Value'
    target_uuid:
      type: uuid
# This part is new:
field.computed.my_field:
  type: mapping
  label: 'Hello World'
  mapping:
    target_id:
      type: string
      label: 'Computed Value'
    target_uuid:
      type: uuid

Any pointers out there?

My understanding is that I can set things up so that the computed value shows up in the $items parameter passed into my custom Formatter's viewElements() method, and, at least as important, will be part of a JSONAPI response when my_field is part of the include query parameter. As of now, neither of those things occurs.


texts:
How do I add flicker photo album on D6 via "insert/ embedded Media" button?
I don't know which links to copy on the fields:
(general + advanced)


texts: When does Views check node_access permissions?

texts:
I'm using the book_access module (https://www.drupal.org/project/book_access) and I'm finding that it has a good deal of bugs in it.

One thing I've found is in views 3.x, when I'm using a relationship to add the data for the top-level book in a view, and grouping the view results by the top level book, every node that isn't currently in a book doesn't show up since it seems that views isn't getting access permissions for anonymous users.

Though, when book_access is disabled, or if node_access permissions are bypassed, these items nodes show up in the view for anonymous users without any issue.

I'm trying to troubleshoot this, and I'm wondering if anyone knows the exact point at which Views 3.x takes node_access permissions into account so I can muck with some debug statements, etc. Can any one help out?


texts: Is there any easy way to switch between groups? Let's say if a user is a member of two groups, I would like a widget with a dropdown (or alike) for the user to select current group.


texts: How to redirect a user to his own content after log in?

texts: I want to redirect a user after log in to his own content.For example lets say a user created a node/3.After log in I want to redirect the user to node/3.How can I do that with rules or with something else?


texts: ckeditor in not showing up on one of my drupal site content type

texts:
I have installed ckeditor in my Drupal 7 site. It works well on all content types except one.
Actually, on one of my content type it doesn't show on Body field when I write content. But when I open that field in structure then I can see ck editor here.

I googled it but didn't find any helpful thing. So anyone of you who knows please help to resolve this issue.


texts:
I have a client with a really large taxonomy, which is used for a certain node type. My client wants that the parent term of a chosen subterm, to also be used for a node.

Let's say that this is the taxonomy:

Parent1

Child1
Child2

Parent2

Child3

If the user checks (they are printed as checkboxes) either child, its parent term will also be used.

Is there already a module for that, or something, or do I have to write my own?

Drupal 7


texts: Serving CSS, images and JavaScript in Drupal

texts: Does the whole Drupal stack get fired up (bootstrapped) each time one of these static content types gets requested?


texts: Selecting an SVG as an Image Field value

texts:
I have a Content Type, News, with an Image Field, News Icon.

When the field settings are viewed at /admin/structure/types/manage/news/fields/node.news.field_news_icon

I have supplied SVG as one of the allowed types.  I have also tried allowing only SVG.

We also have IMCE in use so I have SVG set up in the IMCE config like so at /admin/config/media/imce  I have also tried using a list separated by spaces including SVG.

The Widget settings for the field at /admin/structure/types/manage/news/form-display allow for the IMCE manager to be enabled.  I have tried disabling but it did not resolve the issue.

The widget displays and lists allowed types but no SVG.

IMCE allows upload of SVGs but when selecting one as the news_icon I get

The normal (non-IMCE) file browser gives the following when an SVG is selected for upload:

Is there a deeper setting I am missing to get SVG included in the list of allowed extensions for use as an Image Field value?


texts: Findout when a user joined an organic group

texts:
Is there a way to find out when a user joined an organic group?

I would also like to know how many members an organic group had on a particular date. Is that possible?

Thank you for all your help.


texts: How to add variables in *.libraries.yml in drupal 8

texts:
I need to convert the below code added in hook_page_attachments()
 and
 add the external js in *.libraries.yml but not sure how to add variables like
$token and $user->mail in the *.libraries.yml so I can just attach library

   drupal_add_js('http://js.acobot.com/' . check_plain($token) . '.js', 'external');
    $script = 'var _aco = _aco || [];';
    drupal_add_js($script, array('type' => 'inline', 'scope' => 'footer'));
    if ($user->uid) {
      $user_info = "_aco.push(['email', '" . check_plain($user->mail) . "']);";
      drupal_add_js($user_info, array('type' => 'inline', 'scope' => 'footer'));
    }

Add Your Script to a file
In *.libraries.yml, I have added

acobot-initialise:
  version: 1.x
  js:
    js/acobot.js: {}
  dependencies:
    - core/jquery
    - core/drupalSettings

Added that file to the library under

  $attachments['#attached']['library'][] =
  'acobot/acobot-initialise';

Use drupalSettings to pass data from php to js

  $attachments['#attached']['drupalSettings']['acobot']['email'] = check_plain($account->getEmail());

Added script acobot.js as follows

  (function ($, Drupal, drupalSettings) {

  'use strict';

  Drupal.behaviors.acobot = {
      attach: function (context, settings) {
            var _aco = _aco || [];
            _aco.push(['email', drupalSettings.acobot.email]);
      }   };

  })(jQuery, Drupal, drupalSettings);