texts: Grouping galleries with Colorbox modules

texts:
Since two days that i'm looking around to find a easy and simple gallery for Drupal 7.32 and it seems much more complicated that how should be.

I think Colorbox is exactly what i'm looking for but I cannot find a good tutorial or resource that explain how to create a page with thumbnails that groups different galleries.

So when click on them I should go in another page and see all those thumbs from one specific gallery and be able to click on that and see them as slideshow.

More or less like here:
http://www.hopkinsco.com/portfolio

Can you please point me in the right direction?

Of course if you want to suggest another module or method is fine as well.


texts:
I'm having an issue when creating a new view. The preview pane, upon refreshing/updating" will, instead of updating in the preview section, force the window to navigate to "admin/structure/views/view/MyView/preview/default/" . It doesn't matter is "auto preview" is checked or if I manually press the "update preview" button. I have no idea what i changed recently to start getting this behaviour. My initial thought is that I removed an important js class from a template but I haven't been able to identify which one. I also know it's a theme issue because reverting to any other stable theme fixes the problem!

Is there a better resource for finding what classes are important for core ajax components because I can't find much on the official documentation. Additionally, has any experienced this and know what I might have changed to get this behavior?


texts: Twig finds if statement true whether or not field has value

texts:
I have a paragraphs field that contains a sub-title which is optional. My code below still prints out the h3 tag whether or not the sub-title has any value. Any idea why this is happening as I need to hide the h3 html if there is no value, thanks.

{% block content %}

{{ content.field_title }}

            {% if content.field_sub_title %}

{{ content.field_sub_title }}

            {% endif %}

              {{ content.field_prod }}

{% endblock %}


texts: Dynamic Persistent Menu problem / module alternatives

texts:
I'm using Dynamic Persistent Menu (DPM) but I can't make it work. I have a Main Menu, most of the items have children, and since I don't want those parents to be links I'm using Special Menu Items module (I mention this in case there could be a conflict).

I installed DPM; then go to config > User interface > DPM, add new and select Main Menu as the Menu Root and save. I haven't found any steps to follow from there, so I figured that was it, but the children items do not show up. I tried enabling the DPM block but then I get a blank site.

Anyone who has used this module, could you guide me through it? I need the exact functionality this module provides, and from what I've seen neither Superfish nor Nice Menus modules can do this.

Thank you for any help :)


texts: Image Files Uploaded via REST got Temporary status - Cannot be refereced by Media Image

texts:
Drupal 8.9.11
Image File Uploaded via REST gets "status - Temporary" while setting explicitly "status" case to True server error 403 (code in python)
   "status": [
      {
        "value": True
      }
   ],

The sever returns code 403, an exception:
Status: 403, Message: {"message":"Access denied on creating field \u0027status\u0027."}

The error on the server:
$ vendor/bin/drush watchdog-show
access denied Warning Path: /themag_dp8/entity/file?_format=hal_json.
   Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: Access denied on creating
   field 'status'. in Drupal\rest\Plugin\rest\resou

If I'll not specify "status = true" The next REST call to Create Media fails to reference it due to its temporary status.
   payload = {
        "name": {
            "value": name
        },
        "field_image": [
            {
                "target_id": file_id
            }
        ],
        "field_description": [
            {
                "value": description
            },
        ],
        "bundle": [
            {
                "target_id": "image"
            }
        ],
        "_links": {
            "type": {
                "href": oauth.base_url + REST_TYPE_MEDIA_IMAGE
            },
            oauth.base_url + "/rest/relation/media/image/thumbnail": [
                {
                    "href": oauth.base_url + "/file/%d" % file_id + FORMAT_HAL_JSON
                }
            ],
            oauth.base_url + "/rest/relation/media/image/field_image": [
                {
                    "href": oauth.base_url + "/file/%d" % file_id + FORMAT_HAL_JSON
                }
            ]
        }
    }

Status: 422, Message: {"message":"Unprocessable Entity: validation failed.\nfield_image.0.target_id:
This entity (file: 119) cannot be referenced.\n"}

Server error:
$ vendor/bin/drush watchdog-show
access denied Warning
    Path: /themag_dp8/entity/paragraph?_format=hal_json.
    Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException:  in
    Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 120 of
php           Error
    Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException: Unprocessable Entity:
    validation failed.
    field_image.0.target_id: This entity (file: 119) cannot be referenced.
    in

When I manually, via web site admin (https://drupal8.site/admin/content/files), change the file status to "Permanent", this Create Media REST call succeeds to create a new media/image entity.
Seems the Rest user missing some security allowances, but which one?
Did anybody succeed to create a node consisting of the teaser image, paragraph video and so?
Sure I'm not the first who attack this issue, where the relevant documentation, working code examples?


texts:
I am working on a module with a form that allows multiple "members" to be submitted. The form allows the number of members to be specified, then displays a set of member fields that many times. This is working well, but the set of fields for each member is fixed.

I'm looking at whether it would be possible to turn it into an entity form to allow the set of fields for each member to be configured.

Is it possible for an entity form to display several sets of fields on one form, and have them all submitted together?

Any pointers on how to start?


texts: Kernel test crashes with a Drupal\Core\DependencyInjection\ContainerNotInitializedException

texts:
I have a kernel test that's crashing with a Drupal\Core\DependencyInjection\ContainerNotInitializedException.
The test involves a custom entity type which has a computed field. The computed field's class uses createItem() to create a field value which holds computed data:
class MyComputedFieldClass extends FieldItemList {

  use ComputedItemListTrait;

  /**
   * {@inheritdoc}
   */
  protected function computeValue() {

    $this->list[0] = $this->createItem(0, [
      'value' => 'foo',
    ]);
  }

}

The backtrace shows that this is where the problem happens:
1) Drupal\Tests\my_module\Kernel\EntitlementsTest::testEntitlementTypeFixed
PHPUnit\Framework\Exception: Fatal error: Uncaught Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in /var/www/docroot/core/lib/Drupal.php:131
Stack trace:
#0 /var/www/docroot/core/lib/Drupal.php(159): Drupal::getContainer()
#1 /var/www/docroot/core/lib/Drupal/Core/Field/FieldItemList.php(41): Drupal::service('plugin.manager....')
#2 /var/www/docroot/modules/custom/my_module/src/Field/MyComputedFieldClass.php(30): Drupal\Core\Field\FieldItemList->createItem(0, Array)

What's going on?


texts: Meta tags aren't saved with all content types

texts:
I use the module Meta Tags for adding meta data to my nodes. And it works like a charm. It's super easy to add meta tages like title, keywords, description,... even our IT-noob marketing team can do so. It's awesome.

However, not all content types seems to be able to save those meta data. I've got 12 content types and 3 of them don't display the meta data. Although I add them like on the other nodes...

Here is the source code of a node without any meta:

And here with meta:

So correct me if I'm wrong, but I don't see any meta data in the first example.

Strange part, all the data is present in the database (table metatag), so all nodes does save the meta data, but for some reason, some content types aren't displaying the meta data.

What could be the cause of this "bug". Could it be something like hiding certain content in the template files since they all have a separate .tpl.php file? Or what other causes are you thinking of?


texts: I have a small number of location nodes with geofields, and need to programmatically get the distance between a location and a zip code.  It would be ideal if I could get a query, or a sort, of my location nodes by proximity to the zip code.  I couldn't easily tell how to do this in the geoPHP module.


texts: Go to previous page (not after form submit)

texts:
I have a function that is called by hook-menu item an is accesible from different subpages of the site. This function does not return any html, it just do some database inserts and should redirect user back where he came from.

Well, it could be easily done by adding url args as a parameters to this function and then use drupal_goto() with those arguments. But I'm wondering if there is any drupal function for this. I was trying drupal_goto(drupal_get_destination()); but it does nothing.


texts: Why drush fails to rsync between my two local instances?

texts:
I'm trying to synchronize two local drupal repositories using the following command:

drush rsync

My environment:
 - drush 6.1
 - Mac os X 10.9
 - drupal 7.24

I have followed standard security recommendations for Drupal and configured
permissions with:

MBPC:files pc$ pwd
/Users/pc/Sites/mysite.dev/sites/default/files
MBPC:files pc$ ls -al
total 8
drwxrwx---+ 8 _www  staff  272 18 jul  2012 .
drwxr-xr-x+ 4 pc    staff  136 23 nov 15:08 ..
-rwxr-----+ 1 pc    _www   477 21 nov 15:19 .htaccess
drwxrwxr-x+ 3 _www  staff  102 18 jul  2012 color
drwxr-xr-x+ 3 _www  staff  102 22 nov 09:53 ctools
drwxr-x---+ 3 _www  staff  102 23 mai  2012 pictures
drwxr-x---+ 3 _www  staff  102 23 nov 16:24 private
drwxr-xr-x+ 2 _www  staff   68 24 oct 17:37 styles

The user pc is a member of the _www group.

The .htaccess file contains (following the latests Drupal security warnings) as follows:

# Turn off all options we don't need.
Options None
Options +FollowSymLinks

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

There is a similar .htaccess file in the private subdirectory.

I'm using the following command:

$ drush rsync @mysite.dev @mysite.local

and I get this error message:

You will destroy data from /Users/pc/Sites/mysite.local/ and replace with data from /Users/pc/Sites/mysite.dev//
Do you really want to continue? (y/n): y
rsync: failed to set times on "/Users/pc/Sites/mysite.local/sites/default/files": Operation not permitted (1)
rsync: recv_generator: mkdir "/Users/pc/Sites/mysite.local/sites/default/files/color" failed: Permission denied (13)
*** Skipping everything below this failed directory ***
rsync: recv_generator: mkdir "/Users/pc/Sites/mysite.local/sites/default/files/ctools" failed: Permission denied (13)
*** Skipping everything below this failed directory ***
rsync: recv_generator: mkdir "/Users/pc/Sites/mysite.local/sites/default/files/pictures" failed: Permission denied (13)
*** Skipping everything below this failed directory ***
rsync: recv_generator: mkdir "/Users/pc/Sites/mysite.local/sites/default/files/private" failed: Permission denied (13)
*** Skipping everything below this failed directory ***
rsync: mkstemp "/Users/pc/Sites/mysite.local/sites/default/files/..htaccess.bVe3a4" failed: Permission denied (13)
rsync: failed to set permissions on "/Users/pc/Sites/mysite.local/sites/default/files/styles": Operation not permitted (1)
rsync: failed to set times on "/Users/pc/Sites/mysite.local/sites/default/files": Operation not permitted (1)
rsync: failed to set permissions on "/Users/pc/Sites/mysite.local/sites/default/files/styles": Operation not permitted (1)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
Could not rsync from /Users/pc/Sites/mysite.dev// to /Users/pc/Sites/mysite.local/                                                              [error]


texts: validate a base field in a particular content type

texts:
Since title field is considered as base field  in Drupal 8, I opted hook_entity_base_field_info_alter to add validation to it. But when I look at that hook.

hook_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type)

