texts: Can't change quantity of line item with rules

texts:
I created a rule that checks for the quantity of a product while adding to cart and while proceeding to the second step of checking out.  The action sends a warning message to the site that says you can't have over one qty of the 'gift card' product type and is also supposed to set the quantity back to 1.  The problem is that while the message appears when it is supposed to, the quantity is not being set back to 1 at any point.  I made sure that I also save the cart after changing quantity as well.

Here is the rule export:

{ "rules_1_gift_card_per_cart" : {
    "LABEL" : "1 Gift Card per cart",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "rules_conditional", "commerce_cart", "commerce_rules_extra" ],
    "ON" : [ "commerce_cart_product_add", "line_item_quantity_changed" ],
    "IF" : [
      { "data_is" : { "data" : [ "commerce-product:type" ], "value" : "gift_certificate" } },
      { "AND" : [
          { "data_is" : {
              "data" : [ "commerce-line-item:quantity" ],
              "op" : "\u003E",
              "value" : "1"
            }
          }
        ]
      }
    ],
    "DO" : [
      { "CONDITIONAL" : [
          {
            "IF" : { "data_is" : {
                "data" : [ "commerce-line-item:quantity" ],
                "op" : "\u003E",
                "value" : "1"
              }
            },
            "DO" : [
              { "data_set" : { "data" : [ "commerce-line-item:quantity" ], "value" : "1" } },
              { "entity_save" : { "data" : [ "commerce-order" ] } },
              { "drupal_message" : { "message" : "Only one gift card per order.", "type" : "warning" } }
            ]
          }
        ]
      }
    ]
  }
}

EDIT: I dpm($commerce_line_item) in the action as well and it actually says the quantity is 1 while the cart display is still showing 2, though I believe this is only per item qty in the cart.

The total of the order is still being updated when the gift card quantity is being increased.

EDIT 2: I created a custom rules action to manually update the quantity in the commerce_line_item table which also does not seem to work:

function commerce_giftcards_action_change_qty_one($current_order, $current_line_item) {
  dpm('Current Order ID: ' . $current_order->order_number);
  dpm('Updated Line Item ID: ' . $current_line_item->line_item_id);
  dpm('Updated Line Item Type: ' . $current_line_item->type);

  db_update('commerce_line_item')
    ->fields(array('quantity' => '1.00'))
    ->condition('line_item_id', $current_line_item->line_item_id, '=')
    ->execute();

}

The correct fields are printing in the messages but the database is not updating unless I am going back to the product's page and adding another to the cart.  It only keeps the quantity at 1 if I hit add to cart more than once.  If I change the quantity of the item on the cart page it still increases the quantity in the database while also displaying the message that says only 1 qty of that item is allowed.


texts:
I installed VFV as recommended in one of the questions here, as it seems to be exactly what I need for complex listings. But now my View used to list content nodes bound to a specific term stopped listing them.

Before I wrote that statement I uninstalled the VFV module and the View began working back again. I repeated that operation twice for certainty sake.

Maybe I'm overlooking some option somewhere, but why would one module actually impact the other?

I wouldn't like to give up VFV, really.


texts: What is the best way to preprocess fields with Display Suite

texts: I'm using Display Suite with Drupal Commerce, and I need to pre-process some fields in my product display.  I need to change some values based on some conditions, and need to wrap a few fields in some markup.  Should I write a hook to pre-process and change the values, and use a template to wrap the fields in markup?  If so, which template file would I use, because DS comes with a few templates.


texts:
I have a menu that should look like this:

xx

xx

xx

You can see, that the first ul has a class and the submenu ul doesn't have.

I am using this code to add class to the ul.

function mytheme_menu_tree__menu_mymenu($variables) {
    return '
' . $variables['tree'] . '
';
}

But it adds that class to the all submenus.

xx

xx

xx

Is there any way to theme the sub menu? Thank you.


texts: How do I add secondary tabs to the user (profile) edit tab?

texts: In earlier versions of Drupal, there were categories of users which showed up as tabs on the user (profile) edit page, located at /user/{user}/edit. How can we define new tabs on this page in Drupal 8?


texts:
To recap: I previously built a site in Drupal 7 which showed the availability of two apartments for rent, using the Availability Calendars module. The client easily selected dates and marked them available, booked or unavailable, and the result showed in 3 months of fullcalendar on the frontend.

I have now rebuilt the website in Drupal 8 and found out that the module has not been ported to Drupal 8. As suggested by the module developers, I have tried to rebuild the entire availability system using the Booking and Availability Management Tools for Drupal module.

However, BAT proves extremely difficult to set up. I have successfully installed BAT and dependencies through Composer, then painstakingly followed the manual, setting up units and fields etc.

I have now managed to get to the point where I can select dates and mark them as available/booked/unavailable, but can't find a way to show this on the frontend of the site.

Any change I make (name of a unit, name of a type) results in the whole BAT system giving error screens. For example, the BAT's topmost item in configuration, type group bundles isn't mentioned in the manual, and if I dare create one, BAT just crashes.

