texts: Drupal 7 stopped working 500 internal Server error

texts:
For some reasons, my site stopped responding today, Error

  The www.mysite.com page isn’t working

  www.mysite.com is currently unable to handle this request. HTTP ERROR
  500

I understand there are many reasons for 500 error and it hard to know what exactly happend, I had a look into server log and notice this error

  [Wed May 11 10:31:27 2016] [warn] [client x.y.z] mod_fcgid: stderr:
  PHP Parse error: syntax error, unexpected 'return' (T_RETURN) in
  /var/www/vhosts/mysite.com/httpdocs/pro/includes/common.inc on line
  5106.

Looking into common.inc

function drupal_json_encode($var) {
  // The PHP version cannot change within a request.
  static $php530;

  if (!isset($php530)) {
    $php530 = version_compare(PHP_VERSION, '5.3.0', '>=');
  }

  if ($php530) {
    // Encode <, >, ', &, and " using the json_encode() options parameter.
    return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
  }

  // json_encode() escapes <, >, ', &, and " using its options parameter, but
  // does not support this parameter prior to PHP 5.3.0.  Use a helper instead.
  include_once DRUPAL_ROOT . '/includes/json-encode.inc';
  return drupal_json_encode_helper($var);
}

Line 5106 =   return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);


texts: D8 - How to create a view to show content with a field that is a User Reference to currently logged in user only

texts:
In Drupal 8, I have a content type Medical Records that has a field that is an Entity Reference to Users. I want to create a View which will display Medical Records with that field for the currently logged in user.

How can I do that?


texts: Why does Drupal still convert links using a non-existant url alias pattern

texts:
First I created an alias for an entity type like this:

project/[project_type]/[id]

which worked fine. After a while I decided to delete all aliases and created a new pattern, and bulk generated all aliases.

[project_type]/[id]

However, drupal still converts menu links (with internal path) as well as links in views (linkto content) using the old pattern project/[project_type]/[id]

I have cleared cache of the site,
I have cleared the views cache,
I have re-saved all entities, I have checked the alias list, the
aliases pattern that drupal uses is not present in the list, the new alias patterns are present.

In some way, drupal still uses this phantom-pattern which is cached somewhere apparently. It refuses to use the new alias pattern for converting links.

The new alias patterns do work for manually created links that correspond with the new pattern. Just the automatic conversion from internal path to alias path does not work, it does use the new alias but an already deleted alias.


texts:
$items['mymodule/%user'] = array(
  'title' => 'My Module',
  'page callback' => 'mymodule',
  'page arguments' => array(1),
  'access arguments' => array('access user profiles'),
  'type' => MENU_CALLBACK,
  'delivery callback' => 'mymodule_ajax_callback',
);

Above code is from D7, I've used "mymodule_ajax_callback" as my "delivery callback" in D8 but I'm unable to find a way.

Tried finding solution here Structure of routes but I'm unable to get the solution.


texts: Countdown Timer Field cannot find Countdown Timer Library - even though it's there

texts:
I'm facing trouble with the enabling of the "Countdown Timer Field" module from within "Administrator" -> "Modules" -> Fields.
The error message I get is

  "The jQuery Countdown Timer Library could not be found. Please download it, install it in a libraries directory, and rename the directory to jquery-countdown. The library should be available at a path like sites/all/libraries/jquery-countdown/assets/countdown/jquery.countdown.js (Currently using jQuery Countdown Timer Library Not found)".

This doesn't really make sense to me, since I unzipped the JQuery in the correct location (I think.)

This is part of the "JQuery Coundown" module, version 7.x-1.0-alpha1. My end goal is to use Views on a field with a Countdown.

This is my directory structure:

root@brian-VirtualBox:/var/www/drupal/sites/all/libraries/jquery-countdown/assets/countdown# ls -laSh
total 16K
drwx------ 2 root root 4.0K Dec 30  2011 .
drwx------ 6 root root 4.0K Dec 30  2011 ..
-rwx------ 1 root root 3.0K Dec 29  2011 jquery.countdown.js
-rwx------ 1 root root 1.7K Dec 29  2011 jquery.countdown.css
root@brian-VirtualBox:/var/www/drupal/sites/all/libraries/jquery-countdown/assets/countdown#

Opening up index.html located in /var/www/drupal/sites/all/libraries/jquery-countdown/index.html works on my browser.

This looks like a permissions error.

root@brian-VirtualBox:/var/www/drupal/sites/all/libraries# chmod -R 777 jquery-countdown/

Then, the module will install correctly. However, I do NOT think 777 is a good permission to use on this, so I'm continuing to read about Drupal 7 Libraries, and what permissions should be used. It looks like the .zip I unziped did not preserve the correct file permissions for jquery-countdown.

More specifically, my question has now become, what should the permissions be for directories in sites/all/libraries for Libraries 7.x-20?


texts:
Using Drupal 7, I created a node with the 10 fields; these fields are inserted as a table.

What query can I use insert the field values to the multiple tables, since multiple tables are the multiple fields?


texts:
I'm dipping my toe into modifying a Drupal Commerce form. I want to change a few things with the hook they provide. The form id is: commerce-cart-add-to-cart-form-626 and the id of the submit button is edit-submit.

I created a Drupal module called jch_test

function jch_test_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state) {
  $line_item = $form_state['line_item'];
  $product = commerce_product_load($line_item->commerce_product[LANGUAGE_NONE]  [0]['product_id']);
  if ($product->type == 'product') {
    $form['submit']['#value'] = t('Test');
  }
}

...the module loads, but the code does not fire. What am I doing wrong? I'm sure this is a total noob mistake.


texts: Manually sort Commerce 2 products within the taxonomy term (category)

texts:
I have a view to display my products (categorized by taxonomy term) in the frontend.

I have another view admin/commerce/products to add new products in the backend.

How do I implement and configure DraggableViews so I am able to manually sort my products within the taxonomy term category?

Update

My steps what I tried:

Created a new view (for sorting the products)
added the title field
add the field Draggableviews: Product
In the sort criteria add Draggableviews: DraggableViews Weight (asc)

1) The problem here is that I get some double values?

I have another (taxonomy) view to display my products (categorised by taxonomy term).

2) In this view I am not able to add the sort criteria add Draggableviews: DraggableViews Weight (asc)? Draggableviews is not available in this view?


texts:
I've added some image and link content to region-sidebar.tpl.php before it executes the print $content. All good, except now the client wants the images and links specific to content type. (I can't do it all in CSS, otherwise i'd go that route).

How can I test for content type in region-sidebar.tpl.php or have a variable that is set. The region-sidebar.tpl.php doesn't see a variable defined in preprocess_node.

In region-sidebar.tpl.php I need something like:

<?php if ($content):
  if ($mycontent_type == "foo") {
       ?> < add some html stuff here> <?php
  }
  print $content; ?>


texts: Display an image through page.tpl.php only on front page

texts:
I want to display an image only on front page through page.tpl.php... However i am not sure about the syntax or where i am going wrong as the code that i type in leads me to en error (syntax error)...here's the code:

<?php  if (drupal_is_front_page())
    {

    }
?>


texts:
Is there a module that will help expose Solr through Services?

Specifically I'm looking for ways to pass options (pagesize, content type) on to Solr through rest.


texts: How to Sum up 2 fields of integer, and present as "Time period"?

texts:
I am building a drupal site.
I have 2 fields: "prep time"  and "cook time".
Both fields are:
FIELD TYPE = Integer
WIDGET = Time Period

I need to sum up the two fields to one field (total time), and present it with widget of Time period, Or at least present it in time format ("2 hours 35 min").

Question Update (3/12/2013):
In addition, I need to present the date with ISO format in the HTML code (datetime="PT3H45M"). After I am using the Computed Field module, I don't know how to present the computed number as time format ("2 hours 35 min") and add the ISO format in the HTML code. as you will see below, I created a "field--field_preptime.tpl.php" that works great for the "prep time" and the "cook time", but when I am passing the computed value, the out put is wrong - as I don't see the the time format correctly, and the iso foramt in the html code is also wrong.

can someone help me fix it?

here is how I created the prep time and cook time:
I created the following field override template file called: "field--field_preptime.tpl.php"

<?php
function time_to_iso8601_duration($time) {
    $units = array(
        "Y" => 365*24*3600,
        "D" =>     24*3600,
        "H" =>        3600,
        "M" =>          60,
        "S" =>           1,
    );

    $str = "P";
    $istime = false;

    foreach ($units as $unitName => &$unit) {
        $quot  = intval($time / $unit);
        $time -= $quot * $unit;
        $unit  = $quot;
        if ($unit > 0) {
            if (!$istime && in_array($unitName, array("H", "M", "S"))) { // There may be a better way to do this
                $str .= "T";
                $istime = true;
            }
            $str .= strval($unit) . $unitName;
        }
    }

    return $str;
}
 ?>

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;

  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
    <?php $time = strtotime(render($item), 0); ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>>

          <time datetime=<?php print time_to_iso8601_duration($time); ?> itemprop="prepTime"><?php print render($item); ?></time>
    <?php endforeach; ?>

The Output of "prep time", when I am viewing in the "view source" on the relevant page (I don't know how to do the same for the calculated value of "total time"):

          <time datetime="PT3H45M" itemprop="prepTime">3 hours 45 min</time>

Thanks.

UPDATE 1/10/2014:
I couldn't do it without using computed fields. when I tried, I got an error: "Notice: Undefined variable: field_cooktime in include() (line 54 of D:\XXX\field--field_totaltime.tpl.php). I got the same error for preptime.
I guess that is the reason the output is always 0 sec for total time, even though I put the totaltime field after the preptime and the cooktime fields.

How can I get the value of two fields in my override template, and then Sum up?

Thanks.


texts: How do I change the redirect page for unpublished nodes?

texts:
It seems that the standard Drupal behaviour for unpublished nodes is this: If a visitor types in a URL to an unpublished node they are redirected to a login page. To -me- that signals that the content is 'there' but they just need credentials.

So: Is there a way to change this behaviour so that if they type in a URL to an unpublished node, literally -nothing- happens? Or perhaps they are redirected to the home page?

Below is my attempt to redirect to home page. The page still redirects to the Access Denied. What I don't get is that if I alter the Rule so that it tests for role 'Administrator' it works -fine-. So apparently an Anonymous user has some special property?

{ "rules_redirect_unpubished_content_url_to_home_page" : {
    "LABEL" : "Redirect Unpubished Content URL To Home Page",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_view--bags_cases" : { "bundle" : "bags_cases" } },
    "IF" : [
      { "NOT node_is_published" : { "node" : [ "node" ] } },
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "1" : "1" } }
        }
      }
    ],
    "DO" : [ { "redirect" : { "url" : "/" } } ]
  }
}

