texts: If $db_prefix is "assumed to be a string", then does Drupal automatically sort what is a sharable table in the DB?

texts:
$db_prefix = 'drupal_';

I've found many examples of installations which pick through the tables and place these in an array. And then there is the example of the site I am migrating where it only contained the above string. So, does Drupal sort it all out in the case of this simple string?

What is the big idea I feel I am missing about multi-sites?
(haha the mysteries of the D framework!)


texts: Add a caption to an image field that allows multiple images

texts:
OK, the heading isn't the best example of english ever, but I hope you get what I mean...

I've run up against the bug in Drupal where it doesn;t check the length of the title value in an image field (http://drupal.org/node/916446) and I was using that field to store the caption for the image which I was displaying in a div underneath the image.

Is there a way to either allow the title field to hold more information, or even better (semantically especially), create an additional field to hold my caption information?

The reason I don't just create a separate field for caption is that I'm allowing multiple images on the image field and from a content management point of view, I wouldn't easily be able to match up the images to their captions.

I'm sure it's something simple like creating a version of the image.field.inc? Has anyone done it or know how to make this happen?


texts:
How do I add 'Title' to a search Engine? For Section 508 compliance i need to add 'label or 'title' to the following section :

<input placeholder="Search" type="text" id="edit-search-api-views-fulltext" name="search_api_views_fulltext" value="" size="26" maxlength="128" class="form-text" />

I have created funtion.js with the following query:

$(document).ready(function(){

            $('#edit-search-api-views-fulltext').attr('title', 'Search');}

This doesn't seem to be working. View source says:

 <input placeholder="Search" type="text" id="edit-search-api-views-fulltext" name="search_api_views_fulltext" value="" size="26" maxlength="128" class="form-text" />

How do I add a Title?


texts: WidgetBase with Ajax Callback and manipulate #tree values

texts:
After many tries, maybe someone can help me here. I want a dynamic form field in a widget base, but I keep having problems.

1st Values of the submit button are lost after submit and can´t manipulate the value of 'object_qt'. I thougt, they where handled in massageFormValue and saved in extractFormValues, but it´s not changing and if I save the Node, the values are lost. I have Found here some other Posts, but nothing works for me.

2nd The ajax callback doesn`t work for the types 'button' or 'submit'. Always the whole page loads without any changes.

In Widgetbase.php are the add more Option and also tested it for my TestWidget, but run into the same issues.

class TestWidget extends WidgetBase {
  /**
   * {@inheritdoc}
   */
  public function formElement(
    FieldItemListInterface $items,
    $delta,
    array $element,
    array &$form,
    FormStateInterface $form_state
  ) {

    $element['object_pos'] = [
      '#tree' => TRUE,
      '#type' => 'fieldset',
      '#title' => t('Pos'),
      '#attributes' => [
        'id' => 'position-'.$delta,
      ],
    ];

    $defaultObjectQt = isset($items[$delta]->object_qt) ? $items[$delta]->object_qt :  0;

    $posItems = is_numeric($defaultObjectQt) && $defaultObjectQt > 0 ? $defaultObjectQt : 1;
    $element['object_pos'] += TestWidget::formPos($items, $delta, $posItems);

    $element['object_qt'] = [
      '#type' => 'value',
      '#default_value' => $defaultObjectQt,
    ];

    $element['object_qt_wrapper'] = [
      '#type' => 'container',

      'object_qt_more' => [
        '#title' => t('Qt'),
        '#type' => 'number',
        '#empty_value' => '',
        '#default_value' => 0,
        '#size' => 2,
      ],
      'object_qt_add' => [
        '#type' => 'submit',
        '#value' => t('add more'),
        // '#ajax' => [
        //   'callback' => [$this, 'rebuildPos'], // dosn`t work
        //   'event' => 'change',
        //   'wrapper' => 'position-'.$delta,
        //   'progress' => [
        //     'type' => 'throbber',
        //     'message' => $this->t('Verifying entry...'),
        //   ],
        // ],
      ],
    ];

    return $element;
  }

  public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {

    foreach($values as $itemKey => $itemValue) {
        if(!empty($itemValue['object_pos'])) {
          $values[$itemKey]['object_pos'] = serialize($itemValue['object_pos']);
        };
        // Manipulate values
    };

    return $values;
  }

  public function rebuildPos(array &$form, FormStateInterface $form_state){

    $form_state->setRebuild(TRUE);
    $element = $form_state->getTriggeringElement();

    $delta = $element['#parents'][1];
    $posItems = $element['#value'];

    $posElement = ObjectReferenceWidget::formPos($items, $delta, $posItems);
    $ergebnis = array_merge($form['field_object_reference']['widget'][$delta], $posElement['object_pos']);

    return $ergebnis['object_pos'];

  }

  public function formPos($items, $delta, int &$posItems) {

    $posArray = [];
    for($i=0; $i < $posItems; $i++) {
      $posArray['item-'.$i] = [];
    };

    // get defaults
    if(!empty($items[$delta]->object_pos)) {
      $posValues = unserialize($items[$delta]->object_pos);
      //$posArray = array_merge( $posArray, $posValues);
    };

    foreach($posArray as $itemKey => $itemValue) {
      $element['object_pos'][$itemKey] = [
        'coords' => [

          // ... form fields

        ],
      ];

    };

    return $element;
  }


texts: where in database is renamed login for 'Rename Admin Paths"

texts:
A little embarrassing - I've lost/forgotten the login page for a Drupal 8.9 website. It was renamed using the module "Rename Admin Paths."
I've gone to the module page at drupal.org and looked through issues and comments, but none of the solutions I found will work.
This site is unable to install Composer or Drush at this time, so I can't use any method there. Another suggestion was to search the 'variables' table - but that was specific to D7, I believe. I don't see that table.
I've commented within their page hoping to find the answer, but maybe someone here happens to know the answer?


texts: Drupal 7 submit function not called for themed form

texts:
I am developing a form. 2 functions are:

function reserve_multi_step_form($form, &$form_state)
{
       $module_path = drupal_get_path('module', 'reserve');

       $form['#theme'] = 'reserve_form_2';
       $form["agreed"] = array(
                            '#type' => 'checkbox',
                            '#title' => t("I accept the deposit policy"),
                            '#attributes' => array("onChange" => "policy_accepted();"),
                            );

       $form['submit'] = array(
                       '#type' => 'submit',
                       '#value' => t('Submit'),
                       '#attributes' => array('style' => "padding: 0 10px;"),
                       "#disabled" => true,
                       );

       return $form;
    }

function reserve_multi_step_form_submit($form, &$form_state) {
       print 1111;exit;
}

The theme function:

function reserve_theme($existing, $type, $theme, $path){
   return array(
                'reserve_form_2' => array(
                                          'render element' => 'form',
                                          'template' => 'reserve_form_2',
                                          'path' => drupal_get_path('module', 'reserve'),
                                          ),
}

In the template file I print some text and render the form:

    <?php
    print "text";
    print drupal_render_children($variables["form"]);

The form is displayed correctly. But after I click submit button, the reserve_multi_step_form_submit is not called. Without theming it works. What can be an issue?


texts:
I want to add edit account menu item in user menu, I want the URL to be user/{user_id}/edit.
How can I achieve this without menu_token module.
I also tried creating menu item programatically as follow

$items = array();
  global $user;
  $user_id = $user->uid;
  $items['user/' . $user_id . '/edit'] = array(
    'title' => 'Edit account',
    'access callback' => 'user_is_anonymous',
    'menu_name' => 'user-menu',
    'type' => MENU_SUGGESTED_ITEM,
  );

  return $items;

But newly created menu item only shows at back-end i.e. at structure/menu/user-menu but it doesn't display it on front-end.


texts: Multiple buttons to link to different page and different query

texts:
I have a page in my site (from a custom module) with a hook_menu (red boxes).

The code for the menu is as follows:

$items['upcoming_games/' . date('Y-m-d')] = array(
  'menu_name' => 'main-menu',
  'title' => 'Upcoming Games',
  'page callback' => 'my_page',
  'access callback' => TRUE
);

The page callback calls a function where I insert the date as an argument for a query.
When clicking the menu, it defaults to TODAY.

What I need is to query for a different date depending on the click of the coloured buttons. I get "page not found"...

In the function where I have my query I get the date with the follwing code:

$date_to_show = arg(1);

What am I missing here?


texts:
I would like to use an if statement depending on my token something like

<?php if ([simplenews-category:name] == 'fishing'): ?>
 Go fishing   <?php else: ?>
 Go sailing    <?php endif ?>

Above code doesn't work, can somebody please give me advice?

I'm using Drupal 7


texts:
Quick version:

The login form (at ?q=user/login) post it's information to www.domain.com when Drupal is at www.domain.com/sub/folder. Navigation URLs seem to work.

More info:

I'm in the process of migrating a drupal installation from a host to another. I've moved files/db on the new host, and I have a test url available that looks like

https://server.hostcompany.com:8443/sitepreview/http/mydomain.com/

I've set the RewriteBase (.htaccess) to

RewriteBase /sitepreview/http/mydomain.com

and the base url (settings) to

$base_url = 'https://server.host.com:8443/sitepreview/http/mydomain.com';

So I have this problem with the login form, making me unable to authentificate, and there are some images that are not loaded correctly (the sitepreview/http/mydomain.com is missing)

What have I forgotten/am I doing wrong?


texts:
I want to extend PanelsIPEPageController but I have this error:

[Tue Mar 07 09:48:26.308720 2017] [proxy_fcgi:error] [pid 1170:tid 140603094411008] [client 192.168.10.155:60806] AH01071: Got error 'PHP message: PHP Fatal error:  Class 'Drupal\\zoo_ipe\\Controller\\Drupal\\panels\\panels_ipe\\Controller\\PanelsIPEPageController' not found in /home/www/dev/www/modules/zoo_ipe/src/Controller/PanelsIPEPageController.php on line 6\n', referer: http://dev.local.fr/admin/config/development/performance

This is my code :

modules/zoo/src/Controller/panelsIPEPageController.php

namespace Drupal\zoo_ipe\Controller;

use Drupal\panels\panels_ipe\Controller\PanelsIPEPageController as ControllerBase;

class PanelsIPEPageController extends ControllerBase {

  public function getBlockPlugins($panels_storage_type, $panels_storage_id) {
    echo "ici"; die();
  }

}

Error is on this line :

class PanelsIPEPageController extends ControllerBase {

And my zoo_ipe.routing.yml :

panels_ipe.block_plugins_zoo:

  path: '/admin/panels_ipe/variant/{panels_storage_type}/{panels_storage_id}/block_plugins'
  defaults:
    _controller: '\Drupal\zoo_ipe\Controller\PanelsIPEPageController::getBlockPlugins'
  requirements:
    _panels_storage_access: read
    _permission: 'access panels in-place editing'
    _method: 'GET'

Can you help me ?


texts: Programmatically render HTML in taxonomy term description

texts:
I'm facing an issue where I'm attempting to programmatically set the description property for a taxonomy term that includes HTML, but the HTML is being rendered as text, rather than being rendered into HTML elements, unless I manually access the term in a browser and save it.

Example

taxonomy_term_save((object)array(
  'name' => $name,
  'description' => $t('
My description.

More info.
'),
  'vid' => $vocab->vid,
));

When I attempt to render the description, it appears as:

My description.

More info.

However, if I then go to Structure > Taxonomy > My_Vocabulary > My_Term and simply save the term (without any edits), it will then render properly as:

  My description.More info.

I've also made a number of attempts to achieve this through an Entity Metadata Wrapper, but no luck (though I am admittedly not well versed on EMWs).

How can I programmatically force the description to correctly render the HTML without having to manually re-save it?

Any help is appreciated!


texts: View / Twig Extension : Display other items with the same field value

texts:
I work on a view block which displays a list of parts (content Type : parts), here are simplified examples of parts and fields :

part_ref || part_id
ABCD || 10
BCDE || 11
CDEF || 11
DEFG || 11
EFGH || 12

In my View Filters, only one part is displayed, filtered by "part_ref".
What I would like to do is to display other parts with the same "part_id".

For example, "BCDE" is displayed, I would like to display also "CDEF" and "DEFG".

I have created a Twig Extension in order to do something like :
{{ displayRelated(11) }}

But inside my function "displayRelated", Idon't know how to get parts with the passed "part_id".

Does someone have a link or something to guide me ?
I cannot find anything on google.

Or maybe it's not the right approach ?

Thanks in advance.


texts: Does "Boost" module work together with "Theme Key" module?

texts:
I wonder if the Boost module works together with the ThemeKey module.

Has anyone experience with both modules working together? Especially when it comes to different style-sheets for different devices.


texts: where are menu item configurations stored?

texts: In drupal 8, which file holds the information of the menu items?  I do a config-export and do not see which file is changed when I change the menu items.


texts: 'Manage fields' and 'manage display' links not working for content types

texts:
I did an update of several modules (core included, from 7.xx to 7.26), a couple of weeks ago, and until now I had not tried to access content types.

Today I did, but while I can see the 'manage fields' and 'manage display' links, when I click on them I'm taken to the 'edit' page.  Also, if you have admin_menu installed and just hover on structure/content-type/custom-content-type, a menu with the available edit options appears, but in my case only 'delete' is there.

Searching around I see this is most commonly caused by the 'field ui' module being disabled, but I checked and it's in fact enabled.  I disabled/re-enabled it but nothing happened.

Per this post, I also tried enabling all checkboxes at admin/config/administration/admin_menu under the 'performance' tab, flushed caches, and still no result.

I did the site's update for a client, and still have a version of the site on localhost, where all menus work fine.  I sent them all files/database so their hosting provider would upload the site and now this issue comes up.  I have no access to the database, only the admin pages.  What else could be the problem and how could I fix it?

Thank you in advance.


texts:
I need to import a large dataset (over 300,000 records) into a Drupal 8 site. I have figured out how to do this with feeds on a small test dataset.

The dates in the records are in the format June 8, 2018. I do not see a way to use a Drupal 8 Date field to input dates in this format.

I need to be able to create a view that displays records based on a date range.

What is the best way to get the data into Drupal in a format that a view can use? Would it be to maybe use computed field to transform the data while it is being imported? Or would it be better to maybe execute a SQL query after the data is imported?


texts: Drupal authentication for a non-Drupal script

texts:
I have a non-Drupal PHP script I would like to put on a D7 Drupal site, but I would like it to be available only to users who have logged in via Drupal. What are the best/easiest ways to do this? It's my script, so I can change it any way I want, embed it in a module, a PHP-capable field, etc.

To be specific, it's a signup sheet system that uses form submissions, using files (not the db) to store the data.


texts:
I've been teaching myself Drupal 7 for the past 2 weeks. So far, I've gotten the general idea, and figured out how to use Views (i think) but it's the most difficult CMS I've ever had to learn and I've pulled out lots of hair.

The problem I'm stuck on now is that I want to be able to let the site administrators attach a unique banner image that will appear at the top of every page in my theme. There is a 'banner' region in the theme that was intended to hold this image. I've added a banner image field to the Basic Page content type.  But now I can't figure out how to get that image to show up in the banner region and not in the flow of the rest of the page content (body).

I've tried a few things with views and blocks, but nothing works.  Please Help!


texts: Module(s) doesn't enable properly with Drush

texts:
I have installed Acquia's DevDesktop 2 to create local sites and while testing D8.3.6 I have found an interesting issue. When I enable various modules with drush (drush en paragraphs (example)) drush reports the module installed correctly however when I try to use the module the site errors. The way to fix this is to uninstall with drush then use the Drupal UI to enable the module and all is fine.

The version of drush shipped with the latest version of DevDesktop is 8.1.10

Anyone else seen this?


texts: How to achieve if else statement while querying with database?

texts:
I want to export some data from test_records table depend upon supplied from date and to date. I from and to date not supplied I want to export whole data. So how I can achieve that. Below is my code.

$from_date = strtotime($form_state['values']['fromdate']." 00:00:00");
$to_date   = strtotime($form_state['values']['todate']." 23:59:59");

$result = db_select('test_records', 'n')
      ->fields('n')
      ->condition('submitted_time',  array($from_date, $to_date), 'BETWEEN')
      ->execute()
      ->fetchAll();

I am using one condition that will compare submitted_time in database with supplied from and to dates.  But When I pass nothing, it should get all the data from that table. Any suggestion will be appreciated.


texts: How can I programmatically get the theme name?

texts: In Drupal 8, is there a way to figure out what theme you are currently using in a module?  I need to get the name programmatically within the code of a module.


texts: How do I access data nested within JSON in a Guzzle service description response model?

texts:
I'm trying to pull some data into Drupal from a service, via Guzzle. I've got several clients like this working, but the data returned by this service is structured a bit differently:

{
  pager: [ ],
  row_count: 101,
  data: {
    "794": {
      InventoryID: "794",
      AddressID: "618"
    },
    "2318": {
      InventoryID: "2318",
      AddressID: "536"
    }
  }
}

A service description like this:

operations:
  GetInventoryList:
    httpMethod: "GET"
    uri: "current-stock/inventory?_format=json"
    summary: "Gets all current inventory items"
    responseClass: "InventoryList"

models:
  InventoryListItem:
    type: "object"
    location: "json"
    properties:
      InventoryID:
        location: "json"
        type: "string"
      AddressID:
        location: "json"
        type: "string"
  InventoryList:
    type: "array"
    location: "json"
    items:
      "$ref": "InventoryListItem"

...doesn't work, of course, because it targets the top level of the response. Is there a way to define the models so that the contents of the 'data' array are returned, rather than the top level array?


texts: How to add profile2 field data to a programatically created user

texts:
I create a user from a form (that part works fine) but no profile2 information seems to be created....

profile2_load_by_user returns an empty array which results in the below error.  Do I need to some other step to first associate an "ae_sa" profile with the newly created user?

  Recoverable fatal error: Argument 1 passed to profile2_save() must be an instance of Profile, instance of stdClass given, called in D:\FULLREPO\trunk\sites\all\modules\sps_users\sps_users.module on line 115 and defined in profile2_save() (line 291 of D:\FULLREPO\trunk\sites\all\modules\profile2\profile2.module).

...
$account = user_save(null, $new_user);
$obj_user = user_load($account->uid) ;
$profile2 = profile2_load_by_user($obj_user) ;
$profile2["ae_sa"]->field_full_name[LANGUAGE_NONE][0]["value"] = $fullname;
$profile2["ae_sa"]->field_title_role[LANGUAGE_NONE][0]["value"] = $titlerole;
$profile2["ae_sa"]->field_company[LANGUAGE_NONE][0]["value"] = $ucompany;
$profile2["ae_sa"]->field_bio[LANGUAGE_NONE][0]["value"] = $bio;
profile2_save($profile2["ae_sa"]) ;


texts: Special Character Encoding Issues in Node Titles

texts:
I work in an IT department at a museum whose website is built on Drupal. I have experience with other CMSs, but I've only worked with Drupal a little bit. So far, I've been able to help them fix quite a few bugs with their site, but I can't find any information on how to resolve this particular one.
On any content type, if the Title field has a special character it displays the character correctly on the site, but if it's linked to on Facebook and it pulls the title, it ends up showing the entity number instead.

An example:

Science Movie Night: The Shaman's Apprentice

becomes

Science Movie Night: The Shaman&#039;s Apprentice

I've searched around, but I haven't found anything talking about how to combat this.


texts: Creating a grid of referenced Commerce products

texts:
I'm using Drupal 7 along with Commerce 1.x and I have created a content type that has reference field for Commerce Product entities.
And now I would like to render a grid of referenced products i.e. dedicated add to cart form for each product on the node page.
At least so far it seems like an impossible task to do. I've tried with Views, custom form template variable etc. but it always gives errors like
Notice: Undefined index: #options in function form_process_radios() (row 3188
Parameter must be an array or an object that implements Countable in function form_process_radios() (rivi 3188
Somehow it is always expecting a radio element with options (which is the default formatting) for multiple products.
However, that is not what I want and I've tried to set it as hidden element. I also can see the forms but would like to get rid of errors and create this "by the book".
<?php
function mymodule_preprocess_entity(&$variables) {

  $variables['add_to_cart_form'] = '';

  if ($variables['elements']['#entity_type'] == 'commerce_product'){

      $item = $variables['elements']['#entity'];

      if (empty($item->product_id)) {
        return;
      }

      $form_id = commerce_cart_add_to_cart_form_id([$item->product_id]);

      $line_item = commerce_product_line_item_new($item, 1, 0, [], 'custom_owner');
      $line_item->commerce_product = $item->product_id;
      $line_item->data['context']['product_ids'] = array($item->product_id);
      $line_item->data['context']['show_single_product_attributes'] = 1;

      $product_form = drupal_get_form($form_id, $line_item);

      // Trying to change from radio element to hidden
      $product_form['product_id']['#type'] = 'hidden';
      unset($product_form['product_id']['#theme_wrappers']);
      unset($product_form['product_id']['#process']);

      $form_markup = drupal_render($formp);
      $variables['add_to_cart_form'] = array('#markup' => $form_markup);

  }

}?>


texts: I am able to create nested galleries with help of multiple content types and views, but is there any way that I can create nested gallery with one or two content types. I really don't want to make it messy by using multiple content types.


texts: What is the difference between an 'Attachment display' and a 'Global: View area' put into header/footer of a view?

texts:
I'm trying to decide which should I use. Both can inherit contextual filters, so in my case both of them are good solutions. Except that I already have the other view that I want to put together with the first, so with Attachment I would have to redo the whole other view as a new display of the first, but with View area I could just reuse the other view.

What is the concept behind them? Are there other differences than what I noted above?


texts:
I'm maintaining a website with drupal 6 and recently did an update. I have some links of the following form:

 …
 …
 …

Since the update, every link of that form is dead (since the navigator just tries to open the url "internal:forum", which is completely invalid as is)

It may be a module I forgot to enable again after the update, but I have too much of them to test them one by one, and none of them seems related to that sort of link at all.

What are those links? What is handling them and what do I need to make them work again?


texts: How to get hook_install() to run all hook_update_N()?

texts:
How can i get hook_install() to run all updates that I have for my module? I have in it mymod.install file.

I have tried

function mymod_install() {
  mymod_update_6001();
}

but it does not seem to do anything. If I have an mymod_update_6002() would I still call 6001(), just call 6002() or call both in the order 6001(), 6002().

I thought it would be common sense to run all the updates when you installed a module by default.


texts:
I am trying to fetch an object:

$field_name= 'field_test';
$json_code = $node->$field_name['und'][0]['value'];

NOT WORKING

$json_code = $node->field_test['und'][0]['value'];

WORKING

I must have variable because it's every time different field name

any solution?


texts: Create a Views that displays all unused taxonomy terms

texts:
I found this article about how to create a Views to display all active taxonomy terms: https://www.drupal.org/node/770782

I want to achieve the exact contrary: Get a list of all terms that are not used by my nodes.

Can I reach this with Views UI, relashionships, etc?

Any clue is welcome!


texts: Changing text "Create new account" in /user tab

texts:
Does anybody know how to change the tab text "Create new account" in /user - I am using Drupal 7.

Many thanks


texts: How to store non-entity data using REST?

texts:
I'm developing a decoupled system where the end user can add additional textual information to images displayed by Drupal 8 in a lightbox. When the user opens an image, my custom module launches a Javascript script that puts up the UI to enter the text (subject to permissions, of course). The text is displayed as an overlay on the image - the image itself is not modified.

Each image is a standard Drupal image - i.e. a file, such as an image associated with an article.

I'd like to store and retrieve an image's text as a JSON string somehow "associated" with the image in Drupal's database. My initial plan was to use REST calls (JSON:API, Drupal 8's core REST, or maybe GraphQL) to transmit the text between script and Drupal. However, it appears that these REST implementations will only allow storage of Drupal entities. My JSON strings, not being entities, thus could not be stored using REST.

Is this even possible? How can a script store a JSON string into the Drupal database and link it to a given image?

Please note: I have looked at the existing answers for this issue in drupal.stackexchange and it appears none of them apply to my case. If you believe that an existing answer applies to my case, please point out which answer.


texts:
It doesn't seem I can get my meta tags to appear on the page--front.tpl.php on a Drupal 7 site.

I feel like I have all the correct settings in the Meta tags module configuration, and I have cleared all caches. It works perfectly fine for all pages, just not the front page. This is driving me bonkers.

Any ideas?


texts: Difference between creating a Rest endpoint and a route&controller with jsonResponse

texts:
What is the difference between creating a Rest plugin with the Rest API and creating a route/controller that returns a jsonResponse ?

In which case i have to create a custom route/controller with a jsonResponse ?


texts: How to display all media that references this taxonomy term and its immediate children?

texts:
I have a hierarchical taxonomy vocabulary, "Living Things". A simplified excerpt looks like this:

Plants
--Roses
----Red Rose
----Pink Rose
--Orchids
----White Orchid
----Yellow Orchid

I have a library of media (images and videos) that have a field, "Primary Taxon", which references the appropriate term in that "Living Things" vocabulary. e.g. An image of various roses has its "Primary Taxon" field set to "Roses", and a video of a white orchid has its "Primary Taxon" field set to "White Orchid".

On my taxonomy term pages, how can I display all media that references that species, and that species' immediate children? i.e. The "Roses" page should show media that displays roses in general, as well as red roses and pink roses. The "Plants" page should show media that displays plants in general, as well as roses in general, and orchids in general, but not the individual species.

Ideally, it should also be possible to sort the view with either "this taxon first", or "children first", but I'm interested in any solution without this functionality too.

So far, I have made a view that shows all media on the taxonomy pages. However I can't find an appropriate contextual filter to limit the displayed media. Even a single contextual filter using "Media: Primary Taxon (field_primary_taxon)" stops any media from displaying.


texts: How to create an extra field in the profile module to only accept the numeric values?

texts:
I am creating extra fields in the user registration form. for this I am using the profile module.

In this module there is no option form creating a text field which should only accept the numeric values just like in drupal 7.

So how will I create such field in the user registration form?

Any idea?


texts: How do I reference a file field and node title from another content type & node?

texts:
I need to add a link to a file, added through a file field on its own content type called "Document" from another content type and node call "plan information".

The idea is that the "document" nodes are displayed to provide access to a collection of "documents" throughout the entire site. This content type simply has a title and a file field. That cannot change.

What I need to do is to add a LINK to a user-selected document on the "plan information" content type that links the "document" to the appropriate "plan information" node as selected by the content manager.

On the "plan information" nodes, I want to simply create a UL of the document(s) attached using the title of the "document" node as the anchor text.

We've had a big problem with updating documents where associating the right "document" link on the correct "plan information" node has been problematic at best.

I've tried entity reference but couldn't get that to work. It would either bring in the entire document node, or nothing at all.

I tried node reference but it wants to behave in a similar way as the entity reference did, pulling in the whole node.

I tried field reference, but again, no success.

Most grateful for any guidance/insight on this.


texts:
After run unit tests i am getting fail

Schema errors for views.view.example_form_element with the following errors: views.view.example_form_element:display.default.display_options.filters.my_module.expose.example_element missing schema

I understand the error but i can't solve it. I tried a lot of combinations of schema.yml file name and content but without success result.

I will point out, that module name is

  my_modules

but

  example_element

is under

  my_module

current file looks like

file config/schema/my_modules.views.schema.yml

views.filter.views_example_element:
  type: views_filter
  label: 'xxx'
  mapping:
    expose:
      type: mapping
      label: 'Exposed'
      mapping:
        example_element:
          type: integer
          label: 'xxx'

file Plugin/views/filter/ViewsExampleElement

@ViewsFilter("views_example_element")

What is wrong with it?


texts: Exclude a single module from a Drush update?

texts:
Is there a way to exclude a module from a Drush update so it can be ignored when running eg 'drush up' ?

I ask because Rules 2.8 is causing problems with Drupal Commerce but it would be great if everything else could still be updated with Drush.


texts: How do I pass an object from javascript to PHP?

texts:
I set up a hook_menu like this:

$items['fleet/construct'] = array(
  'page callback' => 'construct_fleet',
  'type' => MENU_CALLBACK,
  'access arguments' => array('access content'),
);

Then I set up a js file with this:

$.post({
  url: '/fleet/construct/',
  data: {new_ships: [1,2,3,4], destroyed_ships: [5,6,7,8]},
  success: finalizeFleetResponse
});

How do I access the data from inside my menu callback function?


texts: Is there any hook to multiple total price only in payment method

texts:
Let think you want show 10000 USD in your site with 10 K$, I did it with hook_commerce_currency_info_alter and work correctly, ( I enter price in scale Thoundans, this mean when my product price is 20000, I enter 20 in price field ),everything in view is fine but my problem is in payment gateways, I want when user go to payment gateways multiple total price to 1000.

Is there any hook or clean to I achieve it in my module?

Or another way is achieve this job only in display, in all displays division to 1000 ( price /1000) and when go to payment gateway use origin price.


texts: Views grouping by day with count of nodes

texts:
I'm trying to show a view with # of nodes by day. That one is "relatively" simple - once you find out about this bug and use the workaround ;-)

I want to show another column that shows the count of nodes that have 0 comments.
I don't think this is possible to do in views?


texts: Is it possible to have three levels of subdomains in Drupal 7?

texts:
I know how to create a sub domains for Drupal website (I create a sub domain and add its folder in /sites folder). Out websites are multilingual so for every language I create a subdomain and in the end the sites are going to be like this :

fr.example.com
en.example.com
ar.example.com

and so on. we have also a few sites that are subset of our main website and we want to display them like this

fr.subset1.example.com

en.subset1.example.com

ar.subset1.example.com

fr.subset2.example.com

en.subset2.example.com

is it possible to implement such thing in Drupal 7?


texts:
I have a controller that passes a list of nodes to a template for rendering. I think I'm missing something simple.

I've tried this with no success:

public function content() {
  $students = $this->getStudents();

  return [
    '#theme' => 'dashboard',
    '#students' => $students,
  ];
}

private function getStudents() {
  $user = $this->currentUser();

  $nids = \Drupal::entityQuery('node')
    ->condition('type','student')
    ->condition('uid', $user->id())
    ->execute();
  $nodes = Node::loadMultiple($nids);
  return $nodes;
}

I have a dashboard theme function:

function dashboard_theme() {
  return [
    'dashboard' => [
    'variables' => ['students' => NULL],
    ],
  ];
}

And a twig template being called:

  {% for student in students %}

{{ student }}

  {% endfor %}

This blows up the page with the error Object of type Drupal\node\Entity\Node cannot be printed, which is no surprise, I'm just not sure what/how to send a proper object to twig.


texts: Syntaxhighlighter Insert do not working with CKEditor 4

texts: CKEditor 4 Drupal Module do not depend on Wysiwyg module, so after configuring Syntaxhighlighter Insert module i can not understand how to have the "Insert Code" button in CKEditor, because in CKEditor Plugins section there is no option to enable the button! if you follow this article (http://jordanjr.com/articles/drupal-7-syntax-highlighting-using-wysiwyg-ckeditor-and-syntax-highlighter) then you will see that they need wysiywg module, but now CKEditor do not need wysiywg module!.. any idea to solve this? here is the screenshot:


texts: spamspan not working, how to apply patch?

texts:
http://drupalcode.org/project/email.git/commitdiff/523cd0d

This is the link to the patch but looking up how to apply a patch I understand the command to use in terminal but I don't understand how to dload the patch?

What type of file is it saved as? and do you apply within modules folder or sites folder?


texts: Why is the http prefix being stripped out of my links?

texts:
I'm having the weirdest issue site-wide on a Drupal 7.23 website, when I create a link via the Link module or via the WYSIWYG like the following Link text and view the source on the page or node, it is rendered without the http prefix (Link text).

I've never seen this before, any ideas? I switched themes and turned off all modules, but it still does it.

I printed the render array function and it always prints with http://.

I have Google pagespeed on my server to compress the HTML and jQuery, has anyone heard of links having the 'http://' stripped from the href= before?


texts: How to disable the add to cart button if the shop owner does not have the premium role?

texts:
I created a marketplace (several stores on the same site) and the merchant can create a paid subscription to have the "Premium" role. Here's what I want to do:

The owner of a store has the role "Premium" = the website visitors have access to the button "Add to cart" on the product pages of his store.
The owner of a store does not have the role "Premium" = the website visitors do not have access to the button "Add to cart" on the product pages of his store.

How to disable the add to cart button (FOR VISITORS) if the owner of the store does not have the "Premium" role? *

Can I do that with a TWIG? If yes, how ?

Read my question. Depending on the role of the owner of a store, all users must be impacted.

WHY :

On my markerplace, I want to set up a paid subscription for sellers.

If the owner of a shop is not subscribed, he can not sell his products ("Added to Cart" button disabled).
If the owner of a shop is subscribed, he can sell his products (button "Added to cart" activated).

Whether the owner of a store is subscribed or not, everyone needs to see the stores and products. Only the "Add to Cart" button is impacted.


texts: Display Suite module is not displaying field labels

texts:
I am using the Display Suite module (version 7.x-1.9) and Drupal 7.37.

I selected above or inline in the Label column for all the fields, but I don't see the labels on my page for any fields.

I also don't see the display suite tab when I try to edit the page. If I want to change the layout, I have to go to admin > module > ds > configure to change the layout.

Can anyone help me workout what's happening?


texts:
I want to call uc_stock module by reference in my custom module. Actually I want to add and delete stocks. I have done this first using node_presave and it works successfully, here is the code:

function my_module_node_presave($node){
  if($node->type == 'add_stock') {
    //drupal_set_message('stock_save :'.print_r($node,true));
    //drupal_set_message($node->field_reference['und'][0]['nid']);
    //$nid=16;
    //$p_node = node_load($nid);
    //drupal_set_message($p_node->field_product_stock['und'][0]['value']);
    $product = $node->field_stock_value['und'][0]['value'];
    drupal_set_message('product :'.$product);
    $nid = $node->field_reference['und'][0]['nid'];
    drupal_set_message('nid :'.$nid);
    $p_node = node_load($nid);
    $stock = $p_node->field_product_stock['und'][0]['value'];
    drupal_set_message('stock :'.$stock);

    $stock = $product + $stock;
    drupal_set_message('Stock :'.$stock);
    $p_node->field_product_stock['und'][0]['value'] = $stock;
    //$p_node = node_load($nid);

    //drupal_set_message($p_node);
   // drupal_set_message('node_load :'.print_r($p_node,true));

    node_save($p_node);
    //drupal_set_message('after saving product');
  }
 elseif($node->type == 'sold_stock') {
   $new_product = $node->field_sold_stock['und'][0]['value'];
   drupal_set_message('new product :'.$new_product);
  $new_nid = $node->field_stock_reference['und'][0]['nid'];
   drupal_set_message('new nid :'.$new_nid);
   $new_node = node_load($new_nid);
  $sold_product = $new_node->field_product_stock['und'][0]['value'];
   drupal_set_message('sold product :'.$sold_product);
   $product_sold = $sold_product - $new_product;
   drupal_set_message('product sold :'.$product_sold);
   $new_node->field_product_stock['und'][0]['value'] = $product_sold;
   node_save($new_node);
 }
}

Now I want to do the same thing as done in uc_stock module of Ubercart.


texts: metatag_hreflang outputting extra hreflang tags

texts:
I need to generate hreflang tags in my website and I've installed metatag_hreflang submodule (belongs to metatag module)
It's now outputting the following
<link rel="alternate" hreflang="en" href="https://domain.com/ca/en/home" />
<link rel="alternate" hreflang="fr" href="https://domain.com/ca/fr/home" />
<link rel="alternate" hreflang="en-CA" href="https://domain.com/ca/en" />
<link rel="alternate" hreflang="fr-CA" href="https://domain.com/ca/fr" />

I don't need the extra "en" or "fr" I've already defined it at the bottom such as en-CA and fr-CA.
how do I get rid of the first 2 lines that it's outputting. This is not happening on other pages, it's only happening on the Homepage.


texts: Moving "vendor/" in a different location and symlinking it breaks drush

texts:
I'd like to have vendor/ moved out of the Drupal 8 root and symlink it. Composer doesn't have any problem with that (all commands work) but when I issue any drush command, even drush --version, it breaks.

Steps to reproduce:

$ composer create-project drupal-composer/drupal-project:8.x-dev website --stability dev --no-interaction --prefer-dist
$ cd website
$ mv vendor ..
$ ln -s ../vendor vendor
$ drush --version

PHP Warning:  require(/tmp/test1/vendor/composer/../../load.environment.php): failed to open stream: No such file or directory in /tmp/test1/vendor/composer/autoload_real.php on line 70
PHP Fatal error:  require(): Failed opening required '/tmp/test1/vendor/composer/../../load.environment.php' (include_path='/tmp/test1/vendor/pear/archive_tar:/tmp/test1/vendor/pear/console_getopt:/tmp/test1/vendor/pear/pear-core-minimal/src:/tmp/test1/vendor/pear/pear_exception:.:/usr/share/php') in /tmp/test1/vendor/composer/autoload_real.php on line 70

Full log: https://pastebin.com/raw/eMDgkdHV

Can I achieve this somehow? Even if I need to temporarily edit some path in an autoloader php script.

I need to do this on the vagrant based dev environment where I'd like to pull vendor/ out of the synced folder which is very very slow.


texts: Can I translate nodes and provide access to their translated content without the use of a site-wide language switcher?

texts:
Intended behaviour / question

Writer creates /node/5001
Translator translates /node/5001 to french using all the niceties of the Content Translation backend system
Visitor goes to /node/5001 and sees a link in the sidebar to the french version
Visitor arrives at /fr/node/5001, reads it, and then clicks away using one of the main menu links or anything in the sidebar
Visitor is now browsing the website in English, since that's the main language of the website, and the language menu links are written in. The viewing of translated content behaves just like viewing any other page on the website; it doesn't change languages for good.

Things are going wrong between steps 4 and 5, since step 4 puts the website in "French mode" which means all menu links point to french versions of content. In theory, all subsequent browsing will be in French (which is not what I want), and in practice the language will switch back and forth between French and English depending on the availability of translations (which is even worse), even though the URL will include the /fr/ prefix no matter what is actually displayed.

Is there a practical solution to this?

Background / supplemental

I've enabled Drupal 8's Content Translation and Language modules. Language detection & selection is done using the default mechanism, which recognizes language code prefixes in the first component of the website's path (for example, /fr/node/1, for the french version of node 1).

I'm now wondering if there's any way, without going toe to toe in a fight to the death with the Drupal final boss, to provide translations ONLY of the content on select pages, but NOT of the entire site, such that the content is made available through links on my website, with the default language being restored to English when navigating away from those same pages?

The intention is to use Drupal's built-in (though other non-core suggestions are welcome) translation management features to create and manage subordinate multilingual content on the backend, but then access these translations on a case by case basis through links in a block for example, without having these navigation actions trigger persistent language selection events (from a user perspective) which rewrite all the menu URLs to match.

Basically, I'm trying to get something to work that would be the Content Translation module equivalent of a bunch of multilingual PDFs attached to a single piece of English content. Except I don't want to link to PDFs, I want to link to ordinary web pages, with the only real difference being that they're written in another language, and linked to an English version behind the scenes.

Am I wasting my time with this, or is there a way to translate just a subset of my content, with access opened up to those translations from the english site, minus the persistence of a full-on language switch for the remainder of the browsing session?


texts:
How does one create the said Redirect a Users Name (Link) to a User Homepage in Panels Using Rules.

Here is my scenerio:

I have a Panels set which will show a subject posted content page in the left panel and the right panel will show a Dynamic list of users in a View, ultimately related to the subject page (ie by ZIP/Postcode, but thats for later).

I wish the View of usernames to then allow the reader to click the said users name (maybe pulled from Profile2 field name link) and take it to a Users (from the said Views) 'about' Homepage. I have pre-designed as a Content (custom) Node template page in the backend Structure for displaying the Users 'homepage'. (the said user will have priviledges to edit/amend via their DB, but that's for later). I'm thinking that this can be done via Views and presumed that a custom Rules Component needs to be created, but I'm stumbling at the next stage hurdle as to "what/where". I'm not sure if I would need to create a dedicated 'node' or whether it can simply be done via a View and if the Relationship elements come into for it to show dynamically to the end browsing user.
Later, the Views will also incorporate Location map nodes (ala Google M), but for now I'm happy with an end result showing a static homepage which would have the normal 'about us' text, photo image, 'Contact Us' etc, ala the old Myspace type page.

I have viewed many of Johan Falks' tutorials at http://vimeo.com/nodeone but am still stumped about my approach or whether I'm missing a further module component?

I'm sure this is very basic stuff, but any clarificiation on this process for a learning novice is appreciated. Thanks.


texts:
I have a custom sub-theme of the Seven theme. The Seven theme makes some node alteration via seven_form_node_form_alter(). I would like to have seven_form_node_form_alter() not run at all or I would like to overwrite it.  How can I accomplish this?

I tried hook_module_implements_alter() but there was no implementation of Seven in there. (I'm wondering if that only works with modules.)
Another thought was hook_theme_registry_alter() but I couldn't see anything there about form alters.


texts: How do I increase the memory assigned to PHP?

texts:
I have a script that saving the hundreds or thousands of nodes at one time and It is nearly impossible to manage it with Batch API. When I am running my script it saying :

  Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 16 bytes) in /home/staging-uls/www/sites/all/modules/token/token.module on line 461.

I set the memory using ini_set('memory_limit','256M'). My script is still so long that showing the error. Is there any other way to do so?

What my script is doing exactly:

It fetches a data from other site using cUrl. The data are articles, journals and some other user's data.
After getting the data in XML format, it adds each content.


texts:
I can't get the wildcard from a hook_menu to pass it to a callback function

Here is what I have:

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

    $items['spin/login/%'] = array(
        'title' => 'SPIN',
        'type' => MENU_CALLBACK,
        'access callback' => TRUE,
        'page callback' => 'spin_check_access'
    );

    return $items;
}

function spin_check_access($type = '') {
    echo $type; // type is never the %
}

Is it correct? I need the $type to be replaced with the wildcard's value.


texts:
I tried to install drupal commerce using following command as described in http://docs.drupalcommerce.org/v2/getting-started/install.html

composer create-project drupalcommerce/project-base mystore --stability dev

but it just shows the following line and stuck for long time

Loading composer repositorUpdating dependencies (including require-dev)

atlast I lost connection with my server so I tried again

composer update

but again same result

Loading composer repositorUpdating dependencies (including require-dev)
Killed

I want to know if there is anything I am missing ??


texts: Is it safe to send the unencoded JSON output?

texts:
The mobile app developers wants an api to get a list of articles from our Drupal site.
It should have these fields in the output:

nid
title
field_teaser_body

The api resonse has to be in JSON format.

The field type of field_teaser_body field is Long text and text processing is Plain text.

I created a custom code to get this working. Here's a simplified version of it.

$query = db_select('node', 'n');

$query
  ->fields('n', array('nid', 'title'))
  ->condition('n.status', 1)
  ->orderBy('n.created', 'DESC')

$result = $query->execute();

$nodes = array();
foreach ($result as $value) {
  $node = node_load($value->nid);

  $data = array(
    'nid' => $node->nid,
    'title' => $node->title,
    'field_teaser_body' => !empty($node->field_teaser_body['und'][0]['value']) ? check_plain($node->field_teaser_body['und'][0]['value']) : '',
  );

  $data = (object) $data;
  array_push($nodes, $data);
}

$content = new stdClass();
$content->nodes = $nodes;

print json_encode($content);

Just for the security purpose, I'm using check_plain() function to sanitize the teaser body text. But, when using this function, it encodes all special characters.

For e.g.,
Bob's height is > than Alice.
converts to
Bob&#039;s height is &gt; than Alice.

The mobile app developers said that they don't want any encoded text in the JSON output.

Is it a safe practice to send the unencoded (unsanitized) text in the JSON output ?


texts: new entity with entity metadata wraper and multiple collection fields, how set a first new collection field ?

texts:
I have one custom content. It contains a multiple collection field.
If I create a new entity (via entity_metadata_wraper), how can I set a new multiple collection field ?

by example :

$new_entity = entity_create('node', array('type'=>'custom content');
$new_entity_w = entity_metadata_wrapper('node',$new_entity);
...
$new_entity_w->a_new_multiple_collection_field[0]->some_field->set('...'); //(1) doesn't work
//$new_entity_w->a_new_multiple_collection_field[]->some_field->set('...'); //(2)doesn't work

Error for (1) :
Unable to set the data property some_field as the parent data structure is not set

Error for (2) :
PHP Fatal error : Cannot use [] for reading in /var/...

I didn't find...thank you for some help !


texts: Display menu edition form, try show only part of menu tree

texts:
I'm trying to display in my module editing form of a menu (the one with dragable items, $q=admin/structure/menu/manage/{menu_name}). Function I stumbled upon during research:

menu_tree_page_data
drupal_get_form
theme_menu_overview_form (cannot be called, core module function)

Ideally I would like to show user only part of the tree and let him edit only this part of the bigger menu. Has anyone of you played with such a thing?


texts: How to hide/remove a specific menu heading tittle

texts:
I have created a menu using Superfish containing the following items: "Menu 1," "Menu 2," "Menu 3," and "Contact."

When I click on each menu, the heading title is displayed. I want to hide the contact menu title. i was trying to hide it from the block but each menu doesn't have a block title.

How can I hide only the "Contact" menu heading title?


texts: Why comments replies are not showing as indented?

texts:
Why are comment replies not indented? I have already enabled comments threading in the settings for the content type.

All comments and their replies are shown in the same sequence and it is getting hard to find out to which comment another comment is replying.

I am using the Bootstrap theme. When I change the enabled them to the Bartik theme, comments are correctly shown as expected.


texts: Open Atrium search always resets the user's current language of site

texts:
I've a multilingual site which has 2 languages one is English running at www.example.com/en and another is french running at www.example.com/fr

Now, what oa_search module does is it checks the condition for search and then sends the search keyword to user or node according to the condition.

i.e. www/example.com/search/node/[search_keyword] or
www.example/com/search/user/[search_keyword]

I've found the following code (inside root/profiles/openatrium/modules/apps/oa_search/oa_search.js) responsible for this behaviour:

var path =  Drupal.settings.basePath +  'search' + '/' + (type === 'users' ? 'user' : 'node') + '/' + term;

The issue is every time I search a keyword the search is redirected to
www.example.com/search/node/[search_keyword] instead of www.example.com/[language_keyword]/search/node/[search_keyword]

as a result of which user's language is reset after making a search.

How to solve this problem??


texts: Change date format for the example dates given below date field

texts:
I'm using Drupal 7, with the latest date module release. I've added a date field to an event node type I created.  However, when I go to create a new event, the example date given (the date format description) underneath the date field uses the American date format of m/d/y. I want to change it so that the example date uses the English date format of d/m/y.  Can someone tell me how to do this.  I did change all the date formats in the date format section to UK date formats, but this hasn't made any difference.  I also changed the timezone to Europe, also with no effect.

I'm sure there is something simple I'm missing?


texts: Programmatically add dropdown to administration toolbar

texts:
I'm trying to add a dropdown menu to the administration toolbar for my custom module but it is not appearing. I have flushed the cache and disabled/renabled the module but with no avail. I am using Drupal 7 and my code is:

function reporter_workbench_menu() {
    $items = array();
    $items['admin/reporter'] = array(
        'title' => 'Reporter Workbench',
        'description' => 'Main menu item which should appear on the toolbar',
        'position' => 'left',
        'weight' => -100,
        'page callback' => 'system_admin_menu_block_page',
        'file' => 'system.admin.inc',
        'file path' => drupal_get_path('module', 'system'),
    );

    $items['admin/reporter/sub-menu-1'] = array(
        'title' => 'Sub menu item 1',
        'description' => 'Child of the menu appearing in toolbar.',
        'page callback' => 'reporter_workbench_section_edit',
        'type' => MENU_NORMAL_ITEM,
    );

    $items['admin/reporter/sub-menu-2'] = array(
        'title' => 'Sub menu item 2',
        'description' => 'Child of the menu appearing in toolbar.',
        'page callback' => 'reporter_workbench_section_edit',
        'type' => MENU_NORMAL_ITEM,
    );

    return $items;
}

How do I properly add a dropdown item to the administration tool bar such as hovering over the "Content" tab?


texts: Weird Drupal Error (The character encoding of the HTML document was not declared)

texts:
I have Drupal 7 with multiple taxonomies and recently for only one (the largest one) when I go to the following taxonomy page:

www.site.com/taxonomy/term/216746

all is fine.

Then when I click edit:

www.site.com/taxonomy/term/216746/edit

My screen goes blank and I see in the console that I get this error:

  The character encoding of the HTML document was not declared.  The
  document will render with garbled text in some browser
  configurations if the document contains characters from outside the
  US-ASCII range.  The character encoding of the page must to be
  declared in the document or in the transfer protocol.

This does not happen with any other taxonomy term and suggestions would be great. Also, I looked in the database and I notice any differences between the terms.


texts:
I wrote simple code:

function rah_cc_generate_form($form,$form_state){
    $form=array();

    $form['gen']=array(
        '#type' => 'fieldset',
        '#name' =>t('generate gift card code'),
        '#collapsible' => TRUE,
        '#collapsed' => false,
//        '#weight' => 5,

    );
    $form['gen']['code']=array(
            '#type' => 'textfield',
            '#title' => t('gift code'),
            //'#default_value' => '',
            '#prefix' => '
',
            '#suffix' => '
',
            '#size' => variable_get('rah_gc_code_size', 8),
            '#maxlength' => 20,
            //'#required' => TRUE,
    );
    $form['gen']['price']=array(
            '#type' => 'textfield',
            '#title' => t('price'),
            '#default_value' => 10000,
            '#size' => 10,
            '#maxlength' => 20,
            '#required' => TRUE,
    );

    $form['gen']['random']=array(
     '#type' => 'submit',
    '#value' => t('generate'),
    '#description' => t("if you want generate random use this plz"),
    //'#weight' => 1,
    //'#submit' => array('rah_cc_generate_random'), // If no javascript action.
    '#ajax' => array(
      'callback' => 'rah_cc_generate_ajax',
      'wrapper' => 'gc-code',
      'method' => 'replace',
      'effect' => 'fade',
      ),
   );

    $form['gen']['save']=array(
        '#type' => 'submit',
        '#value' =>t('save'),
         );

    return $form;

}
function rah_cc_generate_ajax(&$form,&$form_state){

    $form['gen']['code']['#value']=33;
  return $form['gen']['code'];

}

but it doesn't work: textfield is not replaced by the one that has value 33.

There is no JS error and AJAX request returns HTTP code 200.


texts: Accessing the fields of a content via theme file in Drupal 8

texts:
I have a content type called vanilla spice and it has various fields.
Afterward, I go ahead and create relevant content.

How can I display parts of that content type in my homepage?

In my themename.module I did the following:

function amarula_preprocess_page(&$variables) {
    $nid = 61;
    $node_storage = \Drupal::entityTypeManager()->getStorage('node');
    $node = $node_storage->load($nid);
    $variables['vanilla_node'] = $node->field_vanilla_heading->value;
}

In page--front.html.twig I tried to inspect the variable:

{{ kint(vanilla_node) }}

When I view the page, the variable shows as NULL.

How can I get the field values based on the node id?


texts: Can I add a page without clearing cache?

texts:
I have written a module by which user can add custom pages. Do I need to clear the cache every time user adds a page? Is there a way to adding pages without clearing cache? If yes what is it? and if no what's the function I should call?

Is hook_menu the only function I should put my code in it?

Does the Views module clear cache after submitting a new page?


texts: How to translate blocks content (created with views module) in drupal 6?

texts: I created blocks with views, my question is this: When you select a language, even the block content ( created with views )applies to me translated ?


texts: How to use the Leaflet 'maxBounds' option?

texts:
I'd like to restrict the panning of my leaflet map in Drupal.

The Leaflet documentation mentions the maxBounds option

And I'd like to know the best way to implement it for my map.


texts:
I have just installed XML Sitemap on a EC2 drupal 8 instance. I am seeing the following error message in the admin report status page:

XML sitemap cache directory
Not found or not writable
The directory public://xmlsitemap was not found or is not writable by the server.
See http://drupal.org/node/34025 for more information.

The provided link is broken. I have done some reading and created a /xmlsitemap directory in /var/www/html (which is the root of my drupal installation). I chmod it to give rwx access to everyone (a+).

But, the issue remains. I cannot generate the cache files.

How can I solve this issue?


texts: Use Exposed Filter value in no result Global text

texts:
I'd like to use the value of the chosen Exposed Filter (=dropdownlist) in the Global text block when there is no result.

In detail:
Exposed filter (which is a taxonomy list) has 3 values of provinces:

Province 1
Province 2
Province 3

When there is no result using a chosen value, there should be a message (= global text, I presume), saying "Sorry, there are no addresses found in Province 2".

Is this feasible in Drupal views?


texts: All visited urls ending with _900 in cache_page tables

texts: I came across strange problem with drupal 7 and caching for anonymous users. After clearing cache, newly visited pages by anonymous users are stored in cache_page with _900 at the end of url like this www.example.com/examplepage_900. Anybody know what can cause this behavior?


texts: Restrict the node local tabs access to specific content types

texts:
I have a module_name.links.tasks.yml file for Drupal 8, whose content is the following one.

entity.node.module_admin:
  route_name: module_name.admin
  base_route: entity.node.canonical
  title: Admin Page
  weight: 99

entity.node.check_backend:
  route_name: module_name.check-backend
  base_route: entity.node.canonical
  title: Check Backend
  weight: 100

entity.node.download_webagent:
  route_name: module_name.download_webagent
  base_route: entity.node.canonical
  title: Download Webagent.conf
  weight: 101

entity.node.download_httpdconf:
  route_name: module_name.download_httpdconf
  base_route: entity.node.canonical
  title: Download httpd.conf
  weight: 102

These tabs appear in all the content type nodes. How can I restrict them to  specific content types?


texts: I m using Drupal 7 with the Webform module to send email. On a form I have checkbox to send yourself an email copy. When it is checked, there will be a field to enter the email of who sends the email. The email should be send to this address also.


texts: How do I remove a character from the replacement pattern?

texts:
In view I call the field field_store_car_model

settings of this field:

formatter: link
result URL is:veyron-164

So far as expected.

But I need this URL: vehicles/veyron-164.
Because of this I have to rewrite the link.

I check rewrite result, format is plain text, I write in the field vehicle/[field_store_car_model]

Result here: vehicles/veyron-16.4.

Now I have this punctuation in the URL! where does the decimal point come from?
From my vocab because view grabs the term BEFORE pathauto cleans it up.

So how can I get rid of the decimal point?
I am sure there is some PHP but WHERE I have to put the PHP code?

Any ideas?


texts: MegaDrupal MD.Foto: Module dependency displaying incompatibility status

texts:
I've downloaded the MegaDrupal MD.Foto theme. The feature module for MD.Foto has a few dependencies. One of the dependancies is on Chaos Tools, which I loaded. After doing so, I noticed that the Panels module began displaying the incompatibility message:

Requires: Panels (disabled), Chaos tools (>=1.4) (incompatible with version 7.x-1.2)

What do I need to do to correct this?


texts: How do I use the Video module with Colorbox?

texts:
I am using the Video module, and I want to show videos on Colorbox. I have also found a patch for that, but I don't understand something.

I am using the most recent versions.

Colorbox: 7.x-2.3
Video: 7.x-2.9


texts: How do I add tags to Advanced Forum posts

texts: I would like to add the type of tags this stackexchange forum has, so users can tag their posts and the tags appear at bottom of all posts. How do I do that?


texts: Add image field or other fields from node to a custom Block in Drupal 8

texts:
I am new to Drupal and I am learning pretty fast.
However I am stuck on an issue.

I need to make a custom Block for my content (node) images.

There is a system-made content block which pulls from the node form of content type "Basic Page". I've added a "Image upload field" to that so I can upload images within my content.

I am able to render the field on the page after adding the content block to the content region, However, I need to show just that image of that node in some other region.

How can I do this?


texts: Total number of nodes based on content type

texts:
I have 3 content types and I want to add a section to my site that displays the total number of nodes that each content type has.

However I don't want them to display per content type, i want the total number of all 3 to appear.

So basically nodes in A + B + C = total number of nodes

Is this possible?


texts: Are the revision settings on a content type respected when the content is changed programatically?

texts:
I want to practice making some bulk updates via code, but I also want the option of reverting back to an earlier versions in case some of the changes are incorrect.

Are the revision settings respected when revisioning by default is enabled for a content type?


texts: How to use date_make_date() in drupal 7?

texts:
I am porting custom module from drupal 6 to drupal 7
I have the following code:

 $local_date = new DateTime($dateTxt);
 $iso_date_string = date_format_date($local_date, 'custom', 'Y-m-d\TH:i:s');
 $utc_date = date_make_date($iso_date_string, $user_timezone_name, DATE_DATETIME);

What can be the alternative for date_make_time() in drupal 7?

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

  this error is due to a change in the Date API module, instead of
  date_make_date you need to use the new DateObject class. see "D7
  Changes" here: http://drupal.org/project/date

  I fixed this as follows, but not sure if I'm using the DateObject
  properly.

  Edit this block of code in agenda.module, line 354

  // If the Date API is installed, we can do better at DST times   if (module_exists('date_api')) {
    $start               = date_make_date($event['start timestamp'], NULL, DATE_UNIX);
    $event['start time'] = date_format_date($start, 'custom', $block->timeformat);
    $end                 = date_make_date($event['end timestamp'], NULL, DATE_UNIX);
    $event['end time']   = date_format_date($end, 'custom', $block->timeformat);   }

replace with

  // If the Date API is installed, we can do better at DST times   if (module_exists('date_api')) {
    $start               = new DateObject($event['start timestamp'], NULL);
    $event['start time'] = $start->format($block->timeformat);
    $end                 = new DateObject($event['end timestamp'], NULL);
    $event['end time']   = $end->format($block->timeformat);   } alternatively, just comment out the whole block.

I looked in the above node but not sure about the new DateObject() ?

new DateObject()


texts:
I'm running D7 on a php-fpm/nginx stack.

I want to test out some different combinations of cache lifetime and crawler frequency and see how it affects my page cache hit rate. What is the easiest (and reasonably performant) way to create a log with time | url | ip | hit/miss for the built-in page cache.


texts: Search API - Acquia Search - Keyword Search

texts:
I'm using Acquia Search for searching within certain content types (articles, posts, etc). It seems to work for certain keywords but not others. For example, if I search: "Apple TV", I'm expecting the article title: "Spectrum Launches on Apple TV, Offers Apple TV 4K to Customers" to show up (which it does). However, if I search for "4K" the search API brings back "no results".

I reviewed our Acquia connector set up, re-indexed all content and tried with no success. The weird thing is, if I search "4K to customers" it shows the correct article with "4K" also being highlighted (in search results). Does any one have any idea why this would happen? It seems that our config is set up to read basically every field in each content type included and it does seem that this article is indexed. Does anyone have an idea to point me in the right direction?

I'm using the latest versions of Acquia connector, acquia search, search API and Drupal 8.


texts: entity_reference field widget as select instead of autocomplete

texts:
Is there a select widget I can use instead of autocomplete for referencing entities? Right now I am using this in my baseFieldDefinitions function:

->setDisplayOptions('form', array(
    'type' => 'entity_reference_autocomplete',
    'settings' => array(
      'match_operator' => 'CONTAINS',
      'size' => 60,
      'placeholder' => '',
    ),
  ))

but I need to have a select widget instead. Any ideas?


texts: Hide the option of Payment method "No Payment Required" based on user role

texts:
I used module "No payment required" for giving extra payment method as per my client requirement.

I created a site with two user roles: 1. Merchant, 2. Customer.

Option "No payment required" should only display to users with "Customer" role, which is given permission by Merchant. I have searched in google but there is no luck.


texts: Module installation in D8.3.6 was possible, using D8.3.7 the same module couldn't be installed

texts:
I have installed the "Serial field" module with the file serial-7.x-1.8.zip in D8.3.6
I have tried to install with the same zip file in  D8.3.7 and it is coming wih the error message "serial-7.x-1.8.zip does not contain any .info.yml files. "

I've found general info that  ..yml file is required in D8, but is this requirement raised in D8.3.7 first and in D8.3.6 still was possible w/o ..yml?


texts: Hi I have a content containing one date field, it is an empty date field. I mean there is no current date value. when author clicks on that date field and he assigns one date that may be any date on future. What date he will give in future, on that date in future I have  to trigger a mail to him.


texts: Is there an easy way to update img src attributes when moving to a new server?

texts:
I recently copied my site from the dev server to a test server, and I noticed that a lot of images which were placed using the Media module have src= attributes that point to the old server.  Ie., <img src='http://oldsite.com'...> I don't see any settings within the configurable options for the Media module which will update the links.

I know that WordPress has a handy link updater plug-in called Velvet Blue, or something like that.  Does anyone know of a similar module for Drupal?


texts: How to connect to multiple Databases in Drupal 7?

texts:
I'm building an encyclopedia website. There are about 20 subjects that must be stored in the Database (media,library,article,translations,...) and we want to create 20 databases and allocate one DB for every subject. is it possible to do such thing? The main site has 3 sub domains and every sub domain covers specific rows of the subjects. for example the library is a subject and math.mainsite.com must have access only to the math type of the library subject.

the sub-domains must not have not any data, they all should get their data from the 20 above mentioned DBs, so every site must connect to 20 DB.

We selected this strategy because the subjects are subdomain as well, I mean library.mainsite.com and article.mainsite.com and ... are valid urls.

thanks


texts: How to link up a view created page using hook_menu

texts:
I have created a page using view and defined a path for the view. I want to add a tab using MENU_LOCAL_TASK from hook_menu() How can I add a link to the view for the page callback?

EDIT

I have tried this but does not work.

$items['user/%/my-fees'] = array(
        'title' => 'My Fees',
        'description' => 'Student Payment Schedule ',
        'page callback' => 'views_embed_view',
        'page arguments' => array('payment_schedules', 'user_fees', 1),
        'type' => MENU_LOCAL_TASK,
    );


texts: Command option to ignore errors during drush dl

texts:
Just trying to start creating prefab lists (of modules etc.) and building my site development environment at the moment. I'm trying to call sudo drush dl (list of modules) and it works until it can't find one and stops the entire process.

Is there a switch I can use to get drush to continue through the list and perhaps even list the terms which failed to download (not important). I've just seen a sentence alluding to creating your own drush commands, but figured I'd check the community first as that could take a big chunk of scarce time!

Thank you for contributing to this great site, hopefully one day I can return the favour!


texts: Using theme hook suggestions for webform confirmation page

texts:
I've been trying for the last couple of hours and failing to use theme_hook_suggestions for custom webform confirmation templates.  I want all webforms on a specific content type to use a particular confirmation page template.

So I've got the following in webform_confirmation.preprocess.inc (I'm using Omega4 which puts preprocess functions into include files):

function foeomega_preprocess_webform_confirmation(&$vars) {

  $vars['theme_hook_suggestions'][] = 'webform_confirmation__' . $vars['node']->type;
  ...
}

Then I have 2 template files:

webform-confirmation.tpl.php = The generic one I want to override
webform-confirmation--myspecialnode.tpl.php = The new one I want to use instead

No matter how many times I 'drush cc all'/'drush cc theme-register' the suggestion template is never picked up :(

However, I did get the suggestion to work if I commented out the following in webform.module file:

function webform_theme() {

...

  'webform_form' => array(
  'render element' => 'form',
  'template' => 'templates/webform-form',
  // I COMMENTED THIS OUT: 'pattern' => 'webform_form_[0-9]+',
),

...

}

Leading me to believe that pattern and suggestions are not compatible - however I can't find any information on this by Googling - can anyone confirm/deny?

Thinking that 'pattern' and 'theme_hook_suggestions' don't mix, I tried implementing the following in my template.php file:

function foeomega_theme_registry_alter(&$theme_registry) {
  if($theme_registry['webform_confirmation']['pattern']) {
    unset($theme_registry['webform_confirmation']['pattern']);
  }
}

This did seem to remove it from the registry, but alas, the generic template file was still being used (after make 'drush cc ...' commands...).

Any ideas?  I'd really like to have nice content-type specific confirmation pages?

Many thanks,
Chris :)


texts: At the moment I've got 2 drupal 7 site. Now I want to merge those two sites together. If I export the user table in the database from one site and import the data directly into another site, will that be working? Btw, The users don't have any related contents like nodes or comments in the site so I guess the only table I need to worry about the user table. The only concern is the password. I'm not sure if I import the data the user password will be the same.


texts: How do I use a display mode for anonymous users, and another one for logged-in users?

texts:
I would like to change the display mode only for entity.node.canonical, so that a logged-in user would see something completely different than anonymous users.

For example, an entity displayed by an entity reference field should be displayed in teaser mode for anonymous users, and in full mode for logged-in users.

How can I achieve this?


texts: Select list ajax callback fire only once to update textfield

texts:
I face an issue when fire ajax callback function in my coding. I have a select list and a text box. If there is any change in select list field, the text box will be updated by selected value. I added my code in form_alter function. But, it fired only one time. Below is my code.

 function field_collection_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'employee_performance_node_form') {

$form['field_my_weight_select'][LANGUAGE_NONE]['#ajax']= array(
      'callback' => 'custom_test_entity_callback',
      'wrapper' =>'custom_test_entity_wrapper',
      'method' => 'replace',
      'effect' => 'fade',
      'event' => 'change',
    );

$form['field_text_for_test']['#prefix']='
';
$form['field_text_for_test']['#suffix']='
';

if(isset($form_state['values']['field_my_weight_select'])){
      $content_type = $form_state['values']['field_my_weight_select'][LANGUAGE_NONE][0]['value'];
      $form["field_text_for_test"][LANGUAGE_NONE][0]['value']['#value']=$content_type;
    }
    else{ $form["field_text_for_test"][LANGUAGE_NONE][0]['value']['#value']=1;}
}
}