It doesn't holds a $bundle argument. So I couldn't add a validation for title field of a particular node type. How can I override it to be node type specific?


texts: Add a Module Form to a front page region

texts:
As the title reads, I'm attempting to add a custom made module (simple contact form) into a region on my front page (this may be used other places as well, but for not just the front page). Could some one lend me their eyes/advice on how to do this correctly. The region on my page is labeled sidebar_first. I have attempted to add it via a hook_block_view() functionallity, however nothing seems to be taking.

.module

function honey_front_page_form_menu(){
global $user;
//Main Page Call Back
$items['front_page_form'] = array(
    'page callback' =>'_honey_front_page_init',
    'access arguments' => array('access content'),
    'title' => t('Honey Contact page Form'),
);

}

function honey_front_page_form_admin_form(){

  $form['front_form'] = array(
        '#type' => 'fieldset',
        '#title' => t('Admin Menu'),
);

  $form['front_form']['name'] = array(
    '#type' => 'textfield',
    '#attributes' => array('placeholder' => t('name')),
    '#required' => TRUE,

  );

  $form['front_form']['email'] = array(
    '#type' => 'textfield',
    '#attributes' => array('placeholder' => t('email')),
    '#required' => TRUE,

  );

  $form['front_form']['phone'] = array(
    '#type' => 'textfield',
    '#attributes' => array('placeholder' => t('phone')),
    '#required' => TRUE,
    '#maxlength' => 15

  );
    $form['front_form']['comments'] = array(
    '#type' => 'textfield',
    '#attributes' => array('placeholder' => t('comments')),
    '#required' => FALSE,

  );

  $form['front_form']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'SUBMIT NOW',
    '#field_prefix' => '<h3>',
    '#field_suffix'=> '</h3>'

  );

}

function honey_front_page_form_block_view($delta = ''){
//ensures form is only called on the front page.

// if (!drupal_is_front_page()){
//     return NULL;
// }

    if($delta == '1'){
        $form = drupal_render( drupal_get_form('honey_front_page_form_admin_form'));
    $block = array(
        // 'subject' => t('Subject'),
        'content' => $form,
    );

    return $block;

}
}


texts:
I am using a specific content type as blocks (via Nodeblock Module). The nodes have certain taxonomy terms referenced via a term reference field, which I would like to print out in the corresponding block.tpl.php to use them as block classes. Same procedure as one would print terms as body classes, but only in block classes array. I find solutions for printing the term field in node.tpl and page.tpl but not in block.tpl.php
Glad for any help on this
thanks
Matthias


texts:
The Drop-Down menu on a site I manage has stopped working. The link is here: http://www.lslib.com/ I suspect it might be a jQuery issue but I have installed the jQuery Update module but it still does not seem to work. Any hints on what I may be missing or what needs to be fixed?

Thank you!

I see something like this in my html:

<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
window.jQuery || document.write("<script src='/sites/all/modules/jquery_update/replace/jquery/1.10/jquery.min.js'>\x3C/script>")
//--><!]]>
</script>
<script type="text/javascript" src="http://www.lslib.com/misc/jquery.once.js?v=1.2"></script>

and I imagine a browser might take jquery 1.2 instead on 1.10. I could npt find which template <script type="text/javascript" src="http://www.lslib.com/misc/jquery.once.js?v=1.2"></script> is coming from. How can I remove this?


texts: Display menu Shopping cart (# items) and total amount

texts:
In the user menu, I added a menu link to the shopping cart:

Title: "Shopping cart (# items)"

Path: "cart/my"

How to add the total amount of the order, at the end of the title ?

I think it is necessary to use the file "template.php" of my theme.

/**
 * Implements hook_menu().
 */
function commerce_cart_menu() {
  $items = array();

  $items['cart'] = array(
    'title' => 'Shopping cart',
    'page callback' => 'commerce_cart_view',
    'access arguments' => array('access content'),
    'file' => 'includes/commerce_cart.pages.inc',
  );

  $items['cart/my'] = array(
    'title' => 'Shopping cart (# items)',
    'title callback' => 'commerce_cart_menu_item_title',
    'title arguments' => array(TRUE),
    'page callback' => 'commerce_cart_menu_item_redirect',
    'access arguments' => array('access content'),
    'type' => MENU_SUGGESTED_ITEM,
  );

  $items['checkout'] = array(
    'title' => 'Checkout',
    'page callback' => 'commerce_cart_checkout_router',
    'access arguments' => array('access checkout'),
    'type' => MENU_CALLBACK,
    'file' => 'includes/commerce_cart.pages.inc',
  );

  // If the Order UI module is installed, add a local action to it that lets an
  // administrator execute a cart order refresh on the order. Modules that
  // define their own order edit menu item are also responsible for defining
  // their own local action menu items if needed.
  if (module_exists('commerce_order_ui')) {
    $items['admin/commerce/orders/%commerce_order/edit/refresh'] = array(
      'title' => 'Apply pricing rules',
      'description' => 'Executes the cart order refresh used to apply all current pricing rules on the front end.',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('commerce_cart_order_refresh_form', 3),
      'access callback' => 'commerce_cart_order_refresh_form_access',
      'access arguments' => array(3),
      'type' => MENU_LOCAL_ACTION,
      'file' => 'includes/commerce_cart.admin.inc',
    );
  }

  return $items;
}

/**
 * Returns the title of the shopping cart menu item with an item count.
 */
function commerce_cart_menu_item_title() {
  global $user;

  // Default to a static title.
  $title = t('Shopping cart');

  // If the user actually has a cart order...
  if ($order = commerce_cart_order_load($user->uid)) {
    // Count the number of product line items on the order.
    $wrapper = entity_metadata_wrapper('commerce_order', $order);
    $quantity = commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types());

    // If there are more than 0 product line items on the order...
    if ($quantity > 0) {
      // Use the dynamic menu item title.
      $title = format_plural($quantity, 'Shopping cart (1 item)', 'Shopping cart (@count items)');
    }
  }

  return $title;
}


texts: How to get drupal 7 default file upload directory?

texts: I have trouble to get the upload directroy from drupal. Is there some function returning the relative or absolute path?


texts:
Here's the setup: the previous site builder linked a large quantity of assets to particular nodes.  Now that I'm on board, we want to expand those nodes into larger sections, but we need the linked assets to show up on all the pages.

Right now we have a view that uses a contextual filter to look at the NID.  Then, it refers to a relationship to see what assets are related to that NID.  Then, the view is filtered and displayed.

I need to come up with a way to display that same view on different pages that obviously don't share the same NID.  I've tagged all the pages within a section with the same taxonomy term.  I'd like to create a custom relationship that runs an equation that converts tid to nid.

  tid 62 = nid 15
  tid 63 = nid 47
  tid 64 = nid 153

I think you get the picture.  Any help?  If you have a better idea please let me know, thanks!
-JB


texts: Using Mailhandler commands in individual emails (Drupal 7)

texts: My business objective is to create nodes from emails and apply existing taxonomy terms based on individual email content. I've installed and set up Mailhandler (7.x-2.10) in a fresh Drupal 7.38 install (with Feeds and other dependencies). It's connected to the right mailbox and is fetching and parsing email correctly. I've read the readme.txt and install.txt and lots of commentary elsewhere. But what I can't seem to do is deploy commands from the emails being parsed. Can I simply create commands in the "Available commands" field of the "Settings for Mailhandler IMAP stream parser" and then map them to my available fields in the "Mapping for Node processor"? (for example, I add "source" to the "Available commands" field and then map it to a "source" taxonomy in Drupal; every email coming in contains a "source: value" combination at the top of the email). This doesn't seem to work (except with the "status" command that was already written into the parser). Do I need to create a custom command parser in order to get commands from email to work?


texts: I have a Views, that renders nodes as "Rendered entity" with custom display mode - "cover". In template (or preprocess function) for this specific theming case, I need to get the Views object, that calls this render process, especially its arguments. How can I do this?


texts:
I wanted to remove some JavaScript files, since they conflict with my custom JavaScript on my mobile theme.

I tried with the following code, but it is not working in hook_preprocess_page(), which I think it really works in the first place; it's just that the original initialization of $scripts in page.tpl.php loads after hook_preprocess_page() alteration.

// Load all js scripts
    $scripts = drupal_add_js();

  // Unset all unnecessary scripts
    unset($scripts['module']['sites/all/modules/ajax/ajax.js']);
    unset($scripts['module']['sites/all/modules/contribs/mollom/mollom.js']);
    unset($scripts['module']['sites/all/modules/contribs/views_slideshow/js/jquery.cycle.all.min.js']);
    unset($scripts['module']['sites/all/modules/contribs/views_slideshow/contrib/views_slideshow_singleframe/views_slideshow.js']);
    unset($scripts['module']['sites/all/modules/contribs/views_slideshow/contrib/views_slideshow_thumbnailhover/views_slideshow.js']);
    unset($scripts['module']['sites/all/modules/quicktabs/js/quicktabs.js']);
    unset($scripts['module']['sites/all/modules/panels/js/panels.js']);
    unset($scripts['module']['sites/all/modules/tipsy/javascripts/jquery.tipsy.js']);
    unset($scripts['module']['sites/all/modules/tipsy/javascripts/tipsy.js']);
    unset($scripts['module']['sites/all/modules/boxes/boxes.js']);

    // Recreate the template variables

    $vars['scripts'] = drupal_get_js('header', $scripts);

How can I remove JavaScript files from the list of JavaScript files load when my theme is used?


texts:
I'm adding the user login form to the homepage of my site and through printing it out in my page.tpl.php, the validation is getting lost a bit.   The first time I enter in an incorrect username or password, nothing happens, but the second time everything acts as it should. I am confused about why it does not display the first time.

In my page.tpl.php

print drupal_render(drupal_get_form('user_login_block'));

In my template.php

