texts:
In my Drupal 7 site I created a custom search form with an autocomplete field that shows the node title. I want the node title point to the node page. For this I am using the following code in a custom module.

function autocomplete_engine($text) {
    $results = array();

    $result = db_select('node', 'n')
    ->fields('n')
    ->condition('title', db_like($text) . '%', 'LIKE');
    $nodes = $result->execute();

    foreach ($nodes as $row) {
        $node = node_load($row->nid);
        $output = '';
        $output .= l($row->title,'node/'.$row->nid);
        $results[$row->title] = $output;
        }

    $result_term = db_select('taxonomy_term_data', 't')
    ->fields('t')
    ->condition('name ', db_like($text) . '%', 'LIKE');
    $terms = $result_term->execute();

        foreach ($terms as $term) {
        $out = '';
        $out .= $term->name;
        $results[$term->tid] = check_plain($out);
        }

    drupal_json_output($results);
 }

When I click on the node title nothing happens. How do I redirect when the result is a node and not a term name?


texts: Categorize the contents of content type without creating a different template file for each

texts:
I want to apply similar style to the nodes of same content type (style may vary or may be same between content types,  but will definitely be same for the nodes of same content types) without creating a template file for each of the content type.

I know one way is to create a template file as node-TYPE.tpl.php but I am looking if there is some other way.


texts:
I'm aware of this question Find all aliases for a given node - but this appears to be for 7, and I'm looking for a solution for 8.

I'm also aware of the AliasStorage and AliasManager classes, which respectively provide the lookupPathAlias and getAliasByPath methods. But these methods only return one path alias per path, even though I have multiple defined.

What is the best way return all aliases for a path?


texts: editing how a field is output (changing commas to )

texts:
I am getting data from an outside source to populate some of my fields. It comes in as a string separated with commas. In order to display this data in a list format. I did this:

$commaString = ($items[0]["#markup"]);
$NoCommaString = str_replace("," , "<br />", $commaString);
$items[0]["#markup"] = $NoCommaString;

In field--field-MYFIELD.tpl.php. So now field displays like this:

item 1
item 2
item 3

instead of

item 1, item 2, item 3

Which is exactly what I want, yay! However, I'm new to Drupal and am worried I'm bypassing something or not using an API when I should be. So is there a better way to do this?


texts: How to get attachments out of a twig file

texts:
How do I get the attachments out a twig file and add them to a build array?

If there is a twig file with

{{ attach_library('mytheme/pullquote') }}

And because it's in an ajax response, I need to get the attachments out without rendering the page, how do I get a new build array with that library attached?

In my controller:

   $build['pullquote'] = [
      '#theme' => 'pullquote',
      '#quote_text' => $quote_text,
      '#attribution_name' => $attribution_name,
      '#attribution_title' => $attribution_title,
      '#size' => $size,
    ];

    $response = new AjaxResponse();
    $response->addCommand(new EmbedInsertCommand($build));
    return $response;

Because the library is added in twig and not in the build array, it's not coming through in the response.

The EmbedInsertCommand is from the embed module, which entity_embed inherits from, at embed/src/Ajax/EmbedInsertCommand.php

which uses the CommandWithAttachedAssetsTrait, with this function:

 /**
   * Processes the content for output.
   *
   * If content is a render array, it may contain attached assets to be
   * processed.
   *
   * @return string|\Drupal\Component\Render\MarkupInterface
   *   HTML rendered content.
   */
  protected function getRenderedContent() {
    $this->attachedAssets = new AttachedAssets();
    if (is_array($this->content)) {
      $html = \Drupal::service('renderer')->renderRoot($this->content);
      $this->attachedAssets = AttachedAssets::createFromRenderArray($this->content);
      return $html;
    }
    else {
      return $this->content;
    }
  }

Unfortunately, AttachedAssets::createFromRenderArray misses libraries added within twig.


texts: Display new tag to the newly added content

texts:
I am trying to show "NEW!" to the recently added.
I know there is something to do with the Views module, but I couldn't find how to get it done.

How can I achieve this?


texts: Token's available "Replacement patterns" nested table should only be displayed on-demand

texts:
The Token module provides hooks to other modules to serve their own tokens. Multiple modules that support Token integration can generate a really huge nested table tree when displaying the available tokens in the field settings:

This can lead to out-of-memory issues in Views settings or regular field settings:

Earlier I created an issue related to this problem: http://drupal.org/node/1836264. Until a possible solution comes there (e.g. a patch), I would like to solve it my own (it doesn't matter if I temporarily have to "hack" Token's core): I would only like to load this table with the available tokens "on-demand" with AJAX or any other possible solution.

Do you have any ideas how to solve this?


texts: How do you add help text to a form item?

texts:
I would like to change the help text for an input field. My form ID is views-exposed-form-events-page-1. I have a text field that I want the helpful hint to appear below. The field ID is edit-field-event-date-value2, I think, based on the HTML.

From

<input class="form-control form-text" type="text" id="edit-field-event-date-value2-value-datepicker-popup-0" name="field_event_date_value2[value][date]" value="18/12/2019" size="20" maxlength="30" />
Date

 E.g., 18/12/2019

I thought that this would work, but I'm not seeing any help text appearing under the form field.

function mytheme_form_views_exposed_form_events_page_1_alter(&$form, &$form_state, $form_id) {
  $form['edit-field-event-date-value2']['#attributes']['description'] = 'DD/MM/YYYY';
}

What am I doing wrong?


texts:
I am using the CKeditor and IMCE modules.

When in edit mode, I can see the following text formats in the dropdown menu under the body text area:

Filtered HTML
Full HTML
Plain text
PHP code

I am logged in as an admin, selecting different text formats from the dropdown menu does not change anything on the page. For example, selecting Plain text, doesn't remove the icons at the top of the text area. What am I doing wrong/missing?

Selecting the PHP code option however does change the appearence of the text area in a sense that the icons disappear.


texts:
I'm using the Follow module and I'd like to modify the form, where I can preallocate the beginning of the form, like in the picture shown below:

May I know how can this be done?


texts: How do you render a set of checkboxes without using drupal_get_form()?

texts:
I want to use a '#type' => 'checkboxes' render array to display some checkboxes on the page. They aren't going to be part of a form that ever gets submitted, as they are purely for browser-side user interaction. So I don't need any of the extra functionality provided by drupal_get_form(). I just need a few <input type="checkbox"> elements.

Unfortunately, Drupal appears to simply refuse to render '#type' => 'checkboxes' render arrays unless you pass the array through drupal_get_form(). When I try, absolutely nothing except

 Landmarks

gets rendered.

Is there any way to get Drupal to render an <input type="checkbox"> element without using drupal_get_form()?


texts:
I'm still pretty new to Drupal. I needed help creating a blank page template for a certain content type. When I say blank, I mean the only thing thats displayed on the page is the render($page['content']) information. None of the markup that is added with the html.tpl.php template.

To give you a wider perspective of what I'm trying to accomplish - I'm trying to use the assets that are housed here in an .ajax request to display elsewhere.

Thanks for your time.


texts: Hide/disable webform values on select list if a value has been chosen once

texts:
I would like to create a webform with a select list/radios where each option on the list can be chosen only once (unique). I can of course check "Unique" in Validation settings but this is not an optimal solution because users have to "guess" what values are still accessible.

Is there a possibility to create a webform field where:

the field is required (select list/radios),
each value can be checked only once (unique),
checked/chosen values are hidden/disabled if they have been used once by other users.


texts: How do I programmatically set the preferred language for a user?

texts:
I would like to update the preferred_langcode of a user as soon as he changes the language in a language switcher block.

I'm already aware of the getPreferredLangcode method mentioned in https://api.drupal.org/api/drupal/core!modules!user!src!Entity!User.php/function/User%3A%3AgetPreferredLangcode/8.6.x and looking for a setPreferredLangcode method, if one exists.

If not, what other options do I have?


texts: how to create categorized webforms in drupal?

texts:
I want to create a multiple Forms in my site . so i am going with the webform module , i want webforms in such a categorized as display below ,
general inquiry  Forms

general feedback
general inquiry
Training request

Product  Inquiry Forms

Product 1 Inquiry

Product 2 Inquiry

Product 3 Inquiry

Product 4 Inquiry
Service

Service Request

service Feedback

online parts request
In this  general inquiry  Forms is like  a category and genaral feedback and inquiry is webforms. so how can i create that for prodcut inquiry and service categorized multiple form.

and there are many fields are common in that different form , so if i have to create different fields for different form or can i use one field in a multiple time in different forms.
Thanks,
vipul.


texts: How to add reviews alongside ratings using the Fivestar module?

texts:
I want the user to write a review and rate (field while editing).
I want the other users to write their comments with their rates (field while editing).

I want to see the main rate (field while viewing) as result of user's rates.

The rates submitted on comment go in the main rate, but the author's rate not.

How can I fix this problem? I'm wrong, or is it a limitation of module?

I use Drupal 7.


texts: How can I do a Drupal to Drupal migrate that includes the migration of the "url alias"?


texts: How should I go about placing the content of a field from a content type into a block?

texts:
My case is this:
I have a content type called 'Test Type' with 2 fields: Body (text area), Slideshow (Unlimited list of images)
When I create an instance of Test Type and it renders, my goal would be to have the content of the Slideshow field go to a different region, let's say the header. First thought was to create a custom block that would hold a reference to the field content, but that does not seem to be an option. Is this possible to do through the UI with certain settings or would I be better off writing a module. The module Field as Block is pretty much exactly what I was looking for but it seems not work right now.


texts: How to change front page template based on url alias?

texts: I have many homepages and template file for every homepage and also a custom template for the front page the problem is when I change the default front page in admin/config/system/site-information to any other alias the page still have the page--front.tpl.php styles not the custom node style page--node--68.tpl.php , any help please ?


texts: How to place a menu link in views footer?

texts:
I have created a page that displays the latest news. On the right side of the page using context module i have placed a "Recent news" block (Created using views). The recent news block shows 4 recently created news. I have added a "link" field in each item to show "Read more" on the block.

I have created another page using views which displays the complete news created so far. I call this as news archive. My problem is i have to create a "To news archive" menu in the "Recent block" last line.


texts: Passing multivaluearray from php to javascript after ajax call