function custom_test_entity_callback($form, $form_state){
  return $form['field_text_for_test'];
}

Could you tell me what is wrong in my code??

Thank you


texts: So I have the module import_html and I'm trying to figure out if there is a way to periodically invoke it so that it imports new html files. Is there a way to periodically invoke modules with a script? I'm hoping someone can direct me to a good starting source as I am really new to Drupal.


texts: Prepopulate from link in content only visible to users tagged within that content

texts:
I have two content types, Parent and Child. Parent contains a list of tagged users which may create Child. Child contains the tag of the Parent.

On the Parent page I need a link, which is only visible to people tagged in it, to create a new Child with the Parent already tagged in it.

I know I need to use something like Entity Reference Prepopulate but my problem is that I can't figure out how to make the link.

This seems like it should be a simple thing to do but I can't for the life of me figure out how!

The requirement is that this should only use the UI and without editing any .php files as there is no guarantee that other devs will be able to code and allows easy visual recognition of what has changed.

Any advice would be greatly appreciated.


texts: How to copy Location Country field value from Parent object to Child object field default value?

texts:
I use Parent and Child content types with a Field used in both types.

I would like Drupal to automatically propagate the Field value from Parent value to the Child field default value.

How to do this ?
I am interested specificaly in an example for Location>Country field.