How do I show the availability assigned to units in the back end, in a calendar on the front end?
What are type group bundles (they're not in the documentation) and why do they crash all settings 'lower' in the hierarchy?


texts: Display different icons depending on field value

texts:
I am trying to produce a result that requires PHP code to evaluate whether a Drupal 8 node field is a "x", an "f", a "m", a "h", or an "l".

Thanks to some help on an earlier question, I've accomplished my task (to replace the value with a useful icon) when the value is binary: if it exists, show this. If it's empty, show nothing. I've done this via CSS.

Now I'd like to extract the actual value of the node field, and display different icons based on its value.

I am not planning to do this via a function, but rather by code on the node itself.  Is there some syntax I can use within the php that will extract this?  So that I can have the equivalent of:

$price = $node[field][value];

then I'd do:

if ($price == "m") { // use icon X }
else if ($price == "h") { // use icon Y };

Thank you for any and all help/suggestions!


texts:
I am using Views Tree plugin to render a taxonomy. I need to get rid of the surrounding

 wrappers. While I could simply override the theme_item_list function in my template, I would like the override to only take place within a view. Otherwise the wrapper is just fine. What kind of 'if' should I use around it to apply a Views context?


texts: Modifying Poll Template to have big buttons for voting

texts:
I am re-skinning the poll module for an iPad/tablets.

How can I make the poll module vote page have large buttons/images instead of radio buttons.

The template has <?php print $choice; ?>

and thats it :(


texts: How to add comment form to drupal pages not having node and content type?

texts:
mymodule.module

function mymodule_theme() {
return array(
    'mymodule_results' => array(
        'variables' => array('var1' => null, 'continent' => null, 'country' => null, 'location' => null, 'query' => null, 'total' => null,'comments'=>null),
        'template' => 'templates/mymodule_results'
    ),
    }

mymodule.pages.inc

function mymodule_details($beaches = null) {
 drupal_set_title('Beaches Details');
 if (!isset($beaches->comment_count))
    $beaches->comment_count = 0;
return array(
    '#theme' => 'mymodule_results',
    '#beaches' => $beaches,
    '#attached' => array(
        'library' => array(
            array('iks_libraries', 'jquery.tinycarousel'),
        ),
    ),
);
}

mymodule_results.tpl.php

<?php if ($comments): ?>
<?= render($comments) ?>

I need to include the comment form in the template page, But i have not created a content/node type for this. I'm displaying the results in the template page.


texts: Displaying associative array data in twig

texts:
Using drupal 8.7.x

I have an associative array that is returned to twig. However I can't seem to get the data displayed.

Associative array:

array_push($mealsArray, ["meal" =>
  [
    ['strMeal' => $mealTitle],
    ['strMealThumb' => $mealImage],
    ['mealUrl' => $mealTitleUrl]
  ]
]);

Return to twig:

return [
  '#theme' => 'recipe_search_block',
  '#meals' => $meals,
  '#ingredientList' => $ingredients,
  'form' => $form,
];

In twig I'm trying to display them like this:

    {% for meal in meals %}
      {% for fields in meal %}

{{ fields["strMeal"] }}

      {% endfor %}
    {% endfor %}

When I debug with kint this is the output I get

Any help would be appreciated, thanks in advance!


texts:
I'm fairly new to Drupal and Drupalgap.

My Drupal site has a view/content called "donations".

In admin/structure/views, there are two PATHs: /current-donations and /available-donations.  And of course, this URL works fine: http://127.0.0.1:8083/current-donations

Now I'd like to render this view in drupalgap using a views render array.

My first attempt looked like:

function mobile_donor_donations_page() {
try {
    console.log('mobile_donor_donations_list_page()-e');
    var content = {};
    content['avail_donations_list'] = {
        theme: 'view',
        format: 'ul',
        path: '/available-donations', /* the path to the view in Drupal */
        row_callback: 'mobile_donor_donations_list_row',
        empty_callback: 'mobile_donor_donations_list_empty',
        attributes: {
            id: 'avail_donations_list_view'
        }
    };
    return content;
}
catch (error) { console.log(':ER:mobile_donor_donations_page: ' + error); };
}

The above function gets called fine -- on my console (chrome, Ripple) I see

GET: http://127.0.0.1:8083/?q=/available-donations&page=0
200 - OK
views_embed_view - success - TypeError: Cannot read    property 'count' of undefined

Looking at the views_embed_view() code below, it is throwing an exception
because results.view is undefined:

// Render the view if there are some results, or if there are no results and an
// empty_callback has been specified. Otherwise remove the empty div container for
// the view from the DOM.
if (results.view.count != 0 || results.view.count == 0 && options.empty_callback) {

I tried http://127.0.0.1:8083/?q=/available-donations&page=0 from my
browser, it returns html, not JSON.

To force JSON returned, I tried

path: 'drupalgap/node.json&parameters[type]=donation', /* the path to the view in Drupal */

This PATH does indeed return my content as JSON, however the error remains,
since the JSON doesn't contain a "view" element.

GET: http://127.0.0.1:8083/?q=drupalgap/node.json&parameters[type]=donation&page=0
200 - OK
views_embed_view - success - TypeError: Cannot read property 'count' of undefined

What PATH do I need to supply, or do I need to change structure of my content in Drupal to get the view to render?

Thanks!


texts: Views block showing empty content on front end

texts:
I created a view to show a list of news items. I placed the view block in the content bottom region of the page. In the Views preview, it shows the results. However in the front end, the content is empty and shows:

I do have a view template for this block - views-view--news-list--block-1.tpl.php. In the Views page it shows this template as selected. I do not see that it is being rendered on the page though. Even when I just put a basic div with text in the views template, nothing shows in the content div.

What are the possible reasons for this? What can I do to get content to show?


texts: How long will the previous core version supported?

texts:
I want to start a new project at the beginning of 2018 but I don't know if it is better to start this project with Drupal 7 or Drupal 8. Actually, I am not familiar with Drupal 8 coding and template engine.

Even though there are lots of modules that aren't available in Drupal 8 right now, such as admin menu, Date Converting module and others, I finally decided to start my project with Drupal 7, but the point that disturbs me is not knowing how long Drupal 7 will be supported. Is it 2020, 2021, or later?


texts: How to map url_alias table to node table?

texts:
I was trying to use some SQL to map the url_alias field to my node field on the url_alias.pid = node.nid field. However, it turns out that these are not apparently related, sometimes they are the same value and sometimes they aren't. As I'm looking through my mysql db I can see no connection between the url_alias table and the node table.

The url alias is coming from the pathauto module. I just want to create links to my resources when the titles occur in a sql query in a custom module...this seemed the easiest way to do it.

Does anyone have any idea on which fields or tables the connections occur between these two entities?


texts:
I have a form with a field which I would like to be an autocomplete field.

I've tried the form_alter hook:

function autocomplete_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == office_node_form) {
    $form['field_office_name'][0]['#autocomplete_path'] = 'autocomplete';
  }
}

The autocomplete path is correct because I use it elsewhere for another field in another form but the field it's not working as autocomplete.

Anything else I should change in the form_alter hook in order to make it work?


texts: How to get the selected value of a dropdown inside panel?

texts:
I have an exposed filter inside the panel.

I want to filter the taxonomy term. For that I add "Content: Has taxonomy term (exposed)" field.

I need to get the selected value in js.

Drupal.behaviors.mymodule = {
  attach: function (context, settings) {
    var tid = $('#edit-tid').val();
    alert(tid);

  }
};

In alert I am getting "All" rather than the selected tid, as shown in this image:


texts:
Is there a possibility to assign existing nodes as translation of a node?

Cause i migrated a lot of content from a D6 instance. On D6 and D7, it was easy to assign the translation nodes but in D8 it seems not to have that possibility.
I also didn't found any modules which helps.

Any advice?


texts: How to display a view of products that are selectable

texts:
I am working on a site that will capture site details by the sales reps. They will also use the site to order products for the customer and at the same time enter the installation criteria of the product by uploading photos and filling out text boxes.

The site will need to display all the products (50) in a table like views would on the page at once. The products will need to have a check box to select each product and a quantity to be entered. The products entered will need to be saved to the specific site that the sales rep has sold to.

In the screen shot I am using panels to layout the form. I have highlighted in red the image I am currently displaying with html in panels.

I have tried a few modules like Entity Reference / Views and Commerce but cannot find the best way to tackle this. Can anyone point me in the right direction.

Thanks.
Drupal 7.31

Screen Shot http://sitetrack.com.au/images/Screen_capture_1.PNG


texts: Add administration menu item for one role only

texts:
I have a module that has configuration pages in the administration side. I want to have one role that's just for administrating that module, but doesn't have any other administrative privileges.

I can give this role access to the path admin/settings/module/configuration and they see the form, but since they can't see see the administration menu, they can't navigate to it. They have to paste the URL to it.

I would like to have that path show up as a link in their black admin menu bar at the top. But I don't want it to show up for any other admin, just the Module Administrator role, to keep that bar uncluttered. I can get a custom menu item showing up in the admin bar, but how do I get it to redirect to another page, and how to I stop users without the role from seeing it?


texts: Updating core with Composer doesn't work

texts:
I am on D 8.3.0-rc2 and want to update to D 8.3.0 stable. Composer is my only option (requirement of address module). Composer core update doesn't bring me beyond 8.3-0-rc2, not even forcing it. Running drush composer require "drupal/core:^8.3@stable" gives me the following output:

  ./composer.json has been updated
  Loading composer repositories with package information
  Updating dependencies (including require-dev)
  Nothing to install or update

The content of composer.json is the following.

{

"name": "drupal/drupal",
"description": "Drupal is an open source content management platform powering millions of websites and applications.",
"type": "project",
"license": "GPL-2.0+",
"require": {
    "composer/installers": "^1.0.21",
    "drupal/core": "^8.3@stable",
    "wikimedia/composer-merge-plugin": "~1.3",
    "drupal/address": "~1.0",
    "drush/drush": "^8.1"
},
"replace": {
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
    "preferred-install": "dist",
    "autoloader-suffix": "Drupal8"
},
"extra": {
    "_readme": [
        "By default Drupal loads the autoloader from ./vendor/autoload.php.",
        "To change the autoloader you can edit ./autoload.php."
    ],
    "merge-plugin": {
        "include": [
            "core/composer.json"
        ],
        "recurse": false,
        "replace": false,
        "merge-extra": false
    }
},
"autoload": {
    "psr-4": {
        "Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
    }
},
"scripts": {
    "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
    "post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
    "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
    "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
},
"repositories": {
    "drupal": {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    }
}
}

I read about deleting vendor and composer.lock, but I don't understand why this would work.


texts:
I try to create modal window with form (from page /node/add/page).
Try this

hook_menu() {items['mypath']=...} + callback (where echo drupal_render($form); exit();)

//form has many elements from different modules (node + inline register)

Next

get rendered form via ajax (form has action 'mypath')
plug jquery.form.js to the form

Submit

Server returns full page and i'm sure that new page material doesn't save even if i change action to '/node/add/page' instead of 'mypath'

What i do wrong?


texts: Drupal 7: Why isn't the rendered node being displayed with kpr?

texts:
I'm following a tutorial from Drupalize.me and it says that if I add this code...

function mythemenameishere_preprocess(&$variables, $hook) {
  kpr($hook);
}

...in the template.php file, I'm supposed to see something similar to...

node
node
node
block
region

...which shows that each individual node is  getting rendered prior to the block and region. And I do have 3 nodes of content type featured_item, and 3 nodes of content type article. But I only get...

block
region

... and NO NODES. Why is that? I'm in the homepage.


texts: How to print price integer in drupal commerce cart block?

texts:
How to print price without decimals in drupal commerce cart block?
I found this code:

<?php
global $user;
$order = commerce_cart_order_load($user->uid);
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_total = $wrapper->commerce_order_total->value();
$quantity = 0;
foreach ($wrapper->commerce_line_items as $delta => $line_item_wrapper) {
  $quantity += $line_item_wrapper->quantity->value();
}
?>

 items. .

Code working correctly but price render with decimals.


texts:
I have a php_view field in a view, it basically pulls a date field on a specific node, and then use the php function setISODate to get the 'monday' date of the week.

The thing is, i'm on a french language site and the date that the function return is in english, not that I don't like english hehe but the month just doesn't fit very well in the display on that view

Here's the code.

// Retrieve the date field of that node.
$node = node_load($data->nid);
$date_field = $node->field_date;
$date = $date_field['und'][0]['value'];

// Put the year in $annee and the week number in $semaine.
$annee = date("Y", strtotime($date));
$semaine= date("W", strtotime($date));

// Get the monday date of that week
$lundi = new DateTime();
$lundi->setISODate($annee , $semaine);
print "Semaine du " . $lundi->format('j F Y');;

?>

I've tried to use the following code, but it doesn't do anything.

setlocale (LC_TIME, 'fr_FR.utf8','fra');
print (strftime("%j %F %Y", $lundi));


texts: Extending forms (or views, or something else?!)

texts:
If creating something like a form, but also perhaps any piece of front-end UI, what is the correct approach for adding things like extra Javascript (or HTML, or anything)?

I'm putting together a registration form using the Entity Registration module and would like to know if, say, I wanted to have a 'Delivery address is the same as invoice address' checkbox that dynamically hid/revealed the delivery address part of the form, what would be the Drupal way of achieving that?


texts: Ask visitor if he want to view page on his language

texts:
I use Internationalization module on Drupal 7 for multi-language content and my default language is English and I have one more language.

The thing I have to do is:

To check if visitor is from country that primary language is my second language on website (there are four countries that language is spoken), I think that this checking can be done by IP address of visitor.
If visitor is from one of that countries there will be shown modal popup with the question if the visitor wants that page to be shown in his language. If visitor answers affirmative that page will be shown in his language, but if he answers negatively the page will be shown in default language (English).
It is necessary to remember visitor choice so that the modal popup doesn't show up every time, I think that it could be done by saving the cookie in visitor's browser.

Is this possible to be done through some module or the combination of modules or it is necessary to be done programmatically?

Any idea or help where to start is welcome, also the suggestion of some different concept would be nice.


texts:
Is there a way to edit a single field (for example: publication date) across a few dozen nodes?

I added a field called "Publication date" to an existing content type, and now I need to add a date to a whole lot of them. I'd love to have a table display showing the node title, and the field in question next to it in an editable column.


texts: How to define settings from an install profile

texts:
I am looking for the way to set some settings at the install step.

function genius_profile_final() {
  // Enable default permissions for system roles.
  $filtered_html_permission = filter_permission_name($filtered_html_format);
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', 'access comments', $filtered_html_permission));
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'skip comment approval', $filtered_html_permission));

  // Create a default role for site administrators, with all available permissions assigned.
  $admin_role = new stdClass();
  $admin_role->name = 'administrator';
  $admin_role->weight = 2;
  user_role_save($admin_role);
  user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));
  // Set this as the administrator role.
  variable_set('user_admin_role', $admin_role->rid);
  // Assign user 1 the "administrator" role.
  db_insert('users_roles')
    ->fields(array('uid' => 1, 'rid' => $admin_role->rid))
    ->execute();

  // Create a role for webmaster
  $webmaster_role = new stdClass();
  $webmaster_role->name = 'webmaster';
  $webmaster_role->weight = 3;
  user_role_save($webmaster_role);
  user_role_grant_permissions($webmaster_role->rid, array_keys(module_invoke_all('permission')));

  variable_set('taxonomy_menu_vocab_menu_rubric', 'menu-genius-navigation-menu');
  variable_set('taxonomy_menu_vocab_parent_rubric', 0);
  menu_rebuild();

  // Set the regional settings First day to Monday
  variable_set('date_first_day', 1);

  // The return message is optional, if you omit it the default will be used.
  return '
'. (drupal_set_message() ? t('Please review the messages above before continuing on to your new Profile Name site.', array('@url' => url(''))) : t('You may now visit your new Profile Name site.', array('@url' => url('')))) .'
';
}