I also tried this:

function jch_utilities_node_view($node, $view_mode, $langcode) {
  if ($node->status != 1) {
        drupal_goto('/some-page');
  }
}

...and again, the 403 fires before this has a chance to run

Finally, I tried hook_init, but yet again, the 403 fires before this has a chance to run.

What am I missing?


texts: how to delete width and height attributes from image field for particular nodes

texts:
I would like to strip width and height attributes from image fields for a few specific nodes.

I tried hook_preprocess_image($vars) but $vars don't have enough information. From the documentation, theme_image() won't have that information, either. I can't figure out the node from the path, because the node is used in a block. Using CSS width:auto !important; does not work, at least with Firefox 16 (and I've read IE 8 has problems with it, too). Any ideas?


texts: Using the Webform2PDF pdf generation doesn't properly replace tokens, but only when emailed

texts:
For example, the token [submission:values:identification_information:first_name] is blank in the emailed PDF that gets sent out when submitted, but if I go to the "Results" screen in the CMS, and generate the PDF for a particular submission, the above token is properly replaced with the first name submitted on the document.

Why is this not replaced in the emailed version properly?

This is using modules:

Webform 7.x-4.1
Webform 2 PDF 7.x-3.2


texts: Drupal module Date 2.7 update - Database Table name

texts:
I just updated the Drupal7 module Date from 2.9 to 2.10.  There is a database table update that acccompanies that module update.  What is the name of the database table that is updated?  (or can you direct me where to find that information?)

Attaching screenshot of the database update performed when installing the date module.  What are Date text widgets?


texts: Shopping cart not cleared after checkout

texts: I have had several customers who have been able to make changes to previously placed orders. Even though the order status is set to pending after checkout is complete and their payments are processed, they are able to go back into the shopping cart (which should be empty but is not) and delete items from the cart.  They then believe that the payment amount will be adjusted to reflect the new total of items left in the cart, but of course it will not, as the original amount has already been charged to their card by Elavon. Why does the cart still contain items already ordered? How do I prevent this from happening?


texts:
I am trying to simulate a multi-site environment in an integration test with phpunit. I know how to init a new database connection with Database::addConnectionInfo but how can I cleanly switch the database used by the current environment?

Database::setActiveConnection will only work for SQL queries but I would like to use the entity_type.manager service and the only way I found is to replace the database service in the container and call KernelTest::setUp. Switching back an forth between the databases is still pretty buggy and complex.

Any ideas?


texts: Cron Run resulted in Fatal Error Message

texts:
Using Drupal 6.22
PHP 5.2.17
PHP memory limit - 150M

Last time I ran Cron was 2 weeks 19 hours ago

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

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

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


texts: How can I pass a long javascript string to PHP hook_menu in Drupal?

texts:
On mysite/build-order I have a long order code that I'm assembling using Javacsript and sending via _GET in the URL to a hook_menu page for processing.

It can be as long as this (or longer), and am sending it to the create-order page like this:

<script type="text/javascript">
    //...building code
    var orderCode = "sku:OR-4x4>qty:2>prc:55.00>nfo:OR-4x4,sku:CVR>qty:1>prc:50>nfo:OR-4x4,sku:PF>qty:15>prc:2>nfo:OR-4x4 (sdfsdfg),sku:EM>qty:2>prc:12.95>nfo:OR-4x4 (sdfsdfg),sku:SC>prc:25>qty:4>nfo:Some description,sku:DB>qty:10>prc:4>nfo:Some description,sku:ES>qty:10>prc:3>nfo:BlahBlah,sku:OR-4x4>qty:2>prc:55.00>nfo:OR-4x4,sku:CVR>qty:1>prc:50>nfo:OR-4x4,sku:PF>qty:15>prc:2>nfo:OR-4x4 (sdfsdfg),sku:EM>qty:2>prc:12.95>nfo:OR-4x4 (sdfsdfg),sku:SC>prc:25>qty:4>nfo:Some description,sku:DB>qty:10>prc:4>nfo:BlahBlah-visiondelimiter-Phasellus laoreet lorem vel dolor tempus vehicula. Curabitur blandit tempus ardua ridiculus sed magna. Quisque placerat facilisis egestas cillum dolore.-visiondelimiter-eventName";

    var url = '/create-order/' + orderCode;
    window.location.replace(url);
</script>

Ive implemented a hook_menu setup in my custom module called "create_order_menu" and it works fine.

function mymodule_create_order_menu($ordercode){

    // do stuff with $ordercode

}

It all works fine. The only problem is that the order code string passed through the URL can sometimes be twice as long and it trips a 404 Error in the mysite/create-order page. When I shorten the code, it works. When I lengthen it again, it breaks.

Is there a better way to send such a lengthy variable to my hook_menu page setup?


texts: I want to customize my search box. I want it to auto complete as I type and not to be case sensitive. What should I do to achieve this?


texts:
I have created a custom module in Drupal 8 and added the routing table to mymodule.routing.yml. Whenever I am trying to hit a particular path, I am receiving the HTTP response "406 (406 Not Acceptable)."

What is causing this?


texts: What's the coding standard for class constants?

texts:
I'm trying to figure out the proper naming convention for class constants.

For general constants, the coding standards states:

  Constants should always be all-uppercase, with underscores to separate words. This includes pre-defined PHP constants like TRUE, FALSE, and NULL. Module-defined constant names should also be prefixed by an uppercase spelling of the module they are defined by.

However, object-oriented names don't follow the normal conventions of prefixing the name with the module or using underscores, instead opting for various forms of camel case. And unfortunately, the object-oriented coding standards doesn't mention class constants at all.

So which of the following is correct?

class Foo {
  const FOO_CONSTANT_VALUE = 'bar';
}

or

class Foo {
  const CONSTANT_VALUE = 'bar';
}

or

class Foo {
  const constantValue = 'bar';
}


texts: How do I stop duplicate pending orders from being created

texts:
Using drupal 7.63, drupal commerce 1.14
For an unknown reason groups of empty orders are being created with a status of Pending. Each group belongs to the same user. Seems to happen randomly.

Is there a way to track down what triggers this strange action.
I can not find anything in the logs that helps.


texts: How can I use the same render cache but for json?

texts:
I am working on REST API and I would really like to be able to use the same mechanism for responses as Drupal uses for cached content.

Unfortunately there is no render cache, everything is JSON responses. So there are no #ccache setting or page cache policy to be applied out of the box.

So I wonder if it is even possible and if so how should I approach it?

What I'm after basically is to cache the responses in the same manner as entities for example. So if the context is specific user and I am displaying entity information I would like to get fresh information if the entity is changed but the same content if not and the user is the same..and so on.


texts: How to set content-security-policy header?

texts:
I want to set Content-Security-Policy header in my site.

I found a module to set CSP (I have not tried it yet). But I want to know is there any option available in drupal 8 core itself to set CSP.


texts: adding new validation method using HookEventDispatcherInterface::FORM_ALTER event

texts:
I'm trying to add a new validation method for 'user_login_form' using HookEventDispatcher module and events:

class MyFormEventsSubscriber implements EventSubscriberInterface {

public static function getSubscribedEvents() {
      return [ HookEventDispatcherInterface::FORM_ALTER => 'alterForm'];
  }

public function alterForm(FormAlterEvent $event) {

    if ($event->getFormId() == 'user_login_form') {

      $form = &$event->getForm();
      $form['#validate'][] = 'my_api_authentication';

    }
  }

  function my_api_authentication(&$form, FormStateInterface $form_state) {
    $test = 1;
  }
}

But i never reach my_api_authentication function. How i need to refer it and where should be suposed to be implemented ?

May be i should manage with hook_form_FORM_ID_alter instead FORM_ALTER HookEventDispatcherInterface event ?


texts: How to make a Feature available only to certain Spaces?

texts:
For a Drupal 6 Open Atrium site (i.e., Features, Spaces, Organic Groups) I'm running, I've created some custom Features that only really apply to a handful of the hundreds of groups on the site.

As it stands, the "Customize Features" config screen shows all the Features, including those I'd like to intentionally restrict to just a couple of special groups.

What's the best way to prevent these special Features from being offered to every group, while retaining those Features on the special groups?


texts: How can i show only content type fields in block or how can i call a add content type page in a block

texts:
How can i call a add node "content type" in a block.
I have upload an image below Image1.

I have a content type : Upload Resume ie upload_resume

Anomynous users can also only create this content type.

I want this fields in a block where user can upload resume not in page style bcos of below image shows other factors ie Image2

Updated Image after Oscar answer


texts: How to make the Access by Term module respect User Role permissions first?

texts:
I need Access By Term (ABT) to respect the user Role permissions before considering the term relation between the user and the node.

Scenario
The user does not have permission to edit "Basic Page" content type but he is term related to a "Basic Page" node. He should not have permission to edit this page because his Role doesnt grant it, but as he is related to this node by a term, ABT grants him "update" permission.

Any ideas? Is it possible without patching it?


texts: Drush not reading config file from top-level /drush folder within Drupal install?

texts:
I'm trying to have localized drushrc.php configurations and alias configurations per site I'm working on, but no matter what I'm trying right now, drush refuses to find or load my drushrc.php configuration file.

Based on #2 in the example configuration file found here:
https://github.com/drush-ops/drush/blob/master/examples/example.drushrc.php

I should be able to place a drushrc.php configuration file in a top-level /drush folder location:

$DRUPALROOT/../drush/drushrc.php (top-level parent above root folder)

No matter what I'm trying drush never seems to detect the configuration file in this location when I do a drush status in the drupal root folder. Everything works fine if I place drushrc.php within my home folder (~/.drush/drushrc.php) or in a sub-folder of my install (*$DRUPALROOT/drush/drushrc.php). Problem is I don't want there and would like it in a top-level folder above my root install!

Is there a secret to getting drush working based on this ?! I've tried drush cc drush every time I move my configuration around but it's never found!

On Mac OS X if it matters? Please help!