texts:
The passing of the array works only one time. After an ajax call the new array is not passed to drupalSetting only the 1st array will displayed multiple times in the console. I tried it with a static test array, with a dynamic array, with json_encode() and such other things.

My PHP script:

$form['#attached']['drupalSettings']['variable'] = $vars;

devel:

Array (
    [0] => Array (
            [0] => val1
            [1] => val2
            [2] => val3
        )
    [1] => Array (
            [0] => val1
            [1] => val2
            [2] => val3
        )
....
)

My jQuery script:

(function($, Drupal, drupalSettings) {
    Drupal.behaviors.vShop = {
        attach: function (context, settings) {

            var loadVar = function(event, request, settings) {
                var varArr = drupalSettings.variable;
                console.log(varArr);
            };

            $( document ).ready(loadVar);
            $( document ).ajaxComplete(loadVar);
        }
    };
})(jQuery, Drupal, drupalSettings);

console:

Object { 0: {…}, 1: […] }

I think the main issue is that the drupalSettings.variable don't get the new array from the form after the ajax call.The attached values in the form are changed correctly.


texts: Drupal migration api: set custom plugin as source in «process» section

texts: I migrated nodes including metatags from D7 to D8. As soon as metatags are not field in D7 I do not have it as common source in d7_node plugin. Of course, I can extend this plugin with my own and make join with metatag database table. But this variant seems for me not ideal. As I understand I can't execute any db queries inside process plugins, so I need to feed my custom source plugin result to a metatag field in a process section of my migration config. How can I do it and is it possible?


texts:
Has anyone seen modules that provide image effects for post-generation compression?

I'm thinking things like running the image through a tool like optipng, or similar.


texts: Create a new user programmatically and mimic the registration flow?

texts:
I notice we already have an example for programmatically creating a new user in Create a user programmatically and give they a role. However, this example uses user_save(), which does not mimic the registration process, (e.g. no email is sent to the user).

Could I use user_register_submit()?


texts: How to resolve my timeout during import of my Drupal database using phpMyAdmin?

texts:
I downloaded my Drupal database (in MySQL format, and using phpMyAdmin) from my new web site. I am attempting to import it using phpMyAdmin on my local Win 7 computer running Acquia Dev Desktop. It generates a script timout on Drupal table cache_menu with 31 rows imported.

I started the import again. This time the row count in cache_menu is 62. I've been doing this for hours! The row count goes from 31, 62, 93, 124, 155, 186, ... about 30 rows each time. The odd thing is that only 66 rows exist in cache_menu on bluehost.

Here are the versions of software involved:

Bluehost mysql version 5.5.42-37.1-log InnoDB
Acquia mysql version 5.5.42-37.1 InnoDB

Bluehost phpmyadmin version 3.5.8.2
Acquia phpmyadmin version 4.3.7

I tried the suggestions as described in "Maximum execution Time in PhpMyAdmin". Unfortunately, these suggestions resulted in Internal Server Error.

Any idea what's going on?


texts: How to troubleshoot Push Notifications module

texts:
I'm trying to get the Push Notifications module to work correctly. So far I have successfully gotten my device to register with the service, and now I am trying to test the push back to APN. I went through This entire process and created the .pem file from my certification. When I attempt to test the push, I get the following error

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

I'm at a bit of a loss on how to proceed, or how to further troubleshoot. I've tried looking up the error but the definitions seem vague.


texts:
How can I add breadcrumb to a page in my attendance module.

I have used the following hook, but it changed the breadcrumb for all pages in other modules also.

function attendance_init() {
// set the breadcrumb
$breadcrumb = array();
$breadcrumb[] = l('Home', '<front>');
$breadcrumb[] = l('People', 'group/node/'. arg(2) .'/people');
$breadcrumb[] = l('Attendance', 'group/node/'. arg(2) .'/people/attendance');
drupal_set_breadcrumb($breadcrumb);

}


texts:
I'm trying to create a custom search form that uses ajax to perform the actual search and return the located objects as html.

Currently I'm doing something like this:

function example_module_search_form($form, &$form_state) {
   $form['title'] = array(
     '#type' => 'textfield',
     '#value' => '',
   );
   $form['submit'] = array(
      '#type' => 'submit',
      '#ajax' => array(
        'callback' => 'example_module_search_callback',
        'wrapper' => 'bottom',
        'method' => 'replace',
      ),
      '#value' => t('Submit'),
   );
   return $form;
}

function example_module_search_callback($form, $form_state) {
   $title = $form_state['input']['title'];
   $objects = db_query('SELECT * FROM {node} n WHERE n.type = :type && title = :title', array(':type' => 'object', ':title' => $title))->fetchAll();
   $output = '';
   foreach($objects as $object):
     $output .= '
'.$object->title.'
';
   endforeach;
   return $output;
}

The above works fine the first time I submit the form, but in subsequent requests the $form_state['input']['title'] is always the same?

Can someone point out what I'm doing wrong or perhaps there's a better approach. The reason why I would like to implement my own search form is that the form will have a very large set of controls which values will be used to query the database.


texts: Error trying to connect to database when installing new site on localhost

texts:
Has anyone come across this problem?  Once I get drupal all ready to install on my localhost I go to the URL and start going through the installation process and when it comes to my database it fails.

So I import the site into Acquia Dev Desktop, create the database, and then go to the URL, select the type of installation and then when I come to the database information page it fails.

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).

I can't find any helpful documentation on this issue.
Can anyone help?

Thanks!!


texts: 403 page when clicking on activation link in email

texts:
When a user creates an account, they must activate their account by verifying the email. The token in that email is the default one, i.e. [user:one-time-login-url]

But when the user clicks on the link in their email, they get the 403 page (= You are not authorized to see this page).

Can anybody explain why this 403 page shows up?


texts: When user.private_tempstore gets deleted

texts:
I've read about the

  \Drupal::service('user.private_tempstore')->get('mymodule_name');

and found similar to storing data in $_SESSION.

I am using user.private_tempstore in my module to store some data related to the user for a current session but when I logout and login again to the system found the value still persist in that variable. It is supposed to delete on logout.

To store data

  $userSession = \Drupal::service('user.private_tempstore')->get('user_profile');
  $userSession->set('user_profile', TRUE);

To get data

  $userSession = \Drupal::service('user.private_tempstore')->get('user_profile');
  $user_profile = $userSession->get('user_profile');

Is my understanding wrong?


texts: Cart form view - relation to product variation doubles number of rows?