I use node reference or organic groups modules to set up Parent<->Child relationships.


texts: Reaction rule throws exception when previewing node

texts:
I have very simple reaction rule condition 'Node is Type' in Drupal 8 (8.5.3) Rules module (8.x-3.0-alpha3):

Data selector: @node.node_route_context:node

(Note: the mentioned issue occurs also for simple value node in the data selector.)

Content types: page

It works well when a node is viewed, but the rule causes crash with the error message The website encountered an unexpected error. Please try again later. when a node is previewed (button 'Preview' is clicked on the node form).

Note: To replicate the issue you should clear the cache on node form before hitting the 'Preview' button to ensure the node isn't served from the Drupal cache in which case Rules aren't fired.

The logged Error Message is:

Drupal\rules\Exception\EvaluationException: The context for node is NULL,
but the context node in rules_node_is_of_type requires a value.

Any hints on better Rules condition to catch the node type, or a patch for Rules?

Thank you!


texts: How to restrict a module to a specific core version?

texts:
Drupal 8.3 introduced some changes, which broke a custom module; fixing the changes causes the module to break in previous Drupal versions. One way to handle this would be to require Drupal core to above version 8.3+ for this module. However, the following changes to YAML file does not work.

core: '8.3'
core: '8.3.x'

Drupal shows the following incompatibility message.

  This version is not compatible with Drupal 8.x and should be replaced.

