texts: How do I bypass cart and go straight to checkout?

texts:
I know that you can easily achieve this functionality in Drupal 7 with the Rules module or using the Commerce Checkout Express module.

Since Rules and Commerce are not that much integrated yet, I am not sure we can achieve this that easily, in Drupal 8.

Can I implement this feature using just rules? If the answer is no, how can I do it, programmatically?


texts:
I have a content type that has been turned into a Feature named "Earth News".  It includes an optional CCK field called "Source URL".  When that CCK field is not blank I want the site visitor to be able to click on the teaser and go straight to that URL.

I've added the following preprocess function to the .module file for this feature:

function earth_news_preprocess_node(&$vars) {
  $path = drupal_lookup_path('alias','node/' . $vars['nid']);
  $url = $vars['node']->field_se_news_source['und'][0]['url'];

  path_save(array($path,$url));
}

The path_save is throwing a fatal error:

Only variables can be passed by reference

Am I on the right path?  What's that error all about?

Thanks.


texts: How to create view of referenced nodes with fields?

texts:
I have node reference field which can take multiple values in it and I want to create a view of fields of these referenced nodes.

How do I achieve this?


texts: .htaccess 301 redirects breaking clean URLs

texts:
I am trying to make a couple of (I think) very basic rewrite condition / rules in .htaccess.

I placed them as the first rule after RewriteEngine on. Things seemed fine locally, and the rules appeared to work in .htaccess tester under each scenario.

However, when I pushed the code live, clean urls stopped working. Everything was only accessible as its route, i.e. /node/1234 instead of /foo/page.

Here are the rules I added:

<IfModule mod_rewrite.c>
  RewriteEngine on

  # Custom redirects
  RewriteRule ^ptistore/control/interviews(.*) http%{ENV:protossl}://%{HTTP_HOST}/nurse-interviews [NC,L,R=301]
  RewriteRule ^ptistore/control/news(.*) http%{ENV:protossl}://%{HTTP_HOST}/cpn-numbers [NC,L,R=301]

So, any hit on either URL should 301 to the provided URL. I tested them locally and they appeared to work (and not break clean URLs), but when I pushed it up to our Acquia environments, URLs were no longer rewritten.

I wound up implementing a RouteSubscriber to get around this for the moment:

/**
 * Class RedirectSubscriber
 * @package Drupal\mymodule_redirects\EventSubscriber
 */
class RedirectSubscriber implements EventSubscriberInterface {

  public function redirectIndexPHP(GetResponseEvent $event) {
    $request = $event->getRequest();
    $uri = $request->getRequestUri();

    if (preg_match('/ptistore\/control\/interviews\/.*/i', $uri)) {
      $response = new TrustedRedirectResponse('/nurse-interviews', 301);
      $event->setResponse($response);
    }

    if (preg_match('/ptistore\/control\/news\/.*/i', $uri)) {
      $response = new TrustedRedirectResponse('/news', 301);
      $event->setResponse($response);
    }
  }

  static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array('redirectIndexPHP', 39);
    return $events;
  }
}

Which works... but I really would rather it live in .htaccess.

Did I just place my rules too early in the file? How can I correct this?


texts: PDOException SQLSTATE[HY000] causes an old version of the site to appear at the bottom

texts:
I'm building a site in Drupal 7. It's still in development, and isn't "live" yet. While assing the Views Slideshow module, I suddenly got this error appearing at the bottom of the page. Every page, in fact, from then on:

Warning: Cannot modify header information - headers already sent by (output started at
/var/www/drupal-7.7/includes/common.inc:2567) in drupal_send_headers() (line 1018 of
/var/www/drupal-7.7/includes/bootstrap.inc).

PDOException: SQLSTATE[HY000]: General error: 1364 Field 'access_exposed' doesn't have a
default value: INSERT INTO {rules_config} (name, label, plugin, weight, status, module,
data) 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); Array ( [:db_insert_placeholder_0] =>
uc_payment_method_credit [:db_insert_placeholder_1] => Credit card conditions
[:db_insert_placeholder_2] => and [:db_insert_placeholder_3] => 0
[:db_insert_placeholder_4] => 2 [:db_insert_placeholder_5] => uc_payment
[:db_insert_placeholder_6] => O:8:"RulesAnd":12:
{s:9:"*parent";N;s:2:"id";N;s:12:"*elementId";N;s:6:"weight";i:0;s:8:"settings";a:0:
{}s:4:"name";s:24:"uc_payment_method_credit";s:6:"module";s:10:"uc_payment";s:6:"status";i:2;s
:5:"label";s:22:"Credit card conditions";s:11:"*children";a:0:{}s:7:"*info";a:1:
{s:9:"variables";a:1:{s:5:"order";a:2:
{s:4:"type";s:8:"uc_order";s:5:"label";s:5:"Order";}}}s:9:"*negate";b:0;} ) in
drupal_write_record() (line 6861 of /var/www/drupal-7.7/includes/common.inc).

It looks like there's a problem with credit card things of some kind. I am using Ubercart for some of the website, but I didn't touch it at all. I'm not sure exactly when the error appeared, but it was towards the end of this tutorial: http://www.brightwebsitedesign.com/how-to-install-views-slideshow-module-on-drupal7 And yet, I'm not certain that this has anything to do with it, considering it seems to have a problem with payments and cards and so forth.

This is the thing that confuses me the most: I copy-pasted and have been modifying another theme as an example to make my own, and no longer have the original php files inside my theme (though I have the unmodified theme itself in the themes folder, still). However, not only is the error causing a second copy of the site to appear at the bottom of my current one, it is also using the old page.tpl.php file (which no longer exists, as far as I can see, except in the original theme, itself), with the current modified style.css. Also, this still happens on the admin pages, which are using Garland (unmodified, so I can't see if it's using an old version or not).

Another recent change was to put the whole web/sites/all folder into svn, but I doubt that would affect anything.

I may be mixing cause and effect, here. It could be the site replication causing the payment error. How can I go about finding out/solving it?


texts: How to move a taxonomy term from one vocabulary to another?

texts: How can I change vocabulary of some taxonomy term? And keep all its data - tid, references, fields, alias and translations (except hierarchy)?


texts: Is it possible to add inline css styling to a twig email template? Not as a source file reference but by inclusion of css within the template similar to html <style>...</style>functionality.


texts: How to update a biblio field with Entity Metadata Wrapper?

texts:
I can update a field using Entity Metadata Wrapper (EMW). Here's how I can accomplish this.

$node_wrapper = entity_metadata_wrapper('node', $nid);
$node_wrapper->field_custom_field='new value';

However, I'm not able to access and update biblio fields provided by biblio module in the same way. This code won't work

 $node_wrapper->some_biblio_field='new value';

How can I update biblio fields using EMW?


texts: Count how many nodes have been updated per user

texts:
I am using Drupal 8.

I have been trying to find how many nodes (count) have been created by each user of my drupal site.

Following some excellent (although quite old) threads here and here among other sources, I managed to create a View that answers that question.  I added a criterium to filter the date.  I expose the filter so I can play around with it.  The results are a table like:

User     Nodes Created
 A           20
 B           10
 C           5

However, I also want something a bit more subtle, for which I could not find any help.

I 'd like to know how many node updates a user has done.  Something like a table:

    User     Updates
     A        100
     B        90
     C        80

etc..

I have no idea if this is possible and I could not find any relevant information.  I haven't really been using revisions in my site, if that's relevant..

Hope it makes sense,

thanks in advance for any help.


texts:
I want to create an ajax linking a view (front page, for example).
I create an ajax edit link to edit content directely in the node. I success to add a link but when i click to it, a popin was opened(to edit content).
I know how to make it in Drupal 7, but I don't find the solution for Drupal 8.

This is the code I am using.

    $build['ajax_edit_link'] = array(
    '#theme' => 'links',
    '#weight' => -2,
    '#links' => array(
      'ajax_edit_link' => array(
        'title' => t('Edit'),
        'url' => $entity->urlInfo('edit-form'),
        'attributes' => array(
          'class' => array('use-ajax'),
          'data-dialog-type' => 'dialog',
          'data-dialog-options' => Json::encode(array(
            'width' => 1200,
            'height' => 500,
          ))
        ),
      ),
    ),
  );

Here is all captures of the result of this edit ajax link in Drupal 8 (popin).

And here are the capture I want to make in Drupal 8 (Capture in Drupal 7 site).


texts:
I am building a zen subtheme in which I try to adjust my menus from:

            ...

            ...

too:

 <----- mark the very first

            ...

            ...

 <----- mark the very last li element

another example:

 <----- mark the very first

            ...

I know I can handle each menu item with theme_preprocess_menu_link but I didn't find a solution to have the very first and last item marked as I need to? Any suggestions?


texts: Dynamically generating child field collections on node edit forms

texts:
I have a content type that has a field that is a field collection that allows multiple values.  One of the fields within that field collection is another field collection which also allows multiple values.

I am trying to set up an ajax handler that simulates the Add another item button when a value is selected in a select list to generate X number of parent field collection rows.  Additionally, within each parent, I need to generate Y number of child field collection rows.

I am able to generate the parent field collection fields without any problem, but I am having trouble with the nested/child field collections.

Here is a snippet of the code:

        // Parent field collection fields:

        $items_count = count( $arrServices );
        $items = &$form_state['field']['field_MYFIELDCOLLECTION'][ $lang ];
        $items['items_count'] = $items_count;
        $items['field']['cardinality'] = $items_count;

        $form['field_MYFIELDCOLLECTION'][ $lang ] = field_multiple_value_form($items['field'], $items['instance'], LANGUAGE_NONE, array(), $form, $form_state);

    // ^^^^^^^^^  This works ^^^^^^^^^^^^^^^^^

    // Generate children
      $i = 0;

      foreach ( $arrServices as $service) {

        $arrCats = _mymodule_get_child_list( $service->tid );

        $item_count = count($arrCats );

        // Children seem to be handled differently in $form_state
       //
        $items = &$form_state['#parents']['field_MYFIELDCOLLECTION'][ $lang ][$i]['#fields']['field_CHILD_FC'][ $lang];
        $items['items_count'] = $items_count;
        $items['field']['cardinality'] = $items_count;

        $form['field_MYFIELDCOLLECTION'][ $lang ][ $i ]['field_CHILD_FC'][ $lang ] = field_multiple_value_form($items['field'], $items['instance'], LANGUAGE_NONE, array(), $form, $form_state);

          // ^^^^ This line causes an ajax error:
          // EntityMalformedException: Missing bundle property on entity of type field_collection_item in entity_extract_ids()
          // on line 7929 of includes/common.inc
          // The assignment of $items may not be correct

           $i++;
        }

