texts: How do I dynamically modify a block's mark up at render time, in Drupal 7?

texts:
I have a page with the following structure:

Header zone

Header One Area (block)

Content zone

Content Area (node)

The rendered node has an image attached to it. What I need to have happen is to make the attached image render inside the "Header One Area" block instead of as part of the content.

This is proving difficult, since blocks and their #markup are rendered before a node is processed. The better idea I had is to create a preprocess function for the page, through code figure out the node_id being rendered, grab its images, and then dynamically modify the blocks markup.

I have tried creating a MYTHEME_preprocess_page() method inside my template.php and then accessing the block via:

if ($block = block_get_blocks_by_region('header_one_area')) {
   // what code do I need here to make a #markup modification stick ???
   $block['block_4']['#markup'] = "
TEST
";
   print kpr($block);
}

I'm not quite sure how to actually modify its markup dynamically before it is rendered here.

Do you have any suggestion?


texts:
I am wondering if there is a way to create thumbnails of Vimeo videos programmatically. e.g. is there a function like image_style_url() to create an image derivative given a style and image path?
thanks.


texts:
I am implementing REST in Drupal 8. I have created a custom plugin for REST resource, enabled the plugin and configured permissions for that REST endpoint.

After few days, I removed the code for plugin without disabling the REST endpoint. I am encountering a plugin not found function for that REST endpoint.

Following this Drupal\Component\Plugin\Exception\PluginNotFoundException: The "glossify_taxonomy" plugin does not exist., I made changes in the config and cache config table. Still I am encountering Plugin not found exception when I click on Permissions and Extend in Menu.

How can I remove this exception?


texts: Drupal 7 views Contextual filters with Blocks, default value doesn't work properly , wield

texts:
I have a view created that show content based on the url:
eg:
domain.com/projects/[username]/[projectname], which shows a project of a specific user, that works well.
Additionally, I want to show the related projects of this user on the sidebar, so I create a block view, using the Contextual filters and the default value.

because my url is projects/username ,By using the default value -> raw value from URL,  so I set the path component as 2. but that doesn't work for me.
eg:
suppose my username is  "abc".

in the preview, if the url path is "projects/abc", it doesn't show anything although the username is in the 2ed component of url path.

if the url path is "abc/*", it will show the related content, meaning as long as the username is in the first argument of the url path, it works.

I don't what happens, it seems that configuration of path component as 2 doesn't work. I am so puzzled , what happened ?


texts: How to "freeze" a View at the time of publishing?

texts:
I have a content type for publishing a node once a week (type A) - on Saturday night/Sunday morning - that needs to show, as an attachment, a list of some other nodes (type B) that go live daily during the week (one node a day)
I have a view that puts together nodes of type B for 6 days of week - Monday through Saturday, so I have a filter on Post Date between 'last Sunday' and 'now' and I limit the number of nodes to 6. Then I use Viewfield to show the view of nodes B on content type A - and it all seems to work, but! (there are always those 'buts', right??) - I want to 'freeze' the View's content at the time of publishing - so if somebody will click on the type A node two weeks from now, the list of the type B nodes should be relevant to the week the type A node was published on - so, I need to somehow filter the type B nodes view using an "external date" parameter
How do I do that?


texts: Ajax call in form alter of inline entity form

texts:
Inline entity form is using in bricks.
In that Inline entity form, there is 2 dropdown fields available .
i want to form alter in that Inline entity form, so that selection of one dropdown value, second will change.
To fire Ajax call i have used hook_inline_entity_form_entity_form_alter().
On loading of form it is working fine, but when Ajax callback invoked i think hook_inline_entity_form_entity_form_alter() is not loading again.
it is throwing error

  TypeError: Argument 1 passed to Drupal\Core\Render\MainContent\AjaxRenderer::renderResponse() must be of the type array, null given.

not sure Ajax call worked in form alter of inline entity form.

Below is source code:

function customcheck_inline_entity_form_entity_form_alter(&$entity_form,  &$form_state) {

if($entity_form['#entity_type'] == 'brick' && $entity_form['#bundle'] == 'role') {
   $selected = ($form_state->getValue('dropdown_one')) ? $form_state->getValue('dropdown_one') : 0;

   $entity_form['dropdown_one'] = [
    '#type' => 'select',
    '#title' => 'My Test',
    '#options' => firstOptions(),
    '#default_value' => $selected,
    '#ajax' => [
        'event' => 'change',
    'callback' => 'newfunctionCheck',
    'wrapper' => 'edit-output123',
    'progress' => [
        'type' => 'throbber',
        'message' => 'Verifying entry...',        ],
    ]
   ];

  $entity_form['dropdown_second'] = [
    '#type' => 'select',
    '#title' => t('Instruments'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#options' => getData($selected),
    '#default_value' => $form_state->getValue('dropdown_second') ? $form_state->getValue('dropdown_second') : '',
  ];

  }
}

function newfunctionCheck(&$entity_form, FormStateInterface $form_state) {
  return $entity_form['dropdown_second'];
}

function getData($key = '') {
  $options = [
    '90' => ['34' => 'test'],
    '91' => ['24' => 'new test'],
    '92' => ['14' => 'my hckeck'],
  ];
  if(isset($key)) {
      return $options[$key];
  } else {
      return array();
  }
  return $options;
}

function firstOptions() {
  $options = [
      '90' => 'test 122',
      '91' => 'new test 33',
      '92' => 'my hckeck 45',
  ];
  return $options;
}


texts: In Drupal 7 Views Contextual Filters, is there a way to manipulate the URL Value via PHP?

texts:
Given that WHEN THE FILTER VALUE IS NOT IN THE URL has a default value option of PHP to manipulate arguments. (Keep in mind this is when there is NO value set. In my case a value is always set, so this option will always be ignored.)

Is there a PHP option to manipulate WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED? The only option available is validation. I need a PHP option so I can manipulate the argument that is passed in. How can this be done?


texts: Variables are missing on page--node--add.html.twig

texts:
I have created two templates

page--node--edit.html.twig

page--node--add.html.twig

I have discovered that the {{ node }} and {{ node_form }} variables are missing during node creation.

Here is my code to render the node add form there using hook_preprocess_page.

  $variables['node_form'] = FALSE;
    if ($node = \Drupal::routeMatch()->getParameter('node')) {
      $form = \Drupal::entityTypeManager()
        ->getFormObject('node', 'default')
        ->setEntity($node);
      $variables['node_form'] = \Drupal::formBuilder()->getForm($form);
   }

My goal is to print node content type name and form from page--node--add.html.twig template.

PS. No issue on page--node--edit.html.twig (node edit page)


texts: Cannot get values in 3rd level SubFormState

texts:
I have a block that embeds another plugins into itself and this includes configuration form. I can properly handle the form structure but when it comes to validation I am not able to access the values in the embedded plugin form validation handler. I was looking at the SubFormState and I tried to adjust the #parents of the provided form element but it didn't help. I know SubFormState is far from perfect but this should not be an issue.

This is my form:

// ...
$carousel_ajax = [
      'wrapper' => 'carousel-settings-ajax-wrapper',
      'callback' => [get_called_class(), 'selectCarouselAjaxFormRebuild']
    ];

    // No need for "#tree" option here since this form is already embedded.
    $form['carousel'] = [
      '#type' => 'fieldset',
      '#title' => $this->t('Carousel'),
      '#prefix' => '
',
      '#suffix' => '
'
    ];

    $form['carousel']['plugin'] = [
      '#type' => 'select',
      '#title' => $this->t('Use carousel'),
      '#options' => ['' => '- ' . $this->t('None') . ' -'] + $this->carouselManager->getList(),
      '#default_value' => $configuration['carousel']['plugin'],
      '#ajax' => $carousel_ajax + ['trigger_as' => ['name' => 'select_carousel_submit']],
    ];

    $form['carousel']['select_carousel_submit'] = [
      '#type' => 'submit',
      '#name' => 'select_carousel_submit',
      '#value' => $this->t('Select carousel'),
      '#submit' => [[$this, 'selectCarouselFormSubmit']],
      '#limit_validation_errors' => [['settings', 'carousel']],
      '#ajax' => $carousel_ajax,
      '#attributes' => [
        'class' => ['js-hide']
      ]
    ];

    $form['carousel']['settings'] = [];
    if (!empty($configuration['carousel']['plugin']) && $this->carouselManager->hasDefinition($configuration['carousel']['plugin'])) {
      $carousel_plugin = $this->carouselManager->createInstance($configuration['carousel']['plugin'], $configuration['carousel']['settings']);
      $form['carousel']['settings'] = $carousel_plugin->buildConfigurationForm(
        $form['carousel']['settings'],
        SubformState::createForSubform($form['carousel']['settings'], $form, $form_state)
      );
    } else {
      $form['carousel']['settings'] = [
        '#type' => 'value',
        '#value' => []
      ];
    }

    return $form;

This is the block form validation handler(I am experimenting with various structures and whatnot):

public function blockValidate($form, FormStateInterface $form_state) {
    if ($form_state->hasValue(['carousel', 'plugin'])) {
      $carousel_plugin = $this->carouselManager->createInstance(
        $form_state->getValue(['carousel', 'plugin']),
        $form_state->getValue(['carousel', 'settings'])
      );
      //array_shift($form['settings']['carousel']['settings']['#parents']);
      $carousel_plugin->validateConfigurationForm(
        $form['settings']['carousel']['settings'],
        SubformState::createForSubform($form['settings']['carousel']['settings'], $form, $form_state)
      );
    }
  }

3rd level because the block itself is 2nd level being embedded in the \Drupal\block\BlockForm::form


texts: Rules does not have any action for publish selected content

texts:
In admin/content page we have some update options. I want to execute a Php code only when I use publish selected content or unpublished selected content on that page.

This rules should be fired JUST when I publish/unpublished selected content


texts: I want to add more fields to be indexed by solr. How can I do that

texts: I am now using search_api and search_api_solr. I want more custom fields, to be specific, like the weight for a term referred by a node content type, to be indexed together the out-of-the-box filed(like content type, created, language, etc.). How can I achieve that? what is the hook or api to do that?


texts:
I would like the Image Picker to be available on a node (page) as a block so that users can upload images without clicking on 'edit' where they can edit the actual page itself.

I have definitely enabled the setting in the configuration:

Do I need to do it via the Views module (which I do have installed also)?


texts: Detecting if site is inside iframe - loading custom CSS

texts:
I would like to add an extra stylesheet for my site if it's being embedded inside an iframe on another site.

I found a JS method to try detecting an iframe embed over here: https://stackoverflow.com/questions/326069

Basically, you can run a script like:

if (top === self) { not in a frame } else { in a frame }

But I was wondering if it's possible to have that code add a stylesheet to the page in Drupal. Or maybe if there were some way to do it in Drupal, in hook_init() or something, that would be even better...

A final method I could think about is using the JS above to maybe add a URL parameter like ?embed=TRUE so I can detect that and add a stylesheet... but that would require a refresh inside the iframe :-/


texts:
I'm writing a simple module to handle newsletter subscriptions and I want to create a form which is based on information passed in as a url argument.

Example path: /subscribe/verify/eiurhgiergierugskdfadsf

I'd like to create a form for /subscribe/verify which takes "eiurhgiergierugskdfadsf" as a parameter so that I can lookup the user by that hash value and then populate the form with their subscriber id and other information.

I can't seem to figure out how to get url arguments available in my form function though.

$items['subscribe/verify'] = array(
    'title' => 'Verify Email',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('subscribe_terms_form_verify'),
    'access arguments' => array('access content'),
);

function subscribe_terms_form_verify($unique_id) {
   ...
}

How do I safely get access to the url parameter in my form callback?


texts: Inserting div wrappers - changing hierarchy of the html

texts:
I have placed a number of blocks in my Main Section of the site. I have finished all the standard styling for the site, but now that I've moved on to the mobile/phone layouts, I find that I need more control over this list of blocks - I need to wrap some of these blocks so as to position them properly.

Image: http://i720.photobucket.com/albums/ww203/Nongolf/divhierarchy.jpg

I have looked at CCS Injector (which would be more aptly named 'CSS Adder'), and moving blocks for mobile browsers, but far as I can tell I can only move all blocks or none at all.

I really do not want to change the default sections for the blocks now, as the styles are all in place and would be largely ruined by moving them to another section.

So now I'm about to use some jQuery magic to strong-arm the html. But before I do so I wanted to ask you good people if there's another way?


texts:
I've customised the user profile tabs to look like a dashboard by using the generated classes and styling them using just CSS. Just to be clear, I haven't used any hooks or preprocesses to render the tabs, these are the default tabs that appear on the user profile.

I'm really pleased with the result! It all works fine and there's no bugs whatsoever as i've done it all through CSS:.

.logged-in.page-user {
  .dashboard-navigation {
    @include at-breakpoint($medium) {
      width: 20%;
      float: left;
    }
    section {
      padding: 0;
      margin: 0;
      max-width: 100%;
    }
    ul {
      padding: 0;
      margin: 0;
      border: 0;
      li {
        a {
          background: $lightgray;
          color: $darkgray;
          margin: 0;
          border: 0;
          text-transform: capitalize;
          display: inline;
          width: 50%;
          float: left;
          padding: .5em;
          color: $drupal;
          &.active {
            border-left: 3px solid $drupal;
            background: $white;
            &:after {
              content: "›";
              font-size: 2em;
              line-height: 0;
              float: right;
              margin-top: .25em;
            }
          }
          &:hover {
            background: $drupal;
            color: $white;
            &:after {
              content: "›";
              font-size: 2em;
              line-height: 0;
              float: right;
              margin-top: .25em;
            }
          }
        }
        @include at-breakpoint($medium) {
          display: block;
          overflow: hidden;
          a {
            padding: 1em 1em;
            text-align: left;
            display: inline-block;
            width: 100%;
            float: none;
            background: $lightgray;
            color: $darkgray;
            &:hover {
              background: lighten($gray, 10%);
            }
            &.active {
              background: $orange;
              color: $white;
              border: 0;
            }
          }
        }
      }
    }
    .secondary {
      clear: both;
      overflow: hidden;
      li {
        padding: 0;
        border: 0;
        a {
          background: $drupal;
          color: $white;
          &:hover {
            background: lighten($drupal, 10%);
          }
          &.active {
            color: $drupal;
            @include at-breakpoint($medium) {
              color: $white;
            }
          }
          &:after {
            margin-top: .3em;
          }
        }
      }
    }
  }

  .main-content {
    @include at-breakpoint($medium) {
      width: 80%;
      float: left;
    }
  }
}

Here's what i've come up with:

I'd like to take it a step further and add icons to each tab if possible like this:

I wasn't able to target the tabs using CSS as they all have general classes or non at all + obviously the tabs that appear depend on the role so I can't target them using pseudo nth-of-type selectors.

Maybe the solution is to add more specific classes but i'm open to ideas and some help on how I should go about it.


texts:
I was wondering about what might be the best approach to creating a complicated home-page layout along the lines of http://www.time.com/time/

I am attempting to do so. Here is how I'm approaching it:

I'm using views primarily and defining tons of custom regions (I was hoping that there might be a better way)
I have created a custom vocabulary called "Channels". I am using this for NewsFeed, U.S., Politics and so on. Articles are placed into one of these channels
I have modified the "Article" content type and added a field for Channel. Also, I have added checkboxes to mark an article as "Editor's Pick", "Must Read" and "Featured Article". I am then using this as a filter in Views. That was the best way I could think of for categorizing the articles on the numerous boxes on the home page.
Additionally, I'm marking articles with the "headline" tag so that they show up in the "Headlines" box on the upper right corner of the http://www.time.com/time/ home page.
Images are scaled based on where I will be using them. (I'm using Drupal's in built functionality to scale images)

This is how far I've gotten. Since I've just started using Drupal, I was wondering if there might be a better way to do things. Appreciate any inputs.


texts:
Inside my template.php I am populating a custom variable to be used inside my views-view-unformatted--latest_stories.tpl.php

The image data associated with the content type has the structure:

[field_photos] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [fid] => 4
                        [uid] => 1
                        [filename] => DSCF2639_0.jpg
                        [uri] => public://story/photos/DSCF2639_0.jpg
                        [filemime] => image/jpeg
                        [filesize] => 129245
                        [status] => 1
                        [timestamp] => 1397504538
                        [alt] =>
                        [title] =>
                        [width] => 800
                        [height] => 600
                    )

                [1] => Array
                    (
                        [fid] => 5
                        [uid] => 1
                        [filename] => DSCF2657.jpg
                        [uri] => public://story/photos/DSCF2657.jpg
                        [filemime] => image/jpeg
                        [filesize] => 89144
                        [status] => 1
                        [timestamp] => 1397504538
                        [alt] =>
                        [title] =>
                        [width] => 800
                        [height] => 600
                    )

            )

    )