The official documentation does not provide useful information for core keyword.

So how should Drupal core version requirement specified in the .info file? If not, is there any other way to specify such requirement?


texts: How to show users who have not flagged a node with any flag?

texts:
Drupal 7. I have a content type that can be flagged with 3 different flags. I need to display a view of users who have not flagged any of them.

The users that are allowed to flag are listed in an entity reference field on the node. My view is a content view that has the relationship to the entity reference list to get the users, then I have a relationship to Flags: User's flaggings for each of the different flags. There is also a Contextual Filter for the current node.

When I add a filter for Flags: Flagged (False) related by the User's Flagging, it seems to check if the user has flagged any content with that flag, not just the current node.

Looking at the flagging table, it seems like I need to do some kind of combined column check. I need to know if the uid has any entries in the table with the same entity_id (node id in this case).

Will I have to alter the query in code? Any hints on that would be great too. Otherwise, if it can be done in the UI, that would be nice.


texts: How can I assign a database for each user?

texts:
I am new to Drupal and facing problems. I want to assign a database for each user where user can edit, delete or make entry to their database table.

For example I want to develop a database management system for doctors so that each doctor has their own patient database with scanned image of report, patient name, address, description, sex etc so that they can keep track of their patients. How can I implement it in Drupal 8?


texts: How is it possible to place a custom block inside the admin area? (e.g. in a node edit form)? I tried with page restriction but with no success. How can I see the block regions of the admin theme (seven)?


