texts: Database general error: 2006 MySQL server has gone away

texts:
Recently I started getting an error every time I try and add a content no matter what type.  This is the error that shows up in the browser:

  Additional uncaught exception thrown while handling exception.

  Original
  PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT COUNT(cid) FROM {comment} WHERE status = :status; Array ( [:status] => 0 ) in comment_count_unpublished() (line 313 of /Applications/MAMP/htdocs/modules/comment/comment.module).

  Additional

  PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:154:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT COUNT(cid) FROM {comment} WHERE status = :status; Array ( [:status] =&gt; 0 ) ";s:9:"%function";s:27:"comment_count_unpublished()";s:5:"%file";s:56:"/Applications/MAMP/htdocs/modules/comment/comment.module";s:5:"%line";i:313;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://localhost:8888/?q=node%2Fadd%2Farcade-project&amp; [:db_insert_placeholder_7] => http://localhost:8888/ [:db_insert_placeholder_8] => 127.0.0.1 [:db_insert_placeholder_9] => 1338336955 ) in dblog_watchdog() (line 154 of /Applications/MAMP/htdocs/modules/dblog/dblog.module).

I also get the following error in my php error file:

  PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in /Applications/MAMP/htdocs/includes/database/database.inc:2136

  Stack trace:
  0 /Applications/MAMP/htdocs/includes/database/database.inc(2136): PDOStatement->execute(Array)
  1 /Applications/MAMP/htdocs/includes/database/database.inc(664): DatabaseStatementBase->execute(Array, Array)
  2 /Applications/MAMP/htdocs/includes/database/database.inc(2315): DatabaseConnection->query('SELECT expire, ...', Array, Array)
  3 /Applications/MAMP/htdocs/includes/lock.inc(167): db_query('SELECT expire, ...', Array)
  4 /Applications/MAMP/htdocs/includes/lock.inc(146): lock_may_be_available('theme_registry:...')
  5 /Applications/MAMP/htdocs/includes/theme.inc(447): lock_acquire('theme_registry:...')
  6 /Applications/MAMP/htdocs/includes/bootstrap.inc(427): ThemeRegistry->set(Array)
  7 [internal function]: DrupalCacheArray->__destruct()
  8 {main}
        thrown in /Applications/MAMP/htdocs/includes/database/database.inc on line 2136

I am having a little trouble deciphering these error messages. Could anyone help me understand what's going on here?


texts: Action to be triggered on Comment Approval

texts: How can add new rule to trigger when a comment approve, in Drupal 7?


texts: How to hide a DIV if ther's no value in that Content in a node--customtpl.tpl.php file

texts:
How can I hide a DIV if ther's no value in that Content in a node--customtpl.tpl.php file? I have used a code something like this, but if hides everything weather it has data or not. Can anyone help me with this code?

I want to hide this "special-offer" div if there's no value in that field in drupal (this_is_a_drupal_field).

<?php
if ($content['this_is_a_drupal_field'])
  {
  print "
";
  print render($content['this_is_a_drupal_field']);
  print "
";
  }
?>

<?php if(empty($content['this_is_a_drupal_field'])){ ?>


texts: How to stop / hijack a infinite redirection loop with a redirecting rule

texts:
I'm using Rules and Detector module to prevent IE < 7.0 users from browsing the site.

I've setted up a rule, executed when UA (Detector) properties are loaded. Dependings on user agent value, the rule have an action, which consists in redirecting user to a particuler node (explanation).

This works well, so well that redirection is always active, even on my destination node. So it lead me to kind of 'Too much redirection error'.

I don't manage to put another condition, like Path has url alias; that will prevent all undesired redirections.

Do you know what I'm doing wrong?
Please, don't hesitate to suggest me another way to achieve this redirection properly.


texts:
Where is the book navigation block in Drupal 8?

The structure guide for Drupal 7 says you just need to turn the navigation menu on by enabling the block.

  ...One navigational aid you can use is the book navigation block,
  which you can enable on the blocks page administer >> site building >>
  blocks (Drupal 5 and 6) or Dashboard >> Structure >> Blocks (Drupal
  7). Enabling this block will turn on a menu that shows where the user
  is in your book; the menu is only visible when viewing the book.

But there doesn't appear to be a "book navigation block" in Drupal 8 as far as I can see.

Where is this block hiding in Drupal 8?


texts: How to recover content/configuration from a hacked site

texts:
I have a situation where I am faced with two sites which were vulnerable to the Drupageddon SQL injection exploit.  I am looking at what is the best strategy for recovering these websites.  Given that the sites were not patched within the alloted window of time, I am forced to assume they have been compromised.

There is a lot of information on what to do after one's Drupal site has been hacked; but one question that is not really addressed is the workflow for recovering content from the compromised site.

In the case of one site, no pre-exploit database backup is available. For the other website, there is a pre-exploit database backup; however, there is a large amount of post exploit content which has been created/updated.

What would be the workflow for recovering content (other than recreating everything by hand).  Issues I can think of are:

How to clean up existing content?
What tools to use to achieve this?
How to get the content out of the old site and into the rebuilt one?
If site is being rebuild from previous DB backup does it make sense to try to only import content which has changed or been added since previous backup? or does it make more sense just to re-import everything?
How to recover site configuration? Would it be possible to create features and then 'clean' them before installing into rebuilt site?


texts: Override site's registration restriction on accepting invite

texts:
We have a custom module that uses the invite module to send invitation to non users. Our site is set to allow registration only by administrator to avoid spam. When the invitees accept the invite they cannot register as its not allowed by the site. Is there a way to override registration restriction when invitees try to register?

We are looking into duplicating registration form on another route then routing the invitees to register there instead of default route.

Any other suggestions to handle this situation?


texts: Force redirect back to password form until password got set after one-time-login

texts:
When my users click on a one-time-password-reset link then I log them in and then show them a page where they can choose their new password.
Problem is that there are two additional links on that page (one for dashboard and some other one) and they can click on them and visit the linked pages.

I want that until they change their password they cannot navigate to other pages. For now I managed to set a custom value in $_SESSION, but I can't figure out how I can intercept their further request (once they land on password change page). How can I check for such a session value and redirect them back to password-reset page (if they haven't changed their password yet) and allow them to navigate to other pages only after they changed their password?


texts: Use theme function to change the search form input type

texts:
I use the default search block provided by Drupal.
I want to change the type of this search text box from "text" to "search." How do I do this using a theme function?


texts:
I have the Sitemap module installed and it creates an unordered list of my chosen menu's items.

Main Menu looks like this:

Home
 - submenuitem1
 - submenuitem2
 - submenuitemn

Services
 - submenuitem1
 - submenuitem2
 - submenuitemn

References
 - submenuitem1
 - submenuitem2
 - submenuitemn

Links
 - submenuitem1
 - submenuitem2
 - submenuitemn

How can I add DIVs to each main menu item with its subitems ( Home+subemenuitems, Service+submenuitems etc.) ?

I managed to override site_map_menu_link to give it some depth at least.

function MYTHEME_site_map_menu_link(array $variables) {
    $element = $variables['element'];
    $sub_menu = '';

    $element['#attributes']['class'][] = 'menu-' . $element['#original_link']['plid'];
    $menu_id = 'menu-' . $element['#original_link']['plid'];
    $link_depth = 'depth-'. $element['#original_link']['depth'];

    if ($element['#below']) {
      $sub_menu = drupal_render($element['#below']);
    }

    $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    return '

' . $output . $sub_menu . "
\n
";
}


texts: How to make sure that /taxonomy/term/24/WHATEVER gives 404?

texts:
Google found up some weird links on my website and has started indexing stuff like /taxonomy/term/24/WHATEVER. I don't want that.

I also don't want to find all these URLs manually, ideally they will turn up in Google Webmaster's list of broken links and I can fix them using that list.

Unfortunately in the taxonomy term view at PAGE SETTINGS it just says Path: /taxonomy/term/%. Is there a good way to respond 404 on /taxonomy/term/24/WHATEVER addresses?


texts: Author Fields into a content type template

texts:
I'm trying to load some of the information from the author into a node--article.html.twig. So I can provide some information like bio, social media,etc.

Similar to this...

I can easily get the author_name and the author_picture because these two are given by the template. I added extra field at admin/config/people/accounts/fields in this case the only extra field is field_bio

I try to use the include to add this user field into.

node--article.html.twig

{{ author_name }}

{% include('field--user--field-bio--user.html.twig') %}

This what I have on the field template - field--user--field-bio--user.html.twig

  {%- for item in items -%}
      {{ item.content }}
  {%- endfor -%}

Hello