How do I translate the path to a URI which a browser will be able to resolve?

Do I simply strip the public://

What if I move my files to AWS at a later date? Is there a function in drupal API that will handle this for me???


texts:
How to wrap body text around image for drupal 8. I found tutorial for drupal 7 here https://www.drupal.org/forum/support/post-installation/2008-06-30/how-to-wrap-body-text-around-image, but I still confused to implement this for drupal 8.

I found some css files inside css folder and which one that I have to edit?


texts: All content types missing for users other than UID#1

texts:
I am hoping that someone can help me.
I run a network of Drupal websites. They share the same code, but have different databases for each website.

This week, one of the websites began having a serious error -- any user other than me (UID #1) is restricted from seeing all of the content types and therefore cannot add any content, at all.

I've not made any changes to the websites that I am aware of that would cause this to occur. My other websites are all working fine and not having any similar issues.

As UID#1, I can do things normally, but if I masquerade as any other role or user, I am unable to add any content at all. When I mask as one of my higher level users who can see the content types, they are shown a screen that says no custom content types have been created.

I have looked at permissions and everything looks fine. Nothing looks any different than my other websites. I rebuilt the content access permissions and cleared the cache, but that did not help.

I've done some googling to see if I could find any similar issues and while there are a couple instances where content types have disappeared, they are all for earlier versions of Drupal and I assume do not apply to me. I am currently running Drupal 7.41 (just updated today).

Any creative suggestions on where to look next to try to resolve this issue are most appreciated. I'm truly stumped!

Heather


texts: Using the l() function within a node description field

texts: I'm converting an old site to Drupal, and I need to convert all the old URLs to the new system, which uses pathauto. I can turn the old links into node paths (eg. node/28), but I ideally want the aliased paths to show instead. I've found the l() function, but how do I go about applying it to links within the description field of nodes?


texts: How can I provide support for a non-core field type?

texts:
What is the necessary implementation to add support for a field type so that it is picked up by the core migrate_drupal upgrade process?

For example, the Weight module. It provides a simple field that holds a number, but the core migrate drupal module can't seem to map the source to the destination automagically like it can for most of my other fields.

Does this require placing plugin yaml files in modulename/migration_templates?


texts: How do I put registration form in panel in Drupal 7

texts: I would like to know how to put a registration form or any other form to make a new content type in panels. I know the first thing to do is to put the registration form in a block. How can I do that?


texts: un-escaped _server variable in settings.php - bad idea right?

texts:
I recently started working for a new company hosting drupal sites that is using a switch statement within the settings.php for multiple environments. I am accustomed to using multi-site and am exploring the feasibility of having configurations like this.

What concerns me is the lack of any sanitation or escaping of the variable and using it in its raw form. Is this a terrible idea or is it fine if we start sanitizing the 'http_host' variable?

Code:

    switch ($_SERVER['HTTP_HOST']) {

    //Live Settings
    case (preg_match('/^www\.domain\.com$/', $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : !$_SERVER ['HTTP_HOST']) :
    case (preg_match('/^web001\.domain\.domroot\.com$/', $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : !$_SERVER['HTTP_HOST']) :
    case (preg_match('/^web002\.domain\.domroot\.com$/', $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : !$_SERVER['HTTP_HOST']) :
    //Include file that contains sensitive db string
    include_once 'sites/default/settings.live.php';
    break;

    ...

     }


texts:
I am trying to import some videos into a 8.0.5 site (yes, I know I should upgrade)
I have over 200 videos that neeed to be imported into their own individual node. It seems like a perfect opportunity to get my head around the batch api.

After getting all the videos as objects in a sigle array, I then chunk this into batches of 10 using array_chunk() and then set each chunk as its own opperation.

I would have thought that the batch api would have sent each data array as a signle array to my process function. However, it seems that only the first video from each batch is getting processed.

If I add the &$context variable to my process function and dump it out, it just shows me the next object.

Please, can anyone point out what I have done wrong? :(

public function batchStart() {

ini_set('max_execution_time', 0);
$directory = drupal_get_path('module', 'drp_broadcast_videos_importer') . '/broadcast-videos';
$videoImporter = new VideoImporterController();
$videosArray = $videoImporter->getVideosFromDirectory($directory);
// Chunk up the array.
$videoChunks = array_chunk($videosArray, 5);

foreach ($videoChunks as $chunk) {
  $operations[] = [
    '\Drupal\drp_broadcast_videos_importer\Controller\ImportController::processBatch',
    $chunk,
  ];
}

$batch = [
  'title' => t('Processing Batch'),
  'operations' => $operations,
  'finished' => '\Drupal\drp_broadcast_videos_importer\Controller\ImportController::finishedBatch',
  'init_message' => t('Batch is starting.'),
  'progress_message' => t('Processed @current out of @total.'),
  'error_message' => t('Batch has encountered an error.'),
];

batch_set($batch);

return batch_process('/');
}

static function processBatch($video, $context) {
  try {
    $file = (new VideoImporterController())->createNewFileEntity($video->video, $video->filename);

    $broadcastNode = Node::create(['type' => 'broadcast_video']);
    $broadcastNode->setTitle($video->title);
    $broadcastNode->setOwnerId(\Drupal::currentUser()->id());
    $broadcastNode->setCreatedTime($video->date);
    $broadcastNode->set('field_broadcast_pack_name', $video->pack);
    $broadcastNode->set('field_videos', ['target_id' => $file->id()]);
    $broadcastNode->save();

    $context['message'] = $video->title . ' processed.';
    $context['results'][] = $video->id;

  }
  catch (EntityStorageException $exception) {
//              \Drupal::logger('broadcast_videos_importer')
 //                ->error($this
//                  ->t(
//                    'The broadcast video @title could not be uploaded',
//                    ["@title" => $videoObject->title]
//                  )
//                );
//              drupal_set_message($this->t(
//                'The broadcast video @title could not be uploaded',
//                ["@title" => $videoObject->title]));
    }
  return $broadcastNode->id();
 }


texts: How do I override the date filter to filter by years instead of exact date?

texts:
I want to add another option to Date filter to filter with only years not the exacte date.
So i want to add another radio option here:

Like:

The above options added by Date Filter.
I have tried two ways:

Add new filter like date filter:
modules/custom/my_module/src/Plugin/views/filter/DateYear.php

namespace Drupal\my_module\Plugin\views\filter;

use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\filter\NumericFilter;

/**
 * Filter to handle dates stored as a timestamp.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("date_year")
 */
class DateYear extends NumericFilter {
  // Same Code Date class with a little changes.
}

I tried to extend Date class and alter date filter plugin.

I create Class DateYear extending Date filter class:

namespace Drupal\my_module\Plugin\views\filter;

use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\filter\Date;
/**
 * Filter to handle dates stored as a timestamp.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("date_year")
 */
class DateYear extends Date {
  // Override valueForm method..
}

Then i implement hook_views_plugins_filter_alter to override class.

   /**
 * Implements hook_views_plugins_filter_alter().
 */
function cam_views_views_plugins_filter_alter(array &$plugins) {
  if ($plugins['date']) {
    $plugins['date']['class'] = 'Drupal\my_module\Plugin\views\filter\DateYear';
  }
}

But none of the above works ?


texts:
Is there a module or a way in core to have an Image field be a clickable link to a URL that is either entered as an additional setting for the Image field or can be pulled from another field that stores that URL.

This https://www.drupal.org/project/linked_field looks like what I want, but there doesn't seem to be a token that I can use that will do what I want.

This also looks exactly like I want but it's for D7. https://www.drupal.org/project/linkimagefield

I'm using this for a Custom Field Type


texts:
Must I use webform in order to create a custom form? I need to create a form validator that will validate if a number (social security number) is valid. I've used webform for this but whatever I enter in the form, it's always storing it and I have to clear the data by going to admin. I dont want the webform to store user input. The point of the form is just to validate. Basically client side validation (or PHP side) is the only purpose of the form. No storage needed. Is there a way to turn off the storage in webform? Or do I have no choice but to store all inputs entered by users?

I've seen this but I dont want to redirect. My form is just an ajax call..


texts: Why do Drupal.behaviours and document.ready behave differently?

texts:
I have the same piece of jQuery that works differently depending whether it is wrapped in document.ready or Drupal.behaviours. The code is intended to enumerate a list of tabs generated by the vertical tabs module.

Using

Drupal.behaviors.myModule = function (context) {
   $('ul.vertical-tabs-list li').each(function(i){
     console.log(i);
   })
}

Logs no output, but the following works as expected.

if (Drupal.jsEnabled) {
$(document).ready(function() {
      $('ul.vertical-tabs-list li').each(function(k){
      console.log(k);
      })
    })
 }

Why is there a difference and how can I get the first version to work?


texts: Get Multiple Field Values Out Separately In Twig

texts:
I have a content type called 'locations' with a bunch of plain text fields. Each field allows for multiple values.

For example, one of the fields is named 'support' and allows for an unlimited amount of entries. This is because this will be able to accept email address and telephone numbers etc.

I've made a view that takes the latest 2 of this content type, and I'm editing the template used for the single view views-view-fields--locations.html.twig.

I can display the values of each field with {{ fields.field_telephone.content }}, however I can't seem to get the multiple values out, only the first. Kint's really not being helpful (it won't let me kint all the fields or simply a specific field without crashing).


texts: Author name in comment preview not rendering apostrophe properly: a bug or by-design?

texts: This happens on a Drupal 7.26 using the default theme when previewing a comment. The &#039 part is equivalent to an apostrophe. What I don't know if this is something that is part of Drupal to prevent exploits or if this is a bug that should be fixed. I tried searching the Drupal.org forums if this is a bug, I wasn't able to find anything relevant.


texts: Get all orders that contain a certain product

texts:
I am trying to create a rule so that when a node containing a commerce product is update will notify all customers that have made a order containing this product.

I act on event "After updating existing content" and get to the commerce product using entity has field (field_product).
How can I get from the product to all the orders containing it so I can loop through them?


texts: 'Settings' option for region has dissappeared

texts:
I am working on a Node template variant. I added a class each to the two regions (Gear icon, 'Settings' option) that make up the template: page-left and page-right. This worked well and allowed me to write my styles.

However, I've come back to it after the weekend and now one of the classes, page-left has dissappeared. Further more, the 'Settings' option under the Gear Icon is missing, so I cannot add the class back.

Oddly the other region, page-right, has maintained both its class and its 'Settings' option.

Would anyone know what's going on here and how I can bring back this class?


texts: How to group views rows by year using date field?

texts:
I have a content type with a date field.
I need to output them grouping by year, i.e.

2011

- nodeA 2011-09-01
- nodeB 2011-01-29

2010

- nodeC 2010-12-08

How can I do that?


texts: How can I retrieve the profile2 fields selected in a custom module?

texts:
I am totally new to entities in Drupal.  I have used the Profile2 module to add a few profile types.  This is displayed in the add/user screen as Customer.

After adding the profile type I manage the fields and add a new entry called cust with a field_id of field_cid.  This is setup as a list(text) and checkbox widget.

When I edit a user I have a checkbox list for Customer that can be selected by each user.  I have a custom module that I am trying to read the selected value by $user->uid from the profile2 field.

The idea is to retrieve the selected item in my module and format the return values to the user from a custom DB table.  Here is what I have tried and got results but cannot get all the values.

In my module using:

$profile = profile2_load_by_user($user->uid);$list = field_view_field('profile2', $profile['customer'], 'field_cid');print_r($list)

I get this result:

Array ( [#theme] => field [#weight] => 0 [#title] => cust [#access] => 1 [#label_display] => above [#view_mode] => _custom_display [#language] => und [#field_name] => field_cid [#field_type] => list_text [#field_translatable] => 0 [#entity_type] => profile2 [#bundle] => customer [#object] => Profile Object ( [pid] => 9 [type] => customer [label] => Customer [uid] => 1 [created] => 1409542969 [changed] => 1409545821 [entityType:protected] => profile2 [entityInfo:protected] => Array ( [label] => Profile [plural label] => Profiles [description] => Profile2 user profiles. [entity class] => Profile [controller class] => EntityAPIController [base table] => profile [fieldable] => 1 [view modes] => Array ( [account] => Array ( [label] => User account [custom settings] => ) ) [entity keys] => Array ( [id] => pid [bundle] => type [label] => label [revision] => ) [bundles] => Array ( [customer] => Array ( [label] => Customer [admin] => Array ( [path] => admin/structure/profiles/manage/%profile2_type [real path] => admin/structure/profiles/manage/customer [bundle argument] => 4 [access arguments] => Array ( [0] => administer profiles ) ) [rdf_mapping] => Array ( ) ) ) [bundle keys] => Array ( [bundle] => type ) [label callback] => entity_class_label [uri callback] => entity_class_uri [access callback] => profile2_access [module] => profile2 [metadata controller class] => Profile2MetadataController [static cache] => 1 [field cache] => 1 [load hook] => profile2_load [translation] => Array ( ) [schema_fields_sql] => Array ( [base table] => Array ( [0] => pid [1] => type [2] => uid [3] => label [4] => created [5] => changed ) ) [configuration] => ) [idKey:protected] => pid [nameKey:protected] => pid [statusKey:protected] => status [defaultLabel:protected] => [field_cid] => Array ( [und] => Array ( [0] => Array ( [value] => 1 ) [1] => Array ( [value] => 2 ) ) ) [field_test] => Array ( [und] => Array ( [0] => Array ( [value] => 3 ) ) ) [rdf_mapping] => Array ( ) ) [#items] => Array ( [0] => Array ( [value] => 1 ) [1] => Array ( [value] => 2 ) ) [#formatter] => list_default [0] => Array ( [#markup] => Disney ) [1] => Array ( [#markup] => Burger King ) )

I want the name in the last line [#markup] only returned to my function.  In the above output the returned values should be Disney and Burger King.

How can I retrieve these values only?


texts: A time field instead of end date in drupal 7 date field

texts:
Is it possible to have a time field (for example in minute only) instead of end date of date field in drupal 7?

so that the user select start date and time and due time (in minute) and end datetime will be start datetime + due time?


texts: How to use form_set_error if no form field is involved in the error?

texts:
In a form_validate hook, I have some custom validation and I'm using

form_set_error('field_foo', "error_message");

to show validation errors. If the validation returns an error that is not linked to a particular form field, how do I show the error, indipendently? (For example: the error is you compiled more that three times the form.)

EDIT: I though to use:

drupal_set_message("error_message", 'error');

From the documentaion for 7.x

  When a validation error is detected, the validator calls
  form_set_error() to indicate which element needs to be changed and
  provide an error message.

So, form_set_error() produce an error linked to a particular field of the form. I needed to display error indipendently in a custom complex validation, being errors not really about a field. I though to use form_set_error() on a random field, but it is not the perfect solution, for the field was highlighted and only the last error produced this way was visible.
drupal_set_message solves this two problem, but the validation success and the form continues like there was no error.


texts:
I have created a content type to which I added a Serial Field number. For testing purposes, I created many nodes.

Now I would like to reset the value of the serial number, so that the next created node will have 1 as serial number. Can anyone help me how to do this?

I found this document, which suggests to delete the field, but I don't want to delete the serial number field.


texts: Backup restoring differently than how it used to

texts:
I posted a question yesterday, which ended with someone telling me to figure out how my backups are managed and then to ask another question with more details, so here I am.

About a week ago my boss backed up and installed a dev server for his site, so that I could play around with it and learn Drupal without messing up the live version.

About 2 days ago I updated all of my modules and Drupal core to 7.42 from 7.41. The next day I noticed that the login page, where the user has to log in before being able to access the rest of the site, no longer exists. Now when I go to my dev site it shows the main page with the login form somewhere near the bottom, along with all of the menus and everything that you should only be able to see while logged in. You can't actually access the menu links, as when you do it loops back to this same page since it requires a login, but users aren't even supposed to be able to see the links before they login.

I tried restoring the original backup (the one used to create this dev version from scratch) onto the dev site, but the same issue happened. I thought it may be something with the SQL, so I restored the databases using that same original backup; same thing happened. I tried installing the backup onto different versions of drupal too: 6.42, 7.41 (the version that it was originally on), 7.42(the one it updated to that I thought broke it), and the 7.x dev one. Same thing happened on every one.

I tried doing a complete reset, uninstalling and reinstalling lamp, but nothing changed then either.

After doing some searching through the files, I found that the only reference to the image used on the live site's correct page is in the blogger theme's style.css file, which confused me because the rest of the site uses the lexus zymphonies theme. I'm not sure if this means anything, but it's the only real lead I have here about anything related to that page.

Any help solving this issue would be greatly appreciated.


texts: How to move whole Drupal website on USB for localhost use using XAMPP?

texts:
My cPanel subscription will come to an end soon and I want to move my site to a USB stick or CD and still be 'runnable' / executed. It is currently on a cPanel server...

I have seen these options but they all seem outdated and might not be ideal as my website is nearly 300MB in size.

Static Module
uniform server
CD deploy

I want to keep the site static and lose the editing features that come with the modules - essentially I want to freeze what I have done up to now and keep a record of it that will always work locally on a medium.


texts:
I need to create 10 or so pages that are linked in a specific order but can only be accessible when the user enters the correct access code.

The first page would be open and "unlocked" - but the user will need to enter some details before being able to see the next page, they would be presented with the access code for the 2nd page and this would be added to their user profile as their current access code level.

To see the next page, the user would require to enter a specific code to unlock that page.

How would I go about getting this to work? From what I know, webforms would be useful for "linking the pages in order" but I haven't found a way where you must enter a "password" access the next page of the form.

The idea is that the 10 pages would act as 10 different levels for a simple learning "game."


texts:
I would like to print an image URL with an image-style.
This doesn't work, since I don't have a ".value"-value for the image: How to find image style URL from within twig template?

Is there anything different on field-templates?

My code in field--field-images.html:

{% for item in items %}

{% endfor %}

This doesn't work (results in no filename since .value isn't available:

This crashes the page:

Thanks!


texts: Easiest way to add color to a title field?

texts:
I have 2 fields, one is an image and the other is just a title. Now the title hovers above the image, but the problem here is that the image might clash with the font color. If the image is predominately white and the text is white, you wont be able to see it.

I was thinking of creating a new field just for the user to select white or black. Then i would create a tpl just for this article page to parse the "color" field and expose it for css styling. I feel like this is the long way to do this.

What other possible ways can this be accomplished?


texts:
I'm using Drupal 8's built-in search and it will not update the index.

I have cron running every 15 minutes and even tried running it manually but the search status page always says:

"0% of the site has been indexed. There are 80300 items left to index."

Another odd thing is that some nodes appear to be indexed, even though the status report says zero, because some (but not all) nodes will appear when searched for.

Any ideas what's going on?


texts: I have one hook, "hook_form_commerce_checkout_form_alter" and that is modifying something on my checkout process. Within that though I have a switch statement that if true I want to use "hook_commerce_checkout_router" to skip the page. Is this allowed? I can't get any signs of life via DPM. I ran through a bunch of other modules and can't find anything helpful


texts: How do I turn off clean URLs only for logged-in users?

texts: The end-goal is to use filters to support AWS' new CDN dynamic content feature.


texts: How to set access permission to roles due to the content's vocabulary

texts:
There is only one Content Type in my site and two vocabularies  ,say, vocabulary1 and vocabulary2. Now I don't want some roles to access some content due to their vocabulary.

Can I set  access permission to roles due to the content's vocabulary???

thanks!


texts:
I'm using Drupal 7 and Clean theme. My main module is Views. And created 2 field in a content type and listed via Views on page.

I want, rewrite a field link on a other field.

e.g.
My Field:

Head: Content Head
Link: www.site.com

When click content head go to www.site.com

How can i do this?


texts: drupal 7: showing main menu links to anonymous users

texts:
I have successfully enabled the toboggan present login form on access denied (403), however am not sure how i can set my links to be visible to anonymous users. I used views to create the pages and limited access to users with view published content privileges. Problem is if i do not allow anonymous users to view published content in the permissions section the links will not show.

I have tried content access and ACL but they allow anonymous users to view the content. And i can't use the path /?q=user in the text field, titled, Page Not Found 403(access deneid). Any suggestions?

Summary -: I want to show main menu links to pages (e.g. articles) to anonymous users but i want them to be redirected to the log in page when they click the links.


texts:
I am working on Recruiter distribution which uses a Cloudy theme.

I have tried 2 ways to add custom javascript to my site:

  1)Adding jquery code to the .info file of Cloudy theme(default theme)
  called cloudy.js.

  2)Adding a new .js file under js/myjs.js and added
  this to the .info file of Cloudy theme scripts[] = js/myjs.js

However,when I view the source code of my frontpage, neither cloudy.js nor myjs.js is loaded and as a result the jquery code doesn't work.

What am I missing? Has anything to do that it is a distribution and not a drupal site?
thanks


texts: Use a route with an id to mimic a node type but pull from a third party source?

texts: Is it possible in Drupal 8 to create a route like /events/{id} with a controller, and in that controller make a call to a third party API to fetch data and then send that data to a template? It basically would not exist in Drupal as an entity.


texts: Why Views Slideshow JCarousel plugin isn't available on view format settings?

texts:
I've installed:

Views Slideshow
Views Slideshow Cycle
Views Slideshow Carousel

All required libraries are available. Status reports page is green.

I want to create slideshow view. I choose slideshow format, but on settings I have only Cycle as available slideshow type.

What can be wrong?


texts: Views pager when view is running on Node Id

texts:
I have a view with a contextual filter of Nid running to display the current node.
Does anyone know of a way to set up pagers within a view that can handle paging to  next/prev nodes? So a 'next' link for the subsequent node and a 'prev' link to show previous node.

I would normally use custom pagers for this but this module does not work properly with views 3 that I have installed.

Any help or an alternative to custom pagers would be much appreciated.


texts:
I've created a view in order to override the default search page form and results, then I've exposed the content type in order to have the possibility to filter by that, all now is working

How can I have the count of the relative content near each content type label on the filters?


texts: In a node edit form i want to display an editable view, so an author can not only edit the node itself but also can alter some values of other nodes represented by the view, which is editable via the editable views module. How can i alter the node edit form in order to display that view?


texts:
I have a content type with body tag. I want to add content which has a repeating HTML mark-up.

Example:

Main Content 1

Main Content 2

This pattern repeats itself except for the text within the
 tag. Right now I'm typing tons of repeating HTML code into the body of the content type. It would be helpful if I could just focus on the main content and not on the repeating mark-up which could save lots of time.

Is there a way to surround fields with custom HTML tags, so that I can focus on the main content and not on the HTML mark-up?
Is there a module that I can use to do the same?


texts:
How to set reading permission for each separate page?
Do already have existing drupal setting for us to use? or I need to coding it?
Thanks.


texts: Render user login form with custom theme

texts: I have written a custom module, inside which I would like to create a custom user login block with custom theme applied. Now my question is "Inside my custom module, how do I get the user login form?"


texts: FROM_UNIXTIME(o.created,'%d-%m-%Y') in where clause gives error

texts:
I am working on Drupal 6. while executing  query when I add
and FROM_UNIXTIME(o.created,'%d-%m-%Y') <  '".arg(3)."'";
to WHERE clause it doesn't return result.
i have tried by using same query in MySQL Query Browser it returns result.
so I am confused how to pass above condition in WHERE clause,
as I am passing 31-10-2012 in arg(3).


texts:
I have this code, but I don't know how to wrap it in Drupal.

 $(document).scroll(function () {
    var y = $(this).scrollTop();
    if (y > 100) {
        $('.bottomMenu').fadeIn();
    } else {
        $('.bottomMenu').fadeOut();
    }

});

I've already activated the .js file and added the detail in .info, I can see it from the firebug that is ok, but from firebug console I can see that I have syntax errors.

From Drupal website I can see an example:

(function ($) { // Here code javascript })(jQuery);

Can someone show me how the code above should look like into Drupal? Thanks.


texts:
When I create a user view, I don't see the option for having hierarchical select on the exposed filters. I have the hierarchical data saved using hierarchical select already. Simple hierarchical select doesn't have the option too.

How can I create a user list hierarchical select exposed filter?


texts:
I'm trying to send a redirect after logout, but it is not sending properly. I tried using the hook_user_logout in a module as follows:

use Drupal\Core\Routing\TrustedRedirectResponse;

function module_user_logout($account) {
  $redirect = new TrustedRedirectResponse($url);
  $redirect->send();
}

The send() call causes the page to crash with the message: "The __ page isn't working"


texts: Only show field type content added by user

texts: On my website I allow companies to add jobs, I allow a user to create one or more companies. When the user goes to add a job I have a drop down which lists all of the companies on the site, I want this drop down to only list the companies added by the user so they can choose which company they want to attach to the job. I can't find a way to do this via the manage fields screen. Below is a screenshot of my manage fields screen. Any help would be much appreciated!


texts: Why using of custom date format makes my Drupal date outdated and does not change at all?

texts:
I have custom installation profile and I must set date formats programmatically.

I tried:

db_insert('date_formats')
    ->fields(array(
        'format' => $format_long,  // PHP Date String
        'type' => 'custom',          // 'custom'
        'locked' => 0,               // 0 = user-specified date format
    ))
    ->execute();
variable_set('date_format_long', $format_long);

and

$format_long = 'l, Y-m-d G:h';
system_date_format_save(array(
    'is_new' => 1,
    'type' => 'custom',
    'format' => $format_long,
    'locked' => 0,
));

and set this up:

   variable_set('date_format_long', $format_long);
   variable_set('date_format_medium', $format_medium);
   variable_set('date_format_short', $format_short);

At admin/config/regional/date-time all seems to be fine but:

time is e.g 16:04 (now I have 16:38). Time changing, but on settings page time is still the same (after refresh).

I tried to create a content and at admin/content listing I have content updated date as 16:04 too... :(

If I switch to default formats all works ok.

What is wrong?

EDIT

At admin/config/regional/settings time is 16:04 too....

EDIT

I created module based on suggestion from answer, still no luck :(

define('RPKE_DATE_FORMAT_LONG', 'l, Y-m-d G:h');
define('RPKE_DATE_FORMAT_MEDIUM', 'D., Y-m-d G:h');
define('RPKE_DATE_FORMAT_SHORT', 'Y-m-d G:h');
define('RPKE_DATE_DATE_TYPE_LONG', 'rpke_date_long');
define('RPKE_DATE_DATE_TYPE_MEDIUM', 'rpke_date_medium');
define('RPKE_DATE_DATE_TYPE_SHORT', 'rpke_date_short');

/**
 * Implements hook_date_format_types().
 */
function rpke_date_date_format_types() {
    $types = array();
    $types[RPKE_DATE_DATE_TYPE_LONG] = t('Long date format for RPKE');
    $types[RPKE_DATE_DATE_TYPE_MEDIUM] = t('Medium date format for RPKE');
    $types[RPKE_DATE_DATE_TYPE_SHORT] = t('Short date format for RPKE');
    return $types;
}

function rpke_date_date_formats() {
    return array(
        array(
            'type' => RPKE_DATE_DATE_TYPE_LONG,
            'format' => RPKE_DATE_FORMAT_LONG,
            'locales' => array(),
        ),
        array(
            'type' => RPKE_DATE_DATE_TYPE_MEDIUM,
            'format' => RPKE_DATE_FORMAT_MEDIUM,
            'locales' => array(),
        ),
        array(
            'type' => RPKE_DATE_DATE_TYPE_SHORT,
            'format' => RPKE_DATE_FORMAT_SHORT,
            'locales' => array(),
        ),
    );
}

function rpke_date_flush_caches() {
    _rpke_date_purge_date_formats();
}

function _rpke_date_purge_date_formats() {
    $format = system_get_date_formats(RPKE_DATE_DATE_TYPE_LONG);
    variable_set('date_format_' . RPKE_DATE_DATE_TYPE_LONG, RPKE_DATE_FORMAT_LONG);
    if (!empty($format['dfid'])) {
        system_date_format_delete($format['dfid']);
    }
    $format = system_get_date_formats(RPKE_DATE_DATE_TYPE_MEDIUM);
    variable_set('date_format_' . RPKE_DATE_DATE_TYPE_MEDIUM, RPKE_DATE_FORMAT_MEDIUM);
    if (!empty($format['dfid'])) {
        system_date_format_delete($format['dfid']);
    }
    $format = system_get_date_formats(RPKE_DATE_DATE_TYPE_SHORT);
    variable_set('date_format_' . RPKE_DATE_DATE_TYPE_SHORT, RPKE_DATE_FORMAT_SHORT);
    if (!empty($format['dfid'])) {
        system_date_format_delete($format['dfid']);
    }
}

EDIT

The worst nightmare is that creating custom date format from UI (e.g. custom date format in Views) result display of wrong date too....


texts: Referencing an existing image in theme settings

texts:
In a custom theme (Drupal 8.4.3) I would like to add a theme setting, where I can reference (not upload) an image to use as a background image. Like in a normal reference field, already uploaded images should be choosable; these images are stored in media entities.
How can I build such a theme setting? I only found information about Uploading images in theme settings.


texts: How to pre-fill form fields with data from the node?

texts:
I have a site that list different courses that take place in real life (not virtual courses). For each course, there are different fields :

title of the course
start date
end date
place where the course will happen
type of course
...

With View I have created a table that list all the courses. I would like that logged users can subscribe to a course by just clicking on it, and then I would receive an e-mail (or see in the back-end) that tells me that user X has subscribe to course Y (and I will have in the same time all the informations about the course the user subscribed to : title, dates, place...)

For the moment when a logged user click on a course, another page loads that displays informations about the course, and a form where the user have to write out again all the informations in blank fields...

Is there a way to pre-fill the form fields with the informations of the course ?

Or is there a smarter way to do this ?

Thanks


texts: Merging two vocabularies during node site migration

texts:
I am working on a migration where I have two vocabularies that I am merging into one vocabulary in the new site. The problem I am having is when trying to migrate the node that has the two old vocabularies the field is mapped only once.

// Code to merge two vocabulary into one (Working like a charm):

  $vocabulary_arguments = array(
    'Tag' => array(
      'description' => t('Migration of news terms from Drupal 6'),
      'source_vocabulary' => '8',  // D6 Vocabulary ID
      'destination_vocabulary' => 'tag',
    ),
    'TagEntry' => array(
      'description' => t('Migration of blog tags terms from Drupal.'),
      'source_vocabulary' => '7',  // D6 Vocabulary ID
      'destination_vocabulary' => 'tag',
    ),
  );

// Code to merge content type with two vocabularies (last mapping stay)

  $node_arguments = array(
    'Blog' => array(
      'class_name' => 'MyBlogMigration',
      'description' => t('Migration of blog nodes from Drupal 6'),
      'source_type' => 'blog',
      'destination_type' => 'blog',
      'dependencies' => array('Tag', 'TagEntry'),
    ),
  );

// My BlogMigration

class MyBlogMigration extends MymoverNodeMigration {
  public function __construct(array $arguments) {

    parent::__construct($arguments);

    $this->addFieldMapping('field_tag', '7')
         ->sourceMigration('TagEntry');
    $this->addFieldMapping('field_tag:source_type')->defaultValue('tid');
    $this->addFieldMapping('field_tag:create_term')->defaultValue(FALSE);
    $this->addFieldMapping('field_tag:ignore_case')->defaultValue(TRUE);

    $this->addFieldMapping('field_tag', '8')
         ->sourceMigration('Tag');
    $this->addFieldMapping('field_tag:source_type')->defaultValue('tid');
    $this->addFieldMapping('field_tag:create_term')->defaultValue(FALSE);
    $this->addFieldMapping('field_tag:ignore_case')->defaultValue(TRUE);

    $this->addFieldMapping('pathauto', NULL, FALSE)->defaultValue(1);

  }
}

What am I missing?


texts:
When users sign up (via oauth) we need to show them Terms & Conditions as a modal. We have figured out how to make a link open a dialog in D8:

public function build() {
  return [
    '#type' => 'link',
    '#title' => $this->t('Sign in to the Community'),
    '#url' => Url::fromRoute('sc_oauth.start', [], ['query' => $this->getDestinationArray()]),
    '#options' => ['attributes' => static::OauthLinkAttributes()],
    '#attached' => ['library' => ['core/drupal.dialog.ajax']],
  ];
}

/**
 * @return array
 */
public static function OauthLinkAttributes() {
  return [
    'class' => ['use-ajax'],
    'data-dialog-type' => 'modal',
    'data-dialog-options' => Json::encode([
      'width' => 700,
    ]),
  ];
}

but have no idea about how to trigger a modal automatically when the page loads. Probably it involves some JavaScript or perhaps it's doable only via settings? My only idea is to put an invisible link on the page and add some JavaScript (how?) to trigger click that link on page load but this is not elegant at all.


texts: Drupal 7: facebook comment for article only

texts:
I need Facebook comment for Drupal 7.

Which one can I use?

If I use above code it shows me comment of any article for all article.  I need to display comment for article.


texts: Notices and Warnings Drupal Commons 7.x 3.9 Undefined index, invalid argument, illegal string offset

texts:
I get these 7 messages every time a user goes to an event listing.
Happens in this order.  I'd like to troubleshoot and eliminate.

Notice: Undefined index: title in commons_origins_preprocess_form_content()  of profiles/commons/themes/commons/commons_origins/template.php).
Notice: Undefined index: #items in commons_events_entity_view_alter() of ….profiles/commons/modules/commons/commons_events/commons_events.module).
Warning: Invalid argument supplied for foreach() in element_children() of /includes/common.inc
Warning: Illegal string offset '#children' in drupal_render() (line 5890 ) of …includes/common.inc
Warning: Illegal string offset '#children' in drupal_render() (line 5900 ) of …includes/common.inc
Warning: Illegal string offset '#children' in drupal_render() (line 5983 ) of …includes/common.inc
Warning: Illegal string offset '#printed' in drupal_render() of /includes/common.inc).


texts: D7 - Get Path Alias (URL) from referenced Taxonomy Value

texts:
I'm trying to avoid using the PHP filter due to security concerns.

I have a CCK type I already created called Slide that I am dumping out in a view. The Block dumps out all of the items with content type Slide which are then used in a homepage slider.

Within the CCK type, I have an Entity Reference field called Prog Reference that references a taxonomy value.

What I need is the URL that is associated with that Taxonomy value so I can link up the actual slide.

They click the slide -- takes them to that taxonomy term page.

Current setup:

Referenced entity: Prog Reference -- http://d.pr/i/10bX

 Entity Reference: Prog Reference

Fields: d.pr/i/oa3z (wouldn't let me post as link)

(Taxonomy term entity referenced from field_prog_reference) Taxonomy term: Term ID
Content: Slider Image

No Taxonomy term: Path :( -- d.pr/i/FtcC (wouldn't let me post as link)

Taxonomy term: Name
  The taxonomy term name.
Taxonomy term: Programming Image
  Appears in: taxonomy_term:programming_type.
Taxonomy term: Rendered Taxonomy term
  The Taxonomy term of the current relationship rendered using a view mode.
Taxonomy term: Term description
  The description associated with a taxonomy term.
Taxonomy term: Term edit link
  Provide a simple link to edit the term.
Taxonomy term: Term ID
  The tid of a taxonomy term.
Taxonomy term: Weight
  The term weight field

Typically you would just use the Content: Path field to get the referenced entity's path, but for some reason this isn't an option Taxonomy values?

Any ideas? All help welcome!! Appreciate in advance!


texts: How does form API work for CCK (and other #after_build processes)?

texts:
When you want to hook into a CCK form and alter something, you are usually required to call a custom function from $form['#after_build'] (right?).

When doing so, I have noticed I can't write $form['field_name']['#disabled'] = TRUE; but instead I have to use the #attributes approach.

Why? Am I doing something wrong?


texts:
I installed the module "himuesgallery" in a Drupal 7 site, and created two image galleries. To display them on one page, I created a view. When I try to remove the view, the system is showing me the message: "The view has been deleted." It seems to be ok, but it isn't. The view is still there and can't be deleted.

I also flushed the cache, but nothing changed. DO you have any idea?


texts: How to make use of the render placeholder system for cacheablejsonresponse?

texts:
I have custom controllers which provide CacheableJsonResponse responses. Those responses are quite heavy to build (couple of seconds), so I want to build them better. I build those responses by getting the entity object(s), normalizing its content—referenced entities included—and putting the data directly into the response object.

My JSON responses varies by user, checks the role access, and includes some user related content (e.g. flags). I have tried to put a cache context on user (and url) on the CacheableJsonResponse, but this is not a viable way to handle cache, from my perspective; it would create a cache entry for each user and url request and would be ineffective (the cache will HIT only when the same request is asked twice or more by the same user).

Standard Drupal renderer seems to include a placeholder system which makes the majority of the page cached with proper cache context+tags, and the little parts with high-cardinality/invalidation rate rendered last out of the cache system (from my understanding) and then would be useful for my needs.

How can I easily reproduce the same system for my controllers? Is there any standard mechanism/pattern out there?

Reference: https://www.drupal.org/docs/8/api/render-api/auto-placeholdering


texts: How to create autocomplete with more than one value in Drupal 8

texts:
Im building a form with some autocomplete fields.

I need to get the values from the previous field so i can do a condition to filter values, for example

I have vehicle brand and model,  i need to show models based on brand, without using parent child just because is coming from external api, so i think it would be possible to pass the vehicule model to the brand

I have this already:

$form['cbrand'] = array(
      '#type' => 'textfield',
      '#title' => t('Select Brand'),
      '#autocomplete_route_name' => 'vehicles.brand',
      '#autocomplete_route_parameters' => array('field_name' => 'brand'),
      '#required' => true,
    );

    $form['cmodel'] = array(
      '#type' => 'textfield',
      '#title' => t('Select Model'),
      '#autocomplete_route_name' => 'vehicles.model',
      '#autocomplete_route_parameters' => array('field_name' => 'mode'),
      '#required' => true,
    );

Then i have created the controllers

example:

public function cmodel(request $request) {
    $string = $request->query->get('q');
    $matches = array();
      $query = db_select('brand', 'm')
          ->fields('m', array('cmodel'))
          ->condition('cmodel', $string . '%', 'LIKE')
          ->groupBy('cmodel')
          ->execute()
          ->fetchAll();
    foreach ($query as $row) {
        $matches[] = array('value' => $row->cmodel);
    }

    return new JsonResponse($matches);
  }

On this controller i would like to add a new condition based on first textfield.


texts: Views - D7 - Filtering by authorname only works with admin role

texts:
I've created a view which is displaying time tracking information.  Everything works great except one thing and I can't figure out what the issue is.  I have an exposed filter which filters by authorname.  The filter by default is an autocomplete text field.  When I am logged in as an admin role, the autocomplete works as it should, however when I am logged in as an authenticated user, that filter stops working.  All my other exposed filters work, except this one.  I am assuming it is a permissions issue, but I cannot for the life of me figure out what I need to enable to allow a regular user use this filter.

Any suggestions would be appreciated. I am using D7 with Views.


texts: How to update the page breadcrumb when using theme page

texts:
I have an entity form(theme page to display it) .
I have used hook_node_view() to handle breadcrumbs for nodes.
But I don't find any place to handle this $breadcrumb when I have a form and a theme page for it.

This is how I got the $breadcrumb for my news.

/**
 * Implements hook_node_view().
 */
function news_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'news' && $view_mode == 'full') {
    //BREADCRUMB ////
    $breadcrumb = array();
    $breadcrumb[] = l('Home', '<front>');
    $breadcrumb[] = l('News', 'news');
    drupal_set_title('News');
    drupal_set_breadcrumb($breadcrumb);
  }
}

I have hook functions like:

hook_init()
hook_menu()
hook_form()
hook_form_validate()
hook_form_submit()
hook_theme()
hook_preprocess_form()

But I don't find a place to work on $breadcrumb, or somehow manage it.


texts: Validate and submit function for my fom aren't working

texts:
So I'm trying to create a form with a validate and submit function, here is my code :

the form :

    function custom_form() {
      $form = array();
      $form['field1'] = array(
        '#type' => 'textfield',
        '#title' => t('Field1'),
        '#required' => TRUE
      );
      $form['field2'] = array(
        '#type' => 'textfield',
        '#title' => t('Field2'),
        '#required' => TRUE
      );
      $form['field3'] = array(
        '#type' => 'textfield',
        '#title' => t('Field3'),
        '#required' => TRUE
      );
      $form['submit'] = array(
        '#type'=>'submit',
        '#value'=>t('Submit')
      );
      return $form;
    }

the validate function :

    function custom_form_validate($form, &$form_state) {
      if(empty($form_state['values']['field1']))
        form_set_error('field1','field1 is empty.');
      else if(empty($form_state['values']['field2']))
        form_set_error('field2','field2 is empty.');
      else if(empty($form_state['values']['field3']))
         form_set_error('field3','field3 is empty.');
    }

and the submit function :

    function custom_form_submit($form, &$form_state) {
       drupal_set_message("Form has been submitted");
    }

But when I click on submit nothing appends, do I forget something ?

EDIT :
Here is all my code (I'm using shortcode module to create a custom shortcode in order to show my form)

    function custom_form_info() {
      $shortcodes['form'] = array(
        'title' => t('Link form'),
        'description' => t('A simple form.'),
        'process callback' => 'custom_shortcode_form',
      );
      return $shortcodes;
    }

    function custom_shortcode_form($attrs, $text) {
      $form = drupal_get_form('custom_form');
      $attrs = drupal_render_children($form);
      return $attrs;
    }


texts: Is it possible to get node alias during hook_node_insert()

texts:
I need to get the node alias during a hook_node_insert() when creating a brand new node. Function drupal_lookup_path() returns blank because the node actually isn't created yet per hook_node_insert() docs.

Does anyone know of a way to accomplish this or of an alternative to hook_node_insert().


texts: Is it safe to delete default image/file styles?

texts:
For consistency and usability purposes, we want to set up a default set of image styles which are clearly understood by our editors. This probably means getting rid of default style names like "medium", "large" etc.

The question is, is this likely to break other third party/contrib code that relies on the Styles module? Might we need to patch these (possibly too much of a headache) or just configure them to use the new styles?

Note: styles seem to be defined and displayed to editors purely by their (sometimes auto-capitalised) machine names, so we can't set a friendly name that differs from this.

Also: Is it even possible to remove existing styles? I can only seem to find ways/hooks to add them.


texts: Get field (list type) label in a twig template

texts:
I have a content type (appel_offre) with a field_categorie_avis field, which is a list type with these values.

ouvert | Ouvert toute l'année
restreint | Restreint 24h
concurrence | Appel public à concurrence

In the node--appel-offre.html.twig template, I want to print this field but I only get the key, not the value. For example, for Appel public à concurrence, I always get concurrence.

I am using node.field_categorie_avis.value. Is there another way to get the same value?


texts: Menu block doesn't appears where I expect it

texts:
I have this kind of menu:
"Level 1" has menu item "Level 2", which links to the page with "cat1" url. Then, I have node which have aliases "cat1/[nid]", hence, in my opinion, menu block (provided by "menu block" module) should appear. But it doesn't. Why?

If you haven't worked with menu block module and not familliar with it, then how can I force to show "Level 1 -> Level 2" menu part if a node with alias "cat1/[nid]" is loaded?


texts: What is the equivalent of theme_menu_item in Drupal 7?

texts:
I know that in drupal 6 exist: theme_menu_item, but in drupal 7 there is not. Is there any replacements so that I modify the output for main system menu ?

Actually I want to do a kind of filter of the menu items depending some criteria, which I will set in the function.


texts: Get a 404 page already when calling with trailing slash

texts:
My SEO agency complains about the following:

Let's assume the URL http://example.com/foo leads to a non-existing page. Then Drupal correctly responds with a 404.

Now,

if I call http://example.com/foo/ (with a trailing slash),
Drupal first redirects to http://example.com/foo (without trailing slash)
and only then responds with 404.

The SEO agency says that this way I loose "crawl equity".

The desired behaviour would be that

I call http://example.com/foo/
and immediately get a 404 page.

What is the best way to achieve this?


texts: How to place add to cart,quantity and attributes next to each other

texts:
The default position of the add to cart, quantity and attributes list is in a block.

Is there any way to have them next to each other horizontally. I am using Drupal 7.


texts: How do I change the value of a Hidden element?

texts:
I would like to change the value of a hidden element and, depending of this value, to show some elements in the form or not. I'm trying to implement hook_yamlform_element_info_alter(array &$elements) and I do $elements['hidden_element_name']['#value'] = 'New value of the hidden element' but it doesn't work.

Do you have any idea?


texts: My image gallery is showing the images blurry. Its using Ligthbox2. When I click on the images, they show clear in the lightbox. Is this a lightbox setting?


texts: Help to understand and fix this entity error message

texts:
I get this error message:

  Error: Notice: Undefined index: label en EntityDefaultMetadataController::bundleOptionsList() (línea 113 de/Applications/MAMP/htdocs/rooms/sites/all/modules/entity/entity.info.inc).**

The line causing the error message is contained in the following function:

 /**
   * A options list callback returning all bundles for an entity type.
   */
  public static function bundleOptionsList($name, $info) {
    if (!empty($info['parent']) && $type = $info['parent']) {
      $entity_info = $info['parent']->entityInfo();
      $options = array();
      foreach ($entity_info['bundles'] as $name => $bundle_info) {
        /* LINE 113 */ $options[$name] = $bundle_info['label']; /* LINE 113 */
      }
      return $options;
    }
  }

I don't know what other information I can include in this question because I have no idea what the cause could be. I think it is related to the Entity module because the file is inside Entity module.

Why am I getting that notice message? Is there a way to stop getting it?


texts:
In drupal 7 ,this returns the results of the view first page, if using a pager:
Is there a way to get the results depending on the page? (depending on url argument maybe?)

$result = views_get_view_result('viewname', 'displayname');


texts: In a Views page with 3 arguments, 3rd argument default PHP being ignored if 2nd argument is not present

texts:
Using Views 2, I have a View with 3 different vocabularies as arguments.

The first 2 are intended to be acquired from the URL, however the 3rd will only ever receive it's value from the Default Value PHP Code.

However if argument 2, which is optional, is not supplied, then Argument 3 is not evaluated.

SOLUTION:

Just to clarify where I landed:

The default option Action to take if argument is not present is always set to something (there is no do nothing).

It was already set to Display all values which was not working.

However Provide default argument > Fixed Entry > "all" while the argument wildcard is also "all" is allowing the 3rd argument to be evaluated.


texts: Guidance on entity reference - tokens or token parsing tools suggestions?

texts:
I have 3 content types - Organization, Site and Station. Stations related to a Site. Sites related to an Organization.  A user can update is 'location' to show where they are working that day.
I use a token to show the user's current 'location'. I can't seem to parse the location to reflect the Organization relationship.
EG; user is at gate 1. Gate 1 is part of site 'Campus'.  Campus is part of site 'UC Berkeley'.
I get perfect results for Site : [current-user:field_current_location:entity:field_reference_location]
and I get perfect results for Station: [current-user:field_current_location]
but I can't get the correct token to show the current related Organization.
My latest attempt was : [current-user:field_current_location:entity:field_reference_organization:entity]
Suggestions? is there a token parse module that shows values realtime I can rely on?


texts: How to install new drupal packages on local apache server

texts:
I have a drupal site set up on a local mysql and a local apache server. I am trying to install a new module the problem is it brings me to the login for server ftp. I'm not sure what credentials it wants or how to do it exactly is there some way to enable apache ftp or what am I supppsed to be doing.

Thank you for any help.


texts: Incorporating Google Groups code into a block

texts:
The following code is given by Google groups to embed a forum into a webpage. I'm wondering what the best way to add this to a block is?

<iframe id="forum_embed"
 src="javascript:void(0)"
 scrolling="no"
 frameborder="0"
 width="900"
 height="700">
</iframe>

<script type="text/javascript">
 document.getElementById("forum_embed").src =
 "https://groups.google.com/forum/embed/?place=forum/forum-name" +
 "&showsearch=true&showpopout=true&parenturl=" +
 encodeURIComponent(window.location.href);
</script>


texts: I can't translate the text  in a form select list

texts:
I just can't translate the text  in a form select list.
I need it to be translated in spanish lang.
I tried to translate it using the translate interface but I couldn't find it.
Please take a look a the capture:


texts:
I came across this. That shows how you can get a code like {{ cta }} populated with any data you want, and get that inserted in a template. I want the same sort of solution, but for content. In other words, let's say I have a blog post, I want to be able to add:

{{ cta }}

or

[[ cta ]]

or any convention that works. But the end result is that I must be able to populate the variable via code.

BACKGROUND INFO

I have a bunch of events on my website. I often write blog posts where I refer to events on the site. To add dynamic content to my blog posts, I'd love to simply add things like:

{{ events || from:19dec2014 || to: 23dec2018 }}

I would then populate these with the correct information.

Any ideas on how to do this correctly?


texts:
I have created one group using the Group module, then I added some members in that group. Now I want to get list of all members in the group from some custom code.

How do I get the list of all group members?


texts:
Does anybody know where/how to change the pathauto-URL of a node (that comes out of the db table "url_alias")?

Background (Example):

I have a page with list of nodes (A, B, C)

A -> links to "clean-URL/A.html"
B -> links to "clean-URL/B.html"
C -> should not link to "clean-URL/C.html" but to "clean-URL/A.html" (C has a field that says it should link to A)

So, I want that everywhere there is a link to C, the link should be changed to A. For example in search results or in views.

Unfortunately I can't find a pathauto hook that does something like "render_pathauto_link_of_node"...


texts: How to dynamically make a field visible?

texts:
I'm trying to render a field based on a select value. However I couldn't succeed for now, so here is what I tried:

I created a content type with a select field (field_type)

var_dump($form['field_type']['und']['#options']);

gives

array (size=5)
  '_none' => string '- Select a value -' (length=18)
  'externe' => string 'externe' (length=7)
  'interne' => string 'interne' (length=7)
  'carroussel' => string 'carroussel' (length=10)
  'vitrine' => string 'vitrine' (length=7)

I noticed 'und' by printing my field and reading the first comment on this page
Drupal process states 7.x

and my field that should be visible (or not)

$form['field_target_text'] = array(
        '#type' => 'textfield',
        '#default_value' => '',
        '#states' => array(
          'visible' => array(
            'input[name="field_type[und]"' => array('value'=>'interne')
          ),
        ),
      );

I tried to replace input with select, to remove [und] but nothing did the job until I replaced the field like this

$form['field_type'] = [
        '#type' => 'select',
        '#title' => ('TYPE TPE'),
        '#description' => ('TEST.'),
        '#options' => $form['field_type']['und']['#options']
      ];

Seems like he doesn't like my field not having an ['#options'] but ['und']['#options']. However by doing so, when I save my node, the field_type is empty.

Any help or advise would be appreciated.


texts: Should I choose MyISAM for notification tables?

texts:
Using Drupal6 with a MariaDB 10 InnoDB engine for all tables, I have noticed that insert queries into notifications_* tables are very inefficient on InnoDB tables. For example, these frequently in my slow_query_log:

INSERT INTO notifications_event (module, type, action, oid, uid, params, created, counter)
VALUES ('XXX', 'XXX', 'XXX', XXX, XXX, 'XXX', XXX, XXX);

INSERT INTO notifications_fields (sid, field, value, intval)
VALUES(XXX, 'XXX', 'XXX', XXX);

QUESTIONS

Would be a good idea to convert such tables into MyISAM?
Any downside for using such mix of storage engines?
Is there a better solution to shorten the insert time?


texts: In the Encrypt module, can I switch between phpseclib and mcrypt assuming I keep the Key Provider Settings in place?

texts:
A client uses the encrypt module as the basis to encrypt some database cells. The current server is RHEL 6/PHP 5.3. They're upgrading to RHEL 7 but will push to PHP 5.6.

The Encrypt module asks for either a method:

PHP Secure Communications Library (phpseclib)
Mcrypt AES (CBC Mode)
None

Currently the client had the second choice selected. However, the php-mcrypt package doesn't exist in PHP 5.6, and from my understanding, it itself hasn't been updated in a while. The alternative of installing the Libraries Module and cloning down a copy of phpseclib from git clone https://github.com/phpseclib/phpseclib.git seems more palatable at the moment.

Question: can I switch out to using phpseclib assuming I keep the Key Provider Settings in place?


texts: How to reset/save $_SESSION variables in forms for each user?

texts:
I need to add captcha to user login form after 3 failed logins.

To do so I built the following module, and used $_SESSION['failed_login'] to keep track of the number of the failed logins.

This module works well, but when I close the browser and test a failed login again, the number that is stored via watchdog will not reset again from 1, it continues increasingly.

<?php

function failed_login_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'user_login') {
        $form['#validate'][] = 'failed_login_myloginhandler';
    }
}

function failed_login_myloginhandler(&$form, &$form_state) {
    global $user;
    if (!$user->uid) {
        if(!$_SESSION['failed_login'])
            $_SESSION['failed_login'] = 0;
        $_SESSION['failed_login']++;
        watchdog("error", $_SESSION['failed_login']);
    }
}

What is the problem? Why it is not reset from 1 again? How can I have this temporary variable for each user who is trying to login?


texts: What's $mask in file_scan_directory() to find all png files?

texts:
I try to find all png files in a directory inside my module using this code with no success:

$banks = file_scan_directory(drupal_get_path('module', 'order').'/images/gateways', '/^.*\png$/');

What mask should I used for getting all png files?


texts: How do I create a comment programmatically in drupal 6?

texts:
I have a comment form which gets rendered below the content type on content page. I have a comment form and comments being rendered as well. Now the question is that I have a custom form that takes some text and I need to save this to content type's comments.

How can I do this? I have tried comment_save($comment) and it simply breaks my redirection and also the comments are not getting saved.

Here is what I have tried.

function quiz_commenting_form_submit($form, &$form_state) {
global $user;

$data = $form_state['values']['qcomment'];
$qnid = $form_state['values']['qnid'];
$form_state['redirect'] = 'some-url'; // hardcoding this untill i get url for quiz in form

// Let's create a managed object
$comment = new stdClass(); // We create a new comment object
$comment->nid = $qnid; // nid of a node you want to attach a comment to
$comment->cid = 0; // leave it as is
$comment->pid = 0; // parent comment id, 0 if none
$comment->uid = $user->uid; // user's id, who left the comment
$comment->mail = $user->email; // user's email
//$comment->name = 'User name'; // If user is authenticated you can omit this field, it will be auto-populated, if the user is anonymous and you want to name him somehow, input his name here
//$comment->thread = '01/'; // OPTIONAL. If you need comments to be threaded you can fill this value. Otherwise omit it.
//$comment->hostname = '127.0.01' // OPTIONAL. You can log poster's ip here
//$comment->created = time(); // OPTIONAL. You can set any time you want here. Useful for backdated comments creation.
$comment->is_anonymous = 0; // leave it as is
//$comment->homepage = ''; // you can add homepage URL here
$comment->status = COMMENT_PUBLISHED; // We auto-publish this comment
$comment->language = LANGUAGE_NONE; // The same as for a node
//$comment->subject = 'Comment subject';
$comment->body['und'][0]['value'] = $data; // Everything here is pretty much like with a node

comment_form_submit($comment); // saving a comment
comment_save($comment);
}


texts: How can I featurise / store changes to a view provided by a module?

texts:
In my case, Workbench and Workbench Moderation. Workbench Moderation gives me a "My Drafts" and "Needs review" view which I can edit to my taste, but I can't see a way of featurising the view or preserving my modifications in some way.

Is there an approach for this?


texts: How to trim the beginning of a field (reverse trim)?

texts: In Views and several field formatting modules you are given the ability to trim the end of text fields to show for example only the first 100 characters. However what if I want to do the reverse. What if I want to trim a field to not show the first 100 characters but to show everything else, how could I do this?


texts: What is faster: hook_form_alter or hook_form_FORM_ID_alter?

texts:
I want my Drupal site be as fast as it can.
So I'm considering whether to use hook_form_alter with an if statement inside or hook_form_FORM_ID_alter.
I know that it's a bit more convenient to use the latter but I'd prefer to use the faster method.

Does somebody know which is faster and how much? And I don't only mean form_alter, but all hooks with an ID in it.


texts: Accessing Content: Path field within views_view_unformatted TWIG template

texts:
I have a view that has the fields: Content: ID, Content: Title and Content: Path.

In my views-view-module.html.twig file I can access the fields via the following:

{{ item['#row']._entity.id }}

{{ item['#row']._entity.title[0].value }}

But I cannot seem to retrieve the path field using:

{{ item['#row']._entity.path[0].value }}

Do I do this the same way or am I missing a trick?
I've tried to use dump/kint but I keep getting the WSOD.

Can anyone offer me a solution?

Thanks in advance


texts:
I have a maintenance site problem. I can't go to the login page.

I tested in my localhost in maintenance and I could log in on /user.

I copied file system and database online but here I can't access the login page so I can not see the site to make changes and upload data.

This is the site:
redlily.it/

I have displayed the $content variable in a div.content with display:none style. But in '?q=user' and in '/user' i have no loggin form.

Why am I not seeing the log in form under '?q=user' and '/user'?


texts: recaptcha_v3 actions can be tracked in feature?

texts: I using the recaptcha_v3 module in Drupal 7, is there are anyway we can track the actions we are adding part of the feature or it should be added through the hook_update_N() when we push from one environment to another?


texts: what's are these "@name" and "@site-name" token-things in email_example.module and how do they work?

texts:
In the dgo.to/example module's email_example.module's hook_mail() function there's this line:

      $message['body'][] = t('@name sent you the following message:', array('@name' => $user->name), $options);

I haven't seen @thing used that way before?  How does that work?  What convention is that?


texts: I'm using Display Suite to create custom multiple layouts for content. Is it possible to do something similar to the node/add/mycontent page? I want to be do show/hide and organize fields on the edit and add pages.


texts:
I'm using D7 and module Views Accordion (V 7.x-1.1) for my view. I've created my custom template (e.g views-view-accordion--[name of my view].tpl.php) for customize my view. However, when I want to add some variables in preprocess function, I created the function mytheme_preprocess_views_view__[name of my view](&$vars), I cannot get into this function.

Am I doing something wrong? Thanks in advance.


texts:
I am trying to update drupal. I want to break the updates into 2 different runs/groups. I want run the second batch of updates after the first is done.
The first batch contains the updates from the drupal update and the second should contain the custom ones.
Is this possible in any way?


texts: WSOD for logged users after upgrading some module

texts:
I have updated the following modules on my website:

ctools
context
devel
ds
libraries
metatag
pathologic
rel_to_abs
variable
webform

After the upgrade whenever I log in, I am not able to access any page (not just the administration area).
Anonymous users have no problems.
Downloding the whole website and installing it locally with the backup before the update, everything works fine.
I have enabled debug logs and all possibile error reporting options, but I have no error or warning of any kind.
I have increased the memory limit, clean every cache and run the registry rebuild via php.
I have no ssh access to the host, so I cannot run any remote debugging.
Can someone point me out to a possibile solution?


texts:
I have the following query:

$query = "SELECT *
      FROM mytable
      {$typeClause}
      HAVING distance <= {$radius}
      ORDER BY distance ASC"
      GROUP BY type;

    $result = db_query($query);
    $points = array();

    while(($point = $result->fetchAssoc()) != null){
    }

In my db there is field 'type' which is a number
How can I get all records as an array without using the while statement above (something like fetchByGroup):

array(
        '1' => array( [all records of type=1] ),
        '2' => array( [all records of type=2] ),
        ......................................
    );


texts: Can I publish something in my wall of facebook?

texts:
I need to publish something in the user's facebook wall, when you entered the site, automatically.

This is the code that I actually use.

function publish(){
    global $user;
    $attachment = array(
            'name' => 'Name app',
            'href' => url('http://....', array('absolute' => TRUE)),
            'description' => 'Use this application.',
          );

    $user_message = t('Check out the latest application on !site...', array('!site' => t('My Drupal for Facebook powered site')));

    $actions = array();

    $actions[] = array('text' => t('Read More'),
                       'href' => url('http://....', array('absolute' => TRUE)),
                      );

    fb_stream_publish_dialog(array('user_message' => $user_message,
                                  'attachment' => $attachment,
                                   'action_links' => $actions,
                            ));
}

This code work, but it publish again the text when I edit the page, or I go to a different page.

Is there a module (for publish), or another way to do this?


texts: Is it possible to include HTML embeds like Twitter on the WYSIWYG section of the CKEditor in D7?

texts:
I have staff writers who want to include embedded tweets in their articles. However, they don't know HTML and aren't able to use the "source" section of the editor.

Is there a way to embed the HTML inside the WYSIWYG side? Something like:

Regular text and photos

{{copied twitter embed code}}

More regular text and photos

...is what I'm looking to provide them. They're able to copy and paste the code as above, their struggle is finding the correct spot in the "source" section.


texts:
I have a list of all nodes (in my specific case Product Display, generated in Commerce kickstart) using a view. Is there a quick way I can have an unpublish/publish option right there in the view results list? I'd like to avoid the following everytime I need to perform this operation.

browsing to Node/Edit
selecting the publish options tab
(un)ticking Published
hitting Save

Does anyone know of a simple way?


texts:
I have an unlimited-cardinality text field on a node that users need to enter 50-100 values on.  Right now, the user has to type in one value, click "add another item", and then click inside the text field to start the process again.

Is there a module or a way to enable them to simply hit "Enter" after entering the first item, that will automatically open the next text entry area and move the cursor inside it?


texts:
I am looking to programmatically get the aggregated url that I can use to pre-load on a different page. Is there a method I can use in Drupal 8 to do this?

this url usually looks like:

/sites/mytheme/files/css/css_On6fV7UTH_kMXvRAnOzTBfjow6RM77BJcrP4tbb-KoQ.css?t0uY2i


texts: hook_field_extra_fields on node types stored in variable

texts:
I am developing a module. It adds a button to certain content types:

function mymodule_node_view($node, $view_mode, $langcode) {
  ....
  $node->content['mymodule_button'] = drupal_get_form(....);
}

I give the option to configure what content types must have this button:

function mymodule_admin_settings() {
  ....
  $form['mymodule_node_types'] = array(
    '#type' => 'checkboxes',
    '#options' => $options, //node types
    '#default_value' => variable_get('mymodule_node_types', array()),
    .....
  )
  return system_settings_form($form);
}

I want to configure the weight of the button through the 'manage display' page of each content type. For that I use the hook_field_extra_fields() implementation:

function mymodule_field_extra_fields() {
  $extra_fields=array();
  $mymodule_types = variable_get('mymodule_node_types', array());
  .....
  $display_elements['mymodule_button'] = array(
     ...
    'weight' => 0,
  );
  foreach ($mymodule_types as $type) {
    $extra_fields['node'][$type]['display'] = $display_elements;
  }
  return $extra_fields;
}

I need when the admin changes the content types in the configuration page, the 'extra fields' will be shown only in the content types selected, not in the other ones. This function is not working this way with this code.


texts: Tax rate select missing from product price in commerce 8

texts:
I installed drupal commerce 8 rc2 and created a tax type of "European Union VAT".
When I create a new product, near the price field, I can't find the tax rate select.

How can I associate 10% or 22% vat rate to the price of product?


texts:
I have created a content type in which I have a field as field_result of type select list with options as;

pass
fail
hold
postpone

When user selects the pass from select list and update or create a content, email should be sent to all admin users and other users stating that result is pass. Following same thing to other select list options ie for fail,hold and postpone. So what exactly I need to do using rules?

Here event can be both like; user can save the new content also can update using this select list field. Whenever user selects, it should send an email according to corresponding select list option.

Can anyone help me please? I will be thankful to you. My problem is similar to sending mail after checking a selected list in field but it didn't work for me.


texts: How to fix “Cannot read property 'icons' of null” error?

texts:
First of all, I'd like to mention this answer is not related, I'm using Drupal 8.6.1.

I'm trying to create a CKEditor plugin with a new button. In the /admin/config/content page I get the error but the button appears well:

However when I go to /node/add/article page, I get the error and there is a display issue on CKEditor windows:

Clearing the cache does not change anything.
The error does not appear anymore when I uninstall my custom D8 module.

modules/custom/inline_comment/js/plugins/inline_comment/plugin.js

CKEDITOR.plugins.add('comment', {

    icons: 'comment',

    // The plugin initialization logic goes inside this method.
    init: function (editor) {
        // Define the editor command that add a comment.
        editor.addCommand('comment', {
            // Define the function that will be fired when the command is executed.
            exec: function (editor) {
                ...
            }
        });

        // Create the toolbar button that executes the above command.
        editor.ui.addButton('Comment', {
            label: 'Add comment',
            command: 'comment',
            toolbar: 'insert'
        });

modules/custom/inline_comment/src/Plugin/CKEditorPlugin/InlineComment.php

namespace Drupal\inline_comment\Plugin\CKEditorPlugin;

use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\editor\Entity\Editor;

/**
 * Defines the "inline_comment" plugin.
 *
 * @CKEditorPlugin(
 *   id = "inline_comment",
 *   label = @Translation("CKEditor Inline Comment")
 * )
 */
class InlineComment extends CKEditorPluginBase implements CKEditorPluginConfigurableInterface {

  public function getFile() {
    return drupal_get_path('module', 'inline_comment') . '/js/plugins/inline_comment/plugin.js';
  }

  public function getButtons() {
    return [
      'Comment' => [
        'label' => t('Linkit'),
        'image' => drupal_get_path('module', 'inline_comment') . '/js/plugins/inline_comment/icons/comment.png',
      ],
    ];
  }

The location of the icon is: modules/custom/inline_comment/js/plugins/inline_comment/icons/comment.png


texts: Bulk opening of several node edit screens

texts:
is there a way to open up several nodes to edit at once? At /admin/content I can mark all of the nodes that I want to edit, but I still have to click each edit link individually.

Is this something that I could do by adding an action to the "Update Options" dropdown?

Edit
The reason for the mass editing is that I have added a new field to a content type. I would like to add unique values to that field for preexisting nodes.


texts:
I have a content type with multiple fields. Some of the fields are accessible to everyone and there are other fields for which the access is controlled.

Example: There is a content type called Reports with fields like title, summary, body etc. Title and summary should be visible to everyone but the access to body field is controlled.

For implementing this I need to have 2 view modes. one of them will have the fields title and summary displayed with the rest of the fields hidden. The other view mode will have only the body field visible. I am planning to implement the hook hook_node_access to derive the access permissions for the node. So how can I get the view mode in this hook so that I can have my access check based on the view mode.