if ($form_id == "user_login_block") {
  $form['links']['#markup'] = ' ' . t('Forgot username or password?') . '';
  $form['name']['#title'] = t('Username'); // Change text on form
  $form['name']['#attributes'] = array('placeholder' => t('Username'));
  $form['pass']['#title'] = t('Password');
  $form['pass']['#attributes'] = array('placeholder' => t('Password'));
  $form['actions']['submit']['#value'] = t('');
}

My Custom Validate Module

function hook_form_alter(&$form, &$form_state, $form_id){
  if($form_id == 'user_login_block'){
    $form['#validate'][] = '_custom_validation';
  }
}

function _custom_validation(&$form, &$form_state){
  $query = db_select('users', 'u');
  $query->fields('u', array('name'));
  $query->condition('u.name', $form_state['values']['name'], '=');
  $result = $query->execute();
  $name = $result->fetchField();
  if(empty($name)){
    form_set_error('user_name', t('Username or password could not could not be found.'));
  }
}

I also have the module "Email Registration" Installed, not sure if this has anything to do with it also.

Would anyone know anything about this?


texts:
We are developing a single Drupal 8 site with a set of different features (content types, etc).  The CMI approach is great for sharing config through git and importing/exporting on local, dev, stage, and prod environments.

But... I also really like the organizational aspects of the Features module.  It is appealing to have config grouped in meaningful buckets rather than a single global sync folder.  Individual modules also provide a nice place to hang default content and hook_update_N functions.

I've read that these two can play nicely together, but I'm having trouble determining the practical logistics of it all.  When I develop a feature, I usually do a drush cex and commit the changes -- so with Features, do I also export a feature and commit that?  Now the config lives in two places -- should I be concerned?  Will it cause conflicts?

