texts: Why D7 Update Manager keeps sending emails?

texts:
This is very weird,

http://example.com/admin/reports/updates/settings

keeps sending emails to my email while the owner of example.com has changed his website from Drupal 7 to weebly! I mean, the Drupal installation does not exist!


texts: How to generate an excerpt for a specific field in Search API Solr?

texts:
I created a custom query that displays publications based on keywords entered by user. The query looks into "title", "body" and "author title"(node reference) fields.

 if(empty($keywords)!=1){
      $index = search_api_index_load("index_all");
      $query=new SearchApiQuery($index);
      $query->condition('type', 'publications', '=');
      $query->condition('language', $language->language, '=');
      $query->fields(array('title', 'field_author:title', 'body:value'));
      $query->range(0, 30);
      $query->keys($keywords);
      $data=$query->execute();
      $results=$data['results'];

      if(empty($results)!=1){
        print '
'.t('Publications').'
';
        foreach ($results as $key => $result) {
          $alias = drupal_get_path_alias('node/'.$result['entity']->nid);
          print '

'.$result['fields']['title'].'
';
          print '
'.$result['excerpt'].'

';
        }
      }
    }

Everything works well except the excerpt generated.

I don't know why, excerpt seems to be generated in conjunction with "author name" and "body field", I mean every time. Even if the author name hasn't any of keywords, he is printed every time. For example with keyword "tax", I get this:

  Corporate Tax Reform International

  Pierre-Marie Glauser Corporate Tax Reform International ...

The second line is generated by print '
'.$result['excerpt'].'

';

As you can see, the author name "Pierre-Marie Glauser" appears in excerpt, but it is not concerned by keyword "tax".

Also if I disable the title from excerpt in admin UI:

The author name doesn't appear anymore in excerpt!!! For example if the query is "Glauser", I have no excerpt generated (when I had if the title is enabled for excerpt..). Something seems buggy there, it's like "title" and "author name" fields are stucked.

I don't want to exclude author name completely from excerpt. I just want to exclude it when keyword is not matching with it. For example if the keyword is "Pierre-Marie" or "Glauser", the author name should appear in excerpt. Same for title. Only display title if it's matching with keyword

How to get selective excerpts programmatically. For example, is it possible to generate an excerpt for "title" field and another one for "author name" field separately?


texts: Entity Query field condition for Webform submissions

texts:
I'm trying to query webform submissions based on a field value. The field is called "ticket_for".
Somethings I tried and do not work:

    ->condition('ticket_for',$adnummer)
    ->condition('webform_submission_data:ticket_for',$adnummer,'CONTAINS')
...

What kind of condition should I be using in a query like this?

$query = \Drupal::entityQuery('webform_submission')
->condition('webform_id', 'ticket')
->condition('entity_id', $eventID)
->condition('webform_submission_data:ticket_for',$adnummer,'CONTAINS');


texts: Creating a node type module in Drupal 7.x

texts:
I am having some deep trouble getting around creating a node type with Drupal 7.x.
My aim is to create a node type that has some form elements within a table grid. Using any of the existing modules is coming across as a challenge because I can't find anything specific to my needs, hence I decided to explore module building and then enabling it as a node.

The tutorial I have is :
http://drupal.org/node/231019 (Create new content type for Drupal 6.x) .. .there isn't any exact tutorial available for Drupal 7.x

I have followed every step but am unable to see the content type appear in my node module.

Anybody has pointers to any resources for this?

Thanks


texts: How to manage text on my site that's not node content?

texts:
I have text on my site that isn't node content, such as:

footer legal text
"Subscribe to our newsletter"
"Browse our categories"
etc.

I need to save my development work as a Feature but I also need content editors to be able to edit the text. But I don't want to give them permission to edit all blocks. In the not too distant future, the site will be extended to another region so this content will also need to be translated.

Is there a technique / solution designed for housing this data?

I could create a new content type and create a new field for each piece of text. I could easily print the field in TPL files but it might be a little harder to print it in blocks. I also don't know if its performance inefficient to do this, does the whole node object get loaded when you print a single field?

I've heard about (but not used) the Nodeblock module. It looks like this would work but I don't know how easy it will be to work with the Features module (I don't think you can feature nodes).

One nice thing about the first method is that the field label could be descriptive eg "Footer legal text" which would make the translation side of things easier.


texts: How do I turn a select list into a radio button?

texts: I have a list text field that I want to display as a series of radio buttons instead of a select (dropdown) list.  In Drupal 7, I could change this on Manage fields.  How can I do that in Drupal 8?


texts: Best way of having Pathauto based off node title, but not tied to it?

texts:
Sorry for the poorly worded question, I'll try to better explain myself.

I'm swapping (not migrating) from WP to Drupal and I'm trying to replicate WP's URL feature. I want it to initially be based off the title of the node ("My First Blog Post" => "my-first-blog-post")

What I'm not wanting is Pathauto to be directly linked to the title, so I can update the title to something like "My First Blog Post (Updated 5/4/2017)" without having to worry about the URL changing. I want the URL to be easily editable if the need rises, I just don't want it tied to the title.

Would the best way just be to add an extra field, and manually enter a 'URL title' in there?


texts: How to set form action to default contact form action

texts:
I'm editing a Drupal site, it has a hardcodeded contact form which I would like to have the same behaviour than the default contact form (applying filters, inserting info in the database and sending email).

Maybe it is an easy question but I don't know how to do it.

Thanks!


texts:
I'm trying to theme the login user page and it seems that I'm missing something and I can't figure out what it is.

here is what I did:

I've added this code to my template.php:

 function mxblog_theme() {
  $items = array();
  // create custom user-login.tpl.php
  $items['user_login'] = array(
  'render element' => 'form',
  'path' => drupal_get_path('theme', 'mxblog') . '/templates',
  'template' => 'page--user--login',
  'preprocess functions' => array(
  'mxblog_preprocess_user_login'
  ),
 );
return $items;
}

and this that I'm trying to render in the page--user--login.tpl.php

   print drupal_render($form['name']);
    print drupal_render($form['pass']);

    print drupal_render($form['form_build_id']);
    print drupal_render($form['form_id']);
    print drupal_render($form['actions']);


texts: How to revoke edit access to the node's author after publishing a node?

texts:
I am trying to build a new rule on Drupal 7 with both the Rules and Content Access modules (and its sub module Content Access Rules integration). Thus, I get new actions like "grant or revoke an access" for specific role.

An authenticated user can add a content on the website but it is unpublished by default (like a draft).

When the user is ready, he/she can publish the content (different modules can do that, Save Draft, Publish content).

After the content is published (which event?), I need to revoke the modification access for the node author.

I have tried to build the rule as this tutorial shows but without Flag.

It does not work, the author can still edit the content after publication and no modifications have been made on access control for this node (I have checked the "Per content node access control settings" box in the content type settings).

I guess the problem is the non-published state of my node and thus the lack of access settings, since Content Access needs published nodes to operate. Then, I ask Rules to modify content access that does not exist ...

A custom module is available here but I would rather use the Rules module since, theoretically, it could be done.

Here is an export of my rule code :

{ "rules_revoke_edit_access_after_publication" : {
    "LABEL" : "Revoke edit access after publication",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "content_access_rules" ],
    "ON" : { "node_update--manuscript_submission" : { "bundle" : "manuscript_submission" } },
    "IF" : [ { "data_is" : { "data" : [ "node:status" ], "value" : "1" } } ],
    "DO" : [
      { "content_access_action_revoke_node_permissions" : {
          "node" : [ "node" ],
          "permissions" : { "value" : [
              "view:3",
              "view_own:3",
              "update:3",
              "update_own:2",
              "update_own:3",
              "delete:3",
              "delete_own:3"
            ]
          }
        }
      }
    ]
  }
}

Default access for authenticated user : view/modify own content (+ view any unpublished content (of the content type needed) thanks to the View unpublished module)

Access needed after publication : view own content only.


texts: I have a website, but I want to figure out how to create a tab or link within the website that users would have to log in to view. There would most likely be one set of log in information that everyone in my organization would use. For example, maybe the username is org27 and password is 222orgs and everyone would use that to access the tab or link. How would I do that or is that even possible? Thank you.


texts: Display particular Image Style for image based on Role of User?

texts:
Using ImageCache Actions there are 2 different Image Styles - e.g. S1 and S2.

What needs to happen:

User A has Role Y and when s/he views a node/user profile should always be presented with S1 images.
User B has Role Z and when s/he views a node/user profile should always be presented with S2 images.

What are the different ways this can be achieved? All suggestions very welcome.


texts: Is it possible to show a menu in a view as buttons?

texts:
I'm trying to build a page with a quick menu. Now I've created a menu by the regular way and I've shown this on the place i wanted. Now due to the way my site currently looks, this is very out of the shape I wanted it to be.

Now my question is: Is it possible to show my menu items as a view and decorate them with a button (and if possible an icon from the FontAwesome library)?

My idea would look something like this, with the blue things as buttons creating for every menu item:

A module or a work around would both be fine!


texts: How do I create an aggregate view of products i've purchased? (Commerce)

texts:
How do I get an aggregate view of all products i've purchased?

I'm specifically looking to show only one field from the products, "file".  My use-case is that I have a course registration site using Drupal Commerce, Views, Commerce_Registration, etc.  Each course (product) has a non-visible field "file" which I want to aggregate in a view.

Any direction is greatly appreciated!


texts: Cannot add 'Page Title' and 'Main Content' blocks to panel

texts:
Configuration:

Drupal 8.1.5
Panels 8.x-3.0-beta4
Page Manager 8.x-1.0-alpha23
Layout plugin 8.x-1.0-alpha22
Panelizer 8.x-3.0-alpha2

When I create a Panel variant for /node/{node} with Page Manager, I can add field blocks, like

entity_field:node:title
entity_field:node:body

These get rendered.

However, if I add blocks

CORE / Page Title (page_title_block)
SYSTEM / Main page content (system_main_block)

these render to nothing.
Can someone explain why?


texts: Image styles are not generated in Docker for Windows

texts:
When I open in browser http://localhost:1567/sites/default/files/styles/thumbnail/public/2017-10/478069720_1384178114_4.jpg, I see 404.

The "original" images are uploaded successfully, and the website works without any problems. Only the image styles are not generated.

My environment:

Drupal 8. Patched with https://www.drupal.org/files/issues/944582-124.patch, see the issue: https://www.drupal.org/node/944582.
I use the php:7.0-apache image.
Permissions for sites/default/files is 755, owner is root.
tmp has 777, root.

I debugged: there is no request to index.php.
When I remove the SetHandler Drupal_Security_Do_Not_Remove ... in /sites/default/files/.htaccess, everything works. But I do not want to remove these security headers.

FYI: in Docker for Windows everything is executed as root and default permissions are 755. See Official docker for windows documentation about file permissions.

Current workaround

Custom Dockerfile with the next lines at the end:

# Docker works with mounted directories as user with uid 1000.
# A www-data should be 1000 to prevent problems with permissions in /sites/default/files directory.
RUN usermod -u 1000 www-data && adduser dev --disabled-password --gecos "" && usermod -aG www-data dev


texts: How can I log the flags users put, then auto unflag them?

texts:
I used this link to set up a UserPoints Store:

Drupal 7 - How to Set up a Simple UserPoints Store.

I need help finishing one thing:

When user flags item
some code starts working and logs the fact that this specific user just flagged this specific page(content)
Once this information is logged somewhere.
the page(content) that the user see's as [Already Flagged] needs to automatically unflag.
So that user can flag it again if he/she wishes.

If you look in the link above it can be understood that flagging a item(page/content) deducts points from the UserPoints system. As soon as the user presses flag this they get the option to type in the quantity they would like to "purchase" or flag. I need this quantity logged too.

In short, this is an example of how it should log:

User | Time/Date | Quantity |  Page
-----+-----------+----------+--------
id2  | 8/18/2016 |     3    | /node/9
id7  | 2/13/2016 |     1    | /node/5
id4  | 4/28/2016 |     1    | /node/1

I hope it makes sense. It would make more sense if you take a look at the info in the link.


texts: How to trigger a Rules action based on which content pane of a panel is used?

texts:
I have a page with a path like www.example.com/newsroom. On this page nodes are displayed with help of 2 different views:

View 1 : contains voted nodes by user.
View 2 : contains not voted nodes by user.

The 2 views are content panes and www.example.com/newsroom is a panel page. So there is no difference in the path of both views, and the user can see both views together.

I am using the Rules module to perform some action when vote is cast on any of node. And using Rules one can check the path from where a user performs an action on a node, simply by using the token [site:current-page:url]. But  in my case that is www.example.com/newsroom (no matter where the vote is related to).

Is there any way that I can differentiate if a node on that page is voted from via View 1 or View 2? As [site:current-page:url] returns path www.example.com/newsroom ... Based on which view it is, I want Rules to perform different actions. So how to check in Rules if the node being voted on is from View 1 or View 2?

I do have different classes of both views, but I'm not sure how to check those with Rules.

Any suggestions?


texts: How to programmatically get the difference between two entities of same content type?

texts:
I need to implement a function that checks if there has been a change from the previous existing node. If yes, send the updated changes.

I understand that Drupal has revision system and through diff we can see the difference between two revisions.

I want similar to that, however as an API call or a logic which can facilitate getting the difference.


texts: Views hook gets ignored after 1 execution

texts:
I registered this hook in my module:

function MYMODULE_views_pre_render(\Drupal\views\ViewExecutable $view) {
        die('hello world');
}

I cleared the caches, and ran a view.

Output is "hello world" as expected.

I refreshed the view, and my pre_render plugin is completely ignored (view is shown normally).

What's happening?


texts: Trying to compare the fetched result with the user input

texts:
I am new to Drupal and I am facing some issues right now. I am making a hall booking website, so I have a table named "halls" with following fields: HallID, HallName, Capacity, Type, Price.

I created a new module and the form that I need. On the booking page I have 2 dropdown menus, type of hall the hall the user needs. (each hall has different capacity and price). Right after these I have 2 text fields, Capacity and Price.

So what I do is I retrieve from database the Capacity value for the Hall and the Type the user has chosen and right after submitting I am trying to compare the input from the Capacity field with the earlier retrieved result. I am getting "Success" message every time, even if Capacity field value is higher than the value in the db...

Here I am retrieving data intro dropdown menus from db and creating simple forms:

function booking_form($form, &$form_state){
$table = 'halls';
$query1 = db_select($table, 'h')
    ->fields('h', array('HallName'))
    ->distinct();

$query2 = db_select($table, 'h')
    ->fields('h', array('Type'))
    ->distinct();

$result1 = $query1->execute()->fetchAll();
$result2 = $query2->execute()->fetchAll();

$hall_name = array();
foreach($result1 as $res1){
    $hall_name[] = $res1->HallName;
}

$hall_type = array();
foreach($result2 as $res2){
    $hall_type[] = $res2->Type;
}

$form['hall_type'] = array(
    '#type' => 'select',
    '#title' => 'Select the hall type',
    '#options' => $hall_type,
);

$form['hall_name'] = array(
    '#type' => 'select',
    '#title' => 'Select the hall',
    '#options' => $hall_name,
);

$form['nr_people'] = array(
    ...
);

$form['duration'] = array(
    ...
);

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

return $form; }

After this comes the validation. At first I am querying the value of Capacity field based on HallName and HallType selected:

function booking_form_validate($form, &$form_state){

$table = 'halls';
$query = db_select($table, 'h')
    ->fields('h', array('Capacity'))
    ->condition('h.Type', $form_state['values']['hall_type'], '=')
    ->condition('h.HallName', $form_state['values']['hall_name'], '=');

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

$capacity_val= array();
foreach($result as $res){
    $capacity_val[] = $res->Capacity;
}

if($form_state['values']['nr_people'] > $capacity_val){
    form_set_error('nr_people', t('Max. capacity exceeded!'));
} }

So what is wrong? I am not fetching correctly? Any help would be appreciated. And how do I print the value that I fetch from db, in simple php I used "echo" but here in Drupal is not that simple. Btw I am using Drupal 7. Thanks.


texts: How to redirect programmatically inside a module to an external url?

texts:
I am trying to redirect to a page after I unset a session.
I read this article but I am pretty new to Drupal module building.

Here this amazing guy says to do the comming thing:

  If you know that the destination is an external URL then you are
  encouraged to use TrustedRedirectResponse instead:

return new RedirectResponse(\Drupal::url('<front>', [], ['absolute' => TRUE]));
  return new TrustedRedirectResponse('http://www.bbc.com/');

I don't understand how I should use this code and where to put it...

Any help would be great
This is my controller file content.

<?php

namespace Drupal\achva_sso\Controller;

use Drupal\Core\Controller\ControllerBase;

class SsoController extends ControllerBase{
    public function ssoLogout(){
        unset($_SESSION['name']);

        if(isset($_SESSION['name'])){
            $status = $_SESSION['name'] .' is logged in';
        }else{
            $status = 'is logged out';
        }
        return[
            '#type' => 'markup',
            '#markup' => '<p>' . $status . '</p>' ,
        ];

    }
}


texts: Solr returning empty results with accurate pager

texts:
I'm running Drupal 7 with the Apache Solr module version 7.x-1.6, it's configured and seems to be connecting to the Solr server properly.  However when I try to use a search box, there are no results for my queries.  There is no error message or no results found message.  However the pager for the results does render, and it seems to be accurate since the number of pages changes as I search for different terms.  I looked at the page results template file and saw that the variable $search_results is an empty string.

I'm a bit of a newcomer to Solr, any suggestions as to what I can do to resolve this?

Thanks


texts:
I have a third-party vender that provides particular information for us when queried.

Basically, we need to change the URL of the search results page so that their supplied javascript can contact their site and return results from searching the same term.

So if I searched for polar bears the resulting path would normally look like this
http://foo.com/search/node/polar%20bears

I need to append to the path like this
http://foo.com/search/node/polar%20bears?scq=polar%20bears
or
http://foo.com/search/node/polar%20bears?scq=polar bears

How would I accomplish this?


texts: CCK E-mail field, display e-mail form in js dialog

texts:
I set display cck field to 'e-mail contact form'. It lead to page like email/15/field_email.

Is this possible to display that form in modal dialog? Which modules I should use?


texts:
I've been using Feature to provision changes between my DEV, STAGING and LIVE sites.

What I'm finding is when I make a field redundant on a node type on my DEV site, features does not automatically delete is on my STAGING site.

For example: I originally had a field called Key Contact in my Basic Page node type. I created a feature which I uploaded to my STAGING site, the Key Contact field was created and it worked fine.

However, that same field is now redundant. I have deleted it on my DEV site. I re-created the Feature and uploaded to my STAGING site.

The problem is the Key Contact field still exists on the STAGING version of my website.

Can anyone give me some direction to get Features to not just create new fields but remove fields I have deleted on DEV - so I don't have to delete a lot of fields manually on both STAGING and eventually the LIVE site?


texts: User can't change their own location after registration anymore

texts:
i'm using the loaction module for user locations. At the registration form a new user has to enter his oder her location and it will be displayed in his profile. When the user tries to edit his or her location afterwards the fileds will be empty after saving the changes, but the "delete" and "re-geocode" checkboxes show up.

Under permission I gave the user the all the user location permission, so he or she is allowed to edit his oder her own locations as well as administer user locations in general.

I also tried to remove the location field and put it in again - no changes.

Any hints on why this is happening?

Thanks a lot!


texts: Updated to Drupal 7.51 and website is now stuck in maintenance mode

texts:
I just went to update Drupal 7.5 to 7.51 and fortunately the update worked. Unfortunately our site is now locked in maintenance mode and I was logged out of the system and cannot get back in as an admin or anything on the site for that matter.

We tried to do a site rewind to go back to our original settings before the update but still no luck. We also tried using /user and also /?q=user but this doesn't work either. The site seems to be stuck in some sort of page refresh loop. Does anyone have any suggestions of what else we should try or what we should do?


texts:
I'm using the module Leaflet and IP Geolocation Views & Maps to display the marker, I need to give the ability to add markers with the mouse click. I'm trying to add a mark on the map Leaflet, with the following code. But for some reason it does not work, if someone can tell what is the reason?

(function ($) {
    $(document).ready (function(){
        $(document).bind('leaflet.feature', function(e, lFeature, feature){
        lFeature.on('click', function(e) {
          var lMap = Drupal.settings.leaflet[0].lMap;
          var marker = lMap.marker(e.latlng).addTo(lMap);
        })
      });
    });
})(jQuery);


