texts: Add trailing slash to taxonomy term. Issue with relative URL

texts:
We were trying to create relative links by using href="Link" or href="./Link"

This works on all browsers, but in Drupal we are running into a problem becasue Drupal removes trailing slash from existing URL.

For example if we are at page or taxonomy term page

domain.com/term1/child1A

and in there have a link such as a href="Link" it will point to domain.com/term1/Link

becasue child1A does not have a trailing slash.

Is there any way to fix this issue. Technically we are not trying to add trailing slashes to all url. Tried setting base URL but that didn't work either. Or maybe I did something wrong.

Any suggestions on a workaround?

Drupal 8.4


texts: WebForm images not displayed after node creation with submission handler

texts:
I'm at a loss.

I'm using WebForm 8.x-5.2 on Drupal 8.7.3. I have a custom webform handler that takes the submission and creates an unpublished node for review. The webform includes an image field that saves one or more images submitted through the form in the Private Files area as suggested.

Everything in my submission handler works as expected except for the images. Upon viewing the page created by the handler, the images are not displayed. The images are there. If you simply edit the node in the UI and save it, the images show up. I've tried a bunch of things, without success...

Saving files to the public files directory
Adding code to the handler to save the node a second time
Adding code to the handler to make a change to the Title field after saving and then saving again.

Inspecting the node with Devel before and after the manual edit/save shows no difference that I can see. Here's the relevant code snippets...