texts:
I have to make redirect for links:
http://example.com/file/file1.pdf
http://example.com/file/file2.pdf
...
to links:
http://example.com/sites/default/files/file1.pdf
http://example.com/sites/default/files/file2.pdf
...
I've tried .htaccess changing, but fail. (it's too Voodoo for me)
Redirect project has no such function (afaik).
I don't know what hook can I use in my module for such redirect.

How can I make such redirect?

UPDATE:

I've created simple .htaccess file:

  RewriteEngine on
  RewriteRule ^file/(.*)$ sites/default/files/$1 [L]

And it works.

But when I insert in original Drupal .htaccess
line RewriteRule ^file/(.*)$ sites/default/files/$1 [L] after RewriteEngine on
- there is no successful redirect.

Why?

SOLUTION:

  RewriteEngine on
  RewriteRule ^file/(.*)$ sites/default/files/$1 [L, R=301]


texts:
I'm on Drupal 8,

I'm using \Drupal::entityQuery('block') to get the list of blocks.

Now I want to determine if the block is visible for:

Current Page (Content Type)
Current User (Role)
Current Path

I want this information according to visibility settings configured in block's configuration.

I can use $block->getVisibility() method when I load the block and there I can iterate through visibility settings and find out if the block is visible or not.

I wander if there is a better and easier way to do this??


texts: How can I parse php code from another file during nodeapi function?

texts:
I am embedding html and loading javascript onto a page with the nodeapi function.

I use it in this form:

 function first_order_decay_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
     if($op == 'alter') {
         $path = drupal_get_path('module', 'first_order_decay');
         $path .= '/';
         $code = file_get_contents($path . 'templates/first_order_decay-static.tpl.php', false);
         $code = preg_replace("/[\r\n]*/","",$code);           //make $code one line of text
         $code = preg_replace("/<!--EMBEDREMOVE-->.+<!--EMBEDREMOVE-->/","",$code);  //remove stuff in between these comments. This is stuff I don't want
         $pos = strpos($node->body, '[FLOT](kinetics1)');   //search node->body for this command
         if ($pos !== false) {     //insert my html if we found my embed command "[FLOT](kinetics1)"
             $node->body = substr_replace($node->body, $code, $pos, strlen('[FLOT](kinetics1)'));
             //add in js
         }
     }
 }

The question is.... How can I parse php into html from $code variable? It seems that because the page is already in the rendering process, Drupal ignores the php. Is there another phase of nodeapi I can use to do this?

Thanks!


texts: How can I remove everything from a Commerce cart if a certain product is added, except that product?

texts:
I'm sure this is pretty simple to do but I'm spacing out on it.

If a product of a certain type is added to the cart, I want to remove everything in the cart , regardless of its type, except for that product. At the same time I need to make sure that the quantity for that product will never exceed 1.

I've started a hook_commerce_cart_product_add() implementation but I haven't got very far with it:

function MYMODULE_commerce_cart_product_add($order, $product, $quantity, $line_item) {
  if ($product->type == 'the_product_type') {
    // Now what?!
  }
}

I'm more than happy to use Rules instead of custom code for this, but again I haven't got very far trying it that way.

Any pointers would be greatly appreciated.


texts: Site dead after Devel Module and Library sethtmldom

texts: After installing Devel Module (and Library simplehtmldom), the Drupal7 site is completely dead. Have already set the module to 0 on System table in database, and the module files removed by FTP. But still no recovering. How to remove simplehtmldom Library? What else to recover the site? Thanks.


texts: How can I make views page with unique dates?


texts: Is there any module available in Drupal 7 for getting a résumé uploading functionality? I need a form with a couple of text fields and a file upload field that accepts files of .doc, .odt, and .docx formats. My requirement is to send an email also with the attachments, and also see the list of submitted résumés.


texts: How to add custom views display formats to a view?

texts: I have a project in which some views have different displays. I want to create similar displays for other views, see in the image. Can I reuse them or I will have to do custom coding again for each view?


texts:
I run various Drush commands, including lots of queues, in a loop. I want to see the output in my syslog.

I am currently using drush -r /var/www queue-run my_queue_name_here 2>&1 | logger, which outputs the following line.

  Processed 2 items from the my_queue_name_here queue in 0.58

This is OK, but I feel like this must be wrong. Surely many people want to direct Drush messages to the syslog. Is it possible without using the logger as above?


texts: I have a quicktabs instance that shows lists of content by year (2012, 2011, 2010 and so on). Each tab is a views generated block that pulls content by date using relative values (current year, current year-1, etc.). How can I override the title of each of the tabs so that I don´t have to hardcode year values as tabs titles? Thanks in advance.


texts:
I install the module of "mobile switch" and enable it.
But I just only enable this module and set a mobile theme, the error message is showed:

Notice: Undefined index: ismobiledevice in mobile_switch_boot() (line 40 of D:\xampp\htdocs\drupal\sites\all\modules\mobile_switch\mobile_switch.module).

I don't know how to solve it.
Have anyone know what'w happen?
Thanks....


texts: Is there a way to have more/advanced filters on https://example.com/admin/content using Drupal 8? Like filtering for taxonomy terms or fields for example?


texts: Can we output individual form items within a Layout?

texts:
We are using Layouts (via mytheme.layouts.yml) to create regions for our Node Edit forms.  This looks something like...

edit_nodelayout:
  label: 'Edit Node Layout'
  category: edit
  path: templates/panels
  template: edit-nodelayout
  default_region: toplayout
  regions:
    toplayout:
      label: 'Top'
    details:
      label: 'Details'
    other:
      label: 'Other'

We have placed each field for the content-type into the appropriate region via the admin UI.  At least one of our fields is a reference field to a Paragraph entity-type.

In our template, which is defined in the yml as /templates/panels/edit-nodelayout.html.yml, we are currently outputting all content as full regions.