Am I just complicating things by trying to use both?  If forced to choose, I will use only CMI because I want to be sure to control all config (not just the bits I've grouped into Features) -- and we want consistent and predictable deployments between local, dev, stage, and prod.


texts: How do I display a Media entity reference field in a nested paragraph on a template?

texts:
I have been working on this for 2 days and I can't figure it out. I hope someone can help me.
I have a paragraph (dinamic_columns_grid) that has an entity reference field to another paragraph (field_dinamic_column) This nested paragraph has an entity reference field to a Media image field (field_image). All the paragraphs have more fields but this is the one that is giving me problems.
I created a twig template for the first paragraph (paragraph--dinamic-columns-grid.html.twig) where I want to display the nested paragraph's fields individually. I know I could use {{ content.field_dinamic_column }} to display all of the results, and it does work, including the image field, but that's now what I want. All the fields in the code below are displaying correctly except the image field (field_image). I have tried everything but I can't seem to make it work. Any help will be appreciate.

        {% for key, item in content.field_dinamic_column %}
            {{ item['#paragraph'].field_html_content.value|raw }} / text field.It works
            {{ item['#paragraph'].field_hide.value|raw }} / select field. It Works
            {{ item['#paragraph'].field_image }} / Media image field. It doesn't work
         {% endfor %}

I like to be able to see the image or at the very least the url.
Thanks.


texts:
I'm developing a field widget for Drupal 8, similar to 'select' but with more functionality. Since the number of options is large and should be determined after querying an external API I was planning to retrieve options from ajax calls.

However AJAX - How to dynamically add options to select? states that it's not possible. What will be the possible workarounds or solutions?


texts: Flagging users as spam and giving a reason for doing so

texts:
I am creating a community site using Drupal7. The users of my site should be able to report other users as spam users. For this I am using the Flag module. I have created a flag called Report User for Abuse, and placed it on the user profile so that other users may report the user by clicking on the flag.

I want that the flagging user should give a small summary for the reason he or she is reporting the other user as spam etc.

Once this was done, I created a view for the site admin which shows him/her all the reported users. The admin may then see the reason, verify it and take appropriate actions.
Am I going in the right way about this or is there any other way as well?


texts: Module that will display certain facebook content?

texts: I realize there are quite a bit of facebook possibilities main having to do with facebook account connections. What I'm interested though, is content (especially videos!) that is being put up in a facebook group that was created and having that display on the drupal site. Is there a module out there that does that?


texts:
There are a few places where I am calling ImageStyle::load('style')->buildUrl($uri) to get a physical file path of an image.

After enabling HTTPS and forcing all traffic to use HTTPS, I noticed that this will only return http:// at the start of the url, and not https:// causing mixed mode flag in the browser.

Is there a way to do this and get the correct protocol? Can I not just obtain the relative path to the file instead? I notice that this method has hardcoded 'absolute' => TRUE when building the url to return.

Edit: fields using the normal rendering method i.e. {{ content.field_image }} have the correct protocol and do not cause an issue.

Here is the code I am using to generate the variable:

/**
 * Implements hook_preprocess_node().
 * @param $variables
 */
function mytheme_preprocess_node(&$variables) {
  $node = $variables['elements']['#node'];
  $bundle = $node->bundle();

  if ($bundle =='homepage' && $variables['elements']['#view_mode'] == 'hero') {
    $hero_image = $node->get('field_hero_image')->getValue();

    if (!empty($hero_image)) {
      $entity = Media::load($hero_image[0]['target_id']);
      $variables['hero_image'] = ImageStyle::load('homepage_hero')->buildUrl($entity->field_image->entity->getFileUri());
    }
  }
}

In the node view mode twig template:

  {% if node.field_hero_image is not empty %}

  {% endif %}


texts: How to display multiple taxonomy fields in a view

texts:
I have a view that display data from nodes (it's a listing of books).
Next to each rows, I need to display some icons that represent different category per book. Per example, a book could have the categories "For young adults, comic, black-white".

All the categories are in a taxonomy, and when the node is created, we select the ones we need.

Now displaying the field of the categories in the view doesn't work if I have more than one category selected.

I created a relation, allowing me to retrieve the images, but it only displays the first category selected.

How would I be able to display all of them ?

Thanks!


texts:
I want to use some query of database in blocks with Drupal Database API.
I try a lot but my code doesn't work.
It is a code that I made by Drupal Database API.

<?php
$now =date("YmdHis");
$con = Database::getConnection();
$con->query("SET NAMES utf8");
$result = db_query('SELECT quiz_open, quiz_close, nid FROM {quiz_node_properties}');
while($row = $result->fetch_array())
{
    $opentime=$row['quiz_open'];
    $time_format='YmdHis';
    $opentime_hu= unix_timestamp_to_human($opentime, $time_format);
    echo '
';
    $closetime=$row['quiz_close'];
    $time_format='YmdHis';
    $closetime_hu= unix_timestamp_to_human($closetime, $time_format);
    if(($opentime_hu < $now) AND ($closetime_hu > $now)){
        $nid=$row['nid'];
        $result2 = db_query('SELECT title FROM {node} WHERE (nid=$nid)');
        while($row2 = $result2->fetch_array(){
            $quiz_name=$row2['title'];
            $quiz_name2=str_replace(" ","-",$quiz_name);
        }
        echo ''.$quiz_name.'';
    }
}

function unix_timestamp_to_human ($timestamp = "", $format = 'Ymd- H:i:s')
{
    if (empty($timestamp) || ! is_numeric($timestamp)) $timestamp = time();
    return ($timestamp) ? date($format, $timestamp) : date($format, $timestamp);
}

?>

this code should do this:

<?php
$now =date("YmdHis");
$con=mysqli_connect("localhost","I_CANT_SAY_TO_YOU","I_CANT_SAY_TO_YOU","I_CANT_SAY_TO_YOU");
$con->query("SET NAMES utf8");
// Check connection
if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM quiz_node_properties ");
while($row = mysqli_fetch_array($result))
{
    $opentime=$row['quiz_open'];
    $time_format='YmdHis';
    $opentime_hu= unix_timestamp_to_human($opentime, $time_format);
    echo '
';
    $closetime=$row['quiz_close'];
    $time_format='YmdHis';
    $closetime_hu= unix_timestamp_to_human($closetime, $time_format);
    if(($opentime_hu < $now) AND ($closetime_hu > $now)){
        $nid=$row['nid'];
        $result2 = mysqli_query($con,"SELECT * FROM node WHERE nid=$nid");
        while($row2 = mysqli_fetch_array($result2)){
            $quiz_name=$row2['title'];
            $quiz_name2=str_replace(" ","-",$quiz_name);
        }
        echo ''.$quiz_name.'';
    }
}

function unix_timestamp_to_human ($timestamp = "", $format = 'Ymd- H:i:s')
{
    if (empty($timestamp) || ! is_numeric($timestamp)) $timestamp = time();
    return ($timestamp) ? date($format, $timestamp) : date($format, $timestamp);
}

mysqli_close($con);
?>

but my code in the drupal database API doesn't work.What's wrong???


texts: Views with two content type and different fields in one table

texts:
I've got these two content types, A (2014) and B (2015),  I'm tryging to combine in a view but  content A needs field to view node and content B to edit node,

The view show the fields but it show both options edit and view for all contents.

My actual view

The view I would like to do


texts:
I have a NodeEntityListBuilder class with the following in my buildHeader function:

public function buildHeader()
{
    $header = array(
        'title' => $this->t('Title'),
        'type' => array(
            'data' => $this->t('Content type'),
            'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
        ),
        'author' => array(
            'data' => $this->t('Author'),
            'class' => array(RESPONSIVE_PRIORITY_LOW),
        ),
        'status' => $this->t('Status'),
        'changed' => array(
            'data' => $this->t('Updated'),
            'class' => array(RESPONSIVE_PRIORITY_LOW),
        ),
    );

    return $header + parent::buildHeader();
}

I'm trying to makes changes to the headers and no matter what changes I make, it's not reflecting in the admin.

For example, changing Content type to Content Types.

I've tried to clear the cache by SQL:

TRUNCATE cache_config;
TRUNCATE cache_data;
TRUNCATE cache_default;
TRUNCATE cache_discovery;
TRUNCATE cache_entity;
TRUNCATE cache_menu;
TRUNCATE cache_render;
TRUNCATE cache_toolbar;

And also tried by the admin panel: Configuration > Performance > Clear all cache


texts: retaining upload file information in form when validation fails on other fields

texts:
If there are required fields in a form (ie '#required' is set to TRUE), and the user sets a file to be uploaded but not provide all the required fields, validation fails on the required fields and the validation hook does not get called; the specified file does not get uploaded (if that is where the upload code is placed) and the form is refreshed without the previously provided filename wiped out. Is there a way to either upload the file during validation, or reset the filename in the form field, so that the user doesn't have to reselect it again?

thanks


texts: How can I retrieve the value of variable I have defined in a config form from a Twig template?

texts:
I have a module in Drupal 8 to build a configuration form where I can set the value of a variable. But I don't know how to retrieve the value of that variable from the twig template.

In Drupal 7 I just needed variable_get() to get the value. What is the equivalent code that I should use in Drupal 8?


texts:
I would like to use the filtering option of views to generate menu item from a common tag to 2 different taxonomies.

For exemple I have 2 differents content type "Story" and "tutorial" each of them have the tag "potatoes".

I would like a menu item that link to all the stories about potatoes and another to all the tutorial about potatoes.

I was thinking of using views for that but there is no "display format: Menu Item" so i'm stuck.

help please


texts: Creating a page only to be accessed by registered users

texts: at my site tobynews I have users that would be registered as an "author." What I'd like to do is create a page such as an "Author's Resources" page that would only be accessible by someone who is registered as an author through the site. I'm not exactly sure how to approach this, other than trying to connect to the database's user table with a form. Any help is greatly appreciated.


texts: Popup w/overlay for content (Lightbox-esque)

texts:
Is there a module/technique that allows for a popup of a node content?
I'm looking for a lightbox-esque affect that displays specifically content (node?), not an image.


texts: Connecting 3 content types together entity reference/field collection - adding references in reverse?

texts:
I have 3 content types:

1. Client
Fields: business name, description, contact name (all standard text fields)

Field collection (called 'client campaign'): Fields: Entity reference field to campaign content type - so I can select campaign to tie this client to.

2. Campaign
Fields: Campaign brief, campaign duration, campaign budget, campaign monthly hours (all standard text fields)

Field collection (called 'collection publishers'): fields, publisher status (paid, live, dead, pending) [select list], publisher live date [pop up date], publisher payment amount [integer], Entity reference field to publisher field - so I can select publisher from drop down

3. Publishers

Fields: website url, name, contact email, payment method (all standard text fields)

If I now:

1) add a client (create one client node)
2) add a campaign (create one campaign node)

I now can add publishers to my campaigns via the field collection added to this content type (collection publishers) This is set to unlimited to I can add as many as I want, in each one I can add in details for each publisher such as 'payment amount' 'live date' and all the other fields that are within this collection.

This all works fine but I need to be able to see all my publishers in one view with details of them and 'reverse' add them to a campaign all at once, perhaps via checkboxes. This will save loads of time. I tried an editable view but cannot seem to get this to work. I am not sure why. It is almost like I need to somehow write to the database without opening up the publisher node..

Was wondering it anyone out there can give me some pointers here or just tell me I am doing it all wrong! I don't mind which.

(the end goal here is to track publishers working across multiple campaigns and then I can see what's gong on at all times through views I'll create)

ADDED A SCREEN SHOT OF THE 'LOGIC' BEHIND THIS!

Thanks for any help in advance.

Screengrab 2 shows how the current campaign node edit form looks - the field collection is showing the publisher nodes.

Screengrab 3 shows how I would probably like this to look, an editable view of publishers that I can assign a campaign to then save. However, this may not work as publishers can work over many campaigns...


texts: How to implement just a 'Purchase Order' solution (without Drupal Commerce)?

texts:
Here is the situation: I need create a content type 'Purchase Order' with just few fields: date, product to buy, quantity, price unit, price total, author. The goal is don't need be finding in the future the SKU of products which we bought before, and in the finish of the year see how many papers or PC we bought. We are small group and I don't believe a complete 'Drupal Commerce' solution will be necessary, just a content type, with views for some basic reports.

I though make some small content type 'Purchase Order' with a entity reference to the product(s) content type but I stuck in the quantity field (and price). The problem come when I referenced the product, add a field to that relationship for the quantity, and later see in a custom view how many times that product was bought (and link the orders). Also, take the price from the related products, multiply by quantity and count the total price.

Some idea for Drupal 7?


texts:
My exposed filter's form is placed in a region, within a block. I have activated the Config Block > Display Title option (I also overrode the title) but I see no title (a h2 should be added on top of the form, like it is displayed in other custom blocks below the filter, I suppose)

Why is this happening? Could I add the title within a form_alter hook?


texts: send user registeration mail in html format

texts:
I want to send any email of my site in HTML format, I install smtp , mimemail and mailsystem modules, and smpt configured correctly and test it(I check Allow to send e-mails formated as Html), also this is a snapshot of Mailsystem settings

,also in Mimemail settings I set E-mail format in FULL HTML format,also I create mimemail-message.tpl.php in theme folder (and cleared cache).

it seems everything is ok,but when a user register in site, email not send in html format and is only plain text.

How can I send any user email (registertion,canceling,approved,suspending ,...) in HTML format?


texts: How can i attach my content type to level 1 taxonomies in multilevel taxonomy in drupal 7?

texts:
I am using the default taxonomy of Drupal 7. I have a taxonomy like the following one:

Multilevel taxonomy (Vocabulary)

level 1 taxonomy  (Term)

level 2 taxonomy (Term)

I want my blog post have a field type of level 1 taxonomy.

Is there any module for this?


texts: I want the user registration to appear in a block in some other page than home, let's say a page called "Sign up." What I want to achieve is the following.


texts: How can I create a select list with all languages?

texts:
I need to have a field on a form, where the user can choose from the set of world languages for an event.

It's going to be an Autocomplete term widget (tagging) field.

How can I reuse the inbuilt language list in Drupal for this purpose?


texts:
In the form to create a node, when the author field is not filled, the author is set to the anonymous user. I'd like to hide the author field when it is not empty.

Is there a Drupal workaround for that? I am really thinking into resolving this with JavaScript which I consider a desperate approach.


texts:
I need to create a monthly sales report in Drupal. The report should contain products/services sold during last month, quantity and the price. Sales persons have to enter monthly the information in the report. I am thinking to create the products as a content type Product with the field Month, Name, Quantity, Price, Sales person (Author).

If I display in Views the Content Type - Product, how can Users (Sales role) enter the Quantities? How to control that the quantities for all products are set? How to limit it to 1 Report per month? How to identify which users have entered the report and which users didn't do it?

I would appreciate very much if you can guide me how to better achieve this monthly reporting objective!


texts: Drush: "Unknown engine type outputformat" module conflict

texts:
I've been searching in all forums for the answer, I had a problem with drush everything i did showed this message "Unknown engine type outputformat [error]"

I updated drush and still got that message since it took me so long to find the answer I'll post it here for other people with the problem
its the first answer.


texts: How can I get newly created node of a certain type?

texts: I understand I could use hook_nodeapi('insert') in Drupal 6 (Drupal hook fired after node created), but this seems to have changed in Drupal 7. What would the equivalent of that in Drupal 7?


texts: Hide a list of blocks from Panelizer in-place editor (IPE)

texts: I have a list of blocks that shouldn't be added via panelizer IPE popup under manage content. Is there any way to remove them from the list?


texts: Does Boost work together with Google analytics?

texts:
This may be a stupid question, but can the Google Analytic module still track users and count page visits etc. if I use Boost module to speed my site up?

Is there anything I should be aware of? Are there any settings I must do in robots.txt for example? (Other than the line Disallow: /boost_stats.php which should be entered according to the instructions).


texts:
I want to import a content type data from D6 db to D7.
I have db in settings file like....

    /**
     * Database
     */
    $databases['default']['default'] = array(
      'driver' => 'mysql',
      'database' => 'd7',
      'username' => 'root',
      'password' => 'root',
      'host' => 'localhost',
    );
    $databases['d6']['default'] = array(
      'driver' => 'mysql',
      'database' => 'd6',
      'username' => 'root',
      'password' => 'root',
      'host' => 'localhost',
    );

I am trying to query nid's from D6 db from D7 module using db_query, but cant use node_load for D6 db then.

    function import_schools() {
      db_set_active($key = 'd6');

      $result = db_query("SELECT nid FROM {node} WHERE type = :type AND nid         = :nid", array(
        ':type' => 'classified',
        ':nid' => '77307',
      ));

      while ($record = $result->fetchAssoc()) {
        print_r($record);
        print_r(node_load($record['nid']));
      }

    }

How can I chang API from d7 to d6 on fly while switching db using db_set_active.


texts: What is the Drupal API for reading Drupal configuration files (.info .make etc.)?

texts:
Drupal configurations such as .info, .make appear to follow common structure. There must be Drupal API for reading these configurations from code.

How does one load and read these configurations in his code?


texts:
I am new to Drupal.I want to create an image gallery, where each Image have some details.

I have used Media and File Entity modules to add additional field to media.

I want to know that how can I create a view to get details of that image.
Also how can I edit the details of that image


texts:
I am writing an application (non-Drupal) that is POSTing to a 3rd party public form written in Drupal. The problem I am running into is that the 3rd party form never processes the request, it only returns the original form. Is there a trick to posting to Drupal forms? The URL that I am attempting to post to is:

https://www.modelaircraft.org/membership/verify?ama_number=123&last_name=smith&op=Submit&form_id=membership_verify_form

The response should have the following fragment:

Error message

  No match found for AMA 123 and last name smith. Please verify.

But it does not.


texts: How do I disable the "Flood attempts IP blocking" functionality?

texts:
Drupal blocks the IP used to access the site, when a user tries to log in many times.

How can I disable this functionality?


texts: Changing video content type (mime type) in CDN

texts:
I am using media module to save media in CDN. To play videos, we are using jwplayer in Drupal 7. Jwplayer throws error in IE, If video is not of content type [mime type] video/mp4.
I have changed the existing CDN videos mime type from application/octet-stream to video/mp4.

Now whatever mp4 videos are being uploaded/saved to cdn should only be of video/mp4 mime type but when I upload mp4 videos in media module it is saved in CDN with mime type application/octet-stream, How do I change the uploaded mime type [content type] to video/mp4.

How do I change mime type[content type] to video/mp4 in media module, Drupal 7, when mp4 video are being uploaded.


texts: How to programmatically get list of available image styles

texts:
I'm able to get a list of fields using

$fields = array_keys(\Drupal::entityManager()->getFieldDefinitions('node', 'ce_meeting'));

But is there a way to get a list of Image Styles instead?
Something similar to

$fields = array_keys(\Drupal::entityManager()->getImageStyles());

to spit out an array

['thumbnail','original','medium','large','small']

Is there a function to display a list of available image styles?


texts: What is the procedure for deleting a project in drupal.org?

texts:
I created a project in drupal.org but decided that a better name would better suit the project, so I created another one. I need to delete the old project.

What is the official procedure to delete the old project node?


texts: How to change a node's term reference value, dependant on date

texts:
I have a content type "Page" and one of its fields is a term reference to the taxonomy term "Page Type"

Another field is "Expiry Date"

The page type starts off as "Open Consultation", but I need it to automatically change the term reference to "Closed Consultation" if the "Expiry Date" has passed.

I've been a developer for years, but I'm still quite new to Drupal (7)... I know the GUI, but not php or which files to override (if that is the answer)

So, I need a basic explanation of how to achieve this.  Thanks !


texts: Display list of user name with user points sorted by points based on certain time period?


texts: Several same product with a customizable field

texts:
I need a customizable field for a product in Drupal 8 drupal-commerce.
I succeeded to add such field through an order item type.
But if I want to add several same products on cart, this field stand uniq for all the products.

How can I have a line in cart by same product with the specific value of the customizable field for each one (I'd like to avoid the creation of a product variation by specific value. This specific value is customizable and so not in a finite set)  ?

Thank you very much for your help.


texts:
Drupal 8 offers a "REST export" views display. What would be the best way to get an export according to the jsonapi specification? Should I think in terms of creating a new views display, so the view can have a data key, and attributes, as in jsonapi format, or would it be best to modify the REST export views with a hook?

Some other approach?


texts: How do I add the Arab League flag as language?

texts: I can't find a flag of the Arab League in Drupal. How do I add this flag as language? It isn't showing in the languages' list.


texts: Change the cardinallity ratio of a an already existing field from 1 to unlimited

texts:
I've created a webform with a text field which has cardinality of 1 and there are submissions made for that webform. I now want to change the cardinality to unlimited, but I can't do it in the webform UI. I'm not able to change the value.
This is the tootltip shown when I hover over the Allowed number of values field in webform form element settings Allowed number of values field.

There is data for this element in the database. This setting can no longer be changed.

I tried to programmatically change it using hook_form_alter().
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'form_id') {
    $form['field_name']['cardinality']['#default_value'] = FIELD_CARDINALITY_UNLIMITED;
  }
}