texts: How to include the same menu twice in a .tpl file

texts:
I am working on a responsive design for a site I am building and I currently am having trouble including the menu twice in the header template file. I need the menu displayed inside the content wrapper for large devices and outside the template wrapper on small devices so I intende to use bootstrap classes to show/hide the correct menus. However when I include the menu twice in my template file only the second instance is ever displayed. How can I get the menu to render twice in the same template.

    <?php print render($main_menu); ?>

    <?php print render($content); ?>
    <?php print render($main_menu); ?>


texts: How to get height and width of image style?

texts:
We have a custom module mymodule where we call mymodule_tokens so that we can assign custom token values from the current node. These custom tokens are used to insert values in the Article's MetaTag fields.

Problem

When fetching the default value based on an Image Style (e.g. medium), I cannot get the Height and Width based on the Configuration for the Image Style. How can I get the height and width from the Image Style?

What I have tried, but cannot get the height and width:

function mymodule_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) {
  $replacements = [];
  $node = $data['node'];
  $node_image = $node->field_image;
  $field_image_style = 'medium';

  if($node_image->isEmpty()) {
    $field_info = FieldConfig::loadByName('node', 'article, 'field_image');
    $image_uuid = $field_info->getSetting('default_image')['uuid'];
    $image = Drupal::service('entity.repository')->loadEntityByUuid('file', $image_uuid);
    $field_image_url = ImageStyle::load($field_image_style)->buildUrl($image->getFileUri());
    $image_style = ImageStyle::load($field_image_style)->getEffects()->getConfiguration();

    // Both give me error messages.
    $image_style_height = $image_style->get('height');
    $image_style_width = $image_style->get('width');
  }
  else {
    $field_image_url = $node_field_image->entity->getFileUri();
    $image_style = ImageStyle::load($field_image_style)->getEffects()->getConfiguration();

    // Both give me error messages.
    $image_style_height = $image_style->get('height');
    $image_style_width = $image_style->get('width');
  }

  foreach($tokens as $name => $original) {
    switch ($name) {
      case 'custom_image_url':
        $replacements[$original] = $field_image_url;
        break;
      case 'custom_image_height':
        $replacements[$original] = $image_style_height;
        break;
      case 'custom_image_width':
        $replacements[$original] = $image_style_width;
       break;
    }
  }

  return $replacements;
}

Error Message

  Error: Call to a member function get() on array in mymodule_tokens()

When printing ImageStyle::load($field_image_style) using Kint this is what we get.

When printing $image_style, I get the following.

Using core or contrib tokens rather than custom tokens

Using the following tokens only work when there is a value added to the field_image field, but when the field_image is not populated, the token is not able to return the default image that is populated on the field's settings page.

[node:field_image:medium:height]
[node:field_image:medium:url]
[node:field_image:medium:width]


texts: Taxonomy Term View - how to display parent View term info when child terms exist?

texts:
I have two views set up: one that displays the image field, title, and description for each taxonomy terms in a vocabulary, and one that displays a grid of photos/nodes that are tagged with a taxonomy term. What I want is to always display the parent term image/description in the first View so that users can drill down to the children terms, and then ultimately click into the second view of photos/nodes.

For instance, the first View is made up of taxonomy terms associated with the taxonomy vocabulary "Gallery". Under gallery, I have the terms "Parties" and "Games". Parties has no children terms, but "Games" has "Sports" and "Other Games" as children terms.

I would like the Gallery View page content to be displayed this way:

[parties]  [games]

Clicking "Parties" would bring you to a view page (the second View) that shows all of the photos/nodes tagged with that term. Clicking "Games" would take you to a View similar to the first View that shows the taxonomy fields for the child category, like so:

[sports]  [other games]

Clicking on "Sports" or "Other Games" would take you to a view page that shows all of the photos/nodes tagged with that term, like the "Parties" page operates in the example above.

Make sense? Hoping someone here can point me in the right direction.

Thanks!


texts: Title field input textbox way too long in firefox browser

texts:
This looks a very simple question but I seem to find it rather difficult to find a very easy solution...

Textboxes in forms are way too long when looking at it using Firefox but not in Chrome. In Chrome, container widths are respected so the textbox width does not go over containers' width. However, default size of 60 when using Firefox just breaks the container width declaration and does not get respected...


texts: Modules to create submenu with custom markup

texts:
I have a question about how to create menu with full custom markup. Custom markup is applied not to menu items, but to entire submenu.

An example of such menu is provided below:

As you can see, submenu items have different visual attributes. And they are arranged like in a grid layout.

I think, it's possible to catch mouse over events and show html element with the submenu content, when user points cursor at submenu.

But, if you know any Drupal modules, that allow to implement such a feature, or simplify this task, it will be great.

Thanks in advance.


texts:
I'm creating a site which will have multiple 'store' sections, with each store's staff needing to edit their own content, but not anyone else's.

The eventual layout will look something like this.

Store One

Page A
Page B

Store Two

Page C
Page D

This is fine - I figure I should have a vocabulary for 'Stores' and a term for each Store, and then use an access control module to limit page editing based on term.

Now, the complexity: we also need a certain amount of custom information displayed on the front page for each store (think opening hours, location etc). I figure the best place way to achieve this is to have a set of custom fields for each term, and then display them in a view that also lists the pages for the store.

Thus the problem: How do I allow a store to edit their term (and it's custom fields) but not others?

Will gratefully receive to any and all potential solutions.


texts: How to add a value to a field via custom button

texts:
I was wondering how do you add a value to a field on a form(node/add) via a custom button on views?

The scenario:
On the form(node/add) a user can see and search a list of venues(view block) and on each venue there is a 'more' when clicked the user will be able to see a pop-up of the details of that certain venue. Inside the popup there is the 'Select this venue' button when clicked should be able to add that certain venue to the field 'field_choose_venue'.

I've been trying this all day but no luck. Any help will be much appreciated.


texts:
I need to ask some help in converting the date format of a webform.

I'm writing a custom module that send the submissions of my webforms to a third party, however I have to convert my date format from "m/d/Y - H:i a" to the oracle format "DD-MON-YYYY"

I've read up on articles saying that webform uses the site's "short form" but Ideally I'd like to make the conversion in my mod, to keep it contained and because I don't know if changing the "short form" will break anything currently on the site.

This is the line capturing the date field of my form:

 $dob = $submission->data[11]['value'][0];

I'm using Drupal 6.19 and webforms 6.x-3.4
if anyone can give me some suggestions I'd appreciate it.
Please let me know if I need to provide more detail.

Thanks!
Steph


texts:
I'm trying to create a system where, say for a school or other organizations, I can load a ton of users into a database at once, so that they are grouped separately from other databases of users. However, I then want it so that when the user logs in for the first time, it will ask them to fill in all the remaining fields that aren't loaded from the original database, such as a password and email.

is there an easy way to do a two-stage user creation like this?


texts: Panels "custom content" argument formatting

texts:
I'm using Drupal 7.4 with Panels 7.x-3.0-alpha3.  When creating a "New custom content" and using context keywords (eg %node:field-integer), the numeric integer field I'm adding gets pulled through with a comma (eg 7,234 instead of 7234).  This also happens when adding Node (tokens) items.

The field in question does not have it's display formatted like that in Content Types > Manage Display either.

I believe that Tokens and Panels Context/Arguments is pulling this from the same location, but I'm not sure where it is configured like that.

I've also tried %node:field-integer-raw and -unformatted, as well as %node:field-integer:raw and :unformatted, but neither of those worked.


texts:
I have created a view. The view contains a title. The title currently links to the node.

I have Lightbox 2 installed.

To get the node to load in the lightbox I have to add more information to the link see below:

click here to see node content

URL paramenters Format = simple makes only the content of the node load in the lightbox window.

My question is how do I add the additional information (?format=simple & rel="lightframe[|width:800px; height:600px; scrolling: auto;]") to the view title link

I am using Drupal 7


texts: Basic kernel test fails with Type of Drupal\KernelTests\Core\Entity\EntityKernelTestBase::$modules must be array

texts:
Trying to port a Drupal 7 module to 9 with accompanying test and getting this error immediately when running it:
PHP Fatal error:  Type of Drupal\KernelTests\Core\Entity\EntityKernelTestBase::$modules must be array (as in class Drupal\KernelTests\KernelTestBase) in /var/www/html/docroot/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php on line 12

The test:
class MyModuleTest extends EntityKernelTestBase {

  use NodeCreationTrait;

  /**
   * @var \Drupal\mymodule\Query\YearsQuery
   */
  protected $query;

  /**
   * @var array $modules
   */
  protected static $modules = [
    'node',
    'mymodule',
    'mymodule_test',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    ...

I checked around some of the core classes - the $modules declaration looks the same. Note that I am using PHPUnit 9.


texts: Search API + Facets + Voting API + Fivestar - Cannot sort by rating, value always 0?

texts:
I'm trying to build a faceted search for single content type that has user ratings.

What have I done so far is that I have running Solr server with custom index for content type. I have been able to add and index fivestar (Voting API) fields and facets are visible. However whatever are the results of voting it seems that they won't get indexed corrently and always end to be 0, avarage and user's own rating.

Is there any way to make ratings to play nicely with Search API and faceted search?


texts: Autocomplete on multiple fields Entity Reference

texts:
This is my case:

I have a content type advertisement with some fields and an entity reference of content type product. The widget type of the entity reference is autocomplete.

These are my settings of the autocomplete field:

When I create an advertisement I can type in the name of the product. But the product has also other fields like cnk. How can I make sure the autocomplete will search on the name AND the cnk?


texts:
I'm trying to essentially create an alias to an entity edit form, but really all I need to do is redirect, but get a Page Not Found error.

function kidb_profile_menu() {

    $items['profile/%uid/edit'] = array(
        'page callback' => 'kidb_profile_redirect_user',
        'page arguments' => array(1),
        'access callback' => array('edit own main_profile profile'),
        'type' => MENU_CALLBACK,
    );

    return $items;
}

function kidb_profile_redirect_user($uid) {
    drupal_goto('profile-main_profile/'.$uid.'/edit');
}


texts: I have created a webform, but the Body label shows on the page. How do I remove that label from the form?


texts: Taxonomy filter. List terms with ajax checkbox selection

texts:
I need help to make some filter.
Block with taxonomy terms list and checkbox selection closure. Checkbox need to return all nodes categorized by selected terms on change. It has to be transparent for user (Ajax).
Thanks!


texts: How can I control the order of Drupal.behaviors?

texts: I want the JavaScript code from module X to run only after the one from module Y has run. Whats the best way to do this?


texts: How to display Site Name using Custom Block Layout at left corner of header, somehow it is displayed at right side

texts:
I am using Drupal 8.2.6, and instead of showing sitename from Configuration Parameter, trying to disply it with custom block. Custom block will use a png file with specific font design for site name.

I named this custom block as header, and placed it in Header position in block layout.

Problem I am facing is by default it will be placed at right corner of the header, regardless of any css vaule. However I need to display it at left side, where site name is displayed by default.

Am sure my header block is correct in terms of css left position settings, because if same block is placed at content  or footer, it will be displayed at left side only, however in header, it will go to right side.

Let me know please if any suggestion

http://timetracker.fivekittens.com/


texts:
i am facing below error when i am trying to excute my drupal site. Please help me out.

Fatal error: Call to undefined function uuid_get_core_entity_info() in E:\sitesroot\0\sites\all\modules\contrib\uuid\uuid.install on line 36


texts:
I would like to use views data export module.
I cannot find a way on this.
Could you please help me on this?
Thanks


texts: How to add highlighting to exposed views_autocomplete_filter in Drupal 8

texts:
Is there a way (a hook perhaps) that would allow me to modify the autocomplete fields returned by an exposed views_autocomplete_filter field?  I'd like to style the text typed into the field differently from the rest of the suggestion text.

Something like this:

------------------
| term_          |
------------------------------
| terminal emulators      |
------------------------------
| determination         |
------------------------------
| midterm exams      |
------------------------------


texts: How can I automatically make term relations between all the terms with same term name?

texts:
I have multiple Taxonomy Terms which have the same "Term Name" (with different TID).
And I need to make term relations between all the terms with the same term name.

For example:

    term-A (tid=1)
    term-A (tid=2)
    term-A (tid=3)
    term-B (tid=4)
    term-B (tid=5)
    term-B (tid=6)

Then I would like to make term relations between term A and also between term B

Is there any way I can do this automatically?
As I have thousands of this kind of terms it's not realistic to do it manually.


texts: Main menu does not display on pages with a specific path

texts:
Having a really frustrating problem with my Drupal site. On pages that have a specific path the main menu block does not load.

For example I have the path..

meet-our-derms/bios
meet-our-derms/test

The main menu block does not appear on either of those pages. As soon as I change the path to something like meet-our-derms2/bios, the menu appears.

I have the menu block set to appear on all pages, all content types, and I don't believe there are any add-on modules that would have any control over this.

Is there any other place that I should look? Any ideas as to why this is happening on only that path?


texts:
I've been checking the examples for creating a custom module in Drupal 8 and found the code for the custom page module.

I was wondering if there is something similar but for modules that render custom blocks.

What I want to create is a custom module that makes a GET request to an API and prints the results in a custom block.

Any pointers will be appreciated.


texts: How to add condition in between fields in Profile2 module in drupal 7?

texts:
I am using the Profile2 module.
Two fields are there in the Registration Form i.e.

I am : [Baby Male, Baby Female, Daddy, Mummy]

&

Looking For : [Baby Male, Baby Female, Daddy, Mummy].

if user click on I am : [Baby Male] then in Looking For: [Baby Female] is only show.

If select I am : [Baby Female] then in  Looking For: [Baby Male].

So If I am : [Daddy] then in  Looking For: [Mummy] & If I am : [Mummy] then in  Looking For: [Daddy].

How can I do this?. Is there any module in Drupal 7?


texts: Change homepage template, depending on admin setting

texts:
Problem: I have a content type called "Homepage" of which there is only one node instance (which is pointed to as the front page), that contains a bunch of editable fields so the client can update certain front page content in several places.

They want to be able to, now and then, change the front page to a slightly different layout to focus on a call to action. This will probably be an

extra content-editable text area
a driver image

That will take the place of an image on the front page. This image is output in node--homepage.tpl.php as you might expect.

My proposed solution:

Create two new fields in the Homepage content: driver text, driver image.
Create an admin page, or add to an existing admin form a button: "Driver mode". When this button is enabled,
Make the Homepage content type reference a new template that hides the old image and outputs the new fields.

Is it possible to do this - use a new template depending on some set variable, or should I have some logic in my node--homepage.tpl.php that conditionally outputs one bunch of HTML or another depending on the variable set in the admin? E.g. (rough code, ignore syntax/logic errors)

<?php

if (variable_get('driver_mode'))
{
   print render($content['field_driver_image']);
   print render($content['field_driver_text']);
}
else
{
   print render($content['field_homepage_image']);
}

?>

So basically, I'm asking what you think is a simple, clean and/or Drupal way to solve my problem above? Note that the code above is just a general example to support what I'm trying to achieve, no need to analyse it's correctness, I'm more interested in what your approach would be - should I perhaps be preprocessing the output in template.php depending on whether driver mode is on or off, so that I only output one variable, which produces the desired output depending on state?


texts: What causes the error in my custom module for OpenLayers 3?

texts:
This error gives me a whitescreen with just this message:

Drupal\Component\Plugin\Exception\PluginException:
Plugin (ifplabel) instance class "Drupal\ifplabel\Plugin\Style\ifplabel\ifplabel" does not exist in Drupal\service_container\Plugin\ContainerAwarePluginManager::getPluginClass()
(line 120 of /Users/me/Sites/ifp/html/sites/all/modules/service_container/src/Plugin/ContainerAwarePluginManager.php).

Background: The name of the module is called "ifplabel". I am making a custom module for OpenLayers 3 that will provide me with a custom marker style.

My Repo: https://github.com/joelhsmith/ifplabel


texts: I want to install Drupal 7 in a new directory of my site, using the same database account used in my previous Drupal site. Will this cause any data loss?


texts: How to restrict node authors from commenting on their own nodes?

texts:
On my site we have enquiries (nodes) and price quotes (comments). So node authors shouldn't be offered to quote prices to themselves.

That's why I want to disallow node authors comment their own nodes. How can I do so?

Updated: The 'user-compare' option in panels visibility rules could easily allow to achieve what i want. I've used this functionality for other panes i.e. profile fields etc. But  i didn't find 'user-compare' entry in Panels visibility rules for comment form in node template. Why?

I chose the way offered by Pierre.Vriens using Rules because I couldn't  make the code snippet by oksana-c work with Panels. Unpublishing comments with The Rules is not best user experience. Comment Permissions module also didn't help. Any suggestion for unsetting whole comment form for node authors programmatically in Panels environment would be much appreciated.


texts: How to remove a help text from the registration form?

texts:
I'm writing a custom function to now allow spaces and other special characters for the username on the registration form.

How can I remove the text "Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores." on that page?


texts: Secret forum visible only to users of a specific role

texts: I need to create a forum that is visible to only users with a specific role. It should remain hidden to other users including registered users. How can I achieve this?


texts: Override default language via URL parameter

texts:
With the Internationalization module, is there any way to override the default language selection?

We have a site with two languages, EN and FR, and we'd like to send out an email newsletter that has various links to the secondary (non-default) language content.
The Language Negotiation is set to "Path prefix with language fallback", and directs them to the default language, even if we use the full language prefixed URL, ie:

www.example.com/fr/content
--gets sent to--
www.example.com/en/content

What would be ideal is if we could pass an argument like this:

www.example.com/fr/content?force_language=FR

Any solutions out there?


texts: How do I change the default theme with Drush-master

texts:
I've installed a premium theme in a Drupal 8.1.0, and now each time I log into the site It crashes with the error "An unknown error has occurred" (even though the site itself works fine). I thus try to change it with Drush.

I've tried drush vset bartik in drush-master to change the non-admin theme back to bartik in Drupal 8 but then came the error:

  [error]Command variable-set requires Drupal core version 6 or 7 to run.
  [error] The drush command 'vset bartik' could not be executed.


texts: I'm using images generated by Drupal (drupal 7) to feed an application. I'm then caching those images in the app. I'm trying to figure out a way to determine if the image has been updated since the last download, is there anyway to access this information about an image, without actually loading the image?


texts: drush sup Gives "needs a higher bootstrap level" from within document root

texts:
I'm trying to upgrade a Drupal 6 site to Drupal 7.  I do:

cd /path/to/sites/drupal6-site
drush sup

However I get the errors:

  Command site-upgrade needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.
  Command site-upgrade needs the following modules installed/enabled to run: update.

The settings file is at ./sites/default/settings.php.

Running drush dl update (a module I'm apparently missing) also reports:

  No release history was found for the requested project (update).

What do I have to do to get drush to bootstrap?


texts: I am writing a module that will create the data types for my site.  I am using hook_node_info to create the type itself, then I am using  field_create_field and field_create_instance to add fields.  field_create_field and field_create_instance are functions, so I am wondering which hook they should go into.  My two best guesses at this point are either hook_node_info or hook_install.  The api seems to indicate hook_install, but I find this confusing.   hook_install happens before hook_node_info, so how can you add fields to a content type that does not exist yet?  Also hook_node_info happens every page load, but hook_install only happens once (at the time that the module is installed.)  Am I creating my content type correctly or am I missing something?


texts: In a Quick Tabs module what does this display do in a TAB TYPE view?

texts:
There are two options in my Quick Tabs settings:

display:Master
block:sid(depends on the view you have selected)

I want to know their individual effects on output.


texts: I need to limit the commerce_customer_address field to 10 cities. You should be able to choose a city from a select list and this should then set the correct postcode. It also needs to be ajaxified so that the postcode updates dynamically. Possible? How?


texts:
Drupal 7.23, Views 7.x-3.7
I have a Calendar Event content type, with a date field.
In my view, I need to pass a date range as a contextual filter such that if the event's date falls within the specified range, the events is returned.
In other words, something like /events-calendar/2013-09-04/2013-09-30 should return any events happening for the rest of this month.
So far I'm only able to match a single date, not a range.
Any ideas appreciated.


texts: Programmatically enable the entity view display

texts:
I would like to programmatically enable the Layout Builder module. I  followed the instructions given on Layout Builder — building Drupal 8 layouts, but they don't seem to work. They might be outdated for Drupal 9.1. Specifically, I'm having a hard time getting the following piece of code to work.
$entityViewDisplay = \Drupal::entityTypeManager->getStorage('entity_view_display')
  ->load('ENTITY_TYPE.ENTITY_BUNDLE.VIEW_MODE');

Can anyone help me understand it? I just keep getting a NULL result.


texts:
For some reason I can no longer manage the display of a node in the backend. Managing the form display works but not the frontend display managing. I get the following error message:

  Fatal error: Maximum execution time of 50 seconds exceeded in
  /customers/2/f/2/igghq.com/httpd.www/core/modules/field_ui/src/Element/FieldUiTable.php
  on line 100

I can still manage the display of other content types. Just not that specific one. Is there a way to reset the manage display backend form, maybee through the database?

running display suite
Drupal 8

More info: it only locks-up when loading the default display mode. Teaser still works


texts: How to restrict access to a path like user/%/flag?

texts: I have created a views to display flagged content. But the flag page is accessed by all users. I want users to access only their own flagged page.


texts: How can we change primary domain name of the site in Aegir?

texts: I have generated a site using Aegir platform. Now i want to change the primary domain name of the site, is it possible via Aegir configuration.


texts: How to know all the available BASE_FORM_ID?

texts:
I know just a few BASE_FORM_ID to use with the hook_form_BASE_FORM_ID_alter() hook, there is an old article named Using hook_form_BASE_FORM_ID_alter() talking about this.

In the article there is a method to know if a form have en BASE_FORM_ID

But, how to know all the available BASE_FORM_ID in Drupal 7 and Drupal 8?


texts: How to not hide a taxonomy term if it has no content

texts:
I have a view that shows content. The issue is that I needed to still show a taxonomy term even if it has no content under it. Is that possible?

Here's the screenshot


texts: How to patch module files with netbeans 7.4?

texts:
Trying to apply patch https://drupal.org/files/webform_preview-435232_1.patch
to webform 7.x-3.19 via Netbeans tool - apply dif-patch. Downloaded this patch and put into drupal root directory. When applying patch to module files see the following: "The patch cannot be applied in the selected context". Module files are in Netbeans project and all paths are properly set. The code to which patch changes are applied exists in the target file, so what else problems can be?

Thanks!


texts:
Hello is it possible to create drop down menu without using any plugins at all?
In general the structure of menu is as follows for drop down.

Top1

drop1

drop2

I have create new menu and placed menu parents and children accordingly. Now I need to know if it is possible to show the menu in structure as above without using third-party modules.


texts: End points for services module not working

texts:
I have setup an endpoint following this guide. I am getting mixed results, as endpoint/node.xml successfully returns a list of content nodes.

When I try and load an individual node as xml, I just get a blank xml document example below, clicking /endpoint/node/1000.xml results in:

<?xml version="1.0" encoding="utf-8"?>
<result></result>

Also if I try and load it as a ...node/1000.json it just returns false.

Error log is really vague, content is open to non-authenticated users so permissions shouldn't be an issue.

Any help would be fantastic.


texts:
This is my javascript request:

var XHR = new XMLHttpRequest();
XHR.responseType = 'blob';
XHR.addEventListener('readystatechange', function() {
    if (XHR.readyState == 4) {
        if (XHR.status == 200) {
            var blob = new Blob([XHR.response], {type: "application/mp3"});
            var url = window.URL.createObjectURL(blob);
            var a = document.createElement('a');
            a.href = url;
            a.download = 'Myfile.mp3';
            a.click();
            window.URL.revokeObjectURL(url);
        } else {
            document.getElementById(regidrs).innerHTML = "Error: " + XHR.responseText;
        }
    }
});

var FD  = new FormData();
FD.append('uuid', uuid);
XHR.open('POST', '/fetch');
XHR.send(FD);

This is my module routing:

my_module/my_module.routing.yml

my_module.content:
  path: '/fetch'
  defaults:
    _controller: '\Drupal\my_module\Controller\MyController::content'
    _title: 'Hello World'
  requirements:
    _permission: 'access content'

And my controller:

<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Form\drupal_set_message;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
 * Defines HelloController class.
 */
class MyController extends ControllerBase {

  /**
   * Display the markup.
   *
   * @return array
   *   Return markup array.
   */
  public function content() {
     ...
        $response= file_get_contents(....);
        $file = file_save_data($response, "public://myaudiofile.mp3", FILE_EXISTS_REPLACE);
     ...
     return [
      '#type' => 'markup',
      '#markup' => $response,
    ];
  }

}

But file_get_contents returns a mp3 file, and I need to pass this mp3 to the javascript httpresponse in order to donwload it.
Saving $response to a file, I have checked the file is ok.

How can I do it?


texts: Return an Ajax Response from EventSubscriber?

texts:
I am trying to return an ajax response when a user logs in while the page is loading post-login.

/#1 approach was attaching an ajax callback to the user login form submit with form_alter. However this callback fires right on submit and I need an ajax callback to fire after the front page loads post-login.

/#2 approach, I made a user login event and subscriber instantiated during hook_user_login. This works perfectly, I can do a drupal_set_message after a user logs in. But how would I return an ajax response from the event subscriber?

eventsubscriber peared down

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      UserLoginEvent::EVENT_NAME => 'onUserLogin',
    ];
  }

  /**
   * Subscribe to the user login event dispatched.
   *
   * @param \Drupal\gary_custom\Event\UserLoginEvent $event
   *   Dat event object yo.
   */
  public function onUserLogin(UserLoginEvent $event) {
    //$response = new \Drupal\Core\Ajax\AjaxResponse();
    //$response->addCommand(new \Drupal\Core\Ajax\AlertCommand('test'));
    //return $response; does not work
    drupal_set_message(t('Testy testy')); //works
  }


texts: Searching on complete node title in Search API fails to find that node

texts:
I have a site with Search API, Search Pages, and Fuzzy Search modules installed. There's no Solr or anything installed. The core search module is turned off. I have a node whose type is indexed, with title as a searchable field, whose title is "quick brown fox".

When I search for the term quick brown fox nothing comes up.
When I search for the term quick brown nothing comes up.
When I search for the term quick fox my node comes up.
When I search for the term brown fox my node comes up.
When I search for the term quick fox my node comes up.
When I search for the term quick bro nothing comes up.
When I search for the term fox brown my node comes up.
When I search for the term fox quick my node comes up.

What is going on? Why is it getting confused by anything that contains the first word and second word of the node title in that order, but seems to be finding everything else just fine?


texts: Views PHP Filter - Filter Results by Role

texts:
I looked a lot of places and couldn't find a way to filter the results of a view based on the nodes a user could actually edit. So I used Views PHP Filter and some custom code to make it happen.

Comments and improvements welcome.

global $user;
$type = array();
$nid_list = array();
$perms = array();
foreach($user->roles as $role) {
  $role_perms = db_fetch_array(db_query("SELECT `role`.`name`, `permission`.`perm` FROM {role} INNER JOIN {permission} ON `role`.`rid` = `permission`.`rid` WHERE `role`.`name` = '%s'", $role));
  $perm_temp = explode(", ", $role_perms['perm']);
  $perms = array_merge($perms, $perm_temp);
}
foreach($perms as $perm) {
  $pos_edit = strpos($perm, "edit");
  $pos_content = strpos($perm, "content");
  $pos_products = strpos($perm, "products");
  if (($pos_edit !== false) && ($pos_content !== false)) {
    $perm = substr($perm,9,strlen($perm)-16);
    if (!in_array($perm, $type)) {
      $type[] = $perm;
    }
  } else if (($pos_edit !== false) && ($pos_products !== false)) {
     $perm = substr($perm,9,strlen($perm)-18);
     if (!in_array($perm, $type)) {
       $type[] = $perm;
     }
  }
}
foreach($type as $ctype) {
  $nids = db_query("SELECT `node`.`nid` FROM `node` WHERE `node`.`type` = '%s'", $ctype);
  while($row = db_fetch_array($nids)) {
    $nid_list[] = $row['nid'];
  }
}
asort($nid_list);
return $nid_list;


texts: Context Module - not triggering menu active

texts:
I need the menu called "Questionários" to be active/visible (and styled in different color) only for the node 115.

I've installed the context module and tried to use the path pointing to my node but it didn't work.

Here's a print (some things are in Portuguese but I hope you can understand):

Thank you!


texts: Variable available everywhere in template?

texts:
I'm developing my first website with Drupal. So far it's going well but I have a few details I haven't figured out.

I want to load a random variable on each page load, in order to load a different color scheme each time.

My template is called 'fest' so I put this in my template.php:

$color = $colors[array_rand(Array('red', 'blue', 'magenta', 'green' ), 1)];
$variables['color'] = $color;

If I put it in fest_preprocess_html the color var can be accessed in html.tpl.php but not in page.tpl.php. I want that variable available in node, page, html, everywhere.
Putting this code in plain function fest_preprocess didn't work either.
What am I doing wrong?

--EDIT
Check @Berdir's answer, which led me to resolve this issue. This is the code I used after all:

function mytemplate_get_color() {
    static $color = NULL;

    if (!$color) {

        $colors = Array('red', 'blue', 'magenta', 'green');
        $rand_key = array_rand($colors, 1);
        $color = $colors[$rand_key];
    }

    return $color;
}


texts: Importing large content with Feeds and cron

texts:
I've used the migrate module in the past, it's great to import large amounts of content but it's pretty complex.
This time I'm trying Feeds and Feeds_SQL to import from a mysql tables. It imports fine when I kick it off with the import UI. However it will give an Ajax error after importing a few hundred records.

I try to import using cron. That's where it gets confusing to me:

I select "periodic import" -> "as often as possible", uncheck "import on submission" and check "process in the background".

I then start the import using the UI, it imports some nodes and then stops.

When I manually run "feeds_cron" nothing happens. When I manually run "job_scheduler_con" it showed "Finished processing scheduled jobs (0 sec s, 1 total, 0 failed)." in teh logs and imported more records (but not all).
When I run it again it shows "Finished processing scheduled jobs (0 sec s, 0 total, 0 failed)." and nothing gets imported.

Do I have the correct settings? How are the "periodic import" setting and the "feeds cron" and "job scheduler cron" related?

Is there a setting somewhere that controls how many nodes are processed each time?


texts: Why is my custom module not being recognised?

texts:
I am trying to create a simple module by following the instructions in http://websmiths.co/blog/very-introduction-drupals-hookformalter.

I've created the following two files along with the content in them as below:

mysite_simplenews.info

name = Custom Example
description = Just a simple example module
version = 0.1
core = 7.x
package = Alpha Custom Modules

mysite_simplenews.module

<?php

I've uploaded the module to the server, but it is not being picked up in the list of modules.

Is this because I am running Drupal 7 and the tutorial is for drupal 6? Is it because of the <?php line in my .module file?


texts: Show Filename of uploaded files in "Field Collection" Field

texts:
I have a requirement where I have to show files uploaded within a category.. I used Field Collection Module of Drupal for it and made fields in the following way, where each category is a field collection item which has a title field and a multi value file field:-

Now, my end result is to show it in a Search Results Page. When someone searches for a keyword, and it matches the uploaded filename, the file should show in the Search.

I tried views, etc, but I can't output it. Any help please on how to output the file names for the search keyword through Search Results in Drupal ?


texts:
I added a webform to my site. Everything works fine, except that the title (surrounded red) is saying "webform", but I want it to change to "Kontakt" (as the title in the form itself).

Theme is "TB Corpal".

Two questions:

What is the right terminology for this type of title? Is this just called "title" or what is the proper name in drupal?
How can I change that? (I already tried the module "Automatic Nodetitles" but this changes just the title in the form istself)

Or can I do this using "views"? If yes, how?


texts:
When I run drush cim -y on my staging instance of my site I get the following error:

  Drupal\Core\Config\ConfigImporterException: There were errors
  validating the config synchronization. in Drupal\Core\Config\ConfigImporter->validate() (line 728 of /var/www/xeno/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php).
  The import failed due for the following reasons: Site UUID in source storage does not match the target storage. Entities exist of type Paragraph and Paragraph type Image. These entities need to be deleted before importing.

This is what I did:

Copied the database from staging and pulled the latest code
Ran drush cex -y
Committed configuration
Went to staging and pull latest code
Ran drush cim -y and get the error stated above

When I run drush cget system.site uuid on local and staging I get the same uuid so I am not sure why I am getting this error.

How can I fix the error?


texts: OpenID Connect Single Sign On handling login block

texts:
I am trying to implement an SSO system for my 3 Drupal websites. All the sites are separate domain and not sub-domains.
Here is the problem:
On the client site, client1.com, I click "Log in with Generic".
I am transferred to the server site, server1.com.
I entered the Username and Password and click Log in. I "authorize this request". I land at the client site, client1.com. But the login block still shows as previous. When I check the cookies in the browser url bar, it shows a cookie is created with client domain name.
I have followed the steps provide by the article here (https://www.drupal.org/node/2274367).
I don't know how to troubleshoot this issue with SSO. Please help to resolve this issue.


texts:
Right now, I am using Zen theme as basic theme for my website. I want to add Bootstrap into my theme because I don't want to use new theme and setup everything.
Does anyone know if I can only add these two lines of code to setting instead of downloading every single bootstrap file?

settings[bootstrap_source] = bootstrapcdn
settings[bootstrap_version] = 2.3.2

I found the above code in someone's theme setting, but I didn't find the meaning of them. So, I am not sure whether this can be worked.

Thank you very much.


texts:
I have been using this query to query Postgres Table Primary Key Column.

SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS data_type
FROM   pg_index i
JOIN   pg_attribute a ON a.attrelid = i.indrelid
                     AND a.attnum = ANY(i.indkey)
WHERE  i.indrelid = 'semstudent'::regclass
AND    i.indisprimary;

I want to perform the above query in Drupal. Below is my code:

$query=db_select('pg_index', 'i',array('target' => 'import'));
$query->join('pg_attribute' , 'a' ,'a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)');
$result = $query
    ->fields('a', array('attname','atttypid','atttypmod'))
    ->condition('i.indrelid', '"semstudent"::regclass')
    ->condition('i.indisprimary', true)
    ->execute();

The query above create the error below:

  PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type oid: ""semstudent"::regclass"
      LINE 5: WHERE  (i.indrelid = '"semstudent"::regclass') AND   (i.indisp...
                               ^: SELECT a.attname AS attname, a.atttypid AS atttypid,   a.atttypmod AS atttypmod
      FROM
      {pg_index} i
      INNER JOIN {pg_attribute} a ON a.attrelid = i.indrelid AND a.attnum =     ANY(i.indkey)
      WHERE  (i.indrelid = :db_condition_placeholder_0) AND (i.indisprimary =   :db_condition_placeholder_1) ; Array
      (
          [:db_condition_placeholder_0] => "semstudent"::regclass
          [:db_condition_placeholder_1] => 1
      )
      in myid_get_template_table_primary_key() (line 755 of C:\xampp\htdocs\drupal-  7.34\sites\all\modules\myid\includes\myid_inputting.inc).

I guess it has something to do with the statement below.

->condition('i.indrelid', '"semstudent"::regclass')

How do I convert it?

UPDATE:

Suggestions below are appreciated but it doesnt make any changes in my code. I have somehow managed to get it working manually. See code below:

 $database = 'import';
 $table = 'semstudent';

 $query=db_select('pg_index', 't1',array('target' => $database));
 $query->join('pg_attribute' , 't2' ,'t2.attrelid = t1.indrelid AND t2.attnum = ANY(t1.indkey)');
 $result = $query
    ->fields('t2', array('attname','atttypid','atttypmod'))
    ->condition('t1.indrelid', myid_get_table_oid($table, $database))
    ->condition('t1.indisprimary', true)
    ->execute();

I have made the function myid_get_table_oid supplied with two parameters: $table and $database. $table represents the name of the the table. $database represents the target database.

//A function that returns the oid of a particular table.
function myid_get_table_oid($table_name, $database){

    $query=db_select('pg_class ', 't1',array('target' => $database));
    $result = $query
        ->fields('t1', array('relfilenode'))
        ->condition('t1.relname', $table_name)
        ->execute();

    $oid = '';
    foreach($result as $record){
        $oid = $record->relfilenode;
        break;
    }
    return $oid;
}

In many instances, the code I made is working but there is one scenario the function returns no primary key. When I use the code above with a particular table myid_template_27 in my database. The function myid_get_table_oid returns an oid    8948915. But the converted query doesnt return anything.

I am pretty sure that the table myid_template_27 have a primary key column. It must return the column biginta.See image below:

To see if biginta really exist on pg_attribute table, I made a query below:

SELECT t1.indrelid, t2.attname AS attname, t2.atttypid AS atttypid, t2.atttypmod
AS atttypmod
FROM pg_index t1
INNER JOIN pg_attribute t2 ON t2.attrelid = t1.indrelid AND t2.attnum =     ANY(t1.indkey)
WHERE  (t1.indisprimary = true)  AND (t2.attname = 'biginta')

The result shows a different indrelid oid which is different from the value returned by my function myid_get_table_oid.

Where did I go wrong?


texts:
I have more than 100,000 articles to move from Drupal 6 to Drupal 7.

How do I solve this memory usage limited problem?

module: migrate d2d


texts: Managed_file images disappearing after form resubmission

texts:
I'm building a site using the Nexus theme, and wanted to give users the ability to change the slideshow images using Drupal rather than using the default FTP (which is an odd way to make people update their slideshows). There are three images in the slideshow, and each one has its own theme settings for text and links, but not the images. By default they make you update the images by replacing them in the theme folder via FTP (or your preferred method of uploading files).

So for each image I added the following form field to the theme settings (replacing "slide1" with "slide2" and "slide3", respectively):

 $form['nexus_settings']['slideshow']['slide1']['slide1_image'] = array(
  '#title' => t('Image'),
  '#type' => 'managed_file',
  '#default_value' => variable_get('slide1_image', ''),
  '#upload_location' => file_default_scheme() . '://slides',
);

Then I added code to make the files permanent. That all seems to be working well so far--for the most part. The problem is that if I replace only one of the images, the other two will disappear as soon as I hit the "Save configuration" button. It will only work properly if I update all three images at once.

It seems like even though the slideshow is loading the images correctly, the theme settings form doesn't save a record of them. So if the form is resubmitted without three images being present in the managed_file fields, any images that have not been updated will disappear.

How do I get them to save?

Thanks.

UPDATE: I tried the code example at this site with no luck. I'm not sure if that's the wrong thing for what I need or if I'm just not doing something properly.


texts: What am I doing wrong with accessing this array element?

texts:
$form['cookie']['saved'] = array(
    '#type' => 'textfield',
    '#title' => 'How long?',
    '#required' => TRUE,
  );

But if I do:

  if ($form_state['values']['cookie']['saved'] == 'Dog the Bounty Hunter') {
    form_set_error('dog_error', t("That doesn't make any sense."));
  }

I get an error that the 'cookie' index doesn't exist.


texts:
I've setup another commerce price field which I want to use instead of 'default' commerce_price field (under certain conditions). hook_commerce_product_calculate_sell_price_line_item_alter() does the job on full product page but it doesn't work 'globally'. In shopping cart / order page   price goes back to default commerce_price field. Actually it's acting strange because when I add product to the shopping cart it shows amended price but it goes back to default price once page is refreshed...

p.s. I can't use Rules to change price.


texts: Related Content Block for a Views Page, Not a Node Page

texts: I've created a views page that displays the most recent node of a certain content type. I have an image field in that content type that I would like to have displayed in the sidebar in a related content block. I have achieved this on the individual node pages using the contextual filter of NID with Content ID from URL. However, the views page is not the node page, so the related content block will not appear. How would I achieve this? Thanks!


texts:
function lawyer_register_menu() {
  $items['lawyer_register'] = array(
    'title' => 'Lawyer Registration',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'lawyer_register_form'
    ),
    'access callback' => TRUE
  );

  $items['lawyer_register-autocomplete-engine'] = array(
    'page callback' => 'lawyer_register_autocomplete',
    'type' => MENU_CALLBACK,
    'access callback' => TRUE
  );

  return $items;
}
function lawyer_register_form($form, &$form_submit) {
  $form         = array();
  $form['name'] = array(
    '#title' => 'Username',
    '#description' => 'choose a username',
    '#type' => 'textfield',
    '#required' => TRUE
  );

  $form['mail'] = array(
    '#title' => 'email',
    '#description' => 'enter a valid email address',
    '#type' => 'textfield',
    '#required' => TRUE
  );

  $form['fname'] = array(
    '#title' => t('Full Name'),
    '#type' => 'textfield',
    '#size' => 20,
    '#maxlength' => 20
  );

  $form['phone_no'] = array(
    '#title' => t('phone_no'),
    '#type' => 'textfield',
    '#description' => t(''),
    '#size' => 20,
    '#maxlength' => 20
  );

  $form['street_address'] = array(
    '#title' => t('Street Address'),
    '#type' => 'textfield',
    '#size' => 50,
    '#maxlength' => 100
  );

  $form['county'] = array(
    '#title' => t('County'),
    '#type' => 'textfield',
    '#size' => 20,
    '#maxlength' => 20
  );

  $form['send_message'] = array(
    '#type' => 'checkbox',
    '#title' => t('Notify user of new account via email.'),
    '#description' => 'If left unchecked, a message will not be sent.',
    '#default_value' => 1
  );

  $form['submit'] = array(
    '#value' => 'Submit',
    '#type' => 'submit'
  );
  return $form;
}

function lawyer_register_form_submit($form, &$form_submit) {
  $edit    = array(
    'name' => $form_submit['values']['name'],
    'pass' => user_password(),
    'mail' => $form_submit['values']['mail'],
    'init' => $form_submit['values']['mail'],
    'status' => 1,
    'access' => REQUEST_TIME,
    'fname' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => $form_submit['values']['fname']
        )
      )
    ),
    'street_address' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => $form_submit['values']['street_address']
        )
      )
    ),
    'phone_no' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => $form_submit['values']['phone_no']
        )
      )
    ),
    'county' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => $form_submit['values']['county']
        )
      )
    )
  );
  $to      = $form_submit['values']['mail'];
  $subject = 'New account created';
  $headers = "From: something@somewhere.org\nContent-type: text/html";
  $body    = 'A new user account has been created for you at Something.org.
 Your login details are as follows:
Username: ' . $form_submit['values']['name'] . '
 Password: \'???????\'

 Please login to Lawandmoney.org and change your password.
';
  if ($form_submit['values']['send_message'] == 1) {
    mail($to, $subject, $body, $headers);
  }
  user_save(drupal_anonymous_user(), $edit);
  drupal_set_message("Successfully Register. Please check your Email for login    details.");

}

here I'm creating customized login registration page working properly. Now I want to send password to user via email so what i can write in message body like for username I write Username: '.$form_submit['values']['name'].' So what can I write for password?


texts: How do I add a link to the #title property of a checkbox?

texts:
I created a custom module for Drupal 8.6, and I want to post a link to my terms and conditions.

This is the code I am using.

namespace Drupal\commerce_agree_cgv\Plugin\Commerce\CheckoutPane;

use Drupal\Core\Form\FormStateInterface;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneInterface;
use Drupal\commerce_cart\Controller\CartController;
use Drupal\node\Entity\Node;
use Drupal\Core\Link;
use Drupal\Core\Url;

/**
 * Provides the completion message pane.
 *
 * @CommerceCheckoutPane(
 *   id = "agree_cgv",
 *   label = @Translation("Agree CGV"),
 *   default_step = "review",
 * )
 */
class AgreeCGV extends CheckoutPaneBase implements CheckoutPaneInterface {