{# some html here #}
{{ content.toplayout }}

{# some html here #}
{{ content.details }}

{# some html here #}
{{ content.other }}

How would we access individual items within a region?  For example, if within the content.details region, we have placed a field called "Foo", how do we output that individually?  We have tried this...

Please enter everything you know about Foo

{{ content.details.foo }}

This becomes interesting when the field called "Foo" is a reference to a Paragraph entity-type.  How would we then output individual fields within "Foo" entity?

Output the "bar" field within the "foo" Paragraph type

{{ content.details.foo.bar }}

Any help, pointers to documentation appreciated.


texts:
I've implemented hook_menu and in page callback there is a function in my module which retrieves some records randomly and theme them with theme_table. Now I want a button on the page for sending this page exactly as it is to a predefined email address without refreshing the page because of randomly selected records.

I placed a button through simple HTML code but don't know how I can implement it's onClick function. Or is there any better way to do that? Thanks


texts:
Can an anyone help me.I am getting the following error while running my drupal 7 application

Fatal error: Cannot redeclare function views_views_plugins() (previously declared in /var/www/vhosts/cibi.hq.k.grp/newsite/sites/all/modules/views/includes/plugins.inc:15). If this code worked without the Zend Optimizer+, please set zend_optimizerplus.dups_fix=1 in your ini file in /var/www/vhosts/cibi.hq.k.grp/newsite/sites/all/modules/ctools/ctools.module on line 113


texts: How to change (via custom code) the order in which the columns of a view result are rendered?

texts:
I have a table created in a Drupal 7 site, using Views (version 3). I need to change the columns' order depending on some custom code I have.

I've tried looking into all views' hooks, but I couldn't find anything regarding the order in which the columns will be rendered. Where should I look into?


texts:
How can I display questions in a block using the Quiz module?

I do it using the Views module, but when I click on Start quiz, it goes to a page. I want all functionality done inside a block.


texts: How change user form mode programmatically?

texts:
i create 2 custom user register form mode :

When i go to mysite/user/register

Drupal show me the last form mode i create :

  S'inscrire

But when i go in the admin mode, for add a user, it show me the same form.
i try to display "Affichage Admin" form mode with more field.

So i try to alter the form mode programmatically.

Any idea how can i change form mode before it render ?


texts: Views: Sort By Global Math Expression Result?

texts:
I have created a global math expression field in views, and I want to sort the results by the results of the math expression.

In particular, I use Drealty to connect to a RETS server and download property listings.  My local database gets populated with prices and number of bedrooms for each listing.  I want to sort based on Cost per Bedroom.

Any Ideas?


texts: Display Date field in email body with rules module

texts:
On this page I have a registration form. The registration form is send to an e-mail address with Rules module.

The related event (Content type 'Event') has a Date field (Wanneer/When), the Date of the event.

How do I display the Date field in the e-mail body? When I put [entity-fetched:field-event-date] in the e-mail body, it's not displaying any Date?


texts: is there a module for status updates in drupal 7

texts: I am looking for a module that will allow users on my site to post status updates similar to Facebook and twitter. Or is there a way to configure the heartbeat module to allow users to post status updates? i am using the zen sub-theme in drupal 7.


texts:
I have create menu link named as my account

Now i want to link that my account link to  user/user_id(currnt login user)/edit

Anybody  tell me how to do that

Thanks


texts: How can we override view field template in drupal 8

texts: How can we override single field from Views template files 'views-view-field.html.twig' from location themes/theme-name/templates/views/views-view-field.html.twig.


texts: How to get the input value with preprocess from a Fulltext Search Filter exposed form

texts:
For Drupal 7 I found a workaround to a similar situation here, when combining Core search block forms and search api contextual filters. This "workaround" won't work when using Search API, if you don't want the Contextual Filter in your view.
My current setup:
I am using Search API, with a database server, and displaying the results with a Views page. I am using Search: Fulltext search (exposed) and Exposed form in block:Yes for the search block form.
What I am trying to achive:
I would like to put what was searched for in the Header of the view, and also at the top of No Results Behavior like this:
"You searched for bananas"
The problem:
When using Search: Fulltext search (exposed), the replacement patterns for the input value are not available in the Global Text Area. They are only available by adding a Fulltext Search Contextual Filter. There is an issue for this with a patch for Drupal 8 here.
My question:
Is there a views_pre_render or some other hook that can be used for the Header or No Results region to output the value that was input into the Search: Fulltext search (exposed) form?
There is a dev module to create a token, but it only works for the Results Summary.


texts: Creating module with autocomplete and accepting multiple values in textfield

texts:
I am creating my own form in my module using the Form API.

How do I enter multiple values in the below textfield and have it autocompleted, and suggested (separated by commas, for example)?

Right now it takes whatever is in the textfield box as one single big string.

$form['keywords'] = array(
  '#type' => 'textfield',
  '#title' => t('Keywords'),
  '#size' => '40',
  '#multiple' => TRUE,
  '#autocomplete_path' => 'papers_pub_search/keywords_autocomplete'
);

function _autosearch($string) {
  $query = "SELECT name FROM users WHERE name LIKE :name";
  $result = db_query($query, array(':name'=> '%' . db_like($string) . '%'));
  foreach($result as $row) {
    $match[$row->name] = check_plain($row->name);
  }
  drupal_json_output($match);
}


texts:
I have been trying for a few hours to beautify the output that twig generates, such a way that will be properly indented with tabs.
For example, I would like the following output:

To become something like:
For example, I would like the following output:

I would like for this "autoindentation" to happen for all tags, because it makes the markup clean and easier to debug.
So I found this question: https://stackoverflow.com/questions/11878728/rendering-clean-tidy-html-with-twig-templates
And since I have been trying to make drupal load that twig indent extension and that twig lexer extension.

My code so far:

root.info.yml

name: Root
type: module
description: ‘Provides basic cosmetic functionality that should be in core.’
core: 8.x
version: 0.0.1

root.services.yml

services:
  # Override the default Twig Environment so we can add our custom Twig Lexer.
  twig:
    class: Drupal\root\TwigEnvironment
    arguments: ['@app.root', '@cache.default', '%twig_extension_hash%', '@state', '@twig.loader', '%twig.config%']
    tags:
      - { name: service_collector, tag: 'twig.extension', call: addExtension }
  root.twig.Indent:
    class: Drupal\root\Indent
    tags:
      - {name: twig.extension}
  root.twig.Lexer:
    class: Drupal\root\Lexer
    tags:
      - {name: twig.lexer}

and the Indent.php and Lexer.php as provided in that answer.
The problem is that the lexer wold not load because the tag twig.lexer does not exist.

So I tried to add the following code:

namespace Drupal\root;

use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Template\TwigEnvironment as CoreTwigEnvironment;
use Drupal\root\Indent;

/**
 * Twig environment that uses temporary file storage.
 */
class TwigEnvironment extends CoreTwigEnvironment {

  public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, StateInterface $state, \Twig_LoaderInterface $loader = NULL, $options = []) {
    parent::__construct($root, $cache, $twig_extension_hash, $state, $loader, $options);
    // Set our own lexer to the Twig environment.
    $this->setLexer(new Lexer($this));
  }

}

and drupal does not let me replace the Twig Environment and comes with the following complaint:

LogicException: Unable to register extension &quot;drupal_core&quot; as extensions have already been initialized. in Twig_Environment-&gt;addExtension() (line 941 of /var/www/konquer.technology/vendor/twig/twig/lib/Twig/Environment.php).
call_user_func_array(Array, Array) (Line: 322)

Is there a way to do this? I can't find any documentation on this topic.
Or maybe another way to achieve my goal of indented twig output


texts:
I'm just trying to find out how to fund a Drupal project.

I found https://www.drupalfund.us/, but it seems it is not really working because there are no active projects, or maybe I'm missing something.

At this moment, how could I fund a Drupal project?


texts:
I am using db_select for database query, following code works fine when $keyword is any string

 $result = db_select('my_table', 'mt')
        ->fields('mt')
        ->condition('my_column', '%' . db_like($keyword) . '%', 'LIKE')
        ->execute()
        ->fetchAllKeyed();

How can I make the same query working when $keyword is suppose to be an array of strings like ("del","mum") ,if my_column is location column so query will return me places like Delhi, Mumbai.


texts: Kernel testing a function that calls render()

texts:
I have a kernel test that is testing the render array method for a table within a controller.

In this method I have added a dropbutton for an actions column. For this to display correctly in the table column, you need to call the render() function on that cell before returning the rest of the render array.

    [
          'title'   => 'Title',
          'bundle'  => 'My content Type',
          'date'    => '15/10/2019',
          'actions' => render([
              '#type'  => 'dropbutton',
              '#links' => [
                'action_1' => [
                  'title' => $this->t('Action 1'),
                  'url'   => Url::fromRoute('myRoute1'),
                ],
                'action_2'   => [
                  'title' => $this->t('Action 2'),
                  'url'   => Url::fromRoute('myRoute2'),
                ],
              ],
            ]),
    ];

This works fine when viewing the page, but in a kernel test I get:

LogicException : Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead.

Using either renderRoot() or renderPlain() causes the test to pass, but renders the links as individual anchor tags rather then in a drop button.

Is there a different way to render items inside a table render array that will still allow the method to be testable?


texts: CKEditor and IMCE: how to access to public files directory

texts:
I have a problem that I can't access public files directory from IMCE as file browser (and CKEDITOR as editor). When an user write a blog post, he can't upload images to public directory because this path doesn't appear in the IMCE directory tree.
Prior to post this question I have searched in Drupal Answers, in Drupal forum and in Google if there is an answer to my question but without success. I've read some other answer to similar questions but without success. I put here my configuration.

Config media file system:

Public path: sites/default/files
Private path: sites/default/files/private
Temp path: tmp
Checked: Private files served by Drupal

CKEditor file explorer: IMCE (for all)

Users, that can write blog post, has permission to "Bypass file access control", "Administer files", "add and upload new files", etc.

When they write a blog post and open IMCE to upload an image in the body, the paths shown in the directory tree are all relative to private directory and they can't select public path.
It's for Drupal 7.

How should I do to allow user to upload files to public path with IMCE?

UPDATE
After some days searching about this question, I have found where is the problem. There are two, very old, open issues in IMCE that are just my problem.
https://www.drupal.org/project/imce/issues/2018863
https://www.drupal.org/project/imce/issues/1700438
CKEditor launch IMCE according to the method you have selected to download files in Admin > Configuration > Media > File system, under the "Default download method". If you select private download then CKEditor always open IMCE in private folder and then you can't switch to public folder, despite of the new node will be public (blog post).
I think it's a very big problem. I should have the option to select if I want public or private directory in IMCE when It was launched by CKEditor.


texts: File viewer with search filter by category and sub categories Drupal 7

texts:
I want to create a site running locally(localhost) which views files that are uploaded by authorized user. Using search filter by category and sub categories, all ebooks that are included in that sub categories will be shown. How to create this kind of search? Is there any module that will do exactly this one?

Ex, IT books---->programming books--->. Then it will display all programming books that are already been uploaded. When click to one of the programming books, it will display all the pages, like those in adobe reader. The concept is like that. how could i achieve this one? I'm having way too much problems searching for file viewer modules that will perfectly work. Hope you can help me.


texts: How do I redirect the unsubscribe link in a newsletter to a particular node?

texts:
I am using the Simplenews module for sending newsletters, and the Mandrill service for sending emails. When I send a test newsletter to the test user, the unsubscribe link should be redirected to particular node, for example to node/2.

How can I achieve this?


texts: User register endpoint showing notifications

texts:
I'm trying to setup an endpoint for a 3rd party app to allow users to be created on my site through a REST endpoint, which is mostly working so far, although, I've just navigated to my site through the front end, and I've realised it's showing me all the notifications for all the test users I'm creating.

I'm not logged in as an administrator, just a normal user account, and the setting for Show errors and notifications is off, so why is it showing me all these notifications, there's no way I can leave that in


texts: Is taxonomy a good choice for managing Code Lists, instead of creating tables of their own?

texts:
I have a project where there is a set of code lists (code/label), Airport codes for example.

I am hesitating between creating my own tables, with two columns code/label and using Taxonomy (fieldable \o/ )
Any suggestions ?


texts: How can I programmatically restrict node access?

texts:
I'm using Drupal 8 with the nodeaccess module.

I'm able to set the node grants with the form.

I also have a custom module which imports new nodes. These new nodes should be shown only to certain users.

I know I can insert the corresponding lines into the database tables nodeaccess and node_access. But this might be not consistent.

Is there a way to set the nodeaccess programmatically?


texts: Is there a recommended method to construct a form on a grid (2-dimensional array) with Form API?

texts:
Possible Duplicate:
  Theme Drupal Form API checkboxes as a grid

I would like to create a form that is able to accept values which will be saved into a multidimensional array. Is there an advised method on how to accomplish this with Form API?

As an example:

  |  A  |  B  |  C  |
--+-----+-----+-----+
1 |     |     |     |
--+-----+-----+-----+
2 |     |     |     |
--+-----+-----+-----+
3 |     |     |     |
--+-----+-----+-----+

I would like to have a textfield for each grid square and save the end value into a single array which will be serialized and saved as a variable.

EDIT: Just to clarify, I don't particular care if the form is output as a TABLE in a HTML sense, but it would obviously be nice to have it stored as a multidimensional array from a PHP perspective.


texts:
Is it possible to display a node's field in a table? Is there any module providing it?

For example I have a node "English idioms" which has a field named: "Idiom" and "Explanation". I would like to put them both in a (table->tr->td - each).

At the moment I have these fields in div's with classes but I would like to avoid it if it's possible.

Kind regards.


texts: Revert a Feature Component programmatically

texts:
I have a Feature installed using an Installation Profile. But I always have to go and Revert a particular Component so that it's no longer Overridden (so that, for example, the Feature's Blocks appear).  I just wanted to know if I can take this step programmatically using code itself in the Installation Profile.

In the screenshot below, I've shown the component that has to be reverted programmatically (in the screenshot, it's already reverted back so check box is not available).


texts: Using Rules How can I Remove a role from ANY user not just current user

texts:
I have a use case for a project where a user of specific role has access to the site during specific dates. What I want to occur is- when the date passes the user loses his role and access to the site.

Currently, I have this rule working on Cron run, but the only option to me is to react on site:current-user. Is there a way to react on ANY user?


texts:
When I load some pages using Ctools modal window, those pages have many another links, submit buttons etc, so when I follow those links, I loose the window. Drupal Overlay has no problems with it.

Is it possible to emulate Drupal Overlay using Ctools?


texts: Body text special characters are escaped