The word "Hello" is been display on the node--article.html.twig; however, the item.content which is my field information is not been load. =(

I also try to dig up into the user variables by using {{ kint() }} to see if there is this information and I did not find it either.

I have seen some example with a module, which I have avoid them because this is for a contrib theme and I do not want to have any module dependency. I have done this many times with DS but I do not want to use any extra module.

So I have couple questions...

Should I use include for this use case or not ?

If I have too, what I'm doing wrong ? Why the item.content is not been load ?
If I should not use it in this use case, what should I do instead ?


texts:
I'm using Drupal 7, Context and Multisites.  A Context determines which Block to render based on the domain's URL.  This works fine for the live site with the actual URL.

My dev environment uses Domain aliases to make it work.  For sampledomain.com, I have an alias for sampledomain.local.  Context seems to ignore this alias and skips rendering the block on my dev machine.

Is this a known bug with Context/Multisites?  Or is there an additional configuration option to make this work?


texts: Layering fields on top of each other in views

texts:
I use Drupal 6 with Views 6.x-2.10.

I have a spotlight region on my page where I want to display a picture and a description of the next upcoming event.

I want the description text to be on top of the image, in a div with half transparent background, sort of [---image--[description]-].
The image and description are fetched with a view. How do I style it so that one field in the view (the description) is on top of the picture field?

It would be easy to do if I could get the content in

, but the view puts a hell of a lot of other divs around it, making it impossible to have the description inside of the picture div.

What should I do?


texts: Override the output of views with angular directives

texts:
I use Angular material in my Drupal 8 site (perforce!!!) and I have some problem with views.
 I want to override the output of views with custom text:

but as we all know views is strict with html tags and angular material uses custom directives for his purposes...

Question:

How to solve this problem?

How to make views to don't trim angular material directives?

Dose any one has solution for this?

UPDATE: The problem is that nothing is rendered correctly...

For example.

angular material card is this:

but the view shows this result:

This means that angular directives ware trimmed by Drupal, and that's why view shows incorrect result.


texts:
I have two questions.

I wish to build a website that will use a three column look. I was told to use panels, I found it easy to use.

My question is I have a menu bar, all menus point into different panels, the reason I do this every page I have has different blocks in it, some of these blocks point to sub-panels. (A., is there a "smarter way" of doing this?)

B., my main question how can I use ajax, so when somebody clicks any of the links on my menus only the panels reload, not the full site?

Regards,


texts:
The data I need are reported by Devel to be objects of stdClass.
What is that class? Is it a $node, $term or $page? Without guessing, how do I determine what that object is, in order to extract data?


texts: How do I insert a view into an article based on filters that are only defined at node publish?

texts:
I have a website that uses data in tables. I want my copywriters to use a filtered view which will be in the node edit form to create the view they want for a particular article then somehow insert code into the page so that the data shows.

The views that are created will be different every time so this cannot be a pre-defined view as such, more a view with the filters that they decide to use at the time they publish the article.

Does anyone know how I might achieve this?


texts: Can entity references have "types" like links in Jira?

texts:
Suppose I have a node that represents a task, or a to-do item:

Node 1: Instructions for building a drivable car

I want to link this node to another node, such as a sub-task of the original node:

Node 2: Instructions for assembling an engine (Sub-task of Node 1)

Now suppose I have another node that is caused by one of my original nodes, but is not a sub-task of it.

Node 3: How to obtain a driver license (required by Node 1)

The entity reference from Nodes 2 to 1 is of type sub-task while the link from 3 to 1 is of type required by (or maybe related to, whatever).
When viewing Node 1, it might be helpful to display a view of referenced nodes, but rather than just showing the nodes, it would be useful to show the relationship type as well:
Items related to "Instructions for building a drivable car":

| Link Type      | Node                                  |
|--------------------------------------------------------|
| Parent Task of | Instructions for assembling an engine |
| Requires       | Getting a driver license              |

Applications such as Jira handle this via link types. Is functionality like this available within the Drupal ecosystem? Alternatively, what would be a logical way of implementing such functionality?


texts: How do I limit a taxonomy dropdown exposed filter to the terms used by nodes in view results?

texts:
I'm trying to create a custom node search view, that takes Taxonomy terms as a filter (dropdown - autocomplete not an option). The problem I have, is that there could be >1000 terms and I would like to restrict the dropdown to show only the taxonomy terms that are already in use by the nodes returned in the initial view results. Does this make sense?

Can anyone advise if this is possible, and if so, how best to achieve it?


texts: How to display the calculated priced of commerce products?

texts:
I have some product pricing rules that adjust the price a customer will pay.  How can I display this adjusted/calculated price to the customer?  I want to display the calculated price like a field the way the base price is displayed.

Is there a field display setting (for example at /admin/structure/types/manage/product/display) that will do this?
Does it have to be done through rules (if so what event and actions should be used)?


texts:
Trying to get a calculation at the end of an Aggregated Table or even Pivot Table in Views, but as it seems to be a bit of a two step process, I can't figure it out for the life of me...

I have the following table of user skills, pulled together using aggregation (for a number of reasons the way the data has to be gathered). I can also use a pivot to the same result.

I want to then be able to evaluate overall skill of each user by counting the Lows, Mediums and Highs for each user, multiplying them by 1, 2 and 3 respectively, and then add them together to a Total Skill value, per below:

Any ideas on how to do this, or an appropriate module that would give me this result?


texts: Stop Advanced Forum cutting off the username?

texts:
Im using the Advanced Forum module. Many of my users have long usernames which are being cut off (in the author information when they post a comment). Is it possible to lengten the limit before the text is cut off?

I cant see any settings for the Forum or Advanced Forum modules. Below is a theme hook that creates the author information (dont know if this is the right track or not).

/**
 * Theme function to show simple author pane when not using Author Pane.
 */
function theme_advanced_forum_simple_author_pane(&$variables) {
  $context = $variables['context'];
  // Sending the context rather than the account makes it work for anon comments.
  $name = theme('username', array('account' => $context));

  $account = user_load($context->uid);
  $picture = theme('user_picture', array('account' => $account));

  return '
' . $name . $picture . '
';
}


texts: How can I allow users to search for other users based on profile information

texts: I have two profiles for my users. First, is "Infomation" machine name "main" and second "About Me" machine name "about_me" and I want to create a page where other users can search for users with specific attributes in their "Information" or "About Me" profile. I'm just starting out with drupal 7.10 so any help would be appreciated.


texts: How to specify entity reference fields when programmatically submitting to user_register_form

texts:
You'd think this would be easy. I'm calling drupal_form_submit('user_register_form', $form_state)
to automatically register users after they have completed filling out a Webform.

But I have some Entity Reference fields in my user profile and form_validate is not happy with what I am submitting for them. All of the ER fields are references to taxonomy terms. Some of them are single-value fields, some of them are unlimited value fields. They have various widgets attached such as Select List, Autocomplete, Checkboxes and Radio Buttons. Some of them are Required fields, others are not.

I've tried setting all of the following in $form_state['values'] before submitting the form:

$form_state['values']['field_foo']['und'] = $tid;
$form_state['values']['field_foo']['und'][0] = $tid;
$form_state['values']['field_foo']['und'][0]['target_id'] = $tid;

But Drupal still throws out 'An illegal choice has been detected' when it comes to validate the field, or sometimes a 'Field is required' error.

What am I doing wrong and how do I go about figuring out the right way to specify each of the fields?


texts: Changing the field date type from 'datetime' to 'unix timestamp' without losing data

texts:
I am investigating how could I convert the date format in the 4 database tables: field_data_field_article_publication_date from the actual datetime format:
2013-09-10 12:43:03  to its unix timestamp equivalent: 1378816983
with a minimal negative impact on data integrity of the actual articles on a production environment.

UPDATE

My guess scenario would be:

Update the field type in my feature: MYFEATURE.features.field.inc // changed to timestamp [EASY]
Alter the table field structure from 'datetime' to 'timestamp' in a hook_schema_alter [EASY]. This should be performed using db_change_field().

RISKY AS I CAN LOSE DATA WHEN MOVING CONTENT. I MIGHT TRY TO DUPLICATE COLUMN DATE (INTO DATE2) FIRST.

I NEED HELP HERE: Convert all existing dates for articles found in 'field_data_field_article_publication_date' table to the new format unix stamp. [NOT SURE HOW]

Any further help?

I am interested in minimizing querying time by using MYSQL: UNIX_TIMESTAMP(date) somehow.

My approach on No.3

loop over all 4 tables {

   - create a new column date2 of type: int (or datetime?)
   - copy all dates from date to date2 passing them through strtotime()
   - delete column date
   - rename column date2 to column date

}

That would be a start in MYMODULE.install:

function MYMODULE_schema_alter() {
//...loop over 4 tables
  $schema['TABLENAME1']['fields']['DATE2'] = array(
    'type' => 'int', //or timestamp
    'not null' => TRUE,
    'unsigned' => TRUE,
    'default' => 0,
    'description' => 'Field added by my_module',
  );
//…
}

/**
 * Content types using date fields should be using timestamp instead datetime
 */
function MYMODULE_update_7192() {
//define their names or get them from schema
$tables = array('TABLENAME1', 'TABLENAME2', 'TABLENAME3', 'TABLENAME4');

foreach ($tables as $table) {
       //create a new column date2 of type: int (or datetime?)
       $schema = drupal_get_schema($table);
       db_add_field($table, 'DATE2', $schema['fields']['DATE2']);
       db_update($table)
      ->fields(array(
          'DATE2' => strtotime('DATE'),
         )
         )
       ->execute();
      db_drop_field($table, 'DATE');
}
}


texts: Creating a List View and Thumbnail view in Drupal 7 view

texts:
I created a view but I am hoping to create two possible viewings of it.

Basically, it's showing it in either List View or Thumbnail View. Now, one option would be to create two views and showing one of them by default and hiding the other; hence toggling each when the button is pressed. But I was hoping to find some more efficient less resource intensive solution.

Thumbnail view

List view

Thanks.


texts: How to programmatically add a filter that requires a relationship to a view

texts:
I have a view filtering out a specific node by nid, and it was working until I added a relationship. I want to filter based on the nid of the target of the relationship, not the base table nid. Here is my code, pre-relationship:

$options = array(
  'operator' => '!=',
  'value' => array('value' => $nid),
);
$view->add_item ($display_name, 'filter', 'node', 'nid', $options);

I tried replacing nid with the view relationship base field alias, but that didn't seem to be recognized at all. How do I indicate to Views that this filter should work via the relationship?


texts:
I faced with problem while fetching query results, my code:

$result = $query->execute();
$array1 = $result->fetchAllKeyed(1, 0);
$array2 = $result->fetchAllKeyed(2, 0);

But the $array2 is empty, so fetchAllKeyed cut all values from $result.

I'm already tried to use the following:

$query2 = clone $query;
$result = $query->execute();
$result2 = $query2->execute();
$array1 = $result->fetchAllKeyed(1, 0);
$array2 = $result2->fetchAllKeyed(2, 0);

It's works, but I don't want do two queries instead of one.

So, how can I do two (or more) different "fetch" from one result?


texts:
My full site is using SSL for all pages, and working fine.

But I noticed CSS files are included without HTTPS prefix, while I have set the base URL in my settings.php file as:

$base_url = 'https://my.domain.name';

How can I include all CSS files with HTTPS?


texts:
I have migrated my Drupal 7 website to Drupal 8. The content types are showing title as optional and when we save a node without adding the title it's giving the fatal error.

How can we make the title field compulsory?

Note: I know title field is required by default, and it is required by default in my Drupal 7 site. But after migrating the site to Drupal 8 it's not showing required. Is it possible if export content types configuration from my new site and edit the configuration and import them again to fix this issue?


texts:
I am trying to add an attachment to an email from a form_submit. I can see the attachment loading in the hook_mail() before the email sends, but no attachment is coming through. I also tried to use the swiftmailer_swiftmailer_attach() hook and that doesn't work. The emails are coming over with Content-Type: multipart/alternative;

Here is the code:

// from submitForm()
$params['message'] = $body;
$mail_manager = \Drupal::getContainer()->get('plugin.manager.mail');

$mail_manager->mail('so_assets', 'banner_email', 'test@test.com', \Drupal::languageManager()->getDefaultLanguage()->getId(), [
  //'content_type' => "text/html; charset=UTF-8; format=flowed; delsp=yes",
  'from' => 'test@test.com',
  'message' => $body,
  'myattachment' => $store_logo[0],
]);

// in .module file
function so_assets_mail($key, &$message, $params) {
  $options = array(
    'langcode' => $message['langcode'],
  );
  //var_dump($params['myattachment']); die(); // I can see the managed file ID here and load it.
  switch ($key) {
    case 'banner_email':
      $message['from'] = \Drupal::config('system.site')->get('mail');
      $message['subject'] = t('New Request');
      $message['body'][] = $params['message'];
      //$message['params']['files'][] = \Drupal\file\Entity\File::load($params['myattachment']);
      break;
  }
}
// I tried this, with and without the file attachment commented out in the hook_mail()
function so_assets_swiftmailer_attach($key) {
  return \Drupal\file\Entity\File::load(5130);
}


texts: Separate home page per domain in multilingual setup (i18n)

texts:
I have a multisite Drupal with 2 domains, that should have separate home pages, but I can't get it working. I've created a node for each.

Now, I've tried to configure it in the Configuration > Site information > Default Home Page panel. There is note on top of the page: "This form is domain-sensitive, be sure you select the proper domain before saving." ; Therefore I guess that "home page" parameter is per domain?

But it doesn't work : each time I change this field (value : node/92), all domains are affected.

Is it supposed to work? Is there another way to do it?


texts: Change the default timezone variable_get from views

texts:
What I want is to change the way drupal views get the site's timezone setting. I want to set it manually in code.

Searching through the files I noticed that the function "views_get_timezone()" in sites/all/modules/views/includes/handlers.inc @1182 (drupal 7) is responsible for getting the timezone and setting the session.time_zone in mysql, but when I change it nothing happens.

Any suggestion anyone for this or any similar solution? I just want to make a site with multiple timezones for anonymous users so I want to change the session.time_zone in mysql according the user location.

Thanks


texts:
I use drupal 8 and I want to add a new view page to taxonomy view.

I tried to dublicate default taxonomy page view and changed path

from: taxonomy/term/%/
to : taxonomy/term/%/newpath

but this is not working. why would this not work?


texts: I just want to move this login button up above the create new account and request new password. How?

texts: I want to move login button up above other two options create new and request new password links. what I do I have to do. I am new to drupal


texts:
I try to rewrite the node output and i don`t get it. This script produce only

without any content.

$rows = array();
$cols = array();

$cols[] = '
' . $node->title[0]['value'] . '
';

$colnum = 0;

foreach($node->field_body as $col){
  $colnum++;
  $cols[] = '
' . $col['value'] . '
';
}

$rows[] = array('data' => $cols);

print theme('table', $rows)


texts:
I am dealing with a white screen of death I feel like I've pin pointed the issue, but have no way of knowing how to fix it.

This is my first time using Drupal, and my first time running into this issue. Are these errors that are in my log, related to problem? How would I go about fixing it?

Any and all help is appreciated as I have already consulted the handbook and have not found the solution to this issue by doing so.


texts: How to use use db_rewrite_sql() with db_query() in D7?

texts:
I read article where it was written to use db_rewrite_sql($query). In Drupal 7, you need to use addTag('node_access') along with `db_select().

I have  a query with 8 columns and 4 conditions; for simplicity I am using db_query().

How can I use db_rewrite_sql() with db_query()?


texts: Views theming: How to grab the contextual filter?

texts:
My setup is really simple. I have a taxonomy view that takes two contextual filters:

Has taxonomy term ID (with depth)
Has taxonomy term ID depth modifier

Due to a new request I need to be able to change the footer of the view based on the contextual filter. Since the contextual filter isn't inside the [fields] array of the view how can I access its value in my template file?


texts:
When creating a query using db_query in my module I want to make sure it's as secure as possible. So I'd like to use placeholders in my 'WHERE' clauses. The problem I'm having is how to use placeholders when the array values to be used are PHP variables. So for example:

WHERE el.field_experience_level_value='$level'

Is what I'm normally using and it works fine. But then I changed it to the following and added the array part at the end like so:

WHERE el.field_experience_level_value=':level'
...some more code
array(':level' => '$level')

I get no error but it doesn't return those results. So my main question is, how do I add a php variable such as $level above (already defined in previous code, not here) to a placeholder?


texts: How to expand/collapse text in WYSIWYG w/CKEditor

texts:
In full nodes of a certain content type (using panels), I would like to display a text summary with a read more link to display full text, then a show less link to collapse.  I had smart trim enabled which allowed a read more link, but the page simply reloaded to the trimmed summary after clicking the link. I am using WYSIWYG with CKEditor.

So far I have tried jquery expander and expanding formatter.  Jquery expander didn't have any affect on the full text, expanding formatter displayed an ellipsis at the designated trim spot, followed by the full text, and a read more button after the full text.  So, essentially neither worked.

I tried js injector, plus this code and the full text showed -- no effect.

Is there something about WYSIWYG or CKeditor that prevents this function?  Suggestions?


texts: How to limit country list for address form drop-down?

texts:
In my store I defined list of supported billing and shipping countries at store settings. This list is respected during checkout process - limited list of countries is shown when customer is entering the address. But when user is on "Address book" tab of user profile page and wants to add new address list is not limited, but all countries are allowed there.
How can I limit list of displayed countries when editing address at address book user profile tab?
I tried using hook_form_alter() but I don't see country drop-down there?
Also tried hook_preprocess_input() and I see other fields, but not country drop-down.
theme_preprocess_field() didn't help either.
And of course, I didn't find that option in back-end.


texts: What is the best approach to write hooks?

texts:
I had to use some hook functions on almost every project I worked, right now I am working on a project ( basically to collect donations and maintain organizations list ) where I need to write lots of custom code, at first I started to write all the code in theme i am developing, later I realized that its not going good with all the functions in theme because some hooks need to be written in modules so now some of the code is written in module and some is in theme which breaks the functionality when switch theme or with admin theme.

So I am thinking to write all the code again but not sure what is the best approach to write custom code in a drupal project.

if all code goes in custom module some of the theme sections needs to be rebuild and I didnt find any proper article on net on this


texts:
I'm trying to load and get the file using entity_metadata_wrapper. this is my code

$wrapper = entity_metadata_wrapper('node',$variables['node']);
$file_field= $wrapper->field_library_file->value();
$variables['file'] = theme('file_link', array('file' => file_load($file_field['fid'])));

and <?php print $file;?> outputs nothing. I've found this in this address . how can I get set of files that belongs to a node.

thanks.

UPDATE:

this is the code I use for theme hook suggestion, this code is on top of the the above code.

$suggest = "page__node__library";
$variables['theme_hook_suggestions'][] = $suggest;

I created a page and renamed it to page--node--library.tpl.php and <?php print $file;?> is in this page.


texts: Drupal Content Type Data Become Label for Field on Another Content Type

texts:
I'm using Drupal 7, and on my Drupal website I've created a content type. This content type has 2 fields: field name, and code. I need to create another content type, and (on this content type) fields based on the data of the "Name" field of the previous content type.

For example:

Content type ABC: content

Name  | Code
AAAAA | A
ABABA | B
ACACA | C

Content type DEF: fields

AAAAA (widget: textfield)
ABABA (widget: textfield)
ACACA (widget: textfield)

How can I achieve this?


texts:
Why translate tab only available for super Admin in node & taxonomy form.
how can i view this tab & also button of save & translate for both Node & Taxonomy
to another roles (Editors & Translators), what is the proper permission access
should be given to show the translation tab ?

Forget to mention, this happen only when the node or content is unpublished,
but if its published the tabs appear normally.


texts: How to alter incorrect Join type generated by Views?

texts:
I am suffering from a bug in Views 7.x-3.11 detailed here in relation to filter groups. Views incorrectly adds INNER JOINs when LEFT joins would be correct.

I am trying to alter the $query object using the code ( this approach is not based on any documentation, but simply a guess ):

function mymodule_views_query_alter(&$view, &$query) {
  if($view->name == 'my-view' && $view->current_display == 'my-display') {
    $query->table_queue['field_data_field_listing_type']['join']->type = 'LEFT';
  }
}

However this change causes the View to generate an ajax error "Fatal error: Call to undefined method stdClass::build_join in sites/all/modules/views/plugin/views_plugin_query_default.inc on line 1313".

Any assistance?


texts: Working with views, better use various displays or create more views?

texts:
The main task is:

Create a couple of pages with terms of a specific list of taxonomy vocabulary. (Its about 20+ pages).

So, its simple, create a view with a particular route, and set to display taxonomy terms, set the right vocabulary to display, set exposed filters and so on.

Now comes the question, speaking in perfomance, its better create a view to each page (with almost the same config, only vocabulary terms is different), or create just one view and create a display for each page?

Both scenarios work's great, using just one view for all pages and using a view for each page, but which one can be the best alternative for this case?

Looking in Working with Views in Drupal 8, there is nothing about perfomance and best practice. Any advice are welcome.


texts: Exposed filters of a view printed in different places

texts:
How can I get a view to expose filters that are drunk rendering separately.

Have three filters exposed but I do not know how to get it to fit the layout correctly.

Is it possible to achieve this type of layout with drupal 7?

I have an image that explains:

Thanks.


texts: Custom block automatically adds code when edited in admin

texts:
I have written some HTML in custom block, but every time I open the editor in Drupal Admin UI some extra code is added to the block. Essentially, this means I have to remove the added code every time I want to edit the file which is becoming quite annoying. I am using Drupal 8 on the Acquia Cloud. Does anyone know what might be the cause of this?

Edit 1:

I'm using CKEditor

My HTML goes from this

Test

       <button>

       </button>

Sign In

Sign up

To this

Test

      <button></button>

      <button></button>

Sign In

Sign up

Edit 2:
I'm also getting the following code added to a second block

&nbsp;

<button aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" data-target="#navbarSupportedContent" data-toggle="collapse" type="button"></button>


texts: How to define an internal link as parent in mymodule.links.menu.yml?

texts:
How do I create a menu link programmatically to a node that I can use as a parent for other links?
In MYMODULE.links.module, I defined some links for my navbar:
MYMODULE.parent-fruits:
  title: 'Fruits'
  url: internal:/fruits
  weight: 0
  menu_name: food
MYMODULE.fruits-apple:
  title: 'Apple'
  parent: MYMODULE.parent-fruits
  route_name: view.fruits.apple
  weight: 5
  menu_name: food
MYMODULE.parent-vegetables:
  route_name: view.vegetables.page-main
  weight: 10
  menu_name: food
MYMODULE.vegetables-asparagus:
  parent: MYMODULE.parent-vegetables
  title: 'Asparagus'
  url: internal:/admin/structure/taxonomy/manage/card_group_private/add
  weight: 5
  menu_name: food

In this case, I expect to have a menu that looks like this:

Fruits (child-> Apple)
Vegetables (child-> asparagus)

When I go to the parent page, the link to the child should appear in the navbar menu (the parent tree should be expanded).
But what I actually get is:

Fruits (no children)
Vegetables (child-> asparagus)

The problem is caused by defining the menu link with url instead of route_name.  I know this because when I change the parent of fruits-apple to parent: MYMODULE.parent-vegetables, then I see Apple as a child of Vegetables.
When I remove parent from Apple, then it appears in the menu (without a parent), so I know the link is defined correctly.
I can also create the Fruits / Apple links in the menu UI, and those work correctly.
Regarding parent: the documentation says this:

Determining the parent menu_link name can be a little tricky at first.
If you know the path of the parent menu item, you would need to search
for it in all available *.routing.yml files (most text editors and
IDEs should allow you to search all files in a project) and find the
route name for that path. Then, you would need to search for the route
name in all available *.links.menu.yml files. The menu_link whose
route_name matches is your link. Alternatively, if you know which
module is defining the parent menu link (or one of the parent menu
link's children), you can go straight to that module and perform your
search.

Since these are node links, I checked node.routing.yml in the core node module, but I couldn't find the route to node pages.
So: how do I create a menu link programmatically to a node that I can use as a parent for other links?


texts: drupal image field the image doesn't show?

texts:
My drupal site has a content type called Published which has a image field.When I migrate the site from Win2003 server to  CentOS , all the Published node's image field doesn't show. It appears like this:

when I click the image name it shows in a now tab.

I had do some google,but no result . someone said the directory sitename/default/files should be set 777

but it is 777.

Any suggestions Thanks in advance.


texts: Create a form programmatically and display result on template

texts:
I'm trying to create a simple page with a form.
With the different filled fields I want to execute different EntityFieldQuery in the HOOK_form_submit. To finish I want to display the result of myEntityFieldQueryunder the form like aView`.

For the moment I created a module with HOOK_menu :

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

    $items['statistiques'] = array(
        'title' => t('Statistics Page'),
        'description' => t('Homepage for statistics'),
        'page callback' => '_homepage_for_statistics',
        //'page arguments' => array('form_example_form'),
        'access arguments' => array('access content'),
    );

    return $items;
}

A simple form here :

function statistiques_form($form, &$form_state) {
    $form['age'] = array(
        '#title' => t('Age'),
        '#type' => 'textfield',
        '#required' => TRUE,
        '#maxlength' => 3,
        '#size' => 3,
        '#weight' => 0,
    );

    $form['submit'] = array(
        '#type' => 'submit',
        '#validate' => array('statistiques_form_validate'),
        '#submit' => array('statistiques_form_submit'),
        '#weight' => 10,
        '#value' => t('Click Here!'),
    );

    return $form;
}

I have two functions statistiques_form_validate and statistiques_form_submit under hook_form

Then i send my form and others vars to my template like this :

function statistiques_theme() {
    return array(
        'statistiques_template' => array(
            'template' => 'statistiques',
            'variables' => array(),
        ),
    );
}

function _homepage_for_statistics(){
    global $user;

    $output = '';
    $vartest = 'my var test to template';

    $output .= theme('statistiques_template', array(
        'vartest' => $vartest,
        'form' => drupal_get_form('statistiques_form'),
    ));

    return $output;
}

My template look like this :

<?php print render($form['age']); ?>
<?php print render($form['submit']); ?>

I tried Example module, but this case isn't on this module. There is some cases which are close to my problem, after submit the form data are sent to flash message.

With my code the form doesn't work, I can't submit the form but I think it's a small problem... my real problem will come when I will need to display the result of my form validation to my template under the form or on another template. How can do that ?

Thanks


texts: Composer error installing Address module

texts:
I had a previous error with the Address module, here. Unfortunately the solution is no longer helping.

I'm installing the Address module as follows:

composer config repositories.drupal composer https://packages.drupal.org/8
composer require "drupal/address ~1.0"

Unfortunately I get the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package commerceguys/addressing (locked at v0.8.4, required as ~1.0) is satisfiable by commerceguys/addressing[v0.8.4] but these conflict with your requirements or minimum-stability.
  Problem 2
    - The requested package commerceguys/zone (locked at v0.7.1, required as ~1.0) is satisfiable by commerceguys/zone[v0.7.1] but these conflict with your requirements or minimum-stability.

I've tried the solution linked above, but it doesn't help. I've also checked I'm running the latest version of Composer (1.2.1).

Any ideas?

James


texts: Migrated data via XML doesn't import to nodes

texts:
Link to my previous question, which has info on data structure etc.

Now I've gotten my XML read into Migrate and content type and fields set up right (I think), but now I can't get the nodes to save. The import has the correct number of nodes, but they don't ever get imported. The wine examples in the documentation didn't say anything about using prepareRow() or anything when you are using XML. Where are my nodes? Can I pull out that data with Views even if nodes don't import? My end use for this is to arrange everything with Views.

EDIT

Here is my class:

<?php

class ItemNodeMigration extends XMLMigration {
public function __construct() {
parent::__construct(MigrateGroup::getInstance('itemnode', array('default')));
$this->description = t('Grab data in XML');

// There isn't a consistent way to automatically identify appropriate "fields"
// from an XML feed, so we pass an explicit list of source fields
$fields = array(
   'id' => 'ID',
   'type' => t('Description of producer'),
   'Owner' => t('Owner'),
   'Text' => t('Text'),
   'modifiedAt' => 'Date last changed',
);

$this->map = new MigrateSQLMap($this->machineName,
  array(
    'id' => array(
      'type' => 'varchar',
      'length' => 6,
      'not null' => TRUE,
    )
  ),
  MigrateDestinationNode::getKeySchema()
);

// This can also be an URL instead of a file path.
$xml_folder = 'http://example.com/item/';
$list_url = 'http://example.com/CompanyID/Items.xml';
// Each ID retrieved from the list URL will be plugged into :id in the
// item URL to fetch the specific objects.
$item_url = $xml_folder . ':id/desc.xml';

$this->source = new MigrateSourceList(new MigrateListXML($list_url),
  new MigrateItemXML($item_url), $fields);

$this->destination = new MigrateDestinationNode('migrate_module_itemnode');

$this->addFieldMapping('id', 'id')
     ->xpath('/@id');
$this->addFieldMapping('body', 'Text')
     ->xpath('/Text');
$this->addFieldMapping('type', 'type')
     ->xpath('/@type');
$this->addFieldMapping('owner', 'Owner')
     ->xpath('/@Owner');
$this->addFieldMapping('created', 'modifiedAt')
     ->xpath('/@modifiedAt');

}
}

EDIT2:
I have determined that my problem lies here:

    $this->map = new MigrateSQLMap($this->machineName,
         array(
                 'id' => array(
                 'type' => 'varchar',
                 'length' => 6,
                 'not null' => TRUE,
               )
         ),
         MigrateDestinationNode::getKeySchema()
    );

This isn't correctly mapping to my source's ID, which lies at Item/@id. How can I correct this?


texts: How to remove the separator between values of a multi value field in a Views result?

texts:
I'm working on a D8 project. I have a webform with multiple fields and one of those is a taxonomy term. The taxonomy term consist of the title and a file upload field. The admin uploads a file in the taxonomy, and in the webform selects which file/s should be visible to the end user.

In order to display those files to the user I created a webform submission view where I get the specific field. The point is that the field might return multiple values (taxonomy terms) which are separated by comma.

How can I remove that comma? In D7 you could choose the separator in mulivalue field but now I can't find something similar.

EDIT:
The last idea was to change the output in the template file.
So in views-view-field.html.twig I try to replace the comma with space in the  output of the field.

{% set output = output|replace({(',') : (' '),}) %}

What I get is the html of the view with a lot of debug informations but the view is not rendered as it should.
I get something like <!-- THEME DEBUG --> <!-- THEME HOOK: 'webform_element_base_html' --> <!-- FILE NAME SUGGESTIONS: *

Any idea why?


texts: Add (create) content access control with Reference from URL

texts:
I have created a node photo gallery. The display of the images is provided by an EVA view.
Two content types were created: One photo gallery and one image upload node. To the image node were added an image field (for uploads) and one node reference from URL field that references back to the photo gallery. The result being that when someone is viewing the gallery, there is a visible link to add an image. Clicking the link brings up the image upload widget. The user is returned to the gallery after uploading and saving the image. That works well.

All authenticated users have a photo gallery, and they can all visit the galleries belonging to others. But as it stands now, all can see the add image links on all galleries and use it to upload images to someone else's account. The reason for this being that the link is not part of the view but part of the content type (even when the view is deleted, the link still shows.) So the contextual filters in the view do not work in this case.

The link to the referenced node can be disabled in the Reference from URL field settings and could most likely be replaced by a direct link to the image upload node. But this does not prevent a smart user to upload an image to someone else's account directly from the URL.

Is there a way to implement a variety of access controls on the creation of content? All the access control modules I have seen use roles and/or view/edit/delete permission only. Core allows control of node creation but on a role basis only. The ideal would be a filter like in a view that only allows the author of the gallery to add new pictures but unfortunately the Reference from URL link is not part of a view.

Any pointer on how to solve this riddle?

Thanks. :)


texts: How to populate a node reference field based on the selected taxonomy term?

texts:
I have two content types and one vocabulary:

Service Categories - different categories of jobs. (VOCABULARY as the list is small and does not change)
Service Tasks - tasks that relate to an individual category
Services - record consisting of details related to a service performed

On the services page, I have a have a term reference field that allows the user to select the category of service.  Below that I have a node reference field that I would like to have populate the related task from which to choose once the category has been selected.

Without involving programming, is there a solution to my problem?  I am new to Drupal (using version 7) but am picking up the concepts quickly.


texts: What is the quickest way to dump a node to insert into a test case?

texts:
Is there a script, console, drush command etc that can dump a node in the format needed to create a test case?
How can I rapidly fill out
$this->drupalCreateContentType(['type' => 'bond',
  'name' => 'Bond',
  'field_bond_amt_issued' => '1000000000',
]);


texts: How I can unit-test APIs? Is there any method for asserting API response in drupal 7?


texts: Add line item quantity in block-commerce-cart-cart "title"

texts: I'm making the cart-content div hidden as the default (in the sidebar shopping cart block), only the title will be visible, when the user hovers on the block-commerce-cart-cart the cart-contents div will be visible to them. How do I show the user how many items the got it their cart when only the block-commerce-cart-cart is visible, which means adding the line item quantity into the header. Can anyone please help?


texts: Validation error every time on save comment form

texts:
Every time I try to leave comment on a content of a certain type I get this error:

  Validation error, please try again. If this error persists, please contact the site administrator.

Refreshing and resubmitting the comment manually does not fix the problem, I always get this issue. The content type in question is displayed via a Panels Node Template, if that matters.


texts: Error 404 when upload image in profile installation

texts:
I am installing a custom distribution, I have created a form:

my_distribution.install:

/**
 * Implements hook_install_tasks().
 */
function my_distribution_install_tasks(&$install_state) {
  $tasks = [
    "extra_configs" => [
      "display_name" => t("Extra configurations"),
      "type" => "form",
      "function" => "Drupal\my_distribution\Form\ExtraConfigsForm",
    ]
  ];

  return $tasks;
}

Drupal\my_distribution\Form\ExtraConfigsForm.php:

// more code ...

/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {
    $form['#title'] = $this->t('Extra configurations');

    $form['logo'] = [
        '#type' => 'managed_file',
        '#title' => t('Load logo'),
        '#upload_location' => 'public://logo/',
        '#upload_validators' => [
          'file_validate_extensions' => [
            'png jpg jpeg',
          ],
        ],
        '#required' => TRUE,
      ];

    $form['actions'] = ['#type' => 'actions'];
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Save and continue'),
      '#button_type' => 'primary',
    ];

    return $form;
}

// more code ...

Everything works fine but, when I get to that form and load an image I get an error in the javascript console, and i can't continue:

AjaxError:
An AJAX HTTP error occurred.
HTTP Result Code: 404
Debugging information follows.
Path: /core/install.php/%3Cnone%3E?element_parents=logo&langcode=es&profile=my_distribution&ajax_form=1
StatusText: Not Found
ResponseText: {"message":"No route found for \u0022POST \/core\/install.php\/%3Cnone%3E\u0022 (from \u0022http:\/\/my-distribution.local\/core\/install.php?langcode=es\u0026profile=my_distribution\u0022)"}

In watchdog i only see:

ID  Date          Type      Severity  Message
79  08/Oct 13:15  page not  warning   /core/install.php/%3Cnone%3E?element_parents=logo&langcode=es&profile=my_distribution&ajax_form=1&_wrapper_format=drupal_ajax

Drupal version: 8.5.7

What could be the issue?


texts: How can I embed a view in a template when passing view name and parameters are passed as variables?

texts:
Inside my paragraph template I have variables which contain category id and view machine name. So when I print them like this:

  {{ content.field_category }}
  {{ content.field_view }}

I get correct values.

Then I'm using twig tweak to embed view and if I embed it with hard-coded values, like this:

  {{ drupal_view('view_machine_name', 'embed_1', 33) }}

it also works. I hard-coded the same values my variables display from above.

Now I want to use my field values instead of hard-coded values:

{{ drupal_view(content.field_view, 'embed_1', content.field_category) }}

I get error like:

Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 266 of core/lib/Drupal/Core/Entity/EntityStorageBase.php). Warning: Illegal offset type in isset or empty in Drupal\Core\Entity\EntityStorageBase->load() (line 251 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

when I try to replace view parameter and:

InvalidArgumentException: Placeholders must have a trailing [] if they are to be expanded with an array of values. in Drupal\Core\Database\Connection->expandArguments() (line 738 of core/lib/Drupal/Core/Database/Connection.php).

When I try to replace category parameter.

I guess that content.field_category is not an int value and content.field_view is not an string, as this twig filter expects but I have no idea how to convert them to those primitive types?

Tried intval - it's not working

Tried number_format - also not working

I guess I would have to somehow get view machine name and category id directly from those objects but I don't know how to achieve that.

Tried content.field_category.id() and content.field_view.id()

Nothing works.


texts: How to run jquery function on every page load

texts:
I have a Views grid that contain images in DIV containers. I want these containers to have one of two possible heights 60px or 104px, depending on the images height. So I came up with this function (contained in a $(document).ready function())  that I have added in my theme's JS file.

  $('div.givarbild img').each( function() {
    var container = $(this).closest('div.givarbild');
    var pic = new Image();
    pic.src = $(this).attr("src");
    var picHeight = pic.height;
    console.log(picHeight);
    if(picHeight < 60){
        container.height(60);
    }else if(picHeight > 60){
        container.height(104);
    }

  });

Now, my problem is that this only works once, after clearing the caches in Config -> Performance. If I simply reload the page after clearing all caches in Drupal all DIVs are 60 px high and the container.height value is zero in the js console (Firebug).

How can I force this little function to run after every page load?

EDITED:
Hmmm, I am obviously doing something wrong here :-)... but with this code:

(function($) {
    Drupal.behaviors.related_content = {
        attach: function (context) {
            $('div.givarbild img').each( function() {
                var container = $(this).closest('div.givarbild');
                var pic = new Image();
                pic.src = $(this).attr("src");
                var picHeight = pic.height;
                console.log(picHeight);
                if(picHeight < 60){
                    container.height(60);
                }else if(picHeight > 60){
                    container.height(104);
                }
            });
        }
    }
})(jQuery);

... I get the exact same result. It works immediately after clearing all caches in Drupal 7 but not when I reload the page after that. Is there something fishy with my custom script itself?

EDITIED AGAIN: I post this change to my js code in case anyone else is having the same issue. This code does the same thing as the previous one, except that it works every time, and not just the first time after clearing all caches in D7. The only thing I changed was the method for getting the natural image height. It would be interesting to know why this latter code works though and not the first one... it actually works every time even without the added Drupal.behaviors rows.

(function($) {
    Drupal.behaviors.related_content = {
        attach: function (context) {
            $('div.givarbild img').each( function() {
                var container = $(this).closest('div.givarbild');
                $("<img>").attr("src", $(this).attr("src")).load(function(){
                    var picHeight = this.height;
                    console.log(picHeight);
                    if(picHeight < 60){
                        container.height(60);
                    }else{
                        container.height(104);
                    }
                });
            });
        }
    }
})(jQuery);


texts: Inserting "sponsored content" into a fixed position in a view

texts:
So this is an interesting scenario I'm faced with.  Lets say I have a content type called Article.  Within that content type there is a term that is tagged as "sponsored."  The content type also holds other tags like Chicago, Seattle, San Fran, Etc.

The View I have built is simply time based and shows a feed based on time published of all articles.  However I want some special functionality for any article that is tagged as "sponsored."  At the moment the feed looks like this...

1) tag

2) tag

3) tag

4) tag

5) tag

6) tag

This means that if an article is tagged as sponsored is simply falls down the list as new articles are added.  What I'd like to have happen instead is always FIX the 2 latest sponsored articles (maybe in a node queue) in the second and fifth position.  All other articles without the sponsored tag would fall off as normal based on time while the sponsored articles would stay.  So you'd get

1) tag

Sponsored

3) tag

4) tag

Sponsored

6)

Can this even be done in views?  Should I just think about adding it to the view template file in a custom manor?  Thanks


texts:
I'm using drupal search module to search/find/filter content in my CUSTOM MODULE and it's not returning any results when I search for a word listed in content of my custom module content type. It return results only when i search for a users and others content type.

Any body knows what can i do to fix this? Do I have to implement any hook to index the content of my custom module?

PS:

1) My custom module it's based in the drupal core blog module

2) I was using Custom Search module, but i've disabled it

3) I've tried the search api module and views exposed filter (Search Terms) and nothing

Thank you


texts:
I am building a D8 module that, for configuration, needs a list of webforms and their fields (just the entity reference fields, but I am not picky)

I can get the webforms with this:

  $webforms = \Drupal::entityTypeManager()->getStorage('webform')->loadMultiple(null);

But once I get the returned elements (Drupal\webform\Entity\Webform::__set_state), how can I fetch the elements in the webform referenced?


texts:
I've created a widget which has two textfields and a hidden uniqid. One of these fields is for the name of an item, the other is the number of people who can be involved in that item. These save without any problem, and they re-populate on the edit page correctly, but if I change the values, they do not update correctly.

I am not a Drupal expert, so I am uncertain how much code will be required for diagnosis. These seem to be the most relevant parts, but there is a volunteers_field_is_empty, volunteers_field_validate, volunteers_schema, and a volunteers_field_formatter_view, as well as empty volunteers_field_insert, volunteers_field_formatter_prepare_view, and volunteers_preprocess_node.

function volunteers_field_info() {
  $t = get_t();
  $fields = array();
  $fields['volunteers_item'] = array(
    'label' => $t('Volunteer item'),
    'description' => $t('A position for volunteers'),
    'default_widget' => 'volunteers_field_widget',
    'default_formatter' => 'volunteer',
    'settings' => array('length' => 255)

  );
  return $fields;
}

function volunteers_field_widget_info() {
  $t = get_t();
  return array(
    'volunteers_field_widget' => array(
      'label' => $t('Volunteers widget'),
      'field types' => array('volunteers_item'),
      'settings' => array(),
      'behaviors' => array(
        'default value' => FIELD_BEHAVIOR_NONE
      )
    )
  );
}

function volunteers_field_schema($field) {
  $schema = array();
  switch($field['type']) {
    case 'volunteers_item':
      $schema['columns'] = array(
        'position_title' => array (
          'type' => 'varchar',
          'length' => 255,
          'not null' => TRUE
        ),
        'position_count' => array (
          'type' => 'int',
          'sortable' => TRUE,
          'default' => 1,
          'unsigned' => TRUE
        ),
        'unique_id' => array(
          'type' => 'varchar',
          'length' => 255,
          'not null' => TRUE
        )
      );
      break;
  }
  return $schema;
}

function volunteers_field_widget_form_alter(&$element, &$form_state, $context) {
  $type = $context['field']['type'];
  $lang = $context['langcode'];
  $delta = $context['delta'];
  if($type == 'volunteers_item' && isset($context['items'][$delta])) {
    $item = $context['items'][$delta];
    $element['position_title']['#value'] = $item['position_title'];
    $element['position_count']['#value'] = $item['position_count'];
    $element['unique_id']['#value'] = $item['unique_id'];
  }
}

function volunteers_field_widget_form(&$form, &$form_state, $field, $instance,
  $lang, $items, $delta, $element) {

  $t = get_t();
  $type = $instance['widget']['type'];
  switch ($type) {
    case 'volunteer_field_widget':
    case 'volunteers_field_widget':
      $element['position_title'] = array(
        '#type' => 'textfield',
        '#length' => 255,
        '#title' => $t('Position name'),
        '#weight' => 0,
        '#delta' => $delta,
        '#size' => 'big'
      );

      $element['position_count'] = array(
        '#type' => 'textfield',
        '#weight' => 1,
        '#length' => 10,
        '#delta' => $delta + 1,
        '#title' => $t('Number of participants'),
      );

      $element['unique_id'] = array(
        '#type' => 'hidden',
      );
      break;
  }

  return $element;
}

function volunteers_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if($field['type'] == 'volunteers_item'){
    foreach($items as &$item) {
      // setting default values.
      $count = $item['position_count'];
      if(!$count) $count = 1;
      $item['position_count'] = $count;
      if(!isset($item['unique_id'])) {
        $item['unique_id'] = uniqid(rand(),1);
      }
    }
  }
}


texts: How can I create a friendship that must be approved with the Relation module?

texts:
I'm trying to learn how to use the Relation module.  The Node One Screencasts are very helpful in showing how to set up a "User A and B are friends" type relation.  However, most SNS sites require friends to approve each other.

How would one go about setting up an approval mechanism?  The rules module?  What, roughly speaking, would such a set up look like?


texts:
I am currently working on an internal project that would host a Drupal multisite platform.

For this, I am in the process of creating a site_manager module that will be running in the "main" Drupal instance, within the multisite setup.

Now, I want to be able to run a lot of functions in the context of a specific subsite.

For example: I want to run a cache_clear_all() or a module_enable() in a subsite.

When I call these functions, it will always run the functions in the current site's context (the "main" Drupal instance).

I have tried to use db_set_active() to resolve this, but no luck.
It will always run it in the current "main" site.

To resolve the problem I started implementing a custom class that holds methods for the actions I want to perform, that fire custom db_query() implementations...

It works, but that cannot be the cleanest way to do this...
Clearing the cache tables manually via db_query does not seem like the best way to do this, especially when you know that just calling cache_clear_all() should do the trick, when ran in the correct context.

Some research brought me here:
Programmatically create user in another Drupal site
But I don't really see how this would work, because I want the platform to be extendible,so that I can add functions later.

I could try to setup some kind of "client" module that listens for calls from the main site or something like this?

EDIT

After doing some additional research, I am looking into the possibilities of XML-RPC or some kind of webservice (json) that might do the trick as well.

It might be good to note that I would like to find a sustainable solution when looking forward to D8...

Anyway, did any of you try something like this?

Thanks in advance!


texts: Cloned site pointing to original site's database - can this cause problems?

texts:
Can pointing a cloned site to the original site's database cause problems?

I'm running a Drupal 7 site with a MySQL database sitting on a separate server.

I pulled a clone of the site's codebase repository onto a seperate development server, then imported a very recent backup of the database into a fresh database. The site ran correctly, from a different domain.

However, I forgot to update the local.settings.php file, so the cloned DEV site pointed to the PROD database. This file was incorrect for about 16 hours, overnight, and I've since updated it to point to the correct database.

While the DEV sit pointed to PROD, I did not create, edit or delete any content on the DEV site. My only change was to disable 'aggregating CSS/JS files' under performance settings. The CRON would have run many times overnight.

I've since cleared all caches and purged all cached URLs from Varnish, but for political reasons I cannot simply restore an earlier backup of the site.

Could this database crossover cause any problems now or in the future?


texts: How do I add an field containing image links?

texts: I need a list of images in a view that all link to a third party page.


texts:
I suppose this is more of a PHP question.

I'm trying to work on some redirects that's outputting:

http://localhost/mysite/?q=node/add/cmsdeliverable%3Ffield_demo_id_reference%3D1208

But what I need is this:

http://localhost/mysite/node/add/cmsdeliverable?field_demo_id_reference=1208
How can I cut the ?q=, and replace the &3F with ?, replace %3D with =


texts: Taxonomy Term Hierarchy(not programmatically nor content related)

texts:
I know there are zillion topics about this, but I just couldn't apply it to my View Block in Drupal 8. On the other hand all these Taxonomy Term Tree creation is based on content related.

Here is what I would like to do, I would like to display my "Collections" taxonomy term hierarchy without content relationship, as it is(just parent-child terms). This is how my taxonomy term hierarchy looks like:

And this is how far I could get:

This is my result(which is completely wrong):

**FYI: I am using Views Tree and I follow this Taxonomy display children with Taxonomy View Depth not working **

Thank you for help and time in advanced.


texts:
Had posted this on SE, but someone suggested I repost here

I have a client using the Drupal Akamai module to manage their site's caching. The client reports the following group of errors happen occasionally when a certain content type is deleted, however, I suspect that it is not limited to a specific content type.

warning: SoapClient::__doRequest: SSL: connection timeout in /path/to/akamai/akamai.class.inc on line 85

warning: SoapClient::__doRequest: SSL: Failed to enable crypto in /path/to/akamai/akamai.class.inc on line 85

warning: SoapClient::__doRequest: SSL: connect() failed: Unspecified error in /path/to/akamai/akamai.class.inc on line 85

The referenced line is a call to a method defined in the SoapClient's wsdl

$response = $ccuapi->purgeRequest($name, $pwd, $network, $opt, $uris);

I've searched high and low for why this may be happening. Although I've learned a great deal hunting this one down, I'm no soap expert. Any insight is greatly appreciated.

I'm not able to perform extensive testing to try and reproduce the error, but it appears that the urls being sent to akamai are well formed. At one point, an excessive number of redundant requests were being sent, but this was cleared up in a recent release, so that may even have fixed it.


texts: How to print URL arguments in headers VIEWS

texts:
I have a blog with URL http:/node/add/blog and I am using a view discussion board to display the content of blog using VIEWS.

I want to add this URL http:/node/add/blog to  Header view. Any idea? How to do it?


texts: What services must I leave switched on in Elysia cron

texts:
I have installed Elysia Cron to import some Feeds data periodically.
However, I have switched off all the other cron tabs that I have in order not to interfere. However, my database size grows to ten times the size as when the cron was switched on without Elysia cron.

Must I switched them on and with what periodicity?


texts:
I am new to drupal and this community. I want to create a form like below.

I write my custom form but my question is how can I show my form table format like columns and rows headers?

There can be already asked question for this too.Can anyone provide me some links or give me some hints.I am using drupal 7.

Thank You.


texts: Encrypt module; Is there a way of using db_query() on encrypted values?

texts:
I've installed the encrypt module because we will be handling a lot of personal data. For those in the EU there is serious consequences under GDPR for failing to protect users data.

I've also installed Real AES and Field Encryption.

So I have got the values encrypted and followed the instructions. I can see the encrypted values in the database. For example:

  a:6:{s:4:"text";s:88:"fYGWIfFfoQuar4yy/ySsyTtK2Qt/flgz9mg4GdRD6hlDOM8f8fevf9Q6O35Yp+WDwByB7SXGg0yPQLXfCC3FlQ==";s:6:"method";s:17:"authenticated_aes";s:12:"key_provider";s:4:"file";s:7:"options";a:1:{s:6:"base64";b:1;}s:15:"method_settings";s:0:"";s:17:"provider_settings";a:2:{s:4:"path";s:15:"../keys/xscodes";s:6:"method";s:13:"base64_decode";}}

Views also displays the decrypted values. I can also see them when viewing and editing one of my entities.

This particular Drupal install is used to store customer and sales info from many Commerce sites in a centralised place. As a result I'm doing lots of db_query()'s when I receive some order information via a JSON call.

My plan was to encrypt the values given. Then use that encrypted value in my call to db_query().

In the PHP block that comes with Devel I have this while testing:

  $lastname = encrypt('Jones', $options = array('base64' => TRUE), $method = 'authenticated_aes', $key_provider = 'file', $config = 'real_aes_encryption');
dpm($lastname);

    $lastname2 = encrypt('Jones', $options = array('base64' => TRUE), $method = 'authenticated_aes', $key_provider = 'file', $config = 'real_aes_encryption');
   dpm($lastname2);

    $lastnamede = decrypt($lastname);
    dpm($lastnamede);

    $lastname2de = decrypt($lastname2);
    dpm($lastname2de);

So the $lastname gives me:

  a:6:{s:4:"text";s:88:"dQApE9dYu1QE2Cz5N5f9rLRW8xuDEYKvDaq3jmJFEC+GBljGqbQ68XfQjv92fNicECsPnoK+s11agTPX0LRQuQ==";s:6:"method";s:17:"authenticated_aes";s:12:"key_provider";s:4:"file";s:7:"options";a:1:{s:6:"base64";b:1;}s:15:"method_settings";s:0:"";s:17:"provider_settings";a:2:{s:4:"path";s:15:"../keys/xscodes";s:6:"method";s:13:"base64_decode";}}

The $lastname2 gives me:

  a:6:{s:4:"text";s:88:"RDsHVHv2wvcK9012xAElHs/tx3rltR57DjyhUXGcBVXrN1j/RqBt/UVkLY6hxEmyLm9zQkqXtET9SgtKmB8q/Q==";s:6:"method";s:17:"authenticated_aes";s:12:"key_provider";s:4:"file";s:7:"options";a:1:{s:6:"base64";b:1;}s:15:"method_settings";s:0:"";s:17:"provider_settings";a:2:{s:4:"path";s:15:"../keys/xscodes";s:6:"method";s:13:"base64_decode";}}

Both values then de-crypted as expected. $lastname and $lastname2 being different values presents me with a problem when it comes to db_query() calls.

The query I'm trying to do is this:

$firstname = encrypt('Peter', $options = array('base64' => TRUE), $method = 'authenticated_aes', $key_provider = 'file', $config = 'real_aes_encryption');
$lastname = encrypt('Jones', $options = array('base64' => TRUE), $method = 'authenticated_aes', $key_provider = 'file', $config = 'real_aes_encryption');
$email = encrypt('pj@some.com', $options = array('base64' => TRUE), $method = 'authenticated_aes', $key_provider = 'file', $config = 'real_aes_encryption');

$customer_id = db_query("SELECT c.id
  FROM {eck_customer} c
  LEFT JOIN {field_data_field_customer_first_name} first_name ON c.id = first_name.entity_id
  LEFT JOIN {field_data_field_customer_last_name} last_name on c.id = last_name.entity_id
  LEFT JOIN {field_data_field_customer_email} email ON c.id = email.entity_id
  WHERE email.field_customer_email_email = :email
  AND first_name.field_customer_first_name_value = :first_name
  AND last_name.field_customer_last_name_value = :last_name
  AND type = 'customer'", array(':email' => $email, ':first_name' => $firstname, ':last_name' => $lastname))->fetchField();
if ($customer_id) {
dpm($customer_id);
 }

The above query is correct. It works without encryption being involved.

I tried entity field query in case that worked but no joy there.

So the question is, does anyone know of a method to achieve what I want? How can I query the database on encrypted fields?


texts: Select content from a view for further analysis

texts:
The platform I use is Drupal 7 with additional module Views. I have created content about Botany in a hierarchical fashion, for which the inbuilt Taxonomy module seems ideal. The leaves of that hierarchy are lists of Fields. Then I created a View displaying that content:
- Magnoliopsida
-- Solanales
--- Solanaceae
---- Atropa belladonna
---- Solanum tuberosum
-- Magnoliales
--- Magnoliaceae
---- Magnolia kobus
--- Myristicaceae
---- Myristica fragrans

Now I would like to enable the user to browse the hierarchy and select individual leaf entries (e.g. Solanum tuberosum and Magnolia kobus) for further analysis. Meaning that they would have to be stored somewhere and ideally this selection can also be modified/added on to. Based on this selection I want to create further Views and Graphs.

Can this be done without coding?


texts: Customizing a View with Taxonomy, color coding and icons

texts:
I have been searching for help with this and I am stumped.

I am trying to create an attractive, styled table with categories of Web Resources and associated icons for each category.

I currently have the following:

A Taxonomy vocabulary: technology categories (e.g. techA, techB, techC) with an icon image field
A Web Resources content type (title, link, description, tech category = taxonomy)
Block View of Taxonomy Terms in Table Format (built using these suggestions from Anoop Joseph (https://drupal.stackexchange.com/users/10405/anoop-joseph) How to list all taxonomy terms in a vocabulary followed by associated node titles in Views)

What I would like to do:

Show the Taxonomy icons next to the technology category names in the Views table
Style each Views generated table with a different css (e.g. border color, bg color)

But I can't find where I can create/generate specific CSS classes for each of the tables. They are all showing up in the output HTML as:

...

And I don't even know where to start to display the Taxonomy icons next to the Taxonomy.

Do I need to work in Templates? If so, how do I add the appropriate icon to the table captions without hardcoding (e.g. switch / case), because that won't be flexible in the long run. I want site maintainers (not me) to be able to simply add a new category to the Taxonomy and upload an icon to go with it and have it show up in the View as a header for that category.

Thanks to anyone who can help.


texts:
I have created a custom module for a form. And  I have json data which I want to add as checkbox values.

$request = drupal_http_request($url);
$jsonarray =drupal_json_decode($request->data);
print_r($jsonarray);
 foreach($jsonarray as $info) {
$output1 =$info[0];
$output2 =$info[1];
$output3 =$info[2];
}

 echo $output1;


texts: Views link fields are not using Pathauto URL aliases for authenticated user

texts:
I am using some views fields as links to the main content. To make the links use the content URL aliases I have:

Added NID as a field, excluded it from display, and moved it to top of
the list
In the "Rewrite results" section of the field I want to use as a link,
I checked "Output this field as link" and for the link path, I
entered node/[nid].

as explained here.

This seemed to work fine.

But when you visit the site as an authenticated user, these link fields start to display the node/[nid] style URLs.

The URL aliases are still working even for the authenticated user. The title field in a given view for instance, has the aliased path for the href and the link works. But the fields I made into a link with node/[nid] token are not aliased.

I have tried deleting and updating the aliases and clearing the caches. Although not really related, I also tried to turn on and off the "ignore admin path" option in the Global Redirect module settings. Nothing changes as the problem is not limited with the admin pages.

Any ideas why this is happening and how I can solve this?


texts:
How do I programmatically know the jQuery version using a script or a hook?

I have used this script for getting the site's jQuery version.

if (typeof jQuery != 'undefined') {
// jQuery is loaded => print the version
alert(jQuery.fn.jquery);

How could i get the same by using some database query or hook programmatically?


texts:
I want to use font-awesome in an Omega 4 subtheme. I added this line to Gemfile:

  gem 'font-awesome-sass'

and tried to import it in subtheme.styles.scss with:

@import "font-awesome-sass";

But I get this error after running compass compile:

"Syntax error: File to import not found or unreadable: font-awesome-sass.

I also tried @import "font-awesome-sass.css" with no error, but no new stylesheet file is added to the subtheme pages.

Any suggestion?


texts: Redirect to 404 page, if URL alias does not exist

texts:
I am developing multilingual site in Drupal 8. I added content in Turkish language and did not create any translation for that node.

Suppose node ID is 123, so system URL is http://example.com/tr/node/123. I have managed to redirect the system URL to its alias. So when I go to https://example.com/tr/node/123 I am successfully redirected to https://example.com/tr/custom-node-in-turkish which is perfect.

The problem now is, when I go to https://example.com/node/123 (without tr) or add another language http://example.com/ar/node/123 (ar = Arabic) then I want to redirect the user to the 404 page as these are not the original content.

How can I achieve that in Drupal 8?


texts: Simple Sitemap using default instead of website URL

texts:
https://www.drupal.org/project/simple_sitemap/
I am using above module
abc.com/admin/config/search/simplesitemap

When I am generating sitemap via UI or drush simple_sitemap-generate command.
It is using
 <url>
  <loc>http://default/ja</loc>
  <xhtml:link rel="alternate" hreflang="en" href="http://default/ja"/>
  <xhtml:link rel="alternate" hreflang="ja" href="http://default/ja"/>
  <changefreq>daily</changefreq>
  <priority>1.0</priority>
 </url>

On my Website I am using only English language. Other languages are configured. But not using that.
How to remove those?


texts: Import RSS Feed to a specific taxonomy term

texts:
I want to use Feeds (and maybe Feeds Tamper??) to import some RSS feeds.

I want to add a taxonomy to my feeds.

Example : Yahoo Business RSS is tagged with "Business" taxonomy term.
Yahoo News RSS is tagged with "News" taxonomy term.
Reuters News RSS is tagged with "news" taxonomy term.
etc...

How can I add a taxonomy term to my feed import form ?

Thank you,


texts: How to make multiple catalogs on one site using a common vocabulary?

texts:
I have 4 node types:

Type 1
Type 2
Type 3
Type 4

There are also 3 vocabularies (taxonomy)

Vocabulary 1
Vocabulary 2
Vocabulary 3

Each type of material has many of own fields, but these 3 vocabularies (Vocabulary 1, Vocabulary 2 and Vocabulary 3) are common to each of these 4 types of material.
Each of the vocabularies contains several hundred terms. Also vocabularies have their own set of fields.

If the type of material and the catalog would be one, then of course everything is obvious. View taxonomy/term/%, once configure pathauto for vocabulary terms (type-1/term-name), metatag for vocabularies, titles, etc. But how to be when the are 4 types of nodes, and it is required to comply with the condition for taxonomy paths:

type-1/term-name
type-2/term-name
type-3/term-name
type-4/term-name

An example of how it should be:
Types of materials:

News
Event

Dictionary:

Cities

Url should be of the form:

news/city
event/city

And also catalogs on terms:

News
Events

Accordingly, each of the directories when selecting a particular city should show only either the events of the selected city (if the event directory), or the news of its city (if the catalog is news). And also cities should be set up corresponding Meta either for events in cities, or for news in cities.

At first glance, it's need to create 4 sets of taxonomy vocabularies for each type of material, such as:

Vocabulary 1 for material type 1
Vocabulary 1 for material type 2
Vocabulary 1 for material type 3
Vocabulary 1 for material type 4
Vocabulary 2 for material type 1
Vocabulary 2 for material type 2
Vocabulary 2 for material type 3
Vocabulary 2 for material type 4
Vocabulary 3 for material type 1
Vocabulary 3 for material type 2
Vocabulary 3 for material type 3
Vocabulary 3 for material type 4

And then of course everything is configured in an obvious way. But in my case it's a wrong way to duplicate. After all, what if you had to make 10 node types with common vocabulary? Duplicate 10 vocabularies, and then synchronize them, if something is added to them?

What do you advise? How correctly to organize such?


texts:
I have a content type "X", and would like to have 2 different view mode per node(I guess it should be 2 different url per node: /node/1 & node/1/summary). I'm not sure is it possible, but I want to make a view that list node of content type "X", each node has 2 links(2 fields), they are link to view mode 1(some fields) and view mode 2(full).

I have been searching this for day with no luck, and hope someone have done this before.

-- update my question for the confusion : Aug 5, 2015 at 5:pm --
What I really need is to have 2 different views mode pages per node(2 actual page per node), so each node can have their summary page(not a list of teaser mode) and full content page.


texts: How to discard unsaved changes to a view when editing it leads to a WSOD?

texts:
This is one of those times when I tried to add something and realized that I've got it applied to all displays. This time it was a vocabulary filter, so I clicked cancel and it didn't register so I clicked back to site.

After that I tried to edit and it returned

  The website encountered an unexpected error. Please try again later.

The log shows this:

  Exception: No entity type for field vid on view VIEW in
  Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 712 of
  /PATH/core/modules/views/src/Plugin/views/HandlerBase.php).

I checked the active config and couldn't find anything with a vid. Clearing cache and reimporting the view config didn't fix it. So, is there a way?


texts:
I think I'm missing something pretty basic here.

I'd like to be able to export all node content as POT files to send along with the other POT files for translation.

I have i18n installed, and a handful of dependencies and "Translation template extractor".

I am able to export nearly everything on the site (menus, taxonomy, strings from modules, etc) but I do not see an option to export "nodes" or "node content".

Is there a way to do that?


texts:
I have sub menu of Main menu.
I need to set 2nd sub menu as default menu, so when user visit a site 2nd sub menu should open.


texts: How do I create a text field in registration that only shows up if a checkbox is checked?

texts:
I am making a registration process in which there needs to be a text field that only appears if a checkbox is "on". I would think "parent" fields would do this, but whenever I click the "parent" dropdown under account settings, the only option is "none". If I am being too vague, feel free to let me know and I will clarify.

Thank you,

Alex


texts: Menu block Issue while using with multiligual i18n module install

texts:
I've installed the Menu block module (to display 2-level menus in page side bar etc) and the Internationalization module to create a multilingual site.

But when I translate the content in other languages say content in Italian, and come back to view and click on Italian view of page the Menu-Block goes hide.

I assume that it is due to 'it' into the URL (like http://example.com/node/4/it/). How to fix this issue. Kindly help. i'll appreciate. thanks


texts: How can I omit downloading default themes in drupal core in make file

texts: Is it possible to not download the default themes- e.g. bartik, garland etc, in my make file when I download the drupal core?


texts: Google Page Speed Insights recommends Leverage browser caching

texts:
Google complains on leverage browser caching on the following files:

Leverage browser caching for the following cacheable resources:
https://www.googletagmanager.com/gtm.js?id=GTM-xxxxxx (15 minutes)
https://www.googleadservices.com/pagead/conversion_async.js (60 minutes)
https://www.google-analytics.com/analytics.js (2 hours)

I have the following in my .htaccess file which should set all files to 2 weeks:

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

I verified that I have the mod_expires module enabled.

In Cloudflare I have Browser Cache Expiration set to 2 hours.


texts: No Ajax gets initialised from inside the modal

texts:
I've got a bunch of forms that are opening inside a modal so that the user is not redirected off the page. I've then got a few Ajax calls on form items inside the form. They all work when using the form in a page instead of a modal, however when in a modal it just gets an Ajax error.

The simplest Ajax functionality is the following:

function hook_form_alter(&$form, $form_state, $form_id) {
  $form['field_rate']['widget']['#ajax'] = array(
    'callback' => 'changeActualRate',
    'event' => 'change',
    'wrapper' => 'rates-wrapper'
  );
}

function changeActualRate(array &$form, FormStateInterface $form_state) {
  // Get rate from taxonomy term
  $rate = $form_state->getValue('field_rate');
  if (!empty($rate)) {
    // Instantiate an AjaxResponse Object to return.
    $ajax_response = new AjaxResponse();

    $rate = taxonomy_term_load($rate[0]['target_id']);
    $cost = $rate->get('field_cost')->getValue();
    $cost = $cost[0]['value'];
    $ajax_response->addCommand(new InvokeCommand('#edit-field-actual-rate-0-value', 'val' , array($cost)));

    // Return the AjaxResponse Object.
    return $ajax_response;
  }
}

It's a pretty simple bit of functionality but it seems no Ajax gets initialised from inside the modal. Anyone have any ideas on how to initialise Ajax once the modal is open. Modals are being opened via links using class="use-ajax" data-dialog-type="modal".


texts: Exposed filter : search term with select which 'field' to search by

texts:
I have a view which displays a list of nodes with exposed filters. Everything works perfectly.

I would like to add a filter like this:

one input text
one drop-down.

The list items represent fields of content type.

The user can write a search term in the input text and select which 'field' to search by. i.e. All, Title, Summary, ...

Is that possible? How I can do this?


texts: How to remove "All Products" item in main menu of Commerce Kickstart 2?

texts:
I checked vocabulary collection, no "All Products" there.

Is it created programmatically? How can I remove/change this item?


texts: Upload image to commerce product on save?

texts:
Currently working with the Commerce module in Drupal 7.

I've hooked the product creation form (using hook_form_alter()) to include a custom validation function. I have an image for each product that is generated on the fly and needs to be associated with the relevant product. The name of the image field is 'field_pchem_structure_image.'

I'm able to create and save the image, but I need to make sure it is added to the product when the product is saved. I've tried setting:

$form_state['values']['field_pchem_structure_image'] = $file;

However, this does not seem to work. Could someone please explain how to do this?


texts: Why does not hook_block_view_MODULE_DELTA_alter work?

texts:
I'm implementing a hook_block_view_MODULE_DELTA_alter for the user login block.

function mymodule_block_view_user_login_alter(&$data, $block) {
    drupal_set_message($block->module);
}

According to the block table, the module is user and delta is login.
But, the hook was not invoked and the message was not printed out as expected. I'm using D7.


texts: Remove all previous cart if have same product creator

texts:
Thanks a lot joshmiller, but I need this rule on before add product to cart react event, not after save commerce order.

I need when user (buyer) klick second button add to cart (for multi order), system check the product creator id first, if the product creator id for the second order clicked is same with previous (where is actually on cart) system cancel the previous clicked order.

With this scenario I want to limit order only from same product creator for one times order. So if buyer want to continue order from different product creator they have to do after first order completed.

Any suggest how to solve this using rule?


texts: How to collect a list of file URLs using Rules and send a single email containing that list?

texts:
I am using the Rules module to send an email when a content node gets saved/updated.

I have a basic node where users can upload a large number of files and enter an email address to notify someone about the change.

In this example, the Rules Action to Send Email is in a Rules loop, and I get one email per item in list. When I move Send Email to the left, I cannot access the "list_item" variable.

Rules Events:

After saving new content
After updating existing content

Rules Conditions:

Content is of type, Parameter: Content: [node], Content types: BasicPage
NOT Data value is empty, Parameter: Data to check: [node:field-email]

Rules Actions:

Loop
Parameter: List: [node:field-file]
List item: Current list item (list_item)

Send Email
Parameter: To: [node:field-email], Subject: Test [node:title], Message: [list-item:file:url], From: noreply@host.ca


texts: how can I make view_slideshow module thumbnail pager scrollable?

texts:
I am using the view_slideshow module.
When user goes to the property page(Content type property) I am showing the images using view slide_show module.
Main image is moving as a main slider image and thumbnail are being shown under the main image as thumbnail pager.

Now here is a problem:
Thumbnail pager is coming in a div its working fine if the number of images are 3-4.
But if the number of images are 8-10 then they are not being shown in the thumbnail pager div.I want to make the thumbnail pager div scrollable with arrow buttons on both end.

So if user clicks on the next arrow of thumbnail pager then that thumbnail will comes into the thumbnail pager div.

Thanks


texts: How get facet input checkbox field into label

texts:
I am using facets module. The current markup of the facets:

    <input type="checkbox" class="facets-checkbox">
    E-mail
        (2)

    E-mail
        (2)

How do I get the facet input checkbox field into the label? So I get:

  <input type="checkbox" class="custom-control-input">

  Check this custom checkbox

    E-mail
        (2)

Is this possible?


texts:
I've been looking online for a while and I haven't seen anything on setting up Drupal to use Redis for session handling. I've found tutorials and blogs about settings Redis up as a replacement for Memcached for caching.

Anyone know how to do this? I was hopping there was something in the $conf variable in the settings.php file that would allow me to override where sessions are stored and retrieved.

Thanks for any help in advance,FatGuyLaughing


texts: Is there a clean-URL-reflective version of file_create_url()?

texts:
I have a site with clean URLs enabled and in a test I've written, I compare the current drupalGetHeader('location') to file_create_url($file->uri). The tests passes on my site, but on the qa.drupal.org testbot (and, presumably, on any site that doesn't have clean URLs enabled) the test fails.

Is there an API function that's more clean-URL-reflective to file_create_url()?


texts: Drush Fails to Connect to MySQL DB Server Using PDO SSL Options

texts:
Question: How do you force Drush to use all of the PDO options specified in a site's settings.php file?

Background:
I am using Drupal 7.22 with Apache and the Drupal files (and Drush 5.8.0) on one physical server, and MySQL on another physical server. I have specified extended PDO options within the settings.php file in order to connect to the MySQL DB using SSL. The website itself works great, and Drupal can connect and use the DB without error. However, Drush does not establish a connection to the DB, and I receive (using -dv on Drush) the following error:

SQLSTATE[28000] [1045] Access denied for user
'drupal'@'192.168.0.38' (using password: YES)

With the user and host being the proper user and host for the MySQL user. If I disable the SSL requirement of the DB user within MySQL, Drush connects fine. This is not an option however, as security is of importance.

I have also checked the CLI vs. the CGI .ini files, and also ensured the PDO extension was available to both.

The database lines from settings.php:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'drupal',
      'username' => 'drupal',
      'password' => 'password',
      'host' => '192.168.0.39',
      'port' => '3306',
      'driver' => 'mysql',
      'prefix' => '',
      'pdo' => array(
        PDO::MYSQL_ATTR_SSL_KEY => '/home/drupal/client-key.pem',
        PDO::MYSQL_ATTR_SSL_CERT => '/home/drupal/client-cert.pem',
        PDO::MYSQL_ATTR_SSL_CA => '/home/drupal/ca-cert.pem',
      ),
    ),
  ),
);

The user, password, db, ip, and file paths have been changed from the actual, but are similar in nature.


texts: Is it possible to set multiple permission in hook_permission()?

texts:
Let's say I have a custom module. Now I upgrade the module and add some new functionality which is bound to the old functionality. I already have a hook_permission() set in the old version. But now need a second permission to keep unauthorised users away from accessing the new function. Is it possible to set a second permission in the same module? How would I do that?

That's how my hook_permission looks for now:

function MYMODULE_permission() {
  return array(
    'name of permission' => array(
      'title' => t('Access Something'),
      'description' => t('Access Something to do something'),
    ),
  );
}