That didn't work either. Where am I going wrong?


texts:
I would like when a client check one of the checkboxes, a text field appeares. Example: if he clicks on 3 checkboxes, all the textfields of the 3 show off.
My #checkboxes :

$form['input']['livraison'] = [
      '#title' => t('Options de livraison (à la charge de l’acheteur)'),
      '#type' => 'checkboxes',
      '#description' => t(''),
      '#options' => [
        'home' => $this->t('Retrait chez moi (gratuit)'),
        'hand' => $this->t('Remise en main propre (gratuit)'),
        'myself' => $this->t('Je livre moi-même le produit'),
        'colissimo' => $this->t('Colissimo'),
        'custom' => $this->t('Livraison personnalisée'),
      ],
      '#attributes' => [
        //define static name and id so we can easier select it
        'id' => 'select-shipping',
        'name' => 'field_select_shipping',
      ],
    ];

and my textfield :

$form['input']['adresse_home'] = [
      '#type' => 'textfield',
      '#title' => 'Adresse',
      '#required' => false,
      '#states' => [
        //show this textfield only if the radio 'other' is selected above
        'visible' => [
          ':input[name^="field_select_shipping"]' => [['checked' => 'false'], ['value' => 'home']],
          ':input[name^="field_select_shipping"]' => [['checked' => 'false'], ['value' => 'hand']],
          ':input[name^="field_select_shipping"]' => [['checked' => 'false'], ['value' => 'myself']],
          ':input[name^="field_select_shipping"]' => [['checked' => 'false'], ['value' => 'colissimo']],
          ':input[name^="field_select_shipping"]' => [['checked' => 'true'], ['value' => 'custom']],
],
      ],
    ];

**Solution : **

As berramou sent, this way is the one that works the best with checkboxes.  If you have any issues with it look if a plugin couldn't block states, that what happened to me with iCheck.
If you need to show all the input's checked, just put the TRUE condition in your 'visible', this way you can select 2 options and get both display correctly.


texts: How to list blogs by anonymous in blog module

texts:
I am able to list blogs by a specific user, e.g. /blog/123 - where 123 is the uid, but when I use /blog/0 I get access denied.

Can someone advise on a config setting to enable /blog/0 to list blogs by anonymous user (i.e. uid = 0), please?

I could implement a hook or override the View or something, just wanted to check if there isn't a config setting somewhere. I couldn't see one, looking so far.


texts: How to get the "label" of "Allowed Values" for a text list programmatically?

texts:
I created a text list field on the user entity.  I entered the following for Allowed values list:
apple|A delicious apple
pear|A very delicious pear
orange|A not so delicious orange

I can access the key for the field like this:
$current_user->get('field_list_fruits')->value,

which returns apple.  But how do I get the text A delicious apple programmatically?


texts: Alter the exposed filter value on change of other exposed filter value

texts: I wanted to do an interdependent select boxes using views exposed filters. So when i select the 1st exposed filter, the second once should filter itself based on first exposed filter value and this should happen dynamically. I tried a lot with form_alter but did not work. Any example or any suggestion as to how to go about it.


texts: What causes my Rules error when trying to send an email if profile field contains some value?

texts:
I'm using Rules and Profile2 in a D7 site.

I'm looking for help to check my logic for the following rule. I can't get it to work and don't know where I'm going wrong.

Event: After saving a new profile

Condition: Data Comparison--> Selected data: site:current-user:profile-main:field-become-a-distributor

Action: send e-mail

Condition is what breaks.  Here is what is in my error log:

  Unable to get the data value for the variable or parameter data. Error: Unable to get the data property field_become_a_distributor as the parent data structure is not set.


texts: Why extended behavior doesn't work when JS compression is on?

texts:
Because old messages with errors doesn't disappear after next, success upload, I want to remove them by this method.

JS file in custom module:

(function ($) {
    /**
     * Attach behaviors to the file upload and remove buttons.
     */
    Drupal.behaviors.fileButtons = {
        attach: function (context) {
            $('input.form-submit', context).bind('mousedown', Drupal.file.disableFields);
            $('div.form-managed-file input.form-submit', context).bind('mousedown', Drupal.file.progressBar);
            $('div.form-managed-file input.form-submit', context).bind('mousedown', function() {
                    $(this).parent().parent().parent().parent().find('.messages').remove();
                });
        },
        detach: function (context) {
            $('input.form-submit', context).unbind('mousedown', Drupal.file.disableFields);
            $('div.form-managed-file input.form-submit', context).unbind('mousedown', Drupal.file.progressBar);
        }
    };
}(jQuery));

module file:

function rpke_forms_form_node_form_alter(&$form, &$form_state) {
    global $conf;
    //$conf['preprocess_js'] = FALSE;
    $form['#attached']['js'][] = drupal_get_path('module', 'rpke_forms') . '/rpke_forms.js';
}

/**
 * Implements hook_module_implements_alter
 */
function rpke_forms_module_implements_alter(&$module_list, $context){
    if($context === 'form_node_form_alter'){
        $temp = $module_list['rpke_forms'];
        // Removing the mymodule key/value
        unset($module_list['rpke_forms']);
        // Adding the mymodule key value as the last member in the list
        $module_list['rpke_forms'] = $temp;
    }
}

Everything works as expected when JS compression is off, after enabling, it stops working.
It's works all time, when I uncomment $conf['preprocess_js'] = FALSE;


texts: Unable to delete a user with lots of content?

texts:
An AJAX HTTP error occurred.
 HTTP Result Code: 200 Debugging information follows. Path: /batch?id=462&op=do StatusText: OK ResponseText: Fatal error: Maximum execution time of 30 seconds exceeded in /home/evangfep/public_html/manas/includes/module.inc on line 895

While deleting user , I get the above error.
How can I fix the above issue, since its server is shared hosting , I am unable to increase the maximum execution time.


texts: How to reference existing Paragraph entity?

texts:
I'm trying to create an entity reference field for existing paragraph, but can't seem to figure it out.

I've tried creating a normal entity reference field (content) but that only gives me the options to select from content types.

I've tried creating a paragraph field and using a entity reference view to display the results. (this displays a list of paragraph entity ids but when referencing one in a node it comes up with There are no entities matching "(21)".

How do I reference existing paragraph entities in a node?


texts: Captcha session reuse attack detected error message in form with anonymous user

texts:
I am experiencing a problem with the Captcha module 7.x-1.3 version (under Drupal 7.39)

I don't use webforms
My form is a simple Contact form
My form does not contain any AJAX field
My form does not contain any file or image upload system
I configured the captcha Module, giving the good name for the form

form_id : xxxxxx_contact_form
Challenge type : Image (from module image_captcha)

In the Configuration (admin/config/development/performance)

The page cache for anonymous users is unchecked = NOT ACTIVATED
The cache for blocks is unchecked = NOT ACTIVATED

The code of the Captcha for my form is :

$form['xxxxxx_contact_captcha'] = array(
  '#title' => t('Vérification'),
  '#type' => 'captcha',
  '#captcha_type' => 'image_captcha/Image',
);

When a user is connected the form submission works well without any problem
BUT when NO user is connected (= anonymous session), i get the following errors :

  CAPTCHA session reuse attack detected.
  The answer you entered for the CAPTCHA was not correct.

(in french) :

  Attaque à base de réutilisation de session de CAPTCHA détectée.
  La réponse saisie pour le CAPTCHA est incorrecte.

EXAMPLE :

For example, with a "TT7Zi" Captcha image, when I submit the form (in anonymous) : I get the following errors on the screen :

  CAPTCHA session reuse attack detected.
  The answer you entered for the CAPTCHA was not correct.

And in the logs (watchdog) I get two times the same entry  :

  Message   xxxxxx_contact_form post blocked by CAPTCHA module: challenge
  Image (by module image_captcha), user answered "TT7Zi", but the
  solution was "542dda8e8d7fda2358b4b2f319ef198b".

Any solution for this issue will be really helpful.
Thank you all.


texts:
I set at the .info module file the parameter to add a css file,

stylesheets[all][] = css/style.css

but it is not attached even if I clear the cache.

I have look for the web to get the reason but apparently is all I might have to do.