In genius_profile_final(), where as I understood Drupal is fully bootstrapped, I have variable_set('date_first_day', 1), but the first day of the week still is set to Sunday,  after the installation. So it is not working as I expected.

I am using the taxonomy_menu module, and I would like to set at the installation step the menu to be linked with the taxonomy. Because I am installing something known, I know the variable names that might be set are:

variable_set('taxonomy_menu_vocab_menu_rubric', 'menu-genius-navigation-menu');
variable_set('taxonomy_menu_vocab_parent_rubric', 0);

This is not working neither.

I have been following https://www.drupal.org/node/1022020 and looking at other examples but I have had no luck to find how to do this.

Is it possible to change settings in an install profile or are there any restriction? In that case, what restrictions are?

What am I doing wrong?


texts: Set permission for a specific column in view for table format in drupal 8

texts: I have created a view in table format and added a field as global custom text field. I want to show this field to administrator only, not to other created roles. How can I do that?


texts: add fields to a node mapped to date input.The fields value should be mapped to date value

texts:
I want to add  fields to the a content type.

The user should be able input text values that are mapped to a particular date.

Ex: for july 1,
a particular field can have a value of 145, for july 13 it can have a value of 155 and so on.

The date can be entered using date popup field and for every date the field can have different value.

I need the values for 30 dates. The fields are multiple.

I have 5 fields and all 5 fields have different values for a particular day.

I explored the conditional_fields module but it doesn’t seem to meet the requirement.


texts: Load and interact with a node comments from their related node

texts:
I am having some trouble in my quest to build a Drupal 7 custom node based image gallery module. I've got it working, but now I need AJAX to load and manipulate comments.
What I am doing
I've created a Drupal 7 one-image-per-node image gallery; it uses relationships, EVA and even BBQ for deep linking, when viewing the 'gallery' node, EVA feeds in the thumbs and helpful attributes, e.g. URL to full image, url to actual node. I have jQuery in my gallery node, which AJAX preloads the full images on thumb click & manipulates them for fast dynamic full screen browsing, it works perfectly! Even the BBQ deep-linking which was difficult. Some of my gallery display js code is based on http://manos.malihu.gr/tuts/sideways_jquery_fullscreen_image_gallery.html.
Update
I am trying all angles to bring in the comments. I've added one possible solution below but am going to try and figure out some other/better ways of doing this.
I am unsure about Services & Json or the views json output module and if that would be useful to me in this situation?  Would json be better to call a nodes comments?
I suppose now my question remains what is the best way to do this?  Even though this is working for me now I don't think I've found the best way yet.
Well thats where Im at, once I refine this I will pull everything into a module rather than a mix of module & theme layer bits, this will be my first module that defines content types, views and well all sorts of Drupal fun!


texts: How do I override the admin theme in my own theme?

texts:
I created my own Drupal 8 theme:

mytheme.info.yml:

name: My Theme
description: 'Drupal 8 Theme'
type: theme
base theme: bartik
core: '8.x'

mytheme.libraries.yml

global-styling:
  version: 1.x
  css:
    theme:
      css/layout.css: {}
      css/style.css: {}
      css/colors.css: {}
      css/print.css: { media: print }

I am using "Seven" as admin theme.

When I edit a page (/node/x/edit) Seven theme is used.

Now I have to add some CSS the the edit form.
How can I do this?
style.css is only loaded on front end pages. Edit pages use seven theme and my theme CSS is ignored.

How can I add some CSS to admin pages or edit forms in Drupal 8?


texts: Where is the configuration actually saved in the system?

texts: I am new to Drupal 8. I installed the Drupal webform module. I am able to export the configuration file but unable to figure out where the configuration is actually is saved in the Drupal system.


texts:
I'm building my own theme to be used with Angular 4 and can't tell where/why Drupal is deciding to import jQuery.

Here's the code for my theme, loosely based off this Angular 1 theme:

ng.info.yml

name: ng
type: theme
libraries:
  - ng/base
description: 'An theme that makes Angular do all the work'
core: 8.x

ng.libraries.yml

base:
  version: 8.x
  js:
    js/inline.bundle.js: {}
    js/polyfills.bundle.js: {}
    js/styles.bundle.js: {}
    js/vendor.bundle.js: {}
    js/main.bundle.js: {}

ng.module

<?php
function ng_theme() {
  return array(
    'ng_view' => array(
      'template' => 'view',
      'variables' => array('title' => NULL),
    ),
  );
}

ng.routing.yml

ng.view:
  path: 'ng'
  defaults:
    _title: 'Drupal Angular'
    _controller: '\Drupal\ng\Controller\DrupalNgController::viewDrupalNg'
  requirements:
    _permission: 'access content'

src/Controller/DrupalNgController

namespace Drupal\ng\Controller;
use Drupal\Core\Controller\ControllerBase;
class DrupalNgController extends ControllerBase {
  public function viewDrupalNg() {
    $build['myelement'] = array(
      '#theme' => 'ng_view',
    );
    $build['myelement']['#attached']['library'][] = 'ng/inline.bundle';
    $build['myelement']['#attached']['library'][] = 'ng/polyfills.bundle';
    $build['myelement']['#attached']['library'][] = 'ng/styles.bundle';
    $build['myelement']['#attached']['library'][] = 'ng/vendor.bundle';
    $build['myelement']['#attached']['library'][] = 'ng/main.bundle';
    return $build;
  }
}

templates/view.html.twig

<html{{ html_attributes }}>
  <head>
    <title>Angular app</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="HandheldFriendly" content="true" />
    <meta name="apple-touch-fullscreen" content="YES" />
  </head>
  <body>
    <app-root></app-root>
  </body>
</html>


texts: Entity Reference Field: How to filter a View entity reference

texts:
Using Drupal 8 I want to create a field that references certain Views that the user should be able to choose from when editing a node. Creating this reference is possible using the reference field type and choosing "View" as the type to reference.

The problem is I also want to filter which views should be selectable. This does not seem to be possible.

When referencing for example nodes, there's an option to select which bundles should be referenceable. Is there any way to do something similar for views, or for config entities in general? Or is there any contrib module available for this? Maybe there'a a hook / plugin I could implement to filter the referenceable views programmatically?


texts: Make label translatable in Global: Custom Text field

texts:
I'm using Drupal 7 and I have a Global: Custom Text in my view

Label

[title]

[category]

When I try to translate the 'Label' from

`Configuration » Regional and language » Translate interface`

I get an error 'The submitted string contains disallowed HTML'.
That is because the label is wrapped in a div. I could add the div in include/locale.inc in the function

`locale_string_is_safe($string)`

but I don't think is a good idea to edit the Drupal core.

Do you have any better solution?


texts:
We're looking to manage our install of Drupal 7 with CVS (sadly Git and SVN are out). Do you have any pointer for things to think about when setting up the repositories?

Our lay of the land is as follows:

Our staff include UI developers, back-end developers , administrators, and DBAs.
For starting, we're going to install various modules (e.g. Domain, LDAP, Workflow, and Views). We'll write some custom modules down the road. We're also looking for implementing our own look and feel.
We have Dev, Test/QA, and Production instances of Drupal. The flow of code and configurations  will be from Dev to Test/QA to Production (with some looping between Dev and Test).
We'll have top level domains and several subdomains.
We're on RedHat Enterprise Linux 5.5, MySQL 5.x and Apache 2.x.

What are the ways of managing changes that have worked for you?


texts: Email without body being sent to newly added users

texts:
In "admin>config>people>account-settings" for "Who can register accounts?" settings I have selected:

Visitors, but administrator approval is required.
Require e-mail verification when a visitor creates an account.

I have even enabled notifications for sending emails to newly added users from the options available at the bottom of the same page and I am using the default subject and body for the mail.

I have got an very unusual problem that my newly added user receives a mail from my site without any body. Though the subject of the mail is same but the body of the mail doesn't shows up; all I can see in email's body are just three dots (...). Please help.


texts:
I am trying to figure out how to apply a class to user profile pictures in Drupal 8 to make the pictures round.

Since I am using Bootstrap 3 I can just apply image-round class in this case, but I am not sure how to add the class to the profile image.

I tried adding a class with the Field Class module, but it didn't work.


texts: How to change field_tags in hook_form_alter?

texts:
I have the field_tags set to be a select box (not auto-complete). Inside hook_form_alter, how can I change the default value of the field_tags select box? So far, I have:

function autotag_custom_form_alter(&$form, &$form_state, $form_id){

    if($form_id == 'article_node_form'){
      //change default value here
    }

}

But I don't know how to access the field_tags element and then change the default value. Please help! Thanks.


texts:
I am looking for a way to implement a gallery style selection for a content type containing multiple videos.  I am using Drupal 7.

I have a content type called roles which has a title, banner image, description, videos and video thumbnails.

The videos and video thumbnails are file fields which can accept multiple files (the idea being that you can upload the videos then the thumbnail for each video in the same sequence).

At the moment to display videos on the site I am using mediaelement - however for this page layout I need to be able to show the video thumbnails then let the user select and have it load the video via an ajax call.

I have tried using views filters exposed to the user based on the videos file id, however this seems to break the videos.

Is there another way to accomplish this in views? Or is there another way to accomplish what I am trying to do?


texts:
iam using drupal 8.9
i have two  blocks same design with 4 items for each  , so i used same view with same view mode  and change the filter of section by arguments as
{{ drupal_view('homepage_blocks', 'block_5', '391') }}
   {{ drupal_view('homepage_blocks', 'block_5', '286') }}