  /**
   * {@inheritdoc}
   */
  public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
    $link = Link::createFromRoute($this->t('my terms'), 'entity.node.canonical', ['node' => 1], ['attributes' => ['target' => '_blank']])->toString();
    $pane_form['cgv'] = [
      '#type' => 'checkbox',
      '#default_value' => FALSE,
      '#title' => $this->t('I have read and accept', ['the general terms and conditions of business' => $link]),
      '#required' => TRUE,
      '#weight' => $this->getWeight(),
    ];
    return $pane_form;
  }

}

The link does not work. When I go to my page, the link is missing.

The server runs on PHP 7.2.

How do I display the link?


texts:
In my case I do not care about crawler penalty.

I have multilingual site with menu. I use Path module for URL aliases. The URL aliases are language-specific.

I need to create two menu items with different URL aliases but both links have to render the same content node. I need to do it only for one particular node with known node id, so any hardcoded/hack solution is welcomed.

UPDATE:
I'm just thinking about such hack solution: I can create some new fake node, set the proper url alias and add menu item for this node. When Drupal is about rendering of this fake node then I'd interrupt the rendering in the code and just render the desired known node.

Is it possible? If so, how can I achieve this?


texts: How can I import multiple taxonomy terms using Feeds and the Feeds XML Parser