Can someone point me in the right direction on this?

Thanks in advance!


texts: Find entity field order and display names in code

texts:
In PHP code, in Drupal 8, how can I get the display names and the order of entity fields to be displayed in a particular view mode.  I'm specifically trying to get the order of fields in node and paragraphs entities.

I've tried inspecting the node object, using the serializer service and REST interface.  I can find the fields and data, but not this metadata.


texts:
In the webform-mail.tpl.php template, it outputs the main form data using:

[submission:values]

I am using the html format (using mime-mail) and this outputs to the email html in the form:

NameName value

Is there a way I can customise the output so that it doesn't use the label field and uses a
 tag instead?

The problem with the  tag is that I cannot style it in Microsoft Outlook as it ignores all styling for this tag, and the email is quite difficult to read/understand.


texts:
We are building a web site that relies heavily on organic groups.
We provide in the front page a webform to allow non-authenticated people to submit a request of membership to one of the main groups (there are subgroups also).

What I need is the webform to work as it does out of the box, but as soon as a submission is sent, subscribe it to a group. Inside the group, a user which belongs to a certain role will accept/reject the membership request.

So far, I have learned that if you add the feature 'is group content' to the webform content type, it affects to the webform but not to the submissions (i.e. unauthenticated users can't reach the webform since the group in the og_group_ref is configured as 'private' (and it has to be this way).

TLDR: I need the submissions of a webform to be able to be assigned the og_group_ref attribute as they are submited. Is it possible?

TIA


texts: Block visible only to the user who created it

texts: Is there any module that allows a block to be seen only by the user who created it, and not to any user with the same role?


texts: How to load paragraphs fields in hook_form_alter to disallow access?

texts:
I have a field inside a paragraph referenced in an taxonomy term.

/**
 * Implements hook_form_alter()
 */
function custom_general_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
  switch ($form_id) {
    case 'taxonomy_term_application_category_form':
        $entity = $form_state->getFormObject()->getEntity();
        kint($entity);
        break;
  }
}

Inside Paragraph field named field_test_para,
I have a text field named field_text,
how can I fetch array structure of field_text in order to hide the field_text and how can disallow access to the text field. So far, I have managed to get the taxonomy entity and looking on how I can fetch paragraph entity and then alter the #access parameter of text field within it.


texts: Access field object (not render array) in field templates

texts:
In most entity templates like node.html.twig or paragraph.html.twig I do get two major variables, the render array variable {{ content }}, but also the entity object variable like {{ node }} or {{ paragraph }}. Usually they are passed down to Twig in template_preprocess_ENTITYTYPE via $variables['element']['#ENTITYTYPE'].

I'm looking an equivalent for this in field templates, e.g. if I can do {{ node.field_whatever.something }} in node.html.twig I also want the get the same thing by using {{ field.something }} in field.html.twig

I guess I need the FieldItemList in template_preprocess_field to achieve this, but I don't know how to get it there.


texts: Drupal site moved causing issues rendering images

texts:
I received a source code and DB. The site is in Drupal . I upload the site on IIS and DB(with default charset UTF-8).

Now what the problem we are facing is that we are unable to see some of the images. As i checked i find out that the image store in the folder is with the name having special characters can not be read.

And the image tag showing the image path with the image name in Arabic can any one tell how to fix this.

But in the images folder this image is with special characters name. If i upload new image in English name it is perfectly working fine.

My question is how to fix this blunder. Mysql is in utf 8 charset.


texts: display a node id within a specific content type

texts:
I'm looking for a way to display the node id somewhere on all displayed instances of a given content type.  It doesn't need to happen in any particular way, but it would sure help my users to be able to see the node id, as we use it to track physical objects.

I would imagine that there are a couple of ways to do this, so if someone could outline the options that would also help.

I've tried something like

<?php
$node_id = arg(1);
echo($node_id);
?>

To no avail, as I can only put this in each individual node instead of all nodes for a given content type.


texts:
Is it possible to toggle an admin role to see and edit content as a specific user?

I've got a number of entityreferences with contextual filters that are URL dependent, and when I try to edit an entityform submission as admin, I can only see my own data view.


texts: using Feeds Xpath Parser to import RSS feeds

texts:
I am trying to import a Wordpress feed with images (e.g. http://blog.objet.com/feed/) into Drupal 7. I've installed the Feeds XPath Parser module and read the documentation but I am still having the following issues:

The document is XML, but firefox shows it as XHTML. Whic parser to use? XML Parser or HTML Parser?
What is the selector (context) of the root element? I've tried 'xhtml', '/xhtml', 'xhtml:meta',  '/xhtml:meta', 'item', '/item' (with both XML and XHTML parsers) but no elements are getting imported (the feed was imported correctly before I've installed the 'Feeds XPath Parser' module).

Updates:

I was also trying to add "//item" as a selector, this time I got one item, with one image, while no other items being imported.


texts:
I have the following snippet in a theme's page.tpl.php:

          <?php print render($title_prefix); ?>
          <?php if ($title): ?>
<?php print $title; ?>
<?php endif; ?>
          <?php print render($title_suffix); ?>
          <?php if (!empty($tabs['#primary'])): ?>
<?php print render($tabs); ?>
<?php endif; ?>
          <?php print render($page['help']); ?>
          <?php if ($action_links): ?>
<?php print render($action_links); ?>
<?php endif; ?>
          <?php print "**59**". render($page['content'])."**88**"; ?>

The starred numbers in the last line for debugging. The output of render($page['content']) is something like the follwoing:

.....

What I need to perform is programmatically change or add class name to


texts: How to remove tag from SelectQuery object

texts:
I process SelectQuery object using hook_query_TAG_after() or hook_query_alter().

I want to remove 'mytag' tag, which has been added as $query->addTag('mytag') somewhere else. Apparently, neither SelectQuery, nor QueryAlterableInterface has appropriate interface method.

Is there any means (besides SelectQuery subclassing) that I can use to remove a tag?

The reason may be the following (thanks Clive for asking):

I want to make a decision based on (expected) record set size inside hook_query_TAG_after()

I could do $countQuery = $query->countQuery(); $total = $countQuery->execute()->fetchField()

But, the cloned query will have same tag as original one and execute() will invoke the same hook ad infinitum.


texts: Entity reference views display with a contextual filter

texts:
I have this structure:
Organization - a simply content type.
Department - every department have an entity reference to an Organization.
User - every user have an entity reference to a Department.

When I (connected to 'Department 1(25)' in 'Pippo(8)' Organization) create a user i can have in my select list only the department of my organization.

I did not figure how to configure the contexual filter.

I setup a relationship between Department and Organization but how can i filter the organization to the logged user organization?


texts: Drupal not sending emails from contact form

texts:
For some reason my Drupal website does not sends email from contact form. Can you help me where could be a problem?

It also does not send emails to administrator for newly added comments.

Just to mention, that only email it sends is when registered user requests for new password.

Thank you in advance!


texts:
I'm upgrading the Drupal 6 project to Drupal 8 using drupal migrate UI module.

I've installed the below modules in Drupal 8 for an upgrade from 6 to 8.

Nice Menus
Views Slideshow

But, those are not showing in "MODULES WILL BE UPGRADED" list.

What needs to be done before proceeding for "Perform Upgrade". Thanks in advance.


texts: Views Contextual filter using two terms, one assigned to node and one not

texts:
I have a view which uses TID from a single vocabulary as a contextual filter to create a dynamic slideshow.

This slideshow is displayed on nodes of a specific content type ("Landing Page"). The images for the slideshow are loaded from another content type ("Slideshow"). Both are tagged with terms from a common vocabulary with only one level.

The slideshow then displays all images tagged with the same term as the current landing page. This bit is working as intended.

However, I also want all slideshows to include images tagged with another term from the same vocabulary. This term has not been assigned to the landing page.

So, I'm looking for a way to achieve something like this:

Show all images tagged with the TID from the current node AND all images tagged with term 58.

Term 58 is static and will not change.

I've tried all manner of configurations with no luck. I figure I could use some PHP code in the contextual filter but haven't been able to find anything similar that would help. Worse case scenario is I create a separate display in the view for each term but that just seems inefficient.

Thanks

David


texts: Contextual filter with taxonomy term that is not in the url

texts:
I'm hoping someone could please help me tame the beast that is known as contextual filters. :) I have a series of nodes that all have a specific taxonomy term assigned to them (all from the same vocab), but for my url path I do not include those:

For example:

Vocabulary name = videos

A node has terms:

-food
--vegetable
---carrot

assigned to it, but the only url that I want is:

site.com/videos/title-of-node

And then all other nodes which have terms on them will all be under the 'videos' directory:

site.com/videos/title-of-another-node
site.com/videos/title-of-yet-another-node

I created a view that has a contextual filter where I want to display only the nodes that have the carrot term. And it that works perfectly when previewed on the views page, but when loading up the actual page I get a listing of ALL the nodes under the "food" term because I have "WHEN THE FILTER VALUE IS NOT IN THE URL --> Display all results for the specified field"

My main problem I think is that "The contextual filter values is provided by the URL." And my terms are not in the url. So somehow I need to pull the terms associated with each node.

Any help would be much appreciated!


texts: Using Drupal 7 Ubercart - how can I make 'create order' apply taxes?

texts: When an admin creates an ubercart order from the backend, taxes are not applied. Does anyone have a suggestion as to how to make this happen? Through the drupal interface, or if a custom module, which hook or function does this? I have tried a few already...


texts: How can I integrate the job news API into my site to access data through the API?

texts:
I want to integrate the API of job news to display news of different companies. I need to let my system access the data through the API.

How can I integrate it with my website? Can anyone help me by telling me a way or giving some idea for the integration process?


texts: Ctools rebuild form after modal-form submit

texts:
I have a form with a table that displays a number of rows (each row contains user info). On form submit I edit all the users that are displayed in the table. Above the table I render a ctools link "Add user". This opens a modal dialog containing a form. After form submit I'm adding a row to the user table with this code:

$output[] = ajax_command_after('.managers-table tr:last', '
my data
');

This works fine, if I look into my DOM, the table contains that row.
But here is the tricky part, how do I rebuild my "table-form"? Because when I submit my form, drupal doesn't know a row is added to the table, he just ignores the added row... How can I solve this issue?


texts: Add a graphic element in content type without modifying the .tpl

texts:
I would like to add a "like" icon at the end of articles. It’s just an icon which allow the reader of the article to click on the icon and increment a counter. It’s not a social button.

For now, i can add this icon directly in page.tpl

<?php print render($page['content']); ?>

It works but i was wondering if it was possible to add it directly in the content type "article" in admin without modifying the file.tpl


texts: Getting the first URL alias for a node in a SQL query

texts:
For some backups and exports, I need to fetch the URL-aliases for each node in SQL.
The url_alias taqble, however, has no foreign key to the node table (nid) nor the other way around, it seems.

Is there some hidden join-table somewhere? A neat trick to fetch the node and its alias in a JOIN?


texts:
I've installed the entity translation module and everything is translated correctly, the only problem is that when I change the site language, translated nodes are not listed anymore in the main page content block. Nodes are only displayed when the chosen site language is the one in which the node was created.

Is there anyway to list entity translated nodes?


texts:
I am using php in views and trying to make a custom field to remove the duplicates in [field_trucks_notification_no_ref_node_eb:field_trucks_agency] field, i tried to use the row->field_name from the available variables in Global:PHP (output) with no luck.

 stdClass Object
    (
        [entity] => 268
        [_entity_properties] => Array
            (
                [search_api_relevance] => 1
                [search_api_excerpt] =>
                [search_api_id] => 268
                [field_cons_country_border] => 35604
                [field_trucks_notification_no_ref_node_eb] => Array
                    (
                        [0] => 269
                        [1] => 272
                        [2] => 278
                    )

                [field_trucks_notification_no_ref_node_eb:field_trucks_agency] => Array
                    (
                        [0] => 35617
                        [1] => 35621
                        [2] => 35617
                    )

EDIT: using Global:PHP field in views, How can I retrieve the values of the last field (array) above and remove duplicates?


texts:
I'm trying to add following mysql condition:

WHERE       DAYOFYEAR(curdate()) <= DAYOFYEAR(DATE_ADD(FROM_UNIXTIME(field_birthday_value, '%y-%m-%d'), INTERVAL (YEAR(NOW()) - YEAR(FROM_UNIXTIME(field_birthday_value, '%y-%m-%d'))) YEAR))
AND         DAYOFYEAR(curdate()) +7 >= DAYOFYEAR(DATE_ADD(FROM_UNIXTIME(field_birthday_value, '%y-%m-%d'), INTERVAL (YEAR(NOW()) - YEAR(FROM_UNIXTIME(field_birthday_value, '%y-%m-%d'))) YEAR))

To my db_select $query->condition:

//Build query
$query = db_select('users', 'u');
$query->leftJoin('field_data_field_birthday', 'fb', 'u.uid = fb.entity_id');
$query->condition('THE CONDITION MUST BE ADDED HERE');
$query->fields('u', array('uid', 'name'));
$query->fields('fb', array('field_birthday_value'));
$query->range(0,5);
$users = $query->execute();

But i can't figure out how. Simple conditions like =, <> are easy. But i got no clue how to add my more complex condition.

Thx

EDIT:
Should pay more attention to the documentation :). Ty!

//Build query
$query = db_select('users', 'u');
$query->leftJoin('field_data_field_birthday', 'fb', 'u.uid = fb.entity_id');
$query->where("DAYOFYEAR(curdate()) <= DAYOFYEAR(DATE_ADD(FROM_UNIXTIME(fb.field_birthday_value, '%y-%m-%d'), INTERVAL (YEAR(NOW()) - YEAR(FROM_UNIXTIME(fb.field_birthday_value, '%y-%m-%d'))) YEAR))");
$query->where("DAYOFYEAR(curdate()) +7 >= DAYOFYEAR(DATE_ADD(FROM_UNIXTIME(fb.field_birthday_value, '%y-%m-%d'), INTERVAL (YEAR(NOW()) - YEAR(FROM_UNIXTIME(fb.field_birthday_value, '%y-%m-%d'))) YEAR))");
$query->fields('u', array('uid', 'name'));
$query->fields('fb', array('field_birthday_value'));
$query->range(0,5);
$users = $query->execute();


texts: How to restrict direct access to the nodes?

texts:
How to restrict direct access to the nodes but just allow views to access the required field of the particular node type?

For example in Views Slideshow we are sliding the image field that belongs to particular node type. But we don't want search engines to access & visitors to access the nodes belong to that node type.

Any suggestions?


texts: Use dropdown in views exposed filter on text fields with entity not node?

texts:
A very kind soul posted some code here for a small module that allows drop down fields in views for text fields on nodes

I was wondering how I can alter this so it works on an entity I created?

This is the particular field name on this example field_exact_location

My entity type is called "site_object"

function dd_city_form_views_exposed_form_alter(&$form, &$form_state) {
$field_id = 'field_exact_location';

// Only alter forms with the necessary field
if (isset($form[$field_id .'_value'])) {
// Build a query to get all node ids having the specified field
$query = new EntityFieldQuery();
$results = $query->entityCondition('entity_type', 'node')
                  ->fieldCondition($field_id, 'value', 'NULL', '!=')
                  ->fieldOrderBy($field_id, 'value', 'ASC')
                  ->execute();

// Attach the field values to the nodes
$nodes = $results['node'];
field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id));

// Add a default so the filter is optional
$options = array('' => '<select>');

// Buld the options array based on the query results, overwriting duplicate entries
foreach($nodes as $nid => $node) {
  $value = $node->field_exact_location['und'][0]['value'];
  $options[$value] = $value;
}

// Alter the field
$form[$field_id .'_value']['#type'] = 'select';
$form[$field_id .'_value']['#options'] = $options;
$form[$field_id .'_value']['#size'] = 1;
}
}


texts: In Drupal Commerce how can you turn product select box options into images?

texts: As seen in the image below, how can I turn the product dropdown options into selectable images instead? Is there a module for this or does this have to be done via js/css?


texts: how do i create a new link in node.tpl.php by preprocess function in drupal?

texts:
I have content type in which I have two or three links .In node.tpl.php, all links are displaying from a single variable "$links" in node.tpl.php. i want to remove one particular link from the "$links" variable by preprocess function and assign that link to a new variables , so i can display it where ever I want.

I created a preprocess function  to implement it

function sample_preprocess_node(&$variables){
  if($variables['type']="product"){
    $node=$variables['node'];
    $create_review=array();
    $create_review=$node->links['review_field_product_review'];
    $variables['create_review']=$create_review;
    unset($node->links['shopping_review_field_shopping_product_review']);
  }
}

and I pasted the following code in node.tpl.php

print $create_review;

It displays "array" in product page and that particular link is not removed from the variable ($links) in node.tpl.php

Can you tell me how to remove the particular link from the "$link " variable in node.tpl.php and display it by another variable in node.tpl.php?


texts: In Drupal 7, we could create maintenance-page--offline.tpl.php to be shown during database failures. I want to create this page for D8 as well, however maintenance-page--offline.html.twig does not get picked up. Does anyone have an idea what the template name should be in D8?


texts: Incorrect array depth when saving custom field

texts:
I have a module that implements all necessary hooks for a custom field api. I can see hook_field_validate() and hook_field_is_empty() working properly and values are also available on hook_pre_save() but with incorrect depth.

For example on hook_field_validate my $items array have:

161 (Array, 2 elements)
  0 (Array, 3 elements)
    token (String, 15 characters ) test_parameters
    target_id (String, 3 characters ) 161
    value (String, 2 characters ) X1

And on hook_pre_save() my field have:

field_parameters_values (Array, 1 element)
  und (Array, 1 element)
    0 (Array, 2 elements)
      0 (Array, 3 elements)
        token (String, 15 characters ) test_parameters
        target_id (String, 3 characters ) 161
        value (String, 2 characters ) X1

so there is a level more on the resulting array, it can be easily manipulated here but I want to understand the reason for that.

My hook_widget_form() consists in something like:

(...)
foreach ($tokens as $token) {
  (...)

  $element[$custom_id][$delta]['token'] = array(
    '#type' => 'hidden',
    '#value' => $token,
  );
  $element[$custom_id][$delta]['target_id'] = array(
    '#type' => 'hidden',
    '#value' => $custom_id,
  );
  $element[$custom_id][$delta]['value'] = array(
    '#type' => 'textfield',
    '#title' => $token,
    '#required' => $instance['required'],
    '#default_value' => '',
  );
  $delta++;
}


texts:
I want to start by saying this is my first dealings with drupal of any kind. I can turn a wordpress site inside and out but have zero experience with drupal.

My company has recently inherited a Drupal 6.25 site from a company we purchased. I need to delete a lot of inactive users ( 6+ years inactive). I have found how to do that in the administer>user management, deleteing 25 at a time. However, this site has not really been maintained and there are 1,428 pages of users. Yes, 1,428 pages .

I've tried to find a module but everything I can find is for V. 7 and newer. Can anyone give me any advice on where to begin to clean this up?

I've seen mention of cron jobs but have no idead how to go about that for 6.25. Any and all help is greatly appreciated.


texts: I created one content typa and I put one fieldset group through Field_group module, but I can't see settings to add more fieldset. I've 6 fields per fieldset. But I'm not able to do the same with fieldset. It can be done with particular field only.


texts: Hide menu items from non-authenticated user

texts:
Possible Duplicate:
  Hiding link from anonymous users

I have 2 nodes on Drupal 7 site, that only authenticated users can access. But even if I logout, links to these nodes appear in the main menu. When I click any of them, it gives:

Access denied
You are not authorized to access this page.

Which is correct. As far as I know, Drupal must hide the links, that the user can't access. But for these items it doesn't.

How to fix?


texts: How to use websolr with Apache Solr module? (D7)

texts:
I´ve got a Drupal 7 site and I would like to use apache solr.

Is there any way to connect websolr to that module? Haven´t found any module to do that (ie. as the Acquia module).

Thanks!


texts:
Under /admin/config/system/cron I can choose how often the cron runs. However do I still need to set up my server to ping the cron key (that I see in my reports page after I manually run the cron)?

How do these 2 work together? Is the server still required to run the cron, but then the cron wont run more often than is specified in Drupal's UI here: /admin/config/system/cron ?


texts: How do I integrate custom PHP application with Drupal?

texts:
I am a PHP programmer but I have never developed anything yet for drupal. I have used Drupal as a CMS before but I didn't do any custom code since everything I needed at before can be accomplished with existing modules.