texts:
I have this code which I am using to get the body text from a node rewrite it with a regular expression and replace it, (I am replacing all you tube video links with embed codes)
function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {

  switch ($entity->bundle()) {
    case 'article':

    $node_body = $entity->get('body')->value;

    Drupal::logger('origin-body')->notice($node_body);

    $node_body_replaced = preg_replace('/(?:https:\/\/)?(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/', '', $node_body);

      Drupal::logger('replaced-body')->notice($node_body_replaced);
      $body_encoded = htmlspecialchars($node_body_replaced, ENT_QUOTES, 'UTF-8');
      //$entity->body = $node_body_replaced;
      $entity->set( 'body',$body_encoded  ); // This appears to be where special characters are getting escaped

     break;
  }
}

Both my logger messages show normal text output in the drupal log so I guess it happens somwhere when the node gets saved or $entity->set().  I have tried running through htmlspecialchars() and it does nothing.
For example, I am migrating content from WordPress and after running through this function my normal HTML becomes

lorem ipsum dolar lorem ipsum dolar lorem ipsum dolar lorem
ipsum dolar lorem ipsum dolar lorem ipsum dolar .

I am using Drupal 9


texts: I created new content, but I can't see manage field. I googled the problem, all the solutions say enable Field UI module, I did enable the Field UI, but still I can't see the manage fields, any help please?


texts: How do I set the #default_value of a select list to the first option?

texts:
I'm currently using hook_form_alter and $form['#after_build'] to try and set a term reference select list's default value to the first option in the list. I'm using the Reference Option Limit module in my content type, and even though the first item appears to be selected (because the field is set to Required), it's not. With help from the Devel module, I checked, and the #default_value is definitely empty. The closest I've gotten is with this:

function set_keywords_after_build($form, &$form_state) {
    $keyword = $form['field_product_keyword']['und']['#options'];
    $form['field_product_keyword']['und']['#default_value'] = $keyword;
return $form;
}

Looking at the page array, this will set the default value to:

#default_value (Array, 1 element)
 - 13 (String, 19 characters ) KeywordName

where 13 is the tid of KeywordName.

Looking at another term reference field in the same form, it should look something like this:

#default_value (Array, 1 element)
 - 0 (String, 2 characters ) 38

Where 38 is the tid and 0 (I'm assuming) is the key?


texts: Scrolling tables horizontally with Bootstap 3 - Opera Mini/mobile

texts:
I'm having issues on opera(mini/mobile) with scrolling an table horizontally. I am using bootstrap 3 as a theme. My table markup is as follows:

I am using the following CSS:

.table-responsive {
    width: 100%;
    overflow-y: hidden !important;
    overflow-x: auto !important;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    -webkit-overflow-scrolling: touch !important;
 }

The scrolling works on all other browsers I tested, just Opera that not playing nicely

PS: I notice same issue on the bootstrap project page:
http://getbootstrap.com/css/#tables-responsive

Doesn't work, any pointers or workarounds please!


texts: Issue with translating SQL query into Database API (count(*))

texts:
I'm currently building some SQL queries for a view that will display some statistics, and I'm having trouble with adding COUNT(*) in a couple SQL queries:

Original SQL query

SELECT LIBELLE, COUNT(*)
FROM PRESTATIONS
WHERE EXERCICE = 2017
AND NUMCOLL = 89519
AND ETAT = 'R?gl?e'
AND PRESTATION = 'AIDES'
group by LIBELLE;

The result is the following:

+----------+----------+
| LIBELLE  | COUNT(*) |
+----------+----------+
| RESULT 1 | 1        |
+----------+----------+
| RESULT 2 | 3        |
+----------+----------+

This is how I set my code up after reading a bit of documentation:

$group = $value->andConditionGroup()
    ->condition('EXERCICE', 2017, '=')
    ->condition('NUMCOLL', 89519, '=')
    ->condition('ETAT', 'R?gl?e', '=');

$con = \Database::getConnection('old_db');
$value = $con->select('PRESTATIONS', 'prestations');
$value->fields('prestations', ['LIBELLE']);
$value->condition($group);
$value->condition('PRESTATION', 'AIDES', '=');
$value->groupBy('LIBELLE');
$nb_demandes = $value->countQuery()->execute()->fetchAll();

However, when executing this code, I have the following error:

  Syntax error or access violation: 1055
  'old_db.prestations.PRESTATION' isn't in GROUP BY: SELECT COUNT(*)
  AS expression FROM (SELECT prestations.PRESTATION AS PRESTATION,
  prestations.LIBELLE AS LIBELLE, 1 AS expression FROM {PRESTATIONS}
  prestations WHERE ( (EXERCICE = :db_condition_placeholder_0) AND
  (NUMCOLL = :db_condition_placeholder_1) AND (ETAT =
  :db_condition_placeholder_2) )AND( (EXERCICE =
  :db_condition_placeholder_3) AND (NUMCOLL =
  :db_condition_placeholder_4) AND (ETAT = :db_condition_placeholder_5)
  )AND (PRESTATION = :db_condition_placeholder_6) GROUP BY LIBELLE)
  subquery; Array ( [:db_condition_placeholder_0] => 2017
  [:db_condition_placeholder_1] => 89519 [:db_condition_placeholder_2]
  => R?gl?e [:db_condition_placeholder_3] => 2017 [:db_condition_placeholder_4] => 89519 [:db_condition_placeholder_5]
  => R?gl?e [:db_condition_placeholder_6] => AIDES )

I do believe I didn't set up my COUNT(*) correctly but I can't find another way to do so.

How can I solve this?

Thank you in advance


texts: Content type permission to specific users

texts:
How do I set content permission so that specific content types become visible/usable to the admin user only, while other content types may be visible by other user roles?

After I added new content types, I checked the rebuild permissions.

Content access is working fine but the problem seems to be the fact that the enw content types aren't made visible / accessible to the other roles...


texts: Blocks Structure screen not displaying because there are too many blocks

texts:
I have a large D8 site and currently have about 400 blocks. When I got to the main Blocks Structure admin page
-- /admin/structure/block -- It now hangs up and will not display. I just get an error:
The application did not respond in time.
The site is hosted on Pantheon. I have a basic plan limited to 256M of application memory. We tested increasing the memory available to 512MB. That did not help, nor did the Pantheon Advanced Page Cache.
Any ideas on how to fix? Cache this specific admin page? Split up this page up into multiple pages like the Custom Block Library screen?
Thank you, Jeff


texts: How to modify the value of a taxonomy field of a node using hook_node_view()?

texts:
I'm using Drupal 8 and I have a taxonomy field in a content type. I have created a node and added the term reference value to this node. Now the node shows up the link to the term.

I want to show value of the text field added in that taxonomy instead of link to the term.

I want to use this hook and set the value of the term field via code.

function hook_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) { }


texts:
I'm just wondering if its possible to alter a field before loading.

Here is the situation.

Im using commerce kickstart.

When I'm in a product page(inner page or product details page), I want to change the value of field_my_field before it load up to the page.

In pseudocode:
If field_my_field == "something" change field_my_field to "my custom value"


texts: HTML markup is still stripped out, even if I am using the mimemail-message.tpl.php template

texts:
I'm having an issue where confirmation emails from Ubercart seem to have  HTML markup removed. In my setup somehow the HTML markup in the Ubercart email template is being stripped when it reaches the mimemail template. A view of the source for emails sent shows that the HTML markup Mimemail puts into the message is there. It's just everything coming from Ubercart that is stripped out.
The line 35 of the mimemail-message.tpl.php template file is the following one
<?php print $body ?>

This is where the problem lies. All the HTML markup above and below this makes it into the email. However, the HTML markup that should be in the $body variable is stripped out.
Is there something I could be missing in my settings?


texts: Basefield 'string' shown as select list widget in entity form

texts:
I've got a custom entity ('content_sharing') and defined one of the fields as $fields['entity_definition'] = BaseFieldDefinition::create('string').... The create-form I'm showing the user is loaded with an empty entity via a controller like so:

    $contentSharing = $this->entityTypeManager()
      ->getStorage('content_sharing')
      ->create([]);
    $form = $this->entityTypeManager()
      ->getFormObject('content_sharing', 'custom_mode')
      ->setEntity($contentSharing);
    $output['form'] = $this->formBuilder()->getForm($form);
    ...

What I need now is to present the user a select-list of possible strings (options) that are dynamically pre-populated everytime the form is loaded. The only FieldWidget for string fields is a textfield. I tried to come up with my own custom FieldWidget similar to this

 * @FieldWidget(
 *   id = "string_select_list",
 *   module = "content_sharing",
 *   label = @Translation("Select list for strings"),
 *   field_types = {
 *     "string"
 *   },
 *  multiple_values = FALSE
 * )
 */

class StringSelectList extends OptionsWidgetBase {

However, this resulted in an error and I  noticed that this needs to have options defined which I cannot (don't know how to) provide for my string basefield.

I could of cource just add a dummy form-element select list that provides the values for my entity field, but I wanted to use the entityform as it is without any further custom elements.

Possible with a custom widget or any other solutions?


texts: Delete multiple images at once from a node

texts:
I'm having an image field with option set as UNLIMITED to accept infinite images, basically deleting images in single manner is possible, but how it can be possible to delete multiple images at once from a particular node?

I've tried it by applying some logics using Views Bulk Operations and also using Editable Views, but nothing worked for me.

Any suggestion on this?


texts: How to convert hook_filter and hook_filter_tips in Drupal 7?

texts:
I have trouble converting my custom modules in D7. Found a how-to here http://drupal.org/node/224333 but not so clear to me. This how my code in D6.

/**
 * Implementation of hook_filter().
 */
function custom_inline_filter($op, $delta = 0, $format = -1, $text = '') {

  switch ($op) {
    case 'list':
      return array(0 => t('Custom Inline Filter'));

    case 'description':
      return t('Substitutes @inline tags with the uploaded inline images of the node.', array('@inline' => '<!-- INLINE -->'));

    case 'settings':
      break;

    case 'no cache':
      return FALSE;

    case 'prepare':
      return $text;

    case 'process':
      return custom_inline_substitute($text);
      break;

    default:
      return $text;
  }
}

/**
 * Substitute inline image placeholder comments with inline image divs.
 * This function is usually called by hook_filter.process but also by template.php (used for RSS).
 *
 * @param $content
 * @param $node_id
 * @param $rss
 */
function custom_inline_substitute($content, $node_id = NULL, $rss = FALSE) {

  // Get nid from argument

  if ($node_id) {
    $nid = $node_id;
  }
  // Get nid when a node is displayed

  elseif (arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
  }
  else {
    return $content;
  }

  // Instantiate inline image class

  $inlineImg = new CustomInlineImage($nid, $rss);
  return $inlineImg->substitute($content);
}

/**
 * Implementation of hook_filter_tips().
 */
function custom_inline_filter_tips($delta, $format, $long = FALSE) {

  if ($long) {
    return t('You may link to uploaded images within the current node using the wysiwyg editor toolbar icons.
      The Custom Inline Filter is to replace added image placeholders with uploaded inline images.'
    );
  }
  else {
    return t('Use the wysiwyg editor toolbar icons to display uploaded images inline.');
  }
}


texts:
I would like to allow users on my site to be able to display a background image, not from their computer but from an outside source, for their profile page.

I assume the best way to do this is to add some kind of an image embed field on the front end of the profile page and tweak the CSS so that the image resides in the background (panel.)

If so, my question is twofold: (1) What is the best module to use to link to the image and, (2) how do I display the field to users? Do I create a content type and use exposed filters in views to display it?

Is there a better approach?

Thanks. :)


texts: Core request handler documentation maybe has conflicting information?

texts:
I wanted to confirm with the community and maybe get some clarity about D8 Documentation:

On the Core request handling system ported to Symfony2 framework page it states:

  The PHP superglobals for $_GET, $_POST, and $_SERVER are deprecated
  and should not be used, ever.

However, I can't seem to locate this information on php.net. PHP setting register_globals is deprecated. Is this what they are refering to or did I miss something huge in recent news? No longer able to use $_GET in our custom modules for D8?


texts:
How can I change the search form placeholder value? I can change the value of it in my .theme file, but I want it to be also translatable.

What is the correct way of doing this?


texts: Ambiguity of using '.' as a separator in the site directory name might have security implications?

texts:
In a Drupal installation, which is served through the web server's default server config (i.e. it gets any request for an otherwise unknown domain) I have a settings file at DRUPAL_ROOT/sites/example.com.au/settings.php.

This site is normally requested as http://example.com.au/, but what's given that the request gets to the server (and the user agent may not follow the directives of DNS here), what's to prevent it being served as a response for http://example.com/au/ or http://example/com/au/?

The testing I've done suggests something blocks this from working (I get a redirect to the install page), but I want to be clear on what's going on, and to be sure that it's reliable.

If accessing a drupal installation through divisions of the domain name and path other than the expected one is possible, then there would be security implications.

EDIT:

In response to @tenken:

From https://api.drupal.org/api/drupal/sites!example.sites.php/7

This file allows you to define a set of aliases that map hostnames, ports, and pathnames to configuration directories in the sites directory. These aliases are loaded prior to scanning for directories, and they are exempt from the normal discovery rules. See default.settings.php to view how Drupal discovers the configuration directory when no alias is found.

It's not perfectly clear, but that sounds like the directory in the sites file will will still be used if a request arrives with a domain name that was not anticipated, in which case the problem remains.


texts: Where are the best places to post Drupal 7 RFP?

texts:
Do you have any thought on the best places to post an RFP for Drupal 7 development and theme work?

I have posted on drupal.org and groups.drupal.org but someone mentioned odesk, but I wasn't sure if that would be fruitful or just overkill.


texts: Destination property uri not provided migrating uri

texts:
I'm working on a file migration from D6 -> D8, and in my case, all the files are already on S3, and they don't need to move, so all I need to do is migrate the URL to a new fid. Based on direction from mikeryan1 in IRC, in my config file I'm just doing

uri: uri

However, when I try to migrate, I get a 'Destination property uri not provided' error. I tracked down the code to EntityFile::getEntity():

// By default the entity key (fid) would be used, but we want to make sure
// we're loading the matching URI.
$destination = $row->getDestinationProperty('uri');
if (empty($destination)) {
  throw new MigrateException('Destination property uri not provided');
}

where getDestinationProperty() is

  public function getDestinationProperty($property) {
    return NestedArray::getValue($this->destination, explode(static::PROPERTY_SEPARATOR, $property));
  }

Tracking the code all the way through to NestedArray::getValue(), I find that the problem is my $ref array does not contain a uri key, so getValue() returns NULL.

  public static function &getValue(array &$array, array $parents, &$key_exists = NULL) {
    $ref = &$array;
    foreach ($parents as $parent) {
      if (is_array($ref) && array_key_exists($parent, $ref)) {
        $ref = &$ref[$parent];
      }
      else {
        $key_exists = FALSE;
        $null = NULL;
        return $null;
      }
    }
    $key_exists = TRUE;
    return $ref;
  }

Here is my migration config file.

id: file_s3
label: Files - S3
migration_group: file
migration_tags:
  - Drupal 6
source:
  plugin: file_s3_source
  constants:
    # source_base_path must be set by the tool configuring this migration. It
    # represents the fully qualified path relative to which URIs in the files
    # table are specified, and must end with a /. See source_full_path
    # configuration in this migration's process pipeline as an example.
    source_base_path: ''
process:
    # If you are using both this migration and d6_user_picture_file in a custom
    # migration and executing migrations incrementally, it is recommended that
    # you remove the fid mapping here to avoid potential ID conflicts.
  fid: fid
  filename: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/source_base_path
        - filepath
    -
      plugin: urlencode
  destination_full_path:
    plugin: file_uri
    source:
      - filepath
      - file_directory_path
      - temp_directory_path
      - is_public
  uri: uri
  filemime: filemime
  filesize: filesize
  status: status
  changed: timestamp
  uid: uid
destination:
  plugin: entity:file

So what do I need to do to my config file to avoid this error?

Thanks.


texts: What to do for "Login attempt failed for admin." and "Access denied" to path admin?

texts:
In Watchdog, I started seeing several entries like this:

  Login attempt failed for admin.

And