texts:
Currently the xml feed looks something like this

<hotel>
    <hotel_facilities>
        <facility>Gym</facility>
        <facility>Restaurant</facility>
        <facility>Bar</facility>
    </hotel_facilities>
...
</hotel>

I've trying to import all the facilities as taxonomy terms using the Feeds XPath Parser but I am only able to import a single facility. I'm not sure if the module supports this. What currently happens when I set the context to hotel and the xpath query as hotel_facilities/facility it results in the error:

  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 'Restaurant', 'Bar'' at line 1

If I use the query: hotel_facilities/facility[1] it returns and inputs the term into my taxonomy vocabulary, but I require all the terms to be added.

Is there a query/module or setting that I need to run; or is this a limitation of the Feeds/Feeds XPath Parser parser modules?


texts: We use we-mega-menu. After performing an update the mobile (hamburger) menu changed its alignment to the left as well as some other things I was able to fix the other things but I can't seem to figure out how to align the menu to the right within the container. Any ideas?


texts:
I have a content type courses with course name, instructor, coordinator and ta fields. Instructor and coordinator are of type user_reference.

My data looks like below

course   instructor    coordinator

101       joe           guo

102       joe           larry

103       guo           joe

My course view has filter criteria as below
content access: access and Contextual filter : author ID

When Joe logs in, the display looks like