Anybody could tell me what am I missing please? Here the code: https://github.com/jmvelasco/drupal

The js files are attached.

Thanks in advance.


texts: How to (ab)use image effects to serve API generated images?

texts:
I made code to add a custom effect using hook_image_effect_info() that does not alter the image for real. I'd like to serve an image from my own API instead, that has calls like myapi.com/img2123?w=25&h=88&watermark=true. I don't think that the code for a placeholder effect is relevant is it?

I'd like to use this because that way if I add an Image field to a content type I can choose a banner for example on every 'Article' content type.also I need to pass the parameter returned by the dimensions callback (set in the form callback of hook_image_effect_info()) to the GET request as an URL parameter.

I was thinking: could I use some node altering hook to change the uri that is parsed somewhere else in the program?

If you need some additional info, just ask. Thanks in advance.


texts: Adding a new variable to account menu for twig rendering

texts:
I am trying to add a variable to render in the menu-account.html.twig file.

Here is my preprocess function in my .theme file.

function HOOK_preprocess_menu__account(&$variables) {
    $variables['account_name'] = Drupal::currentUser()->getAccountName();
}

HOOK is replaced with my theme name

And in my twig file I have this snippet:

<div class="welcome-message">
    Welcome, {{ account_name }}!
</div>

So I can edit pre-existing variables but I cannot seem to add a new one.

I was reading that new variables cannot be added in a preprocess function and that the HOOK_theme_registry_alter should be used.

Here is what I attempted and by using xDebug I can tell that it is getting looked at when flushing caches.

function HOOK_theme_registry_alter(&$theme_registry) {
    $theme_registry['menu']['variables']['account_name'] = [];
}

Does anyone know the steps to get a new variable to be rendered in the menu twig file. This my first time using the theme registry hook so I might be doing something wrong there as well.

Thanks,

EDIT: "menu--account.html.twig" was named correctly in my code but mistyped in my question. Thank you to GiorgosK for pointing this out.


texts: In an Aegir platform how do I change what modules drush enables when a site is created

texts:
So far I have successfully in setting up Aegir and seting up a number of Platforms using makefiles. Now I want to tinker with one of the platform by adding a number of modules and tweaking some template files.
I realize making these changes within the platform folder will propagate to all of the sites within that platform. What I want to know is, what do I have to change, so that when I provision a new site the new modules that I have added will automatically enabled? Does this have something to do with drushrc.php? it seems there are two, one in the platform and one in the site. I'm also wondering how to get Aegir to set certain values, like auto populating users.


texts: Creating a list of Quiz questions that have randomized order?

texts:
I'm using the Quiz module and created a view (using the Views module) which lists all of the questions of the current Quiz being accessed, and whether each question has been completed.

The only issue is the sorting of these questions. When the quiz has the question order set to random the list does not update to reflect this change, since the questions are being ordered by weight.

This is a problem because a user may have just completed the first question but by weight it may be question 6, which is visually confusing. Therefore how can one create a list of the questions that reflect the randomized ordering of the Quiz?

I looked at the "Quiz: Randomization" field but I am not quite sure how to use this. It causes an SQL error if I try to enable it.


texts: Views - how to create a chart AND a table from the same filter selection

texts:
I know how to create a chart using Views and I also know how to create a table. How do I used the same set of filters to create both but on the same page I am looking at?

I have embedded views inside views as well but that doesn't seem to do the job. Anyone got any idea?


texts: How do I add unique page titles and meta titles to paginated views pages?

texts:
I have overridden the taxonomy term pages with a view, and I want to be able to set the page title, both visible and meta, with unique titles for each page within the pager for SEO purposes. I am hoping the solution resides in a module, or in a view setting (and not on a template basis).

Do you have any suggestion?


texts: User Profile Picture Cached After Change

texts:
When changing your profile picture (using core pictures support) the image is uploaded correctly but is saved with the same file path as the old image.

The result is even though the image is uploaded correctly, the browser has cached the old one and still displays it, making it seem as though the new picture wasn't uploaded.

Forcing a refresh (ctrl + f5) resolves the problem, but this is not normal user behavior and has already caused confusion.

Is there a way to force a reload for this? Change the image path? Set an expires header? Open to suggestions.


texts: Can't install modules from UI when site placed in subdirectory

texts:
I have Drupal 8 installed in a subfolder (www.example.com/drupal), and I have my root .htaccess configured to mask the subfolder (i.e. the URLs resolve to www.example.com; /drupal does not appear in the URLs).

Everything works great except when I try to install new modules I get a 403 error.  I see in the URL for authorize.php that /drupal now appears in the URL.  Where I would expect www.example.com/core/authorize.php/, I instead see www.example.com/drupal/core/authorize.php/.  I imagine this is the reason for the 403?

What additional modifications do I have to make to /drupal/.htaccess in order to get access to the /core files required to install new modules?

Here's what's in my document root .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_URI} !drupal/
RewriteRule (.*) /drupal/$1 [L]

And the only modification to /drupal/.htaccess is to uncomment the subdirectory per the instructions in the file:

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /drupal


texts: Is there any online tutorial explains how can I map the requested URL to actions' code in drupal 7?

texts: I'm beginner to Drupal 7. As I know, when the user request for example the URL: (www.example.com/node/123) then the Node module will responsible on responding to this request. How can I create a simple php function in my custom module so that it can respond to a specific request generated from my custom page or my custom form submission? for example: www.example.com/mymodule/blablabla?


texts:
I have created a custom fieldable entity. Now I want to inject the field data into the entity and render the complete entity with the fields.

The following code is working for text fields and taxonmy reference fields, but when I want to inject image field data, the image have no uri.

My field data, I want to inject:

[type] => paragraph
    [configuration] => Array
        (
            [field_body] => Array
                (
                    [und] => Array
                        (
                            [0] => Array
                                (
                                    [value] => Lalelu
                                )

                        )

                )

            [field_image] => Array
                (
                    [und] => Array
                        (
                            [0] => Array
                                (
                                    [fid] => 17
                                    [display] => 1
                                    [width] => 60
                                    [height] => 60
                                    [description] =>
                                    [upload_button] => Upload
                                    [remove_button] => Remove
                                    [upload] =>
                                    [alt] =>
                                    [title] =>
                                )

                        )

                )

            [field_tags] => Array
                (
                    [und] => Array
                        (
                            [0] => Array
                                (
                                    [tid] => 1
                                    [vid] => 1
                                    [name] => Term 1
                                    ...

                                )

                        )

                )

        )

This are the lines, that work for the field_body (textfield) and field_tags (taxonomy). The form is getting rendered, even the image field.

  // Append field data from storage.
  form_set_value($element['chunk']['edit'], $vars['edit'], $form_state);

  // Append fields from chunk entity to the form.
  field_attach_submit('chunk', $chunk, $element['chunk']['edit'], $form_state);

  // render entity form
  field_attach_form('chunk', $chunk, $element['chunk']['edit'], $form_state);

But when I try to render the entity, all fields get rendered, but the image field.

  // Append field data from storage.
  form_set_value($element['chunk']['preview'], $vars['edit'], $form_state);

  // Append fields from chunk entity to the form.
  field_attach_submit('chunk', $chunk, $element['chunk']['preview'], $form_state);

  // render chunk entity
  $element['chunk']['preview'] += entity_view('chunk', array($chunk), 'preview');

I get the error:

  Notice: Undefined index: uri in theme_image_formatter() (line 605 of /xxx/modules/image/image.field.inc).

I think I'm missing any kind of image view preprocessing, where the uri from the managed field is loaded form the database.

Do you have any idea, what's my problem? Or do you have any other solution to get the entity rendered?

Thank you!


texts:
I would like to make a view created as a block where every item is displayed as a thumbnail of a cover photo-field of the content type.

I can't find this option in the display options dropdown ... How should I go about it?


texts: I am using Drupal 6. How would I programmatically activate two or more menu items when I am on a certain node page?


texts: Content type export with drupal console not working

texts:
I have a content type called slider as the image below shows:

I tried the following to export the content-type:

drupal config:export:content:type slider

when I enter the command, I am prompted to type a module name, which doesn't sound right.

Enter the module name [admin_toolbar]:

How can I export a specific content type using the drupal console?


texts: How can I get all the taxonomy term objects from the database regardless of vocabulary?

texts:
I can see in the Drupal taxonomy api taxonomy_get_tree() which returns an array of term objects, however, the vocabulary ID is a required object.  I thought also about taxonomy_term_load_multiple, but an array of IDs is necessary to populate it.

How can I get all the objects regardless of vocabulary affiliation? More or less what I am looking for is taxonomy_get_tree('all').

Each term object contains the [vid] it's associated with. I need to be able to loop through each object and determine the vocabulary it's associated with rather than the other way around.


texts: Different user form for registration and edit

texts:
I'm trying to make different forms layout for user registration and user edit account:
- User Registration: Display it paginated, like a wizard.
- User edit: Display it in only one page.

I can use FieldGroup Multipage field to make a paginated user registration form. But it affects the edit page too.

There's some module that can accomplish this?

Any help would be appreciated!


texts:
I'm seeing the following error when running cron (in terminal via drush and on screen via the status report page.

  Error: Call to a member function getScriptTag() on a non-object in /home/loktah/public_html/includes/common.inc(1762) : eval()'d code, line 2

I'm not sure where to even start looking for the source. Any direction would be appreciated.


texts: How to establish a relation among two content types in drupal 7

texts:
Consider there are two CCK's Products and Reviews(reviews for a product) how to relate them?

There can be any number of reviews for a product. Hence i may want to retrieve all the reviews that belongs to a particular product OR Create a Review OR Delete OR Update.

Is there any module in drupal to accomplish this?

UPDATE

I tried this using Entity Reference module

First I created a REVIEWS CCK with the following fields
Name, Email, Review, Rating, Product(This is the Entity Reference, So that it helps to determine the Product to which the review is belonged to).

Products CCk

Product Name, Product Description, Product Cost

Consider there are 3 products A, B, C and i want to review for Product A. I must add all the fields such as Name, email etc and have to select a Product from Drop down

This is Better. But the interesting point is How can i Retrieve all the reviews that belongs to Product A ?

If i create a VIEW to list all the Products i cannot get It's reviews.
Similarly if i create a view to list all Reviews i will get only product name but not its details.

Do any one have any Idea how to solve this?

Many Thanks.


texts: Attach a particular profile2 form to user registration form