  access denied 2016/04/04 - 15:06  admin

These are generating a fair number of log entries.  The IP address is different for each request; they all geolocate to Russia.

Obviously, this is not me, and there doesn't appear to be any particular danger to my site, but is there a way to minimize such requests?


texts: Update node revision programmatically don't save new value

texts:
If I try to edit a review:

$node = node_revision_load(56);
$node->set('field', 'value);
$node->save();

This has no effect. The value is not changed.

The function does not make mistakes, it seems to save everything, but it is not so.

How can I do ?


texts: Fatal Error when upgrading to Drupal 7.43

texts:
I'm trying to upgrade from 7.26 to 7.43 but after following the instructions here, /update.php returns a blank page.

When I visit the site homepage, I receive the following error...

  Fatal error: require_once() [function.require]: Failed opening
  required
  '/websites/123reg/LinuxPackage22/cr/es/t_/crest-buildingservices.co.uk/public_html/includes/menu.inc'
  (include_path='.:/usr/local/php52/share/pear:/usr/local/php52/share/php')
  in
  /websites/123reg/LinuxPackage22/cr/es/t_/crest-buildingservices.co.uk/public_html/includes/common.inc
  on line 5110

Any advice greatly appreciated.


texts: Drupal website only in Arabic on English installation

texts: I have installed my Drupal in English Language. But i want my all pages to be only in Arabic as of now. English launch will be later. How i do such that all wesbiste content can be only in Arabic and Admin language will be in English.


texts: webform "Load a pre-built option list" not shown

texts:
I use the webform module to build a form. I'd like to fill a select with values coming from a database. I use the hook

Here is some sample code:

    /**
     * Implementation of hook_webform_select_options_info().
     * See webform/webform_hooks.php for further information on this hook in the Webform API.
     */
    function custom_webform_pre_build_list_webform_select_options_info() {
        $items = array();
        $items['user_roles'] = array(
            'title' => t('Roles'),
            'options callback' => 'custom_webform_pre_build_list_user_roles'
        );

       return $items;
    }

    /**
     * Build an options list to be used with webforms select list based in drupal roles
     */
    function custom_webform_pre_build_list_user_roles() {
        $roles = user_roles();

        $contentarray = array();

        $contentarray[0] = t("Select user role");

            #$new_taxonomies = array();
            foreach ($roles as $role) {
                $contentarray[$role] = t($role);
            }

        return $contentarray;
    }

I activated the module. Now my problem is to select this list of entries for my select. I cannot see the "Load a pre-built option list" when I click "Add" under "options" for the select box in the form builder.
What am I doing wrong?

I'm using version 3.x of webform and the "Options element" module.

Thx, Sven


texts:
I have my migrations pulling in my field data. However, I cannot figure out how to get the text_format set in my YML file so the HTML doesn't show up on import. I have my content type body text format set to full_html, yet on import if is basic_html.

Here is my YML parts:

source:
  plugin: url
  data_fetcher_plugin: http
  urls: 'http://location.to.xml/node/00000/xml'
  data_parser_plugin: simple_xml

fields:
  -
    name: body
    label: body
    selector: content:encoded

process:
  'body/format':
    plugin: stripouthtml
    default_value: full_html
  'body/value': content

destination:
  plugin: 'entity:node'
  default_value: news

I think it is the process part I need help understanding. I have tried a few different ways. I just cannot find anything that has worked or should work.


texts: What are my pages called for adding blocks?

texts:
I've searched for an answer, but cant find one. On my site I'm building I have 6 or seven main links/pages called things like Home, About us, Contacts, local issues, etc.

I want to add blocks to these pages individually, and I'm told when adding blocks that:

"Specify pages by using their paths. Enter one path per line. The '' character is a wildcard. Example paths are blog for the blog page and blog/* for every personal blog. (front) is the front page."*

OK, so I can use 'front' (in tags) for my home page, and that worked - but what are the other pages called? What do i put in the box other than 'front' (in tags) to get a block on say my 'Contacts' page.

I am a real newbie, and still rather overwhelmed with Drupal, so please don't asume I understand much!

Thanks


texts: How to get the inreverse selection of a Views query?

texts:
Imagine that you can easily create a view that gives you a subset of some content on my site. However, you want the opposite view - all the content minus that subset - and that view is very hard or impossible to create.

The question then becomes: Is it possible to invert the result/selection of a Views query?

NB! Sorting is irrelevant for this question: It's all about the returned selection of items, not the order of the items.


texts:
In job schedule module, I have bunch of jobs that works, What I want to do is give the admin the ability to stop a certain job as he desires.

The only way I could do is that I could remove the job all together from the table with this:

  JobScheduler::get($job['name'])->remove($job);

and I would recreate it again.

But isnt there a way to skip the job instead of deleting and recreating it again? Rules maybe?


texts:
The front page title in the menu is Home or Startseite in german. I would like to give it another name. How can I do this?

The question is asked multiple times over the internet (fore example here) but no clear answer... Thank you


texts: CKEditor placeholder text doesn't work (config.js)

texts:
I'm trying to add placeholder text to my ckeditor screen like for example Type here ... . You can do this with the configuration helper plugin.

I've placed the ckeditor library in sites/all/libries. I've pasted the plugin in sites/all/libraries/ckeditor/plugins. Then I've added the following code to my config.js (in ckeditor folder).

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
    config.extraPlugins='confighelper';
    config.placeholder = 'Type here...';
};

But this doesn't work. The config.js isn't added to my page when there's a ckeditor. The code is also not in ckeditor.js (which is loaded on the page, I thought that the plugin maybe added it to the file).

I've also tried to add the code to my script.js which is always loaded like this:

(function ($, Drupal, window, document, undefined) {
    Drupal.behaviors.my_custom_behavior = {
      attach: function(context, settings) {
        CKEDITOR.editorConfig = function( config ) {
          // Define changes to default configuration here. For example:
          // config.language = 'fr';
          // config.uiColor = '#AADC6E';
          config.extraPlugins='confighelper';
          config.placeholder = 'Type here...';
        };
      }
    };
})(jQuery, Drupal, this, this.document);

But still no result... . I'm using CKEditor 4.4.2.1567b48 . Text format is filtered html. The ckeditor works but I can't add any plugins (I would also like youtube plugin). Also cleared my cache a couple of times.

Am I doing something wrong?


texts: Is there a module that will let me set up site-wide notifications like Stack Overflow's orange one?

texts:
I'm looking for a Drupal 7 compatible module that will let me set up site-wide notifications similar to Stack Overflow's orange bar (Welcome to this site, read the FAQ etc.). I haven't been able to find one.

Please note that I don't want to display system messages like this, I want something where I or other selected users can set up custom ones.


texts: How can change RealName / User account link destination in D7

texts:
I'm using RealName module in D7 to show real names on nodes and in comments and would like to link the real name [user:first-name] [user:last-name] to a custom content type (a 'profile' page), instead of the standard 'user account'.

It is easy to use RealName in D6, but I've been searching for ages for a solution in D7.

I have read "Have username link to profile rather than regular userpage by default", but I am not using Content Profile.

I wondered if I need to 'preprocess' the user name, but can only read php and have no idea what to change there.

I have set the URLs for account pages to be [user:first-name]-[user:last-name]-account using URL alias patterns and the URLs of the custom content type I am trying to link to look like [user:first-name]-[user:last-name].

What is the simplest way to change the 'View user profile' link, which appears in comments and in node 'Authored by' to point at my custom user profiles instead of the standard 'user account's pages?


texts: How to place a specific comment on top of list

texts:
PLease help me with this requirement in D6.

I need to mark one comment as best, so this comment should stick on top of all comments posted irrespective of sort order.

How can this be achieved, any ideas?


texts:
How can I style the Date Module as noted in the image below?  Which hooks/functions would be involved?

Is there a better Date input widget for Drupal 7?

I'm using Drupal 7 and the Date module is currently 7.x-2.0-alpha4.

.


texts:
I am trying to get the Category name (from the General form settings) for webforms in a preprocess function, ultimately to add as a class to the webform wrapper.

MYMODULE.module:

function MYMODULE_preprocess_webform(&$variables) {
  kint($variables);
}

Right now I don't see a "category" value in the array structure.

How do you get this value in preprocess? Maybe I need a different hook?


texts: How do I replace function commerce_customer_options_list with my own?

texts:
How can I replace

/**
 * Implements hook_options_list().
 */
function commerce_customer_options_list($field) {

in commerce_customer.module around line 949 with my own options_list build routine?

the hook is just sent directly to the commerce_customer module, and I don't see how I can hijack it.

Thanks


texts: Following an excellent suggestion, I added the Flag module to a website in order to allow users to store their favorite stories in a dedicated page. This seems to be working really nicely, but how do I now add the option to flag content as a field in a view?


texts: hook_file_download is invoked when the file is deleted

texts:
I have a implementation of hook_file_download because I check if this is a private/specific file and do a redirection for specific link:
function my_file_download($uri) {

 //some code here
 // if(substr($uri,0,26) =='private://specificcontent/'){
    header("location:http://mysite.com/myURL");

}
But, when I remove a file such as image below, this function too is called, generating a error, because the code try redirect for "http://mysite.com/myURL". I believe that when the file is deleted, not is correct receive a call in hook_file_download. But, case if it is not evitable, what I need do for verify that is a delete command and ignore redirection command?


texts: How to display a block with menu child items programmatically?

texts:
I need to create block with a list of links menu child items (only first level) of a given menu like this:

Item 1
Item 2
Item 3

With this code I can have the menu items but I don't know how to process each element to obtain the menu item title and the menu item url.

$menu_name = 'main';
$menu_tree = \Drupal::menuTree();
$parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);
$parameters->setMinDepth(0);

$tree = $menu_tree->load($menu_name, $parameters);
$manipulators = array(
  array('callable' => 'menu.default_tree_manipulators:checkAccess'),
  array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
);
$tree = $menu_tree->transform($tree, $manipulators);


texts:
i have installed i18n module and added this lines to setting.php and empty cache to translate slogan and contact form information and  ...
but it doesnt affect site and values dont add to i18n_variable table.

$conf['i18n_variables'] = array(
        'site_name',
        'site_slogan',
        'site_mission',
        'site_footer',
        'anonymous',
        'user_registration_help',
        'user_mail_welcome_subject',
        'user_mail_welcome_body',
        'user_mail_approval_subject',
        'user_mail_approval_body',
        'user_mail_pass_subject',
        'user_mail_pass_body',
        'contact_form_information'
    );

do you have any suggestion to solve this problem?


texts: How to display title of a webform in twig template Drupal 8

texts:
I want to display webform title in a webform.html.twig but I did not find anything in variables array regarding the title of the webform

function THEMENAME_preprocess_webform($variables){
  $title = "?";
}

How do I get webform title in a preprocess function ? Any suggestions or other approach ?


texts:
I have a search form in my header. Instead of using the core search, I used a custom block that takes the search string and passes it to the Advanced Search page, built in Views, where users can further filter their results. That's working.

What I want to do is have the form fields collapsed by default, with some text that says "Filter Results" that when you click it expands to show the fields.

How do I do this?


texts: Condtitional taxonomy terms (from different vocabularies) during content creation

texts:
I have existing content type using vocabularies for year, model name, manufacturer, etc. I want users to be able to create new content of a different content type where they would select model year to start and then be able to select from a list of model names tagged with that year. Even better, once they make that selection, it would be nice to have Drupal select manufacturer.

I've looked at hierarchical select, SHS, entityreference, and others but can't seem to find something to work with terms in different vocabularies. Term relations looked promising but broke the taxonomy manager so I couldn't figure out how to use it.

Any help is greatly appreciated.


texts: What to replace entity_uri() with in Drupal 8?

texts:
So I have the following code in my Drupal 7 module:

$uri = entity_uri('node', $node);
$breadcrumb[] = l($node->title, $uri['path'], $uri['options']);

Anyone know how to convert the above code to Drupal 8?

Since l() is depreciated, I believe the second line should be replaced as follows:

$breadcrumb = array(Link::createFromRoute($node->title, $uri['path'], $uri['options']));

I'm struggling with what to do with entity_uri() since the change records don't really indicate how that function is to be replaced.

Note: this is being used within the BreadcrumbBuilderInterface class.


texts: Prepopulate Exposed Group Filter with relevant values

texts:
I have a view which displays the venues (including city), dates and times shows are being performed at. Once a date passes the listing disappears.

There are more shows in the database than are being performed at any one time and new shows are added occasionally.

Using an exposed filter (grouped) I want a user to be able to select from a list of shows that is scheduled to perform or from a list of cities we are touring to.

As the lists of cities and shows changes on a weekly, sometimes daily, basis I don't want people to have to go in and edit the view to add or remove shows or cities from the  redefined lists and to do it programatically instead.

I have a table (node-type) for shows, another for venues, and a third for performances which uses node-reference to to state X-show at Y-venue and then adds performance details.

My view pulls from the performance type where the performance is greater than or equal to now (only showing future performances), with relationships to the Shows type to get the name of the show and another relationship to get the name/boxoffice/location/etc of the venue.

My view works fine with manually entered values into the 'configure filter criteron' - but this needs to be updated dynamically.

Can anyone suggest anything to make it work, or another approach to the problem which may be more apt?

Thank you.

System: Drupal 7, Views 7.x-3


texts:
I'm using Drupal7 with CK editör.

When I add html code for an image (<img src="...")
I can see it on the editing page; but when I save it, I can't see anything on the page.

How can I solv it?


texts: Set dropdown list programmatically in exposed view filters

texts:
I have programmatically set a text CCK to a select and given a few choices:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'myview') {
    // Add our custom All buttons.
    $form['field_1hour_currency']['#type'] = 'select';
    $form['field_1hour_currency']['#options'] = array(
      '' => t('<Any>'),
      'USD' => 'USD',
      'EUR' => 'Euro'
    );
  }
}

But this display defaults to a Multiple Choice box, and I want it to be a dropdown list. How can I set programmatically a select to force single so it displays a dropdown list?

Thank you


texts: How do I remove default comment validation in drupal 7?