Courses

101

102

103

I'm trying to figure out how to display only the courses joe is an instructor for. It should not show 103.

Any ideas?


texts: How to resolve my fatal error while trying to migrate an existing site to Platform.sh?

texts:
I am new to Platform.sh and I am trying to migrate an existing site to Platform.sh, using the Platform.sh documentation.
I have successfully imported the code base, the database, and the files. I tried to "Rebuild the site registry" and execute the following command:

$ php ../tmp/registry_rebuild/registry_rebuild.php

But it resulted in an error like so:

web@x6l3bau6sowvu-master--php:~/public$ php
../tmp/registry_rebuild/registry_rebuild.php
DRUPAL_ROOT is /app/public/sites/default/files.
Bootstrapping to DRUPAL_BOOTSTRAP_SESSION
PHP Fatal error:  Call to undefined function db_query() in
/app/public/sites/default/files/includes/cache.inc on line 348
Fatal error: Call to undefined function db_query() in
/app/public/sites/default/files/includes/cache.inc on line 348
web@x6l3bau6sowvu-master--php:~/public$

I do not understand what this means. Can anyone tell me what is wrong, and how can I solve this issue?


texts:
The HTML structure is the following one:

.........

.........

...


texts: Pager extention not working in dynamic database query

texts:
I am trying to create a page which shows all the nodes created by the currently logged in user.  To do this I am using a dynamic query to fetch the relevant nodes.  However, for some reason the pager is not working.  Instead it lists all of the nodes.  I have not been able to work out why this is occurring as I have successfully used pagination previously with other less complex queries.  The following is from the page callback function:

function playground_page() {
  $build = array();

  $build['intro'] = array(
    '#markup' => 'This is a testing ground for Drupal concepts.',
  );

  // Example of table join. Display content created by current user.

  // Construct base query.
  global $user;
  $query = db_select('users', 'u');
  $node_table_alias = $query->join('node', 'n', 'n.uid = u.uid');
  $query
    ->fields($node_table_alias, array('nid'))
    ->condition('u.uid', $user->uid);

  // Add pager and node_access options.
  $query
    ->addTag('node_access')
    ->extend('PagerDefault')
    ->limit(5);

  $nids = $query->execute()->fetchCol();
  $nodes = node_load_multiple($nids);

  foreach ($nodes as $node) {
    $key = 'node_' . $node->nid;
    $build[$key] = node_view($node, 'teaser');
  }

  $pager_args = array('tags' => array('<<', '<', NULL, '>', '>>'));
  $build['pager'] = array(
    '#markup' => theme('pager', $pager_args),
  );

  return $build;
}


texts: How to create structure "Author -> Book -> Quote"?

texts:
I need to create structure [taxonomy_term] Author -> [taxonomy_term] Book -> [node] Quote.
I already have the following structure: [taxonomy_term] "Author name and Book name" -> [node] "Quote". Now I want to split vocabulary "Author name and Book name" into 2 different vocabularies: "Author" and "Book" and link them to each other and to node type "Quote" to get the following hierarchy:

Author [taxonomy_term]

Book [taxonomy_term]

Quote [node]
Quote [node]

Book [taxonomy_term]

Quote [node]
Quote [node]

I can create this hierarchy using Entity reference, but I don't know how to achieve the following.

On node (Quote) creation user should be able to:

choose existing "Author" term and existing "Book" term that belongs to this Author (conditional select);
choose existing "Author" term and create new "Book" term (and link this book to "Author" term);
create new "Author" and "Book" terms (using taxonomy autocomplete widget) and link them to each other.

Is there any way to achieve this using existing Drupal modules?

Please note: I need to use 2 different vocabularies for authors and books. I know that it would be much easier to use 1 vocabulary and parent-child hierarchy of terms, but that is not suitable in my case.


texts:
I want to get all created content of some content type by query. By now I can access nodes by their ID.

$MyNode = \Drupal\node\Entity\Node::load(1)

I tried some query, but none of them worked for me. Maybe wrong conditions. My content type is 'beacons'.

$query = \Drupal::entityQuery('node')

Cant find it in my d8 book too.


texts: #autocomplete_path becomes invalid with % placeholder

texts:
I'm writing an autocomplete-equipped field widget, and obviously, am installing a menu item

$items['MYMODULE/autocomplete'] = array(...)

to handle the search requests. For cleaner javascript code though, I would like to also pass the delta to the request, but as soon as I start fiddling with wildcard placeholders, such as:

$items['MYMODULE/autocomplete/%delta'] = array(...)
$items['MYMODULE/autocomplete/%delta/get'] = array(...)

the field loses the autocomplete functionality. What am I missing?


texts:
I have created some nodes containing Javascript code into body field using Php filter. I also have tried by using Full Html filter. Now when I search through default drupal search then result list also show Javascript code as shown in figure below. But when I visit the node that shows right output rather than Javascript code.

