texts:
I have a module that adds functionality to the front-end. The feature can be turned on or off via the configuration page of the module.

I pass the settings to the frontend in the HTML preprocess function using #attached. Simplified, the code looks like this:

function my_module_preprocess_html(&$variables) {
  $config = \Drupal::config('my_module.settings');
  $settings = ['enabled' => $config->get('enabled')];
  $variables['#attached']['drupalSettings']['my_module'] = $settings;
}

This approach is suggested here:

https://docs.acquia.com/tutorials/fast-track-drupal-8-coding/add-custom-variable-drupalsettings/

It works fine when logged in, but for anonymous users changing the setting from the module's configuration page does nothing until I clear caches (as, I assume, the drupalSettings variable is defined within the HTML that makes up the page)

So, my question:

Is there a way to ensure the settings are fresh with each page load (without disabling the entire page cache, of course), or
Should I refresh the cache whenever the module's configuration form is submitted? If so, what's the most efficient way to do that? (I've noticed a full cache clear is far slower on D8 than it was in D7)


texts: Is it possible to load different versions of the same module?

texts:
I am running Drupal 6, in a multisite installation. While I fully understand the problems with having varying versions of the same modules running concurrently, I guess I want to know if there's a way to match a specified version of one module to only process requests, or handle calls made by another module?

I currently have Views 2.x in sites/all/modules. It doesn't work w/ Views Slideshow: Cycle 3.x. I want a way to also have Views 3.x in sites/www.mysite.com/modules, and force it to only process requests that would normally be made by Views Slideshow: Cycle 3.x - but nothing else, as Views 2.x would pick up the rest.

I sort of envision it in the same way Blocks work - where you may have regular expression matching for specified URLS. Thanks for any help in advance.


texts:
I am an experienced programmer in various languages, and also have experience with web development. I am new to Drupal, and as with any new platform there is sometimes a language barrier. I've read drupals small documentation on theming on their site, but I just want to make sure I'm wrapping my head around this correctly.

The way I understand it, a theme in Drupal is a site's skeleton, the basic HTML and CSS. If that's true then I at least have that part right. Where I'm losing it is where does the theme stop, and web design/content development start? For example, what exactly should I expect when I download a Drupal theme/template, should I be editing the theme directly to add my images and text, or is there specially created modules for that I'm just not seeing? Is it common practice to sub theme or just edit the theme directly?


texts: adding media content to a Drupal Commons Group page header?

texts:
I've been playing with Drupal for a bit, and have gotten used to the idea of Content and fields.  I am now trying to use Drupal Commons 7 to up my game some and improve how my site looks.  Im a bit stumped however on how I can edit the look of my Group page.  Id like to add a big image at the top, before the group content.  I think this is done using panelizer but Im not sure.

First is this right?  Second, if so, where can I look for getting started tutorial type stuff that explains panelizer and how it works with the underlying field system?  Do I have to add a field to content somewhere?  If so, what and where?

Thanks


texts:
I have a controller that generates a custom 500 page.  I have set up a route at the path: '/500'.  I would like to capture this as HTML and save as a static file, so that I don't need to bootstrap Drupal and run that controller when I return a custom 500 page.

I have been using this code:

  global $base_url;

  $contents = file_get_contents($base_url . "/500");

This works for me locally, but we have a lot of restrictions on our QA site so that file_get_contents is blocked.

Is there another way to render the entire page that this controller would return?  For example, with the render service?

Also, I would want it in a logged-out context.  I wouldn't want the admin toolbars, etc. to show up.

I found some code about subroutines.  Is that a good way?  I'm sure there's a way to use the Drupal render service to render a render array with the entire page.  That sounds maybe the best way to do this?

Does anyone know how I might render the entire page programmatically?

I'm thinking in order to render the metadata and page classes based on a route, you're pretty much required to make a request.

There is another question about rendering parts of the page, but not the entire page.


texts: Use a content type's field as a pager item in Views

texts:
I'm creating a very custom slideshow with views. It has a content type that has a photo field, some text fields and a thumbnail field. I would like to have my thumbnail field set as the pager items.

I've been messing around with the Views Slideshow plugin, however I don't think it will work in my case because I have my thumbnail's wrapped in a image carousel.

I've been doing some searching and can't find any code/module/example of how to do this.

Alternatively, maybe I could print the field value in the custom page template (outside of the node)?

Any thoughts? I'm using Drupal 7 with the latest version of Views.


texts: How can I programmatically create products via REST?

texts:
I have a module of rest service api, that is used to receive users upload products. Here is my code...

function commerce_services_product_create($data, $flatten_fields) {
    $status =1;
    $commerce_price = array();

    $sku = $data['sku'];
    $title = $data['title'];
    $type = $data['type'];
    $commerce_price = $data['commerce_price'];
    $price = $commerce_price['amount'];

    $cp = commerce_product_new('product');
    $cp->uid = 1;
    $cp->sku = $sku;
    $cp->title = $title;
    $cp->language = LANGUAGE_NONE;

    $cp->commerce_price = array(
        LANGUAGE_NONE => array(
            0 => array(
                'amount' => $price ,
                'currency_code' => 'MMK',
     )));

    // for store
    $cp -> cmp_store = array(LANGUAGE_NONE => $data["cmp_store"]);
    // for category
    $cp->field_category[LANGUAGE_NONE][0]['value'] = 137;

    try{
        commerce_product_save($cp);
        $result = "success!";
    }catch(Exception $ex){
        $result = "not success!, error -> ". $ex;
    }
}

When I pass the following json string to the function, this function create a product but not include cmp_store, mean cmp_store is null.

{
  "sku": "saa_prduct120",
  "title": "saa_prduct",
  "type": "product",
  "commerce_price": {
    "amount": "150000",
    "currency_code": "USD"
  },
 "cmp_store": 2
}

And when I check store drop down button with themer info module, it shows #name as like this, "field_product[und][form][cmp_store][und]".

Above my code I use this code for adding store, mean when users upload their product, they have to choose store. User choose store is passed by json.

 // for adding store
 $cp -> cmp_store = array(LANGUAGE_NONE => $data["cmp_store"]);

And I also try like this,

$new_product ->field_data_cmp_store[LANGUAGE_NONE]['cmp_store']['und'] = $data["cmp_store"];
$new_product -> field_product[cmp_store][und] = $data["cmp_store"];
$new_product -> cmp_store = $data["cmp_store"];
$form_state['values']['cmp_store']['und'] =   $data["cmp_store"];

not ok yet!


texts: How to render HTML output in hook_ENTITY_TYPE_presave()

texts:
Upon node save, I want to take the value of a text field that uses a custom input filter and save the HTML-ified final version (what the input filter renders) in a second field.

I have two text fields:

Field text_main (which is never actually displayed, avoiding the performance penalty of rendering the field)
Field text_main_display (which is displayed publicly)

The field text_main uses a custom input filter that is very slow to run.  So, I want to get the rendered output of the field after running the input filter and save it to the field text_main_display.

/**
 * Implements hook_ENTITY_TYPE_presave()
 */
function MYMODULE_node_presave(NodeInterface $entity) {
  switch ($entity->getType()) {
    case 'custom_page':
      $processedResult = $entity->get('field_text_main')->view('custom_display');
      // $processedResult is now a render array. How do I render this to HTML?
      $entity->set('field_text_main_display', $processedResult);
      break;
  }
}

Reference: This post on how to render Drupal 8 fields


texts:
I installed the Field as Block plugin without problems, but when I go to Structure > Content Types > Basic Page > Manage Display, I still don't see the "Display as block" checkbox.

I tried googling but did not find anything else that what was written on the plugin page. What am I doing wrong? This plugin would really help me.


texts: How to determine which element has called (triggered) the AJAX callback function?

texts:
For example:

/** FIRST FIELDSET **/

$form['fieldset_1']['enabled'] = array(
  '#type'        => 'radios',
  '#options'     => array(1 => t('Enable'),
                          0 => t('Desable'),
                          ),
  '#ajax'    => array('callback' => 'my_ajax_callback',
                      'wrapper'  => 'my_wrapper_1',
                     ),
);

$form['fieldset_1']['myChangebleField'] = array(
  '#type'   => 'whatever',
  '#prefix' => '
',
  '#suffix' => '
',
);

/** SECOND FIELDSET **/

$form['fieldset_2']['enabled'] = array(
  '#type'        => 'radios',
  '#options'     => array(1 => t('Enable'),
                          0 => t('Desable'),
                          ),
  // Now I am calling the same callback function but assigning a different wrapper
  '#ajax'    => array('callback' => 'my_ajax_callback',
                      'wrapper'  => 'my_wrapper_2',
                     ),
);

$form['fieldset_2']['myChangebleField'] = array(
  '#type'   => 'whatever',
  '#prefix' => '
',
  '#suffix' => '
',
);

function my_ajax_callback($form, $form_state) {

/**
 *  How do I figure out which of the element "enabled" was the caller?
 *
 *  In that way I could do something like:
 **/
   switch($caller){
     case 'fieldset_1':
       // do stuff...
       break;
     case 'fieldset_2':
       // do stuff...
       break;
     // ...
   }

   return $form[$fieldset]['myChangebleField']
}

As seen in the example above, how do I figure out which of the element "enabled" was the caller?

Having two callback functions is not an option as the form elements will be constructed in a dynamic way and I won't actually use a switch statement in the callback function as shown in the example.

Cheers,


texts: How can webform performance be improved on low internet connection?

texts:
I built a site with Drupal 9 and webform.
The form consists of three pages and contains a few computed fields.
On the first page are mandatory fields.
The form is used by logged-in users only.
When on a machine with a normal/fast internet connection, everything is fine.
When on a machine (smartphone) with a slow internet connection (or on Low-end mobile in Chromium's developer tools), I can enter all information on the first page, press next, it loads the second page and jumps back to the first one, claiming that the mandatory fields were empty.
Is there something that should be cached and that I missed so far? Do I have to manipulate some timeouts (where are they, I didn't find them)?


texts:
I am building a site with main-menu at header and side-bar-menu. For each main-menu entry there will be some sub-menus. And same sub-menu will be displayed into side-bar-menu according to the portal we are in. Is it any way (or module) to synchronized main-menu->sub-menu and side-bar-menu so that in case we need to change menu, we can change it in one place and reflects in main-menu and side-bar-menu.

Thank you.


texts:
I have a content type with a field 'field_departimage' which uses entity reference to reference a taxonomy I have set up which holds the name and image.

I would like to filter by the taxonomy 'name' in views but I'm having some issues linking them

I am able to display the taxonomy but they don't seem to be linking to node to filter correctly. I'm probably doing something wrong with the contextual filters or in the relationships section.


texts:
I'd like to print (in Views - custom/PHP field) random part of body of a node, as a kind of teaser, different with every print.

Any ideas? Thanks! :]

Szy.


texts: Why does drupal_set_message not appear in the message area?

texts:
I often use something like drupal_set_message( krumo( $row ) ); to output debug information. This is suppose to output that message within the $message area placed via the page.tpl file, however sometimes this is output in line where the code is suppose to be rendering (via a field template.)

Is there any way to make drupal_set_message output to the right place when being used in the the theme layer?


texts:
I'm writing a field formatter and I need to override the default field formatting. I've already implemented themes for the items itself, but I can't get my theme to work for the field container.

I've set #theme in the following code, and my field-image.html.twig is found by Drupal and processed:

class ImageGalleryFormatter extends ImageFormatter {

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items) {
    $elements = parent::viewElements($items);
    foreach ($elements as &$element) {
      $element['#theme'] = 'imagegallery_format';
    }
    $elements['#theme'] = 'field_image';
    $elements['#attached']['library'][] = 'imagegallery_formatter/light-gallery';
    return $elements;
  }

}

But it doesn't actually work correctly, I don't get any content for {{ item.content }}. This is the core of my field-image.html.twig:

{% for item in items %}
   <div>{{ item.content }}</div>
{% endfor %}

I suspect that I didn't implement hook_theme() correctly, I tried a few variants, but none worked.

function imagegallery_formatter_theme() {
  return array(
    'imagegallery_format' => array(
      'variables' => array('item' => NULL, 'item_attributes' => NULL, 'url' => NULL, 'image_style' => NULL),
    ),
    'igimage' => array(
    'variables' => array(
        'style_name' => NULL,
        'uri' => NULL,
        'width' => NULL,
        'height' => NULL,
        'alt' => '',
        'title' => NULL,
        'attributes' => array(),
      ),),
      'field_image' => array(
        'render element' => 'element',),
  );
}

The first two themes work, for those I simply copied the variables array from existing code. The third one doesn't work, and I couldn't find any existing code I could use as a template. I tried to define the variables instead of using 'render element', but I don't know how to define the items variable there. I tried setting it to NULL or an empty array, but nothing did work. When I put a variables array in hook_theme, I get simply four empty divs, with the render element array I get a single empty div.

What am I doing wrong here, and how do I override this theme correctly in my module?


texts:
I'm using Panelizer to panelize nodes of a specific content. This content type is used so that content editors on the website can easily edit (with the help of Panels IPE) the content of pages which all have unique custom layouts (ie. different sets of panels panes at different positions).

To ease deployments, I"m looking for a way export panelized nodes from the development (local) site to the validation and production sites in a non-interactive fashion. Import/Export of nodes themselves is not the issue here, there is several solutions. But, AFAIK, none of them handle the panelizer part. The solutions to use will likely depend on the exact how to export/import the panelizer part of the panelized nodes and how it can be integrated in an automated workflow.

So far, for a panelized $node, I've found the following

// Export the panelized entity information
ctools_export_crud_export('panelizer_entity', $node->panelizer['page_manager']);
// Export the panel display of the entity
ctools_export_crud_export('panels_diplay', $node->panelizer['page_manager']->display);


texts:
I have a little problem and I have no idea what is going on.

I have a block in my footer that is only displaying say 100 characters. Then it just gets cut off. Yet on my old server the entire block got displayed. The only difference is PHP version.

Is there something that I can look at that would cause a block to only partially render?


texts: What's the fastest method/implementation for an Ajax callback?

texts:
I have a map which loads markers via ajax on various/numerous map events. Currently, I define a custom page callback for my hook_menu() item which prints my json/js.

Since my page callback does not return any content and only prints content, Drupal does not render the full template, menu, etc, and thus allows me to return a page with only my JavaScript.

Although this does work, I believe that Drupal still fully bootstrapping, which means it is adding a lot of overhead I would like to drop.

I've been looking at High-performance JavaScript callback handler, which boasts itself as a "High-performance JavaScript callback handler" and which, in short, looks as though it offers a js.php to compliment index.php to direct your requests to and customize/limit/optimize the bootstrapping Drupal does by default.

Unfortunately the js project doesn't have a D7 release yet (petition for one here), which leads us to the beginning...

What is the fastest way to implement an Ajax callback in Drupal?


texts: Build a dynamic form based on user input

texts:
I am looking on how to build a dynamic form in Drupal 6.
Users enter the number of people attended the meeting, and the form should present a text box for each of the people attending the meeting, and containing the contact information. I would love to use webforms to do this.

What would you suggest as best way to do this?


texts:
I logged in as admin. I opened the css configuration page. I clicked edit rules page. After that, css edit rules page should open but my site is stuck at screen 2(home page). After I click edit rules many times, sometimes, I get the edit rules page. I feel that this is a site wide issue not css injector issue.

Example: If I click Save on views page, it does save but my page gets stuck at the home page. I have to hit the back button to come back to view and I see that views is already saved.

If I click clear cache in performance page, I have similar issue. It does clear the cache but the site is stuck at home page. I hit back button to come back to performance page again.

I simply do not know where to start troubleshooting. I am not getting any error messages. If you could point me to right direction to solve this issue, it would be very helpful.

enter image description here

Screen2:


texts: Why does drush say "command not found" when I try to execute remote commands?

texts:
When I use a drush command to do something on a remote machine, I get the following message:

  bash: drush: command not found

What's the problem?


texts:
I have:

a view which displays three pictures of 300 * 200 each
it should be responsive at breaks of 300 and 600
adaptive themes

1) I installed responsive grid view. In here I need to add a wrapper – but I don't know which one or what to create. Is there already a wrapper in the adaptive theme for this?