Now, with my new project, I have an existing single-page app using a PHP RESTful API and AngularJS on the frontend. I want it to be integrated with a Drupal CMS.

I am aware of the following possible ways to do this:

Rewrite my existing code into a Drupal module - There is very little possibility that this app will be re-used. Furthermore, it is more likely that this app will be used stand-alone without Drupal. I also don't think I have the time to learn how to write a Drupal module.
Keep the backend API as it is now and write the frontend as a Drupal page. - This will put my frontend code inside the Drupal database and NOT in the filesytem anymore so I can't version control the frontend code.

I am not happy with the above two choices and I believe that there is a better way to do achieve what I want.

Additional background of my custom app:

I created this app as a way for me to learn more about single-page applications. It is already currently functioning well as a standalone app. The app basically collects information from several users and collates all those information to be displayed on an HTML table.

I am sure there is also a Drupal way of doing the things that my Angular app does (something like a custom node type with fields coming from the input of different users) but I would like to use my existing code if that makes it easier.


texts: How to pass content type filter to taxonomy

texts:
I created a classified ad website with different content type like vehicle, clothing, mobile phone, computers, etc. Within this content type has a field called location. A location field is an address of the item posted on my website like cities.

My question is on how can I filter location plus the content type. Currently, when I click the location, all of the content type article shows.

Here's an example of what I want:

Select article about vehicle, within the vehicle article is a field called location. When I click the location of the item, the result should include only items related to the previous content type, that is, vehicle content type. Location field is connected to Location taxonomy I created.

BTW, I already installed views and it is working fine.


texts: How can I alter methods in ContentTranslationHandler?

texts:
I want to alter some of the methods here:
https://git.drupalcode.org/project/drupal/blob/8.8.x/core/modules/content_translation/src/ContentTranslationHandler.php

How can I alter just some of the methods?

Or can I override this class in any way?


texts:
I am having an issue with exporting my main menu with the features module. I go to features > module_name > recreate > menu_links and then check all the links that I want.
Once I import the feature on a fresh instance, not all of the menu links show up. If I go to features > module_name > overridden > menu_links all of the links show up there but when I click revert changes, nothing happens


texts: How to start migration with migrate module

texts:
I'm trying to make the migrate module to work, but I can't find where the dashboard is located.

In this url: www.foo.com/admin/content/migrate

I have the list of all available content that can be migrated into the DB (screenshot below).

However there must be another screen where you can actually initiate the import process.

I've tried this other url: www.foo.com/admin/content/migrate/dashboard

But it gives a 404 page not found error.

Any suggestions?


texts: having problem with db_or() and LIKE clause in drupal 7

texts:
I am trying to retrieve data from db with INNER JOIN.

I need the following query executed from drupal's db_select(), query is in normal format :

SELECT uo.* , uop.data FROM `uc_orders` AS uo
INNER JOIN `uc_order_products` AS uop ON uo.order_id = uop.order_id
WHERE (
  (
     uop.data LIKE '%mfp_donation%'
  )
  OR (
     uop.data LIKE '%scholar_donation%'
  )
  OR (
     uop.data LIKE '%reunion%'
  )
)

I already tried in drupal, the process is following :

$query = db_select('uc_orders', 'uo')
    ->fields('uo')
    ->fields('uop', array('data'));

$alias = $query->join('uc_order_products', 'uop', "uo.order_id = uop.order_id");

$order = $query->condition(db_or()
       ->condition($alias . '.data', '%mfp_donaiton%', 'LIKE')
       ->condition($alias . '.data', '%scholar_donaiton%', 'LIKE')
       ->condition($alias . '.data', '%reunion%', 'LIKE')
    )
    ->execute()
    ->fetchObject();

All the process is working fine, but the problem is when i execute/fetch the results then i only get the output for ->condition($alias . '.data', '%reunion%', 'LIKE') . I mean i only get the %reunion% part. The first two conditions is not executing i think.

Any suggestion?


texts: How do I convert the result fro views_get_view_result() to an array?

texts:
I am getting an object from views_get_view_result().