texts:
I'm editing standard "Cart form" Drupal commerce view. I need to get some field from product variation, but by default setup it's not available. So I added relationship product variation and field is available now, but I got doubled number of rows?!? Only difference is that first row version doesn't have value of that field from product variation and second one does. Beside that they are identical.
Tried using distinct, but didn't help. With aggregation I get some ultra long error message that starts with:
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'commerce_order_item_commerce_order__order_items.unit_price__' in 'field list': SELECT commerce_order_item_commerce_order__order_items.purchased_entity AS commerce_order_item_commerce_order__order_items_purchased_en, commerce_product_variation_field_data_commerce_order_item__commerce_product_variation__field_summary_title.field_summary_title_value AS commerce_product_variation_field_data_commerce_order_item__c, commerce_product_variation_field_data_commerce_order_item.langcode AS commerce_product_variation_field_data_commerce_order_item_la, commerce_product_field_data_commerce_product_variation_field_data__commerce_product__field_summary_title.field_summary_title_value AS commerce_product_field_data_commerce_product_variation_field, ..."
Distinct helps only have relationship with product variation, but  I don't add that field form it. But in that case I don't need that relationship at all, right?
What I'm doing wrong? Why form cat view returns doubled results when I add relationship to product variation?
Update:
Tried catching results in hook_views_pre_render() to remove faulty rows from there, but there all rows look ok and I can not distinct which one is ok and which on is missing field value.
    foreach($view->result as $row){
      $productVariation = $row->_relationship_entities['commerce_product_variation'];
       $fieldValue = $productVariation->get('field_name')->getString();
...


texts:
In my website I would like to limit product quantity to 1, meaning is that user can order only one of a product in one order. And my question is how to configure to set maximum quantity to 1 . Any suggestion is greatly appreciated.

Thanks.


texts:
I'm working on writing some automated tests for an AJAX API, and getting strange results. If I directly view the page, I see the following output, sent by drupal_json_output:

{"guid":"8e2a179e-c901-8744-05fc-e80de9500dd6","success":1}

My unit test hits this same URL. Here's the test function:

 public function testInit() {
    $response = $this->drupalGetAJAX('plugin/init', array('query' => array('guid' => $this->registered_user->uuid)));
    $this->assertEqual($response['guid'], $this->registered_user->uuid, 'GUID Loaded');
    $this->pass(json_encode($response));
  }

When I initiate the test run, it goes to the usual batch API progress page. Rather than moving directly to the test results page, I get "An error has occurred, please continue to the error page". Here's the output that follows:

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /batch?id=64&op=do StatusText: OK ResponseText: {"guid":"a06f78ec-1368-f4c4-c9ac-a710b3e941b5","success":1}{"status":true,"percentage":"100","message":"Processed test 1 of 1 - \u003Cem class=\u0022placeholder\u0022\u003EPlugin\u003C\/em\u003E.\u003Cdiv class=\u0022simpletest-fail\u0022\u003EOverall results: 7 passes, 1 fail, 0 exceptions, and 1 debug message\u003C\/div\u003E\u003Cdiv class=\u0022item-list\u0022\u003E\u003Cul\u003E\u003Cli class=\u0022first last\u0022\u003E\u003Cdiv class=\u0022simpletest-fail\u0022\u003EPlugin: 7 passes, 1 fail, 0 exceptions, and 1 debug message\u003C\/div\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\u003C\/div\u003E"}

This reads to me like some sort of error within the test runner, as you can see the response from the AJAX API module is there. It looks like it's showing my module's JSON output concatenated to the output of the batch call to the test runner.

The output for $response is always "1" when viewing the test results page. In the detailed test result page, the call is listed as follows, returning 1 byte:

  GET
  http://platform.dev/plugin/init?guid=5b299683-49d8-7754-f9ca-3fb88e79ff0f
  returned 200 (1 byte).

For experimentation sake, I also ran the test suites for AJAX commands and the batch API. The same thing happens. My best guess is that this is a bug in Drupal 7.15.


texts: With REQUEST_URI i get id node or alias path?

texts:
I have a big doubt. In template.php I am using:

$_SERVER['REQUEST_URI']

what will the output like:  node/id-numberor /Alias_page ?


texts:
I have a cutom module which creates a page with a custom form.
the problem is that i don't print whole form at once like :

$form = drupal_get_form('custom_example_form', $adverts);
print render($form);

Rather my code is like:

$form = drupal_get_form('custom_example_form', $adverts);
print render($form['name']);
print render($form['descriere']);
print render($form['submit']);
print render($form['form_id']);
print render($form['form_build_id']);

The problem us that is second example drupal is not generating

<form id="" accept-charset="" method="" action="">

How do i generate  in second situation?


texts: How to create a view using the References module?

texts:
I currently have Two content types:

Content Type 1: Videos

Content Type 2: Politicians

The main Videos content type references the Politicians content type as a way of "tagging" Politicians that can be seen in the videos.  What I'd like to do on each Video node is create a view that shows all other video nodes that have the same Politicians referenced within them.  For some reason I cant seem to get it to work.  This is what I have so far.

Create a view block with title field from the Video id like to
see
Create a relation to the Politicians field with a reverse
Create a filter based on Content NID

For some reason when i go to a Video node I don't see any results at all. In fact I don't even see the video of the node I'm currently on.

If I change the relation to Politicians field without the reverse I only see the same node that I'm currently on.  I should be seeing all videos with the same politician.  What am I doing wrong here?

Keep in mind I and not using and wont be switching to the Entity Reference module since this is a large legacy project (I'm using the References module).


texts: How to create a "go back" or "cancel" button on the node add form?

texts:
I'm trying to add a "cancel" button to my content type.

In hook_form_alter(), I'm using this code:

  if ($form_state->getFormObject()->getOperation() == 'default') { // On node add, make it clear "cancel" deletes any input
    // Do not show cancel button to people who have not completed their profile.
    if ($user->hasPermission('create MYTYPE content')) {
      $form['actions']['submit_cancel'] = array (
        '#type' => 'submit',
        '#weight' => 999,
        '#value' => t('Delete all input and return to previous page'),
        '#submit' => array('MYMODULE_userpageredirect_callback'),
        );
      $form['actions']['submit_cancel']['#attributes']['class'][] = 'btn-danger';
    }
  }

....

/**
 * Cancel changes and return to previous page
 * @param array $form
 * @param FormStateInterface $form_state
 */
function MYMODULE_userpageredirect_callback(array &$form, FormStateInterface &$form_state) {
  $route_name = 'user.page';
  $form_state->setRedirect($route_name);
}

This creates a cancel button that returns the user to the user page when they click cancel.

Problem

If a field is marked required, and the user has not input any text in the field, the browser prompts the user to input a value into the field before the cancel button will work.


texts: How to use OpenFramework Responsive Grid Views?

texts: For Drupal 7, the Bootstrap-based theme, OpenFramework, comes with css classes for Responsive Grid Views, such as "views-grid-four", but where/how are they used? Does the class name go into the Views administration somewhere, or in a css file?


texts: Theme hook suggestion for nodes within a menu link?

texts:
I need nodes within a certain place in my menu to use a new node TPL file.

My menu is hierarchical like this.

link1
link2
link3
-linkA
-linkB

I need nodes whose menu link is link3, linkA or linkB to use these new TPL files.

I have 2 content types whose nodes can be in the menu and I need a different TPL file for each content type. These nodes can also be outside of the menu in which case they should use the normal TPL file.

So a node of content type A which has a menu link of link1, link2 or no menu link would use the default node--typeA.tpl.php.

A node of content type A which has a menu link of link3, linkA or linkB would use node--typeA--special.tpl.php

A node of content type B which has a menu link of link1, link2 or no menu link would use the default node--typeB.tpl.php

A node of content type B which has a menu link of link3, linkA or linkB would use node--typeB--special.tpl.php

As I'm extending the node not page TPL I started with this:

function MYTHEME_preprocess_node(&$variables) {
  $variables['theme_hook_suggestions'][] = 'node__SOMETHING';
  kpr($variables);
}

Im assuming I need an if statement around the 2nd line which checks if the node is typeA and also in the correct place in the menu? However I had a look at the $variables on the screen and I couldn't see anything I could use to find out the menu position.

I then looked at preprocess_page to see if it had a variable I could use. There is an array called main_menu which is the name of my menu. But it contains 0 elements.

function MYTHEME_preprocess_page(&$variables) {
  kpr($variables);
}


texts: How can I restrict access to a static HTML page served from a subfolder of my site to authenticated users only?

texts:
I have a Drupal 8 site that has all roles and permissions necessary for authenticated users. One of the new requirements is to serve a static microsite (like a campaign site, totally different design compare to Drupal site) which is a single folder with all the static assets (HTML, CSS, JS , images). We have to serve this site under the same domain drupal is hosted and should be accessed ONLY by authenticated users.

I tried to host it under sites/default/files/ directory, but it means it is public and anyone can access it.


texts: How to set Contextual filter of views for profile2 module?

texts:
I want to show some data of users in their profile page. I'm using Views and profile2 modules.

In contextual filter I set "user ID from url" in uid Contxtual filter.

But this views don't show anything. When I set "Display all results for the specified field" this views block shows all users data in any profile page.
url of profile pages is "www.example.com/profile-stores/uid". actually in this project, I have 2 type of users. one of these is "stores". for example I want to show "address" of stores in their profile page. I'm using Profile2 to create some types of user.

Image-1

Image-2

What should I do?


texts: Display certain taxonomy terms in Select List?

texts:
I have my content type set up something like this:

type (select):
  type1
  type2

taxonomy_term_reference (select):
  term1
  term2
  term3
  term4
  term5
  term6

When a user fills out my node and chooses type: type1, I want only these terms to show up as options:

  term1
  term4
  term5

When a user fills out a my node and chooses type: type2, I want only these therms to show up as options:

  term2
  term3
  term6

Is there any good way of doing this?  The only way I can think of is with custom code via hook_form_alter()?


texts: Workaround for: Message rejected due to DMARC policy for yahoo.com

texts:
Using Drupal 7 on CentOS 6 with stock Postfix 2.6.6 and since recently any mails sent by Drupal on behalf of users with @yahoo.com mail addresses are bounced hard:

Diagnostic-Code: smtp; 550 5.7.1 Message rejected due to DMARC policy for
    yahoo.com

And also:

Message not accepted for policy reasons.  See
    http://postmaster.yahoo.com/errors/postmaster-28.html (in reply to end of
    DATA command)

I think this is result of Yahoo changing its mail policy, so that all other big mail providers participating in DMARC (like Gmail or Mail.ru or ...) only accept @yahoo.com senders from Yahoo mail servers (and thus not from my little Drupal website).

Has anyone affected by this change found a good workaround on the Drupal site for this problem?

UPDATE:

My Postfix installation works well and is not the problem.

The problem with Yahoo users should be solved in Drupal hook for sending contact and registration mails. I think (from reading Yahoo docs) the "From" header there should be replaced by "Reply-To" or something similar.

Note: My question affects Drupal and has to be solved with Drupal means (which is why IMO it belongs in this SE-site).


texts:
I'm editing an existing Drupal 7 site, with coloured menu buttons, and each part of the site has the corresponding colours in it's titles and links.
For example: the menu item "about us" is coloured orange, and each subpage of "about us" uses orange for it's titles and links.

The problem is: these are all inline styles, fetched from the database table "field_data_field_colour" and printed by a template.
I can change the hex-colour values directly in the database, but I've looked everywhere and can't find where to change/set those colours without messing with the database.


texts:
I'd like to achieve the following:

I'd like to give help text for a field in a content type, and I would like to show that help text on the node page as well.

I've looked at $content in page.tpl.php and $variables in theme_field() but these variables doesn't seem to contain these help texts.

How can I make these help texts appear?


texts: My custom Save button does not save the new form values

texts:
I added a custom button to my form which I want to call a function which grabs some values from that form, email them out to whomever, and then save the form. I have successfully emailing the value, but I cannot get the form to save.

function my_mod_form_node_form_alter(&$form, &$form_state, $form_id) {

    $type = $form['type']['#value'];
    if($type !== 'support_ticket')
        return;

    $form['actions']['submit2'] = array(
        '#type' => 'submit',
        '#value' => t('Accept And Close'),
        '#submit'=>array('my_mod_email_and_close')
    );
    return $form;
}

function my_mod_email_and_close(&$form, &$form_state) does not contain any logic to actually save the form values. It only checks the form for some values and emails those values out.

I need to save the form however, how do I also get this custom button to submit and save the form. I tried adding these lines to the bottom of my_mod_email_and_close()

$form_id = $form['form_id']['#value'];
drupal_form_submit($form_id, $form_state);

but it doesn't actually save. I get 2 of the same errrors however: Trying to get property of non-object in _support_assigned() from a different module so I am not sure whats going on.

Perhaps I am using the wrong hook?


texts: Title encoding to display correctly foreign characters

texts:
In my html.tpl.php file in the <head> tag
I display the page title as follows:

<title><?php print $head_title; ?></title>

This displays the foreign characters not correctly when watching the pages
in the browser.

I tried to add the
<meta charset="utf-8" /> but it didn't help.

Caches were cleared.

What else could you change so that the foreign characters are encoded correctly?


texts: problems with CKEditor install in drupal 7

texts:
I have installed CKEditor correctly and still get the error:

  The CKEditor component is not installed correctly. Please go to the
  CKEditor homepage in order to download the latest version. After that
  you must extract the files to the sites/all/modules/ckeditor/ckeditor
  or sites/all/libraries/ckeditor directory and make sure that the
  sites/all/modules/ckeditor/ckeditor/ckeditor.js or
  sites/all/libraries/ckeditor/ckeditor.js file exists. Refer to the
  README.txt file for more information.

I have downloaded and re-downloaded CKEditor several times. Everything is there but still getting error.

I am also confused about exactly what to put in the CKEditor global profile.


texts: Drupal 8 - How to add link & display in twig template

texts:
I have file in src/Form/TestForm.php.

I would like to add link of Forgot password in buildForm function & want to display in twig template file.

How to achieve this?


texts: how to concatenate term name with it's parent name in select list

texts:
I have created cck field as select list and selected the taxonomy terms and displaying all taxonomy terms in the select list. Then How can I add its parent name besides it.

let say India->Mumbai->Pune need to disaply as below in select list:

India (No Parent)
Mumbai (India)
Pune (mumbai)

IN Drupal 7?


texts: Customize Order Items table on admin order screen

texts:
On the order edit admin screen at /admin/commerce/orders/270/edit, how do you customize the Order Items table? I've been looking all day and can't figure it out. There's a view that controls this same table on a user's orders tab, but it doesn't seem to affect this screen. All I want to do is add a column for the item's SKU and I would have thought that to be a pretty straightforward change.

Thanks!


texts:
I made a custom template for my view to print fields into a custom html syntax.  The problem  I have is that in the view I am calling all content types.  Now, in my template file I want to display certain information depending on what content type the content is coming from.

For instance, I want something like this:

If (node->type['animals']{
    print 'this is the animal node';
}
else{
    print 'this is not the animal node';
}

My fields inside the view are printed as follows, but this works:

<?php print $fields['title']->content; ?>

The only problem I am having is calling the node type.

I tried adding content type to my views in drupal, then tried it that way:

<?php if ($fields['type']->content = 'animals'){} ?>

but the view looks through the document and see that there is a content type with that name, and prints the data anyway.


texts: How can I get the user ID from an order?

texts: How can I get the user ID from an Ubercart order?


texts:
I have two template files for a view but only one of them is getting picked up.   If I look under the Theme dialog for the view I can see that my two theme files are bolded.

The Display Output template file is working but the Row Style is not working.  I've also added this to my template file to try try and get it to work but I don't think it's doing anything.

function mytheme_preprocess_views_view(&$variables){
  if ($variables['view']->name == 'travel_extras_hotel_carousel') {
    $variables['theme_hook_suggestions'][] = 'views_view_fields__travel_extras_hotel_carousel__block';
    $variables['theme_hook_suggestions'][] = 'views_view__travel_extras_hotel_carousel__block';
  }
  return $variables;
}

Does anyone have any ideas about what else I could do?

I'm using views 3.3


texts:
I'm working on a D7 site at the moment and need a bit of help with the admin themes.

I've got 2 levels of admin for the site. Super user and a lower level admin that can only edit content they created. The lower level does not have access to the administration theme so their pages and admin forms are showing up in the site's content.

My question is: Is there a way of theming these pages through a template? Does it just use the basic node.tpl.php file? I can style the page in the CSS but I don't think this is going to be enough.

Thanks


texts: Get the url for an images in a Field Collection for the Node Template

texts:
This is a bit messy so bear with me. I've built a node with a field collection 'field_meet_videos'. That field collection contains another field collection 'field_about_video'. The inner field collection has 3 fields (two text fields and an image field 'field_image'). This field collection is also used as multifield so it'll be used more than once (lets say 3 times for this example).

What I'm trying to do is just get a printed output of the image url (with imagecache style) on the node template (to use them as html element backgrounds).

<?php
  $content['field_meet_videos'][0]['entity']['field_collection_item'][34]['field_about_video'][0]['entity']['field_collection_item'][35]['field_image']
?>

This looks to contain enough that I could cobble together a url by sticking these variables into a url string but it feels like there must be a better way to access these variables.


texts: can features module provide fields to an entity created by a different module?

texts:
A contrib module provides an entity and some default fields in its contribmodulename.install file.

In the UI we have added fields to that entity.  It appears like these fields, both $field_bases and $field_instances are exported properly in our custom "features" module.  But reverting the feature on our test/staging site does not add the fields to the entity.

Should it?  Or is that not possible because the entity was created by a different module?


texts: how to stop increase product quantity after click add to cart in drupal 7?

texts:
I am using drupal commerce in my site its working fine. I need to stop increase product quantity when user click  "add to cart" same product second time. In my case user can add multiple products in cart but not same products. and user can increase quantity via quantity fields not a click on add to cart.

I used this rule its working.But I have mention in my question, when I increase quantity from cart page then quantity should be increase.. but this rule restricting me to increase quantity.

> { "rules_restrict_quantity_to_1" : {
>     "LABEL" : "Restrict quantity to 1",
>     "PLUGIN" : "reaction rule",
>     "REQUIRES" : [ "rules", "entity" ],
>     "ON" : [ "commerce_order_presave" ],
>     "IF" : [
>       { "user_has_role" : {
>           "account" : [ "site:current-user" ],
>           "roles" : { "value" : { "1" : "1" } }
>         }
>       }
>     ],
>     "DO" : [
>       { "LOOP" : {
>           "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
>           "ITEM" : { "list_item" : "Current list item" },
>           "DO" : [ { "data_set" : { "data" : [ "list-item:quantity" ], "value" : "1" } } ]
>         }
>       }
>     ]   }

}


texts: Form hook not found through module_hook_info in module subdirectory

texts:
Context:
In my Drupal 7 project, I have a module with several submodules. Because the module's root directory got crowded, I moved the submodule files to their own directories within the root.

My module's structure is like this:

mymodule
├── mymodule.info
├── mymodule.module
├── mymodule1
│   ├── mymodule1.block.inc
│   ├── mymodule1.form.inc
│   ├── mymodule1.info
│   ├── mymodule1.module
│   ├── mymodule1.page.inc
│   └── pages
│       └── foo.tpl.php
└── mymodule2
    ├── classes
    │   └── foo
    │       └── Bar.php
    ├── mymodule2.form.inc
    ├── mymodule2.info
    ├── mymodule2.install
    ├── mymodule2.module
    ├── mymodule2.page.inc
    └── pages
        ├── foo.tpl.php
        └── bar.tpl.php

Before "the big move", files that are now in the subdirectories mymodule1 and mymodule2, were located in their parent directory (the module's root directory).

The problem:
Ever since moving the files, my custom forms are not loading anymore. I have a form in mymodule1.form.inc, which used to load and render perfectly before. Now, when I use drupal_get_form() to load the form, I only get an empty form with a hidden build ID input.

Keep in the mind that the only thing that has changed here, is that the .inc files have been moved to the subdirectory, along with the module file. Also, drupal_get_path('module', 'mymodule1') returns the correct path to the module in the subdirectory.

Strangely, there are also block hooks, located in mymodule1.block.inc, which work perfectly fine, even after clearing all caches.

This is the first time I'm working with separate directories per submodule within a module. I got the inspiration from the module i18n, which uses the same construction. I searched in the Drupal documentation and the code of i18n, but could not find where I'm going wrong.

Does anyone know where I could possibly have gone wrong, or if I need to add data to mymodule1.module or mymodule1.info to make this work? Thank you.

Some details:
Caches were cleared through <path to project>/admin_menu/flush-cache multiple times.

I use module1_hook_info() to direct the hooks for blocks and forms to separate files. This is the return value:

array (size=9)
  'block_info' =>
    array (size=1)
      'group' => string 'block' (length=5)
  'block_configure' =>
    array (size=1)
      'group' => string 'block' (length=5)
  'block_save' =>
    array (size=1)
      'group' => string 'block' (length=5)
  'block_view' =>
    array (size=1)
      'group' => string 'block' (length=5)
  'forms' =>
    array (size=1)
      'group' => string 'form' (length=4)
  'form' =>
    array (size=1)
      'group' => string 'form' (length=4)
  'form_validate' =>
    array (size=1)
      'group' => string 'form' (length=4)
  'form_submit' =>
    array (size=1)
      'group' => string 'form' (length=4)
  'form_alter' =>
    array (size=1)
      'group' => string 'form' (length=4)

My form functions are called:

mymodule1_foobar_form
mymodule1_foobar_form_validate
mymodule1_foobar_form_submit


texts:
All views in my drupal site lost "Show row weights" function. Everytime when clicks "Show row weights" link, its text will change to "hide row weights". But there is no weight column in view table.

Here is a screenshot showing what I am encoutering:

This issue has been struggling me for quite a while. Many thanks if anyone can offer some ideas about it.

Cheers!


texts: Countries Additional Data Tokens not working

texts:
I'm using Pathauto and Countries to build path aliases that reflect the country and corresponding continent of a node. For example if a node's country field is set to Spain the url should be:
europe/spain/node-title.

My pattern is:
 [node:field-prgm-country:continent-name]/[node:field-prgm-country]/[node:title]
The country renders correctly but the continent shows nothing. I've tried any other additional data (see attached image) and none of it shows.

How do access this additional country data for use in my path aliases?


texts: Password Security for Downloading PDF in drupal7

texts:
i have a file upload field type in my content type.
so user can upload PDF file in that. i want to make password security for  downloading the PDF.
Can anyone help on this?

Thanks in Advanced.


texts: Display webform submitted data in profile page

texts:
I have created a webform with several fields. I have implemented webform registration module too. Now if the user registers, Soon after clicking register button he will need to see his profile page with the submitted values.I can use tokens for this but it's not a good idea because user should be able to edit his profile page too.
 -I have tried displaying webform submissions on view.which doesn't work here.
 -But specifically a user should see his profile page with submitted data after
   submitting the webform
 -Please help me on this.


texts: Installing Drupal with existing Pantheon site?

texts:
First, I am completely new to, well, all of this... So I'm sorry if I sound like an idiot. I have been fighting with this thing all day, and I think I'm more confused then when I started. I work for a non-profit, and I'm supposed to be helping our web designer with the new website. He uses Drupal and Pantheon. His instructions were something to the effect of "Download the repositories from Pantheon, install Drupal, and point Drupal to the repositories" Yeah... I downloaded the stuff from pantheon using Git, so I think I at least did that part right, but I have no idea how to install Drupal. I have read half a dozen different manuals, all of which tell me to do different things, most of which I don't understand. And our web designer can't help me because he doesn't know how to do any of this on a Windows box. (He's a Linux guy). Help??

I'm using Windows 7 Ultimate.


texts: How do I create and delete a forum via POST to taxonomy_term?

texts:
I'd like to be able to programmatically create and delete Forums on a Drupal 7 install, via the Services module. I want to send in HTTP requests and have those things happen.

I know how to create a node (page, article, or forum topic).
I know how to delete a node.

How can I create a forum? I think Forums is a taxonomy_vocabulary. I think creating and removing forums is equivalent to adding  and removing terms to the vocabulary.  But I would like to see an example.

Any help?


texts: Redirect to a view with contextual filters

texts:
I would like to redirect the user to a view with some contextual filters on the submit of a custom form.

For now I use this :

$form_state->setRedirect('view.search.page_1', ['myvalue' => $value]);

But it add "myvalue" like this : /search?myvalue=$value

and what I want is : /search/$value

Thanks


texts:
I am trying to implement a Queue for my cron job, but some how it is not working. Following is the code snippet I have tried, but it is not working.

function hook_cron() {
watchdog('notice', 'Cron is executed');
$queue = DrupalQueue::get('update_item');
  for($i=0;$i<=10;$i++){
    $queue->createItem($i);
  }
}
function hook_cron_queue_info() {
  watchdog('notice', 'called queue info');
  $queues['update_item'] = array(
    'worker callback' => '_my_queue_callback',
    'time' => 15,
  );
  return $queues;
}
function _my_queue_callback($data){
   watchdog('notice', "Queue call back $data");
}

Following output I am expecting in logs
"Cron is executed"
"Called queue info"
and "Queue call back 1"..."Queue call back 10"

But I am only getting

"Cron is executed"

I am runing the cron using elysia_cron interface (in my linux box cron job is not added in crontab). What might be the reason I am not getting "Called queue info"
and "Queue call back 1"..."Queue call back 10" in my logs.


texts: update price based on current date vs field_date_event

texts:
I have a content-type = Event; and a product-type = Registration.

A visitor registers (submits this as an order) to an Event and is sent to their cart to process their payment. I need to modify the price of Registration based on a date range related to the actual Event date.

I want to compare field_date_event (from the content-type), to the current system date so I can do a Data comparison in Rules. How do I do this?


texts: How to add permissions and configure links to a module in the /admin/modules page?

texts:
I created a custom module and when I go to /admin/modules page it looks like this (no links):

How can I add the configure and permissions links to my custom module, just like Devel does?


texts:
Is it possible to restrict the login or role  access by IP in drupal 7.Is there any module available in drupal 7  to provide similar  functionality  Restrict Login
Any one guide me do this.
Thanks


texts:
I have created a module i can use to create multiple blocks, now with one of those blocks, there is a requirement for a form (which the user needs to be able to see). However, this does not require any Drupal "Save" interactions.

Its a very simple static form that is manipulated with Ajax functionality. I have just coded this form simply within the TPL file.

<form name="formelement" method="post">
    <input name="data" type="hidden" value="" />

something here

something there

    <input required="" type="text" class="" name="blah1">
    <input required="" type="text" class="" name="blah">

        <button type="submit" class="btn" href="">submit</button>

</form>

Question - I need to be able to get the $_POST in a function - what would be the best method of creating this form with the .module file or the drupal 7 api and then print it within the tpl file


texts: How to set URL for image with view method properly?

texts:
Image formatter should accept image_style and url parameters.
I've got image_style working but not url.
function mymodule_preprocess_views_view_field(&$variables) {
  // ...
  $variables['image'] = $node->get('field_image')->get($delta)->view(['settings' => ['image_style' => '195', 'url' => '/test']]);
  kint($variables['image']);
  // ...
}

Why url is NULL (instead of /test)?


texts: How can I create a patch for a contrib module or core which is not in version control?

texts:
Because we use a devOps system that installs packages on the server via Composer, my core drupal installation and contrib modules are not in version control (Git).

I used to patch modules as follows:

Commit everything, so my branch is up-to-date.
Make my changes to the module (= write the fixes in the module).
Inside my code editor go to Code -> Create patch and follow the steps there (because of Git, my editor knows what has changed).
My patch gets saved where I prefer to do it.

Since we started working with keeping modules and core out of Git I do not have a clue on how to create my patches anymore.

Curious about the solutions you might have!


texts: How to get user edit form in mini panel?

texts:
Could you, please, explain me how to get user edit form in mini panel ? I need to replace standard user edit form and to do it in block but have some problem with that - it seems that nothing happens.

This is an export output of it:

$mini = new stdClass();
$mini->disabled = FALSE; /* Edit this to true to make a default mini disabled initially */
$mini->api_version = 1;
$mini->name = 'use_profile_edit';
$mini->category = 'General layout';
$mini->admin_title = 'User profile edit';
$mini->admin_description = 'User profile edit';
$mini->requiredcontexts = array();
$mini->contexts = array(
  0 => array(
    'identifier' => 'User edit form',
    'keyword' => 'user_edit',
    'name' => 'user_edit_form',
    'uid' => '448',
    'id' => 1,
  ),
);
$mini->relationships = array();
$display = new panels_display();
$display->layout = 'flexible';
$display->layout_settings = array();
$display->panel_settings = array(
  'style_settings' => array(
    'default' => NULL,
    'center' => NULL,
  ),
);
$display->cache = array();
$display->title = 'test of user edit panel';
$display->uuid = 'a100b9d4-cbcb-467e-98d4-6b1b403d6b24';
$display->content = array();
$display->panels = array();
  $pane = new stdClass();
  $pane->pid = 'new-d4156689-563a-4ad9-af83-098a55f33f26';
  $pane->panel = 'center';
  $pane->type = 'form';
  $pane->subtype = 'form';
  $pane->shown = TRUE;
  $pane->access = array();
  $pane->configuration = array(
    'context' => 'requiredcontext_user_edit_form_1',
    'override_title' => 0,
    'override_title_text' => '',
    'override_title_heading' => 'h2',
  );
  $pane->cache = array();
  $pane->style = array(
    'settings' => NULL,
  );
  $pane->css = array();
  $pane->extras = array();
  $pane->position = 0;
  $pane->locks = array();
  $pane->uuid = 'd4156689-563a-4ad9-af83-098a55f33f26';
  $display->content['new-d4156689-563a-4ad9-af83-098a55f33f26'] = $pane;
  $display->panels['center'][0] = 'new-d4156689-563a-4ad9-af83-098a55f33f26';
  $pane = new stdClass();
  $pane->pid = 'new-33b3eb45-4af7-4e68-aee8-dafdafdfb78e';
  $pane->panel = 'center';
  $pane->type = 'entity_field';
  $pane->subtype = 'user:field_first_name';
  $pane->shown = TRUE;
  $pane->access = array();
  $pane->configuration = array(
    'label' => 'title',
    'formatter' => 'title_linked',
    'delta_limit' => 0,
    'delta_offset' => '0',
    'delta_reversed' => FALSE,
    'formatter_settings' => array(
      'title_style' => '_none',
      'title_link' => '',
      'title_class' => '',
    ),
    'context' => 'context_user_edit_form_1',
    'override_title' => 0,
    'override_title_text' => '',
    'override_title_heading' => 'h2',
  );
  $pane->cache = array();
  $pane->style = array(
    'settings' => NULL,
  );
  $pane->css = array();
  $pane->extras = array();
  $pane->position = 1;
  $pane->locks = array();
  $pane->uuid = '33b3eb45-4af7-4e68-aee8-dafdafdfb78e';
  $display->content['new-33b3eb45-4af7-4e68-aee8-dafdafdfb78e'] = $pane;
  $display->panels['center'][1] = 'new-33b3eb45-4af7-4e68-aee8-dafdafdfb78e';
$display->hide_title = PANELS_TITLE_FIXED;
$display->title_pane = 'new-d4156689-563a-4ad9-af83-098a55f33f26';
$mini->display = $display;


texts: Function not working in contextual filter

texts:
I have a function in my custom module that return the nids for drafts in array.

function get_all_drafts(){
    $query = db_query("select bid from kom_draft");
    $res = $query->fetchAll();
    foreach($res as $bid){
        $output[] = $bid->bid;
    }
    return $output;
}

and following code is used in contextual filter nid ( php code text area )

$nids = get_all_drafts();
return implode('+',$nids);

and checked the multiple value checkbox but its not working, i checked the query and there in not value to compare.

when i use the same code on tpl file i am getting proper output that is + separated nids.


texts: What to use for node_prepare in Drupal 7

texts:
I am converting a module from Drupal 6 to Drupal 7. I have come across a Drupal 6 functional call named node_prepare and I am not sure what needs to be done to make this work with Drupal 7. What should this function be replaced with?

Thanks.


texts: address dependent locality field not shown

texts:
drupal 8.8.2  address 8.x-1.7

address module is working in that i can add an address to my content, however I am not able to display the "dependent locality " field  even when it is set to "no override" or "required"

from the doc i did find : https://docs.drupalcommerce.org/commerce2/developer-guide/customers/addresses/countries-and-subdivisions

it shows a "suburb" field, which i am assuming is this field.  I was planning to use this to contain the "county"

is there a dependency i need to check to enable this field ?

thanks for your time.

ps. i was not sure how to tag this question, i did not see a tag for modules or address


texts:
I am using the following function to alter the node's data before saving it to the database.

function mymodule_node_presave($node) {
  if ($node->type="mytype") {
    if ($node->is_new) {
      $node->status = 0;
    }
  }
}

How do I know that the node is new and not updated/edited? In the example, you may see I have used $node->is_new, and I need to make sure that is correct. So is it?


texts: new domain url for multi sites linked to sub domain drupal install

texts:
Because my drupal install is not in the root of document but in a subdomain, everything is a little more difficult for setting up multi-sites.

I found a way of adding multiple subdomains successfully to the subdomain containing drupal install but now that I am wanting to add a new domain url pointing to same IP obviously it keeps wanting to direct to document root and if I set it up in virtualhosts what happens is it makes it so you have to go to URL example.com/drupal/install.php which obviously I don't want because I want it to 'appear' as other multi-sites in the exact url not path to drupal folder.

Do I need to use a symlink for this to work? See I have two domains pointing to the ONE IP but as I have the drupal core in a SUBDOMAIN of the main IP then the second domain name doesn't want to follow the same rules as the other subdomains running off drupal core subdomain and direct from vhost to html/drupal and APPEAR in subdomain url. Rather the second name url is following the path LITERALLY and so I can never install anywhere but path to drupal folder.

So completely stuck on what to do from here. How can I make my second domain url POINT to the subdomain root drupal install and not the root of IP which is static?


texts: Add classes to programmatically added fields

texts:
I have programmatically created a few content types and fields for said content types in a module I'm building, but I need to add classes to said fields.

So if I have a text field called "background_color", I would like to add a class to it called "color-picker".

Im added the instance of the field to my bundle like:

...
    'background_color' => array(
        'field_name' => $fields['field_background_color']['field_name'],
        'label' => 'The stroke color',
        'bundle' => 'nji_map',
        'entity_type' => 'node',
        'attributes' =>array('class'=>array('minicolors')),
        'widget'      => array(
            'type'    => 'text_textfield',
        ),
        'display' => array(
            'default' => array(
            'label' => 'above',
            'type' => 'text_textfield',
            ),
        ),
        'description' => 'The background color is the color between.',

    )....

Edit - Here is more of my code (node the full code snippet because there are too many fields)..

        $fields = array(
        'field_map_background_color' => array(
            'field_name' => 'field_map_background_color',
            'type' => 'text'
        ),...

$instances =  array(
    'background_color' => array(
        'field_name' => $fields['field_map_background_color']['field_name'],
        'label' => 'The background color',
        'bundle' => 'nji_map',
        'entity_type' => 'node',
        'attributes' =>array('class'=>array('minicolors')),
        'settings' => array(
            'prefix' => '
',
            'suffix' => '
',
        ),
        'widget'      => array(
            'type'    => 'text_textfield',
        ),
        'display' => array(
            'default' => array(
            'label' => 'above',
            'type' => 'text_textfield',
            ),
        ),
        'description' => 'The background color is the color between.',

    ), ....

  foreach ($fields as $field) {
    field_create_field($field);
  }

  foreach ($instances as $instance) {
    field_create_instance($instance);
  }


texts: How to get project's data from packages.drupal.org

texts:
Drupal projects can be searched similarly as Packagist:

https://packages.drupal.org/8/search.json?s=projectname
https://packagist.org/search.json?q=projectname

From Packagist can be also extrated the project's data (e.g. versions):

https://packagist.org/packages/symfony/symfony.json

Is it possible to get project's data also from the Drupal repository?

More info:

Using packages.drupal.org
Packagist API Documentation


texts: What is the "correct" way of reporting problems detected by sanity checks, or catching exceptions?

texts:
Example I:
You do something with Entity API, which sometimes throws an EntityMalformedException. So you wrap it into a try/catch block. You develop a fallback behavior, but you also want the admin to know that something is wrong.

Example II:
You expect that a specific field on a node is mandatory. There is a block that only works correctly if this field is set, and not empty. You develop a fallback behavior for the case that the field is empty, but you also want to let the admin know that something is wrong.

Example III:
A file you need is not readable. You develop a safe fallback behavior, but also want to let the admin know that something is wrong.

So far what I came up with is to do two things, plus the fallback:

Call watchdog($module, $message, array(), WATCHDOG_WARNING).
Call drupal_set_message($message, 'warning'), if the user has user_access('administer site configuration'). Regular users will not see this message.
Move on with a safe fallback behavior. E.g. if we cannot render a specific block, we just return an empty block. If we cannot load an image, we show a placeholder image. Etc.

What I see in other parts of Drupal 7 is that corrupt data can travel quite far, without being checked, before something blows up. And mostly I get uncontrolled PHP errors and warnings like "trying to get property of non-object", instead of controlled and checked warnings.

So, what is the "correct" or recommended way to do this stuff?
The fact that I am manually doing two separate things here and manually doing the access check indicates that I might be missing something..


texts: I have a major problem: the boost module is great but SOMETIMES i find some pagers without any CSS or JS like the image below:


texts:
I am trying to perform a query on a database that has the following info (in Drupal 7.21):

nid | sid | cid | data
----------------------
32  |  2  |  1  | date
32  |  2  |  2  | name
32  |  3  |  1  | date
32  |  3  |  2  | name
32  |  4  |  1  | date
32  |  4  |  2  | name
         etc..

I would like to perform a query on the database where I extract the following information in this manner:

nid | sid |    date    |    name
-----------------------------------
 32 |  2  | date_value | name_value
 32 |  3  | date_value | name_value
 32 |  4  | date_value | name_value

Where date and name are the actual values. Of course the result of this query would be an object. I am using the table display here to illustrate what I want to achieve in terms of data extraction.

My query looks like this:

$query = db_select('webform_submitted_data', 'sub1');
$query->innerJoin('webform_submitted_data', 'sub2', 'sub1.nid=sub2.nid and sub1.sid=sub2.sid');
$query = $query
  ->fields('sub1', array('nid', 'sid'))
  ->addField('sub1', 'data', 'date')
  ->addField('sub2', 'data', 'name')
  ->condition('sub1.nid', 32)
  ->condition('sub2.cid', 2)
  ->condition('sub1.cid', 1);

I thought the addField command would accomplish this but Drupal doesn't like it. What am I doing wrong?

Thanks.


texts: Strange behaviour with hook_entity_field_access

texts:
I've implemented hook_entity_field_access like this:

function opencase_entity_field_access($operation, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $account, $items = NULL) {
  if ($field_definition->getName() == 'field_linked_opencase_actor' && $operation == 'edit') {
    error_log($account->hasPermission('administer users'));
    return AccessResult::allowedIfHasPermission($account, 'administer users');
  }
  return AccessResult::neutral();
}

When I log is as a user without the "administer users" permission and I go to the edit page containing that field, I get a 'PHP message: \n', in the error log showing that the if-block has been reached and that the user does not have the permission. But the field still appears! If I return an AccessResult::forbidden, however, it works as expected. Any ideas why allowedIfHasPermission doesn't?


texts:
I'm trying to rewrite the URL of a node. I have the following test code:

function mymodule_url_outbound_alter(&$path, &$options, $original_path) {

    if ($path == 'testpage') {
        $path = 'test-alias';
        $options['alias'] = $path;
    }
}

Which doesn't seem to do anything when I visit /testpage or /test-alias. It's definitely executing the code inside the if statement. Am I doing something wrong here?

I have previously implemented hook_url_inbound_alter(), which works perfectly and doesn't do anything on this particular page. I also use the Path module.


texts: Form Alter Foreach Loop changes not sticking

texts:
I'm trying to modify my exposed filter block to put each of the controls inside fieldsets, and make other modifications to them.

However, when I try to utilize a foreach loop to do this, none of my changes are 'sticking'.

foreach($form_state['input'] as $delta => $input) {
    $collapsed = (empty($input) ? TRUE : FALSE);

    $form[$delta . '_fieldset'] = array(
        '#type' => 'fieldset',
        '#title' => t($form['#info']['filter-' . $delta]['label']),
        '#collapsible' => TRUE,
        '#collapsed' => $collapsed,
    );

    $form[$delta . '_fieldset'][$delta] = $form[$delta];
    unset($form[$delta]);
    unset($form['#info']['filter-' . $delta]);

}

This wont work, but this will:

$delta = 'field_resource_type_tid';
$collapsed = (empty($form_state[$input][$delta]) ? TRUE : FALSE);

$form[$delta . '_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t($form['#info']['filter-' . $delta]['label']),
    '#collapsible' => TRUE,
    '#collapsed' => $collapsed,
);

$form[$delta . '_fieldset'][$delta] = $form[$delta];
unset($form[$delta]);
unset($form['#info']['filter-' . $delta]);

I've been trying to find out why this wont work, but I can't for the life of my figure out what the form modifications wont stick when done inside this foreach loop.


texts: Canvas element is getting removed from the page

texts:
I am new to Drupal 8. I am trying to implement Chart js in Drupal 8.

I am trying to create a  element to load the chart. But while rendering the page,  element is getting removed automatically.
Below the controller code.

class DashboardController extends ControllerBase {

  public function content() {

    return array(
        '#type' => 'markup',
        '#markup'   =>  '
<canvas id="test"></canvas>
',
    );
  }
}

Here, I am getting only

I am unable to find the canvas in the page. Because of that, chart is not getting loaded.

Anyone help me to figure out the exact problem.


texts: How to override a service provided by a contrib module?

texts:
I need to override Validator class from Telephone Validations contrib module.
I tried the both static and dynamic methods described here:
https://www.drupal.org/docs/8/api/services-and-dependency-injection/altering-existing-services-providing-dynamic-services

namespace Drupal\mymodule;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
// @note: You only need Reference, if you want to change service arguments.
use Symfony\Component\DependencyInjection\Reference;

/**
 * Modifies the language manager service.
 */

class MyServiceProvider extends ServiceProviderBase {

  /**
   * {@inheritdoc}
   */
  public function alter(ContainerBuilder $container) {
    // Overrides language_manager class to test domain language negotiation.
    // Adds entity_type.manager service as an additional argument.
    $definition = $container->getDefinition('telephone_validation.validator');
    $definition->setClass('Drupal\mymodule\MyValidator');

    $definition->addArgument(new Reference('country_manager'));
  }

}

and also static:

services:
  telephone_validation.validator:
    class: Drupal\mymodule\MyValidator
    arguments: ['@country_manager']

but it the both methods do not work, Drupal still uses Validator class form oroginal module

Also I tried modified method described here:
https://github.com/RikdeBoer/service_overrider

class MyServiceProvider implements ServiceModifierInterface {

  /**
   * {@inheritdoc}
   */
  public function alter(ContainerBuilder $container) {
    // Overrides language_manager class to test domain language negotiation.
    // Adds entity_type.manager service as an additional argument.
    $definition = $container->getDefinition('telephone_validation.validator');
    $definition->setClass('Drupal\mymodule\MyValidator');

    $definition->addArgument(new Reference('country_manager'));
  }

}

The result is the same: MyValidator class is not used instead of default Validator class.
So what I am doing wrong?


texts: Programmatically redirect users to the default "access restricted"

texts: I would like to programmatically redirect my users to the default "access restricted" page. I know that I need a "RedirectResponse" object for a simple redirect, but how do I specify the default "access restricted" page here?


texts: Statistics module has less functionality

texts:
The official documentation for the statistics module lists some exciting features. Here is a quote of what I found there.

  Viewing site usage

  The Statistics module can help you break down details about your users and how they are using the site. The module offers four reports:

  Recent hits displays information about the latest activity on your site, including the URL and title of the page that was accessed, the user name (if available) and the IP address of the viewer.
  Top referrers displays where visitors came from (referrer URL).
  Top pages displays a list of pages ordered by how often they were viewed.
  Top visitors shows you the most active visitors for your site and allows you to ban abusive visitors.

Unfortunately I don't  see any of those functionalities in my drupal 8 site. All I see is the number of views on a node, and no way to see the IP addresses, or referal URL or any of the above functionalities. Looking at the source code, I also don't see where the above functionalities are implemented.

What do I need to do to get the functionalities listed above?


texts: How do I create a collaborative webform using Webforms?

texts:
How can I create a webform that allows users to collaboratively fill out a webform built using the Webform module in Drupal 7?

The users are building their own webforms, which works great to populate text and content. Some forms should allow several users to collaborate on filling them out. Basically, they will be to-do checklists where each user will mark tasks complete. This is a single submission edited by multiple users.

I could write these checklist type forms using the Forms API, allowing the users to maintain the forms themselves has proven much more efficient for getting forms published.

I am open to modules that extend Webforms or even other modules that fit the requirements better. However, I would like to stay with Webforms because my users are already comfortable with it.


texts: Identify active image in jcarousel - views slideshow

texts:
Is it possible to highlight the current active image in jCarousel thumbnail pager combined with views slideshow image?

I have setup views_slideshow and added a views_slideshow_jcarousel pager. I see there is an active class on one of the carousel images, but I can't seem to use it. I can only affect the first image in the list with css like:

.views_slideshow_active_pager_field_item { opacity: 0.5; }
.jcarousel-item-horizontal .active { opacity: 0.5; }

For example...add opacity to the active image select below:


texts:
Very new to Drupal--trying to understand building a dynamic navigation menu for end users to handle. Is it possible to print the Main Menu inside a block I'm using for the header? e.g.

<nav id="main-menu" role="navigation" tabindex="-1">
<?php
      print theme('links__system_main_menu', array(
        'links' => $main_menu,
        'attributes' => array(
          'class' => array('links', 'inline', 'clearfix'),
        ),
        'heading' => array(
          'text' => t('Main menu'),
          'level' => 'h2',
          'class' => array('element-invisible'),
        ),
      )); ?>
</nav>

Pages render the <nav> tag, but nothing inside such as the content (basic pages) that Main Menu definitely contains so far as I can see in /admin/structure/menu/manage/main-menu.

I'm using my own sub-theme (derived from Zen, but most regions removed,) so I've been trying the code above (and variations) in a block added to the Header region. Is this not the Drupal convention?


texts: Comments form action points to different node

texts:
I'm having a very weird problem with comments on a node. I recently upgraded to Drupal 7.12.

Now the comments aren't working right. When a user (registered or anonymous) enters in a node page, the action call of the comment form points to the page URL. But, when the user browses to another page, the action call of the comment form of the new page remains pointing to the previous page! This happened until the browser is closed, or the user logs out.

Could anyone shed some light as to why this is happening?

[Edited]
I just discovered that when I disable de Panel module the issue is not happening. The problem is that all the presentation layer goes to the trash :-( Anyone had a similar problem?


texts: How to create display page depending on role?

texts: I have a role of shopkeeper who is able to update the product info. But I want to create a different page for specific role of user. How to do this


texts: List content referenced to another content type

texts:
I'm creating a simple site which has shows and episodes. I have created both content types and I added the entity reference field to the episode type. The episode would reference a show which it belongs to. I have a view which lists all the shows. However, when I click a show I want a list of all the episodes belonging to that show.

How would I achieve this?


texts: What is the naming convention used for overiding file-link.html.twig?

texts:
I have been trying to override file-link.html.twig for a specific content type. I can override it for all but for a specific type I cannot find the corret naming convention. I have twig debug and the like all on but it only suggests file-link.html.twig.

My initial thought was:

file-link--content-type.html.twig

I have tried this and a few others but nothing gets picked up. CAn anyone point me in the right direction please?


texts: Why would all theme background colors disappear after moving to different server?

texts:
A site using MAYO 7.x-1.2 was moved from a Windows IIS to a Linux server. Shortly thereafter, all background colors defined in MAYO settings (and also any custom CSS) have disappeared. Also gone is the custom background color for dropdown Nice menus – it just goes transparent. Other than the bg color, main content and layout are OK. Perhaps there is no relationship of this to the server change, but in any case I haven't been able to debug this with anything I tried. The PHP version is now 7.2, maybe that is related, and I'm not sure what it was under the Windows server. Site needs to stay in D7 for now, although a D8 upgrade is planned.

Also note, I was aware that this is an old version of MAYO that should have been updated long ago. I hesitated to update because I had modified the template file to get an additional region, and wasn't sure how to apply the update while preserving the custom region. (Could use some advice there.) In reading the docs about the security update, it seems the circumstances for risk don't really apply for this site.

Advice on either of these issues will be much appreciated.


texts:
I need to render the main menu within the admin section of my website.  I am setting up a module to do this on a new page.  I need to theme this menu custom for just the admin, and leave it as it typically would be on the front-end of the site.

How can do do this?

$menu = menu_tree_all_data('main-menu');
// ...customize template/output for this menu and render from my module...


texts:
I am a beginner with Drupal. I have successfully installed it and:

Created the front page. I did it through Content, Add content, Basic page. Then Configuration, Site information and then in the Default front page I put the alias of my Basic page.
Created an Image gallery with ColoxBox plugin. I went to Structure, Views and created a new view. This view is linked to the Main menu in order to obtain a link in the Menu.

The problem is that my Galleries link came before the Home link.

How can I change the order of these links?

Any help will be appreciated.


texts: Toggle translation in a multilingual site

texts:
I'm building a bi-lingual site (English and French) with Drupal 7. I want to create a link at the top right corner of my site that toggles a page between English and French. How do I do this?

I have also installed the Internationalization module. I haven't used it yet. Maybe that can help my situation.

For example, say I am on the page http://example.com/home.  How do I figure out the french equivalent of that page, its URL, and print it to the right hand corner of my site?


texts:
How do you hide the SKU in the line item display.

It seems to be part of the "Line item label" field on
admin/commerce/config/line-items/product/fields

Theres also no option in the view to change it.


texts: Altering body text of a node before the page is rendered

texts:
I am using the Zen theme. I want to alter the body text before it is rendered as a page. In particular, I want to replace a string with another string. I thought that the general solution for this would be to place the code in the the theme_preprocess_node hook in my sub-theme's template.php. Here is the code that I've got so far:

<?php
function mytheme_preprocess_node(&$variables) {
    if ((isset($variables['body'][0]['value'])) && (preg_match('/suppose/i', $variables['body'][0]['value']))) {
        dpm('string was found in "value"');
        $variables['body'][0]['value'] = preg_replace('/suppose/i', 'new tring', $variables['body'][0]['value']);
    }
    if ((isset($variables['body'][0]['safe_value'])) && (preg_match('/suppose/i', $variables['body'][0]['safe_value']))) {
        dpm('string was found in "safe_value"');
        $variables['body'][0]['safe_value'] = preg_replace('/suppose/i', 'new tring', $variables['body'][0]['safe_value']);
    }
}
?>

However, this has no effect what so ever. I do get a positive match - this I can verify by the debug dpm() display.

Am I simply trying to rewrite the wrong sub-array?

Thanks in advance,
Valera Rozuvan


texts: Views expose filter of start and end dates

texts: I want an expose filter of start date and end date. I want to show the events that have start or end date between these two dates. If end date is not given in filter then display all the events having start date greater than filter's start date.


texts:
I made 2 custom modules: boutique and paypal. paypal is a dependance of boutique.

I check if paypal is enabled, with the following code.

namespace Drupal\boutique\Form\Multistep;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\paypal\Controller\PaypalController;

abstract class MultistepFormBase extends FormBase {
  protected function saveData() {
    if (\Drupal::moduleHandler()->moduleExists('paypal')) {
      $test = new PaypalController();
      $test->setPaiement(10,0,1);
    }

    $this->deleteStore();
    drupal_set_message($this->t('The form has been saved.'));
  }

}

All is working good, but use Drupal\paypal\Controller\PaypalController; is always be here; if the paypal module is not present, does it create problems? How can I conditionally use use Drupal\paypal\Controller\PaypalController;` only when the module is installed?


texts:
I want to disable login at all on my drupal site, even better also hide the form. If i need login i will enable it from a ssh session and after working disable again.

I will prefer to do this with rewrite rules in .htaccess but i cannot figure out the right rule.

Update (as this seems to be a popular question)

I ended up with .htaccess like this:

 # disable well known Drupal user login endpoints
  RewriteCond %{QUERY_STRING} q=user
  RewriteRule ^/?$ http://%{HTTP_HOST}/? [R=307,L]
  RewriteRule ^user$ http://%{HTTP_HOST}/ [R=307,L]
  RewriteRule ^user/register$ http://%{HTTP_HOST}/ [R=307,L]

  # goto user login with that "secret" URL
  RewriteRule ^op9__P87? /user [NC]


texts: Display one image of commerce product in product display view

texts:
I have created a view which display indexed nodes (product displays) in teaser mode.
The commerce product entity has a field called field_images which contain several images.

In teaser display mode of the commerce product, I choose to display Images.
On the views, for each commerce product, all images are displayed.
I'd like only the first to be displayed.
Unfortunately, I can't set a delta in the teaser display mode form.
I could have set the delta to 0.

I will seems reasonable to me, but I can't find an easy way to fix it.
How can I achieve this ?


texts: Doubt with display a query using Custom Field Module in View

texts:
I have installed the CustomField module.  I have a view and I'd like to add a new column in a table in the view.  The content of this column is a result of a query to a table different to node.  Is this possible with this module?

I am using Drupal 6.


texts: Views formatting: liquid number of columns?

texts:
I have a Views page that creates a 3-column grid layout.  These look just fine on a desktop browser.

On a mobile browser, each column is too thin to usefully read the text that's displayed, and it looks pretty awful, even if I use media queries to scale the text down.  I'd like to go to a single-column layout on these sorts of screens.  Is there a good way to do this?  Ideally, a CSS-only approach would be best, since I've managed to get my layout fluid using only CSS thus far.


texts: I am looking in to migrating our D7 Commerce site to Drupal 8 (just the product entities). I expect using the migrate module will be our best bet, but I'm not really sure where to start. Has anyone successfully set up a migration for this yet? Do I need a yml file for each field?


texts: Content Type exists in Database but does not show up

texts: I have created a content type, but I can not find it in the create content list. When I checked mysql database, the content type exists there. What is the problem? How can I solve it?


texts: Make sure content of every view is published

texts:
I'd like to set a query alter function that checks if the node.status condition is already set in the view's query, and if it's not I'd like to set it to only get published content. The following code doesn't seem to running on my app. Do you have any suggestions to make this work?

function hook_views_query_alter(&$view, &$query) {

    $found = false;

    foreach($query->condition as $condition) {
        if($condition = 'node.status') {
            $found = true;
        }
    }

    if(!$found) {
        $this->query->add_where(
            $this->options['group'],
            db_or()->condition('node.status', 1, '=')
        );
    }

I have > 100 views to implement this change on.


texts: How can I get the uploaded file path of a contact form in drupal 8

texts:
I'm using the hook_mail_alter() to create a custom email for contact forms.
I was able to get the fields labels and values and use a twig template to send the email. Most of it is working just fine, but my problem is when I use file fields on the contact form. I want to be able to show the path of the uploaded files. When I use the default drupal email, it shows the paths at the end of the file. I want to do the same thing at my custom email. Can anyone tell me how to do this?


texts:
I have cretad a menu for edit a form in drupal...

Code:

function pricepackages_menu()
{
    $items = array();
    $items['membership/packages'] = array(
        'title' => t('Add Membership Packages'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('pricepackages_form'),
        'access arguments' => array('access administration pages'),
    );
    $items['show/packages'] = array(
        'title' => t('Manage Membership Packages'),
        'page callback' => 'view_packages',
        'access arguments' => array('access administration pages'),
    );
    $items['package/%/edit'] = array(
        'title' => 'Edit Membership',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('pricepackages_form_update'),
        'access arguments' => array('access administration pages'),
    );
    return $items;
}

3rd menu is for eidt purpose...

The codd to show form i worte is:

function pricepackages_form_update($form, &$form_state)
{
    $form['packagename'] = array(
        '#type' => 'textfield',
        '#title' => 'Package Name',
        '#required' => TRUE,
    );
}

Please let me know how can get the value of the id in the url :

URL :  http://somedomain.com/package/1/edit

I want to get the id 1 from the url and than want to add a select query... please let me know how can i get that value so i can wrote teh select query...

Also do i have to specify a new parameter in the pricepackages_form_update() or not?

Thanks in advance...


texts: How to set jquery datapicker options from within Drupal?

texts:
I want to customize a jQuery datapicker in Drupal 7. I found code to set an event:

(function ($) {
Drupal.behaviors.only_monday = {
  attach: function (context, settings) {
   // $( ".selector" ).datepicker( "option", "showWeek", true );
   $.datepicker._defaults.beforeShowDay = onlyMonday;
    function onlyMonday ( date ) {
      if ( date.getDay() == 1 ) {
        return [true, 'ui-datepicker-days-cell'];
      }
      else {
        return [false, 'ui.datepicker-unselectable'];
      }
    }
  }
};
}(jQuery));

This works great, except for commented line. According to the jQuery docs that line (added by myself) should make visible the numbers of the weeks:

$( ".selector" ).datepicker( "option", "showWeek", true );

The context from within Drupal is probably different. But I have no knowledge of js :-(

In what way does this code for setting an option has to be adjusted ?


texts: How could i make it available for the admin to be able to upload images and categorize them in add content window? I added a taxonomy vocabulary and added a field as a taxonomy term to the content type but it only shows the terms from that vocabulary . I also would like to be able to upload an image for that term. Is it possible?


texts: How can I add "data-target" additional attribute in mega menu?

texts:
How can I add an additional attribute to menu item I am using mega menu?

On element inspect my current menu url is displaying as :

 something

I need to create it as :

 something

I have used menu links attribute module but its not working with mega menu
any other suggestions by doing some custom code?


texts: How do you setup Commerce Event Tickets?

texts:
I'm using Commerce 7.x-1.10 & Commerce Event Tickets 7.x-1.x-dev. I have installed all the prerequisites for both modules.

How do you setup Commerce Event Tickets so it creates the ticket entity per unit in the order?

I have done the following to try to set this up:

Under Checkout Rules admin/commerce/config/checkout/rules, I have change the following rule Update the order status on checkout completion under the action of Update the order state to COMPLETED.
Create a custom product type.
Add the existing field cet_enable to the product type.
Create a product and enabled the checkbox Enable Tickets.
Create a Product Display
Add a product reference field to the Product Display to the product created in step 4.
id a test purchase to see if the ticket entity was created for the product.
(This is where my process breaks down, it should create the ticket entity as this point.)


texts: how to make a page with record displayed from database

texts:
I am using a cutom module to display records from database.code below fetches all the record from database table but does not know how to display it on a page in my Drupal site (version 7):

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

  $items['form/formModule'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' => 'Form', //page title
    'description' => 'A form with a text field and Submit button.',
    'page callback' => 'formModule_intro', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form

    'access callback' => TRUE,
    'expanded' => TRUE,
  );

  $items['form/formModule/form1'] = array(
    'title' => 'Form One',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('formModule_form'),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
    'weight' => 1,
  );

  $items['form/formModule/reviewOrder'] = array(
    'title' => 'Review Order',
    'page callback' => 'formModule_page',
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
    'weight' => 2,
  );

  return $items;
}

function formModule_page() {
return array('#markup' => '
' . t('Review Order: The table below shows the TOTAL STOCK and TOTAL QUANTITY of product purchased.') . '
');

  $query = db_select('formmodule_order', 't'); // Using the TableSort Extender is what tells the
  $query->fields('t');
  $result = $query->execute()->fetchAll();

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

  foreach ($result as $key => $row) {
  $rows[$key] = array();

  foreach($row as $col) {
   $rows[$key][] = array('data' => $col);

   }
  }
drupal_set_message("
" . print_r($rows, true) . "
");

}

iam using the following code to dispaly it on a page but no results:

$header = array(
    // The header gives the table the information it needs in order to make
    // the query calls for ordering. TableSort uses the field information
    // to know what database column to sort by.
    array('data' => t('S.No.'), 'field' => 't.S.No.'),
    array('data' => t('Product Name'), 'field' => 't.Product Name'),
    array('data' => t('Total Stock'), 'field' => 't.Total Stock'),
    array('data' => t('Total Purchasing'), 'field' => 't.Total Purchasing'),

  );
 drupal_set_message("
" . print_r($header, true) . "
");**/
  $query = db_select('formmodule_order', 't'); // Using the TableSort Extender is what tells the

            // the query object that we are sorting.
  $query->fields('t');

//drupal_set_message("
" . print_r($query, true) . "
");

 $result = $query->execute()->fetchAll();

// drupal_set_message("
" . print_r($result, true) . "
");

  foreach ($result as $key => $row) {
  $rows[$key] = array();
   foreach($row as $col) {
   $rows[$key][] = array('data' => $col);
   }
  }
drupal_set_message("
" . print_r($rows, true) . "
");
  // build the table for the nice output.
  $build['formmodule_order'] = array(
    //'#theme' => 'table',
    //'#header' => $header,
    '#rows' => $rows,
  );

 drupal_set_message("
" . print_r($build, true) . "
");
  return $build;

what is wrong in the code?


texts: How to get Entity Registration fields into a View

texts:
I need help understanding if this is even possible or not. I have a view where we search current users within the site. I want to see if I can add parts of the Registration Module into the view so when we find someone that went to the event but didn't sign up online we can add them to the event post-event for reporting. I know I can just copy their user name then navigate to the registration page and add them, however I want to see if I can better the process by allowing the Content Admin the ability to register them from the view directly.

See attached for helpful image. Any ideas will be helpful since I am not a hard core php/drupal developer.


texts: Unexpected error when trying to view revisions

texts:
A website I maintain can't view revisions without receiving an unexpected error. The log file points to this code in the .theme file but I have no idea what it does. When I commented it out, the website seems to function fine and revisions are viewable.

function themename_preprocess_page(&$variables) {
  $current_path = \Drupal::service('path.current')->getPath();
  $path_args = explode('/', $current_path);
  $node = \Drupal::routeMatch()->getParameter('node');
  if($node) {
    $node_info = \Drupal\node\Entity\Node::load($node->id());
    if($node_info->hasField('field_component')) {
      $paragraph = $node_info->field_component->getValue();
      if($paragraph) {
        foreach ( $paragraph as $element ) {
          $p = \Drupal\paragraphs\Entity\Paragraph::load( $element['target_id'] );
        }
        $variables['hero_banner'] = $p;
      }
    }
  }
}

The log particularly points to the 6th line above as the error. It mentions "Error: Call to a member function id()".

Does anyone have any clue? Thanks!


texts:
I've trying to setup a Drupal 7 site where I already have some content added. The content is bound to a multi-level menu, but the path's for nodes in the submenus show only the actual node's alias, omitting the parent nodes. I wish to have url's where the path contains the content structure, no matter how many levels are?

I have tried a few pathauto settings:

[node:menu-link:parents:join-path]/[node:title]
[node:menu-link:parent:url:path]

After each try, I have rebuilt the paths and cleared cache, but I am still not getting the paths that I need, and they haven't actually changed.  All of my nodes have the "Generate automatic URL alias" setting checked on the node edit page.

How can this be achieved?


texts: Fields in View template views-view-fields--blog-posts.html.twig

texts:
I have a view called blog_posts, which selects the following fields: title (linking to node), Picture (an image field), Body and Authored on.

I have created a custom fields template views-view-fields--blog-posts.html.twig, which displays each node. Here is the content:

{{ fields.title.content }}

{{ fields.authored_on.content }}

                        {{ fields.body.content }}

Currently it is correctly displaying the title and the body.

The picture field is not displaying. I adapted {{ file_url(fields.field_picture.0.entity.uri.value) }} from a node template where it is displaying a picture correctly. Ho{{ file_url(fields.field_picture.0.entity.uri.value) }}w can I make it work in a view template?

The authored on field, {{ fields.authored_on.content }} should display the posted date of the node.

Finally, I would like to put the URL of the node in the link. Is it possible to get this from the data I have, or do I need to add a field for it?

Thanks for your help,

James