texts:
I have about 3 profile types each with their own registration path. But there's one without a path.  I want to attach this to the main registration form. So that it shows when adding user on the main user add page but not other pages.

i got it to show with the code below but error when saving the user.

Recoverable fatal error: Argument 1 passed to profile2_save() must be an instance of Profile, instance of ProfileType given,, called in C://....

function short_fixes_form_user_register_form_alter(&$form, &$form_state) {
  global $user;
  $current_user_role = in_array('family',$user->roles);
  $form['account']['status']['#access'] = FALSE ;
  if($_GET['q'] == 'admin/people/create' && $current_user_role){
      $form_state['profiles'] = array(
        'family' => profile2_get_types('family')
      );
      profile2_attach_form($form, $form_state);
    }
}


texts:
Using Content Type: application/json I tried like:

EDIT:

{
 "type": "article",
 "title": "Test article with image1",
 "body": {
 "und": [{
     "value": "test body!"
   }]
  },
 "field_image":{
 "und":[{
  "fid":{
  "filename": "bar.jpg",
  "target_uri": "sites/default/files/styles/large/public/field/image/bar.jpg",
  "filemime": "image/jpeg",
  "file":        "iVBORw0KGgoAAAANSUhEUgAAAKQAAAFzBAMAAABC179RAAAAD1BMVEUYooorZrPZwVO3Sd0M9BOSfwC2VwFIl7c9aAAAAABJRU5ErkJggg==",
   "filesize": "12345"
       }
     }]
    },

  "language": "und"
 }

Problem: Image is not created.


texts:
I am trying to add a list field to the menu links. I have executed the database update and it creates the field in the "menu_link_content_data" table correctly. But when I go to the menu link form the field does not appear. I have tried to clear cache, run the cron and even add the field by hand with an alter form. No value is ever saved in the database.
Even if I check the definition of the entity, the field I created does not appear
$defition = \Drupal::service('entity_field.manager')->getFieldDefinitions('menu_link_content', 'bundle');

This is my hook update.
  // Installing a new field storage definition.
  $field_storage_definition = BaseFieldDefinition::create('list_string')
    ->setLabel(t('Menu type'))
    ->setTranslatable(FALSE)
    ->setSettings([
      'allowed_values' => AreaMenu::getMenuTypes(),
    ])
    ->setDisplayOptions('form', [
      'type'   => 'options_select',
      'weight' => 10,
    ])
    ->setDisplayConfigurable('form', TRUE);

  Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('menu_type_service', 'menu_link_content', 'menu_link_content', $field_storage_definition);

I don't know if I'm doing something wrong or it's a bug in the core, could someone give me some indication? Thank you very much.
Drupal 8.9.1


texts: How to display add node form with node reference?

texts:
I have a very similar functionality to stackoverflow - i.e. I have a a view that display question and below it there are answers (seperate nodes references).

Currently, in order to add new answer to the question, the user has to click on a link, which takes him to add node form. But I need to display the form below the view, so the user can answer without being redirected to add node form on a seperate page. I guess it can be done programatically using drupal_get_form() function, but I have no idea how to start. Can anyone give me any suggestion or tutorial? Or maybe there is module for that..?  Any advice is greatly appreciated.


texts: Create an 'active' class for partial url?

texts:
I have a system of menus on a site that helps the user drill down to the page they are looking for.  If they click a link in the main nav, it might take the to /category.  On that page, a sidebar menu would direct them to /category/page.

Previously, I have used the active class to highlight a menu item while the user is on that page.  In this case, I want both menu items to be highlighted, since the page the user is on falls is a part of the main category.

To clarify, how can I keep a link active if it points to /category and the page the user is viewing is /category/page?

Thanks for the help!


texts: Ajax Function jquery Fails to send data Drupal 7

texts:
I am in the process of converting Drupal 6 module to Drupal 7.
i have a problem of Passing php data to Ajax.
The function should display if a speaker on or off by interchanging icons, when clicked by using (toggle function).
whats i have discovered is that this part $.ajax() doesnt work, while in Drupal 6 it works.
 below is the code.

longa.module file:

  //hook menu
  function longa_menu(){
  $items=array();
  $items['longa/set_speaker_state'] = array(
   'page callback' => 'longa_set_speaker_state',
   'access arguments' => array('longa talk'),
   'type' => MENU_CALLBACK,
  );
  return $items;
}
 //the callback
 function longa_set_speaker_state($speaker_state) {
  global $user;
  $_SESSION['longa_speaker_state'] = $speaker_state;
  user_save($user, array('longa_speaker_state' => $speaker_state));
 }

longa.js file:

(function($){
 $(document).ready(function(){
  if (Drupal.settings.longa_module.has_audio ==1){
  im_flash_player_listener.onInit = function(){
    this.position = 0;
  };
  if ($('#im-console-speaker-icon-on').css('display') == 'none') {
    is_muted = 1;
  }
  else {
    is_muted = 0;
  }
  $('#im-console-speaker-icon-on').click(function() {
    set_speaker_state(1);
    is_muted = 1;
    //alert('You clicked the speaker');
    $('#im-console-speaker-icon-on').toggle();
    $('#im-console-speaker-icon-off').toggle();
    });
  $('#im-console-speaker-icon-off').click(function() {
    set_speaker_state(1);
    is_muted = 0;
    $('#im-console-speaker-icon-on').toggle();
    $('#im-console-speaker-icon-off').toggle();
    });
  }

 });
})(jQuery);

 function set_speaker_state($speaker_state) {
  if (Drupal.settings.longa_module.has_perms ==0) {
   return;
  }
 var sendurl= url_prefix + 'longa/set_speaker_state/' + $speaker_state;
  //alert(sendurl);
   $.ajax({
   type: 'GET',
   url: sendurl ,
   dataType: 'json',
   data: 'js=1'
   /**success: function(xhr) {
    alert('sent successfully');
    },
    error:function(xhr) {
   alert('error occured');
   }*/
 });
}

I will appreciate for any help.


texts: How can I change which view wins over two using the same path?

texts:
I have two views in Drupal 8.

The standard Taxonomy term (content) view, path: /taxonomy/term/%
My custom view for just one term at path: /term-alias

When I go to my custom term, I see the view for all terms (#1), when I want to force it to #2.  How can I do that?


texts: How do I get a link to an image CCK in Drupal 7 in the node view?

texts:
If I do this:

print_r($node);

I get this:

 [field_main_photo] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [fid] => 86
                        [uid] => 1
                        [filename] => 01.jpg
                        [uri] => public://01.jpg
                        [filemime] => image/jpeg
                        [filesize] => 28385
                        [status] => 1
                        [timestamp] => 1409510061
                        [alt] =>
                        [title] =>
                        [width] => 600
                        [height] => 400
                    )

            )

    )

How can I turn that information into a usable link? I want to know how to link directly to 01.jpg?


texts: How to bypass node_access when using EntityFieldQuery?

texts:
With the following code, if the current user does not have 'bypass node access' (see _node_query_node_access_alter() for exact verifications), then the query checks for node_access, even though I do not use the "node_access" tag.

How can I avoid the node_access check with the following query for a non-admin user?

I'm using this code from a module, so I can verify permissions myself, no need for node_access checks.

  $query = new EntityFieldQuery;
  $result = $query
    ->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'foo')
    ->fieldCondition('custom_id', 'value', $custom_id)
    ->execute();


texts:
I would like to add an additional access condition to viewing user pages like user/1.
I looked at the following guidelines, but have not succeeded in coming up with a solution.
https://www.drupal.org/docs/drupal-apis/routing-system/altering-existing-routes-and-adding-new-routes-based-on-dynamic-ones
and
https://www.drupal.org/docs/8/api/routing-system/access-checking-on-routes#access-custom
The module code I have come up with this far - I can restrict all access to user profiles fine.
But I fail at my attempt to get the account id of the page being requested. Once I have the account I can load the field I need to check.
my_module.services.yml
services:
  my_module.route_subscriber:
    class: Drupal\my_module\Routing\RouteSubscriber
    tags:
      - { name: event_subscriber }

my_module/src/Routing/RouteSubscriber.php
<?php

namespace Drupal\my_module\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 *
 * We deny access to profiles, if the user has not accepted the terms.
 *
 * See https://www.drupal.org/node/2187643
 *
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    $path = \Drupal::service('path.current')->getPath();
    $path_args = explode('/', $path);
    // @todo: the right path does not seem to be accessible here - how do we get the user account id?
    // Always deny access to '/user/{uid}'.
    // Note that the second parameter of setRequirement() is a string.
    if ($route = $collection->get('entity.user.canonical')) {

      //$account = \Drupal\user\Entity\User::load($account_uid);
      // This effectively denies all access to user profiles
      $route->setRequirement('_access', 'FALSE');
    }
  }

}

EDIT:
Based on the comments I tried the following, but I am not being restricted to paths like /user/1, so I guess something is still amiss:
My module structure now looks like this:
/my_module
  /src
    /Access
      my_moduleAccessCheck.php
    /Controller
      my_moduleController.php
    my_module.info.yml
    my_module.routing.yml
    my_module.services.yml

my_moduleAccessCheck.php:
<?php

namespace Drupal\my_module\Access;

use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;

/**
 * Checks access for displaying configuration translation page.
 */
class my_moduleAccessCheck implements AccessInterface {

  /**
   * A custom access check.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for this account.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(AccountInterface $account) {
    // Check permissions and combine that with any custom access checking needed. Pass forward
    // parameters from the route and/or request as needed.
    // $account->hasPermission('do example things') && $this->someOtherCustomCondition()
    return AccessResult::forbidden();
  }

}

my_moduleController.php:
<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
 * An example controller.
 */
class my_moduleController extends ControllerBase {