Array
(
 [0] => Drupal\views\ResultRow Object
    (
        [_entity] => Drupal\node\Entity\Node Object
            (
                [in_preview] =>
                [values:protected] => Array
                    (
                        [vid] => Array
                            (
                                [x-default] => 9
                            )

                        [langcode] => Array
                            (
                                [x-default] => en
                            )

                        [revision_uid] => Array
                            (
                                [x-default] => 1
                            )

                        [revision_timestamp] => Array
                            (
                                [x-default] => 1508904645
                            )

                        [revision_log] => Array
                            (
                                [x-default] =>
                            )

How do I convert it to an array? My objective is to get the content types fields values. In an entity object there is toArray() to achieve this, but it doesn't work for what views_get_view_result() returns.


texts: Can a title of a node not be associated with a url?

texts:
I want to create a node with multiple urls.  I don't want the title of the main node to be a url.  Right now the main node is being pulled up in a list view through taxonomy.  When I create multiple nodes for the main node, it shows up multiple times in the taxonomy list as the same item.

I want the main node to show up once in the list with all the "sub-nodes" clickable in the main node's summary view.  Hope this makes sense.


texts: How do I create a simple checkbox in a content entity?

texts: I just want a boolean checkbox with a label beside it. How do I do it?


texts: Checkbox to make billing information same as shipping information does not work for Anonymous users

texts:
For Anonymous users, the My Shipping information is the same as my Billing information checkbox doesn't reload the Shipping Information checkout pane.

I have the checkbox working for authenticated users, but when an anonymous user is going through checkout, the ajax callback never fires. The #element_validate function 'commerce_customer_profile_copy_validate' is never called. The #ajax['callback'] => 'commerce_customer_profile_copy_refresh' is never called.

Watching the network tab in Chrome, the ajax request is never fired.

The checkbox is checked by default and nothing happens when I un-check it. The Shipping Information pane doesn't expand and show the shipping information form fields via ajax.

Is there some permission I'm missing that would allow anonymous users to use this checkbox?


texts: How do I overwrite the view output for each vocabulary?

texts:
This is the Drupal 8 version of the following question: How do I override a taxonomy/term/% list with a view?

In short: You can edit the default, global taxonomy/term/% view, but you can not set custom taxonomy view. For example, /my-custom-category/% will show the default, global view output (not the customized one).

As you can see, the most elegant solution for Drupal 7 was using the Taxonomy Display module. However, it hasn't been ported.

How would you tackle this problem in Drupal 8?


texts:
I am using PepiPost mail service for sending an email. PepiPost mail service provides an SDK for send sending mail. They provided a sample code for sending mail.

When I send the mail getting the following error message:

  Unable to send e-mail. Contact the site administrator if the problem
  persists.

But mail is sent to the corresponding user and user can receive the mail.

I have created a Custom mail system call by implementing
MailSystemInterface. The code is available in the here. Although this is the code I placed in mail()  function.

class TestMailSystem implements MailSystemInterface {
  require_once __DIR__.'/includes/vendor/autoload.php';

  use PepipostAPIV10Lib\Controllers\Email;

  public function format(array $message) {
    // Join message array.
    $message['body'] = implode("\n\n", $message['body']);
    return $message;
  }

public function mail(array $message) {

$email = new Email();

$data = array(
      'api_key'   =>  '************',
      'recipients'    =>  $message['to'],
      'email_details' => array(
        'from'          =>  $message['from'],
        'subject'       =>  $message['subject'],
        'content'       =>  $message['body'],
        'fromname'      =>  $message['fromname'],
        'tags'          =>  'test',
        'replytoid'     =>  $replyto,
      ),
      'X-APIHEADER' => array('UserID1','UserID2'),
      'settings' => array(
        'footer'        =>  true,
        'clicktrack'    =>  true,
        'opentrack'     =>  true,
      ),
    $response = $email->sendJson( $data );
}

}

When I send the mail getting the following error message:

  Unable to send e-mail. Contact the site administrator if the problem
  persists.

User receives the email. What would the reason for the error message be?


texts: How do I add an SQL query with  hook_views_query_alter()?

texts:
I have the following SQL query:

db_query("SELECT content_id, COUNT(*) as count FROM {votingapi_vote}
          WHERE value_type = '%s'  AND value = 1
          GROUP BY content_id;", "option");

If I want to override the view, which code should I put in mymodule_views_query_alter()?

The content of $query is the following:

    views_query Object(
      [table_queue] => Array(
        [node] => Array(
          [alias] => node
          [table] => node
          [relationship] => node
          [join] =>
        )
      )
      [tables] => Array(
        [node] => Array(
          [node] => Array(
            [count] => 1
            [alias] => node
          )
        )
      )
      [relationships] => Array(
        [node] => Array(
          [link] =>
          [table] => node
          [alias] => node
          [base] => node
        )
      )
      [where] => Array(
        [0] => Array(
          [clauses] => Array(
            [0] => node.status  0
            [1] => node.type in ('%s')
          )
          [args] => Array(
            [0] => provider
          )
          [type] => AND
        )
      )
      [having] => Array()
      [group_operator] => AND
      [orderby] => Array(
        [0] => node_created DESC
      )
      [groupby] => Array()
      [header] => Array()
      [distinct] =>
      [base_table] => node
      [base_field] => nid
      [fields] => Array(
        [nid] => Array(
          [table] => node
          [field] => nid
          [alias] => nid
        )
        [node_title] => Array(
          [field] => title
          [table] => node
          [alias] => node_title
        )
        [node_created] => Array(
          [field] => created
          [table] => node
          [alias] => node_created
        )
        [content_id_] => Array(
          [field] =>
          [table] => content_id
          [alias] => content_id_
        )
      )
      [count_field] => Array(
        [table] => node
        [field] => nid
        [alias] => nid
        [count] => 1
      )
    )


texts:
I have created some blocks of a specific type, in Drupal 8, and I want to import them into the cloned instance.

There is no core import feature available. How can I achieve the task?

They don't get imported by the configuration synchronization; if you try, you will get the error

  This block is broken or missing. You may be missing content or you might need to enable the original module.

and no listing in custom block library.


texts: How to hook user registration page? Basically I want to save some cookies when user comes on the register page through an affiliate link. I used hook_user_view but it is working only when user is logged in. Can someone please tell me how to do that?


texts:
I want to load entity form for comment entity type.

I can load entity form for node (entity type = node and bundle = article).

But the entity type = comment and bundle = comment.

Here is the code of loading entity:

  $values = [];
    $definition = \Drupal::entityManager()->getDefinition("node");
    $bundle_key = $definition->get('entity_keys')['bundle'];
    $values['entity_type'] = "node";
    $values[$bundle_key] = "article";
    $entity = \Drupal::entityManager()->getStorage($definition->get('id'))
      ->create($values);
   return \Drupal::service('entity.form_builder')->getForm($entity);

=> This example works well.

But if i replace entity type with comment and bundle with comment, not work :(.

        $values = [];
        $definition = \Drupal::entityManager()->getDefinition("comment");
        $bundle_key = $definition->get('entity_keys')['bundle'];
        $values['entity_type'] = "comment";
        $values[$bundle_key] = "comment";
        $entity = \Drupal::entityManager()->getStorage($definition->get('id'))
          ->create($values);
       return \Drupal::service('entity.form_builder')->getForm($entity);


texts:
Please could someone advise what is wrong with the following? When the page loads it downloads an unknown file type. The form is displayed but not with the template/theming.

The form...

function test_form($form, &$form_submit) {
    $form['message'] = array(
            '#type' => 'textarea',
            '#title' => t('Message'),
            '#required' => TRUE,
    );
    $form['submit'] = array(
            '#type' => 'submit',
            '#value' => t('Send')
    );

    // Get the path to the module
    $path = drupal_get_path('module', 'test');

    // Attach the CSS and JS to the form
    $form['#attached'] = array
    (
            'css' => array
            (
                    'type' => 'file',
                    'data' => $path . '/css/test.css',
            ),
            'js' => array
            (
                    'type' => 'file',
                    'data' => $path . '/js/test.js',
            ),
    );

    $form['#theme'] = 'test_form';
    return $form;
}

The theme...

function test_theme($existing, $type, $theme, $path) {
    return array(
            'test_form' => array(
        //'arguments' => array('form' => null),
        'path' => drupal_get_path('module', 'test') . '/templates',
        'template' => 'test',
        'render element' => 'form',
            ),
    );
}

The directory...

test
test/css/test.css
test/js/test.js
test/templates/test.tpl.php
test/test.info test/test.module


texts:
Hi I am running the code on p247 of "Pro Drupal 7 Development", which includes the code below and then defines a form.  I have enabled the module and cleared the cache but this isn't showing up in my menu system.  What am I doing wrong?

/**
 * Implements hook_menu().
 */
function formexample_menu() {
  $items['formexample'] = array(
    'title' => 'View the sample form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('formexample_nameform'),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM
  );
  return $items;
}


texts: How to alter single custom field value in views?

texts:
I have a view with field Global: Custom Text, which is modified as a link.
I want to change replacement tokens for generating this link, dependent on a value of other field.

Tried to modify this in hook_views_pre_render but I can't find a way to do this.

In hook_views_post_render there are two arrays:

$view->style_plugin->render_tokens
$view->style_plugin->row_tokens

which contains generated links for every row, but they are not present in pre_render, and changing them in post_render doesn't work.

I've also tried to do that in template_preprocess_views_view_fields but for that specific view this function does not firing (for other views it does), and I don't know why.


texts: What is the command to execute after manually editing the composer.json file?

texts:
I want to build a site broadly based on an exiting site and was thinking that the best way to do this would be to copy and paste required modules from the existing site composer.json and paste them into the new composer.json. What would be the correct command to download the modules via Composer once the file has been amended?

I think composer update is the command, but I don't know if it also updates dependencies that should not be updated.


texts:
I've used drupal7, Search API 7.x-1.16, Search views 7.x-1.16, Solr search
7.x-1.9, Apache Solr search
7.x-1.7.

I am listing contents of some content type. Now i want to trim description field only if the content belongs to some content type.
How to do this using theme_preprocess_views_view_fields?


texts:
Some Drupal views I have are "In code" (while some others are "In database"); I understand that some are hard-coded in some PHP files and some are coded in the SQL.

Generally, what are the PHP files in which the "In code" views are stored?


texts:
I have installed phpmailer module and it works fine.
https://drupal.org/project/phpmailer

But it doesn't seem to have the option for DKIM.
How can I set DKIM for the mails sent by phpmailer?


texts: Admin pages including content edit are exremely slow

texts:
I am using latest 7/16 version of core and complicated field collections with all kind of stuff. The problem is it takes up to 1 minute to load all kind of pages in admin section. All dev modules and update manager are disibled.

How could i know what exactly cause such a low performance? What can i do to improve it?


texts:
I'm currently converting a mock-up and I need to display four menus in a list, the first two are expanded, and I need to display both the titles and menu items, and the next two are collapsed, so I need to display the titles but not the menu items. It should look something like this:

Menu 1

Menu item 1
Menu item 2
Menu item 3

Menu 2

Menu item 1
Menu item 2
Menu item 3

Menu 3
Menu 4

Is there an easy way to do that in Drupal's admin panel?


texts: Adding an external image to a views output

texts:
I am trying to alter the output of a view  with a tpl.php file. My goal is to insert an image immediately after another image in the view. This should only happen for 1 result. That is to say, if the value of my array image is apple, I want to also display another image of apples. So if I have a view that returns images of fruits:

Grapes
pears
apple
peaches
bananas

I want to display these images:

Grapes
pears
apple apple1
peaches
bananas

I'm open to ideas, so far I've been trying to solve the issue programatically by creating a custom .tpl file for the view, but if a cleaner solution exists I'd be willing to give it a try.


texts: Find slowest loading / longest time to generate pages

texts: Is it possible to find pages that take the longest time to generate? I am aware Devel can collect query log per page, but is there a module that collects these per page and displays a list of slowest pages?


texts:
Right now I have it so that I grouped a list of taxonomy terms with Group Filters like this:

House Pet:

Dog
Cat

Sea Creatures:

Whale
Shark

All:

Dog
Cat
Whale
Shark

My current problem is that when using group filters I keep getting No Results, however if I use a single filter and choose one of the options I get results.

I have seen a lot of videos of people using groups with taxonomy, but I have not been able to replicate what each of them have done. I have tried using the Filter Criteria with the field as well as the content taxonomy has terms with depth option as well. The content is tagged and has departments (you can see it from the the field I am showing with the view) so I know that the tags exist, but they always return with no results.

Ideas, options, patches, questions, help? I have run out of ideas.


texts: How to include a juery ui file in drupal 7?

texts:
In my code for drupal 6 I had added the following js, jquery-ui and css files

 jquery_ui_add('ui.draggable');
  drupal_add_css(drupal_get_path('module', 'ort') . '/js/jquery.alerts.css');
  drupal_add_js(drupal_get_path('module', 'ort') . '/js/jquery.alerts.js');
  drupal_add_js(drupal_get_path('module', 'ort') . '/js/ort.js');

For drupal 7 I have to write the above code..
I have read that drupal 7 has jquery ui as part of core so how should add the

jquery_ui_add('ui.draggable'); //drupal 6

code given above in drupal 7 ?


texts: Users cannot login. The username field is highlighted red, but there are no error messages. There is no password reset link

texts: I've inherited a Drupal site and uploaded it to a new server but retained the existing domain name. The site is working, but when I try to log in as admin (or any other user) the login page just reloads with the username field highlighted red. There are no error messages and the username is definitely correct. I have tried to re-set the password manually in the database. I have also tried to add a new user directly into the database with admin privileges. Neither works. Also, there is no forgot password link on the login page. I have tried to change the base url and cookie url in the settings.php file but that did not work. I have tried repairing the sessions table but to no avail. I'm new to Drupal so not sure what to try next.


texts:
I already have a custom content type (jobs). When I create jobs nodes, they are displayed. I have created a new content type (ideas). When I add an idea node, I get a Page not found error. Any new custom content type I create gives me the same error.

The nodes I created are published. I cleared the cache.

I tried re-building the node permissions here: https://www.foo.com/admin/reports/status

Which didn't work.

There does appear to be  Experimental modules found: Content Moderation. This would no longer be experimental in 8.6, currently the site is running 8.2. Not sure if that upgrade would help or create more problems.

There is this error which is interesting:

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions. Content
The node.field_recognition_date field needs to be uninstalled.

But I am not sure how to uninstall that or how to fix this issue. Any help would be appreciated.


texts: Views Exposed form in block : how to add a ajax results counter?

texts:
I implemented a view as following :

a page display with an extensive exposed filters form (Better exposed filters), ajax enabled, let's call it the landing page
a clone of it, in a second page display with exactly the same fields, but few exposed filters instead (quick search form)
that clone has exactly the same path, Exposed form in block is set to yes

I display the clone created block (quick search form) on homepage : submitting its form redirects to landing page with correct results and the complete exposed filters. This is fine.

Question :

I need to display a results count next to the exposed form block, which refreshes each time you change a exposed filter value in the form.

The Global: Result summary in header or footer doesn't work because  footer and header aren't displayed together with the exposed block, they only come with the full view display.

How could solve that, either with UI or programmatically ? Below some ideas to begin, there might be a good and straight way :

force the results count header to be displayed next to exposed block ?
add a markup to the form with ajax results ?
create another block ?

EDIT

I tried several approaches based on Shreya answer below, but the blocking point is always the same, I need to execute the view to get result count, but as soon as I do, it returns an Allowed memory size exhausted.

in template.php :

function shoot_preprocess_views_exposed_form(&$vars){

  if($vars['form']['#id'] == 'views-exposed-form-customer-products-list-search-block') {
    $view = views_get_view('MY_VIEW');
    $view->set_display('MY_DISPLAY');
    $view->execute();
    $count = count( $view->result );
    $vars['count'] = $count;
  }
}

in views-exposed-form--MY_VIEW.tpl.php

print 'There are:'. $count. 'results';

And other tries with views_get_current_view() or views_get_view_result() in the tpl, also tried within form alter :

function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if($form['#id'] == 'views-exposed-form-my-view-my-display') {
    $view = views_get_view('MY_VIEW');
    $view->set_display('MY_DISPLAY');
    $view->get_total_rows = true;
    $view->pre_execute();
    $view->preview('MY_DISPLAY');
    $view->execute();
    $content = $view->total_rows;
  }
  $form['submit']['#value'] = 'Voir les'. $content.' résultats';
}

Any clue to explain why I can't execute the view, or how to return count in that context ?


texts: Restrict pagination using entity field query

texts:
I have pagination using entity field query:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->entityCondition('bundle', 'content_type');
$query->pager(3,0);
$result = $query->execute();
$pager=theme('pager');
print render ($pager);

and it is successfully displayed like below,

I need to restrict them to display to number 6 then ... like below:
1,2,3,4,5,6....next,last


texts: Naming conventions for fields machine name in Drupal

texts:
There is a naming convention for the fields machine name such as:

entity_name_field_name

for not shared fields

or

field_name

for shared fields.

When I go to start a project, what should be the naming convention I must use on it?


texts: can't wrap any custom html around nivo slider title text

texts:
As the nivo module makes this content type called 'slide', there is a title to be set and with views you can normally influence this title field adding some html to it to give it some specific css. But somehow this html doens't get wrapped around the text from the title field.
I made this view called 'slideshow' which is displayed as a block.

FORMAT:
Format: views nivo slider
Show: views nivo slider

FIELDS:
Content: title

Unchecked: Create a label, Exclude from display, Link this field to the original piece of conent.
Style settings: Only checked 'customize field HTML'. Then, from the pull-down list, I set HTML element to STRONG just for testing. No css class yet only wanted to see if there would be strong tags in my nodetitle when inspecting element.

Everything else in Content: title is set to default.

Content: Body - pretty much default.
Content: Slide - Settings don't really matter. The rest of the block containing this view works rather fine.

FILTER CRITERIA:
sorted by date. Doesn't really matter.

Everthing else is pretty much set to default and I don't think it's really relevant for this issue if I'm not mistaken.

So to see what's going on, I would go to a page that shows the block containing this view and rightclick on my nodetitle in the nivo slider caption and inspect element. Only to see that any text that is wrapped in the nivo divs is to be found in a p element with no attributes at all. So leave alone a strong element or whatever I would've chosen under content:title settings in my slideshow view.


texts: Webform Entity Checkboxes outputing its HTML in an odd manner

texts:
I have a medium sized web form composed mostly of standard web form elements and is using the Webform Module.

One of the items I have is a set of three Entity Check boxes which get their data from an Entity Reference view that returns only a title, e.g. "Rajasthan". Rajasthan is a node of a particular content type (Destination Detail)

The idea been the person filling out the form can choose one or more destinations by selecting the corresponding check box.

The problem I am having is that the check boxes display the title fine like

but if you inspect the HTML for the Rajasthan element is looks like this:

<input data-drupal-selector="edit-which-destination-asia-79"
    class="form-checkbox" id="edit-which-destination-asia-79"
    name="which_destination_asia[79]" value="79" type="checkbox">

Issues I am having trouble understanding:

1) Entity Check boxes belonging to the same group all have that number in the name, and other attributes but the number is different as it is the node id of that item. The problem here is in trying to PRE-set the default value for the correct item.

I did try put the Entity Check box element into a Fieldset element but this hasn't helped in any way.

2) Secondly the other issue is when the form is submitted, the admin get the node id returned which in a spreadsheet pretty much doesn't mean much to anyone other that me the developer.

I'd have thought that the Check box would have set the value to the title of the item returned from the Entity Reference, why is it using the node ID? I am not even returning that in the entity reference view

I have double checked the view, and it is returning only the textual title of the node which is correct and what I want to show as the value and check box text.

If the value of the check box was set to the actual title I think this would solve the pre-setting issue for me.

Many thanks
John


texts:
I need to have the following html classes with IE conditional comments in my Drupal 8 site:

<!--[if lt IE 9]>      <html class="no-js lt-ie10 lt-ie9"> <![endif]-->
<!--[if IE 9]>         <html class="no-js lt-ie10"> <![endif]-->
<!--[if gt IE 9]><!-->
<html class="no-js">
<!--<![endif]-->

Ideally I would use html_attributes.addClass see this question: Safe to add a class attribute to the HTML element via the theme?

I tried this:

<!--[if lt IE 9]>      <html{{ html_attributes.addClass('no-js lt-ie10 lt-ie9') }}> <![endif]-->
<!--[if IE 9]>         <html{{ html_attributes.addClass('no-js lt-ie10') }}> <![endif]-->
<!--[if gt IE 9]><!-->
<html{{ html_attributes.addClass('no-js') }}>
<!--<![endif]-->

But it seems once you add a class to html_attributes then its printed every time, so my final instance which should only have a class of no-js instead has this:

no-js lt-ie10 lt-ie9 no-js lt-ie10 no-js


texts: Determining What Text Editor to Use By Default Based on Site Location in Drupal 7?

texts:
Okay, so this is something I've been wrestling with for a while. We have several different types of users on our site. For example: Bloggers, Writers (for actual articles), editors, and ordinary users that don't have access to writing blogs or articles.

When a user that falls under the Blogger/Writer/Editor role goes to post on our forum section, he/she is presented with the option of choosing what text editor to use.

What I'd like to do is set things up so that a plain text editor is used by default for the forum, and that a WYSIWYG editor is used for articles and blogs. I don't want to present the user with a choice as to which one to use. It should be a straightforward process.

So what do I need to do in order to define the default text editors?


texts: How to an Add to cart Button to a Content Type?

texts:
Is there a possibility to show add to cart button in node page.

Requirment:

Node will be created along with price
Add to cart button needed in that content type
Users can click on "Add to cart" button
Then ask for the payment like credit card, paypal.

I dont want a huge functionality like Drupal Commerce does. No products, products sku.

Any suggestions or any ideas about how to get this to work?


texts: Add an entity reference select to a form

texts:
I am writing a Drupal 8 module, and I have some code that adds an entity reference field to a form.
$form['commitment']['goal'] = array(
    '#type' => 'entity_autocomplete',
    '#title' => 'Goal',
    '#target_type' => 'node',
    '#selection_settings' => ['target_bundles' => ['goal']],
);

This works, except that I want a select list instead of an autocomplete.
How can I accomplish this?


texts:
I have this form which has 2 radio buttons. If I select the radio button labeled as one way, the return date and time will be invisible; if I select return, the return date and time will be visible. I just want to test if the data have been entered when oneway is selected. This is because when I select return, I can print out all the input values by user, but if I select oneway, I can't do so.

This is the code I am using.

echo "
Booking
";
$submit = $_POST['submit'];

if ($submit) {
  // Check the direction selected by user.
  if ($direction == "return") {
    if ($liner && $direction && $from && $f_date && $f_time && $destination && $t_date && $t_time && $txttotal) {
      echo "$liner/$direction/$from /$f_date/$f_time/ $destination/$t_date/$t_time/$txttotal  ";
    }
  }
}


texts: How to change the url pattern of user revisions?

texts:
How can i change the url pattern of a user revision ? I want to change

users/jon-doe/revisions/123/view

to

users/jon-doe/archive/123/view

There is no option in pathauto to influence the url patterns of revisions.


texts: Vocabulary Term Translation Edit/Delete Page Get Access Denied/ Doesn't Function Correctly

texts:
I currently have a taxonomy term with multiple translations. When I visit the translate tab for the term it does list all of the languages properly.

However no matter what translation I'm attempting to edit, it takes me to the edit page for English. I found that it seems to automatically send you to the edit page of the translation that matches the user's set Site language.

If I change the site language of the admin user to Spanish no matter what edit link I click it only takes me to the Spanish translation. The admin user has access to all allowed languages so I'm not sure why it would restrict all access to the specified site default language.

Side note if I attempt to delete a specific translation it deletes all translations.
If I manually enter this path

/taxonomy/term/{taxonomy_term_id}/translations/edit/{language}

I get an access denied page.
I shouldn't ever get an access denied page because I'm an admin with all
permissions enabled.
I do believe this path should exist because looking at the routes associated with the taxonomy term entity does contain that path. Here is some of the content of the entity info produced by devel.

[links:protected] => Array
    (
        [canonical] => /taxonomy/term/{taxonomy_term}
        [delete-form] => /taxonomy/term/{taxonomy_term}/delete
        [edit-form] => /taxonomy/term/{taxonomy_term}/edit
        [create] => /taxonomy/term
        [devel-load] => /devel/taxonomy_term/{taxonomy_term}
        [devel-render] => /devel/taxonomy_term/{taxonomy_term}/render
        [devel-definition] => /devel/taxonomy_term/{taxonomy_term}/definition
        [token-devel] => /taxonomy/term/{taxonomy_term}/devel/token
        [drupal:content-translation-overview] => /taxonomy/term/{taxonomy_term}/translations
        [drupal:content-translation-add] => /taxonomy/term/{taxonomy_term}/translations/add/{source}/{target}
        [drupal:content-translation-edit] => /taxonomy/term/{taxonomy_term}/translations/edit/{language}
        [drupal:content-translation-delete] => /taxonomy/term/{taxonomy_term}/translations/delete/{language}
    )

Why can't I access the edit forms for the translations that don't match the users set site language? How can I fix this?


texts: Can I automatically regenerate all images after using Drush image-flush?

texts:
I used drush image-flush to delete all generated image style images on my site.

I know that image style images are automatically regenerated when you try to view them in a browser, but is there a way to "prime the cache" and automatically regenerate all image styles for all images after they have been deleted?


texts:
I have
node type= activation
with fields = active_date, status

Now i want to select from node type "activation", where is active_date (less as) today and status=active and get nid's.


texts: How to extend (alter) webform submit function to add more funcitionality?

texts:
I have created a webform, whose id is webform_client_form_1, I have 3 fields:

  Name:
  Email:
  Phone number:

Now I want to extend webform submit function to send SMS to that Phone number. I have a working PHP script which sends SMS, using 3rd party service.

So my question is how to extend the submit function for webform? Is there any hook available or there is other method to do it?

Submit function for webform is: webform_client_form_submit


texts: What should be the optimum values for Minimum cache lifetime and Expiration of cached pages

texts: i am working on a mobile app. Using drupal json views i am parsing the data and displaying on the device. It takes nearly 10 sec to load 10 records on the device. Initially i thought this might be due to slow internet, but that is not the issue. Later i came to know this is something related to cache. So can any one help me to minimize the loading time by suggesting minimum cache lifetime and expiration of cached pages .


texts: How to describe dynamic config.settings values in schema.yml

texts:
I have a module config settings.yml file with a dynamic list of the fields attached to a user entity, eg
archive:
  directory: user-history/archive/
  filename: user-history-archive
  max_cardinality: 5
base_fields:
  uid: true
  name: true
  pass: true
  mail: true
  timezone: true
  status: true
  roles: true
  created: true
  changed: true
  access: true
  login: true
  init: true
  langcode: true
  preferred_langcode: true
  preferred_admin_langcode: true
attached_fields:
  field_alpha_text: 1
  field_beta_term: 1
  field_paragraph: 1
  field_user_story: 1
  user_picture: 0
  field_delta_value: 1
no_change:
  ignore: true
  delete: ''

I am unable to find out how this structure should be described in the module schema.yml file so that config_inspector does not flag the schema as invalid.
I have tried vaiations on
user_history.settings:
  type: config_object
  label: 'User history settings'
  mapping:
    no_change:
      type: mapping
      label: 'No change'
      mapping:
        ignore:
          type: boolean
          label: 'Ignore records with no change'
        delete:
          type: string
          label: 'Delete "no change" records older than'
        batch:
          type: integer
          label: 'Batch size for "no change" record delete'
    base_fields:
      type: mapping
      label: 'Base fields to be tracked'
      mapping:
        uid:
          type: boolean
          label: 'Uid'
        name:
          type: boolean
          label: 'Name'
        pass:
          type: boolean
          label: 'Password'
        mail:
          type: boolean
          label: 'Mail'
        timezone:
          type: boolean
          label: 'Timezone'
        status:
          type: boolean
          label: 'Status'
        roles:
          type: boolean
          label: 'Roles'
        created:
          type: boolean
          label: 'Created'
        changed:
          type: boolean
          label: 'Changed'
        access:
          type: boolean
          label: 'Last access'
        login:
          type: boolean
          label: 'Login'
        init:
          type: boolean
          label: 'Initial mail'
        langcode:
          type: boolean
          label: 'Langcode'
        preferred_langcode:
          type: boolean
          label: 'Preferred langcode'
        preferred_admin_langcode:
          type: boolean
          label: 'Preferred admin langcode'
    attached_fields:
      type: mapping
      label: 'Attached fields to be tracked'
      mapping:
        attached_fields.%key:
          type: integer
          label: [label]
    archive:
      type: mapping
      label: 'Archive settings'
      mapping:
        directory:
          type: string
          label: 'Directory for archive files'
        filename:
          type: string
          label: 'Name for archive files'
        max_cardinality:
          type: integer
          label: 'Maximum field cardinality for separate column values'

but without success.
Any suggestions please?


texts: Custom redirect specific page after edit

texts:
With my Drupal website ( which is much more custom than drupal ) I've got node referenced in another ( ex. an article in a custom page ).

I want the ability to easily edit the referenced content. To do that I've put a button with the link:

<?php print $base_url; ?>/node/<?php print $article->nid; ?>/edit?destination=<?php print urlencode('node/'.$node->nid); ?>

Sadly Drupal doesn't care about the destination and redirects me to the article node and not the current node it was into.


texts: Is it safe to delete the /module folder?

texts:
I see that the /module folder still exists and a /module/contrib folder has the updated module folders in it.

composer update has updated the site to 8.9
composer update will not update any of the modules still shown in /modules (webform for example)
When running composer update, Composer reports installing Webform 8.5.16, but it doesn't in fact install it and the site still reports Webform 8.x-5.4-beta1

Many other modules are also not updating
The modules in /module are the old versions, while the newer versions are in /module/contrib
Drupal think the modules are in the old path (for example, /module/webform)

What is the safest way to fix the problem?
Delete folders in /module folder other than contrib and rerun composer update?

I have already executed the following commands.

composer composerize
composer cc
composer self-update
sudo rm -Rf composer.lock vendor/
composer update


texts: Use orConditionGroup with query (non entity)

texts:
I've used orConditionGroups with queries before. Specifically with entity queries. But now I have a custom sql table I created separate from drupal but still on the same database I have access to. I want to update a row if any of the fields are different but I'm having generating the or statement. Here was my attempt.

$connection = \Drupal::database();
$orConditionGroup = $connection->orConditionGroup()->condition('address', $fulladdress, '!=')->condition('full_name', $fullname, '!=')->condition('telephone', $workphone, '!=');
  $connection->update($table)->fields(['full_name' => $fullname, 'address' => $fulladdress, 'telephone' => $workphone, 'email' => $email])->condition('id', $id)->condition($orConditionGroup);

But I get the error

  undefined method
  Drupal\Core\Database\Driver\mysql\Connection::condition()

Which makes sense since the connection class isn't a query object on its own, but not sure how else to tackle this. How would I create an orConditionGroup for just a plain direct sql query that isn't a drupal entity or anything like that?


texts:
I have a parent theme with templates defined in a directory called templates. Within that folder, I have directories like base (page, html, block etc twig templates), views, and menu folder.

My subtheme, which is based on the parent, will not load these templates even though base_theme is set in the .info.yml file.

What am I missing? If I copy the templates into the subtheme, they begin to work.


texts: How to render Entityform submission (entity) without DOCTYPE and HEAD tags?

texts:
I need to render entity as a part of page instead of individual page. By this I mean I want to able to render it without DOCTYPE declaration and HEAD tags.

Typically this could be done within html.tpl.php but I haven't found the correct naming  convention or other solutions.

How to render entity programmatically in a bare div container using Entity view modes? This shouldn't be a huge problem since e.g. Views can list entities using a certain display/view mode. I'm trying to render it in a Rules config to send it out as email.


texts: How to count the number of calls to a rest service?

texts:
I created a rest service which every user on the site calls from a product we are selling.

How do I count the number of calls for every user so I can generate a report of this.

D8


texts: How to trigger a rule whenever users update their picture

texts:
Using Drupal 7 and the Rules module
I need to trigger a rule whenever users update their user-picture.
I tried using the event "After updating an existing user account" which does trigger the rule, however it is too general and triggers on many irrelevant events, such as change of user role, or any change the user might make their account fields.
I tried to set a condition, a data comparison between the account before and after. something like account-unchanged:picture:fid,  but 'picture' is an invalid parameter..
How could this be done?
d


texts: I am using drupal commerce module. In my site, there are two types of products - a regular product, and a product service. The customer can add both product types to the cart.  On the Checkout page, I would like to be able to see a product total for the regular products and the product services separately.  How do I do this?


texts:
I have Drupal 7 with biblio 7.x-1.0-rc7 module.

How can I set up the biblio module that the initial of an author to be more then one character. I know it is a strange request, but e.g. in Hungarian the character combination zs, sz, ty, gy, ... are one letter (sound).
So a name like Jeno Szabo has initial J. Sz.
This thing happens in other languages too, like Romanian: Ge, Ce, Ghe, Che, ...
Pop Gheorghe initials are P. Ghe.

How can I set so in case of some authors I would define the initial in the biblio module?

I found the filed in author setup: Prefix _ First Name _  Initials _ Last Name _ Suffix _
I don't understand how the Initials filed works (maybe this is not the solution). for example: author Jeno Szabo I want to be displayed as Jeno Sz.

So the author setup filed should be like:

Prefix _ First Name Szabo  Initials Sz J Last Name Jeno Suffix _
result: Jeno SSz J

OR

Prefix _ First Name Szabo  Initials z Last Name Jeno Suffix _
result: Jeno Sz in the publication, but if I search between the authors list still appears as Jeno S.
So, this is deinitly not the correct solution to generate initials from two character.

My bug report can be found here: https://www.drupal.org/node/2460733


texts: Result should return a value greater than or equal to the selected facet

texts:
Here is the scenario. I have created a facet which list all GPA's (these are decimal numbers). e.g. 2.0, 2.5, 3, 3.5 etc.

What I wanted is when say a user choose 2.5 GPA from the facet, the returned contents should be contents that has a GPA of 2.5 and above.

I have been trying to figure it out using views alone, but I can't get it to work. If It can be done with just views, can you please suggest what to do? Or do you think this can only be achieved by code?


texts:
I have a 2 content types.

Article
Page

and the Article content type can reference pages from an entity reference field.

Now I want to display a block on Article nodes that have a same reference.

So I tried this:

Create a views block listing Articles.
Add some fields.
Add a relationship field_page_reference: Content
Add contexual filters of Content Id and provide default value to Content Id From URl and Specify validation criteria set to Content and select article.

But it doesn't work? Any idea?


texts: Prevent empty  item in Views (HTML List format)

texts:
I'm using the HTML List format for my View, which has three fields (nid and title, both excluded and Custom Text).

The content of Custom Text is as follows:

View Project

[title]

Lorem Ipsum

I've noticed that using the
 item in my Custom Text field will result in an empty
 item wrapping my content. As such, the output I get from this is as follows:

View Project

Item 1

Lorem Ipsum

View Project

Item 2

Lorem Ipsum

My question to you is: How do I remove those empty
 tags?

I tried to set wrapping element to none but to no avail. I've also attempted to do it with an unformatted list and create everything in custom text but then I'd have a
 for each row and I do not have access to data-content="#colio_c[nid] that way.

An export of my view is available at http://ideone.com/KyNGO4


texts: How to modify module output via another module - whois module?

texts:
In drupal 7, can we access and read return value of a specific module via another module?

Specifically, I am using the whois module, and would like to access its output from a custom module, with the goal of modifying the output.

How can I do this?  What is the suitable hook function? How can I access the output from whois before it gets rendered.

Please guide me.

Thanks a lot.


texts: Attach behavior only to the file upload button

texts:
I have a form with a managed_file field where I need to know when the upload button is clicked, and then perform an action. I decide to make it by attaching a behavior to my button but it also trigger when I click on the remove button. Here is my code:

Drupal.behaviors.mattButtons = {
    attach: function (context) {
    jQuery('input.form-submit', context).bind('mousedown', Drupal.matt.checkFile );
    }
};

Drupal.matt = Drupal.matt || {
    checkFile : function(){
        console.log("Hello");
        var url = jQuery('.file a').attr('href');
        console.log(url);
    }
};

Is there any way to only attch my behvior on the file upload button?


texts: Convert exposed dropdown filter to links Drupal Views

texts: So I have a date filter for my view which filters the view by post date(year). I already used BEF(Better Exposed Filters) but the only available options there is Default select list or jQuery Date Picker. I've attached some pics here, the first one is what's the filter looks like currently and the second one is how it should look. Need to convert the dropdown to look like the second pic. Thanks!


texts: Module content type not removed after uninstall

texts:
My module adds content types by implementing hook_node_info. After disabling and uninstalling the module, the content type is still in the database and is merely marked as disabled.

NOTE: I also add create and instantiate custom fields for the created content type.

Since according to this answer content types created in hook_node_info are deleted automatically, is my problem a sign if DB inconsistency or am I doing something else wrong.

Code:

function test_core_node_info() {
    // Name of the proper localization function
    $t = get_t ();
    // Adding author
    return array (
            'test' => array (
                    'name' => $t ( 'Test' ),
                    'base' => 'test_module',
                    'description' => $t ( 'Test' ),
                    'title_label' => $t ( 'Title' ),
                    'locked' => TRUE
            )
    );
}

-- EDIT --

I mentioned removing instead of uninstalling. This is corrected now.


texts: how to count results in a Calendar view?

texts:
I enable the calendar module, then "Add view from template" on /admin/structure/views/add-template, but I cannot count nodes published at the same day in the month view by following this tutorial.
I want events occurred in the same day can be counted like "3 events occurred" other than the original output in the red box, and the counted field can be rewritten.

I tried aggregation feature of views, but no luck.


texts:
I am producing large query results that can exceed a sizable PHP memory limit (128 Mb). I've been trying to address this and came across unbuffered queries. Unfortunately, these only seem to be supported by MYSQL while I'm using PostgreSQL. There does seem to be a similar process for PostgreSQL involving cursors, but I'm unsure how to implement them within the Drupal framework using db_query(). Demo implementation with plain PHP can be found here.

My alternative solution would be to call a query multiple times with restrictions to LIMIT and OFFSET. Query performance is reasonably good, so this may be a viable solution as well. With this method I have yet to figure out how to divide queries into chunks by memory size. Instead, I would have to use a fixed row range. This could be a problematic approach given rows can significantly differ in size.


texts: Exclude a .js file on certain Drupal 6 paths

texts:
I've run into a dilemma with Drupal and SSL.

I'm utilising the Disqus module, however, Drupal loads the Disqus .js files on all pages including the cart and checkout addresses. This would be fine except that it includes non-secure paths to external JS files that contain more non-secure paths, which means that browsers show SSL errors.

I'm trying to find some way to just exclude these .js files on particular paths. I've seen information on excluding files entirely or including them, but not just from these path's.

Any help would be greatly appreciated, thanks!


texts: Drupal View Filter Criteria "Contains Taxonomy"

texts:
I need to filter based on taxonomy term in my view, I have set up this filter however I would like to return nodes that 'contain', not "Is one of". See screenshot below:

Is there a module or a way I can achieve this? If I put 'vod' instead of 'vodafone' it does not return anthing:

The end goal is to filter nodes from the URL e.g. localhost/numbers?field_company=vod will return nodes for vodafone and vodafoneblahblah.


texts:
I created a new user field to keep count of comments. I want to increase it by 1 after a user posts a comment and decrease it by 1 when comment is deleted.

Is there any way I can use rules to do this?

I know I can use views aggregation to get comment count, but I don't want to use this method.


texts: Drupal installation profile: menu_link_save() doesn't work for "import" path

texts:
In my installation profile, I am trying to add a menu link for the /import path (from feed_import module). menu_link_save() works for all my menu paths with the exception of /import. Anyone have ideas why?

So, this works and creates a menu path to /user:

$link = array('menu_name' => 'menu-authenticated', 'link_path' => 'user', 'link_title' => 'Account');
menu_link_save($link);

But this does not:

$link = array('menu_name' => 'menu-authenticated', 'link_path' => 'import', 'link_title' => 'Import');
menu_link_save($link);

After installation is finished, /import path works (feeds_import is installed and enabled in the installation profile), but the menu link was not created.

Any help would be much appreciated. Thanks!


texts: Run module after 'Order status gets updated' Action runs

texts:
I need to load the order object and run the init function when the order status is updated in Ubercart instead of using hook_menu(). How do I hook into the "Order status gets updated" action?  The order state should be "Payment Received."

Does it have something to do with the following code:

function uc_order_rules_event_info() {
  $events['uc_order_status_update'] = array(
    'label' => t('Order status gets updated'),
    'group' => t('Order'),
    'variables' => array(
        'order' => array(
            'type' => 'uc_order',
            'label' => t('Original order'),
        ),
        'updated_order' => array(
            'type' => 'uc_order',
            'label' => t('Updated order'),
        ),
    ),
);

function hemo_menu() {
  $items['add_listing'] = array(
    'page callback' => 'init',
  );

  return $items;
}

function init() {
  foreach ($order->products as $product) {
    $array = data_array($product->data['attributes']);

    foreach ($array as $property => $value) {
      $product->$property = $value;
    }

    $product->primary_email = $order->primary_email;
    create_directory_listing($product);
  }
}

function data_array($arr) {
  $array = array();

  foreach ($arr as $key => $value) {
    foreach ($value as $key2 => $value2) {
      $chars = array(" ", ",", "'", "(", ")", "__");
      $key = str_replace($chars, "_", strtolower($key));
      $value2 = ucwords($value2);
      $array += array("$key" => $value2);
    }
  }
  return $array;
}

function create_directory_listing($product) {
  $node = new stdClass();
  $node->type = 'directory_listing';
  node_object_prepare($node);
  $node->language = LANGUAGE_NONE;
  $node->uid = $product->order_uid;
  $node->field_order_product_id[$node->language][0]['value'] = $product->order_product_id;
  $node->field_order_id[$node->language][0]['value'] = $product->order_id;

  if (isset($product->attendee_name)) {
    $node->title = $product->attendee_name;
  }
  if (isset($product->institution)) {
    $node->field_institution[$node->language][0]['value'] = $product->institution;
  }
  if (isset($product->lab_group)) {
    $node->field_lab_group[$node->language][0]['value'] = $product->lab_group;
  }
  if (isset($product->address)) {
    $node->field_address1[$node->language][0]['value'] = $product->address;
  }
  if (isset($product->address2)) {
    $node->field_address2[$node->language][0]['value'] = $product->address2;
  }
  if (isset($product->city)) {
    $node->city[$node->language][0]['value'] = $product->city;
  }
  if (isset($product->state_or_region)) {
    $node->field_zone[$node->language][0]['value'] = $product->state_or_region;
  }
  if (isset($product->country)) {
    $node->field_country[$node->language][0]['value'] = $product->country;
  }
  if (isset($product->phone)) {
    $node->field_phone[$node->language][0]['value'] = $product->phone;
  }
  if (isset($product->primary_email)) {
    $node->field_email[$node->language][0]['value'] = $product->primary_email;
  }
  if (isset($product->zip_or_postal_code)) {
    $node->field_postal[$node->language][0]['value'] = $product->zip_or_postal_code;
  }
}


texts: How do I troubleshoot specific Products missing from Commerce Search?

texts:
Using Commerce Kickstart 2

Having a situation where certain Products simply do not appear in the Search results. Is there a way to troubleshoot specifically -why- certain products (or other content) are not appearing in the search index?

I looked through the search_api_db_product_display table and sure enough, the missing node is -not- there.

So: Is there a log or table which displays each node and index term and/or -why- a particular node was included/excluded?

Just to be clear: If I enter the URL for the Product directly, it displays fine.

ALSO: I can search from admin/commerce/products and the Product shows up as well as from admin/content.

Perhaps related: There seems to be a known issue where adding new products does not automatically update the index. But I have cleared the index and rebuilt several times and it makes no difference.


texts: How to get token of parent entity in paragraph?

texts:
I have a paragraph, which is referenced by a node. Now I am trying to pass field values of node to the paragraph using tokens. I'm only aware of [paragraph:parent_id] and [paragraph:parent_type] but don't know how to get specific field values.

What I've tried so far without success:
[node:field_foo:value]
[paragraph:field_foo:value]
[paragraph:node:field_foo:value]
[paragraph:parent:field_foo:value]
[paragraph:parent:entity:field_foo:value]

The list of available tokens does not contain parent tokens. Is it even possible to get token of the parent entity? And if so, how?


texts: How to sort images in Views by their position?

texts:
If you have multiple images uploaded to your node, on the edit mode you can drag those images up and down and position them. How do I set that top image is shown first in Views?

Which sort option is that for the image field?


texts: How to keep labels displayed for all facet filters

texts:
I have Search API with Facets API set up.  For my checkbox selections, how can I prevent the facets from hiding when they aren't available?  I want all of the facets to be listed, even if not available.

I can't seem to find an easy way to do this.

EDIT: I may have incorrectly used the term "facets" here. I mean to say filter options.  So, if blue, red, and green are options, but the only available results are blue, I still want red and green to display as check boxes.


texts: validating textfield input with ajax on every key entry

texts:
I'm new to Drupal and Javascript, so please bear with me. I have a simple class project to create custom validation on textfields without using select options or checkboxes. For one of the fields, the only valid inputs are 'right' or 'left'.

I have validation upon submit working, but I wanted to use ajax to check user input key by key, and display an error message before clicking the submit button. (As soon as it's clear the input will not be 'right' or 'left').

The function is working, but drupal pauses for a half second or so with every keyup while it does the ajax call, making it not very user friendly or practical to use. Hitting backspace to clear the field before drupal 'resumes' even navigates away from the page.

I have looked extensively online for resources on this, and have not found an example or module that seems to address this particular issue. Modifying autocomplete_path seemed like the best option, but I can't figure out how to modify it for my purpose.

I have the module on my github here, or here are the parts in my module dealing with ajax.
In my form:

$form['direction'] = array(
    '#title' => 'Direction',
    '#type' => 'textfield',
    '#description' => 'Enter the shift direction',
    '#element_validate' => array('validate_direction'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#required' => TRUE,
    '#ajax' => array(
            'event' => 'keyup',
            'callback' => 'validate_direction_callback',
    ),
);

and then the actual ajax callback

function validate_direction_callback($form, &$form_state){
    $commands = array();
    $commands[] = ajax_command_html('#error_message', render($form['direction']));
    $commands[] = array(
        'command' => 'validateDirectionCallback',
        'selectedValue' => $form_state['values']['direction'],
    );
    return array('#type' => 'ajax', '#commands' => $commands);
}

I didn't include the js file here because it didn't affect the pausing even when it was commented out. Thank You! Oh, and I am using Drupal 7.39.


texts: How to use Tokens [current page arguments]?

texts:
I dont know how to use tokens to get arguments from url.

I have url: site/country

On this page i have links to terms, i want them to have in alias first argument from current page /country/term-name.

But instead of this my terms have alias /batch/term-name
Can i have a little help and show me a little example of how to use tokens of current