$values = $webform_submission->getData();
if (!$webform_submission->isDraft()) {
  $node = Node::create([
  ...
  'field_image' => $values['image'],
  ...
 ]);
 ...
$node->save();

My submission handler is setting taxonomy terms, multiple fields, URLs, and everything is working except for the images. What am I missing?


texts: PHP query in a view will cause website error

texts:
I'm using a global PHP query in a View to find out the count of membership users.
The first query, that extracts the total number of users from the database works fine, but when I use the WHERE clause in a query for a comparison with a string, I received a website error like in the image attached below.

This is the query:

<?php
$count_users_premium = db_query('SELECT COUNT(license_id) FROM {commerce_license} WHERE state="active"')->fetchField();
print $count_users_premium;
?>

So, if I want to use WHERE some_number=3, it will work, but comparison with a string didn't work. (Drupal 8 version)


texts: How to extend/override Rest EntityResource Plugin in Drupal 8

texts: I would like to extend/override the Rest EntityResource Plugin in Drupal 8.  I have read everything I can find online and I can see how to create a resource plugin for something other than an Entity (such as dblog).  However, I can't figure out how to extend/override the existing Entity resource plugin.


texts:
I'm upgrading my site from D6 to D7, and want to move a section of the site to a better spot. That requires about 10000 redirects. (I use redirect module: https://drupal.org/project/redirect ).

With D7, the redirect table includes a hash ("hash - A unique hash based on source, source_options, and language."). How can I build that, using PHP? I have a textfile with node/# and the old URLs. I can make them into a mysql table.

But while I can do basic PHP, I'm not advanced enough to understand the redirect.module source. The relevant bits are, I understand, lines 399-403:

$redirect->source = $path['original']['alias'];
$redirect->redirect = $path['source'];
$redirect->language = $path['original']['language'];
// Check if the redirect exists before saving.
$hash = redirect_hash($redirect);`

and lines 1069-1081:

function redirect_hash($redirect) {
  $hash = array(
    source' => $redirect->source,
    language' => $redirect->language,
  );
  if (!empty($redirect->source_options['query'])) {
    $hash['source_query'] = $redirect->source_options['query'];
  }
  drupal_alter('redirect_hash', $hash, $redirect);
  redirect_sort_recursive($hash, 'ksort');
  $redirect->hash = drupal_hash_base64(serialize($hash));
  return $redirect->hash;
}

Thanks!


texts: Why do I get a Drupal\Core\DependencyInjection\ContainerNotInitializedException exception error?

texts:
I am using Drupal 8.1.3, Drush 8.1.7, and PHP 5.6.2 on a Mac OS X.

I've installed a fresh Drupal 8 site demo from Zircon on a local MAMP stack. When I try to run watchdog show, and some other commands, I get the following error:

  Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in Drupal::getContainer() (line 129 of /Applications/MAMP/htdocs/example/docroot/core/lib/Drupal.php).

I was able to run the following commands successfully:

drush cr
drush version
drush status

I've just updated to latest version of drush, but this is my first time seeing this error.

Also, drush pm-update returns:

  Command pm-update needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.

Edit/Update:

Here is the output of drush status:

Drupal version         :  8.1.3
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  localhost
 Database port          :  3306
 Database username      :  ******
 Database name          :  ******
 PHP configuration      :  /Applications/MAMP/bin/php/php5.6.2/conf/php.ini
 PHP OS                 :  Darwin
 Drush script           :  /usr/local/bin/drush
 Drush version          :  8.1.7
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /Applications/MAMP/htdocs/example/docroot
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default
 Sync config path       :  sites/default/files/config_pHswhbzOqqMuWn7c6kYMbap6DKcyXxItrvbtsCQeJYoQ04xTi19pOZywbF8KZ8Wrx43VrLsVMw/sync

The user interface does work.

Update: I checked some of my other projects (Drupal 7 and 8 sites), for which drush worked perfectly fine on, and they are throwing errors with the same Drush command, which tells me it's probably not a Drupal 8 problem but probably due to changes I made on my dev platform. I had installed Composer and upgraded Drush, and other related changes.


texts: How to render entity referenced nodes field inside node.tpl.php?

texts:
I have 2 content types: book and author.
This is the structure:

I want to use (print) some fields of author content type inside the node-book-tpl.php.
How can I do that? Is there a method to print referenced entity's fields like <?php print render($content['field_author']); ?> etc.?
Note: I tried the Inline Entity Display module but because I want to do this with custom node-book.tpl.php it doesn't work for me.


texts: Showing more detailed error messages to user

texts:
im making an app with titanium that connects to a drupal backend. im using the awesome library (https://github.com/jbeuckm/drupal-client).

how can i show more detailed error messages (e.g. email/username has already been taken)?

i only get a 406 error code in ios when i register a new user that has already been registered.

error: {"success":false,"code":406,"source":{"url":"http://domain/user/register.json","method":"POST","ondatastream":null},"type":"error","error":"HTTP error"}

i noticed that when i connect with android there are more detailed messages available (e.source.statusText for instance).

any ideas?

update:

in android i get the information that i would need (statusText). why cant i access it in ios?

error: {"code":-1,"source":{"autoRedirect":true,"status":406,"allResponseHeaders":"Date:Mon, 13 Jul 2015 10:09:47 GMT\nServer:Apache/2.2.15 (Red Hat)\nExpires:Sun, 19 Nov 1978 05:00:00 GMT\nCache-Control:no-cache, must-revalidate, post-check=0, pre-check=0\nContent-Length:259\nContent-Type:application/json\nKeep-Alive:timeout=15, max=100\nConnection:Keep-Alive\n","connected":false,"password":null,"validatesSecureCertificate":false,"tlsVersion":0,"responseText":"{\"form_errors\":{\"name\":\"The name editor83 is already taken.\",\"mail\":\"The e-mail address editor83@vodes.net is already registered. Have you forgotten your password?\"}}","username":null,"responseXML":null,"statusText":"Not Acceptable : The name editor83 is already taken. The e-mail address editor83@vodes.net is already registered. Have you forgotten your password?","apiName":"Ti.Network.HTTPClient","location":"http://editors-testdrupal.rhcloud.com/rest/v1/user/register.json","readyState":3,"domain":null,"responseData":{"height":0,"bubbleParent":true,"type":2,"mimeType":"application/json","apiName":"Ti.Blob","nativePath":null,"file":null,"text":null,"length":259,"width":0},"connectionType":"POST","autoEncodeUrl":true,"bubbleParent":true,"_events":{"disposehandle":{}}},"error":"Not Acceptable : The name editor83 is already taken. The e-mail address editor83@vodes.net is already registered. Have you forgotten your password?","success":false}
[INFO] :   ALERT: (KrollRuntimeThread) [47,17536] Not Acceptable : The name editor83 is already taken. The e-mail address editor83@vodes.net is already registered. Have you forgotten your password?
[INFO] :   [object Object]account was not created

update 2:

it seems to be more of a ecplise/android/ios issue, so ive posted the question on the main forum.

https://stackoverflow.com/questions/31381522/different-rest-object-output-in-android-and-ios

if i get an answer ill post it here as well.


texts: How do I stringify objects or at least get a string value?

texts:
The item.content for my field item is 'active'. However, when I use a comparison operator as seen below, it never equates to True but always False. I thought maybe some spacing issues was the reason, but that seems to not be the case.

Is the content in item.content not a string? I am assuming when I call item.content, its probably a object, but I can't find any documentation on how to turn a object's value into a string so it equates to true.

{% for item in items %}
  {% if item.content == 'active' %}

{{ item.content }}

  {% else %}

{{ item.content }}

  {% endif %}
{% endfor %}


texts: How to loop through a dynamic taxonomy vocabulary and if term is chosen, do an action?

texts:
My problem is as follows:

I have a taxonomy vocabulary with terms, which are changing from time to time.
I have two node types --> type 1 and type 2
Type 1  has a taxonomy term reference field
Type 2 has an entity reference field which can be prepopulated with the module "entity reference prepopulate"

If I create a new node of node type type 1 then a rule should check which terms are selected and create a new node of type 2 for each selected term automatically.

The entity reference field of the new type 2 node should be prepopulated with a reference back to the original type 1 node.

Because the terms of the vocabulary are changing, the check up by the rule should be IMHO dynamic.

Dummy-Code:

If a new node of node type 1 is saved,then check which taxonomy terms are selected.

for each selected term:

create a new node of type 2
and prepopulate the entity reference field of node type 2 with the value of node type 1.

I tried it with the Conditional Rules module, but there seems no for..each control loop available.

How can I solve my problem?


texts: Getting book pages in same level like getting child pages

texts:
I have a book called courses with several subpages, I want to show the list of ot other subpages when one subpage is open.

Example:

-Courses
---Course1
---Course2
---Course3
---course4

I want to show course1, course2 & course3 when course4 is open. I know to get childpages, but have no idea how to get pages in same level. I am using Drupal 7.


texts:
I'm trying to get the full CKEditor working in Drupal 8, but I only see the standard toolbar. I've downloaded the full zip file and unzipped it into core/modules/ckeditor, uninstalled/reinstalled ckeditor but still it's the standard toolbar.

How do I enable the full toolbar?


texts:
I know how add fields to entity, now what is XXX in below code when I want add this field to comment of articles?

$instance = array(
    'field_name' => 'field_image',
    'entity_type' => 'xxx',
    'bundle' => 'xxx',
    'label' => t('Images'),
    ....

if any other setting is required, then what is that?


texts: When I hover over a block on the front end, I get the Contextual Links popup to edit the block.  Can I also set this so when someone with permissions to do so hovers over a node, they get a link popup to edit that story?


texts: What's the best file permission to drupal's files and directories?

texts:
Possible Duplicate:
  What are the recommended directory permissions?

I want to know what's the best file permission under a linux system to my drupal's files and directories including the files directory and the core either.
Thank you very much


texts: Sanitizing User Input using Form API - Creating Nodes

texts:
I'm using D7 Form API to make some custom forms for users that create nodes on submit (using node_submit & node_save functions). This is an example form I'm using:

function create_article_form($form, &$form_state) {

$form['node_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Node Title'),
    '#size' => 20,
    '#required' => TRUE,
 );

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

return $form;
}

This works great, but I'm just wondering about sanitization. From my research it seems like the check_plain() function should be used for text fields for security. However, it also causes raw HTML entities to be saved.

For example, I am setting the node title in the submit function like this:

$node->title = check_plain($form_state['values']['node_title']);

This problem is, if the user enters something like this:

Mike's Tacos

it gets saved in the node title like this:

Mike&#39;s Tacos

So if I output that title anywhere (in a view, in a custom node--XX.tlp.php, etc, it shows in this way.

Can anyone help with how to still use check_plain (or whatever function will provide the best security) but have the value saved with the human-readable format (Mike's Tacos)?


texts:
I am having problems getting a pager to display after a table in the block_view hook of a module

The code for the query is the following one.

$query = db_select('registry', 'r');
$query = $query->extend('PagerDefault')->extend('TableSort');

$query->limit(10)
    ->fields('r', array('name', 'type', 'filename','module','weight'));
$result = $query->execute();

I build and the table with no problem adding it to the content

Then I add the pager or rather I don't with the following code

$block['content'] .= theme('pager').'
mmm
';

the mmm bit was just there as a quick check to see what was happening.

I know that the extend needs to be assigned to a new variable and I believe that I am doing this.

Is there anything wrong I am doing?

This is the complete code of the module.

/**
 * @file
 * A block module that displays registry info.
 */

/**
 * Implements hook_help.
 *
 * Displays help and module information.
 *
 * @param path
 *   Which path of the site we're using to display help
 * @param arg
 *   Array that holds the current path as returned from arg() function
 */
function current_posts_help($path, $arg) {
  switch ($path) {
    case "admin/help#current_posts":
    return '
' . t("Displays registry info for testing tables and pager") . '
';
    break;
  }
}

/**
 * Implements hook_block_info().
 */
function current_posts_block_info() {
  $blocks['current_posts'] = array(
    'info' => t('Current posts'), //The name that will appear in the block list.
    'cache' => DRUPAL_CACHE_PER_ROLE, //Default
  );
  return $blocks;
}

function current_posts_block_view($delta = '') {
  switch($delta) {
    case 'current_posts':
      $block['subject'] = t('Modules list');
      if(user_access('access content')) {
        $query = db_select('registry', 'r');
        $query = $query->extend('PagerDefault');
        //$result = $query->limit(50)
        $query->limit(10)
          ->fields('r', array('name', 'type', 'filename','module','weight'));
        $result = $query->execute();

        // Array to contain items for the block to render.

        $rows = array();

        // Iterate over the resultset.
        foreach ($result as $node) {
          $rows[] = array(
            'name' => t($node->name),
            'type' => t($node->type),
            'filename' => t($node->filename),
            'module' => t($node->filename),
          );
        }

        // Table header.
        $header = array(
          'name' => t('Name'),
          'type'     => t('Type'),
          'filename'    => t('Filename'),
          'module'    => t('Module'),
        );

        $block['content'] = theme('table', array(
          'header'  => $header,
          'rows'    => $rows,
          'id'      => 'table-articles',
          'class'   => 'articles',)
        );

        $block['content'] .= theme('pager').'
mmm
';
      }

      return $block;
  }
}

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

  $items['admin/config/content/current_posts'] = array(
    'title' => 'Current Registry',
    'description' => 'Configuration for Current posts module',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('current_posts_form'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

/**
 * Page callback: Current posts settings
 *
 * @see current_posts_menu()
 */
function current_posts_form($form, &$form_state) {
  $form['current_posts_max'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum number of posts'),
    '#default_value' => variable_get('current_posts_max', 3),
    '#size' => 2,
    '#maxlength' => 2,
    '#description' => t('The maximum number of links to display in the block.'),
    '#required' => TRUE,
  );

  return system_settings_form($form);
}


texts: Fully display only most recent post on front page, furl the others

texts:
Currently my Front page will only show a teaser for all my new posts.

I know that I can go to Structure > Views > Frontpage and change it to show Content | Full which will show the full post of every post on the front page.

What I would like to do though is show the full post of only my most recent post, and then a teaser of all the others.

Is it possible to do this?


texts:
I need to execute a few lines of PHP code before a page is rendered.
Basically what I need to do is to store in a database the user's original http_referer together with an anonymous visitID, and save this visitID in a session.
So the code i need to execute is something like this:

if(!isset($_SESSION['lock'])) { // we only want this to run when the user enters the site, not on subsequent pages
   $_SESSION['lock'] = true;
   save_http_referer_in_database();
   $_SESSION['visitID'] = mysql_insert_id(); // gets the id of the last inserted row
}

I've found a few solutions but not very convincing.
UPDATE 16th Oct: I'm making a short summary here as I've edited this post many many times.

First, I tried putting the required code at the top of html.tpl.php... it works, but stops running if i enable caching. Not good. I don't want to disable caching.
I tried putting the code in the settings.php and index.php, but drupal's session aren't initialized yet in there.
As suggested here, I've tried creating a custom module implementing hook_boot, but this solution has weird problems when caching is enabled.
What happens is that the save_http_referer_in_database() function correctly runs the first time, but when the user loads another page, it runs again! All the subsequent page loads don't trigger it again though.
This post has some more informations about it.
This bug report on Drupal.org shows some other bad things that happen with sessions and caching and hook_boot()
SOLUTION: Use cookies instead of sessions.

Regarding @znerol's answer:

I wouldn't have DB problems anyway because i save visitID and referer in another database, so i manually db_connect() to my database and manually run mysql_query(). Hopefully it's not a bad thing.
How could exposing the visitID to the user create problems? The visitID is a completely anonymous ID, generated by MySql as the Auto Increment column of the table containing the http_referers. I can't imagine how someone could use this ID to do something 'bad'.
The reason why I want to do it inside my application, is that I need the visitID to "connect" certain actions on my site to the http_referer (through the visit_id foreign key). So basically i have a structure like this:

VISITS (visitID, http_referer)
EVENTS (eventID, event_description, fk_visitID)

When an event is triggered, I add it to the database by fetching the fk_visitID from the cookie (or session)

I couldn't find a way to accomplish that through AWSTATS (which is installed) or Google Analytics or other similar software.

I didn't know Piwik but thanks to the API it might be fine for what I need, right?


texts: What is the correct way to implement a custom block with twig template?

texts:
I know there are tons of posts for this but I think I have a problem with understanding how a custom block with a custom template is meant to work in Drupal 8.
Problem
My aim:
To place a custom block to display social icons. The block needs some logic (generate a url for example).
My main problem:
Everything seems to work so far but I do not get the variables passed through the twig-template (url and urlencode). They always contain the default value from the module-file (null).
What I have so far:
Files under /modules/custom/wzm_social_icons:

wzm_social_icons.info.yml
wzm_social_icons.module
src/Plugin/Block/WzmSocialIconsBlock.php
templates/block--wzmsocialicons.html.twig

I installed the module and also placed a custom block with id "socialicons". The block itself is just a placeholder with no special fields.
Files
wzm_social_icons.module
function wzm_social_icons_theme($existing, $type, $theme, $path) {
  return array('block__wzm_social_icons' =>
    array(
      'variables' => array(
        'url' => null,
        'urlencoded' => null
      ),
      'template' => 'block--wzmsocialicons'
    )
  );
}

WzmSocialIconsBlock.php
class WzmSocialIconsBlock extends BlockBase {
  /**
   * {@inheritdoc}
   */
  public function build() {
    $oUrl = Url::fromRoute('<current>');
    $sUrl = $oUrl->toString();
    $sUrl = \Drupal::request()->getSchemeAndHttpHost() . $sUrl;
    $sUrlEncoded = urlencode($sUrl);

    return array(
      '#url' => $sUrl,
      '#urlencoded' => $sUrlEncoded
    );
  }
}

Nothing special in the twig-template - just the output for {{ url }} and {{ urlencode }}.
I think my main problem is to understand what needs to be declared with which key in the module-file and if the custom-block-id is used somewhere. No clue so far.
Thanks for any help!
Cheers


texts: Theming the field.tpl.php - accessing variables from a field collection

texts:
I've got a field template which is rendering a field collection field using the standard field.tpl.php file:

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

     <?php endforeach; ?>

I want to output the a CSS class inside the div in the loop with some text which comes from a colour field inside the $item variable.

EG. I would like to access the variable such as:
render($item['field_colour']);
in the loop, but this obviously doesn't work.

What's the best practice for doing this?


texts: View block (NOT page) that takes contextual filter argument from URL path component

texts:
My question is exactly the same as View block not accepting contextual filter argument
but I'm unable to comment and the question never received a valid answer.

I want to know if it is possible to achieve this functionality: A view block is placed on a node and shows all results by default. The node path is /community/blog. /community/blog/106 will display the same node with the placed view block, except the view block is filtered to content associated with the TID in the third path component.

Like the previous question, I do have this configured to work in the view preview. However /community/blog/106 leads me to a 404. This makes sense because how can Drupal know that for that particular path formation, it should first attempt to pass the 3rd path component to the view on /community/blog/ as an argument, and if it succeeds, display /community/blog/ with the filtered view, and if it fails... Who knows what?

It seems to me that this functionality does not exist, even though the Views UI would lead you to believe it does. It exists if you're using a view page but NOT a block. This confusing usability problem exists because the contextual filter options that work with a view page are not removed for view blocks (Unless I'm wrong, which I would love to be). As in the previous question, it does not always make sense to completely throw your site layout out the window in order to have a view page that can accept path arguments. Does anyone know if what I'm asking for is possible using a view block?


texts: A website called Drupal X-Ray can detect a Drupal site's Drupal version and modules in use. So if I don't want others to find that information, what can I do?


texts: Load form via ajax and submit by ajax not working

texts:
I have loaded a form via ajax and submit by ajax not working. But if I load form directly by url ajax submission is working. Form is loaded by ajax is using jQuery.

$('#button').on('click', function () {
        $.ajax({
            url: "user_group/edit_ajax/",
            success: function (result) {
                $(".RblockMain").html(result);
            }
        });
});

mymodule.routing.yml

mymodule.user_group_edit_ajax:
  path: 'user_group/edit_ajax/'
  defaults:
    _controller: '\Drupal\mymodule\Controller\UserController::user_group_edit_ajax'
  requirements:
    _permission: 'access content'

UserController

public function user_group_edit_ajax() {
        $form = \Drupal::formBuilder()->getForm('Drupal\mymodule\Form\UsergroupForm');

        $body_data = array(
            '#theme' => 'usergroup_edit_ajax',
            '#usergroup_form' => $form,
        );

        $message = \Drupal::service('renderer')->render($body_data);
        $response = new AjaxResponse($message);
        return $response;
    }

UsergroupForm.php

class UsergroupForm extends FormBase {

   public function buildForm(array $form, FormStateInterface $form_state) {

    $form['user_group_name'] = array(
          '#type' => 'textfield',
          '#title' => '',
          '#required' => TRUE,
          '#attributes' => array('placeholder' => t('Group Name'),),
          '#theme_wrappers' => array(),
        );

    $form['go'] = [
      '#type' => 'button',
      '#value' => $this->t('Submit'),
      '#attributes' => array('class' => array('btn btn-primary'),),
      '#ajax' => [
        'callback' => array($this, 'submitForm'),
        'event' => 'click',
        'progress' => ['type' => 'throbber', 'message' => NULL],
      ],
    ];
    }

public function submitForm(array &$form, FormStateInterface $form_state) {
 $title = $form_state->getValue('user_group_name');
$data = array(
        'type' => 'admin_user_group',
        'title' => $title,
        'uid' => 1,
        'status' => TRUE,
      );
      $usergroup = \Drupal::entityManager()->getStorage('node')->create($data);
$usergroup->save();
$response = new AjaxResponse();
    $response->addCommand(new AlertCommand('Submitted successfully'));

    return $response;
}
    }


texts: How to show forums even if you don't have access?

texts:
This is a follow up to this question.

I now know how to modify which forums are shown using the MYMODULE_preprocess_forum_list hook. But I have another scenario I can't figure out.

When you create a forum taxonomy term, you can use Forum Access module to set which users can access which forums. I have:

a board called "premium"
a role called "premium

Only premium members can access this board and this works great. But I still want the premium board to show on the forum landing page. When the user clicks on it, it must tell them they don't have access.

A workaround would be to simply give users access to those forums. Then the forum will display. Then write some other hook or chunk of code that actually stops the user when he clicks through to those pages. But it really feels to me like this should just be setting somewhere.

Am I missing something, or is my suggested solution the best route to go?

UPDATE

My problem could be solved if I could add another option to the screen below that says: "View Posts in this Forum"

Then i can specifically allow them to see the posts, but not actually click through to them.


texts: How can I give users the opportunity to make few posts completely private (i.e. visible only to themselves)? I'd like to do this with a make this post private - only for me checkbox.


texts: Drupal Apache Solr How to process all the results and not only 10?

texts:
I have a Drupal 7 website with apache solr search engine, and i want to access to all the results via my custom module before it is displayed, so i used this hook hook_apachesolr_process_results and as it says in it description

  This is invoked by apachesolr_search.module for the whole resultset returned in a search.

and that works good as long as your results are less then 10, but if your results are more then 10 results, then this hook will only process 10 by 10 (and 10 is the number of results that are returned in search page by default) so it only process the results that are currently displayed in the current page.

my question is there is a way to access all the results and not only the 10 results that are displayed in the current page?

Thanks in Advance


texts:
I'd like to make a Drupal 8 menu dynamic so it can i.e. point to the latest node of the articles or news or hide another from the menu if it doesn't have an entry at all.

How can I achieve this?


texts:
I am using Drupal Ckeditor (The main one, not the WYSIWYG module).

I would like to add buttons to the interface for inserting <quote> and <cite> tags.

How can I do this?

It already has a blockquote, but I would like <quote> and <cite> as well.


texts: D7: file_create_url() usable in node.tpl.php?

texts:
Can you use file_create_url() inside node.tpl.php? Should I assume you can only use it in the template.php?

$img_src = render($content['field_image']);
$bgimage = file_create_url($img_src);

Using the following code, I am only getting public://science-of-rock_background.png from $img_src.
Is there any reason why it would be blank?

print $img_src;
print $bgimage;

Edit made to avoid confusion:

In my tpl page for this field I am generating the uri.

field--field_image.tpl.php

<?php foreach ($items as $delta => $item) : ?>
  <?php
  print $item['#item']['uri'];
  ?>
<?php endforeach; ?>


texts: how to delete the files uploaded in the file field?

texts:
if i remove the files that were uploaded in a File field,and then upload a same name file, the file removed just now is still present in the server and the new uploaded file gets renamed to a name with index ,say, xxx_0 ,xxx_1.

What I want to do is when I remove a file, it should be deleted from the server, to save space in the server, How can I do this?


texts: Can I change the Display Settings by modifying the database?

texts:
I am using Drupal 8.5.6 and need to make the authoring information hidden for each content type. In other words, there should be no 'authored by admin on (date)' on any page. The fix should be simple (How do I hide the authoring information?) but similarly to https://stackoverflow.com/questions/51771776/drupal-8-display-settings-tab-missing-from-all-content-types, I do not have the display settings tab. I can get it back by uninstalling the Manage Display module (I tested on a seperate site), but there is a module dependent on 'Manage Display', which if I uninstall, content that shows up on the main page is lost.

Is there a way to replicate checking the 'Display author and date information' box from the database alone? Or is there a way to change this setting without uninstalling the Manage Display Module?


texts: How can I display the content of user profile using the Views module?

texts:
I want to create a view for displaying the title of the content posted by the user whose profile is being currently shown using the Views module. I am using the following modules:

Views for displaying the profile related content
Panels: for displaying the user profile

How can I do this?


texts: Per node contact form, recipient from taxonomy

texts:
I'm attempting to build a conditional recipient contact form on D7 and I'm running into a few issues.

Here are my requirements. I have a Content Type called "Dataset", which has a Term reference field of "Departments". The "Departments" taxonomy has an additional field called "Contact Email", so by referencing or selecting a term from "Departments" you can also retrieve the contact email for that department.

I'm attempting to generate a contact form per node of the "Dataset" Content Type, that populates the recipient of the webform from the "Departments" taxonomy field "Contact Email". In addition, I would like to obfuscate the email in the list. I have seen the handbook guide for Webforms about creating a dropdown list and reading the recipient email from that, but that's not quite what I'm aiming for.

I've attempted a few different approaches, using Webforms with Rules, and I can't seem to make any progress. Can anyone provide guidance or best practices for this? Thanks!


texts:
Let's say I have a Region content type that have multiple entity reference to a City content Type.

When I'm on a City page, I would like to display Cities of the same Region as the City page.

How can I achieve this through a view?

Keeping in mind that I also need to display cities of a Region at some point, switching the relation owner (City having the entity reference field to Region) might no be a solution here.


texts: How to pre-populate the username field on the login page when clicking an e-mail link?

texts:
I am using the Private Message module on my site; users receive a notification by e-mail when they receive a new message.

In this e-mail, there is a link to the login page.  Many users access the page via their mobile phones, so typing in their username can be a pain (they might also forget what their username is).

Is there some way to prepopulate the username via the link in the e-mail, perhaps using tokens?


texts: 7 - access callback get currently checked path

texts:
In my module I have lots of different pages. All pages, as defined in mymodule_menu, access the same access callback function mymodule_user_access and perform different things based on the parameters passed. Now as far as I understand drupal calls that function for all the menu items that may be rendered on the page, which means that if there are 10 menu items visible, it will call the function for each one of them separately. What I would like to have is some way of seeing what path drupal is currently checking when the function is accessed. So if I have

$items['mymodule'] = array(
    //some stuff here
    'access callback' => 'mymodule_user_access',
    //some more stuff
);

$items['mymodule/path1'] = array(
    //some stuff here
    'access callback' => 'mymodule_user_access',
    //some more stuff
    'type' => MENU_LOCAL_ACTION,
);

$items['mymodule/path2'] = array(
    //some stuff here
    'access callback' => 'mymodule_user_access',
    //some more stuff
    'type' => MENU_LOCAL_ACTION,
);

which means that when I access mymodule page the mymodule_user_access page is accessed 3 times (for mymodule, mymodule/path1, mymodule/path2). What I would love to do is:

function mymodule_user_access() {
    drupal_set_message($path); //This should output 3 different messages: mymodule, mymodule/path1, mymodule/path2
}

Is it possible without explicitly sending the path as a parameter in access arguments?

UPD: I tried current_path but it returns the path I am trying to access. Same with arg()


texts: What is the equivalent of hook_property_info_alter()?

texts:
In Drupal 7, we had hook_entity_property_info() and hook_entity_property_info_alter() which allowed us to add custom properties. (Not everything is a field.)

I can't find anything related to Drupal 8. The only thing I find is how to add it on a custom entity. How should I add properties to an existing entity/bundle?


texts: Drupal 7 View display "Page not found" without contextual filter

texts:
I have created a drupal view for my content type "Work", it has a relationship "Taxonomy terms on node" and a contextual filter "(term) Taxonomy vocabulary: Machine name". My path is /work/%.

When I go to work/sector, then it displays correctly all from content type work with the vocabulary sector. But when I go to just /work I get a "page not found".

Is there anything I need to be looking out for?


texts:
Is hook_boot() hook removed from drupal 8?

If yes then what is alternative method which can be used instead?


texts: adding a phone field in out of stock form of commerce stock notifications drupal commerce

texts:
Is there a way adding a phone number field (along with the e-mail) in the out-of-stock form that is being used from the commerce stock 7.x-2.2 module and commerce stock notifications 7.x-1.1 module?

I am using drupal commerce kickstart2 and when i have a product that is out of stock the above modules helps no to be able to add them in the shopping cart as long as it gives the option to fill in an e-mail address. I would like to add a phone number field as well under the e-mail address I was wondering if anyone knows how.


texts:
I just realised many guide on the internet not works for Drupal 7 Views pager

This is generally Nginx and Views pager issue. I've tried in Apache2 and the pager works without problem.

For example, I'm installing Commerce Kickstart. After submitting contents (SKU), I try to browse admin/commerce/products. But sadly, when clicking next page, it not showing any change

The first page URL is

http://www.website.com/admin/commerce/products

while second page, third page, and so on is:

http://www.website.com/admin/commerce/products?sku=&page=1
http://www.website.com/admin/commerce/products?sku=&page=2
http://www.website.com/admin/commerce/products?sku=&page=3

Currently, below is my nginx config:

server {
    server_name *.com *.net *.org *.in *.cc;
    root   /var/www/html/$host;
    index  index.php index.html;
    set $boost "";
    set $boost_query "_";
    if ( $request_method = GET ) {
      set $boost G;
    }
    if ($http_cookie !~ "DRUPAL_UID") {
      set $boost "${boost}D";
    }
    if ($query_string = "") {
      set $boost "${boost}Q";
    }
    if ( -f $document_root/cache/normal/$host$uri$boost_query.html ) {
      set $boost "${boost}F";
    }
    if ($boost = GDQF){
      rewrite ^.*$ /cache/normal/$host/$uri$boost_query.html break;
    }
    try_files $uri $uri/ /index.php;
    location ~ \.php$ {
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass    127.0.0.1:9000;
    }
    location ~ (.*)/x-progress-id:(\w*) {
        rewrite ^(.*)/x-progress-id:(\w*)  $1?X-Progress-ID=$2;
    }
    location ^~ /progress {
        report_uploads uploads;
    }
    location ^~ /files/private/ {
        internal;
    }
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        track_uploads uploads 60s;
    }
}


texts: Finding entity/webform fields in the database

texts:
A bunch of user accounts were deleted and recreated with new UIDs, and so any webform submissions or entities that have fields pointing to the old UID are now broken/wrong. I already updated some UID columns to the new UID, but now I need to find other tables/fields that still point to the old UIDs (and the columns aren't called "UID").

Given the ID of an entityform or webform submission, how can I find which tables/columns in the database correspond to the fields that make up that entityform or submission?

As an example, say I have an entityform with entityform_id = 123 and type = 'my_report'. If I view the entity using the Drupal interface, I see a user field that is blank, because it points to a user's old UID. How do I find where that field is located in the database? Is there a mapping from type 'my_report' to a list of fields or tables?

Also of note is that I need to do this for a decent amount of types of entityforms and webforms, so it'd be nice if I could query for them all, rather than looking at each field of each form using the interface or something.


texts: How i can increase the Block settings limit?

texts:
We are implementing blocks through features and features extra module.

Here only 50 blocks are displaying in admin>structure>features>create Components. We want to increase that limit to 100. Please find the attached snapshot.


texts: entity_metadata_wrapper Changes not being saved to user Profile2 profile

texts:
Challenge:

I have a profile2 taxonomy term reference field (single select) on user profiles called "field_member_interest_group".
On save/update of the user profile, I wan to A) See if the user has a role of "Elephant", then if so, select the term of "Elephant Group" from that user's taxonomy term reference field and save the changes.
"MYMODULE" is the name of my module in lowercase.

My (not working) Code:

function MYMODULE_user_update(&$edit, $account, $category) {
    $account = user_load($account->uid);
    $profile_profile = profile2_load_by_user($account->uid, 'profile');
    $profile_wrapper = entity_metadata_wrapper('profile2', $profile_profile->pid);

    if (in_array('Elephant', $account->roles)) {
        $termX = 3942; //tid of "Elephant Group"
    }
    $profile_wrapper->field_member_interest_group->set($termX);

    //Save changes to the profile entity
    $profile_wrapper->save();
}

Problem:

The changes are not saved to the user account, they are ignored completely.

Any thought on what could be going wrong?


texts: Clearing the cache changes the nice menu every time

texts:
Maybe this isn't a cache problem, but I am using Drupal 6, I have cache disable and I am editing a custom nice menu CSS file.

I didn't see changes right away to my nice menus, so I cleared the cache in the performance page, and the menu would revert back to old changes. When I cleared the cache again, it randomly found new settings for Nice Menu.
I then installed Devel, and cleared the cache, but it didn't help. Clearing the browser cache didn't help either.

Do you have any idea?


texts:
I have enabled both modules for D6 but I'm going to disable one to tidy up my Drupal stack. So wondering what are exactly the differences between the two modules, in terms of  functionality. Are they interchangeable for basic task of allowing users to subscribe to posts and send notification updates? If so, which one is preferred?

P.S. there is relevant thread here some other people may find useful.

Thanks


texts: $form['redirect'] = "something=$someId"; doesn't work in Drupal 7

texts:
I am here again with a problem! I want to make a form redirect usign a url with ids and somethings else as parameter, but when the code is executed something encode my url, so, if I put something like this $form_state['redirect'] = "page=$nid"; I get this in the url "page*%3D*123456789" %3D is the =$. So, how i have to do that? I tested with utf8_encode too.

Can I use a drupal_goto() inside a form? Why yes? Why not?

Thanks people!


texts: Validating form data that it is a weekday

texts:
I'm trying to validate a custom form field from an Ubercart module (in the checkout process). The field would specify a delivery date. The delivery date must be a business day.

How does one determine if it is a business day or not?

Are there given functions within Drupal that provide which day of the week when a response is given? Or would native php functions be the route to go with?


texts:
Newbie here!

I have created a view with some fields and i want to group some of the fields in one wrapper and remaining in another wrapper and also want to change the structure i.e. adding own wrappers and classes.

Thanks.


texts:
I'm having an issue with Views 3.7 not displaying all fields in the 'add field' dialog when trying to add a field to a view. There is only a small number of fields available from nodes etc whilst on my development version (which is almost identical) there are loads of fields to choose.

I have tried to copy my development version database to use on the staging version and use that but I get the same problem. Flushed caches etc.

Another related problem is when you try to add a custom header to your view, there are no selections to choose from. Click on close, and you get a page full of JSON.
I am unsure where to go on from here. Anyone had a similar issue in the past? Thanks.


texts: Form validator and submit handler is not getting called

texts:
I've created a Form using my module, which looks like this, then I've created a _validate & _submit handler (please see the linked file above). Then, in my front page, I printed the form using:

$form = drupal_get_form('mymodule_signin');
print render($form);

But when I'm submitting the form, the validate & submit handlers are not getting called, I'm getting redirected back to the front page. However, I created a submit button but when I was clicking it, the form was not getting submitted, so I submitted the form using jQuery's .submit() method to submit the function!

Can anyone help me why the form was not getting submitted first time, and finally when it was submitted (using javascript) the handler was not getting called? Here goes the template file I used to render the form.

PS. I created an entry in the hook_menu() and when I submit form using this page, the form gets submitted (calls validate handler). But it is not calling validate/submit handler when I submit it in my front page. :(


texts: How do I perform a redirect to a custom URL after login?

texts:
I am trying to redirect users to a custom URL after they logged in, but my code doesn't work.

How do I redirect users after they logged in?


texts: Local database setup in combination with staging server database

texts:
I have a central remote Git repo (Bonobo git server) where I track
all the Drupal 8 code etc.
We have a staging server already up and running installed with
Drupal 8.
I cloned the remote repository locally

I want to use Acquia Dev desktop to develop the site locally. But how do I have to use the database setup? So it's somehow related with the staging database. What are best practices for this? Do I have to create a different database in Acquia Dev desktop? When I add configuration and add nodes locally. How do I get this on my staging server?


texts:
I am trying to create an event ticketing system with drupal 7 and would like to insert the company's commission to it.
In simple explanation.
If event planner ticket price is $x
Company commission rate is 15%

The planner to choose whether the customers pay for the commission + ticket or the planner pays upfront.

Is there any module that support something like this?


texts:
So I am running into the issue where I can't add any custom javascript to elements inside the WYSIWYG because its an iFrame. Is there some special way of adding custom javascript.

The main thing I want to accomplish is adding a custom tooltip to img elements that have a title attribute.

I tried things like hook_wysiwyg_editor_settings_alter to add a js file with my custom code.

I have also tried doing some custom css to accomplish like using :hover, :before, and :after but found out that sometimes this doesn't work well on images on various browsers.

Any ideas on what a good solution would be for this problem? Might have to create a custom plugin that doesn't have a button that imports javascript, I wonder if that could work?


texts: How do I move conditional library includes out of a twig template?

texts:
I have a javascript library with several separate files which I would like to include only if necessary. I currently determine which need to be included within the twig template.

{{ attach_library('flot_d8/flot') }}
{% if options['xaxis']['mode'] == 'categories' %}
{{ attach_library('flot_d8/categories') }}
{% endif %}

{% if options['selection'] is defined %}
{{ attach_library('flot_d8/selection') }}
{% endif %}

{% if options['pan'] is defined %}
{{ attach_library('flot_d8/navigate') }}
{% endif %}

{% if resizable == true %}
{{ attach_library('flot_d8/resize') }}
{% endif %}

{% if nodiv == false %}

{% endif %}

Is there a better, or alternative way to perform this logic? I would like to override this template in another module and make the simple
 element more complex. However, I would have to copy all the library inclusion logic with it.


texts: Add users from SSO server database to Drupal

texts:
I am trying to implement an SSO system for Drupal system. The detailed description of the scenario can be seen in "Understanding Drupal's session management and user authentication".

I did implement the authentication part, as per the using the suggestions provided (thanks to Pierre Buyle). Now, I have a requirement to add the users to Drupal database which are already present in SSO database.
The IT team of SSO will create a form which will post this values to a URL on the Drupal site.

This URL have to catch the request and create a user in Drupal. I'll be using the method user_save() to achieve this.

My questions are:

How do I create this URL in Drupal? (Thought of using hook_menu and use $items to create the URL, but I don't want it to be accessible to users except admin.
How could I read the data from that URL?

I'm not asking for the complete code. Just pointers to which hooks or methods should I use for the use cases would be enough.


texts: drupal 7.35 .htaccess: Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration

texts:
I'm trying to deploy an instance of drupal with cloudfoundry. Everything loads up and seems to start correctly, but when I try to hit the page I get the following error in the logs:
../.htaccess: Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration

I'm using the following php-buildpack: https://github.com/cloudfoundry/php-buildpack

I was able to get the app to load the install page and run by commenting out this line in .htaccess:
Order allow,deny

However I feel like this may cause security issues, and I really want a better fix to this issue./


texts:
How to redirect form to a url having wild card character in drupal? For example, can I do like this below shown?

$form_state['redirect'] = 'admin/component/%/edit'

or any other alternative approach to do like this?


texts:
I am modifying a module that extends PathBasedBreadcrumbBuilder, but that only has methods to add a link at the end of the bread  and I want in certain cases to start the breadcrumb from scratch or add a link at the beginning of the breadcrumbs.

How can I do this?


texts: Change field type for custom entity (from integer to decimal) with existing data

texts:
Yes I have seen previous answers about that, but I'm looking for an new answer :

That does not use SQL request
That does not use deprecated function like db_change_field()
maybe that uses the new API (see https://www.drupal.org/node/3029997)

I'm not familiar enough with the Drupal 8 storage system so I also look for insight.

I have looked into a lot of documentation, including :

https://www.drupal.org/node/3034742 (example included for a schema change, for a revisionable field)
https://www.drupal.org/docs/8/api/update-api/updating-entities-and-fields-in-drupal-8#updating-a-base-field-type (which feels to be the best answer yet)

What get my attention is this : "Starting with Drupal 8.7.0, the Entity system provides a new Update API for converting the schema of a content entity type from (non-)revisionable/(non-)translatable to revisionable/translatable, which also works when there is pre-existing data for the entity type whose schema is being changed.."

Which indicated some built-in way to change a field type with existing data without having to write lots of code.

So I tried this to change a field type of my custom entity which already have data (~ 10000 rows).

function mymodule_post_update_0011_field_conversion(array $sandbox) {
    $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
    $last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository');

    $entity_type = $definition_update_manager->getEntityType('my_entity_id');
    $field_storage_definitions = $last_installed_schema_repository->getLastInstalledFieldStorageDefinitions('my_entity_id');

    // Update field already existing in $field_storage_definitions
   // I also tried to create a new field, with the same outcome.
    $field_storage_definitions['order_vat'] = BaseFieldDefinition::create('decimal')
      ->setLabel(t('Order VAT Rate'))
      ->setDescription(t('Order VAT Rate.'))
      ->setSettings(['precision' => 5, 'scale' => 2]);

    \Drupal::entityDefinitionUpdateManager()
      ->updateFieldableEntityType($entity_type, $field_storage_definitions,$sandbox);
  }

Which ends with a Drupal\Core\Entity\EntityStorageException : Unsupported entity type

I tried to use this same function to add a new field in the entity, with the same error as outcome.

Is there something wrong with my attempt, and is the only way to manage this is to manually, inside a post_update_hook, to create a new field with the appropriate type, copy all values from the old one to the new one, empty the old one, and delete the old field ?

That seems a lot for a simple operation, which, in my case, I could do with a quite simple SQL statement.

Last precision, this is a custom entity, created from code only (ContentEntityBase), without any revision (for now), which content is only manipulated programmatically.


texts:
I would like to have a calendar be displayed as a filter for a view. When a user clicks on a date on the calendar the views result on this page are updated (preferably via Ajax) to show the chosen dates event. Such as the design below. The calendar should not be a popup calendar.

I am aware of the date popup calendar in views exposed filter options but that only displays the calendar as a popup calendar as expected.

I have tried to look into the calendar module as well, however the default behavior of the mini calendar block does not fit my needs as when the user clicks on a date on the mini calendar it will redirect the user to that specific dates calendar page instead of updating the views listing.

Any suggestions or direction on how to implement such a feature would be greatly appreciated!


texts:
I've got a Views (machine readable name: e.g 'views-events-page') page that I gave a URL (in the path field, e.g. 'events').

I want to link to this Views page from Link field. Of course, I can paste the path 'events' into the link field. But supposing I would change the path of the Views page the link will be broken. Is there any chance of using a token to get the path of this Views page, like [views:view-events-page:path].

I was not lucky asking the search engine of choice the right question. I did not find any useful


texts: I just started using the ThickBox module to to create a simple gallery.  However, only some of the photos will load.  A couple will work, than one will just give the loading line and freeze on it.  I have the image module working fine and image caching as well.  Any idea what might be going on?  Thank you.


texts: How to make an upsert query with two keys?

texts:
I have a custom table with a primary key made from two fields (route, uid) and I want to use the upsert() method to insert or edit a record. The problem is that the key() method only accept one key which will be used to identify the existing row. But I have two (route and uid)

  Sets the unique / primary key field to be used as condition for this
  query.

public function key($field) {
  $this->key = $field;

  return $this;
}

Maybe I'm missing something or I misunderstand the upsert() method. So, Can I make an upsert query with two keys?

Edit: I'm using mysql.


texts: Skip_on_empty row method working, but entity still created

texts:
I am migrating a field in a node to a paragraph. I am trying to only create the paragraphs where the field has values. That field is an entity reference to another node.
source:
  plugin: d7_node
  node_type: my_node
process:
  target_id:
    -
      plugin: get
      source: node_er_field/0/target_id
  parent_id:
    -
      plugin: get
      source: nid
  parent_type:
    -
      plugin: default_value
      default_value: node
  er_paragraph_field:
    -
      plugin: skip_on_empty
      method: row
      source: '@target_id'
      message: 'node skipped'
    -
      plugin: get
      source: node_er_field
destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: paragraph_er
migration_dependencies: null

When I run the migration, I get a strange reported result though. Of the first two nodes, one has something in the field, and one doesn't.
drush mim group_paragraph_field_node --limit=2
Processed 3 items (2 created, 0 updated, 0 failed, 1 ignored)
When I look at messages. The skip_on_empty message appears. But the row that it supposedly skipped is still created. I can't for the life of me understand why this is happening. The row method is being fired. I've tried every permutation I can think of in terms of doing the skip_on_empty, within the same pipeline or like this one. With the target id or just with the field as is. I've tried another custom plugin skip_on_empty_array. Either its 2 created and 0 or 1 ignored, but I always get 2 paragraphs out of it.
I've gotten skip_on_empty to work in other contexts. I don't understand why it is not working here. Had a hard time finding a similar example as well.
Any thoughts?


texts: How can I rewrite a content link and replace spaces with dashes?

texts:
In D8, I am struggling to build a link in Views. I keep running into either a missing option or checkboxes ignored.

I have three fields pulled into views:

Content: Title [hidden]  .... token is {{ title }}
Content: Resource Type [hidden]  .... token is {{ field_resource_type }} Pulls values from Taxonomy
Content: Link to Content .... token is {{ view_node }}

I want to rewrite the Content: Link to pass variables. So I'm outputting the URL as text

I essentially want:
"{{ view_node }}?title={{ title }}&type={{ field_resource_type }}

I also want to replace the spaces with dashes, so my end result is:
/resource/article-one-url?title=article-one-title&type=white-paper

But... if I override the output, and make my own URL, the system ignores if I check the box to Replace spaces with dashes

I do this by first checking "Output this field as a custom link," so that I can see and check the "Replace spaces with dashes" option.

I would try to rewrite the URL in the "Output this field as a custom link" section, but the field I thought was supposed to be there, is not.

UPDATE: I also tried this with a custom text field. Within the field settings I checked "Output this field as a custom link" and put the same tokens in, but this does the same thing. Spaces exist in the url.


texts: Commerce 2: Can Cash and Check payments be implemented?

texts:
My client's business and website is primarily online purchases. However, there are instances when special customers or referrals come into their office and buy the product by cash or check.

My client wants those purchases to be recorded in the same database as online orders, along with the same captured contact information.

Is there a way to implement the checkout process so that certain employees with designated privileges can enter orders through the online store, but no request for payment information is required.  Or for those and only those privileged people an additional cash / check option is shown? (And the check option may also ask for additional info, such as the bank name and check number.)


texts: Displaying a taxonomy term (token) in a block

texts:
How do I display the name of a taxonomy term page in a block?

For example, I am on the ww.example.com/taxonomy/term page and I want a title block on that page that displays TERM. Is there any PHP already written for this out there?

I tried a couple of suggestions made here using contextual filters but they do not work, either the block doesn't show or the term displayed is not the one in the URL (The taxonomy has children.)

Thanks. :)


texts:
I am using the JSON API module and I would like to create a comment. I was able to create nodes based on the documentation found here, but I can't figure out how to create comments.

How can I add a comment using that module? I managed to do it through the default REST API module.


texts:
I have created a block view with title and image using fields. When I use the default image styles, they work as they should.
The custom image style I created is a thumbnail (120 x 70) with canvas. When I try using this style in Views, I get the original image size.


texts:
I have a website where 80% of it are Webforms. Admins can create webforms themselves and registered users can fill them in. ( A PDF will be created etc etc...).

Now I have to make this website in 3 other languages then the default.

I Found already the following module:

https://www.drupal.org/project/webform_localization

Now my initial question:

Imagine you have a webform in the wizard with  a label, and a textarea and a default value as type or static text. What is the best way to get the 'default' values in the context translated?

Example
http://i.imgur.com/pAiQEJM.png

Note:
This is text which got changed for every webform generated on the website.


texts: Drop Tables After Backup Migrate Restore

texts:
I find myself using Backup and Migrate's Restore (from manual backups folder) when testing module sets or after a change to a project is problematic. I use Schema after the restore to check for extra tables left in the database during the restore process. Generally,  orphaned extra tables that are no longer wanted, needed or an issue are tables from modules or entity/content type fields being prototyped/tested. Module tables left in the database cause PDO Exception errors if I attempt to reinstall same module or alternate dev version after a restore. Extra field tables can get quite numerous and chaotic when rapid prototyping.

EXAMPLE
Match (107)
Hide Extra (11)
Tables in the database that are not present in the schema. This indicates previously installed modules that are disabled but not un-installed or modules that do not use the Schema API.

Schema report looks like:

Match (107) Tables for which the schema and database agree.
Extra () Tables in the database that are not present in the schema. This indicates previously installed modules that are disabled but not un-installed or modules that do not use the Schema API.

field_data_field_test_termsfruits   // fields for content types
field_data_field_test_code_and_api
field_data_field_test_drupal
field_revision_test_termsfruits
field_revision_test_terms_code_and_api
field_revision_test_terms_drupal
search_api_index                    // a module not being used
search_api_item
search_api_server
search_api_task

Seems that Backup and Migrate team is not ready to include drop tables options and the issue has been discussed in detail. I've also tried the Demonstration module which was great in D6 but just spits errors in D7 for me.

Aside from phpMyAdmin, MySQL GUI tools or command line to drop tables (and realizing security risk if permissions are compromised), what contributed modules or other PHP/API methods can I use from within the Drupal interface to drop specific tables?


texts: How to create an Atom RSS feed with site's content type?

texts: I have a content type named "blog" of drupal 7 website. How to create Atom RSS feed with site's blog?


texts: How to generate block with Views, Entity Reference and Taxonomy Terms

texts:
I have a site with content types: book-page & ride.

These are organized so that each book-page displays several rides (using Entity Reference), and each ride is tagged with several taxonomy terms.

I'd like to create a block which displays links to other pages whose rides share a taxonomy term with any of the rides on the current page.

Looking at the table structure I can see that the following query will yield the desired results (for node id 9).

SELECT DISTINCT your_page.title
FROM node my_page
INNER JOIN field_data_field_rides my_page_rides ON my_page.nid = my_page_rides.entity_id
INNER JOIN node my_ride ON my_page_rides.field_rides_target_id = my_ride.nid
INNER JOIN taxonomy_index my_ride_terms ON my_ride.nid = my_ride_terms.nid
INNER JOIN taxonomy_term_data my_term ON my_ride_terms.tid = my_term.tid
LEFT JOIN taxonomy_index your_ride_terms ON my_term.tid = your_ride_terms.tid
INNER JOIN node your_ride ON your_ride.nid = your_ride_terms.nid
INNER JOIN field_data_field_rides your_page_rides ON your_page_rides.field_rides_target_id = your_ride.nid
INNER JOIN node your_page ON your_page.nid = your_page_rides.entity_id
WHERE my_term.vid = 2
  AND my_page.nid = 9
  AND (your_page.nid IS NOT NULL AND your_page.nid != my_page.nid)
  AND your_page.status = '1'
  AND your_page.type IN ('book')
  AND your_page_rides.entity_type = 'node'
  AND your_page_rides.deleted = '0'

My question is - can the same thing be done through the Views UI using a Relation?

I'm using D7 with Views 3.


texts: Is there a way to translate a view page title in Drupal 8? How can I achieve it, if it is possible?


texts: Rearranging subfields with the Address Field module

texts:
Is there a way to rearrange the fields within the widget with a specific hook? Should I use hook_form_alter()?

To be more specific, I want to put the country field below the zip-code field when using the Address Field module.


texts: Avoid redirect to comment page if comment is invalid

texts: I have configured comments to display in the node page, but if submit an invalid comment (e.g. without text in the comment field) I get redirected to the /comment/reply/ page. I would like to remain in the node page.


texts:
How hook_form_alter() works in Drupal? It will work when the form is just loaded right ?  I need to modify the form variables before submission only  . Suppose i am modifying some form variables after rendering the form and the submitting it , where i can write the code for this ?

Take an example as I have a form  node_form() , and I am modifying the form variables in node_form_alter() and processing the submission in node_form_submit() function . Will node_form_alter work on pre submission too ? Or is there any workarounds ?


texts: Migrate doesn't update destination files if source files have changed content

texts:
I'm using Migrate 7.x-2.5 to keep Commerce products synchronized between a legacy system and a Drupal ecommerce website.

I setup two migration methods, one for Commerce Products entities and one to generate nodes for product display. Migration tasks are supposed to be run every night, because people during the day add new products, update some, and delete others. So both migration tasks are run with the "update" checkbox checked. I take care to delete obsolete content at postImport() and all is good.

Everything is working for me, except for product images. When source files are updated with different pictures, filename doesn't change (that's a legacy system behaviour). Migrate doesn't seem to notice that the file has changed, so it doesn't migrate it and pictures don't get updated.

Anyone can help dealing with this file updating issue?

Here's the relevant migration part where files are handled.

$this->addFieldMapping('field_image', 'immagine'); //this field gets populated in prepareRow()
$this->addFieldMapping('field_image:file_class')
        ->defaultValue('MigrateFileUri');
$this->addFieldMapping('field_image:source_dir')
        ->defaultValue(SRC_IMG_PATH);
$this->addFieldMapping('field_image:file_replace')
        ->defaultValue(FILE_EXISTS_REPLACE);


texts:
Hello i was hoping to create a block to attach to the taxonomy/term/* page but i am running into problems with the date arguement working with the term argument. I have just cloned the archive view and disabled the taxonomy view, added the arguments but to no avail.

Has anyone ever achieved this before with D^ and Views 3?

thanks


texts: How can I add a "weight" functionality to nodes?

texts: I would like to be able to specify a "weight" for the article nodes published in the homepage. What is the best way to do this?


texts:
I am using coder to review code of my module, and I am seeing this in .module file. I am not sure how to fix this up.

Line 49: The $string argument to t() should not begin or end with a space. (Drupal Docs) [i18n_11]

  '#title' => check_plain(t('Role Limit (' . $value . ')')),


texts: How is domain_taxonomy_access module configured?

texts:
I am trying to use the domain_taxonomy_access module, but I do not know how it is configured.

How I do so that the user of a certain domain can manage their newsletters?

I am trying to implement the solution shown here: https://www.drupal.org/project/domain/issues/558692

Thanks


texts: Slow loading in edit mode - only on some pages Drupal 7.22

texts:
On editing some pages, there's a 20 second wait, and on others it's only 1-2 seconds. Both are the same content types.

I seem to always get the following error message:

Notice: Trying to get property of non-object in node_page_title() (line 2211 of /data/www/www.xxx.xx.xx/modules/node/node.module).


texts:
I have custom module code that check the user role and based on user role, user fields updated,

for example

if(array_key_exists(12,$user->roles)) {
    //Manger
    $role =  array(8=>8);
} elseif (array_key_exists(13,$user->roles) ) {
    // super Manger
    $role =  array(14=>14);
} elseif (array_key_exists(11,$user->roles)) {
    //section manager
    $role =  array(14=>14,8=>8);
}

so when I want to move this module to other site and import roles using feature, the ids will changed.

so how can I use machine name for roles instead of ids.

Regard,


texts: field_attach_form with user picture and user mail?

texts:
I'm trying to build a custom "edit profile" page and use a lot the field_attach_form function in order to build it :

field_attach_form('user', $user_entity, $form, $form_state, NULL, array('field_name' => 'field_user_firstname'));
field_attach_form('user', $user_entity, $form, $form_state, NULL, array('field_name' => 'field_user_lastname'));
field_attach_form('user', $user_entity, $form, $form_state, NULL, array('field_name' => 'field_user_organisation'));

I'm trying to insert input for user mail and user picture, but as they are properties and not fields, the following snippet is not working.

field_attach_form('user', $user_entity, $form, $form_state, NULL, array('field_name' => 'mail'));

Is it possible to insert user's properties form with this function ? or is there another way ?


texts: How to order unions separately in db_select?

texts:
I have a UNION query, where the second part of the UNION should be ordered separately, not the complete UNION.

The resulting query should look like this:

(
  SELECT id, fname FROM tab1 WHERE fname = 'Frank'
) UNION (
  SELECT id, fname FROM tab2 WHERE lname = 'Sinatra'
  ORDER BY fname DESC
)

My question is: How can I order the second part of the UNION? I know, I could use a db_query, but I'd like to join this db_select in another db_select. And I think I cannot join an executed db_query result and a db_select object.

Here is my current code:

$subquery1 = db_select('tab1','t1');
$subquery1->fields('t1',array('id','fname');
$subquery1->where('fname=:fname',array(':fname'=>'Frank');

$subquery2 = db_select('tab2','t2');
$subquery2->fields('t2',array('id','fname');
$subquery2->where('lname=:lname',array(':lname'=>'Sinatra');
$subquery2->orderBy('fname','DESC');

$subquery1->union($subquery2);

$result = $subquery1->execute();
...

The resulting query is:

(
  SELECT id, fname FROM tab1 WHERE fname = 'Frank'
) UNION (
  SELECT id, fname FROM tab2 WHERE lname = 'Sinatra'
)
ORDER BY fname DESC


texts: I want to save data in a mysql table database using drupal 7 (costume module), but my question is that depends if the value exists I have to use the UPDATE command and if not INSERT command but I don't know how to write this code with the db api.


texts:
I added a field to content type. The field type is select list.
I created a view. I added a filter criteria using the above field:

Operator > Is one of

Options > Select All is selected.

When I go to front end, I see -Any- selected by default but I dont the content/result. When I click Apply, i get the result. I am not sure why I have to click Apply to get the result. It should give me result as soon I go to views page.

Please help.


texts:
I am working on a module that has an install file that creates a taxonomy with postal codes.
And then imports all contacts from a csv file.

Now i would like to add a field to my taxonomy (boolean).

How would i approach this?

Thanks in advance!


texts:
In Drupal 8, what code determines if a link is output as text, or an anchor tag with text?

I have entered a route:<nolink> item in the menu, but the output is this:

<span target="" data-highlight="0" data-icon="" title="Description of wris." data-drupal-link-system-path="<front>">wris

Instead, I want an anchor tag with just # for the href.

Is there a reason why it only outputs a span? Where can I adjust this? Or, should I do this?


texts: Show only nodes in a view which have the same value of a text field (field_phone_number)

texts:
I have a content type "ABC" with the "telephone" field (field_phone_number) added to it,
and I already have on my website around 1K nodes of this content type "ABC".

I want to display a table view on every node of type "ABC", displaying the title of all other nodes that have the same
"telephone value" as the content type being viewed.

I have tried to use the EVA module but with no success.

This is what I have done so far:

Create an EVA View that show: "content" of type: "ABC".
Add all the field that I want to display.
EVA Settings:

Entity Type: Content
Bundles: ABC
Arguments: Check the "Use tokens from the entity the view is attached to" and add: "[node:field_phone_number]"

Add contextual filter: "Content ID" with provide default value: "Content ID from URL"

Results:

A table view displayed on every node with only the node itself is displayed inside the table !!!! (Not what I need)

For example:

If lets say i have 12 nodes that have the same phone number value: "123456789".
What I am expecting to see is a view table displaying all the title of those 12 nodes every time I visit the page of each
and every node of those 12 nodes.

Usually doing the above by using an entity reference field as the comon value between nodes is very easy, but the problem is that I do not have an entity reference
field in commun between the nodes, rather I have the "Phone Number" field which is obviously it is not of type "entity reference".

Any help ?

Thank you,


texts:
I'm using Panels in page manager to create unique pages with different blocks and panes. I'd like to be able to add settings to each individual pane such as adding a class or style.
For example when I edit a block or pane, I receive this window

I'd like to be able to add settings here but I'm not sure where to start.
In Drupal 7 adding styles to individual panes was clear and I'm not sure it even has that functionality in 8 yet.


texts: What does Rules token "node:unchanged" mean?

texts:
I am on Drupal 7 and I am using the Rules module to do some stuff.

I must say that I am not very used to using this module; there are few questions that need answers, such as the use of the node:unchanged token.

For example, when I set a rule with a data comparison as a condition, I have to give the name of the referred field; then, there is either node:changed or node:unchanged.

I am quite accustomed to using node:changed. What does node:unchanged mean?


texts: In Drupal 7, it appears that the Content Lock module (which prevents concurrent editing of nodes) is not able to work its magic on Entityform-based nodes. Is there a workaround? Something similar with Entityform capabilities?


texts: Use image scale and crop in custom function

texts:
In Drupal 7, I'm trying to use image_scale_and_crop() to take an image from an external URL and resize it.  Then I want to print it out to my page.  Here is my code:

$filename = $bjt_img;
$img_url = "http://www.mydomain.com/uploads/".$filename;
$myimg = image_load($img_url);
$myimg_scaled = image_scale_and_crop($myimg, 100, 80);

print '<img src="'.$myimg_scaled.'">'

I'm getting the message:

  Recoverable fatal error: Argument 1 passed to image_scale_and_crop()
  must be an instance of stdClass, boolean given, called in...

How exactly is the image returned with image_scale_and_crop()?


texts: Redirect on Custom page after one time login link

texts:
I created password reset link using user_pass_reset_url function. This is redirecting to user/uid/edit page after click login.

How to redirect on custom url?


texts: How to check the first item/content on Drupal View

texts:
I'm currently using Drupal Views and I'm trying to figure how to check the first item/content on the view. On a twig template I could write

{% for items in related_content.entity.field_content_items %}

    {% if loop.first %}

    first element

    {% endif %}

{% endfor %}

I tried writing the same condition within the view using {% if loop.first %} but it doesn't work. Is there similar code to achieve this within Drupal Views Custom Text


texts:
How do I show login redirect page as a modal form or dialog popup? I'd like to keep my site consistent since I'm using Modal Forms for login and register pages.

I'm not trying to display a popup showing an "Access Denied" error.

(edited for clarity)


texts: How to get the children terms of a taxonomy in views?

texts:
I just created a view to show terms of a given vocabulary. I works but the children terms aren't shown.

How do I do to get children terms?


texts: How do I provide a field storage definition for hook_entity_bundle_field_info?

texts:
The documentation says:

  Bundle fields either have to override an existing base field, or need to provide a field storage definition via hook_entity_field_storage_info() unless they are computed.

How can I do that?

I tried something like this:

/**
 * Implements hook_entity_field_storage_info().
 */
function km_mod_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'node') {
    $definitions['field_metatags'] = \Drupal\Core\Field\BaseFieldDefinition::create('metatag')
      ->setName('field_metatags')
      ->setLabel(t('Metatags'))
      ->setTranslatable(TRUE)
      ->setCardinality(1)
      ->setTargetEntityTypeId($entity_type->id());
    return $definitions;
  }
}

/**
 * Implements hook_entity_bundle_field_info().
 */
function km_mod_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {

  if ($entity_type->id() === 'node') {
    $fields = [];

    $fields['field_metatags'] = BaseFieldDefinition::create('metatag')
      ->setLabel(t('Metatags'))
      ->setDisplayOptions('view', array(
        'label' => 'hidden',
        'type' => 'hidden',
        'weight' => 0,
      ))
      ->setDisplayOptions('form', array(
        'type' => 'metatag',
        'weight' => 50,
      ));

    return $fields;
  }
}

It does not work as intended though. The field does not appear during Form display, and when trying to save:

Drupal\Core\Entity\EntityStorageException: Table mapping contains invalid field field_metatags. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()

I've checked the field storage config yaml (by creating the field manually) and it doesn't really look any difference to how I try to configure it:

uuid: 4c6ecbd5-49b3-4305-8f47-518f76a917f7
langcode: sv
status: true
dependencies:
  module:
    - metatag
    - node
id: node.field_yaay
field_name: field_yaay
entity_type: node
type: metatag
settings: {  }
module: metatag
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

I have run drush entity-updates as well, with no luck.

So what am I doing wrong?


texts:
i am using below code to show content in admincontroller of my module but $filelink is show as text instead of html

i tried to show href link in $filelink but it renders and text content like below:

Resume

but i want it as

Resume

  function content() {
    $url = Url::fromRoute('bd_career_add');
    //$add_link = ;
    $add_link = '
' . \Drupal::l(t('New Submission'), $url) . '
';

    $text = array(
      '#type' => 'markup',
      '#markup' => $add_link,
    );

    // Table header.
    $header = array(
      'id' => t('Id'),
      'name' => t('Name'),
      'number' => t('Number'),
      'email' => t('Email'),
      'email' => t('Resume'),
      'operations' => t('Delete'),
    );
    $rows = array();
    foreach (BdCareerStorage::getAll() as $id => $content) {
      // Row with attributes on the row and some of its cells.
      $editUrl = Url::fromRoute('bd_career_edit', array('id' => $id));
      $deleteUrl = Url::fromRoute('bd_career_delete', array('id' => $id));

    $file = \Drupal\file\Entity\File::load($content->resumefid);
    $filelink ="getFileUri())."' target='_blank'>Resume";

      $rows[] = array(
        'data' => array(
          \Drupal::l($id, $editUrl),
          $content->name.' '.$content->lname,$content->number,$filelink,
          \Drupal::l('Delete', $deleteUrl)
        ),
      );
    }
    $table = array(
      '#type' => 'table',
      '#header' => $header,
      '#rows' => $rows,
      '#attributes' => array(
        'id' => 'bd-career-table',
      ),
    );
    //return $add_link . ($table);
    return array(
      $text,
      $table,
    );
  }


texts: Experience with Drupal 7 Install Profile

texts:
"How to Write a Drupal 7 Installation Profile": http://drupal.org/node/1022020

Any experience with this (good or bad)?

The link above references the ability to create an installation profile. Question is, how much can it do?

The real objective is to be able to put everything into code (and version control) that defines the website; permissions, OG field group settings, you name it.
And then use that as a routine production path from dev, to stage, to production.

I've heard theory that this technique could be used to not only establish a site, also as a vehicle for migrating from the dev environment, to staging, to production.

Clearly, there is a benefit to be gained by an organization like Pressflow to be able to build a preconfigured base distribution. But, how viable is this technique for routine website updates and maintenance?


texts: Is there a way to access tokens of another webform ? I have users of one role who need to evaluate in a webform files uploaded by users with another webform


texts: a non existing subdomain is added to image urls

texts:
I have some images in my home page and from time to time the URL of these images get changed somehow and a subdomain is appended to it automatically.

For example:
www.mysite.com/sites/default/files/image.png becomes abc.mysite.com/sites/default/files/image.png.

Here are some other facts that might have something to do with this issue:

The site supports two languages (english and arabic which is the default language) and this issue only appears in English Site.
We had a very old drupal 6 site before that was using Subdomains extensively (using the subdomain module) and I noticed that any subdomain appended to the image url is usually a randomly selected one of these old subdomains. So these domains used to exist. But the weirdest thing is that we actually moved to a completely new server a year ago and we created this new site from scratch using Drupal 7. We have not imported any content or modules from the old site and we don't use subdomains any longer. The old server is no longer active. Also we have removed all subdomains from DNS in cPanel.
The issue goes away sometimes after clearing the cache.

What could be causing this weird issue?


texts: One filter criteria for two different displays of the same view?

texts:
Hi there drupal wizards.

I want to be able to filter two different view displays and display the search results of a filter query simultaneously on the same page with only one shared filter criteria search that works on both views.

I have no problem to do the filter criteria for each one, but I want one common filter search criteria that filters both views and displays them one after the other on the same page.

How do I do this?

If possible I don't want to hack code, just configure things.

To be more precise:
I have one map search working based on location data. The filter is exposed as a block. However I've created a block display showing the same view as a table list that the filter block query does not seem to affect at all. I'm using context to display the second view display block In the same path.


texts: Conditional e-mails based on radio buttons Drupal Webform

texts:
I've built a form at http://dev.vies.dk/tilmelding. In the backend, it is easy to send e-mails to people filling out the form.

However, I need to send additional e-mails to other people based on some of the answers in the webform, namely the subjects they choose and the sex they have.

Subject         Female       Male
Soccer          mail@mail.dk mail@mail.dk
Handball        my@mail.dk   your@mail.dk
Kayak           mail@mail.dk mail@mail.dk
Dance           be@mail.dk   eb@mail.dk
Biking          sv@mail.dk   ls@mail.dk

Is there a hook, where this can be programmed, so I can achieve what I want?


texts: Custom tpl.php for custom content types rendered through another tpl.php

texts:
I have a custom module which displays multiple content types in tabs. My module uses a custom tpl.php which renders the tabs and the contents(of multiple types).

The challenge is to have custom tpl.php for each content types I render. The theme file node--TYPE.tpl.php works when I directly hit a node of a TYPE. But it is not used when I rendered the node content using the below code,

    $node = node_load($aTab['nid']);
    $view = node_view($node, 'full');
    $rendered = drupal_render($view);
    print_r($rendered);

What is the suggestion to have my module to render each content types using their custom theme file.


texts: Different redirect page for registration, login and first time login

texts: Im trying to redirect the user to different pages on login, first-time login and registration. I used the Login Destination module but it only has the option to redirect the user to one page on registration login and first-time login. Is there another way of doing this?


texts:
I am trying to do a POC using Migrate, Migrate Plus, and Migrate Tools to define migrations and having trouble getting my migration to register and appear in the list of migrations for the migration group I created (in the UI).

In my yaml file, I put in the basics just to try and get it to appear in the UI:

id: remote_entity
label: TESTING
migration_group: mygroup

I named the file remote_entity.yml in a folder called migrations (I got this from the example in the Migrate Plus) module. Yet, it does not appear.

I see other modules have theirs in the config/install directory with a naming pattern assigned. Where is this file supposed to really be? What should it be named to get picked up? If it is in the config/install directory, do I have to uninstall/install the module numerous times as I iterate over a POC and make changes to the migration definition?


texts: When taking a copy of the node template do you need to maintain the article tag that is in there

texts:
When taking a copy of the node template, should you keep/maintain the original code that is in the file?

Example the article tag.

nid; ?>" class=" clearfix"> etc..

What are the implications of removing this, if any?


texts:
I've been getting the following php notice:

Notice: Undefined offset: 9 in include() (line 89 of node--name.tpl.php).

Here's the code:

<?php
// loops through array to print out addendum pdf's.
for ($i = 0; $i < 10; $i++) {
  $variable2 = "../sites/default/files/" . $node->field_addendum['und'][$i]['filename'];
  $variable1 = $node->field_addendum['und'][$i]['filename'];
  if (isset($variable1)) {
    $result = $i + 1;
    echo "$result&nbsp&nbsp&nbsp";}
  else {}
}
?>

The field_addendum is a "file" field type from a custom content type. I understand why I'm getting the notice: if the node only has 3 addendums, once the loop gets to $node->field_addendum['und'][3]['filename'] and onwards, there is nothing in the array.

Is there a way to get the number of files without having to loop through the array first?


texts: Can a theme name be started with a number?

texts:
Can I start a theme name with a number? For example: "123go"

Does Drupal recognize folders & files that start with it?

Does it work in the temple.php as the start of a function?


texts:
I have a server that hosts our Drupal 7 development, testing, and production environments:

/var/www/html/dev
/var/www/html/test
/var/www/html/prod

Instead of having dev and test live in subdirectories like http://ourdomain.edu/dev, we want the URLs to be http://dev.ourdomain.edu.

From a Drupal standpoint, is this best accomplished through an .htaccess file in each directory?  Or in settings.php?

At the moment, functions like path_to_theme() aren't working at http://ourdomain.edu/dev since path_to_theme begins with a forward slash.  Consequently, the theme refers to http://ourdomain.edu/sites/all/themes/ourtheme/images/logo.png instead of http://ourdomain.edu/dev/sites/all/themes/ourtheme/images/logo.png

It would be great to know what's considered best practice.

Thanks!


texts: Views pager with anchor on another page?

texts:
I'm creating a page that have two sections, one with an image, as a "presentation", and other at the bottom that has a list, created with a View. That list have pagers created with the "Views Simple Pager" module(https://www.drupal.org/project/views_simple_pager), and that view is within a section markup in the page.

The problem now is that when I change the page of the view, from page 1 to page 2, for example, the whole page is refreshed and it goes again to the top, where I have the image and not the list. I would like to customize the pager in some way that permits me to go directly to the views section, something like "mypage.com/News?page=2#views-section" instead of "mypage.com/News?page=2".

Is it possible? Thanks.


texts: Drupal Commerce and large product inventories

texts:
Does anyone have any insight into using Drupal commerce with a large inventory? We are utilising using Drupal 8.1 headless and scoping an eCommerce integration using Drupal Commerce with around 30 million products. Currently, our thoughts are to use a MongoDB backend and Elasticsearch on top of it.

Does anyone have any experience or insight into handling such a large inventory and our planned approach?

The products will not have to be managed via the front end and instead will be imported with their various categories and attributes. Any changes we plan to do from a staging database and synchronise accordingly.

Thank you for any insight.


texts:
In Drupal 7 t() this warning was present:

  You should never use t() to translate variables

In Drupal 8, well, it's Drupal 8, who knows where to even look?

I tried

StringTranslationTrait::t
t()
LocaleTranslation::getStringTranslation()

and haven't found a similar warning. But absence of evidence is not evidence of absence. Is it OK now to use a variable?


texts: Search results showing duplicate entries

texts:
For some reason the search results show duplicate entire with the view I have, I also have  distinct on under the query options so it doesn't show duplicate nodes, I cant figure out why its doing this for the life of me.

This is the view I have of it.

Any input is appreciated.

Edit: It seems to only do this when I search for  only 2 words, for example "should I" "can you" "this that" "now here" ect...


texts: Send POST data to payment gateway on form submit

texts: I am running drupal 6 and currently working on payment gateway integration module. I have a basic form in my module which will collect billing information from the user. In the form submit handler, I need to create certain parameters and send the post data to the payment gateway URL. How do I handle this? Any help is appreciated.


texts: How should the search autocomplete module be configured to recognise spaces?

texts: We're using the Search Autocomplete module to power a site search for users. Unfortunately, it doesn't like spaces in the username. Has anyone faced this and found a simple solution?


texts: Need a current page's "Content Type" passed to a node.html.twig template (for a different content type) on page load, AND after ajax call

texts:
I'm trying to get the Content Type value of a node page (that the user is currently visiting - let's call it CT-1)... and feed that value as a variable into a DIFFERENT content type's node.html.twig template (CT-2). This CT-2 template is being used in a View output, displaying on a CT-1 page. Here's my code...

function custom_mods_preprocess_node(array &$variables, $hook) {
   if ($node = \Drupal::request()->attributes->get('node')) {
     $variables['pageNodeType'] = $node->getType();
   }
 }

Then I print out the pageNodeType variable into CT-2's node.html.twig template like so...

{% if pageNodeType == 'TYPE' %}

TEST

{% endif %}

This all works perfectly on page load. But when the view output is filtered with AJAX (via an exposed filter), pageNodeType becomes NULL, and therefore the "if statement" breaks with the CT-2 template.

What can I do to keep that variable active after an ajax update?

I tried leveraging..

\Drupal::request()->headers->get('referer');

..to pull the previous page, but it seemed like quite a task to get the Content Type via this approach. Is there a better way.

Thanks!!

Edit: May be related to this post as well... but no answers? Views with ajax get current node in hook_views_query_alter


texts: How to get visitors count of a page created using views

texts: I have created a page in Drupal using views. Is there any option to get the count of visitors that visit the page?


texts:
I would like to know how to correctly define the highwater property when using Migrate for Drupal 8. I am doing an import from a legacy non drupal database and I should be able to update only the relevant nodes whenever a column highwater changed. According to the official documentation, the solution is to use a highwater property. How to declare it? Is it a property to be set in the Plugin mapping class or is it an entry in the migrate.migration.*.yml file?
Thanks!


texts: Why aren't the titles of my items in a new product type not displaying at check out? - Commerce

texts:
I am building a store based on Commerce Kickstart.  I am using one of the original product types and two new product types that I created by essentially copying the field and display settings in the content type and product variations settings.  After a lot of fiddling around I have everything displaying properly, except in a couple of places in the check out process.

1) In the cart ( mysite.com/cart# ) the line items that I created display the sku of the item but not a "view product" link.  Where can I change this?

2) In the review order page ( mysite.com/checkout/ordernumber/review ) the line items of the product type that I created don't display the item title, while the item type that was there originally does.  Where can I change this?


texts: How do I give access to only specific roles to buy at my store?

texts:
I have a platform with roles for moderators, editors, teachers and students. Only student roles should be able to buy courses and the other roles should not be able to buy courses or see any of the commerce store information e.g. cart etc. How do I set their permissions? All roles still see "cart" in the menu bar. Am I missing a setting in permissions? There doesn't seem to be a permission for cart, only checkout permissions.
What am I missing?


texts: How to add Clear button for views exposed filter?

texts:
I created a content type and View with Filter Criteria for my project, when I click the Search it shows the appropriate results.

But there is no option to clear the Search Fields and redirected to previous page (View).

In my requirement I need to keep a [clear/cancel] button with [search] button.

How to add [clear/cancel] button with [search] button in View?


texts: How to redirect a user to the Last Domain Browsed

texts:
I have a question, what will i do to save the last domain a user was on either on a cookie or a session or anythin else that will work so that whenever they type the main domain they are redirected to the sub domain they were on last even if the browser is closed. i have about 3 sub domains and the main domain. i am using domain access. for example

main.com <== TLD
sub.main.com <== Sub Domain 1
sub2.main.com <== Sub Domain 2

user types in main.com and was browsing sub.main.com yesterday and instantly gets taken to sub.main.com
 and on another machine user types main.com and gets taken to last domain e.g. sub2.main.com
Help!