2) Also I generated a css file at gridpack.com. This css file I added to the theme and I replaced:

.col with the views-responsive-grid label (css is in the page)
.col with .views-column (the css is in the page)
.row with .views-row (I can't see this back in the page)

It still doesn't work. Still on the big screen all images are display vertically. Is this the way it should work or there any other suggestions?


texts: determine custom templates in custom module hook_preprocess_page function

texts:
I'd like to create a module that use a set of custom templates depending on http status code

Very well inspired by
Custom template for 404 error pages

Here is where i am so far

function my_module_preprocess_page(&$vars) {
  $header = drupal_get_http_header('status');
    if ($header == '404 Not Found') {
      //this
      $vars['template_files'][] = 'page__404';
      //or that
      $vars['theme_hook_suggestions'][] = 'page__404';
    }
}

in my module templates folder , i have created a

page--404.tpl.php

this template is not overtaken !?

EDIT :
i have also tried what's in there

function my_module_preprocess_page(&$vars) {
$header = drupal_get_http_header('status');
if ($header == '404 Not Found') {
  $vars['theme_hook_suggestions'][] = 'page__404';
}
}

function my_module_theme() {
  return array(
    'page__404' => array(
      'template' => 'page__404',
      'variables' => array('xxx' => null),
      'path' => drupal_get_path('module', 'my_module')
    ),
  );
}


texts: View of taxonomies connected to view of each taxonomy

texts:
I'm creating a store using Drupal commerce and I'm trying to show a catalog of products.

First I create taxonomy of product types
Then I use taxonomy to create a view of product types(product type
view) and I'm showing taxonomies image
Then I add a taxonomy reference field to product contents

I want to show all products of a type every time I click on a taxonomy in product type catalog view.

Can anyone help me?


texts: How to test Drupal distributions and see examples

texts:
Is there a way to see Drupal distributions already installed for testing as demo sites? I was searching drupal.org, where I only found 'case studies'. Sites there are sorted only by categories, not by used distributions, so it is difficult to check every site to find it out.

I want to use and feel distributions before installing them. It would be perfect if link to the demo site would be included in distribution description.


texts:
I would like to show a message when content has changed moderation states from review to published. I set this up below but it does not work. Is there a rules debug log in Drupal 8?

Event:  When content is update.

Condition: Data Comparison.

node.moderation_state
Operator: ==
data value: published

Action: Send System message, with

The message type
drupal_get_message(‘status’);

But this doesn’t work. I get this error:

  error   php  InvalidArgumentException: Cannot set a list with a non-array value. in Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue() (line 59 of /var/www/html/d815/core/lib/Drupal/Core/TypedD


texts: How do I programmatically change contextual filters?

texts:
Basing on a blog post, I wrote the following code.

/**
 * Implements hook_views_pre_view().
 */
function mm_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
  if ($view->id() != 'product_listing' && $display_id != 'page') {
    return;
  }

  $tid = reset($args);

  if (! $tid) {
    return;
  }

  $term = Term::load($tid);
  $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')
    ->loadTree($term->getVocabularyId(), $tid);

  foreach($terms as $child_term) {
    $args[] = $child_term->tid;
  }

}

I cleared the cache, but the code I wrote doesn't have any effect. The SQL query is not altered; only single taxonomy ID is returned. I have selected Allow multiple values for the filter.

What is wrong with the code? How can I fix it?


texts:
My main navigation menu is visually split as in the picture:

Level 1 is visualised in the upper-right corner, level 2 below.

Technology (like all the current items in level 2) is child of About.

In the screenshot, Technology has been assigned the class is-active. Is there a way to also assign it to About? In other words, I would like the entire active branch of the menu to be displayed as active.


texts:
How do I modify the text on a breadcrumb?

Is there a way to hook this generically so that I can change the text of any breadcrumb that is shown, regardless of the page?


texts: How can I load a taxonomy term into a views preprocessing hook?

texts: I have a strange situation where I need to insert a non-product entity into a view result of products. The view appears on a taxonomy term page, and I want to add some field content from the term into the view result. I can get the term ID from the view in a template_preprocess_views_view hook, but I can't load it with something like $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid); to get the field content. I guess I'm wondering if this is the right way to do this, it's sort of an unusual requirement in my experience.


texts: When I load an overlay to edit a node, how can I open a specific vertical tab?

texts:
I have a content type with field collections. I want to open an overlay to edit a node but switch to a tab for a specific field collection. Does anyone know how I can do this?

I can open the overlay with #overlay=node/16/edit, but this will just go to the first vertical tab.


texts:
I'm creating a new content type named "Portfolio".

Image 1: I put a name to the "Title field label": Project Name

Image 2: That thing works as a 'Node module element' in Fields

Image 3: I can't get the Field to sort it below the Project Image

I even can't get this 'Node module element' from Views (using Views module). The sorting problem is specific to "Teasers" in the portfolio page:

I just want the Project Title to sort a bit so that I can place the title just after the Project Image. I'm familiar with WordPress, but a newbie in Drupal.


texts: How can I update content automatically every X hours?

texts:
I have a content type that I want updated every five hours. When some nodes haven't been updated, the I'd like to alert a content admin with a warning message containing the list of nodes that have not been updated, e.g. :

  [node:title] has not been updated! please update

The nodes can also be displayed in a block


texts: Should I just paste the code in the main template file, or is there any other recommended way of attaching new Jquery plugins in Drupal 7?


texts: How to use wildcard search in apache solr search module?

texts:
I am working on apachesolr search module.

I want to implement wildcard search I have used hook_apachesolr_query_prepare() function to modify apachesolr query but it is not working can any one give me solution.
I have implemented code like this.

I have taken reference from here : https://www.drupal.org/project/apachesolr/issues/1539284

function custommodule_apachesolr_query_prepare(DrupalSolrQueryInterface &$query, &$caller) {

  $search = '';
  $keywords = preg_split("/[\s,]+/", $query->getParam('q'));

  foreach ($keywords as $keyword) {
    $search .= '*' . strtolower($keyword) . '* ';
  }

  $query->addParam('defType', 'edismax');
  $query->replaceParam('q', $search);

}

ENV: Drupal 7.60 | Solr 3.X


texts: Views, find content types with field NOT IN other content type

texts:
Content Type A
-Nid A
-Field A

Content Type B
-Nid B
-Reference Nid A

How can I find in a view all As that have no reference in B ?

in sql this is

select A.field
FROM TABLE A
LEFT JOIN TABLE B
ON A.KEY = B.KEY
WHERE B.key IS NULL

I have tried Views reference filter, but it is very slow and consume a lot of memory (the trick with this modules is not a join but a SELECT... NOT IN (...).

Which is very inefficient, because, i have 16.000 As and 14.000 Bs.

Is there any efficient solutions with views?

Thanks.


texts: How is a field's value (rather than its key) obtained?

texts:
In Drupal 7, I have a page content type that has a field called group (so the machine name is field_group).  The field is a List (integer) field type.

This field might have allowed values as follows:

0|Description 1
1|Description 2
2|Description 3

If I want to return the key of this field for the current page, the following code correctly works:

field_get_items('node', $node, 'field_group')[0]['value']

If the key were set to 1 for this page, the above code would return 1.

However, is there a way to instead return the associated value (e.g., "Description 1," "Description 2," etc.)?

I thought I had a way to return the value already, but I was told yesterday that my previous method was not a good way to get the value (or key) because my previous method may return extraneous data (such as unwanted HTML), when I really just want the raw key/value itself: How is a field's key (rather than value) obtained?


texts: The login doesn't show a username anymore

texts:
I can't login into my Drupal anymore and I'm not sure why.
I've got the BOTCHA Spam Prevention module and commerce (enabled with anonymous checkout).
Now my login looks like this:

I can't create a new user:
"the field username is required"
and I can't request my password (there is no username/email field).

I repaired the session table already. Tried several browsers and computers and the admin account has the User ID 1.

Don't know how I can get back into my Drupal :-S
Any ideas?

Thanks,
Chris


texts: How to style a byline field in an article content type?

texts:
There might be a simple answer to this but it's driving me crazy. I'm working on a template for an article node and I want the byline to display this way:

  By Author Name

I don't want to change the field label in the web form, so I just want the "By" to be inserted through the node template. No matter what CSS styling I use, the byline field always displays like this:

  By
  Author Name

Is there a way to get the label and field to show up inline?

Here's the PHP I'm using in the template:

<div class="newsbyline">
  <?php print t('By'); ?> <?php print render($content['field_newsbyline']); ?>
</div>

Setting the "newsbyline" <div> to inline doesn't seem to be working.


texts: Best way for including javascript/jQuery OnLoad in EVERY page on my site

texts:
Currently, in my theme.info file I am including 2 scripts:

scripts[] = js/backstretch.js
scripts[] = js/scripts.js

Backstretch is a jQuery plugin that allows for an expanding background image to cover your entire page.

I am currently using this code to autoload the JS:

(function ($) {

    var bgs=["bg1.jpg", "bg2.jpg"];
    var bgr=Math.floor(bgs.length * Math.random());
    $.backstretch(bgs[bgr], { speed: 1000 });

})(jQuery);

Two issues:

Sometimes it doesn't load the backstretch.js properly which may have something to do with my current OnLoad function in scripts.js. It loads the image but not maximum width/height of the browser initially.
For some reason, it doesn't work past 1 level in the site (although the JS seems to load when I check the site (could it be that the location of images is not relative of the JS file?) e.g.,:

  Works: site.com, site.com/page

  Doesn't Work: site.com/dir/page, site.com/dir/dir/page

I was wondering in my scripts file what would be the best OnPageLoad (or Preload?) function would be best to use?

Many thanks in advance.


texts: Is it possible to add unlimited values as a group of fields?

texts:
Imagine I have a content type that asks you to list your friends.  The 2 fields are:

| first name |

| last name  |

Is there a way a user could add unlimited friends for both fields (i.e. first and last name) as a set?  Right now Drupal is not smart enough and only let's me add unlimited first names or unlimited last names.  In other words, they are not paired together.

If any of you have used Sharepoint, then you will know what I mean.  In Sharepoint you can easily hit the "add another" link and it would create a new set of first name and last name fields that stick together as a group.  You do not want to separate the first and last name fields.


texts:
So I have created a drupal multisite install with a shared user database and I would like to store the site the user has signed up on.

I have also created a view of user and I would like to filter them by site. Ideally I would like the view filter to be a dropdown, but it isn't essential.

I am already overriding the user_register_form via the template.php file, would it best to create a new text field for the user then hide and set it to the current domain via the template.php file?


texts:
What should be considered the optimal way of creating a custom field in views?

For example:

if($content_type == 'article'){
  print 'something';
}
else{
  print 'something else';
}

I either create a Custom Text field and write my php code in its template, or, lately, I've started using views_php field.

The disadvantage with the templates is that if your site is kinda big, you end up with tons of template files that are sometimes hard to manage, and also (obviously) cannot be managed from someone without server access. Furthermore it cannot support sorting/filtering of some kind.
Apart from that, it's "fail safe", it's robust, it doesn't add to complexity via an extra module.

The (possible) disadvantage of the php field is that it's an extra layer of complexity to the site and thus an extra bug possibility.
Apart from that, it's easily manageable and it can even be used for filtering/sorting!

So, what would you guys suggest? What do you usually do in such cases?


texts:
I added a pager to a site I'm working on and the URL for a page comes out to: http://example.com/blog/0%2C0%2C0%2C0%2C0%2C5 which is an encoded version of */0,0,0,0,0,5. However, I'd like the URL to be http://example.com/blog/5 or similar.

I'm using Drupal 7.31 and have clean URLs enabled.


texts: Disable Internal Page Cache And Enable Dynamic Page Caching

texts:
Can some one let me know how to disable internal page cache and enable dynamic page cache. And also how to enable and configure varnish or memcache in drupal.
Can we enable and use both varnish and memcache ?
Does enabling of varnish or memcache will disable drupal's default dynamic page caching ?


texts: Rendering fields with node display settings

texts:
I would like to take advantage of the settings I can set under admin/structure/types/manage/node_type/display when i render my custom fields in node--node_type.tpl.php but using the following code I just get some sort of default display setting:

<?php
  print render( field_view_field('node', $node, 'field_date', array('label' => 'hidden')) );
?>

This prints my date in the long format, but under /display I already set it to medium.
Also I have already set the label as hidden under the display settings.

How can I use those settings and only override them if I want to? Or is field_view_field() not the right function?


texts: D7 Rules - Unable to get data value & Unable to evaluate action in custom module

texts:
I am working on a module that gets the order data upon commerce checkout completion and sends it to an api elsewhere for processing. In testing, everything was working fine until I called my method from my rule, which led me here.

I am wondering if my inexperience with Drupal has caused me to make an error in defining my rule. Any additional information that can point me in the appropriate direction is always welcome.

I have researched this topic rather intensely and did not find any solid remedy, please don't assume I have not searched. I assure you I have, I have been stuck on this issue for 4 days now :/  Thanks in advance.

Here is my rule:

function my_module_rules_action_info() {
  $actions = array();
  $actions['my_module_sync_inventory'] = array(
    'label' => t('Sync inventory'),
    'callbacks' => array(
      'execute' => 'my_module_rules_sync_inventory'
    )
  );
  return $actions;
}

and here are the defaults:

function my_module_default_rules_configuration() {
  $rules = array();
  $rule = rules_reaction_rule();
  $rule->label = t('Sync Inventory on Checkout');
  $rule->tags  = array('Commerce Cart', 'Commerce', 'Inventory', 'Sync');
  $rule->weight = 20;
  $rule->active = TRUE;
  $rule
    ->event('commerce_checkout_complete')
    ->action('my_module_sync_inventory');
  $rules['my_module_sync_inventory'] = $rule;
  return $rules;
}

this is the callback

function my_module_rules_sync_inventory() {
  global $user;
  $data = commerce_cart_order_load($user->uid);
  // ... process data
}


texts: Can I add and edit a custom entity from the same URL?

texts:
I am creating a custom entity called user_profile. Each logged in user will have a user profile. I want to be able to add and edit the user_profile entity from the same URL.

The example module provided at

Creating a Content Entity Type in Drupal 8

shows adding and editing with the same form but from different URLs.

I want to be able to create the profile when the profile does not exist and edit the profile when the profile does exist from the same URL like /user/3/my-profile


texts:
So I am new to Drupal and I am trying to create a new theme for a site. I am trying to create a page template for a specific custom content type. Research has led me to adding this to my template.php file:

function yourthemename_preprocess_page(&$vars) {
  if (isset($vars['node']->type)) {
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
}

However, it is not working. I know the template.php file itself is being pickup up because a simple echo test works, but putting one in the function above does not fire. So I have to assume this function is not being called. I changed the 'yourthemename' to what I think is my theme's machine name. The folder name and .info name is FWMurphy. I tried that and fwmurphy and neither worked. I am stumped.


texts: XML Sitemap Last Modified Date on a View

texts:
The site I am working on has a front page gallery view.

Is there any way to update the last modified date of the view in the XMLSitemap file? As currently it is just empty.


texts: How do i ajaxify /Use ajax on Side bar custom menues so that links are loaded to my content div without refreshing page

texts: I have a vertical menu on My site ,I want to use ajax to load the Menu link into the content so the page doesnt have to reload,Please how can i go about it ,I tried the ajaxify module it doesnt seem to work properly.


texts: How to color cards (hearts and diamonds) red in Drupal 7 comments?

texts:
I run a Drupal 7 website with Forum, Blog, Comment core modules enabled and a custom module (generates a block with Flash game and blocks with player rating) written by me.

The website is dedicated to a Russian card game and users often mention card colors in their comments when discussing some card riddle or a game:

Most users are older folks, who don't understand anything like HTML tags, so I have only enabled plain text comments for them.

My quesion is: in the plain text Comments - how to recognize the strings like K♥ or 7♦ and color them red?

The PHP code would be something like:

preg_replace(/(1?[0789JQKA][♥♦])/, '\1', $str);

(I can improve the regex later) - but where/how to apply it in Drupal 7?


texts: Change authoring information on multiple nodes

texts: How can I change the publication date for multiple nodes at the same time without to individually edit each node?


texts: Modify checkbox event on custom line item type to hide show div

texts:
I have a block of custom length fields and a rule to figure them and put the correct total in the cart however I want to hide the div that contains them unless the exact lengths checkbox is checked

however currently this always shows on my test site and from how the site is set up now with a paragraph of instructions and a textbox i've found that people are lazy and don't read directions.  so I don't want to give anyone the opportunity to fill in fields without the checkbox checked

I have tried using JS_Injector to add some js to hide and show but it only seems to be able to add js to the header or footer which doesn't help me add it to the form on the checkbox change event does anyone have any other suggestions short of telling me to write a module with a hook_form_alter()?


texts:
This is my first time using Drupal so I'm not entirely sure if I'm asking the right questions. I come from a WordPress background so I may be approaching this problem in the wrong manner.

I'm attempting to create a list of the latest blog post in a block that I created. How would I go about doing something like this? Would I list it via PHP within the block editor or is there some type of module (?) that I should be using? Any help would be much appreciated.


texts: Editting/Modifying markup of registration form

texts: I would like to over ride the default registration form of Drupal. I want to edit its mark-up. Add few classes and wrap them with few div tags. I don't know how to get this done ? Is it possible to over ride like what we do for html.tpl.php ? I mean copy pasting a particular file some where from system into the template folder and edit it ? Please help me. I am very much new in Drupal.


texts: Hide the email address when searching for users

texts:
When using the Drupal custom search form, and searching for users (search/user), the user's email address is displayed to administrator users. I want to hide it, even to the administrator users.

How can I do this?


texts: D7: $node->created property not available in mytheme_preprocess_block(&$variables) function?

texts:
Hello I need to insert a formated date in a block template: block--delta-blocks--page-title.tpl.php

As I think this can be done using a preprocess function to set the $day, $month, $year variables:

function cybele_preprocess_block(&$variables) {
    $variables['day'] = format_date($node->created, 'custom', 'd' );
  }

But it seems $node->created is not visible here.
It works if I place it in:

function mytheme_preprocess_node(&$vars) {
    $node = $vars['node'];
    $vars['year'] = format_date($node->created, 'custom', 'Y' );
    $vars['month'] = format_date($node->created, 'custom', 'm' );
    $vars['day'] = format_date($node->created, 'custom', 'd' );

}

but not in _preprocess_block function. Can someone help me do that?
Probably I need to declare in mytheme_preprocess_page but the block template won't see from there either.


texts: HTML in square brackets -> output as normal HTML

texts:
We do import (using Feeds_ex) some data into Drupal (we do not control data-source we use to import data) and these data contains HTML in a brackets.

so far I have found these 3 brackets:

 1. [b]bla bla bla[/b]
 2. [i]my text[/i]
 3. [url=http://www.google.com/[/url]

I'm wondering if there is a good approach to deal with these values:

 - Convert them during import?
 - Somehow define in Drupal that these tag are equal to <b>, <i> or <a
   href>?

At the very end I want to output these data as HTML.

I would be happy to get any suggestion.

Thanks.


texts:
I have reviewed other similar posts, but none matches my problem.

I built a Drupal site based on an old ASP.NET site. I imported the users from the old DB (which had passwords in plain text!). Most users have been able to log in fine, using their old username (email addresses) and passwords.

But a few users are having trouble logging in. In some cases they forgot their password from the old site.

So they request a new password on the login page, get the email with the one-time login link, use it to change their password, but they can't login again using the new password.

What I have done to test / fix

tried resetting password myself in a testing account I set up a couple months ago:

got reset password email link
made sure I was logged out on the site
user emailed link  to get into the account
entered new password
logged out and then couldn't log in again with the password I just entered ("Sorry, unrecognized username or password. Have you forgotten your password?")

tried using a different browser, flushed cookies and cache, all to no avail. I cannot seem to login to this account EXCEPT by requesting a password reset email and using the link in that. But if I log out, I cannot log in again.
installed Password Reset Landing Page (https://www.drupal.org/project/prlp). This moved the password resetting to the page you land on from the email link, but it didn't solve the problem.
I also just tried making a different brand new testing account, asking for a password reset, resetting as before. This time it worked. No idea why it works with this new account but not with the other, older testing account. To be clear, the old testing account still doesn't work following the same steps that worked for the new account.
I monitored the user table in the DB. The password is being changed, but system doesn't recognize the newly entered password.

Is there anything I can post here to get help investigating this?


texts: Preventing other sites from embedding Drupal page

texts:
How do I prevent other sites from embedding a page from my Drupal site using an iframe? Ideally, I'd like the parent window to redirect to my website if this happens, or alternatively redirect the iframe to an error page.

Any modules/hacks/code/tips?

Thanks


texts: How to add custom plugin controls to CkEditor

texts:
I have made custom plugin for ckeditor in drupal ckeditor module.
The page where I am displaying CKEDITOR is loaded through AJAX and I am doing a replace div to show the CKEDITOR.
the code for replaceDiv is:

function replaceDiv( div )
{
    if ( editor )
        editor.destroy();

    editor = CKEDITOR.replace( div ,
    {
        toolbar : 'Basic'/*'Basic'*/
    });
}

But, the problem is that in this way I am not getting my custom plugin displayed, I tried adding my control name in the toolbar definition in the array but it seems that I am not doing in the right way since it is not working!


texts:
I want to capture a value from the url and display it in a piece of content, if available.
In my node body I enter text like:

The sid is "[current-page:query:sid]".

If I then view that node at http://example.org/node/123?sid=foo the content shows as:

  The sid is "foo".

Excellent, all working great. Here's the problem: if I visit the page without the ?sid argument in the url (just going to /node/123), then the content displays literally as:

  The sid is "[current-page:query:sid]".

I would prefer the token to just be blank in that case. How can I get it to output

  The sid is "".


texts: Move to Online Mode only one site of two multi sites sharing the same code base

texts:
When I was working on one local site, I used to copy all the folders & files including the "sites" folder into my FTP account in addition to the database in order to have my local site online and be accessible by a specific domain name for example: www.FirstWebsite.com

However, Now I am using multi local sites (Two websites) on my laptop with separated databases, but sharing the same code base...
Which means the code base files for both websites are the same except the following folders which are specific for each website:
C:\DrupalSites\devdesktop\drupal-7.32\sites\FirstWebsite
C:\DrupalSites\devdesktop\drupal-7.32\sites\SecondWebsite

What are the files which I have to upload to my FTP Account in order for example to put only the website name: "Second Website" online ?!

Any help will be highly appreciated,,,
Thank you in advance...
             ---------------------------------------------------------------

Okay, i will rephrase my question...
if you are working locally on one site named "FirstWebsite" and you want to host it online by using one of the hosting server available like for example "HostGator.com", you have only to transfer to the cpanel/file manger all the files and folders of your website .
However, when you want to create LOCALLY another website, you should make a multisite configuration . Whichmeans, all the folders will be used by both websites except the two folders named: "FirstWebsite" (for the existing website) & the "SecondWebsite" (the new folder created for the new website) .
Okay, So let say now we want to host online ONLY the new  website whom all its files are under the "SecondWebsite" Folder without hosting also the existing website whom all its files are under the "FirstWebsite" Folder .
Note: Do not forget that both websites are sharing the same code base.

My question: What folders and files i should transfer to the cpanel/file manager to ONLY host online the new website  whom basically all its files are under the "SecondWebsite" Folder?

Thank you very much for trying to understand my problem even if it is not well explained...


texts: How can I export users, forums and comments to another Drupal site?

texts: I need to move Forums containers and topics and their associated comments and users to another Drupal site.  I am exporting it into an already existing site.  How can I do this?


texts: How can I add multilingual taxonomy breadcrumbs?

texts:
I have a site with two languages and a large number of taxonomy terms.  I want to use breadcrumbs on my taxonomy pages, but I can't find a system that works well with multiple languages.

I translated my taxonomy terms with the Entity Translation module, using the field method.  What can I do?


texts: How can I theme the markup for the labels in a set of radio options on a specific form item?

texts:
Given this form item defined in a custom module;

$form['my_items'] = [
  '#type' => 'radios',
  '#title' => $this->t('Items'),
  '#options' => $optionsSet // array of options pulled from a data source
];

How can I modify the label of each option to include a small image to the right of the text? In my case, the image is stored in the same dataset alongside each label.

I'm going to guess this has something to do with adding a '#theme' attribute, but I haven't been able to determine the entire process for setting that up.


texts: dump $variables in theme_preprocess functions

texts:
In theme_preprocess functions (e.g. theme_preprocess_block, theme_preprocess_menu, etc) there is the $variables argument.

In Drupal 7 I could look at this variable using devel module and typing dpm($variables).

How I can do that in Drupal 8?

I tried kint, dump and var_dump, but for all of them I get a fatal error memory exhausted.


texts:
I am building a website which on the contact page will have a section to find your local sales representive. I intend to do this by having a content type of sales rep with a location field and creating a view from this content on the contact page.

As an improvement to this i would like it to automatically (if the user allows it) to take the geo location of the user and automatically filter the view by this showing the users nearest sales rep.

Are there any modules in existence which i can use to achieve this? Or am I likely to have to build a custom module?


texts:
Faceboock has just released on GitHub their new Hiphop PHP VM, please follow this link:

https://github.com/Facebook/hiphop-php/wiki

Do you know if it is possible to enhance Drupal performance with HipHop PHP VM?

If yes, do you have a good howto, or the different steps to make it work, with a CDN?


texts: Rules condition to check if user is a member of a specific group type?

texts:
I'm trying to create a rule where the condition is that the currently logged in user is a member of a specific type of group. Can anyone offer assistance on the proper data selectors to use to build this condition?

For example, we have three types of groups:

Group Type 1
Group Type 2
Group Type 3

The condition, upon login, should be to check if the logged in user is an active member of Group Type 2.

Thanks in advance.


texts: Fatal error when altering the user login form

texts:
i want to customize login block in a fancy login box.

i used this code in a template.php

function bootstrap_form_user_login_block_alter(&$form, &$form_state, $form_id) {
  $form['name']['#size'] = 30;
  $form['pass']['#size'] = 30;
  $markup = l(t('Forgot your password?'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
  if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
    $markup .= ' ' . l(t('Sign up'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'), 'class' => 'register-link')));
  }
  $markup = '
' . $markup . '
';
  $form['links']['#markup'] = $markup;
  $form['links']['#weight'] = 10000;
}

this code working fine, but on clicking singup link it giving error

  Fatal error: [] operator not supported for strings in C:\xampp\htdocs\drupal\includes\common.inc on line 2445

How do I resolve it?


texts: How do I render the absolute URL of a referenced entity in a simplenews newsletter?

texts:
When I send a node as a simplenews newsletter I use the node's Email: HTML display.
One of the fields in this view is a label of a referenced entity to be rendered as a Link to the referenced entity.
Drupal renders it as a link with a relative / site-local URL. I want it to be rendered as an absolute / external URL.

For what it's worth:
In the render array the link is stored in
$variable['items']['0']['content']['#url'] which is a Drupal\Core\Url with a protected external property of false

I can't see anything in the Url interface that would change external to true or indeed whether this is the thing to do.


texts: Node create progrmatically with multiselect

texts:
I am creating a node progrmatically.

here is my code..

     $node = new stdClass();
      $node->type=$type;
      $node->status = 1;
      $node->uid = $uid;

        foreach($_POST as $field_name=>$field_value) {
          $node->$field_name=array('und'=>array(0=>array('value'=>$field_value)));

        }
node_save($node);

this is working fine. if we have a single value for each field.. Now i have a filed having select box with multiple select. How to save them.

Thanks


texts: I want to add user points whenever user like the page for Facebook. How can I do this?

texts: After sharing or like a page on Facebook I want to add userpoints in Drupal 7, how can I do this?


texts: How to manage acquia website in Lamp environment?

texts:
I know, there is Acquia dev desktop application available for Wamp and Mamp environment.

We have Lamp environment. But, we are not able to clone the website in linux environment.

I want to use the same or other interface for managing the Acquia application for Lamp environment.

Please guide.


texts:
I am displaying a 'Contact Us' entityform in a lightbox (fancybox, specifically).  I need the entityform to send the admin the page that the user was browsing when they decided to contact us.

However, because I am displaying the form in fancybox via an iframe (in order to use drupal's ajax capabilities), my entityform is always loading from its own node - not the one I need to email the admins about.

Ultimately, I need to know how to get arbitrary info into an entityform.  Any thoughts?


texts: Emails are not triggering when MIME mail is selected

texts:
I want to send HTML emails on webfrom submission. Gone through many tutorials as well as Questions on stack but didn't found a proper solution.
I am using three modules to send these HTML mails.

MIME mail,Mail system,SMTP Authentication Support

I had configured all the settings in MAIL system module.
when all the the class are set to MIMEmailsystem_SMTPmailsystem.

Mails are being sent but am not getting "Send e-mail as HTML" option my webform email configuration"

When i am setting "Webform module class" to MIMEmailsystem, "Send e-mail as HTML" is visible but mail are not getting dispatched.


texts: Commerce PayPal commerce_payment_transaction PDOException[23000]

texts:
I'm using commerce paypal to accept payment on a drupal website. i have configured the module as described in drupal commerce support website and created sandbox accounts both for buyer and seller. i created a test order and paid with paypal, the IPN is received successfully and it is verified according to report/dblogs with message:

  IPN validated for Order 2 with ID 7DW624906V374562U.

But after this db log there's another one which is an error with message:

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062
  Duplicate entry '' for key 'name': INSERT INTO {users} (uid, created,
  data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
  :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 13054
  [:db_insert_placeholder_1] => 1396116964 [:db_insert_placeholder_2] =>
  a:1:{s:7:"contact";i:1;} ) in drupal_write_record() (line 7194 of
  /home/findaper/public_html/includes/common.inc).

and type:

  commerce_payment_transaction

So, the payment is validated, but there's this error, and the event "when order first paid in full" is not firing. i have no idea how to fix this. can anyone help me with this??

drupal and all modules are the latest version. [drupal7]


texts:
By debug, these are the suggested names:

 FILE NAME SUGGESTIONS:
   * panels-pane--fieldable-panels-pane-top-hero-content.tpl.php
   x panels-pane--fieldable-panels-pane--uuid-00524104-9c1e-4ee7-a896-270b5d30d935.tpl.php
   * panels-pane--fieldable-panels-pane.tpl.php
   * panels-pane.tpl.php

However, I can't get panels-pane--fieldable-panels-pane-top-hero-content.tpl.php to load.
I copied the file to the next name panels-pane--fieldable-panels-pane--uuid-00524104-9c1e-4ee7-a896-270b5d30d935.tpl.php and it DOES work.

What can be wrong? Both files are in the same directory.


texts:
I have a "view" that return me the JSON fields version (views_datasource is the module I use). One of this fields is a field of type "Long text" where is present 1 token [mytoken] that in the normal node view (node/123) display some images.

In the JSON output of this field I don't want to see the string "[mytoken]" but images. How can I achieve this?


texts: Building a simple render array and rendering it

texts:
I'm trying to render a render array. This render array will be configurable through a UI.

For some reason, I'm unable to render it.

I've isolated the issue so we can replicate it quickly.

Here's the render array:

$render_array = array(
  '#type' => 'html_tag',
  '#tag' => 'h1',
  '#attributes' => array('class' => 'title'),
  'children' => array(
    array(
      '#type' => 'link',
      '#title' => 'Link title',
      '#href' => 'Link URL',
      '#attributes' => array('class' => 'inner'),
    )
  )
);

$html = render($render_array);

debug($html);

The result of this is:

<h1 class="title" />

I tried many possibilities, tested multiple things... but it won't work.

I also searched the API and found this comment and the example in the comment is pretty much the same as mine... but it won't work either.

Is there an easy why to build a complete HTML structure with a render array ?

I could use '#theme' => 'link' but it's not advised, see this thread.

Anyone got a clue ?

Thanks!

Edit1: I opened an issue on Drupal.org which is a workaround to get this fixed.


texts: How to use Rules' "set data value" with image fields?

texts:
I would like to be able to create an entity using Rules, and then populate the image field of the entity with an image file using "set data value".

When populating text fields using "set data value" it is quite straight forward since you can either use tokens or input any text you desire. The trouble is, how do you reference the image that has been uploaded to the server? There is no appropriate token available for it.

What is the best way to achieve this?


texts: Drupal as an interface for users to Add/Edit/Search a database

texts:
I have a friend who wants to set up a site for an NPO that basically allows users to search and edit a data table with about 100 fields. My solution (being from the MS world) would be to set up a simple MVC.Net site which pretty much auto-generates pages and forms for searching and editing rows. The technology the NPO has set up however, is Drupal 7 running on Apache with a MySQL instance floating around in there.

I've searched Drupal modules and poked around with things like Data which seemed fit for constructing a UI that searches and modifies DB tables, but didn't see any way to make it work. This seems like it would be a pretty common problem people want to solve though. Can anyone propose some appropriate tools/modules for setting up such a site?

That's my question, but if you are looking for some additional information about what they're trying to accomplish, here's some relevant details:

The data we want to kick off the site with is about 300 rows in an excel spreadsheet. Something supporting a bulk data import would be preferable, but isn't required. I've already converted the data into an SQL db, so if we can simply point a module to the database, that would be great too.
Most of these are plain text fields, some are numeric, some are paragraph format (with line breaks). Rather than just text boxes for everything though, while editing and searching on certain fields, they want to present the user with a drop-down list of available values.
On the same vein as having drop-down lists for certain fields, forms that supports some customization (such as custom data validation routines) would probably be handy.
I have a grand total of about 10 hours of experience working with Drupal, but I'm comfortable with installing and configuring modules, and have ssh access to the server.


texts: Getting current tid on taxomony/term/{id} without using arg()

texts: From a page based on a url of taxonomy/term/##, how do I properly get the tid (the numeric value in the URL) without using args()? Is using args() a decent way of doing this?


texts: Custom field widget with entity reference

texts:
I have 2 content type. I want content type 2 to contain a custom field that holds the following information in that field:

Text field 1
Text field 2
Entity reference to Content type 1

I declared my hook_field_info() along with the widget_info, formatter info and hook_field_schema.

And used the entityreference_autocomplete contrib (https://www.drupal.org/project/entityreference_autocomplete) for the entityreference field within my widget.

All works well except for the fact that Drupal throws a PDO exception when saving the node that has the custom field.

It tells me that the insert value list does not match column list: 1136 Column count doesn't match value count.

After some debugging, I discovered that the entityreference_autocomplete field is trying to save all params (entity type, bundle, entity_id, ...) to my table.
Where I just want then entity_id that is referenced to be saved (just like entity_reference works by default).

Any ideas on how to fix this?

I wanted to take this approach to avoid using field_collections...

It is also important to note that i will need to build a view based on this custom field's entity reference.

Many thanks in advance

Autocomplete implementation in field widget

    $element['service_category'] = array(
      '#type' => 'entityreference',
      '#title' => t('Service Category'),
      '#era_entity_type' => 'node',
      '#era_bundles' => array('service_category'),
      '#era_cardinality' => 1,
    );


texts:
how to remove empty rows from view(block) ?
I have a created a View block using field collection even empty condition are enabled in the fields settings still im getting empty rows PFA for image 2 in that only view-row-95 has values rest all the view-row are empty .


texts: How to resolve my error in bootstrap.inc?

texts:
I use Drupal 7.38 and I have taken the backup from server side and added in my local server. Then the following error showns up:

  Fatal error: require_once(): Failed opening required

  'D:\xampp\htdocs\kaya/sites/all/modules/commerce_invoice_receipt/commerce_invoice_receipt.admin.inc'

  (include_path='../lib;D:\xampp\htdocs\kaya\sites\all\modules\custom\commerce_citrus\lib;.;D:\xampp\php\PEAR')
  in D:\xampp\htdocs\kaya\includes\bootstrap.inc on line 3186

How can I resolve this error?


texts:
I am having problems making my module work.

module_name.info

...

files[] = module_name.module
files[] = module_name.pages.inc
files[] = module_name.admin.inc
files[] = module_name.install
files[] = module_name.controller.inc

...

But when the module should access to functions stored on module_name.module I get this error, saying the function has not been found.

Warning: call_user_func_array() expects parameter 1 to be a valid callback....not found or invalid function name in call_user_func_array() (line 517 of /path_to_modules/module_name/includes/menu.inc). =>

If I put the functions on the module_name.module file, everything works fine. Apparently is not loading the files[]

Update: I've followed this example:
https://github.com/LearningDrupal7Development/artwork

Any idea?


texts: I have been installing and uninstalling modules on my site and I am starting to run into problems involving re installing previously disabled modules.  The install script is finding old database tables from previous module installations and is refusing to install.  For some of these modules, there is no 'uninstall' option.  Is there a good way to determine which database table are associated with each module?  I'm looking for a method of discovery or an online list.


texts:
I have Subscription webFrom which I need to use it with different products.

Subscription Webfrom will ask  Email and Name to be submitted.

When I click on the product it take to the subscription form where the user enters the name and the email. How do I know to which product the subscription form was submitted. How do I pass the product information to the subscription webform without user having to select the product again or avoid create a same subscription form to each product.

Thanks

B L Praveen


texts: Simplest way to add a custom icon to a Navbar menu item

texts:
The Navbar module comes with some pre-set icons for common uses. They're fixed to the menu item names.

If you want different icons, or, to add icons to custom menu items or menu items provided by 3rd party modules, what's the simplest way that makes these new icons appear on pages using both the admin and main themes?

There's an issue in the Navbar queue for 3rd party module maintainers wanting to support Navbar icons out of the box, but it's not intended for site builders.

The ideal answer would:

Work in both main and admin theme contexts without duplication (so, not just adding CSS to theme)
Not cause the icons to fall off if the wording of their menu item labels is changed - in many organisations CSS styling and site structure will be handled by different people and should be independent of each other (this currently happens to Navbar default icons)


texts: How do I jump to a specific place on a page?

texts:
I wish to be able to jump to a specific place on a given page.

I have inserted  into the text of the page, and set the link to the page to be "about_us/customers/#placetojumpto."

If I type the URL in the address bar it works fine, but when I try use the link generated by Drupal, it converts the "#" to "%2523," so the link becomes "about_us/customers/%2523placetojumpto" and then fails.


texts: My action links on my nodes are not visible

texts: My action links (view, edit, note export, devel)  on my nodes are not visible, i've been working like this for a while ignoring it, but now its becoming kind of annoying. Any ideas?


texts: How do I get the menu block choice "Expand all menu items" to stay checked

texts:
I have 2x menu blocks. One in the header and one in the footer. I'd like the header one to stay unexpanded, but expand all the items in the footer.

When I check "Expand all menu items" in the footer, save the result and come back to the block settings it is unchecked when I review.

8.7.6


texts: ShareThis module: show titles on mouseover

texts: Is it possible to add the TITLE attribute to the links made in the ShareThis module? So when I hover the facebook image, I see 'Facebook'...


texts: How to find bad PHP node that makes search_cron fail?

texts:
I can't run cron, manually or automatically. I installed Cron Debug module, checked all modules, and found out that the Search module makes cron stuck. When I disable it, cron is working.

I suppose the reason is one of my nodes has bad PHP code in it.
I googled for "search_cron errors", and found a solution in Drupal.org
I tried it by editing node.module, but I got this error:

  Fatal error: Call to undefined function db_fetch_object() in /home/mysite/public_html/modules/node/node.module on line 2616

Can you propose me a solution on how I can find the errorenous PHP code in nodes?
I am using Drupal 7.12.


texts: Why is the test runner not picking up tests for a contrib module?

texts:
I recently added tests to Cache Register, but the test runner on drupal.org doesn't seem to be picking them up. The tests are all located in tests/src/Kernel (repo) but aren't queuing up in the issue queue for either patches or merge requests. Am I missing something?
EDIT: Current answer references the namespace of the base test class, but that's no longer relevant. I refactored that Base class into a testing Trait instead and made sure that the remaining "real" tests use the proper namespace. Everything runs locally but still not getting picked up by the runner as far as I can tell.


texts: D7: How do you get the name of a module?

texts: I am using module_list() to get a list of all modules, but I want the names of the modules, not their machine name. Anyone know how to do that?


texts: Where is the configuration file for my custom plugins?

texts:
In my development environment, I create my first plugins that uses REST with a GET method. I use Rest UI to declare my plugins directly inside Drupal.

All is ok, the request sends me the json result as expected.

But, from here, my questions are :

Rest UI avoid to declare manually a config file. Great. But after using Rest UI I'm not able to find the config file, where is the configuration saved ?
In production, must I install Rest UI too, and re-configure my plugin ? Or is it possible to just copy/paste a configuration file ?


texts: Add preprocess to content within body field

texts:
I need to be able to wrap an anchor tag with rel="shadowbox" and href with the path to the image on all img tags that are inserted into the body field of a node. I think I can somehow do this with preprocess?

I realise that I can have a field of images and do it that way, though the client wants the images within the body text itself.

Any advice would be much appreciated.


texts: Twitter Profile Widget internal js doesn't work

texts:
I'm trying to set up the Twitter Profile Widget module in another language instead of the default english.

To do so I need to modify the widget.js file, so I have to use the option "Internal" in the module admin panel in order to use my custom widget.js inside the module folder.

But if I select "Internal" the twitter messages aren't shown, I've checked the source code and the local widget.js it's loaded correctly

I have also replaced the default widget.js file from the module folder with the one in the external url: http://widgets.twimg.com/j/2/widget.js, but still doesn't work

Any idea what I could be doing wrong?


texts: Form theme function is not invoked for a block content

texts:
Have a custom module with a block. Added form and form theme functions. Using hook_theme() to register  form theme function.

Trying to put form content in the _block_view() function into block content.
But finaly it doesn't use form theme function - theme_mymodule_custom_form()

The form is displayed on a block, but theme function is not in use,
Have no idea how to make this work.
Found a good sample here http://www.jaypan.com/comment/1758, but it didn't help me.

 function mymodule_block_view($delta = '') {
  switch($delta){
    case 'mymodule':
      if(user_access('access content')){
        $block['subject'] = 'Block header';
        $block['content'] = drupal_get_form('mymodule_custom_form');
      }
    return $block;
  }
 }

function mymodule_theme()
{
    return array
    (
        'mymodule_custom_form' => array
        (
            'render element' => 'form'
        ),
    );
}

/**
*  Create a form
*/
function mymodule_custom_form($form, $form_state) {
  // Form elements
  $form = array();

  // Text field
  $form['Input'] = array(
    '#title' => t('Input field'),
    '#type' => 'textfield',
    '#required' => TRUE,
  );

  // Submit
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Search',
  );

    // Get the path to the module
    $path = drupal_get_path('module', 'mymodule');
    $form['#attached'] = array
    (
        'css' => array
        (
            'type' => 'file',
            'data' => $path . '/css/style.css',
        ),
        'js' => array
        (
            'type' => 'file',
            'data' => $path . '/js/sample.js',
        )
    );

  return $form;
}

function theme_mymodule_custom_form($variables )
{
    // Isolate the form definition form the $variables array
    $form = $variables['form'];
    $output = '
Themed form
';
    $output .= drupal_render($form['Input']);
    $output .= drupal_render_children($form);
    return $output;
}


texts: Is there a way to test or spoof different user access?

texts:
Possible Duplicate:
  Multi-user/role testing, best practices

My current style in testing different user access is opening a different browser or opening a private session and logging into a different user.

Is there a way to spoof the current logged in user's identity? For example, I am logged in as Admin (user 1) and I want to see the site as regular user (ie, user 23). Is there a way I can do that in place within the same browser window/tab?


texts: How to migrate from test environment to production environment?

texts:
The migration is from the local environment to the production environment. The production environment has run some time and created a lot of articles.

In order to add new things to my site, I added a custom theme and installed CCK, Views and other modules in my local test environment. Now that the local test environment is finished, how do I migrate it to the production environment, without destroying the content of its database?


texts: Alter a panel page variant provided by another module (programmatically)

texts:
How can I alter a panel page variant provided by another module in my own module?

I am using Advanced Forum, and it provides a panel page to override Drupal's core forum display behavior and some variants: Top Level Forum, Container and Forum. But I have changed some layout options, and added a few more panes, and disabled some other panes etc in page manager UI. Now I want to export this into code, i.e. in my custom module. I can export the code using the export option in the UI, but I don't know how to add that code in my module. In other words I don't know which hook to implement to override this variant provided by Advanced Forum, instead of creating my own variant.

I know how to provide default panel pages or variants using hook_ctools_plugin_api() and hook_ctools_plugin_directory(), but I couldn't find out how to alter an existing page variant provided by another module.

Is there a hook for that?


texts: Drupal 7 Form API - AJAX updates for multiple file uploads

texts:
I have a Drupal 7 custom module form that uploads then processes multiple images.

I have an ajax callback that updates page content with the processed images. BUT, the page update happens when all uploaded files are finished and I would like to alter this to update when each uploaded file is processed.

Form creation:

function awsImage_form($form, &$form_state) {
  $form = [];

  $form['file'] = [
    '#type' => 'file',
    '#name' => 'files[]',
    '#title' => t('Upload files to test'),
    '#description' => t('TIFF\'s, JPG\'s, GIF\'s, and PNG\'s only, 20MB Max Size'),
    '#attributes' => ['multiple' => 'multiple'],
  ];

  $form['submit'] = [
    '#type' => 'submit',
    '#value' => t('Upload'),
    '#ajax' => [
      'callback' => 'awsImage_form_callback',
      'wrapper' => 'results',
      'method' => 'append',
    ],
  ];
  $form['results'] = [
    '#markup' => '
Results:
',
  ];
  return $form;
}

Form validation [error checking & save location [$destination] removed to keep it brief]:

function awsImage_form_validate($form, &$form_state) {
  //Save multiple files
  $num_files = count($_FILES['files']['name']);

  for ($i = 0; $i < $num_files; $i++) {
    $file = file_save_upload($i, [
      'file_validate_extensions' => ['tif tiff png gif jpg jpeg'],
    ]);
    if ($file) {
      file_prepare_directory($destination, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
      if ($file = file_move($file, $destination, FILE_EXISTS_REPLACE)) {
        $form_state['values']['file'][$i] = $file;
      }
    }
  }
}

AJAX callback [image processing removed to keep it brief]:

function awsImage_form_callback($form, $form_state) {
  $form_state['rebuild'] = TRUE;
  $processed_out = '';
  if (is_array($form_state['values']['file'])) {
    foreach ($form_state['values']['file'] as $file) {
     // image processing stuff which builds and array: $img_reponse_details
      $output = '';
      foreach ($img_reponse_details as $key => $img_details) {
        // build front end $output
      }
      $processed_out .= $output;
  }
  // push output back to form.
  $element = $form['results'];
  $element['#markup'] = $processed_out;
  return $element;
}

Ideally, I would like to update the front end in the foreach loop in the ajax callback:

function awsImage_form_callback($form, $form_state) {
  foreach ($form_state['values']['file'] as $file) {
      // deal with each image
      // push output back to form.
      $element = $form['results'];
      $element['#markup'] = $processed_out;
      return $element;
    }
}

But as soon as I return the current result, that's the loop over and only the first file is displayed - which is correct as it is a return... but what I am really after is 'do the AJAX update and carry on with the rest' and I am not sure how to go about that part?


texts: How to Disable Whole Form from hook_form_alter?

texts:
I've got a form I want to be disabled when certain criteria are met. According to the Form API I thought $form['#access'] = FALSE; would be sufficient. But no dice.

Instead, I'm doing this, which feels wrong, plus I get an error, "Warning: implode(): Invalid arguments passed in form_builder()"

foreach($form as $key => $element){
          unset($form[$key]);
}
$form['#prefix'] = 'Bad user. Don\'t access this form!';

Kind of a big stick approach. What's the right way to do this?


texts: I create advanced search with views and I want use selectize.js (https://www.drupal.org/project/selectize) for entity refrence selector . How can I do it ?


texts: entityform association with organic group

texts:
Is it possible to associate entityform with organic group?
Ive created form and would like it to be accessible by a group specified.

Organic Groups allow to make that possible with content types but I was wondering if this is possible with entityform.

If not - are there any alternatives?


texts: Displaying all fields of a custom content

texts:
I have a page.tpl.php ; where I want to display inside a
 in it the fields of a custom content I've created before :

1)The custom content is called "Slider"

2)It have a field I've added called image (Machine name :"field_image_slider")

I've tried this code but it didn't works :

    <?php
        if (!empty($node)) :
           $fieldImage = field_get_items('node', $node, 'field_image_slider');
           print var_dump($node); //to check the fields
           foreach ($node->field_image_slider['und'] as $item) {
              $val=$item['uri'];
              print '

Hi

';
           }
        endif;
    ?>

I've spent 3 days figuring how to solve this problem , any help would be extremely appreciated .


texts: Executing a method of a custom entity after all instances have been built

texts:
I'm putting together a private message module. Conversations threads are a custom entity within the module. A thread can potentially appear twice on a page - once in the 'inbox' (a block), and once as the main content of the page. I'm wrapping the rendered threads with a div that I'm attaching in an override of EntityViewBUilder::view(). If the user has not viewed the thread, I'm adding a class of 'unread-thread' to the div wrapper.

Where I'm running into a problem, is finding a place to mark the thread as 'read'. If I do it at the end of EntityViewBuilder::view(), then the class is only applied to the first instance of the thread on the page, since it's already been marked read by the time it comes to the next instance of the thread on the page. I want the class to be part of the wrapper on all instances of the thread on the page.

So I need to find somewhere to mark a thread as read, but only after all instances on the page have passed through EntityViewBuilder::view(). I'm thinking a post-render hook may be good, but I'm not finding one. Does anyone have any suggestions?


texts: Dynamic route's controller method not firing

texts:
I'm trying to use the Background Image module, but there seems to be a problem with the dynamic route it registers for generating CSS. I've been debugging it, but I have run into a wall. It's basically a duplicate of the core Image module's routing setup, so I'm not sure what's wrong, but the controller method never fires; the controller isn't even instantiated. Here's the config file:

route_callbacks:
  - '\Drupal\background_image\Routing\BackgroundImageRoutes::routes'

Here's the routes method:

  public function routes() {
    error_log('Router::routes');
    $routes = [];
    // Generate background image CSS files. If clean URLs are disabled the
    // files will always be served through the menu system. If clean URLs are
    // enabled and the file already exists, PHP will be bypassed.
    $directory_path = $this->streamWrapperManager->getViaScheme('public')->getDirectoryPath();

    $routes['background_image.css'] = new Route(
      '/' . $directory_path . '/background_image/css/{background_image}/{scheme}/{file}',
      [
        '_controller' => '\Drupal\background_image\Controller\BackgroundImageCssController::deliver',
      ],
      [
        '_access' => 'TRUE',
      ]
    );
    error_log(print_r($routes, true));
    return $routes;
  }

Here's the $routes object:

Array
(
    [background_image.css] => Symfony\Component\Routing\Route Object
        (
            [path:Symfony\Component\Routing\Route:private] => /sites/default/files/background_image/css/{background_image}/{scheme}/{file}
            [host:Symfony\Component\Routing\Route:private] =>
            [schemes:Symfony\Component\Routing\Route:private] => Array
                (
                )
            [methods:Symfony\Component\Routing\Route:private] => Array
                (
                )
            [defaults:Symfony\Component\Routing\Route:private] => Array
                (
                    [_controller] => \Drupal\background_image\Controller\BackgroundImageCssController::deliver
                )
            [requirements:Symfony\Component\Routing\Route:private] => Array
                (
                    [_access] => TRUE
                )
            [options:Symfony\Component\Routing\Route:private] => Array
                (
                    [compiler_class] => Symfony\Component\Routing\RouteCompiler
                )
            [compiled:Symfony\Component\Routing\Route:private] =>
            [condition:Symfony\Component\Routing\Route:private] =>
        )
)

If I try to hit a URL such as /sites/default/files/background_image/css/3/public/dq5DbF1hqHxkHXGiHSl9yuXubPox08bOX6nE12gX2h0.css?p2aptq (which the module correctly generates when I've got a background image set up on the site) I get a 404 error and nothing in the error log.

I'm using docker4drupal and have checked the nginx config and am 99% sure that's not the issue (there are no rules for /sites/default/files/ and I do see the 404 in the nginx log.)

Why doesn't the dynamic route work as it should, and as it doesn't for the Image module?


texts: I have created a content type that has a "number of accepts" field. I want to add a button, "accept", to the content type. When a user clicks it, it will temporarily store their username and etc. Depending on the number of accepts field, the content type will display "1/10 Accepts" for example. How would I be able to do this and have the number of accepts displayed in realtime. thanks!!


texts: Is vbo respect the order set by view while performing operation? or is there a way to tell it to perform in same order as result

texts:
In a simple vbo I needed to set field_serial_no to row no of view's result. By default view result is ordered by title in ascending and order cannot be modified (not exposed to user).
When these entities are passed to VBO, will it be aware of order of entities always? if yes I can directly access the index and save it in field_no. I not is there any method?


texts: State and postal code fields are not populating based on the selection of country with addressfield module and commerce drupal 7

texts:
I am using Addressfield module with Drupal commerce in shipping and billing section. I have a requirement to display the country dropdown only the country where user is on means when user shops in United states cart, then the shipping section country dropdown should display only United states as value. For this i added addressfield_standard_form_alter function and code looks like below

function exigo_order_integration_field_widget_addressfield_standard_form_alter(&$element, &$form_state, &$context) {

  // Only for shipping section
  if ($element['#entity']->type == "shipping") {
    $countryOptions = array();
    // Build the country option from session which contains session value of user country currently on
    $countryOptions[$_SESSION['exigo_settings_current_country']] = $element['country']['#options'][$_SESSION['exigo_settings_current_country']];

    $countryOptions['TT'] = "Trinidad & Tobago";

    $handlers = array('address' => 'address');
    $context = array('mode' => 'form');

    $address = array(
      'country' => $_SESSION['exigo_settings_current_country'],
      'name_line' => '',
      'first_name' => '',
      'last_name' => '',
      'organisation_name' => '',
      'administrative_area' => '',
      'sub_administrative_area' => '',
      'locality' => '',
      'dependent_locality' => '',
      'postal_code' => '',
      'thoroughfare' => '',
      'premise' => '',
      'sub_premise' => '',
      'data' => '',
    );

    // Regenerate the addressfield to properly show province, postal code, etc
    $address_rendered = addressfield_generate($address, $handlers, $context);

    // Assign the newly generated field to the element
    $element['street_block'] = $address_rendered['street_block'];
    $element['locality_block'] = $address_rendered['locality_block'];
    $element['country'] = $address_rendered['country'];

    // Override the country option list
    $element['country']['#options'] = $countryOptions;
  }

I added 'Trinidad & Tobago' country to the dropdown and selection of this country the address section is not re-generating. If i remove the above function then again all country get displayed in country dropdown and everything will work fine. What i doing wrong here or what additional changes need to do to populate state and postal code based on country selection?

Any help will be really appreciated


texts: Can jquery code be triggered by ajax success?

texts:
I know that I can add any code inside ajax success like this

$.ajax({
      type: 'GET',
      url: element.href,
      dataType: 'json',
      success: function (data) {
        //mycode

And mycode would be executed after previous script is done. But is it possible that jquery script alone can somehow detect certain ajax success and be triggered only by that?
I posted this question to this forum because drupal uses behaviours which might be helpful with that. But that is my guess only.
Thank you for any clues.


texts: How to add a class to a List field based on the content?

texts:
I have a List Field for the Articles that will work like a Category.

This is an image of the PSD file:

There are 6 options on the list so the user can select the appropriate one when creating the Article. The problem is that each of those options needs a different CSS class and it should still be possible to make a View for those contents and show them as shown on the next image.

The boxes with colors is what I need to create as the Category, but I cannot add CSS classes for each content on the list while having the View that shows those 4 articles.

Any idea how can I get this to work?


texts: Programmatically get exposed filters from view

texts:
A little bit of context:
I am running a headless Drupal 8 with React in the front-end. All the data gets exposed through various endpoints.
Now i am trying to render a view in react, there was no problem in obtaining the data. But when i tried to get the exposed filters i ran into a problem (the filters are based on taxonomy terms). I expected to get the filter values like this:
value: {5:"Value one", 6:"Value two", 49:"Value three", 50: "Value four"}

Except i got the filter values like this:
value: {5:5, 6:6, 49:49, 50:50}

So it feels like instead of get the key and value i only get the keys...
I am wondering if i am doing something wrong or there is another way of obtaining the exposed filter values.
The following code i am using to obtain the filters
$this->$view // ViewExecutable
$filters = [];
foreach ($this->view->filter as $filter) {
  if($filter->isExposed()) {
    $filters[] = $filter->options;
  }
}


texts: How do I customize the search result page?

texts: I have customized the teaser view of my content types and the page view. Now I need to use the teaser view for the search results page. By default, Drupal displays a full text jumbled mess for each result, I need to be able to customize the look of each one per content type. I don't want to change HOW drupal gets the results, just how it displays them.


texts: How to display the webform submission data in the below format in Views?

texts:
I want to display the webform submission data along with some other information in the below mentioned table format (like multiple rows for a particular column inside of a table).

Is it possible with Views, or can anybody suggest a module, if there is such or any other way of getting it? I tried searching but found no module that meets my requirements.


texts: Why can't I have hyphens in my db_query()

texts:
I am trying to SELECT all the rows in my MySQL where a field matches a variable using the db_query() function. The variable is not a user input, it is retrieved from another database table based on the user currently logged on, so basically the variable is safe, but it does contain hyphens. Obviously without the hyphens the queries won't work properly, but for some reason if I include the variable the database query  stops working.

When I say it stops working, I can use the functions in the object that is returned but whenever I try to get individual fields I get an error. In case it affects any suggestions, the query has two more 'comparisons' but without the third, containing hyphens, the query could return more than one row. I only want either one or zero rows to be returned.

Anybody any ideas?

UPDATE: The code I have looks something like this:

global $user;

        $ukey = "A-B-C";

        $result = db_query("SELECT NAME FROM ukeys WHERE uid = :uid AND EMAIL = :email AND GENERATEDKEY = :key", array(
            ':uid' => $user->uid,
            ':email' => $user->mail,
            ':key' => $ukey
        ));

        if($result->rowCount() == 1){
            $name = $result->NAME;

And the error comes on the bottom line where I try to get the NAME from the results.


texts: Fields on images, displayed on edit page

texts:
I'm trying to implement a way for users to add a "caption" and "credit" (name of the photographer) to photos which are attached to an article. The user should be able to upload an image and assign a caption and credit, preferably from the edit page for the article.

I've installed the media module and added "caption" and "credit" fields to the image file type, but I can't figure out where the user can edit those fields. Is there any way to show those fields somewhere on the edit page?


texts: How to adding our own sorting to a view on Drupal?

texts:
I have develop a drupal view with table format.

Here table rows are Name and Date.
I am sorting a Name column with default sorting in views,it's working fine.
But when user click on views page automatically views page redirected to default sorting in views.
Here problem is when user click on sorting with (asc/desc) that order permanently store in database.

how can we achieve this.


texts: Allowing users to add taxonomy terms but requiring administrators to verify them

texts:
I would like to allow users to add new taxonomy terms, but I would like this to be verified by an administrator. The way I envision this working would have a user filling out a form which would send a notification to the specified admin; then, if the admin accepted the users request some hook or method would be triggered that would create the new taxonomy term.

Is there way to do this kind of thing with Drupal?


texts: See what database a site is connected to

texts:
Is there a page in Drupal 7 (or a module) that will show me what the name of the database is that the site is pointing to?

I know this can be done via settings.php, but I am setting up a build procedure that I can have lower level developers (or even non-developers) handle and a UI would be better.  I recently had an issue with two sites pointing to the same database and it borked some things up.  I want to add checking this setting to our build procedures.


texts: Programmatically change the available options in a views exposed filter

texts:
I have an existing view in which I want to change the available options in a view exposed filter. I can't manipulate the form because the modifications are dependant on other views data, so I thought I could use a view hook:

function my_mdoule_views_pre_view($view, $display_id, $args) {
  // This doesn't work unfortunately
  if ($display_id === 'gallery_media_select_modal') {

    $filters = $view->display_handler->getOption('filters');

    $filters['bundle']['operator'] = 'IN';
    $filters['bundle']['value'] = ['image' => 'image'];

    $view->display_handler->overrideOption('filters', $filters);
  }

}

This setting is basically the same that you can do in the UI, but like I said I need to do it dynamically.

I can see that this is in fact set correctly (and still set in later view hooks) but it's never picked up by the code that is responsible for building the exposed select.

I've found many similar questions, but conclusively they've only been answered for Drupal 7, e.g. https://groups.drupal.org/node/82219


texts: How should I use the Queue Runner module?

texts:
I would like to run tasks in sequence (commerce product feed before commerce node feed). I think the Queue Runner module could do the job. However, I can't find sufficient examples of how to implement it.

As far as I can see, I should create a queue with subtasks and use the serial_collection queue.

So far I created the following (with only one subtask), but the callback is never run:

function mymodule_run($file, $importer) {

  $data = array();

  $task = array();
  $task['data']['title'] = 'Subtask ' . $file->fid;
  $task['data']['worker']['callback'] = 'mymodule_callback';
  $task['data']['file'] = $file;
  $task['data']['importer'] = $importer;
  $task['data']['retries'] = 10;
  $data['subtasks'][] = $task;

  queue_runner_add($data, 'serial_collector', 5);
}

function mymodule_callback($data) {

  $importer = $data['importer'];
  $file = $data['file'];

  watchdog('mymodule', 'running importer: !importer, using file: !file',
    array('!importer' => $importer, '!file' => $file->filename));
}


texts: Hide some options from Image Properties overlay in WYSIWYG editor?

texts: Im using the CKEditor WYSWYG editor. Is it possible to hide some of the options from the Image Properties overlay popup?


texts: Drush post-installation - where can I find drushrc.php?

texts:
Just getting my first hands-on with Drush 5.1. The stuff works and is very promising as per how modules can be installed and enabled. One question though. Where should I look for the drushrc.php file that everyone is referring to and how should I code it to set up aliases for my sites?

I did a search over my disk and found nothing except examples.aliases.drushrc.php. Also I found a couple of mysterious locations:

C:\Program Files\Drush
C:\Program Files\Propeople\Drush
C:\ProgramData\Drush
C:\ProgramData\Propeople\Drush

They surely contain vital stuff and I'm not going to touch anything, but I'm wondering if this is the correct post-installation shape.


texts: "Fetch entity by property" for users that share terms with new node

texts:
I have a content type of RFP that has a term reference field named "RFP Categories".  The users also have this same term reference.  When I publish a node, I want to email all users who selected a category that is tagged in the node.

This SE post (Email users on node creation based on taxonomy reference) comes very close to the answer I am looking for, but I'm not quite able to follow it.  I believe in their case they are setting the 'value' to a specific taxonomy term, whereas I need to fetch any use who has a term matching the node's terms.

My rule has the Fetch Entity by Property action seen below.  Unfortunately, I cannot see (or maybe I'm failing to understand) how to link the "RFP Category" terms in the node to the terms in the user entities. It is broken somehow because when I publish an RFP node, I get a SQLSTATE error.

This is what my rule looks like so far.


texts: Load more content with ajax when clicking more link in a view

texts: I have a custom block view. I display the last 5 node titles. If someone clicks the more link I want to load the next 5 titles underneath the current 5 node titles. No page refresh and not pager. Is this possible? How would I go about doing this?