  public function sayHi() {
    dpm('Hi');
  }

}

my_module.routing.yml
my_module:
  path: '/user/{uid}'
  defaults:
    _controller: '\Drupal\my_module\Controller\my_moduleController::sayHi'
    _title: ''
  requirements:
    _my_module_access_check: 'TRUE'

my_module.services.yml
services:
  my_module.access_checker:
    class: Drupal\my_module\Access\my_moduleAccessCheck
    arguments: ['@current_user']
    tags:
      - # Required: Mark that this service is for access checks.
        name: access_check,
        # Optional: Specify which routes this applies to.
        applies_to: _my_module_access_check


texts: Which of the two approaches to routing a module settings page is the best practice?

texts:
There seems to be two ways to link a route to a settings form for a module. I'm curious as to whether one is considered a better practice, and why.

_controller: '\Drupal\mymodule\Controller\MyController::myMethod'

or

_form: '\Drupal\mymodule\Form\mySettingsFormFile


texts: Discover custom services with drush generate

texts:
When I create a module and a custom service with drush generate and then create another service, also with drush generate, the first one is not available to inject.
What is missing to make it become available?
I'm on drupal 9.1 and drush 10.4.
The steps to reproduce
drush generate module

Given any name
dursh en test_module
drush cr
drush generate custom-service
drush cr

Given any name
drush generate custom-service

Answer dependecy injection with yes and try to find the name from the first service.


texts: What is the variable for the human readable name of the node type?

texts:
In my node.tpl I have added <?php print $type; ?>. This gives me the machine name of the node type e.g. blog_entry. What do I use to get the human readable form e.g. Blog entry?

Edit (Here is my current code)

<?php if ($display_submitted): ?>

<?php print $type; ?>

<?php print $name; ?>

<?php print $date; ?>

<?php print $comment_count; ?>

  <?php endif; ?>


texts: Management of priorities with node_access

texts:
I do not understand how priorities are set for the node_grants... I have a module node_grants function that provides 4 grant ids for the user, but some nodes only have 2 gids... how do I know which one allows the user to view the node or not?

Thanks,


texts: module_invoke/module_invoke_all with multiple arguments

texts:
I know enough D7 to be dangerous. I'm stumped, however, as to how to call one module from another. In this case, I want to call the simplenews module's subscribe_user hook from a custom module I'm creating. I'm having difficulty passing the multiple arguments either as a string or an array. Here are the variables the hook accepts:

$mail = 'test@test.com';
$tid = 1;
$confirm = TRUE;
$source = 'unknown';
$preferred_language = NULL;

Can someone please help me call this properly?

module_invoke('simplenews', 'subscribe_user', $args);


texts: Can a domain redirect work for both http and https?

texts:
Currently hosting a site on Pantheon and I would like to redirect traffic to a single domain. There is already a lot of links inside my site that are using:

http://example.com/somepage, http://www.example.com/somepage, https://example.com/somepage, https://www.example.com/somepage

Since Pantheon uses nginx I would have to use settings.php to redirect traffic. My Question is would it be possible to direct traffic to a single domain but it can be served in either http or https?

Some sample code:

// Require www.
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) &&
  ($_SERVER['PANTHEON_ENVIRONMENT'] === 'live') &&
  (php_sapi_name() != "cli")) {
  if ($_SERVER['HTTP_HOST'] == 'example.com' ||
      $_SERVER['HTTP_HOST'] == 'https://example.com') {
    header('HTTP/1.0 301 Moved Permanently');
    //or https://www.example.com
    header('Location: http://www.example.com'. $_SERVER['REQUEST_URI']);
    exit();
  }
}


texts: Can't get React app to use Auth0 to login

texts:
We want to use Auth0 for login for a React app with headless Drupal: We have to support phone number +OTP as well as email+password, and we want to have some users be able to login to other D8/9 sites in the ecosystem/federation.
The question is: How to use Auth0 for a React App authenticating to a headless Drupal site?
We have Drupal 8 configured to use Auth0 for login based on the Auth0 supported module (https://www.drupal.org/project/auth0). It works fine from a browser but we can't see how to get it to work from React app.
Our objective is similar to https://github.com/auth0-community/auth0-drupal/issues/163.
We have separately built a React app to provide a login interface with the help of this documentation https://auth0.com/docs/quickstart/spa/react/01-login that logs in directly to Auth0, and this works fine.
Auth0 provides a single sign-on that presumably should allow the App session to be carried over to a Drupal session, I believe using a JWT token. We are unsure how to get this to work and would like advice.
In terms of having the React app login to Drupal and use the Drupal session when making calls to the API, we have had success with  using the OpenID Connect module but not with Auth0..
We believe we need to use a JWT access token to do a SSO login to Drupal 8.
Alterntively we can have the React app talk to Drupal8's Auth0 module, get rediected to Auth0, do the login with email password or phone# + OTP, then get returned to Drupal8 site and return to the React app with a Drupal user session.


texts: Cannot target  tag after switching to Picture module

texts:
I have a image field that I have added an 'onload' attribute to in template.php.

function mytheme_preprocess_field(&$variables) {
    if($variables['element']['#field_name'] == 'field_images'){
        foreach($variables['items'] as $key => $item){
            $variables['items'][ $key ]['#item']['attributes']['onload'][] = 'imgLoaded(this)';
        }
    }
}

I have this image field wrapped in
:

    ?>
<<?php print $tag; ?> class="<?php print $classes; ?>"<?php print $attributes; ?>>

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

  <?php endif; ?>

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

        <?php print render($item); ?>

    <?php endforeach; ?>

</<?php print $tag; ?>>

When the image has loaded, the following script adds a 'loaded' class to the img-wrapper div:

function imgLoaded(img){
var imgWrapper = img.parentNode;
imgWrapper.className += imgWrapper.className ? ' loaded' : 'loaded';
};

Since enabling the Picture module, my markup has changed and images are no longer wrapped in a  tag but inside a <picture> tag. Now the 'loaded' class is not being applied to the img-wrapper div.

Inspecting the DOM I can see that firstElementChild is now picture. Without the Picture module the firstElementChild was img.image-style-none cake.png

parentElement and parentNode are the same for both.

From what I have read, it seems that picturefill in the Picture module adds the  tag, but I'm unsure of this. I cannot see the  tag when inspecting in Firebug.

How can I add the 'loaded' class to the img-wrapper div once the image has loaded now that  has been replaced with <picture>?


texts: Is there a way to automatically cancel an account after 14 days?

texts:
I'm working on a website where we are offering trial access and I want a way to automatically cancel an account after the account is more than 14 days old EXCEPT if they have submitted a feedback form in which case they get an additional 7 days (for a total of 21 days).

I think there ought to be a way to do this using Rules or cron but right now I'm stuck.


texts: CiviCRM hosting for small member based org

texts:
I am researching running Drupal 7 & CiviCRM for a new client that needs a CRM solution.

Specs:

~200 members
recurring memberships
membership payments
bulk email to members

I am considering CiviCRM with Webform integration, but the client has budgetary issues for hosting.

Have users here successfully run CiviCRM in a shared hosting environment, as opposed to a VPS?

And is CiviMail the main resource consumer, or is any CiviCRM installation likely going to need VPS hosting to run without problems?

Assuming CiviMail is the main resource issue, can one use an external bulk mail tool with CiviCRM (e.g. MailChimp) instead of CiviMail? If so, will this take the burden off the host and mean a VPS isn't necessary to run CiviCRM?


texts: Views REST Export not stripping HTML tags and adding extra special characters for links

texts:
I created a REST export using Views for taxonomy. But, I am unable to strip  tags from the description. Also, I am getting extra special characters for links.

[{"title":"featured 1","header":"learn how to contribute","text":"\u003Cp\u003ELorem ipsum dolor asit Lorem ipsum dolor asitLorem ipsum dolor asitLorem ipsum dolor asit\u003C\/p\u003E\r\n","link":"https:\/\/www.google.com"},{"title":"Featured 2","header":"learn how to contribute","text":null,"link":"https:\/\/www.facebook.com"}]

How can I strip HTML tags from the description and remove "//" from links in above JSON output?

I checked "Strip HTML tags" option for description. Please see image below.


texts: Show a block only on the frontpage of the sub-domains

texts:
I am using Drupal 7 for a site and I installed the Domain access module for maintaining the sub-domains. The slideshow block (created using the Views module) should be displayed on the sub-domains front page, but not on the main domain.

I tried the Domain block module, but it would require to manually set the block for each domain.

How can I make the block appear only on the front page of the sub-domains?


texts: Create 3 Views blocks that display 1st, 2nd, and 3rd most recently created nodes

texts: How can you create three View blocks such that (based on a particular field value or taxonomy category or just content type) the first block displays the most recently CREATED (not updated) node, the second displays the second most recently created node, and the third displays the third most recently created node?


texts: how to get a list of all nodes that haven been created and are not in use on the system

texts:
as the title says..
i need to get a all published nodes of type A that have been created and not used (at the moment) by other nodes.

in other words a list of all node of type A that are on the Database except for those that are NOT been referenced in an entity reference field.

the easy approach will be to load all nodes that uses node of type A, and that load all type A nodes and check for each if it's has a reference for it.
but then if i add another node that will use node of type A as an entity reference i'll have to go back check it as well.

is there an easy way to do it ?


texts:
I would like to place some (PHP)functions in a helper files, which requires across modules and themes.

Do I have to create a new module or I can place a simple helper file with list of common functions, what is the best practice for these kind of functions in drupal 8 ?


texts: render form item of type text_format in twig file

texts:
I have created a form element, basically I want text formats to change texts as accordingly.

$form['thankyou'] = [
        '#type' => 'text_format',
        '#title' => $this->t('Thank you'),
        '#format'=> 'full_html',
        '#default_value' => $config->get('thankyou'),
      ];

Now, I have created a function, where I'm getting this form element value.

$config = \Drupal::configFactory()->getEditable('myconfig');
 $thankyou_paid = $config->get('thankyou');

If I directly debug $thankyou_paid, I get all my data formatted. (in bold)

But If I render it through hook_theme,

return array(
      '#theme' => 'mytwig',
      '#type' => 'markup',
      '#thankyou' => $thankyou_paid,
      '#cache' => ['max-age' => 0,],
    );

It gives me <b>ugwdegfgiurgiuterug</b>. Means, data gets rendered without formatting.

How to get this text (ugwdegfgiurgiuterug) as ugwdegfgiurgiuterug.


texts: How to split up content in a referenced entity in Twig?

texts:
I am maintaining a project that was built by a sitebuilder and is frankly a bit of a mess.

I have some content types, that use custom blocks to add in the ability to enter location details e.g. address and geolocation (shown via leaflet).

Now, I need to be able to 'split' the output of this rendered entity so I can place the address in one part of the page, and the leaflet map in another.

I was obviously able to duplicate the output f the entire block by placing {{ content.location_lock }} in two parts of my node template.

But I was unable to see anyway to just output the address for example. I tried {{ content.location_block.address }} but that didn't work.

Is there a way to achieve this rather then spitting out the entire block and hiding the bits I don't want with CSS? (really don't want to go that route!)