When I use Javascript into Php filter:

When I use Javascript into Full Html filter:


texts: Trouble getting block to display after module enabled

texts:
I've created a drupal module, it's info file, and a tpl.php for the block all in the same module directory.  When I enable the module, I can see the block listed and assign it to a region.  However when I view the page the block does not display.  If I do a vardump on $content within block_view, the dump displays at the top of the page, and firebug shows that block is wrapped with the right div tags.  I would think if you did a var dump on within the block_view function, it should display in the right region.  This one is probably really simple, but it's got me stumped - any help much appreciated.  Also if I title the block just to see if it shows up anywhere in the page - it's still nowhere to be seen even though admin shows it it in the region, and no filters are set to prevent it being viewed.  I would think that if you gave the block a title -if it's on the page it would at least show a title even if everything else is blank.

module file:

function my_block_block_info() {
   $blocks['my_block'] = array(
      'info' => t('My Block')
   );
   return $blocks;
}

function my_block_block_view() {

if(arg(0) == 'node' && is_numeric(arg(1)))  {
    $id = arg(1);
}
   $query = "SELECT * FROM table WHERE id= :id AND deleted=0";
   $args = array(':id' => $id);
   $result = db_query($query,$args)->fetchAll();
   foreach($result as $item) {
     $stuff[] = array($item->stuff_url,$item->stuff_name);
   }
   $content=
      theme_render_template(drupal_get_path('module','my_module').'/'.'block--         my_block.tpl.php',array("stuff" => $stuffs));
   return $content;
   }

 block--my_block_tpl.php

<div class="wrapper">
 <?php

 foreach($stuffs as $thing) {
 for($i=0; $i < count(thing); $i++) {
       //print out result passed from module
  }
  }
 ?>
 </div>


texts: Adding a custom URL to the top of a view based on status of another field

texts:
Okay... so I have this crazy problem. Not really, but I can't figure out how to do it.

I have a view, that lists out a content type "request". When you click on the title, it links to that node (also displayed using a view).

So what I'm trying to do is this:
When on a node whose content type is "request", I need to dynamically create a link that uses the title.

For example, if the Node is http://www.example.com/request/this%20is%20the%20title

Then I'd like a link to appear of this form:
http://www.example.com/survey?request=this%20is%20the%20title

BUT ONLY if that node has a field_type_status of "closed"

Summary:
Dynamically create a link using node's title using a view based on a field's status.


texts: Filter a view with contextual authored date

texts:
I have a Drupal 8 view where I want to sort nodes by authored year using  contextual filters.

So www.mysite.com/2017

will list all nodes from 2017.

I set up the filter using 'Content: Created Year' which takes YYYY format.

But the filter is ignored.

www.mysite.com/2017 returns all years.

What did I miss?


texts: Create a custom front page for anonymous users

texts:
I'm trying to create a custom front page for anonymous users, something like page--front-anonymous.tpl.php.

I could use the page--front.tpl.php template file, and check the role there, but I believe it is possible to create a separate template file for the front page when it is visited from anonymous users.

Any advise?


texts: How to setup "drush @mysite.env ssh" command?

texts:
I am trying to create a custom drush command in which I have to access another remote environment and run some drush commands there. The problem is I am unable to ssh to another environment e.g, "dev" etc.
I am able to run

drush @mysite.env status

but when I try

drush @mysite.env ssh

then I get this error

PTY allocation request failed on channel 0
Command not supported as typed.
An error 255 occurred while running the command `ssh -p 2222 -o AddressFamily inet"

"pantheon.aliases.drushrc.php" is placed in "~/.drush" folder.

Please let me know what's missing.

Thanks


texts: Fetch product data from commerce order on rules check-out completention

texts:
This is the scenario :

Designing a automation website, user buys a product of type "EditOption", an EditOption consist of an editor and a task. When a user buy one of these products a new content of type "Project" should be created automatically, containing Editor and the task which must be assigned to him/her. So what I want is to fetch EditOption's Data from commerce order so these can be used later creating the new content.

I'm looking for a solution based on rules events.

The problem I faced is I can't get through commerce-line-items to fetch it's data. this is the result I get :


texts: updating database fields of custom entity

texts:
I have updated my site to drupal 8.4.  Has installFieldStorageDefinition() changed in 8.4? Previously code such as below successfully added an entity reference field to my custom entity database table.

  $storage_definition = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Evaluation'))
    ->setDescription(t('The Evaluation the team evaluates'))
    ->setRevisionable(TRUE)
    ->setSetting('target_type', 'evaluation')
    ->setSetting('handler', 'default')
    ->setDisplayOptions('view', array(
      'label' => 'inline',
      'type' => 'entity_reference_label',
      'weight' => -10,
    ))
    ->setDisplayOptions('form', array(
      'type' => 'options_select',
      'weight' => -10,
    ))
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE);

  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('eval_id', 'project_team', 'team', $storage_definition);

Is there a change that should be  made?  Thanks.


texts: how to only 30% payment of order total payment in ubercart in drupal 7?

texts: I am using ubercart module in my site. I need to pay only 30% of order total not fully payment at the time of checkout. For this I am using uc_downpayment module . But I am not getting any option for such type of functionality.


texts: "It is not safe to rely on the system's timezone settings."

texts:
I'm finding the following error in the Recent log messages report:

  Warning: DateTime::createFromFormat(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Symfony\Component\HttpFoundation\Response->sendHeaders() (line 331 of /var/www/drupal/drupal-8.1.1/vendor/symfony/http-foundation/Response.php).

My site does include any custom module, but as far as I can see, the only date function it calls is time(). Shouldn't Drupal handle the timezone setting?

Is there any way I can isolate where this function is getting called from?

It's not a major problem, but I'd prefer to minimise unnecessary warnings in my log.


texts: Migrate users from a custom application DB into Drupal

texts:
Is there a way (kind of best practice or tool) to import Users from a custom CMS into Drupal (with of course the all fields already set)?
I think a JSON object with my all Users' data is the only way.
Passwords are actually strings encrypted in md5 so all passwords should be regenerated by the Users (that's not a big problem).
Someone suggested JSONdata.com but the URL is not reachable.

Thanks in advance for all welcome suggestions/remarks.


texts:
How do you add the 'Edit View' Links in the gear icon that appears when you hover the mouse over a block. I can see "Configure Block" but I want also "Edit View" option.
I know these icons are the output from the Contextual links module that comes with Drupal core so I'm not sure how to merge the two to be used on 1 block.


texts: How do I create a file object from a local file?

texts:
I am trying to attach a file in the custom module's directory to every new node created for a content type. How do I create the file object? The following code gives me an error.

$uri1  = file_unmanaged_copy('checklist1.pdf', 'public://checklist1.pdf', FILE_EXISTS_REPLACE);

$file1 = File::Create([
    'uri' => $uri1,
]);
$file1->save();

The error I get is the following one:

  The specified file checklist1.pdf could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.

To add, this code is in the module file inside a hook.


texts: Change Pager-ItemsPerPage over URL argument

texts:
I use Views to get Nodes in JSON format via REST service. I can switch the pages with;

http://myside/?q=my/path&page=1

but I want to change the limit of one page like;

http://myside/?q=my/path&limit=100.

Has anybody a good solution or one alternative.


texts: Drupal Commerce Product SKU pane not showing after upgrade

texts:
After performing an upgrade of a Drupal 7 site (core and modules), including Drupal Commerce, the Product SKU pane is not showing up on my panels page.  I'm able to add it to my panels page and there are SKU's for the product.

Why is this happening?


texts: How to add default text that clears on focus to a form in Drupal?

texts:
I would like to display a default text in a field of a views filter form. That default text would then be hidden "on focus", and would re-appear "on blur".
So far I have tried to follow the instructions given here:
How to add default text that clears on focus with jQuery to a search form text field in Drupal
but with no success.

What I did:

1. Downloaded the Jquery files (https://github.com/mudge/jquery_example/downloads), and copied them in my /sites/all/libraries/mudge-jquery directory

2. Added a helper.js file into that directory with that code

(function ($) {
  Drupal.behaviors.helper =  {
    attach: function(context, settings) {
      $('input#edit-title.form-text.beautytips-module-processed.bt-active').example('TEXT TO HELP');
    }
  };
})(jQuery);

3. Created a simple module with that code:

function helper_preprocess_page (&$vars) {
  // Let's add some js to page for the search box.
  $path = drupal_get_path('module', 'helper');
  drupal_add_js($path . '/sites/all/libraries/mudge-jquery/jquery.example.min.js');
  drupal_add_js($path . '/sites/all/libraries/mudge-jquery/helper.js');
}

Still nothing is displayed in my "input#edit-title.form-text.beautytips-module-processed.bt-active" field. What am I doing wrong here?


texts: Unable to update header value using hook_views_pre_render?

texts:
I have create the header value using Global: Unfiltered text (Global: Unfiltered text) .

BY us hook_views_pre_render i want to update the header value . How can I update the header value .

How to update header text in hook_views_pre_render provide the solution for the header value to update but its not working for me

    function mytheme_views_pre_render(ViewExecutable $view) {

      if ($view->id() == 'works') {
//    enter code here
             $my_value='No result found';
             $view->display['page']->handler->handlers['header']
             ['area_1']->options['content'] = $my_values;

        }

      }
    }


texts: Add text message under "Add new comment" title

texts:
I would like to add a disclaimer message under "Add new comment" title and above the form in drupal 8 site. I changed the help text on this path /admin/structure/types/manage/article/fields/node.article.comment but nothing changed.
Any suggestions please?


texts: How to set permissions to a particular role?

texts:
I want to create an IT role. Superadmin should only create this IT role and enable or disable the permission for this role anytime (which roles this Superadmin can assign to the users), if this admin wishes to. IT role should not be permitted edit any of the users.

The Superadmin will decide which roles an IT person (IT role) can assign to users. Users with role IT role can not assign the roles above their position, this is a simple funda. For example, such users (with the IT role) cannot assign Admin role.

Superadmin designed the IT role in such a way that he can assign Forum Admin, Writer and Writer Admin. Hence, he can assign these roles he wish to.

Permissions to setup for IT roles:

Such user can create a users.
Such user can block or activate the users.
Such user can assign the existing roles to the users he wants and can revoke it.
Such user cannot delete.