the block has custom design( with one big image and 4 small)  , so i write this code in hook_preprocess_node  inorder to get the row index
if(!empty($variables['view'])){ $view = $variables['view']; $node = $variables['node']; foreach($view->result as $key => $row){ if($row->nid == $node->id()){ $variables['_total'] =count($view->result); $variables['row_index'] = $row->index; $variables['argg']= $view->args[0]; } } }
Because one of the items in block 2 is in block 1 too ;
the problem appears that
the same node in block 2 take the argument for the first block (391).
so the view result array become  different and the row index is changed .
the result as debugging was argg=286 for 3 items and the fourth is argg=391
please can any body help in this issue, how to make row index return correct and  view result is independent for each view block.


texts:
I am creating my first theme.  I don't see the "Search form" block under structure>block for my theme.  It is present for other themes.  I am not sure what I am doing wrong.  Should I put something the the .info file to enable it?
NB: I am working with Drupal 7.


texts: Redirect from one URL to another based on user role

texts:
I have two pages on my site (created using views) that I would like to hide from anonymous users by redirecting them to a custom access denied page. i.e. If an anonymous user tries to go to the page "wolfdogs/deceased" they are redirected to "access-denied". I found this bit of php that looks promising:

if (in_array('anonymous user', array_values($user->roles))) {
  $dest = $_SERVER['REQUEST_URI'];
  $dest = substr($dest,1); //this removes preceding slash from string
  $path[]='vote'; //example paths to hide from anonymous users...
  $path[]='volunteer';
  $path[]='papers-list';
  $path[]='event-register';
  $path[]='replays-list';
  $path[]='how-to-upgrade';
  $path[]='membership-renewal';

  if (in_array($dest, $path)) {
    return drupal_goto('members-only'); //this line re-directs to custom access denied page.
  }
}

Ideally I would like put this into a block, and then put the block on the "hidden" pages. However, it was written for Drupal 6; I don't if it works with Drupal 7, and I am unsure how to implement it into a block.


texts: How to display physical dimension fields on node--product.tpl.php?

texts:
I am using the Drupal Commerce module and I want to print the physical dimension fields(machine name: field_width) value on product detail page.

How can I print physical dimension fields value in node--product.tpl.php file?

My file code is like so:

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"
<?php print $attributes; ?> >

<?php print $user_picture; ?>

<?php print render($title_prefix); ?>
<?php if (!$page): ?>
<h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?>

<?php endif; ?>
<?php print render($title_suffix); ?>

<?php if ($display_submitted): ?>
<?php print $submitted ?>
<?php endif; ?>

<div class="content clearfix"<?php print $content_attributes; ?>>

<?php
if ($view_mode == 'teaser')
else
print render($content['field_image1']);
print render($content['field_width']);
print render($content['product:commerce_price']);
?>


texts: Is it possible to count sub-items in view in Drupal 7?

texts:
I want to count nodes in sub-categories (taxonomy terms using) and view result to category field. how to do this in views?

Example:

category with counter http://3.reshleon.z8.ru/catalog/bytovaya-tehnika

items in category, needs to count them http://3.reshleon.z8.ru/catalog/42


texts:
What I need is a link to click and open a form in a modal.

Call to undefined function ctools_ajax_text_button() in ctools\includes\modal.inc on line 184

This is how I'm calling the function in hook_page_build() function.

ctools_include('modal');
ctools_modal_add_js();

$links[] = ctools_modal_text_button(t('Modal Login'), 'modal_forms/nojs/login', t('Login via modal'));

And this also not working.

$test = ctools_modal_text_button('Test Link', 'node/123', 'alt here', 'no-class');


texts: How do I create an uncacheable field plugin base?

texts:
I created a custom field plugin base for show an additional data column in a  view.

In my FieldPluginBase Class, I define the value of my additional data column for each row of my view (one row equal one node). The datas depends some node parameter.

My problem is users can often changes nodes parameters, but when the user access to my view after change a parameter of a node, the additional column show old data.

I notice when I clear website cache, the view show the new value.

This is the code of my class, can you tell me what must I do for the view shows all the time the newest value of the node in my field plugin base ?

class MyFieldPluginBaseCustom extends FieldPluginBase {

    ...
    public function render(ResultRow $values) {
        //do some work with the current node (the current row view)
        if(node_parameter_test_isOK() == true)
            return "string A";
        }
        else{
            return "string B";
        }
    }

    // 0 : the view shows a list of node
    // the view ;
    // (nodeid - mycustom Field Plugind)
    // node1 - "string B"
    // node2 - "string A"
    // node3 - "string B"
    ...
    // nodeN - "string B"

    // 1 : a user change the parameter of the node3

    // (2) : then, when the user access to the view page, the view must show
    // node1 - "string B"
    // node2 - "string A"
    // node3 - "string A"
    ...
    // nodeN - "string B"

    // 2 : However, the view hasn't been updated and show again (unless I clear caches via drush cr by example)
    // node1 - "string B"
    // node2 - "string A"
    // node3 - "string B" // row not updated
    ...
    // nodeN - "string B"
    ...
}


texts: What is the easiest way to create a mobile stylesheet for a Drupal 6 site? Is there a simple way to just create a css file, declare it in the info file add a viewport meta tag to your templates and have it all be automatically recognized by the site pages? Based on my own attempts, I'm thinking it's a little more complicated than that, but maybe someone has a fairly simple solution...?


texts:
Say I am writing a page template to show the daily special menu of a restaurant. Each menu item is a content and has a field to store which day of a week it goes on special. The page will have 7 tabs(Mon, Tue, Wed etc) to display the query of that day.

I wonder how to achieve this in drupal 8?


texts:
I was wondering if anyone knew how to go about adding a drop down or even a list of links to help change the amount of views results per page.

Ideally, when there's a lot of results you would want to be able to choose:

5 per page
10 per page
20 per page
50 per page

A drop down box would be brilliant for this; it is the sort of thing you see on many search forms.


texts: How to customize CKEditor format configuration

texts:
I'm using Drupal 7 with CKEditor module and I would like to delete some formats in the dropdown box that is currently labeled "Format". So I modified the config file which is site/all/modules/ckeditor/ckeditor.config.js. I modified the code like this :

CKEDITOR.editorConfig = function(config) {
   // some code here
   config.format_tags = 'p;h1;h2;h3'; // I added this line
}

Then I flush all caches of drupal and the cache of browser, but it doesn't work. When I create a new content, I always have all the formats. How to make it work?
(Note : I don't want to customize it from admin/config/content/ckeditor/edit page)


texts: Building a non-config, programmatically-created, semi-dynamic, semi-manual menu

texts:
We have a custom entity called "Topic". With this entity, users can build topics and reference other content to "belong" to the topic. We also have a requirement where, whenever a user creates a topic, a menu is also created for it. When content is added to the topic, a link is automatically added to the menu pointing to that content.

The workflow is like:

User creates a topic.
User references a bunch of arbitrary content to the topic.
User saves topic.
Menu associated with topic automatically adds links to added content.
(optional) User adds more links to menu, not necessarily for topic content.

Now this menu currently couldn't be a custom-built block, as we also have a requirement where users should be able to to add menu links like a regular menu. But the downside to using menus is that they're config - they need to be exported. Otherwise, a deploy without the config would wipe out all the created menus.

Is there a way to create a menu without making them config? Is there a better approach to this problem?


texts:
I have a Drupal site, and I am suffering performance issues. I found How do I convert a database from MyISAM to InnoDB? indicating that performance may improve by switching.

How can I tell if my MySQL database is InnoDB, or MyISAM?


texts: Adjust Entity Reference "Number of values" Based on Role

texts:
There are two roles, standard and premium. I would like the standard role to be able to select up to 10 users via the entity reference field. I would like the premium role to be able to select an unlimited number of users via the SAME entity reference field.

A standard user can upgrade to a premium user, so any nodes they edit after an upgrade would need to allow for additional selections via that entity reference field.

I'm a front end developer, and not too handy with PHP, so ideally I would need to be able to make this functionality via another module and configuration. I'm essentially looking for the functionality of Field Permissions Module, but extending it to the number of values a user can select.


texts: View to filter a list of nodes which has TWO taxonomy terms

texts:
I have a content type - 'video post'.
This content type has several taxonomy terms associated with it, 'star rating' and 'warm up'.

The 'star rating' taxonomy is a list of numbers: 1, 2, 3, 4

The 'warm up' taxonomy has 3 options: warm up, long, cool down.

What I've been trying to do is to create a view block to display on the content type 'video post' so that it displays a list of nodes which have the exact same set of taxonomy terms as the one currently being viewed.

So if I go to node/1 and this has these two taxonomies as follows:

star rating - 2

warm up - long

I only want nodes to display which also have this same combination of terms.

It would also be great if I could exclude the current node from the list too, as this is obviously not required.

I've tried just about everything that I know, but I always seem to get results that I don't want.

Any help is greatly appreciated.


texts: How to automatically post a message with the discount on the site?

texts:
I have a store with Commerce 2 and Drupal 8.

In my store I created a reminder of 20% on the whole site.

I want a message to be posted on my site with the conditions, the percentage, the end date and the description of the discount.

A bit like this :

How can I do this ?

Thank you


texts: How to get Search API module to index the full country and state name from Addressfield Module?

texts: The Addressfield module stores an abbrivated name for countries and state such as US for United States and FL for Florida. The Search API indexes the these words which are not very useful when doing searches for places like New York, Boston, France, ect.. Should I just discard the Addressfield module and make text fields or is there another way to go about doing this?


texts: Set the "from" header in the email to be in the format "Full Name"

texts:
How can I change the from header in the email sent from Drupal to be in the format "Fullname" <email@address.com>?

I managed to do it on a Drupal 6 site at one point in the past, but I no longer have access to that site, and I don't remember how to do it.


texts: How to put 2 'views' side by side in 1 region using the bootstrap theme?

texts: Is there a way to place 2 separate views (mine in particular are in block), and set them beside in each in a region? I am using the bootstrap subtheme and specifically the content region. I am using drupal 7.


texts: how to inspect the output array from PHPVideoToolkit::getFFmpegInfo()

texts:
I got the following error message

PHPVideoToolkit Error: Execute error. Output for file "$DOCROOT/sites/example.com/files/private/videos/original/file.flv" was not found. Please check server write permissions and/or available codecs compiled with FFmpeg. You can check the encode decode availability by inspecting the output array from PHPVideoToolkit::getFFmpegInfo().

How do I inspect the ouput array from PHPVideoToolkit::getFFmpegInfo()?


texts: How do I set an entity base field as NOT NULL?

texts:
When creating custom entities in Drupal 8, you define a bunch of fields in baseFieldDefinitions() on your entity class, like this:

  <?php
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);

    $fields['postal_code'] = BaseFieldDefinition::create('integer')
      ->setLabel('PLZ')
      ->setDescription(t('Postal code.'))
      ->setSetting('unsigned', TRUE)
      ->setDisplayOptions('form', [
        'type' => 'number',
      ])
      ->setRequired(TRUE);

    return $fields;
  }