texts:
I need to build a "blog archives" block with Views 3. I've seen (and am currently using) the solution at Archive block for nodes using Views, but this method doesn't allow specific enough paths.

Following the linked method, the summary output relies on the selected context filter. For example, if you use Content: Created Year+Month, your links turn out like base_path/YYYYMM - no separation between month and year. Likewise, if you use the Content: Created Year or Content: Created Date contextual filters you get a string output... not that great for organization.

Is it possible to generate a link path like base_path/YYYY/MM instead of a mixed string? I have attempted to create this solution using aggregation, count and grouped Views fields with no luck.


texts: How to display single fields in multiple line in VIEWS?

texts:
How to display single fields in multiple line in view.

Example : Address contain multiple lines so each items show on line by line.


texts: What is the correct way to get the value of a field?

texts:
We have several fields on the Article content type such as field_headline (plain text field). When we try to access the value of this field in a module hook such as mymodule_preprocess_page (mymodule.module), we have found several ways to do it.

What is the correct way to get the value of the fields?

Example:

function mymodule_preprocess_page(&$variables) {
  $node = $variables['node'];

  // These both work.
  $node->get('field_headline')->value;
  $node->get('field_headline')->first()->getValue()['value'];
}


texts: Using hook_js_alter to change localsettings variable in the autologout module drupal