texts:
Drupal is showing error message for empty comments by default. how can i remove that error message.
Note:- (I have not written any custom validation. It's the default validation provided by drupal module.) My changes in comment.module

if (empty($comment->cid) && empty($comment->pid)) {
if(($form['#node']->type=='iks_videos_youtube_video') || ($form['#node']-               >type=='iks_videos_vimeo_video' || $form['#node']->type=='iks_videos_video')){
if(isset($form['#node']->type) && $form['#node']->type=='iks_videos_youtube_video')
{   $vtype='yt';}
else
{   $vtype='v'; }
$form['#action'] = url('video/' . $form['#node']->video_id[LANGUAGE_NONE][0]['value'] . '/'.$vtype.'/' . strtolower(str_replace(' ', '_', $form['#node']->title)));
  }else{
$form['#action'] = url('comment/reply/' . $comment->nid);}

}

my custom module code

function  iks_videos_form_comment_node_iks_videos_youtube_video_form_alter(&$form, $form_estate) {
if (isset($form['actions']['preview']))
unset($form['actions']['preview']);
$form['subject']['#access'] = FALSE;
unset($form['author']['mail']['#description']);
$form['#submit'][] = '_iks_videos_comment_form_submit';
    }

alter form

function _iks_videos_comment_form_submit($form, &$form_estate) {

if(($form['#node']->type) && $form['#node']->type=='iks_videos_youtube_video')
    $vtype='yt';
else
    $vtype='v';
$form_estate['redirect'][0] = 'video/' . $form['#node']->video_id[LANGUAGE_NONE][0]['value'] . '/'.$vtype.'/' . strtolower(str_replace(' ', '_', $form['#node']->title));

}


texts: Create field collection item in drupal 7

texts:
I am trying to dynamically create a field collection for a node.

Field collection item (field_markers) is used to create a point or a polygon for a map content type.

During debugging I found that my code create an entry for all the member elements of field collection but it does not create or update a record for field collection itself.

I have referred to https://stackoverflow.com/questions/6242018/dynamically-add-a-field-collection-in-drupal-7-by-script but was not able to resolve my problem.

Following is my code so far.

//Create field collection
$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_markers'));

//Create fields related to field collection
$field_collection_item->field_title['und'][0]['value'] = "Brian 22";
$field_collection_item->field_summary['und'][0]['value'] = "Test entity creation.";
$field_collection_item->field_summary['und'][0]['format'] = "filtered_html";

$lat = -35.3241665257384;
$lon = 139.8046875;

$field_collection_item->field_coordinates['und'][0]['wkt'] = 'POINT ('.$lon.' '.$lat.')';
$field_collection_item->field_coordinates['und'][0]['geo_type'] = 'point';
$field_collection_item->field_coordinates['und'][0]['lat'] = $lat;
$field_collection_item->field_coordinates['und'][0]['lon'] = $lon;
$field_collection_item->field_coordinates['und'][0]['left'] = $lon;
$field_collection_item->field_coordinates['und'][0]['top'] = $lat;

$field_collection_item->field_coordinates['und'][0]['right'] = $lon;
$field_collection_item->field_coordinates['und'][0]['bottom'] = $lat;

//attach field collection to map content type
$field_collection_item->setHostEntity('map', $node);
// Save the entity.
$field_collection_item->save(TRUE);


texts:
What I can't workout is what steps I need to see if the entity is loaded using simple test. Any direction will be greatly appreciated thanks.

/**
 * @file
 * Definition of creation of a entity.
 */

/**
 * Coded entity display test.
 */
class CreateCoded extends DrupalWebTestCase {

  /**
   * Implements getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => 'Coded',
      'description' => 'Adding table to entities to create entity',
      'group' => 'Coded',
    );
  }

  /**
   * Enables modules that are need for test.
   */
  public function setUp() {
    // Enable any module that you will need in your tests.
    parent::setUp('coded');
  }

  /**
   * Tests for table coded.
   *
   * @Description
   *   Method needs to start with test if you wnat to test.
   */
  public function testCreateCodedEntity() {
    // how to I test the entity

  }
}


texts:
I am trying to pre-populate a webform based on the values from a third party service.

I am using form_alter to start the processing and then using a recursive function to traverse the tree. I am passing the sub-form(part of a form of type fieldset) by reference, so that changes do carry forward.

Here is the code :

function my_module_form_alter(&$form, &$form_state, $form_id) {
    $submitted = $form['submitted'];
    prepopulate_form($submitted, $value_array);
}

function prepopulate_form(&$form, $value_array) {
  foreach ($form as $key => $settings) {
    if (is_array($settings) && isset($settings['#type'])) {
      if ($settings['#type'] == 'fieldset') {
        prepopulate_form($form[$key], $value_array);
      }
      $value = 'Some logic to get the value from value arrya';
        dpm($value); // I am getting the expected output here.
        $form[$key]['#default_value'] = $value; // The changes I make here are not being carried to the actual $form array I suppose
    }
  }
}

But the form is not getting pre-populated. I am not sure what I am missing here.

Any insights would help. Thanks !


texts: Simple views handler to compute math expression.

texts:
In Views, I would like to expose a fake field that is just an elementary mathematical expression of other fields of the table (let's say, for example, field1+field2).

I expose the field in hook_vies_data via some

  $data['my_table']['fake_field'] = array(
   'field' => array(
     'handler' => 'views_handler_my_handler',
  );

Which function of the handler shall I define? And how do I get in the handler the two values of field1 and field2?

Alternatively, where do I found the documentation of what I am looking for?


texts: Need to add custom element in sitemap.xml file

texts:
I have installed sitmap module to create sitemap.xml file.
Now I want to add some custom element like

<expires>2010-10-10</expires>

for some URLS.


texts: Add block to form (before submit button)

texts:
I'm having problems placing a block in my form. This is what I have now:

I have a register form and a fb button block. I say the block must be visible only when page is equal to user register page.

But the problem is that I don't want to have the form and underneath the block. I would like to add the block before the submit button of my form. How can I do this?


texts:
I m using Conditional Fields for Drupal 7 to create country state relational dropdown in my Field Collection module, but it is not working properly.

I created Country US and Canada and, depending upon those, US States and Canadian States; I created the relation, but in the front end all the drop-downs are shown.

Can anyone suggest me what I am doing wrong? If this module does not work, how do I create a country state relational dropdown in my Field Collection?


texts: Adding tool tips to menu items and views

texts: I need to add tool tips to some of the primary links in my menus, and also to a link in a view, I tried to use the Tool Tips module, but it doesn't seem to be designed for this kind of use... is there another module I can use, or is there another way I can integrate tips to my dynamic content?


texts: How to get exposed filter dropdown option selected value in drupal hook

texts:
I'm trying to get exposed filter selected value in hook_form_alter().

myModule_form_alter(&$form, $form_state, $form_id) {
     if ($form['#id'] == 'views-exposed-form-view-id-display-id'){
          var_dump($form['exposed_element']['#options']);
     }
}

i tried with also

$form['exposed_element']['values'],
$form['values']['exposed_element']
$form['exposed_element']

But none of them giving me selected option value.

Any help/suggestion would be greatly appreciated.

EDIT

For more clarification

function myModule_form_alter(&$form, $form_state, $form_id) {
    switch ($form_id) {
        case 'views_exposed_form':
            switch($form['#id'])
            {
                case 'views-exposed-form-soldproduct-page-1':
                       var_dump($form['exposed_element']['#options']);
                break;
            }
        break;
    }
}

Where soldproduct is my view name and page-1 is the view display id.


texts: When I buy a product and continue as guest, I get a random email. How can I remove it and keep it empty?

texts:
When I buy a product and continue as guest, I get a random email.

I suspected it is coming from the anonymous user email (which might have been added), but when I checked the database, the anonymous user doesn't have any email.
How can I remove it and keep it empty?
I am using Drupal Commerce 8.x-2.20.


texts: Show Taxonomy Terms with Depth to Create Main Menu Dynamically

texts: I'm using views to create pages based on taxonomy terms and their child terms. I'd like to create a menu based on that output but don't know where to begin.


texts: views filter autocomplete not working without taxonomy value

texts:
I have created a view with contextual filter taxonomy :-> display all when value not available. and an exposed filter content title with auto complete widget.
my view and exposed filter is working fine when i pass a taxonomy in url but i does not work without taxonomy.

any one know this problem?


texts: Importing XML feed returns only the first value

texts:
I am trying to import xml feed to custom content type and one of my XPath queries has multiple values being returned but only the first one gets posted to the node.

the XPath query follows:

itinerary/itinerary/item/item/description/node()1

Any ideas why only the first items gets posted? I've tried to run this query in XPath checkers and brings back the values fine. Also if I turn on the debugger on parser it brings back values as well. They just don't get posted on the node.

Thanks,
Dom


texts: What's the difference between the components ending in .system and .module in the Bug tracking system?

texts:
I am a phd student focus on automated testing of complex systems and I selected the Drupal system as a case study.
First, I need to examine the bugs recorded for a number of modules in Drupal. Thus, I looked in the issues of each module, e.g. File module https://drupal.org/project/issues/drupal?text=&status=All&priorities=All&categories=1&version=All&component=file.module . But, I noticed that there exist file.module and file.system components in the issues for Drupal. And, this happens with most of Drupal modules. Thus, my question is what is the difference between file.module and file.system in the issues. I need to recorded the bugs associated to each module, so I do not know if a need to consider the bugs of .system components or .module components or both.

Thanks in advance,
Best


texts: Adding form placeholders to text input fields

texts: Is there a way to convert a regular form and add placeholders with a module, or should this be done with a form template or with jQuery?


texts:
I do have nodes with the same title however they are designed for different countries -smart ip.
So someone is Russia will see Apple is great node id 12 jjdesigned for Russia that is different from someone seeing same Apple is great node id 14 designed for  America.
But when I search I see the content twice, is it possible to display just one based on ip??


texts: Translated content not accessible / wrong links

texts:
At the moment I am working on a multilingual page (German/English). I finished adding my German content, and want to add my English version, so I can access it like examplesite.com/examplepage (German) --> examplesite.com/en/examplepage (English).

The steps I did so far:

I enabled the right custom language settings for translation
I added the needed pathauto-patterns
added a path-prefix-configuration for English "en"

My problem now is the fact, that I can't access these pages after adding the translations.

This means when I access a German site in the front end, and click the language switch to the English version, it won't link me to the translated content but only refreshes the page.

The same weird behaviour is shown in the backend on the content-overview page. The translated pages all exist in the list and if I hover over the title it will show me the right URL like e.g. examplesite.com/en/examplepage but when I open the url it will just show me a 404. It seems that the content is not connected to the right, translated urls.

Am I missing something?


texts: Field or View for selecting images attached to another selected node

texts:
I have a content type of 'property' and have multiple file fields for attaching images.

I have a content type of 'flyer' where I have an entity reference field to select a property. I have this working. Next I need to display the files attached to that property and select one to be used in my 'flyer' content type. So selecting a new property in the select list should update my image choices.

I think this can be done with some combination of views contextual filters and relationships, but I don't understand it enough to get all the right pieces into the right places if it is indeed possible.

Do I need to create a custom module for a new field type or can this be done with what I've mentioned and if so please guide me how?