However, these fields, despite being marked required, are defined as nullable in the database.

There’s no ->setNullable(FALSE) or similar method on BaseFieldDefinition. So how else do you make Drupal generate the schema correctly?


texts: Add a views exposed filter block into my theme using template.php

texts:
I would like to render a views exposed filter block in my node theme. This is what I am doing:

function MYTHEME_preprocess_node(&$vars) {
   $search_form = drupal_get_form('views_exposed_form');
   $search_box = drupal_render($search_form);
   $vars['search_box'] = $search_box;
}

This way I could simply add variable $search_box into my theme and the filter block would be displayed.

I have confirmed and 'views_exposed_form' is the correct form_id. The problem is that this is throwing a nasty error that doesn't log the error message. My template gets broken (still appears, but broken) and no error message is logged.

It does work if I try to display, let's say, a regular search box. The code is the same, all I have to do is change to the search block form id (search_form) like this:

$search_form = drupal_get_form('search_form');

Right now, I am almost pulling my hair, have searched up and down the web. Any help is appreciated. Thank you!


texts:
Here's an example I just ran into. I'm trying to put some HTML in the label of my field.

$form['field_feedback']['und']['#title'] <- has the title
$form['field_feedback']['und'][0]['#title'] <- has the title
$form['field_feedback']['und'][0]['value']['#title'] <- has the title. (Works)

Why are there three populated #title attributes with only one being used?


texts: How to add a button :"Get my location" in page views

texts:
i have created a gmap views page, and i want add a button "get my location like this :

i want give to visitor a button that can get his location in the map,
some one have an idea how to do that ?


texts: After adding info an entity via hook_ENTITY_TYPE_storage_load, how do I access that data in hook_ENTITY_TYPE_view?

texts:
I'm adding data to the node on the storage_load hook, and trying to put it into the $build on the view hook. However, when I try to get the data, I can't figure out how to do it. $node->get('i18nfiles') gives me a "Field i18nfiles is unknown" exception, while $node->values['i18nfiles'] cannob be accessed because it is protected. Sure miss simple stdClass objects about now. :) Code below.

/**
 * Implements hook_ENTITY_TYPE_storage_load() for nodes.
 *
 * @param type $nodes
 *   the array of nodes being loaded from the database.
 */
function hqq_node_storage_load(array $nodes) {
  $nids = array_keys($nodes);
  $result = db_query('SELECT fa.* FROM {node__field_attachments} fa INNER JOIN {node_field_data} nfd ON nfd.nid = fa.entity_id AND nfd.langcode = fa.langcode WHERE nfd.nid IN (:nids[]) AND nfd.status',[':nids[]' => $nids])->fetchAll();
  foreach ($result as $record) {
    $nodes[$record->entity_id]->i18nfiles['files'][$record->langcode] = $record->field_attachments_target_id;
  }
}

/**
 * Implements hook_ENTITY_TYPE_view() for nodes.
 *
 * @param array $build
 *   The renderable build array.
 * @param \Drupal\node\Entity\Node $entity
 *   The entity being rendered.
 * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
 *   The entity view display holding the display options.
 * @param string $view_mode
 *   The view mode for the entity.
 *
 */
function hqq_node_view(array &$build, \Drupal\node\Entity\Node $node, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, string $view_mode) {
  if ($display->getComponent('i18nfiles') && ($files = $node->get('i18nfiles')->getValue())) {
    foreach ($files as $langcode => $fid) {
      $lang = Drupal::languageManager()->getLanguage($langcode)->getName();
      $url = file_create_url(File::load($fid)->getFileUri());
      $options[$url] = $lang;
    }
    $build['i18nfiles'] = [
      '#type' => 'select',
      '#options' => $options,
      '#attributes' => ['class' => ['i18nfiles']],
    ];
  }
  if ($display->getComponent('i18noutdated') && $node->get('content_translation_outdated')->value) {
    $build['i18noutdated'] = [
      '#type' => 'item',
      '#markup' => '
' . t('This translation is outdated') . '
',
    ];
  }
}

/**
 * Implements hook_entity_field_info().
 * Returns an array of extra fields provided by the module.
 *
 * @return array
 *    The array of extra fields provided by hqq module.
 */
function hqq_entity_extra_field_info() {
  $extra = [];

  // Add the i18nfiles element, for translations of documents
  $extra['node']['document']['display']['i18nfiles'] = [
    'label' => t('Translated files'),
    'description' => t('A dropdown list of all languages in which a published translation is available'),
    'weight' => 10,
  ];

  foreach (NodeType::loadMultiple() as $bundle) {

    // Add also the 'language' select if Language module is enabled and the
    // bundle has multilingual support.
    // Visibility of the ordering of the language selector is the same as on the
    // node/add form.
    $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', $bundle->id());
    if ($configuration->getThirdPartySetting('content_translation', 'enabled')) {
      $extra['node'][$bundle->id()]['display']['i18ninprogress'] = [
        'label' => t('Translation in progress'),
        'description' => t('An indicator for if there are translations in progress.'),
        'weight' => 0,
      ];
      $extra['node'][$bundle->id()]['display']['i18noutdated'] = [
        'label' => t('Translation outdated'),
        'description' => t('A notification if the current translation is outdated.'),
        'weight' => 0,
      ];
    }
  }

  return $extra;
}


texts: How do i get views field labels in the template file

texts:
I am creating a view, and displaying view by using custom template files. As per theme suggestions I named the template file for fields as views-view-fields--blog-display--page.tpl. In this file I want to display labels for the view fields which i have given while adding fields. I tried using

<?php print $fields['label']->content; ?>

But not able to get the label.
What am I doing wrong?


texts: How to archive old orders in Drupal Commerce

texts:
I have a site with more than 15000 commerce orders. This is slowing down the site drastically. I have upgraded all the modules and applied the patches regarding the table locking and so on. They haven't been of much help.

I am ok with removing the order history from the site. I just want to keep an archive of that so that I can use them once I have enough resources to handle everything.

I am not able to get the site up. Hence I will have to do all the work from the command line. So is there any safe and suggested way to archive the orders?


texts: How do I make an FTP connection from a module?

texts:
I'm trying to create a custom module that would connect to an external FTP and grab an XML file (provided by third party). This file can't be accessed through http.

In Drupal 8, there is the Drupal\Core\FileTransfer\FTP class, but I'm not sure as of how I could use it inside my custom module. I don't see any service I could use.

Do I use that class directly, or is there a service I need to use?


texts: what is the difference between using drupal_add_js and ['#attached']

texts:
What is the difference between drupal_add_js() and $form['#attached']['js'][] ?
When is the purpose of using each of the above functions?

(I mean I know that it is used to attached js to say form if used inside form but when is drupal_add_js used and when is $form['#attached']['js'][] used ?)


texts: "drush cron" doesn't work anymore after moving the site to a new server

texts:
After moving a site to a new server, drush cron stopped working and now I am getting the following error:

  [Symfony\Component\Console\Exception\CommandNotFound]
  Command "cron" is not defined.

What am I missing?


texts:
I try to display authorised user's news feed:
I installed Facebook Stream module in Drupal 7. After facebook login module displays an error:

  FacebookApiException: User must specify a valid extended permission or
  data permission in BaseFacebook->throwAPIException() (line 1325 of
  Z:\home\devfb.kz\www\sites\all\modules\facebook_stream\facebook-php-sdk\src\base_facebook.php).

I can't understand why permissions which I specified in the module are invalid?
Permissions:

return '<fb:login-button '. drupal_attributes($attr) .' onclick="FB_Connect.login_onclick()" scope="read_stream,publish_stream,offline_access">'. $text .'</fb:login-button>';

Maybe I can do this with another module?


texts:
I need to take control over and change the flash notification a user gets when they register, but administrator approval is required.

I want to alter this...
"Thank you for applying for an account. Your account is currently pending approval by the site administrator. In the meantime, a welcome message with further instructions has been sent to your email address"

https://api.drupal.org/api/drupal/core%21modules%21user%21src%21RegisterForm.php/function/RegisterForm%3A%3Asave/8.2.x

It states...
'Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.'

I'm trying to figure out what the Drupal 8 way of doing this is.
Should I be trying to "alter" the message with a hook?
Should I be overriding a service? (though from my understanding this
is not service).
Should I be extending this?
Or is there some other best practice way of overriding this?

I'm learning Drupal 8. So I'm not entirely sure the "right" way to handle this particular case.


texts: How to access table tokens in views through handler

texts:
I've added a custom field of type global using views_handler_field. This custom field type is basically a button that needs to call a javascript function. This javascript function takes an adjacent field's value as a parameter. When I edit the view on my webpage, under rewrite rules->replacement values, I can see the token for the value I need in my handler's functionality. In the code example, it's [fieldID]

However, I don't see any way to access this value in my views_handler_field include file.