texts:
I want to know how to use hook_js_alter to change the localSettings variable in autologout.js.

In autologout.module in line number ( 377 - 389)

$settings = array(
    'timeout' => $refresh_only ? ($timeout * 500) : ($timeout * 1000),
    'timeout_padding' => $timeout_padding * 1000,
    'message' => t('@msg', array('@msg' => $msg)),
    'redirect_url' => url($redirect_url, array('query' => $redirect_query)),
    'title' => t('@name Alert', array('@name' => variable_get('site_name', 'Drupal'))),
    'refresh_only' => $refresh_only,
    'no_dialog' => $no_dialog,
  );
drupal_add_js(array('autologout' => $settings), 'setting');
drupal_add_js(drupal_get_path('module', 'autologout') . "/autologout.js");

In this it passes the settings variable to the javascript file.

I want to change
" 'title' => t('@name Alert', array('@name' => variable_get('site_name', 'Drupal')))," attribute using "hook_js_alter" in my custom module so that javscript takes the new value.


texts: How can we view the latest unpublished version of a node even if a previous revision was published?

texts:
The scenario: All staff have "View any unpublished". They edit a node a few times, publish it, then un-publish it (because they decide it's not ready). Then they edit a few more revisions. Now they want to send it to someone who only has view permission for review before making it public again.
This is the problem: When they go to view the node they see the version that was at one time published. Therefore in view mode some of the recent changes are not visible.
Viewing the latest revision in the revision tab doesn't see to be a workaround, if the latest revision is selected we still see the latest published version - and the route is exactly the same as the "view" route.
I think there may be a core bug for this already but I can't locate it.
I have run this through the debugger and I can see the revision id's being swapped out. I didn't get time to figure out the logic completely.
I started to think it might be related to this bug from Workbench Moderation which was the original source of the "View all unpublished" permission:
I tried making a view of all revisions to see if I could find a problematic revision id with no success. On some nodes all revisions are unpublished but we do not see the latest one on the "View" route. I also tried the workspaces module since that would be very close to what we need here but that seemed to cause other issues of a similar nature. I had one node that wouldn't save at all with workspaces enabled due to some validation around publication status.
How can I make this scenario work for the editors with "View all unpublished"?


texts: How can I import and export Drupal Commerce Products?

texts:
I have a Drupal 7 site and installed the Drupal Commerce module.
In which I have added Commerce Product with Category like:

Software Products
Hardware Products
Electronics
Others

  I would like to Export those Commerce Products from My Development
  Server to Production Server.

So, for that we have any modules available in Drupal.org so, I can export the Commerce Products and Import to my server.

I found the Node_Export module, but it only applies to exporting the nodes. It does not apply to Commerce Products.

Anyone has an idea how I can Import/Export the Commerce Module Products?
I think it is general problem who are using the Commerce Module of Product (but not sure).


texts: How can I display comments/comment form with a custom module?

texts:
I have created a module which returns a render array via page callback in hook_menu. The render array contains several arrays that render markup and tables (and data from a particualr node: passed in by a wildcard in the submitted URL). At the bottom of the rendered page I would like the comments and the comments form to be displayed.  My plan is to get the comments via a database query, put them into an array and add them to the render array. For the comments form I was going to use the following code:

    $comment = new stdClass;
    $comment -> nid = $nid;
    $form = drupal_get_form('comment_form', $comment);
    return $form;

How do I append this to my page callback function so that my table/markup render arrays and comments/comments form appear on the outputted page?

Thanks. Hope this makes sense. I'm open to changing my plan if you think there's a better approach.


texts: How to switch logo and menu links based on subdomain?

texts:
my D7 site will be accessible from 4 different subdomains:
- a.site.com
- b.site.com
- c.site.com
- www.site.com (or just site.com)

I already enabled a domain cookie for .site.com and the login works across all subdomains.

Now I want to be able to show a different logo logo based on the subdomain and I also want to be able to switch the main menu links.

I tried the context module but didn't find a way to detect the subdomain.

I don't want to use the domain access module. I was thinking about modifying the theme to switch the logos. Can I do the same for the menu links?

Does anyone have a  better idea?


texts:
I am working on my theme in Drupal 8 and I want to add a class to my header div. I tried adding this to the region.vars.php file.

if ($region === 'header') {
  $variables[header]['class'][] = 'navbar-right';
}

It's not working, though. This is the complete region.vars.php file.

<?php
/**
 * @file
 * region.vars.php
 */

use Drupal\Core\Template\Attribute;

/**
 * Implements hook_preprocess_region().
 */
function bootstrap_preprocess_region(&$variables) {
  $region = $variables['elements']['#region'];
  $variables['region'] = $region;
  $variables['content'] = $variables['elements']['#children'];

  $theme = \Drupal::theme()->getActiveTheme()->getName();

  // Content region.
  if ($region === 'content') {
    // @todo is this actually used properly?
    $variables['theme_hook_suggestions'][] = 'region__no_wrapper';
  }
  // Help region.
  elseif ($region === 'help' && !empty($variables['content'])) {
    $content = $variables['content'];
    $variables['content'] = array(
      'icon' => array(
        '#markup' => _bootstrap_icon('question-sign'),
      ),
      'content' => array(
        '#markup' => $content,
      ),
    );
    $variables['attributes']['class'][] = 'alert';
    $variables['attributes']['class'][] = 'alert-info';
    $variables['attributes']['class'][] = 'messages';
    $variables['attributes']['class'][] = 'info';
  }

  // Support for "well" classes in regions.
  static $wells;
  if (!isset($wells)) {
    foreach (system_region_list($theme) as $name => $title) {
      $wells[$name] = bootstrap_setting('region_well-' . $name);
    }
  }
  if (!empty($wells[$region])) {
    $variables['attributes']['class'][] = $wells[$region];
  }

   if ($region === 'header') {
    $variables[header]['class'][] = 'navbar-right';
  }

}

I got most of this code from the Drupal 8 bootstrap theme. Everything else is working.


texts: How to remove colon in a label which is not in a form - D6

texts:
How can I remove colon from the labels which is not in a form?

If it is a form, themename_form_element() can be used, but my question isn't related to forms.

For example, I need to remove colons from the profile view page. How can I do that?

I would like to do this the "Drupal way" (meaning not using JavaScript/jQuery)

Thanks in advance.


texts: Query a list of field values of a node in drupal 7

texts:
I am new to drupal 7, I have a question and hope to receive your helpful responses! :D

I've created a new content type named 'school', and create a custom 'city' field in it.
After that, I create two new nodes of 'school', and their city are 'London' and 'Beijing'.
How can I get a list of city of schools programmatically in Drupal 7?

Any help will be appreciated!


texts: Block configuration form values are not translated

texts:
I have the following code in my custom block:

    public function blockForm($form, FormStateInterface $form_state) {
    $form = parent::blockForm($form, $form_state);

    $config = $this->getConfiguration();

    $form['headline'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Block headline'),
      '#default_value' => isset($config['headline']) ? $config['headline'] : NULL,
      '#required' => TRUE,
    );

      return $form;
    }

and:

    public function blockSubmit($form, FormStateInterface $form_state) {
      $this->setConfigurationValue('headline', $form_state->getValue('headline'));
    }

The configuration is saved correctly, but only for English language.
The block translation doesn't show my variable (headline) in the translatable configuration.
What am I doing wrong?

Thanks


texts: Access row value in template_preprocess_views_view_fields(&$variables)

texts:
In template_preprocess_views_view_fields(&$variables), when I print $variables['row'], I get the following object.

How can I access values inside the node entity?

I tried with the following code, but it is not working.

$variables['row']->_entity->values['field_file_pdf_upload']->target_id


texts: Alternative Top Menu bar for logged in users only via their Role

texts:
I want to have an alternative top menu bar for certain Roles when they are logged in. For example, 'Teachers' have one top menu bar, 'Students' have another type.

For now, I want to do this using Rules, is this a good approach or is there an easier way. Simple functionality is the key here so at this time I'm not looking to hack tpl.php files as I just want to get something working for demo purposes.

I'm using Bootstrap and happy to stay that way for the future.

Any suggestions & advice on the above, most welcome. Thanks in advance.


texts: Create a view to display the list of content created by user

texts:
I want to create a view for each individual user of my site which would display the content create by that logged in user only, i.e, When a user logs in, then when he clicks a tab (i am using quicktab here) a view appears which shows all the content that this user only has created. I do not want to show this user content created by others. Is there any efficient way to do so. I am using Views3.

Thanks for your time


texts: Iconfont not displaying when CDN is enabled

texts:
I am using the Icon module to display iconfonts on my Drupal 7 site and they work fine until I enable the CDN module. Upon enabling the CDN module, the iconfonts are displayed as blank squares and the console displays the following error message:

  Font from origin http://CDN_URL has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin http://SITE_URL is therefore not allowed access.

The browsers tested are:

Google Chrome Version 38.0.2114.2 dev (64-bit) - Iconfonts are blank squares
Apple Safari Version 7.0.5 (9537.77.4) - Working fine
Mozilla Firefox 32.0 - Iconfonts are squares with the \eXXX code

I have tried to add the following lines to the htaccess file in my root directory, but that did not work.

# Apache config
<FilesMatch ".(eot|ttf|otf|woff)">
    Header set Access-Control-Allow-Origin "*"
</FilesMatch>

Any advice would be greatly appreciated.


texts: How can I print Views language-specific $field variable values inside a views template?

texts:
I am using Views with "Format Show:Content" instead of "... fields."

I have a multilingual website. In the filters section of Views I have Content: language = user's default language. However, Views refuses to honor this filter selection.

I am also using views-view-fields.tpl.php file to output the fields. currently it is calling, for example, $fields->content to output content.

How can I get Views in Show Content format to honor the language filter? I am familiar with needing to add the 'und' key to certain fields at times, but do I need to do that here? Should adding the filter in the view not be enough? If I do need to add the key where does it go?

If you want, you can see the error in the slideshow at http://goniseko.com


texts: Add cutom body class when view is not return any results

texts: I know how to add additional class by preprocess function but I need to combine it with the view. So the new custom class should be added if my view returns 0 results. It looks like I can't use hook_views_pre_build because there's no vars for page elements. Any thoughts how to achieve it?