function render($values) {

    $actions = array();
    $variable = variable_get('fieldID'); // HERE is what I'd like to do to get the adjacent [fieldID] icon

    $alt = t('Download File');
    $actions[] = array(
      'name' => t('Download'),
      'html' => 'javascript:initiateDownload('.$variable.')',
      'id' => t('download-button-' . $variable),
      'icon' => theme('image', array('path' => drupal_get_path('module', 'download_process') . '/images/edit.png', 'alt' => $alt))
    );

    $output = '';

    $counter = 0;
    foreach ($actions as $action) {
      $output .= l($action['icon'], $action['html'], array('attributes' => array('id' => $action['id'] . $counter), 'html' => TRUE, 'external' => TRUE));
      $counter++;
    }
    return $output;
  }
  function query() {

  }

I've tried working with get_render_tokens, but I don't think that that's what I'm looking for. Any help here would be appreciated! For reference, I'm using Drupal 7.


texts: How can I use configuration management to "snapshot" config on my dev server while I try new things out?

texts:
I was a heavy Features module user in Drupal 7 so I'm trying to use Configuration Management in Drupal 8 to recreate my old workflow.

In Drupal 7, when I wanted to try making changes, I would:

Add my current config to a feature (store the values of variables with Strongarm)
Export the feature.
Commit the code.
Mess around with the variables and see if I like my changes better.  If yes, update the feature.  If no, revert the feature.

The key to this workflow was that I was storing the config in code on the same dev server that I was using; in other words, I wasn't syncing between two servers, but rather using the Features module to store a snapshot of a working configuration while I made changes that would potentially need to be reversed.

I see that I can use Configuration Management to export configuration, but this is in archive format, which isn't very easy to diff.  Also, committing a bunch of archives to my git repository seems like the wrong way, and a big step backward from Drupal 7.

My question: In Drupal 8, is it possible to export configuration such that it can be committed to a git repo, then diffed and used as a "reset button" when making changes that go awry?

What I tried

In the Configuration Management documentation, it has the following solutions:

UI-based
Drush-based
File--system-based

But what I'm looking for is code-based.  I thought this might be "file-system-based", but these files are in the /files directory, which is usually exempt from git by the .gitignore file.


texts: Where is the setting saved when I modify a configuration setting?

texts: When I modify a setting from a custom module, where is that saved?  How can I get that setting without exporting the configuration?


texts: What are the nfs values seen in the Strongarm seciton of features

texts:
When preparing a feature I see that there are a number of values beginning nfs_ in the Strongarm section.

What are these nfs_ values and do I need them in my feature?


texts:
I've got 'Webform 7.x.3.20" installed on my Drupal 7 and it works perfectly, apart from it seems to have 'broken' the MySQL database. I first noticed this when I tried to use the 'Backup and Migrate' module - I got the following error:
Additional uncaught exception thrown while handling exception.

Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000]: General error: 2013 Lost connection to
MySQL server during query: show table status; Array ( ) in
backup_migrate_source_db_mysql->query() (line 435 of
/home/example.com/public_html/sites/all/modules/backup_migrate/includes/sources.db.mysql.inc).
Additional
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has
gone away: INSERT INTO {watchdog} (uid, type, message, variables,
severity, link, location, referer, hostname, timestamp) VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2, :db_insert_placeholder_3,
:db_insert_placeholder_4, :db_insert_placeholder_5,
:db_insert_placeholder_6, :db_insert_placeholder_7,
:db_insert_placeholder_8, :db_insert_placeholder_9); Array (
[:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] =>
php [:db_insert_placeholder_2] => %type: !message in %function
(line %line of %file). [:db_insert_placeholder_3] =>
a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:112:"SQLSTATE[HY000]:
General error: 2013 Lost connection to MySQL server during query: show
table status; Array ( )
";s:9:"%function";s:39:"backup_migrate_source_db_mysql->query()";s:5:"%file";s:96:"/home/example.com/public_html/sites/all/modules/backup_migrate/includes/sources.db.mysql.inc";s:5:"%line";i:435;s:14:"severity_level";i:3;}
[:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] =>
[:db_insert_placeholder_6] =>
http://example.com/admin/config/system/backup_migrate
[:db_insert_placeholder_7] =>
http://example.com/admin/config/system/backup_migrate
[:db_insert_placeholder_8] => 82.29.92.127
[:db_insert_placeholder_9] => 1409596675 ) in dblog_watchdog()
(line 160 of
/home/example.com/public_html/modules/dblog/dblog.module).
Uncaught exception thrown in session handler.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has
gone away: SELECT 1 AS expression FROM {sessions} sessions WHERE (
(sid = :db_condition_placeholder_0) AND (ssid =
:db_condition_placeholder_1) ); Array ( [:db_condition_placeholder_0]
=> Zy8B5O3kHHKb5uIZnFFODRyXl9C_a82Ek-o9why5wNU [:db_condition_placeholder_1] => ) in _drupal_session_write() (line
209 of /home/example.com/public_html/includes/session.inc).

I then went to look on phpMyAdmin to find that if I clicked on the database itself, it showed that there were no tables and has started logging me out of phpMyAdmin almost immediately. However, if I click on the '+' to the left of database name on the left hand side, I can view all of the tables in the database and even browse them individually.
Finally, I have used mysqlcheck over SSH and found that all the tables are OK until it reaches any belonging to webforms, and then I get "Got error: 2013..." again. I know for definite it is the module because I tried removing the tables for the database, and everything goes back to normal.
Any ideas why this is happening and how this can be fixed? The webform module is excelllent and I do make good usage of it, however I'm going to have to find an alternative if this continues as I can't even update Drupal core or backup the database at the minute!


texts:
After several days and more hours I only found issues and patches about what to do once a cookie is set, but not one is mentioning how you get a cookie set in the first place.

Our intention would be to set a (session) cookie of the landing page (for ALL user roles) and retrieve that cookie on certain pages, through views, to use in the URL of an outbound link.
This would be very simple in standard programming (even I understand) but I am starting to have considerable doubt if this is actually possible in Drupal.


texts: Add basic page title and its teaser view in basic page

texts:
I wanted to have one basic page, that allows me to add brief data about other basic pages like title and some data in teaser view. ie to create basic page, whose content is, some content of other basic pages.

I know that we can achieve this by using view. But I wanted to know if there is module available that allows me to do this, so that I can select the pages which are to be embed in the page I am creating.


texts: How attach a Custom Field do it by code to a Custom Type Page

texts:
I create by YAML files a Field Custom, using the next documentation:

https://www.drupal.org/docs/8/api/entity-api/programming-custom-fields-into-your-content-type

In this tutorial attach the field to Custom Type "car_brand" created by code, in my case I need attach the custom field to the Custom Type "page", he come default in drupal.

How I can attach the field to "page" content type?

Thanks a lot.


texts: How do you add an incrementing primary key to an existing table?

texts:
I'm working on the contributed Login History module which has an existing table that does not have a primary key. I'd like to add a primary key to the table, but am struggle with the db_add_field syntax for upgrades. The existing table is:

/**
 * Implements hook_schema().
 */
function login_history_schema() {
  $schema['login_history'] = array(
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'uid of user.',
      ),
      'login' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => "Timestamp for user's login.",
      ),
      'hostname' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => "The user's host name.",
      ),
      'one_time' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Indicates whether the login was from a one-time login link (e.g. password reset).',
      ),
      'user_agent' => array(
        'type' => 'varchar',
        'length' => 256,
        'not null' => TRUE,
        'default' => '',
        'description' => 'User agent (i.e. browser) of the device used during the login.',
      ),
    ),
    'indexes' => array(
      'login_history_uid' => array('uid'),
      'login_history_onetime' => array('one_time'),
      'login_history_uid_host' => array('uid', 'hostname'),
    ),
  );
  return $schema;
}

And what I think should work to add a primary key is a hook_update like this:

/**
 * Add device_id and login_id columns.
 */
function login_history_update_7106() {
  if (!db_field_exists('login_history', 'login_id')) {
    db_add_field(
      'login_history',
      'login_id',
      array(
        'description' => 'The primary identifier for a login.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      array('primary key' => array('login_id')));
  }
}

However, that results in this error:

SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead                                                                                [error]

I've tried:

Reading and re-reading the docs for db_add_field and db_change_field
Using db_add_field to add an empty int field and then using db_change_field to make it a serial primary key.
Using db_add_field without the 4th parameter that sets the new primary keys and then trying to use db_add_primary_key('login_history', array('login_id')) but that gives an error before the field is even added saying that auto_increment fields have to be part of a unique key.

I've grepped core and some contrib looking for instances of adding an auto increment primary key and can't find any for Drupal 7.


texts: Views Table Grouping not working if group field is blank

texts: I'm using Drupal 7. In a field collection view, I have data in a table that has field groups. I have 3 fields I want to group on, the first two are required, the third is optional. Everything worked until I added the 3rd field. When there are records with no data in that field, the record shows up as a row of empty table cells. Can anyone suggest a fix for this?


texts: domain-name.com/user and other URLS not loading

texts: When I go to my domain.com/user I get a blank page, where as usually that was the URL  I go to to log in and change content. I came across this thing: https://www.drupal.org/node/256410, but I do not know if it is the same issue. I tried uploading a new .htaccess file to no avail. Any thoughts/ suggestions?


texts:
I am trying to set up a D8 (8.7.9 to be precise) multilingual site and hitting some weird bug.

I have a node type basic page consisting of the title field and a body text field.

Initially I create the page in German (title: "test page de" / content "test content de"), then click Translate to add an english version, save it. So far, so good - the german page pops up at /de/node/12, the english one at /en/node/12, the language switcher works fine.

Then, I edit the German page to say "test page de-1"/"test content de-1", and submit. The German page shows the proper content, as does the English one, but now, when I edit the English page, I suddenly get the title set to "test page de-1" and the body to "test content de-1". What is going on here?


texts: How to link to last comment on a node page?

texts:
I have some nodes with lots of comments that use a pager. I want to link from the top of the node page to the last comment.

Is there a simpler way than building the link like this (source):

Get number of (published) comments for a certain node;
Get number of comments per page (it can differ from on content type to another);
1+2 = number of pages;
Get cid of the last comment;
Create a link like /node/[nid]?page=[page]#comment-[cid]


texts: I want to show a progress bar during form is submitted and processed until submission is created

texts:
I am using Form API to create a form on a page and I ask user to submit CSV File which is then process in _submit function for that form. Kindly suggest me a way to add progress bar with Drupal's way. I tried this actually but did not work.

function userop_form_users($form_state) {

  $form['file'] = array(
    '#type' => 'file',
    '#title' => t("Upload CSV file containing information."),
    '#description' => t('Download sample file.
Upload a file, allowed extensions: csv'),
    '#ajax' => array(
        'progress' => array('type' => 'bar', 'message' => t('TestMessage'),'interval' => '1500'),
     ),
    );

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

  $form['#cache'] = FALSE;
  return $form;
}


texts: How do I apply HTML IDs to field output result?

texts:
I'm trying to build a block for tb_megamenu of a view of items of a certain content type. I want to use some JavaScript so that when the end user hovers over a title then associated content appears on the right hand side.
I've got the JavaScript/jQuery functionality working by attaching a library to the views display twig template and it works with a simple global text field using the correct IDs. However, it won't work with tokens because all ids will apply to all instances of the field content, so that hovering will show all related content.
Is there a way to separate the fields out like a delta field? I can build this in HTML ultimately but it wont be manageable by the end user ultimately.
Note: The tb_megamenu is irrelevant really. Just a view. Imagine a list of links coming from a field in a content type - Title1, Title2, Title3 - 3 pieces of content. I add another field to the view - Summary for example. I want to display the summary related to Title1 if I hover over Title1. And the summary for Title2 if I hover over Title2. My approach which I dont think can work was to hide the fields and to rewrite the output in a global text field using tokens. I add a javascript library to the view template so that I could use divs in the rewritten output.


texts: How can I make a drupal field that gets a value from a specific database/table, it should be a select list. What I need is to have a drop down select where I can see all entries from a specific content on the drupal system. So I have content type A, and content type B. When I want to create a new content of type B I want a select box where all entries from content A are listed.


texts: What is the Drupal 6 equivalent or alternative to hook_node_load?

texts: In Drupal 7, there exists the function hook_node_load. Does anyone know how I can hook into a node being loaded from the database in Drupal 6? If not, can you suggest an alternative hook? I am simply trying to get my custom module to load my javascript file upon the user visiting a particular node page. Thanks.


texts: Multiple Drupal sites using the same code base

texts: Is it possible to use the same Drupal code base for different Drupal sites, just by changing settings.php and the database settings, and accessing it through a subdomain?


texts: keywords and description for front-page of drupal 7 site

texts: I managed to set page titles with the "Page Titles" module and keywords and description with the "Meta Tags (Quick)" plugin, however it seems like there is currently no way of having custom keywords/description for the front-page. Does anybody knows of a work around this?


texts: Expose a view filter that lists usernames of a specific roll in a roll down menu

texts:
I have a view on one of my sites that list a table of content that is connected to (entity reference) a user with a specific role.

Is it possible to make an exposed filter that lists all users of role X in a roll down menu?


texts: How do I implement 'fuzzy' search with the Solr search API

texts:
Some sources equate 'fuzzy' search with matching partial terms (substrings), others include matching misspellings, also, as being 'fuzzy' search. I want to do both.

I have configured partial word matching, so that a search on 'break' will return results for content that includes the term 'breakpoint'. See here.

How do I configure Drupal/Solr so that a search on 'Brasil' will return results for content that includes the term 'Brazil'?

I am running:

Search API: 8.x-1.0-beta4
Solr search: 8.x-1.0-beta1

I added the following to schema.xml, under the first occurence of <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/> within the field type <fieldType name="text" class="solr.TextField" positionIncrementGap="100">:

<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="25" side="front" />
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="25" side="back" />

So, a search on 'hell' or 'ello', for example, returns reults for 'hello - but a search on 'hillo' returns nothing.

I've found the below on d.o, but I'm not sure it refers to solr:

  Fuzzy Searches

  Lucene supports fuzzy searches based on the Levenshtein Distance, or
  Edit Distance algorithm. To do a fuzzy search use the tilde, "~",
  symbol at the end of a Single word Term. For example to search for a
  term similar in spelling to "roam" use the fuzzy search:

  roam~

  This search will find terms like foam and roams. An additional
  parameter can specify the required similarity. The value is between 0
  and 1,, and with a value closer to 1, only terms with a higher
  similarity will be matched. For example:

  roam~0.8

  The default value is 0.5 if the parameter is not given.

I'm not convinced this is even possible. Thanks.


texts: How do I select a table using a variable with db_query()?

texts:
I'm trying to find records from a table based on a variable that is grabbed from user submission. This is my query:

$field = t('field_data_' . variable_get('tabbed_content_field'));
$fieldValue = t(variable_get('tabbed_content_field') . '_value');
$query = db_query('SELECT :fieldValue FROM {:field}', array(':field' => $field, ':fieldValue' => $fieldValue));

However, whenever I run this query I get the following error:

  PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064
  You have an error in your SQL syntax; check the manual that
  corresponds to your MySQL server version for the right syntax to use
  near ''field_data_field_news_release_date'' at line 2: SELECT
  :fieldValue FROM {:field}; Array ( [:field] =>
  field_data_field_news_release_date [:fieldValue] =>
  field_news_release_date_value )

I can retrieve the records successfully with:

$query = db_query('SELECT ' . $fieldValue . ' FROM { ' . $field . '}');

However, as I understand it this would be insecure.

Does anyone know why the first query won't work?


texts: Is it possible to only update one panel (or block) as a result of a the URL clicked elsewhere?

texts:
Is it possible to only update the content in a particular panel as a result of a URL clicked elsewhere? (i.e no other pages get refreshed.)

I have created Views with context filters and would be using them in Panels and would prefer for the whole page not to have to be refreshed.

I'm particularly interested in how to retain the zoomed position of a OpenLayers map, but general advice welcome. (I would consider my OpenLayers use as being a 'side' case of my general question. I think the permalink co-ords option may help me here.)


texts:
My custom module needs content of a page generated by another custom module. Please note I am not trying to pull a node content, so my question is different than one on How to load page content by url programmatically in custom region

If I put dpm(render($page['content'])); in page.tpl.php and go to the page generated by the other module then it outputs the exact part that my module needs. Unfortunately, the other module doesn't provide a hook for the needed content part, so I need to first load that page and then extract $page['content'] part.

Is there any way to load a custom Drupal page's content knowing only its URL?


texts: Why doesn't "composer update drupal/drupal" work?

texts:
I installed a Drupal 8.2.0 site with composer create-project drupal/drupal testsite.

Now I would like to upgrade it to Drupal 8.2.1. However, running composer update drupal/drupal  doesn't work. It prints the following error:

  Package "drupal/drupal" listed for update is not installed. Ignoring.

How do I do this? The support is clearly documented in example.gitignore.

# Ignore core when managing all of a project's dependencies with Composer
# including Drupal core.
# core

So there has to be some way to do this with composer, but how?


texts: The connection to the server was reset after trying to log as admin to Drupal

texts:
I did upgrade on Drupal 7 and imported these sites and database from localhost to another server. On localhost everything works well, on the server I can´t log to Drupal as admin. After  entering password every browser shows similar message:The connection to the server was reset while loading page. When I want to change address in browser after that I have to delete all history, cookies, cache, etc., otherwise it writes the same message. I changed base_url, cookie_domain in settings.php, deleted cache and session tables in database. It didn't help.

Notes:

Putting /?=admin doesn't work, I am redirected to homepage, even on my localhost page where I can login .htaccess has the same content as old .htaccess
My pages are on web hosting. I am not sure if I can restart webserver by myself.
About server log messages: any special thing except of missing of favicon.ico in folder. I repaired it.
I tuned the .htaccess file. I don't see effect for a while. Maybe after server restart?
I don´t have Coder module.
my web hosting doesn't allow me increase stack size. Is this problem always connected with some Drupal module? Is somewhere some list of Drupal modules which causes page reset after admin login? Code module isn't my case.

This problem was finally solved by Php upgrade on the side of hosting server!


texts: Use Subdomains as variable with Domain Access

texts:
I'm new to Domain Access module. It seems it is built to allow you to run different sites off the same database. I'm looking for something more simple than that.

I want to the subdomain title to be included in the site name. I want a content type to be assigned to different subdomains and for that content to be the only content of it's type visible on the same subdomain.

Aside from that, everything else on the site should remain the same. Theme, users, layout, etc.

How can I best do this with DA module? Is it possible to use the domain as a variable (for use in views, panel's context and a token for the site name)?


texts: Drush: Listing all modules installed on multiple servers

texts:
I have many servers installed on the same network, and I want to check them all to see if they need updates.  This requires me to login to each server and run drush up and check the results.

Can someone suggest a better way to do this, maybe a script or something similar?


texts: Remote entities versus local entities for third party integration

texts:
While integrating any third party tool with its own data storage capabilities, I usually end up with a question

So far I could figure out following Pros and Cons in both the cases.

PROS for storing on Drupal(local entities):

Easy reporting with views.
Being local entites to Drupal, we can leverage drupal out of the box functionalities like add/edit/delete forms.

CONS for storing on Drupal(local entites):

It creates dependency on Drupal, while the third party tool has all possible capabilities to run as standalone application.

Another possible option could be storing at both places Drupal and third party tool

But that would cause data syncronisation problem, and will require development at both ends to push data changes.

An example of such integration I recently came across is Camunda(BPM tool).

What will be a suitable place for data storage? Should we keep it on Drupal, or should we leverage third party storage capabilities?


texts: Views - Unable to set custom form field value in Exposed form

texts:
I have a view with 2 exposed filters . one is the start date and the other is the end date. I need to programatically control the end date filter based on a checkbox. I added a checkbox to the exposed form in the form_alter hook. I implemented views_query_alter hook to update the expiry date value based on the state of the checkbox. This works as expected so far.

The problem is with the display of the checkbox in subsequent displays of the page(Ex: Pagination or submit exposed form). I need to get the submitted value of the checkbox and display it as checked or unchecked accordingly. I am unable to get the value submitted for the checkbox using the variables $form and $form_state.

Can someone help me in getting the submitted value for a custom field in hook_form_alter?

Link to a similar issue.  Not sure if the solution provided here works.


texts: Is there a way to call a drupal ajax function on a multistep form without causing the form to resubmit?

texts:
I added a drupal ajax element to my multistep form but when it runs, it reloads the entire form.

The problem is, there is logic which is performed via a case structure for each step.  When the ajax loads, the next step's logic is ran.

For example, the user is on step 2 of a 4 step form.

The user will cause an ajax call to load in a preview image.  Triggering this ajax call loads step 3.

Triggering the same ajax call again will submit the form (step 4) causing very undesirable results.  Is there some sort of secret voo doo code or argument I can use to prevent this?


texts:
I need to create a post/comment structure almost exactly like what you're looking at right now: original post with comments, subsequent 'answer' posts with their own comments. In response, I'm displaying a views page with a custom path displaying the original post (content type) and the subsequent answers (also content types). The issue lies with printing comment forms for each of the following nodes.

So far, I'm attempting to use the Views PHP field to print the comment form and failing pretty hard. There is D7 comment form doesn't submit relating to this, and Nikit's solution did produce a comment form on demand. However, this form does not submit or preview, submission just redirects the user to the node's comment reply page. Even now I do not understand how this method of calling drupal_get_form() works with two arguments.

So I turned to the trusty Drupal API to reference the drupal_get_form() function and saw that it doesn't take two arguments and returns drupal_build_form() instead. I thought that calling drupal_build_form() straight up might be more appropriate, since from what I could gleam off of the scarce user feedback said I needed to use a form_state['redirect'] of some sort to get users back to the original node page they posted their comments from. As expected however, everything I try returns a pile of errors and gets me nowhere.

The one spot of success was with the Commentsblock module that allowed me to place a real live comment form on a page and actually have the stupid thing submit a comment. While this works for the main content, I'm still at a loss for the subsequent 'answer' comments/forms. In ripping through the source code for the module I discovered comment_node_page_additions($node);, but this does not turn out any valid results either.

There are so many questions here:

How does one actually USE the Forms API (and to print comments)?
Should I be doing this in a .tpl file instead of Views?
Where does the second argument of drupal_get_form() go?
What exactly is the difference between drupal_get_form and drupal_build_form and how are they used?
Is $form_state['redirect'] called before either of these API calls or after?

This might seem like 'too much' of a question for a single thread, but I'm tired of posting partial questions and getting partial answers. In the interest of education, I would like to build some sort of tutorial either on Drupal.org or elsewhere so that this information can be made available to others in the same situation. Obviously I am not the best person to undertake this due to my massive lack of understanding, but maybe, just maybe with your help this can become a reality.


texts: How can I make a node-specific variable available to me using variable_get() within a block?

texts:
I am using PHP code in a block with the PHP filter module. I am attempting to render an image within this block and the image rendered should be dynamically determined and specific to the content being shown in the content block. I was thinking I could use something like the node id or title of the page but so far I have been unable to use $title or $node->id.

So far my proof of concept with this is limited to being able to determine the site name or site slogan which is not specific to the node (and therefore doesn't help). This is what the code in my block looks like now. If I can figure out a way to replace $site_name with something useful, I will put that at the top (instead of the the $gbhe variable) and use it to determine which image to show.

  <?php
  $gbhe = true;
  if ($gbhe) {
    $src = "http://localhost:8888/drupal-7/sites/this_site/files/SIDEBAR_IMAGE-P2_07.gif";
  } elseif (!$gbhe) {
    $src = "some_other_image_url_TBD";
  }
?>

<img alt="gbhe" src="<?php print $src; ?>" />

<?php
  $site_name = variable_get('site_name');
  echo $site_name;
  // $my_vars = get_defined_vars();
  // print_r($my_vars);
?>


texts: How can I create 301 redirects from "unclean" URLs?

texts:
I am moving a Wordpress site to Drupal and want to ensure that proper 301 redirects are in place for SEO purposes.

The old urls are in the form of: http:www.domain.com/?page_id=123

I was hoping this would be simple enough with the Redirect module, but when attempting to enter a path such as ?page_id=123 I see the following message.

  The source path /?page_id=123 is likely a valid path. It is preferred to create URL aliases for existing paths rather than redirects.

I want to be absolutely sure that a 301 redirect is created but I am unsure that adding an alias is the correct method for this.

Another approach I have considered is adding the following code to the .htaccess file in the web root.

Redirect 301 /?page_id=123 https://www.exacmple.com/node/321

Again, I am unsure if this approach is recommended for Drupal 8.

How should I add redirects and avoid the new Drupal site is penalized in search results?


texts:
I want to hide the user's blog link that appears on blog entries e.g Anonymous's blog

How can I do this in node--blog.tpl.php?

I tried hide($content['author']); but that doesn't seem to work.


texts: I have a drupal site and I exported a Drupal feature and got a download file. Now I want to import that file to another drupal site, but there is no import function, so how do I add it?


texts: Commerce - Discount on three or more products in order

texts:
I am moving my site from Ubercart to Commerce and would like to replicate a discount that I have set up in Ubercart.
I have an Ubercart coupon that automatically adjusts the price for a product if there are three or more applicable products in the order.
I have spent all day looking at Commerce Coupons and Commerce Discounts but have not found a way to do this yet
Is this possible?


texts: Add CSS just to the main content and not to include comments

texts:
I'm theming using the Omega HTML5 starterkit theme on Drupal 7, and I want to add CSS just to the main content region in nodes but not to the comments.

How do I do that? What is the class (or ID) for that?


texts: Drupals clean-urls (.htaccess) breaks with mass vhost

texts:
Apache has a nifty mass vhost feature. Problem is, when I use this to reach my site, clean-urls stop working. Is there a way to combine this with clean urls?

<Directory /var/www/localhost/htdocs>
  Order allow,deny
  Allow from all
  AllowOverride
</Directory>
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /tmp/access_log vcommon
VirtualDocumentRoot /var/www/localhost/htdocs/%0/web
VirtualScriptAlias /var/www/localhost/htdocs/%0/web

Obviously I've attempted to add

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

to the <Directory/>, but that doesn't help.


texts: Allow anonymous users to post content but require login/register before it is saved

texts:
I have a website with a node form displayed as a block on the frontpage. This is done to make sure users get down to posting content easily and quickly.

However I'm interested in saving details of the poster so they can later be notified of comments, etc to their node. I would like for the user to then be required to login or register before their content is posted.

So from nodeform block, they click Save and then they are asked to login or register..After that content is saved.

Is there any module that does this, or what approach can I take to code my own?

Thanks


texts: How do I update the URL after changing the hosting of a website?

texts: Our website recently changed hosts. After updating the named servers the home page shows but all links in the page take you to 404 error.  The new host advises that the URL links need to be refreshed.


texts: How do I remove "active" css class from breadcrumbs?

texts:
I am trying to include Structured Data in my breadcrumbs. The google validator throws an error on my final breadcrumb. When I remove class="active" from the code in the code validator window the code passes without error.

I used the theme_breadcrumb hook to add the Structured Data Markup to the breadcrumbs, but there is no mention of the css active class.

function MYTHEME_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];
    $breadcrumb = substr_replace($breadcrumb, 'http://mywebsiteexample.com/', 9, 1);
    $rich_snippet = 'rel="v:url" property="v:title" ';
    $breadcrumb = substr_replace($breadcrumb, $rich_snippet, 3, 0);
    if (!empty($breadcrumb)) {
        $breadcrumb[] = ''.drupal_get_title().'';
        //Added this line  to avoid displaying node title twice
        unset($breadcrumb[count($breadcrumb) - 1]);
        $output = '' . t('You are here') . '';
        $output .= '
' . implode(' » ', $breadcrumb) . '
';
        return $output;
      }
    }

Is there another hook I can use to remove the active class exclusively for breadcrumbs? Ideally I would like to do it without inserting Javascript into any templates.


texts: How to edit the id of a form element of a content type?

texts:
I have a content type with a text field that I need Javascript to do some work on (when in the content type add/edit form). I prefer to have Javascript identify the form element by it's id so I would like to set the id of the form element to something meaningful.

I've attempted to set the id in with a hook_form_alter() but to no success. If I kint() out the template with the form I do see the id being set in the kint() info however the actual form element html is unchanged. My hook_form_alter():

function hook_form_alter(&$form, FormStateInterface $form_state) {
  $form['field_element_name']['#id'] = 'element_name_id';
}

Is what I'm attempting possible and if so does anyone know how to do this? Or is there some completely different way of achieving this?

Thanks!


texts: Using Migrate API to select items from within an Events JSON array

texts:
I am using the migration import to pull in events from a calendar service json api. I can capture and map almost all the event details except the start date which is contained within an array. I tried to use the extract plugin but can't quite get it to work.

"events": [
   {
      "event": {
         "id": 920693,
         "title": "This is the event",
         "url": "http://woodowloriginaldesigns.com/what-lies-beneath/",
         "photo_id": 481020,
         "detail_views": 892,
         "event_instances": [
             {
                 "event_instance": {
                     "id": 2711527,
                     "ranking": 0,
                     "event_id": 920693,
                     "start": "2017-06-28T00:00:00-04:00",
                     "end": null,
                     "all_day": true
                 }
            }
    ],
    "address": "124 Main Street USA",
    }
  }

I am trying to get the "start" date out of there. The process section for my yaml file for the start date currently looks like this:

field_importdate:
  plugin: extract
  source: event_instances
  index:
    - 0
    - event_instance
    - start

When I omit this, I can successfully pull in/map all the other fields with a drush migrate-import jobnamehere  command.

How should my extract plugin be configured here to get the start
date?

Happy to provide more details and entirety of yaml file if needed.


texts: When should I use Apache Solr instead of Drupal core search?

texts:
I'm in the process of migrating a medium-sized on-line magazine to Drupal.

I do not know much of Drupal's internal search engine capabilities, but I'm aware of the Apache Solr Search Integration module, which integrates the java-based search engine from Apache. Unfortunately, Solr is something new to me too.

So my questions are:

When should I use Apache Solr instead of the Drupal core search? In what type of websites core functionality is not enough? Should I care about the performance gains of using Solr if my visitors only do hundreds of searches per day?
Will learning how to use and integrate Apache Solr cost me lots of weeks/months?