texts: Call to undefined function libraries_load()

texts:
I am writing a custom module for commerce shipping and want to use the shipping company's web service code in my module.  My thinking is to include it as a library using the Libraries module. I use hook_libraries_info() to define the library but when I want to load it later on using the libraries_load() function I get the error message.  I'm using colorbox that is dependent on Libraries and that is working fine.  I have also made my module dependent on the Libraries module in mymodule.info.  What am I doing wrong?  Why is my custom module not able to use a function in the Libraries module?

Also, my module is an exact copy of commerce_shipping_example but it includes the hook mentioned above.  The code that I've tried:

libraries_load('commerce_shipping_mds', $variant);
libraries_load('commerce_shipping_mds');

and

if (module_exists('libraries')) {
  libraries_load('commerce_shipping_mds', $variant);
}

I've seen this question asked many times and almost all the answers has got something to do with the Libraries version.  I have tried all the available versions and still get the same error in apache2/error.log.

All of the code (except for libraries, off course) is in my commerce_shipping_mds.module file. The currently installed Libraries version is 7.x-2.2+5-dev and I see the schema version in the system table  for sites/all/modules/libraries/libraries.module is 7200.  I also see there is another entry in there sites/all/modules/libraries/tests/modules/libraries_test_module/libraries_test_module.module and the .info says :  This is an example info file of a library used for testing purposes.  Am I supposed to have an entry like this for my library?

Here is my hook_libraries_info():

function commerce_shipping_mds_libraries_info() {
  $libraries['commerce_shipping_mds'] = array(
    'name' => 'MDS library',
    'vendor url' => 'http://collivery.co.za',
    'download url' => 'http://collivery.co.za',
    'files' => array(
      'php' => array(
        'Cache.php',
        'Collivery.php'
      )
    ),
  );
  return $libraries;
}

Thanks for the help.

Forgot to add - I'm trying the libraries_load() function later in the .module file.

Drush libraries-list gives the following output:

Name                   Status        Version  Variants          Dependencies
commerce_shipping_mds  Not detected  -        -                 -
colorbox               OK            1.5.14   minified, source  -


texts: How to get rid of message “Leave site? Changes that you made may not be saved”?

texts:
I have a site which are using 2 themes : adminimal and a custom made.
When submitting a form in adminimal no message appears. In the custom theme based on bootstrap it does. The message is:

“Leave site? Changes that you made may not be saved”

We would like to get rid of it.

It is a thing in Javascript/jquiry.  So when I scan alle code in the custom theme no string is found on this error.. ?!?

It there an option within drupal to disable this check? Within the bootstrap options on
/admin/appearance/settings/default
there are a lot but I do not understand what option I can/should be use.


texts:
I'm working on my drupal website.

I need that Manager(a custom user role) and Publisher(a custom use role) can upload documents (a custom content type) and until here it's all ok.

Then i need also that for example there is:

user A that is a manager

user B is a publisher

user C is publisher

I want assign the possibility for A to see the documents uploaded by B, but not C documents.

How i can do it ?

Thank You.


texts:
I'm trying to apply a button class to the {{ link }} attribute in code below.

<a class="usa-button"{{ link }}

It displays correctly however the markup is not correct. I see an extra <a="" tag.

<a class="usa-button" Image styles for grid view_3.docx

Any ideas on how to apply class cleanly?


texts: How can I get the taxonomy tree by the vocabulary ID?

texts:
I want load all the taxonomy terms by their vocabulary ID in Drupal 8. In Drupal 7, I would use the following code.

$terms = taxonomy_get_tree($vid);

What code should I use in Drupal 8?


texts:
I use user_save() to create a new user in a custom module. If the function returns TRUE, is it possible to auto login the user?

EDIT

I've done some more searching and found the user_authenticate()

This is the code I have so far:

$user_info = array(
  'name' => $sessdata['username'],
  'pass' => user_password(),
  'mail' => $sessdata['username'],
  'init' => $sessdata['username'],
  'status' => 1,
  'roles' => array(DRUPAL_AUTHENTICATED_RID => TRUE),
                    'access' => time(),
                    );
  $save = user_save($account,$user_info);

  if($save) {
    $loggedin = user_authenticate($save->name, $save->pass);

    if($loggedin) {
      echo "logged in";
    } else {
      echo "damn";
    }
  }

Well it saves the user but it doesn't logins him.


texts:
How can I access fields values inside profile2 main profile? Only on edit main profile page? I try to hide a field on profile2 edit page based on another value. Code is from my template.php

function my_theme_form_profile2_edit_main_form_alter

and then calling

global $user;
$profile = profile2_load_by_user($user->uid, 'main');
$checkbox1 = $profile->field_checkbox_admin1['und'][0]['value'];

The problem is that profile variable is not accessible if all of the fields in profile are empty. dpm($profile) shows nothing and I get undefined variable error.


texts:
I just created the webform and added fields.

I need to create a Webform Submission Using Rest API POST method. I just installed Rest & Rest UI modules for this.

But when I try to test my API using API tester its showing the error like this :

{"message":"Could not determine entity type bundle: \u0022webform_id\u0022 field is missing."}

But I have already determined the webform_id and here is my configuration

POST URL : http://example.com/entity/webform_submission?_format=json

Headers :

Content-Type : application/json

POST Data :

{
  "type": {
      "webform_id": "my_form"
    },
"your_mobile":[{"value":"123456789"}],
"your_name":[{"value":"Test"}],
"your_email":[{"value":"test@gmail.com"}]
}

Drupal Version : 8.6.4
Webform Module version : 8.x-5.1

Can anyone let me know Why its not working?


texts:
I was installing the panels module when all of a sudden my site went to white screen of death with a whole bunch of error messages. (Check this out here: http://graphbyte.co/fuck.png ).

Right before I tried to install panels I had abandoned the process of creating a custom page. I realized I hadn't enabled the panels module, which I needed for this custom page, so I jumped into the modules page and attempted to install it.

I tried deactivating the panel module directly from the database but that had no impact on the situation.

What can I do??? Please helllllp!!

Thanks,

G


texts:
I'd like to be able to intercept calls to files (.pdf for instance) in order to run some custom code before the user accesses/downloads the file, and add a cover page accordingly.

From what I understand this can't be done by Drupal alone, and requires some server-side configurations as well. Could anyone guide me towards a solution and/or the hook to intercept file downloads? (hook_file_download seems appropriate on the first glance)


texts: Unable to render title field on node template

texts:
For my content type - Article I have a template

node--article.tpl.php

I currently render other fields such as the body text just fine. However the title cannot be displayed.
I'm using

print render($content['title']);
print render($content['body']);

But only the title is displayed. To make sure I'm using the right machine name, I looked at the content type configuration.

Is there something missing? Or is there something special I have to do to to the 'title' field?


texts: I would like to split up the fields in the 'create new content' screen into sections

texts: I have a content type with about thirty different fields.  I would like to group them by category and I would also like to split them up so that half of the fields are filled in at the time of creation and the rest are filled in later (as a two-part work flow.)  There is a strong possibility that access to the two field groups will require two different roles.  Is there a good module that can do this?


texts: "Limit list to selected" and default to all selected?

texts:
When I set up an exposed filter with the "Limit list to selected items" option enabled, and select a subset of items in the "Options" list, when the view is presented, non of the selected items are selected by default.

If I turn off the "Limit..." option, then all items (checked and not) are shown, with the checked items selected by default.

Sorry if I'm not describing it more clearly, but I would like a limited list displayed, with all of its items selected by default.

Suggestions?

BTW - I'm using Better Exposed Filters to display the selection items as checkboxes and the exposed form is shown in a block.

Thanks.
Bill


texts: Where is the node created timestamp stored in the database?

texts:
I need to create an SQL query that finds all nodes of a certain type created X days ago, so I can get their IDs. Due to the massive number of nodes in the database, I would prefer to use a direct SQL query, rather than entityQuery. I was warned entityQuery can be slow if working with large volumes of data.

Anyway, I need to find where is the node created timestamp stored in the database. In Drupal 7, it is stored directly in the node table, but not in Drupal 8.


texts: If one block has content do not show other block

texts:
I have a region in my page.tpl.php file called "seminars", and it has two blocks (views) assigned to it, one is called "view_upcoming_seminar" and the other is called "testimonials". The content shows up great for both blocks (views) in the region. What I'd like to do is only show "testimonials" if there is no content in "view_upcoming_seminar".

I'm just not sure what the best approach is, and any pointers in the right directions would be grand!


texts:
On my website, I have used the Taxonomy to created different sections. Each section has its own "contact us" page. I want to create a variable that will create a path to the relevant contact page. That way I can print the variable in taxonomy-term.tpl.php, node.tpl.php and page.tpl.php files to print the path dynamically.

How can I test for the taxonomy, and then change the value of the variable accordingly?

I've looked around for an answer and the closest I could find was How to move custom code into template.php. However, it requires a taxonomy reference field to present to perform the test and so wont work on the main taxonomy index pages (which cannot have taxonomy field references).

EDIT: Please note: The contact us page is just a normal node with telephone numbers on it. It is not the Drupal contact us form.


texts: with gettranslation how doI get the user of the most recent revision

texts:
I am using $node->getTranslation('language') to get all of the information in the translation object.

I want to know how I can get the user id of the most RECENT revision of this translation.

I can get the title and the fields like this below but don't know how to get the creator of the most recent revision:
          $translation = $node->getTranslation($translang);
      $title = $translation->title->value ;
       $audience = $translation->get('field_pup_audience')->target_id;


texts: How to display the field in a joined table with hook_views_data()

texts:
I am trying to figure out how to display a field in a joined table, but documentation isn't that great or obvious.

I have my base custom table with a tid field that ties to the taxonomy_term_data table.  I want to display the term name, based upon my tid field.  How to I specify that name field for display in my view?


texts: D7, Sorting / Grouping (Views Relationships with Entity Reference fields)

texts:
I am rendering Name Tags for thousands of content nodes in one content type called “Cadet.”
Each of these "Cadet" nodes specifies a single "Attendee" for an upcoming event.

The situation:

Some attendees also need name tags printed out for their “friends” who are attending "with them."
That is no problem—these “friends” obviously need their own node with the same fields to get their own name tag, so I distinguish that they are a “Friend of an Attendee” with a simple checkbox.
To link them to the Cadet nodes they are attending with, I used an Entity Reference field.

The sorting order / grouping problem:

When rendering the view, I need these “friends of attendees” to appear “right after” the attendee they are going with.

The final question:

Using relationships, how could I get the Views module to sort the friends of attendees "right after" the attendee they are going with? There seems to be a need for "grouping" in this relationship, but after three days of trial and error, I cannot figure it out.

I am technically using the Views PDF module, but it has the basic Views functions, so if it's possible with Views, it will probably be possible with this module.

In this link, I've provided my settings in a compiled high resolution image with explanations on what I have done so far. If anyone would be able to direct me on the right path, I would appreciate it very much!

Thanks!


texts: "Drupal calls should be avoided in classes, use dependency injection instead"

texts:
In my module using below code for getting url alias of given url:

$alias = \Drupal::service('path.alias_manager')->getPathByAlias($_POST['url']);

But one I run Automated Review(http://pareview.sh/) in my module I am getting below warning:

  16 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead

How can I update above code using dependency injection? My entire class code is given below.

<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
 * MyModule Class defines ajax callback function.
 */
class MyModule extends ControllerBase {
/**
 * Callback function for ajax request.
 */

  public function getUserContent() {
    $alias = \Drupal::service('path.alias_manager')->getPathByAlias($_POST['url']);
    $alias = explode('/', $alias);
    $my_module_views = views_embed_view('my_module', 'default', $alias[2]);
    $my_module= drupal_render($my_module_views);
    return array(
      '#name' => 'my_module_content',
      '#markup' => '
' . $my_module. '
',
    );
  }

}


texts: Returning the form in form_alter function

texts:
I have a doubt that is, can i use return $form; in hook_form_alter function. When i used some callback function inside the form, its not calling to that particular function. Thatsy i confused whether the form is returning or not.
i tried this thing but its not calling to custom_form_reset function

function cap_academy_contactus_form_alter(&$form, &$form_state, $form_id) {
       if ($form_id == 'webform_client_form_860'){
        $form['actions']['reset'] = array(
          '#type' => 'submit',
          '#value' => t('Reset fields'),
          '#submit' => array('contact_form_reset'),
          '#prefix' => '
',
                '#suffix' => '
'
        );
        return $form;
      }
    }

    function contact_form_reset($form, &$form_state){
      $form_state['rebuild'] = FALSE;
    }


texts: form_validate work with ff, not with chrome using jQuery trigger click

texts:
I have create a form with form_validate and form_submit functions.

Using Firefox, everything is OK so the problem is not about an error in functions names.

Using Chrome, when I click on submit the page is just reloaded. I have added to my code drupal_debug to track the process into validate function and submit function. System not going into these functions.

I have no ideas about how form_validate function could be linked with choice of browser.

UPDATE : I have found more details about the cause of the problem :

To submit the form, user not click on the submit button directly. He have to click on an other button which launch js function.

At the end of the js function, I use jQuery( "#edit-continue" ).trigger( 'click' ) to simulate click on the real submit button.

I have tried to click directly on the real submit button and it is working but with trigger I see the ajax GIF of drupal but there is no passage to my form_validate function.

So, I really need to know how drupal can make the difference between a real click and an emulated one. And the most important how can I do to fix or skirt this problem.


texts:
I am building a site in Drupal 8, where users can add training programs. An example of such a program could look something like this:

The way I see it, I will need 3 node types:
Node type 1: Program (with a Set entity reference)
Node type 2: Set (with a Exercise entity reference)
Node type 3: Exercise

When adding a Program node-type, it can have multiple Set entity references. When adding a Set, - it will need a Exercise entity reference.

But how to ensure a smooth "Program" adding routine? So when adding a set to a program, the user will be sent back to the program after creating the needed Set-node.

I hope my description makes sense. Any ideas?


texts:
I have a drop down menu of a few items( Drupal 7) and I have assigned them some weights in order to show them in a particular order on the page.
When I save the changes , clear the cache and reload the page , the items don't move and stay in the same order .
Can anyone help ??


texts: Why do we duplicate field data in the field_revision_* tables when revisions are disabled?

texts:
Even with revisions turned off for a given content type, the field_revision_* tables for the fields each contain a single record that matches the corresponding record in the corresponding field_data_* table.

I've always been aware of this, and previously, I've never had a reason to question it. However, now I am dealing with an extremely large database, and almost 50% of the database size is made up of this duplicated data in the revisions tables.

Why do we duplicate all the field data in the revision tables when revisions are disabled for a content type?


texts: Drush remote with switching shell users (sudo)

texts:
Problem: I have a remote server with SSH access where the Drupal site can only be accessed as another user (www-data). My own shell user is not able to use drush directly for security reasons.

So how can I run all drush remote commands as www-data? I have sudo priviledged to execute commands as root.

My aliases.drushrc.php:

<?php

$aliases['accounting-phd'] = array(
  'root' => '/var/www/example/docroot',
  'uri' => 'example.com',
  'remote-host' => 'server.example.com',
  'ssh-options' => '-t',
  'path-aliases' => array(
    '%drush-script' => '/home/klausi/drush-remote.sh',
  ),
);

And in drush-remote.sh on the server:

#!/bin/bash
sudo su www-data -c "drush $@"

This prompts me for my password successfully, but then fails with

su: unrecognized option '--root=/var/www/example/docroot'
Usage: su [options] [LOGIN]

How can I separate the options from the su command?


texts: How to add multiple field groups to a node

texts:
I have a node type "Project", and users can add multiple tasks for this Project node. e.g. There is a Project named "Building website", it contains two tasks "Design" and "Code", and every Task has another two fields: time and budget.

The Field Group module can solve part of the problem, it can mix multiple fields into one field. But this mixed field amount can only be 1. That means I can only add one Task field in a Project, however I need add unlimited Task field to Project. Do you know any modules can do this job?


texts: Regions do not display in "Demonstrate block regions"

texts:
I wonder why some regions of my theme don't display in section 'Demonstrate block rerions'.
This happens with some themes which I downloaded from Drupal.org, for example with the Software theme.
Here is part of its 'info' file (showing multiple regions):

And this is what 'Demonstrate block rerions' for this theme looks like:

My question: What could be causing this?
I use SEVEN as admin theme. On page admin/structure/block I see the link  "Demonstrate block regions (Software Responsive Theme)" and all regions that defined in .info file. But when I click this link, I see ONLY SOME OF IT BUT NOT ALL .
I try to change admin theme, but it is not help.
Maybe problem in this particular theme?


texts: Get Drupal views field values as html radio buttons

texts: I am having a view page created for a node type. It is out putting the content in the page. In that there  is a field called options with multiple values per node. I want it to be outputted in the form of html options/radio button. Is there any way to do it?


texts: Embedding Javascript in Content or Block Causes Misalignment of Regions / Overflow

texts:
When embedding Javascript, the content area seems to "overflow" past its container. I am pasting an example of how embedding Tweets can cause this problem. The content shouldn't be extending into the dark green area.

I am new to Drupal, but have basic web programming experience. Should I be looking at CSS rules for this? Could it be a quirk with a theme setting? Many thanks for any leads!

For reference, right now Tweets are being embedded by pasting this code block into the content (with Full HTML enabled):

TEXT & SUCH FROM TWITTER

Note that I intentionally pasted the same tweet twice so that it would better illustrate the problem.

Edit: Interestingly, the problem seems to resolve itself if I press "alt" while in Chrome or Firefox. The page seems to re-render slightly, filling in white space on the right. Perhaps this is because CSS is usually executed before JavaScript when rendering pages? I noticed this after bring up the inspector tool, which seemed to fix the problem.


texts: Where does Drupal store its url/domain name?

texts: I created a site using an IP address and imported a live site on another server, then I made the domain name live on the new server created with the IP address.  Since then I get permissions error for the admin when logged into the domain name/ url.  However if the same admin logs in using the IP address, I can see the broken links report. Otherwise it says I don't have permissions.    I'm trying to reset the root domain url but uncommenting it in the settings file doesn't fix the permissions issue. I think it is something deep in the DB


texts: How can I make Plupload in D7 start uploading automatically?

texts:
I'm using the Plupload integration module and the problem is that once the users select the files, they think that they have already uploaded the files. No matter how obvious, bold and huge you make that "Start upload" button, most of them just ignore it. Plus it is not a good user experience.

What I need is for the "Start upload" button to disappear and the upload of the files into Plupload should begin automatically as soon as the files are selected. Would someone be kind enough to suggest how can this be done?


texts:
When a user registers in my site, the registration form asks the user on which type of food he likes, the user choses one or more from a taxonomy terms.

A user can also create content and tag them from the same taxonomy terms on the registration from.

Now I want to create a view that gets all food "content" the user likes based on what he chose in the registration form or profile.


texts: How do I programatically create a context?

texts: I'm using the migrate module to move content into a Drupal site. Some of this content needs to be created as blocks and added to a region using contexts. I have the creation of blocks (actually, boxes) working using a purpose-built module, but I don't know where to begin on the context side of things - looking for something like add_block_to_context() but I cannot find anything. Any ideas?


texts: How do I handle multiple arguments with `hook_drush_command()`?

texts: I have to implement a drush command with multiple arguments. How should I handle them  in hook_drush_command()?


texts: How to add auto generate password link for admin?

texts:
I am using Drupal 7 for my website.
I have two roles administrator and IT.
I want to add auto generate password link at the time change the password by superadmin or IT role and also send the mail to respective user.

Please help how to add this functionality in my site.


texts: Taxonomy i18n does not translate term name in a term page

texts:
I set option Localized in my Vocabulary "Categories" and translated all the terms in english French and german some of them. The default language is russian.
Term page title has russian name: http://tlito.ru/en/categories/debugging in all the languages. I've made html-document title in need language using Page Title module. But the page title rest russian.
Please what is this bug?


texts: token_filter module: [node:nid] for custom block?

texts:
Drupal: 8.1.7

Module: token_filter 8.x-1.0-beta1

I have a custom block with a Text format that has Global and entity tokens are replaced with their values enabled.

The custom block has this value:

current-page:url:unaliased :          [current-page:url:unaliased]

current-page:url:unaliased:absolute : [current-page:url:unaliased:absolute]

current-page:url:unaliased:args :     [current-page:url:unaliased:args]

current-page:url:unaliased:brief :    [current-page:url:unaliased:brief]

current-page:url:unaliased:path :     [current-page:url:unaliased:path]

current-page:url:unaliased:relative : [current-page:url:unaliased:relative]

that will render as:

current-page:url:unaliased : http://www.example.com/node/1657
current-page:url:unaliased:absolute : http://www.example.com/node/1657
current-page:url:unaliased:args : , node, 1657
current-page:url:unaliased:brief : www.example.com/node/1657
current-page:url:unaliased:path : /node/1657
current-page:url:unaliased:relative : /node/1657

I am attempting to get the Content Id (e.g. [node:nid]) from the page, but that token is not available.

Workaround using Inline Javascript:

Node Id:

which will render as:

Node Id: 1657

I tried the following:

current-page:url:unaliased:args:node : [current-page:url:unaliased:args:node]
current-page:url:unaliased:args:0 : [current-page:url:unaliased:args:1]
current-page:url:unaliased:args:1 : [current-page:url:unaliased:args:1]
current-page:url:unaliased:value:node : [current-page:url:unaliased:value:0]
current-page:url:unaliased:value:0 : [current-page:url:unaliased:value:0]
current-page:url:unaliased:value:1 : [current-page:url:unaliased:value:1]

Without modifying the module how would I get [node:nid] from within a Custom block?


texts: How to avoid caching of fields in Entity View?

texts:
I have a few computed fields on my entity and they have dynamic values. These values cannot be cached because they change often.

I've created the necessary field formatter that uses the same approach that the comment module uses to display the uncached comment form by using the #post_cache_render callback.

This I found does not always work(the value is sometimes displayed in one view mode but not in another).

The other issue I have is that if the value is empty, the field label is still visible because it is not part of the formatter and therefore it is cached with the rest of the Entity View data.

So my question is: how can I use fields with dynamic values so they won't get cached in the Entity View?

I've also tried all hooks that allow adding or changing data in the Entity View but every single one get's cached and so I found it impossible to avoid the cache.


texts: How to save a free text views query entered into an exposed filter by the user?

texts: I would like to save the entered exposed filter text by the user possibly into its own content type. Would I have to look at the url path for this via $_GET vars?


texts:
I made a view which works fine in the page view, but clicking on the feed icon or going directly to the path for the feed gives a  http 500 internal server error on IE 11.

And on firefox it simply has a blank white page.

Why arent the feeds working?


texts:
I've been looking for some official guidelines on how to format long strings in module code, but the closest thing I've found is an ambiguous section on indenting long SQL queries which suggests any of the following styles:

$text = '
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ligula odio,
  hendrerit consectetur porta vitae, sollicitudin sit amet eros. Integer
  hendrerit varius felis id dignissim.
';

$text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ligula'
. 'odio, hendrerit consectetur porta vitae, sollicitudin sit amet eros. Integer'
. 'hendrerit varius felis id dignissim.'
;

$text = <<<TEXT
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ligula odio,
  hendrerit consectetur porta vitae, sollicitudin sit amet eros. Integer
  hendrerit varius felis id dignissim.
TEXT;

The Drupal Coding Standards talk about how to use the concatenation assignment operator:

$string .= 'Foo';
$string .= $bar;
$string .= baz();

but they don't actually state whether single long strings should be broken up that way.

To add further confusion, the Coder module handles long strings differently again in its "good.php" test file:

$text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ' .
        'ligula odio, hendrerit consectetur porta vitae, sollicitudin sit ' .
        'amet eros. Integer hendrerit varius felis id dignissim.';

Personally, I've just been doing it like this until now:

$text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ligula
        odio, hendrerit consectetur porta vitae, sollicitudin sit amet eros.
        Integer hendrerit varius felis id dignissim.';

However, I'd like to start doing it the "right" way (if there is one). Does anyone have a definitive answer?


texts: How to get the custom class added to a view

texts:
Views let people to add custom css class to a display. I'm looking to get this information and add to the body tag.

I try with this two functions and the dpm() function from devel:

views_get_view('name');
views_get_page_view();

But I'm not able to find the custom class that I add to the view.

Do you have any idea how to get this information?


texts: Drupal + Moodle SingleSignOn logout issues

texts:
Does anyone know how to set cookie_domain to use an IP-Address and not a domain name?

I recently put together a SSO solution between Drupal and Moodle. Drupal is acting as the users repository with Moodle as a subdirectory.

To get the sso working I'm using the moodle-sso module to good effect.

The only problem is that logging out of moodle does not log a user out of drupal.

After much googling, I found articles indicating cookies are the key to solving this problem.

I attempted following moodle-sso cookie_domain instructions but then I can't log into my site anymore because I access my dev site via IP address and not a domain name.

I set cookie_domain as follows: $cookie_domain = 'http://128.79.128.44/drupal-site';

The project structure is http://128.79.128.44/drupal-site/moodle.

Any help is appreciated.

UPDATE:

I added the following data to my /etc/hosts file on my Linode server:

128.79.128.44/drupal-site/ dev.drupalsite.com.

When I visit dev.drupalsite.com I receive the following error:

Forbidden

You don't have permission to access / on this server.

Clearly, dev.drupalsite.com is not a globally recognised URL but how do I use it to access my website on a LIVE Linode server?


texts: Modify the node title with the node ID before saving it

texts:
I need to modify the node title while saving the node ID. I implemented hook_form_FORM_ID_alter() as follows.
/**
 * Implements hook_form_FORM_ID_alter()
 */
function module_name_form_form_id_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['title']['#access'] = FALSE;
  $form['#entity_builders'][] = 'change_node_title';
}

function change_node_title($entity_type, NodeInterface $node, $form, FormStateInterface $form_state) {
  $node_id = $node->nid->value; // Not getting the node details
  $node->setTitle('Custom Title -' . $node_id);
}

The node details aren't found from the #entity_builders callback.
How can modify the node title before saving it? I don't want to use any custom modules for this. I don't want to use hook_node_presave() either, as it would affect the cloned nodes.


texts: Select selection exposed filter using XML Views Backend

texts:
I'm using the Views XML Backend to pull in data from a URL.

I'd like the user to be able to optionally be able to select a value for a single field and display the record for that selection. For example, if the XML had information for different offices, I'd like to show the user the records for all of the offices, but allow them to pick a specific office from the list to see only the record for that office. The URL can take a query string or POST parameter with the search terms, but I'm fine with letting the search be done by Drupal.

How do I achieve this in a way that leverages Drupal's capabilities, as opposed to doing the filtering in jQuery?

I already have the view created, but I only see exposed filter options I saw were XML: Numeric, XML: Text, and Global: Combine fields filter.  What I'm looking for is something like XML: Pick a Value.


texts: Feeds SQL Import shows data in preview but fails to import

texts:
I have a problem on a client site with a Feeds import that shows the correct data within the import preview but does not copy the data across to the assigned field during the import.

There are 18 columns being exported from a MySQL database, all mapped to fields within a single Product content type. Running the export 'manually' by generating an SQL to CSV file export and then uploading the CSV file to the default feeds CSV parser works a charm, no problems.

The client wants it run regularly from their product database though; so I have been trying to achieve this using either the Feeds SQL or Feeds Database parsers. Both produce the same result.

When importing with either of the direct database parsers then there are only 6 of the 18 fields that actually copy across the data. There is nothing special about any of the fields, most are text, some are decimals for prices with a few taxonomy fields also.

When viewing the data with the fetcher preview for the SQL query then the correct data is displayed.

If however the import is viewed using the Feeds Preview module then some of the data is missing. Some of the data that IS shown on the Feeds Preview does not actually make it through the final import either, there is only data displayed for 9 fields in this preview. The full import only ever pulls in 6 of these fields.

There are no errors shown in the logs for any of these import fails.

Debugging Feeds isn't the easiest task but by using Feeds Debug Tamper I can see that when dealing with certain fields, their content is missing, even though it was present during the last import read, as can be seen here:

The 'Artikel_FK' value is contained within the initial import string, but in the next import read pass then the same field is now shown as blank. This only happens on the import read for that piece of data, then it is hidden, and on subsequent reads it remains hidden.

This is happening with all of the missing items, they are present in the fetcher preview, but do not show in the preview generated by Feeds preview.

As far as I understand, the Feeds debug output is before the data is parsed, so I need to find a way of tracing at what stage that data was read and why it is showing as blank.

The client database I am importing from has been problematic for so long now anyway, using Windows-1252 encoding with a Latin1_German1_CI collation on the database I have had to previously use Feeds Tamper to convert some field data to UTF-8, HTML entities conversions for German characters, trim whitespace and perform a few search-replace on certain mis-spelled strings.

To remove any of these possibly being the culprit I have taken a copy of the database and moved onto a development server and converted all of the tables and columns to UTF-8 with a UTF-8_unicode collation. I have also added to the initial SQL fetcher script calls to convert the read data as utf8. Hopefully I have removed any 'incompatible' data formats, but the errors still persist.

The condition of the missing data is the same if I clone the importer and remove all of the Feeds Tamper plugins, so again that has no affect.

Any help, pointers or tips on further Feeds/Import debugging would be appreciated.

cheers all :)


texts: how to validate email id is already register or not

texts:
function lawyer_register_form_submit($form,&$form_state)
{
$mail = $form_state['values']['mail'];
$new_password = user_password();
$edit = array(
  'name' => $form_state['values']['name'],
  'pass' => $new_password,
  'mail' => $mail,
  'init' => $mail,
  'status' => 1,
  'access' => REQUEST_TIME,
  );
  if(!db_query("SELECT COUNT(*) FROM {users} WHERE mail = :mail;", array(':mail' =>  $mail))->fetchField())
  {
  $to = $form_state['values']['mail'];
  $subject = 'Lawandmoney New account created';
  $headers = "From: admin@lawandmoney.info\nContent-type: text/html";
  $body = 'A new user account has been created for you at us.lawandmoney.info.
 Your login details are as  follows:
Username: '.$form_state['values']['name'].'
 Password:  '.$new_password.'

 Please login to us.lawandmoney.org and change your password.
';
     user_save(drupal_anonymous_user(), $edit);
     if($form_state['values']['send_message'] == 1)
     {
     mail($to,$subject,$body,$headers);
     drupal_set_message("Sussessful register.Please check your Email for login   deatils.");
     }
     else
     {
     drupal_set_message("mail not send.");
     }
     }
     else
     {
     drupal_set_message("You are already register.");
     }

we created a custom user registration form.now we have to checked if user is already register then its give error like You are already register, data will not inserted into database and mail not send to user.


texts:
I'd like to convert the instructions from this answer into a general script that can be reused across projects.

I'm wondering how these commands can be written in Drupal 7 PDO format:

UPDATE `system` SET filename = replace(filename, 'sites/all/modules/contrib', 'profiles/distroname/modules/contrib');

Is the mysql replace function something generic to all SQL, or is it mysql specific? I understand this is an expression, but I'm not clear on how to use the PDO expression syntax in this case.

What are the advantages of writing it PDO, as opposed to just a simple db_query() with the sql query from above?  In PDO, will this truly be db agnostic?


texts:
Here is the situation:

I have two content types. Content type a has a CCK reference field for content type b.

Now I am trying to load all the nodes from content type a that are referenced to content type b.

Here is the code that I have.

$nidcur =  $fields['nid']->content;

$node = node_load(array("field_micselect" => $nidcur));

dpm($node);

So I would like to load all the nodes that are related to the nid $nidcur.


texts: Drupal 8 ignores block display settings for the default content block, if it is configured to be hidden on a node page

texts:
can someone help me understanding this scenario (D8): My content type - let's call it basic page - has two fields; title and body. I have a node (id = 33) with path /url. On the block layout page I have disabled both 'page title' and 'page content' blocks for path = /url, and instead I have created my own block (using a view) that displays the title and body together. This block is set to be SHOWN for path = /url.

Now when I navigate /url, I expect to see the title and body. Instead I see the title, body and again the title and body. Inspecting the markup reveals that the default content block is not hidden (as it should be, according to the block layout page).

I have seen this behaviour now on a couple of projects, I get the same issue if I use node/33 or if I set this node as the home page and use front. It seems Drupal 8 ignores the block display settings for the default content block if you set it as invisible on a node page.

Why is this happening?


texts: How to batch upload images and generate multiple images

texts:
I am planning my new website with Drupal 7. The site will have two core features: blog and photos. Blog is no problem and for photos I know how to implement most of my requirements. Except one ;-)

I plan to add a content-type "Photos" (or "Media"). Each photo will be stored in its content. These contents are categorized using a taxonomy so each photo can be in multiple terms (aka albums). For example a whale can be in "Underwater", "Big-fish" and "Salt water". Views with contextual filters will render the "album"-views etc. So far no problem.

What we don't know how to do yet is bulk-upload of images. Any idea would be great. If there is a gallery module or profile that handles that taxonomy thing / dynamic albums it would be an option to.

Idea: Maybe I can define a "Bulk-Upload" content type which is for uploads only. This conent-type has an "image" field set to "unlimited". When creating such a content a Rule will be triggered which creates multiple "Images" contents for it and deletes the "Bulk-Upload" content afterwards. ...sounds possible but a little tricky.

Any ideas?

Thanks and cheers,
Marc


texts: User View List in Drupal filter by taxonomy

texts:
In a social website powered by Drupal, Users are allowed to add interest tags into a taxonomy terms by autotagging.

My problem is how to create a view page to list all users based on a certain interest in the term list.

Say, I need to display user interested on PHP.


texts: Is there a way to automatically convert the relative urls to absolute? For example, when uploading an image it is automaticlaly included as a relative url, so it doesn't appear in the html email when received. Is there an automated way to change this or does one need to go in the source of the newsletter and change the url for all image/link instances?


texts: How to show the content on ajax or Jquery lightbox

texts:
I have created views custom template file for one of my view and works fine. And how can i show fields content(second in the below code) on Lightbox popup box when the user clicks on title field.

 <?php dpm($fields); ?>
   <?php print $fields["title"]->content; ?>

   <?php print
 $fields["field_availability"]->content; ?>


texts:
I have setup some Structure/Views for items that I am pushing to the front page.
I have 2 separate link items (1 displays facebook icon, 1 displays arrow icon)
some instances will have both links, some instances will have 1,
currently if I leave the facebook link field blank, the display still leaves the space for that item.

It seems related to the font awesome "fas" class that needs to be added to the Views setting in order to load the icons (icons are used in "content:" in css). Once I remove the "fas" class the height of the empty link field removes itself from the page.
How do I retain "fas" class on the: View (structures/views/ (item) / link field;
but remove the height of empty fields?

code:

Read More

The below screenshot shows how the class is applied to the View/Field, with "Hide if Empty" applied.


texts: Why there is not loadData() method in FileSystem?

texts:
To use the private:// scheme of Drupal 8 I had to :

Create a folder outside the docroot folder
Implement a  $settings['file_private_path'] = '../private-files'; to designate this folder
Make sure authorization matches the website user to write into it

Then I load the filesystem helper (I could use injection dependency but that is not the point here) :
$this->filesystem = \Drupal::service('file_system');

Prepare the directory in case it does not exists :
$this->filesystem->prepareDirectory('private://any_folder', FileSystemInterface::CREATE_DIRECTORY);

And then I could save a (unmanaged) file:
$this->filesystem->saveData(json_encode(['My Beautiful File Body']), 'private://any_folder/any_file.json', FileSystemInterface::EXISTS_REPLACE);

And this works fine.
But to load the file, I would have expected to have an "opposite" (say, loadData() ) method in $this->filesystem.
And as the file is unmanaged (which is fine) I cannout use File Entity::load() to load it.
So I end up with :
$loadedFile = json_decode(file_get_contents('private://any_folder/any_file.json'), JSON_OBJECT_AS_ARRAY);

Which works fine, but raises questions :

Is this a legitimate way to do it (meaning, using a Drupal helper to save a file, then loading it from a straight PHP function) ?

Why there is no loadData() method in the FileSystem service as I would have expected ?

How does the Drupal scheme 'public:// or private://) is resolved from this PHP function ?


texts:
I have made a Feedback Form in comments entity, Each node has multi file fields, I'm looking to force the users to submit the form & give their feedback after that redirect them to file download when click submit button, I'm using Views & Custom Formatters and I made the feedback form displays in Colorbox popup to keep them on the same page

feedback URL "node/%/feedback"

is there any function that can help me ? I'm using Drupal 7


texts:
I have file upload field in node edit form. After succesfull upload process (ahah by clicking Upload form button) I am getting thumbnail instead of file upload field. It's standard Drupal behaviour. I would like to know how to change size of image thumbnail generating by Drupal after ajax upload.

Could somebody give me any advice?


texts: Blocks disappeared when I changed themes

texts:
Some blocks are no longer showing under Block Layout (or under custom blocks). Some of the blocks came from views. And the views are still there and in block mode. Another block was of the type "Contact Block".

why does my views-block not appear? And why did the contact block disappear?

All I did was change the default theme to a standard theme. Then I uninstalled the previous theme and removed all its files. Then I put in a new theme and activated it and set it as default.


texts: Getting error of "entity_share_client.commands"

texts:
While trying to update Drupal core I was facing issue with error

- drupal/entity_share 1.x-dev requires drupal/jsonapi >=1.0.0 <2.0.0

But updating version of drupal/entity_share to latest version resolve this issue. Now while trying to update database it gives an error saying

ERROR: The service "drush.command.services" has a dependency on a non-existent service "entity_share_client.commands".

In composer.json drupal/entity_share version is "^2.0" and Drupal version is updated to 8.7.6. Also, I m using JSON API module and Entity share module too. Not getting any solution to resolve "entity_share_client.commands" error. Any suggestion?


texts: How can I change the text: "Images must be larger than 200x200" in the image field for a specific content type?

texts:
How can I change or replace the text: "Images must be larger than 200x200" in the image field for a specific content type?

I have created a image field CCK and I have put the Minimum resolution for Images of 200x200.  When I put this restriction appears the text:   Images must be larger than 200x200.  I need to replace or change this text by:  Minimum size for images:  200x200, in some content types.  Is it possible?

I am working with Drupal 6.x.

Thanks.


texts: Complex form - merge of two with single callback

texts:
I have a complex form of two logical parts, which I have placed in different  functions (my_module_partner_form & my_module_fields_form). Both forms have submit handlers (my_module_partner_form - 1 submit, my_module_fields_form - 2 different submits). I would like to display those on one page.

So my solution was the following:

Create a menu item like the following:

$items['complex-form/%/%/%'] = array(
    'title'         => 'Complex Form',
    'page callback'     => 'drupal_get_form',
    'page arguments'    => array('my_module_complex_form', 1, 2, 3),
    'access callback'   => 'my_module_complex_form_custom_access',
    'access arguments'  => array(1, 2, 3),
    'type'          => MENU_NORMAL_ITEM,
    'file'          => 'includes/some_file.inc',
);

Create a callback function to handle it

function my_module_complex_form($form, &$form_state, $param1, $param2, $param3)
{
    // ... some irrelevant code here ...

    $form = array();
    $form = drupal_get_form('my_module_partner_form', $someParam);
    $form += drupal_get_form('my_module_fields_form', $someParam);

    return $form;
}

Here are the forms itself (code obfuscated)

function my_module_fields_form($form, &$form_state, $param1)
{
    // ... some irrelevant code here ...

    $form['save_all'] = array(
        '#type'     => 'submit',
        '#value'    => 'Update',
    );
    $form['save_with_no_changes'] = array(
        '#type'     => 'submit',
        '#value'    => 'Save with no changes',
    );

    return $form;
}

function my_module_partner_form($form, &$form_state, $param1)
{
    // ... some irrelevant code here ...

    $form['save_profile'] = array(
        '#type'     => 'submit',
        '#value'    => 'Save contact details',
    );

    return $form;
}

SO, the question is: what am I missing, as the submit function for each of the functions (except for the my_module_complex_form_submit - why?) is being called, but I can not identify which button was clicked.

What I have already tried, not to waist your time:

reading $form_state['clicked_button']['#value'] - always the same - "Update".
creating custom #submit elements for each button - this will not work as I only need one handler to work each time. Please correct me if I missed smth in the workflow.

Any ideas welcome.


texts: Is there any way to clone a content type

texts: My site has a lot of different content types, they all have the same fields, the only difference is the name of the content type. Is there any way to clone those content types other than create them one by one. Thanks.


texts: Trying to display a views list with order based upon current node being viewed

texts:
I have a view block which shows lists of content type "news" which displays in a sidebar showing only the node title for users to peruse.

There are about 150 such "news" nodes and so I use pagitation.

These "news" nodes are completely linear. You always want to read them in order. So if you read node/20, you must read node/21 next, then node/22 etc.

I would like the view block in the sidebar to display the titles of 2 nodes BEFORE and AFTER the current node. So, if I went to node/20, I would like the view block to display:

Title of node/18
Title of node/19
Title of node/20 (current node being viewed)
Title of node/21
Title of node/22

I was hoping for some pointers as to how I might achieve this. All things that I've tried thus far have proved futile.

Thanks.


texts: Send 'compare product' action to Google Analytics

texts:
I am having a products page in my site. In that I have a comparison functionality.

Now I want to send data to google analytics so that Admin can later on check which products were compared. I have captured the products I.E. on which products checkbox the user clicked and store that array of products in a jquery variable.

Now I want to send this variable in ga function but I am not able to do soo. Can anybody help me out with it or some other solution?


texts: Field template in theme based on Garland

texts:
I have problem with template for field "field_is_new" in Drupal 7.
My_Theme is a modification of the Garland theme. (I don't know if it's important.)

I have created a template for this field in my theme folder ("My_Theme/templates/field--field-is-new.tpl.php").

In template.php, I added:

function My_Theme_preprocess_field(&$variables, $hook) {
  // Add specific suggestions that can override the default implementation.
  array_unshift($variables['theme_hook_suggestions'], 'field__' . $variables['element']['#field_name']);
}

I cleared the cache, and rebuilt the theme.

I was thinking it's good way to do this, but it's not working.
What's wrong?


texts:
In Drupal 7, my user profile page is getting really long. If someone sets or forgets a password, they don't see the Save button, and hence their password is not changed.
Using the Corolla theme, how can I add an extra save button right below the password fields?


texts:
I am trying to achieve is move active class from  element to parent  element, this should be possible to do in .twig template (I wouldn't like that) so how to get menu in Drupal 8 and alter it's attributes?

{#  https://api.drupal.org/api/drupal/core!modules!system!templates!menu.html.twig/8
menu_name: The machine name of the menu.
items: A nested list of menu items. Each menu item contains:
  attributes: HTML attributes for the menu item.
  below: The menu item child items.
  title: The menu link title.
  url: The menu link url, instance of \Drupal\Core\Url
  localized_options: Menu link localized options.#}

{# All menu and submenu items #}

        {% for item in items %}

            {# Menu with submenu #}

            {% if item.below %}

                     {{ item.title }}

                        {# Menu -> Submenu #}

                        {% for item in item.below %}

 {{ item.title }}

                        {% endfor %}

                {# Menu without submenu #}

            {% else %}

                {# Menu - Link #}

 {{ item.title }}

            {% endif %}

        {% endfor %}

The above code is menu--main.html.twig file,hear attributes not working.


texts: How can one module's template file be overriden by another module?

texts:
I'm trying to use a custom template file within my Features module to handle a Views exposed form, but have been unable to figure out how to do so. I've seen a couple of other questions on here which seem to be the very same class of problem, but who's solutions have not worked for me.

I have been successful in getting both my template file and a preprocess function to take control, but it appears that they completely disable View's own preprocess function, which is necessary for the form to be generated correctly.

Presently, I am creating a theme hook in my custom module:

function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'views_exposed_form__people__page' => array(
      'base_hook' => 'views_exposed_form', // BTW, am I using this thing right?
      'template' => 'views-exposed-form--people--page', // (hook--view--display)
      'render element' => 'form',
    ),
  );
}

I understand that this means my preprocess function will now be called, and I use that to add my template file into the mix:

function mymodule_preprocess_views_exposed_form__people__page(&$vars) {
  $vars['theme_hook_suggestions'][] = 'views_exposed_form__people__page';
}

This works, but now it looks like View's default preprocessor template_preprocess_views_exposed_form(&$vars) in Views' theme.inc isn't firing, and that's bad because that function needs to run for this to work properly.

I'm also struggling to understand the rules behind what functions and templates get used when. The system doesn't seem overly complicated, I've just had to piece how it works together from disparate sources. I may be operating under one or more misconceptions here, so let me know if you want to probe what I think I'm talking about.


texts:
In my Drupal 7-configuration, i'm getting this error:

The following module is missing from the file system: imagcache_actions. For information about how to fix this, see the documentation page. bootstrap.inc:1138

The tips on https://www.drupal.org/node/2487215 didn't help.
also imagcache_actions is not to find in the database.

Any hints?


texts: Wiki-like "create this page" with page manager?

texts:
I want to make it easier for editors to create new pages with page manager.  Is there a way to provide a "create this page" functionality for non-existent paths, so that editors can insert a new path in existing pages and proceed to create and edit the new page, just like editing a wiki?

I am wondering if I can implement this feature by using a menu tab like this to redirect unhandled path to the page manager's creating page.  Helps are very much appreciated.


texts: How to send one time login url with Rules?

texts:
I have a rule to create a user and an action to send login url to user's email. I didn't find any action to send login url, so added an Send HTML Email action and added the [user-created:one-time-login-url] token in mail body. but it appears as it is([user-created:one-time-login-url]), and is not translated to login url.

Then I used this php function to print the same url:

<?php
print user_pass_reset_url($user_created);
?>

It prints a url but also prints the following notices:

Notice: Undefined property: stdClass::$uid in user_pass_reset_url() (in line 2299 /var/www/web/modules/user/user.module).
Notice: Undefined property: stdClass::$pass in user_pass_reset_url() (in line 2299 /var/www/web/modules/user/user.module).
Notice: Undefined property: stdClass::$login in user_pass_reset_url() (in line 2299 /var/www/web/modules/user/user.module).

$user_created is the php variable referring to the user created in the previous action. But it seems it's not a user object(because of notices).

What's the proper way to send one time login url?


texts: How do I make a single page use ssl in Drupal 7?

texts: I have a form I created with Webform, and I need it to be secure.  I don't need a login for everyone, only SSL for that one page.  Is that possible?  How do I use https:// for that one page?


texts:
I created additional field for user profile, which is a reference to node (content type - Company).

How can i get values of this field for a current user?

 $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());

 $field_company= $user->get('field_company')->value; // result is empty

I know that second string is wrong, but i don't know what should I write.
Please, help.

Thanks a lot.


texts:
Migrating from D7 to D8, can someone explain how to theme a custom field in a content type?

Say I start with the "Basic page" content type and I add an image field, however I don't want this image to appear in the body of the text, I want it to span the entire page.

In Drupal 7 I would have gone into /sites/all/themes/mytheme/templates/page.tpl.php and added the following:

<?php if(isset($node->field_image_undernav) && count($node->field_image_undernav) > 0):?>
    <?php $imagePath = file_create_url($node->field_image_undernav['und'][0]['uri']); ?>
    <img class="img-responsive" id="img-top" src="<?php print $imagePath;?>"/>
<?php endif; ?>

How do I do this in Drupal 8? I'm guessing it's something like /themes/mytheme/page.html.twig and adding:

{# Top Image #}
    {% if page.machine_name_of_field %}
       {% block machine_name_of_field %}
         {{ page.machine_name_of_field }}
    {% endblock %}
{% endif %}

This changes where I can render the image in the template, but includes unwanted fields (like title) and some DIV wrappers. I just want to locate the image URL.

If I do

{{ dump(page.machine_machine_name_of_field) }}

I get NULL. If I dump(page), I see the URL but concatenated as part of a string in ["#markup"]. Any way to extract just the image URL from this field so I can place it exactly where and how I want?

The official D8 theming documentation doesn't seem to have this info, and unofficial guides like John Hannah's is helpful but seems to stop after basic setup.

Any guidance on this specific issue or documentation to learn more is much appreciated.


texts: How can I flush a json response in a controller?

texts: Didn't find this when I googled before, posting to maybe save the next person some time.


texts: Which link field accepts an URL or a Node reference?

texts:
I am looking for a field just like Link, but that allows the user enter a URL or via an autocomplete a node/entity reference.

This is because this field might be an external link or an internal link in which case it should refer to the entity.

Any suggestions?


texts: Translation of a element['#object'] rendered field

texts:
I have some fields in which I rendered additional fields from a nested term via element['#object']:

e.g. {{ element['#object'].field_country.entity.name.value }}

Unfortunately, this fields do not translate inside the node view although the node and the nested term itself is translated.

How can I make them display with their translation?


texts: How do I set up a new Drupal instance with all the modules from a previous one?

texts:
I had a temporary instance of drupal set up with lots of modules. I now have a new instance of Drupal and I want to install all the same modules, but I can only see how to do it with the GUI admin interface, which is frankly, horrifically clunky and unwieldy.

Is there another way to do this without spending half a day manually installing them again?

I've only heard of Drush, but I'm not sure how to set this up on windows, so this might not be the best answer. Everything I search for online (e.g. 'Export drupal modules') points me back to a 'modules that exports nodes etc.', not a 'mechanism for exporting modules'.

I've also found something called Deploy but I can't tell if this is for modules or just nodes.


texts: Is there a way module to tell if you're logged into Dev, Stage, or Production

texts:
Our deployment model has

Dev
Stage
Production
Failover (mysql replication and load balancer)

Our problem is that the server has failed over, we want to alert content editors that they're on the failover, or moreso, we'd like to ensure they're editing in the production areas and not on a development box.

Is there a way to distinguish the environment, after a user logs in? Is there a module by which color codes the admin bar depending on the server's host name?


texts: How do I reverse the order of submit and preview button?

texts:
I need to change the submit and preview button order in the node edit form in Drupal 7.
By default the submit button shows first the preview button, But I need vice versa.

How can I achieve this?


texts:
Hi i am  running from issue in drupal 7 site
-problem
There is lots of css   files come
in sites/defaults/files/css

    -uyqtwuetuwet.css
-uyqtwuetuwet.zip
    -khkjhkhk.css
 -khkjhkhk.zip

there is lots of files of this kind

I only use style.css
And file url come like this

I dont know how they come
Also there is zip file are made on server
Same issue on the  Js
It causes site performance issue
Thanks


texts: How can I add markup to a link in node links?

texts:
I am trying to add some markup around the number of comments link in the standard node links. I want to do this so I can theme the number of comments as a little comment bubble and hide the text (possibly only on mobile).

I can get this far:

function mytheme_preprocess_links__node(&$variables) {

 if (isset($variables['links']['comment-comments'])) {
    $title = $variables['links']['comment-comments']['text'];
    $count = 7 // need to get the actual count in here.

    $variables['links']['comment-comments']['link']["#title"] = \Drupal::translation()->formatPlural($count, ''1 comment', '@count comments');
  }
}

When I dsm the $title variable I can see that the comment count is in there, I just can't figure out how to get it out into the $count variable. Any help?


texts: Apply only database updates for a single module

texts:
update.php and drush up --no-core both list several database updates pending across several modules. I'm being asked to only apply the database updates for a few specific modules because it is desired to do just these modules and test things in relation to that before running any of the other updates.

drush seems to only give me the option to apply all of the pending updates as does the update.php script. Is there a way to apply only the pending database updates for a particular module when there are pending updates for multiple?


texts: Fatal Error HtmlRouteProvider not found?

texts:
Fatal Error: Fatal error: Class
  'Drupal\custom_avatar\CustomAvatarHtmlRouteProvider' not found in
  /Sites/drupal8/core/lib/Drupal/Core/Entity/EntityTypeManager.php on
  line 252

I am creating config Entity type and below is structure of my module shown in screenshot:

I below code I have defined below routing so that I don't have to define each of these routes statically in our module's routing.yml file. My class extends AdminHtmlRouteProvider :

  "route_provider" = {
         "html" = "Drupal\custom_avatar\CustomAvatarHtmlRouteProvider",
       },

<?php

namespace Drupal\custom_avatar\Entity;

use Drupal\Core\Config\Entity\ConfigEntityBase;

/**
 * Defines the Avatar profile entity.
 *
 * @ConfigEntityType(
 *   id = "custom_avatar",
 *   label = @Translation("Avatars for user profiles"),
 *   handlers = {
 *     "list_builder" = "Drupal\custom_avatar\CustomAvatarListBuilder",
 *     "form" = {
 *       "add" = "Drupal\custom_avatar\Form\CustomAvatarForm",
 *       "edit" = "Drupal\custom_avatar\Form\CustomAvatarForm",
 *       "delete" = "Drupal\custom_avatar\Form\CustomAvatarFormDeleteForm"
 *     },
 *     "route_provider" = {
 *       "html" = "Drupal\custom_avatar\CustomAvatarHtmlRouteProvider",
 *     },
 *   },
 *   config_prefix = "custom_avatar",
 *   admin_permission = "administer site configuration",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "label",
 *     "uuid" = "uuid"
 *   },
 *   links = {
 *     "canonical" = "/admin/structure/custom_avatar/{custom_avatar}",
 *     "add-form" = "/admin/structure/custom_avatar/add",
 *     "edit-form" = "/admin/structure/custom_avatar/{custom_avatar}/edit",
 *     "delete-form" = "/admin/structure/custom_avatar/{custom_avatar}/delete",
 *     "collection" = "/admin/structure/custom_avatar"
 *   }
 * )
 */

class CustomAvatar extends ConfigEntityBase implements CustomAvatarInterface {
  /**
   * The Avatar profile ID.
   *
   * @var string
   */
  protected $id;

  /**
   * The Avatar profile label.
   *
   * @var string
   */
  protected $label;
}

<?php

namespace Drupal\custom_avatar;

use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;

class CustomAvatarHtmlRouteProvider extends AdminHtmlRouteProvider {

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = parent::getRoutes($entity_type);

    $entity_type_id = $entity_type->id();

    if ($collection_route = $this->getCollectionRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.collection", $collection_route);
    }

    return $collection;
  }

  /**
   * Gets the collection route.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route|null
   *   The generated route, if available.
   */
  protected function getCollectionRoute(EntityTypeInterface $entity_type) {
    if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) {
      $entity_type_id = $entity_type->id();
      $route = new Route($entity_type->getLinkTemplate('collection'));
      $route
        ->setDefaults([
          '_entity_list' => $entity_type_id,
          // Make sure this is not a TranslatableMarkup object as the
          // TitleResolver translates this string again.
          '_title' => (string) $entity_type->getLabel(),
        ])
        ->setRequirement('_permission', $entity_type->getAdminPermission())
        ->setOption('_admin_route', TRUE);

      return $route;
    }
  }

}

Please suggest what is cause of error, the module gets installed without any error but when I clear all cache it shows error and the routs are not build using this way(page not found). I want to try using this class to build dynamic admin (canonical, add, edit, and delete forms for entities ) routs rather than defining in routing.yml

Thanks!


texts: I am using FFmpeg 0.10.7 on the server and video module (drupal.org/project/video) 7.x-2.10. I'm aware about video watermarking but only when u're using Zencoder. How can i set up a watermark with FFmpeg?


texts: How to show the count of members that belong to a group?

texts: I have a view showing a list of nodes of type group. How do I set it up to show the count of members that belong to each group?


texts: Drupal 7 - Get pages created from custom modules listed under Entity reference field

texts:
I'm using Drupal 7 Entity Reference field in one of the content types. I want to populate the Auto complete field with pages created using my custom module.

Currently in the options, it is showing only the content types that are existing. How can I achieve this?


texts: How to highlight new added links on front page with cookies?

texts:
My front page contains say 3 different views and each view has 10 rows. My requirement is Links which were not published to the frontpage the last time the user loaded it should be highlighted. I am using common template file for field shown on front page. (that is title file with anchor tag having link to some URL) Example in image :

I am having no idea how I can achieve this, I tried searching lot but I have idea that this can be possible with cookies.

Please suggest that will be very helpful !!

Thanks :)

UPDATE :

I have set nid values in cookie with below logic :

function custom_views_pre_render(&$view) {

  //frontpage highlight

  if (current_path() == "frontpage") {
    if (!empty($view->result)) {
      $nids = array();
      foreach ($view->result as $res) {
        $nids[] = $res->nid;
      }
      if(!isset($_COOKIE['FrontPage'])) {
        setcookie("FrontPage[$view->name]", implode(',', $nids), time() + (3600 * 24 * 5), '/');
      }
    }
}

Now I need to compare values of each row nid with in this array.


texts: Field formatter only displays file name not link to file

texts:
I installed Drupal 8.3.5, no extra plugins or themes. I have added in the "base page" (structure/type) a field (file_in) to upload files.

If I add a new page (node/add/page) and also load a file in file_in (file2.txt), the new page displays me the link to the file.

Then I add a new field called file_ext as entity reference (file type). If I add a new page (node/add/page) and put in file_ext a reference to the file2.txt, I see the new page, but with only the label name of the file, not its link.

File module is enabled, version Drupal 8.3.5 (new and clean).


texts: Accessing variable_get when loading bootstrap from an external file

texts:
I am loading the core drupal 7 components through an external file by loading bootstrap. While the core drupal functions work properly, when I try to access variable_get I keep getting the default value. The variable_get works properly when accessed from within a module. Any ideas?

require_once dirname(__FILE__).'/scripts/encrypt.php';

//Include drupal
$currdir=getcwd();
define('DRUPAL_ROOT',$_SERVER['DOCUMENT_ROOT']);
chdir(DRUPAL_ROOT);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
global $base_url;
$base_url = (array_key_exists('HTTPS', $_SERVER) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'];
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);

print_r(variable_get('var_name',DEFAULT_VAR_NAME));

This always returns

DEFAULT_VAR_NAME


texts:
I am logged in as user/1 and have created a News content type with publishing options as "Use as simplenews newsletter". I believe all the permissions are correct.

When I try to add new content using this content type I see these at the top of the page:

Add this newsletter issue to a newsletter by selecting a newsletter from the select list. To send this newsletter issue, first save the node, then use the "Newsletter" tab.
Set default send options at Administration > Configuration > Web services > Newsletters.
Set newsletter specific options at Administration > Content > Newsletters.

Re: Add this newsletter issue to a newsletter by selecting a newsletter from the select list. To send this newsletter issue, first save the node, then use the "Newsletter" tab.
I cannot see a "select list" on my create news page.

Re: Set default send options at Administration > Configuration > Web services > Newsletters.
I have created a newsletter category called "Ad Hoc"

Re: Set newsletter specific options at Administration > Content > Newsletters.
I have selected the All newsletters option from the dropdown menu. But no newsletters are available at the bottom of the page...

I am unable to get to Configuration > Simplenews as per the readme file.

What am I missing in order to be able to create News (newsletters)?


texts: How to add paragragh information under hovered menu item?

texts:
Hi all,
I want to add descriptions under my menu items like above (Eg. Home (ADD my description) Products (etc)?
Do I have to create children under these menu items and enable these????
Any advice would be appreciated.

Drupal 7


texts: How to modify Parent Item under Menu Settings to display current language links only?

texts:
We have a multilingual site where the menu links are based on the current locale. If 100 nodes are created in English and 50 nodes are created in Italian, for example, then when the locale is set to English, then the English menu link should display, but if the locale is set to Italian then i should only see the 50 nodes set to Italian.

The locale/language detection is based on URL so if the URL has ".com/en/" then the locale should be English, but if the URL is ".com/it/" then the locale should be Italian. As a result, the menu will display based on that locale.

The issue we are having is that on the Italian pages under menu settings, when i view the Parent Item Dropdown, i am seeing all the English menu links (whose language=en) displays with "(disabled)" next to it. All Italian links display as normal without "(disabled)".

Current example with language in parenthesis:

Parent Link (en)
Child Link1 (en)
Child Link2 (en)
Child Link3 (disabled) <-----this is an it (Italian)
Child Link4 (disabled) <-----this is an it (Italian)

The ideal scenario would be when i click on "Parent Item" dropdown that i only see links based on the current node's language (not other links assigned to a language that is different than the current node's language).

Expected behavior (if node's language = it):

Parent Link (IT)
Child Link3
Child LInk4

Expected behavior (if node's language = en):

Parent Link (en)
Child Link1
Child LInk2


texts: Using webservice to popolute/search Address Field fields

texts:
I'm busy developing a custom shipping module and want to have an auto-complete/select list of towns but the available data for the list is from a webservice (the reason for this is so that the shipping company can update their details without me having to update on my side the whole time).

How do I interact/modify/manipulate Address Field fields?  I tried to modify field.tpl.php to hide a country but it does not affect the address section in checkout, only the products section of the cart (and somehow I don't think this is the way to go anyway).  I also looked at addressfield.api.php but that looks very limited.  Should I just use normal fields one by one (street, town, zip code etc) and try and modify them. I'm not sure where to even start researching what to do to accomplish this so any pointers in some direction will be appreciated.


texts: Video Embed Field: Check All My Videos on existance?

texts:
My question on drupal.org did not have an answer:
To check if YouTube video exists in all my nodes?
Please yow to do these?


texts: Can I use static classes in template files?

texts:
Can I reference data as:

<?php print t(OgNotifyAttendHelper::findWelcomeName($user)); ?>

The class is included in the .info file for a module, and this template is accessed via hook_theme from a parent module (this is a submodule).


texts:
Webform creates a duplicate entry on edit, instead of editing the entry, is there a way to make it work the way it should (by not creating a new entry)?

Using Drupal 7 and Webform 7.x-3.17+3-dev.


texts: Filter node by custom_field in admin panel

texts:
I'm using Drupal 7, Views and Panels. Created a content type and custom field (field_list) And showing contents by list on my site. Thanks Views :) But when i click find content in admin panel, many many contents in my area.

Can i add filter option by field_list in my admin panel? Is it possible?


texts: problem with page count in pressflow & varnish

texts:
i'm using pressflow &  varnish & cashrouter in my site.
my problem is node counter is not true because google analytic show diffrent count of node.
for example in google analytic show count of node is 12000 but in pressflow show 300 hint.
im using revers proxy.


texts: Server Error 500 when changing pager of Views to display all items

texts: I have a View with 1,000 potential items. When it is paged, it works perfectly, both with Ajax paging or normal paging. But when I try to switch off the display type, the server throws a Server Error 500. No log in the watchdog table of the database or any other registry. I guess that there must be some problem with memory or something, but I would expect a PHP memory allocation error or something. It is not practical to show the 1,000 items at a time for the first time, but if I would want to change to some Page scroll pager like jScroll, I am worried that this is not entirely possible in Drupal.


texts:
After successfully enabling it, how do you know it's working? And how do you know how much better performance is increased?

In homepage of https://www.drupal.org/project/memcache it says:

A module that provides a comprehensive administrative overview of
Drupal's interaction with Memcached and stats.
A set of tests that can be run to test your memcache setup.

But there is nothing for Drupal 8.

If you read docu http://cgit.drupalcode.org/memcache/tree/README.txt?h=8.x-2.x there is no information how to test/confirm memcache is doing its job.

It shows in Status report it's enabled. Memcached version  3.0.0 But how do you know it's not just hanging around or idling?

Anyway, I read the 7.x docu and it had this:

## CACHE HEADER ##

Drupal core indicates whether or not a page was served out of the cache by
setting the 'X-Drupal-Cache' response header with a value of HIT or MISS. If
you'd like to confirm whether pages are actually being retreived from Memcache
and not another backend, you can enable the following option:

  $conf['memcache_pagecache_header'] = TRUE;

So I put in $settings['memcache_pagecache_header'] = TRUE;, but I don't see anything in my Network tab of Firefox's dev tools. All I see is X-Drupal-Cache UNCACHABLE with or without the setting.


texts:
I have a content type "Room" with this config:

Title
Body
field_comments (Comments)
field_members (Users Entity reference)

When I create a room I send with hook_entity_insert() an email to users add to the room

But my problem is when I edit this room and I add New members, I want to send an email only for new.

I try it with this code in custom module with hook_entity_update:

notify.module
/**
* Implements hook_entity_update().
*/
function notify_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
 if ($entity->getEntityTypeId() !== 'node' || ($entity->getEntityTypeId() === 'node' && $entity->bundle() !== 'room')) {
   return;
 }
 $mailManager = \Drupal::service('plugin.manager.mail');
 $module = ‘notify’;
 $key = 'new_notif';

 //send to all members in room
 $members = $entity->get('field_members')->getValue();
    $tos = [];
    foreach ( $members as $member ) {
        if ($member['target_id'] !== '1') {
            $tid = intval($member['target_id']);
            $user = \Drupal\user\Entity\User::load( $tid );
            $tos[] = $user->getEmail();
        }
    }

 $membersTo = implode (', ', $tos);

 $to = $membersTo;

 $params['message'] = 'You access to the room';

 $params['node_title'] = $entity->label();
 $langcode = \Drupal::currentUser()->getPreferredLangcode();
 $send = true;
 $result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
 if ($result['result'] !== true) {
   drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
 }
 else {
   drupal_set_message(t('Your message has been sent.'));
 }
}

I Don't know how to exclude old members after edit, add new members and save a room.


texts:
I just want to know how to show child terms in list box see the below image

i tried http://drupal.org/project/hierarchical_select this module but don't know how to achieve this.

http://wimleers.com/demo/hierarchical-select/az-standards this is the link to achieve in Hierarchical Select, but no idea to implement this, hope someone implemented this.

or is there is any module available?


texts: The only email header field that can be replaced is the Reply-to field?

texts:
Under the heading E-mail header details in the e-mail settings for my webform I have set the option E-mail from address to the component E-mail, from the current webform.

When the webform is submitted and recieved it works to click Answer in the recipient's Outlook client (the user e-mail from the webform is used in the TO field of the new mail).

But unfortunately this does not work when the recipient have enabled an auto reply, such as Out of office. In that case the address used in the auto-reply mail is the site's default e-mail address.

I have cleared all fields where the default FROM e-mail address can be stated (Default e-mail values in webform config, E-mail options in the SMTP settings) and tried with the option Use Reply-To header in the webform config both enabled and disabled.

I have also tried to use the variable $from instead of site_mail in htmlmail.tpl.php.

Is there really nothing I can do to replace the FROM address with a custom address fetched from the webform? Apparently the only header field that the webform can replace is the Reply-to field?


texts: Block in Utility menu top only shows on home page

texts:
heres my site coonvalleytel.com/drupal

I made a block with 3 pictures that are links to youtube, twiter and facebook.  But they will only show when you are on the home page.  Do you guys have any ideas for getting it to show for every page?


texts: Commerce Search API with Custom field search

texts:
I have a Custom search form with multiple fields on my front page. After clicking on submit button, user would be routed to search result page. (Ideally, a Commerce search view). On search result page, all facets blocks are enabled.

Products are mapped with Commerce Stores (cmp_store). I have used field collection for Store so Seller can add multiple stores. Each store has Zip code associated with it.

I am getting zip code in my search facets.
But if User has not entered zip code then I want search result based on User's current location + 25 kms radius. Sorting should be location based.

I guess I have to alter the search query. Not sure how to alter query.

How can I do that ?


texts: Drupal login error message display on page by make new module

texts:
I created the module and added the field in the user login block form for displaying error. I want to display the error in warning field instead of using form_set_error(). I am able to see the warning field in the login block. When I submit with error it did not display the error. Code is as under. I am missing how to refresh the value of form once it gets error.

function usermoved_form_user_login_block_alter(&$form, &$form_state) {
$form['warning'] = array(
'#value' => t('oops'),
'#weight' => 11
);
$form['#submit'][] = 'usermoved_form_submit_code';
}

function usermoved_form_submit_code($form, &$form_state)
{
  global $user;
 if (!$user->uid) {
  $form['warning']['value']= "changed to something";

}

}

I have disabled the error in user.module as follows.

function user_login_final_validate($form, &$form_state) {
  global $user;
   if (!$user->uid) {
//form_set_error('name', t('Sorry, unrecognized username or password. <a
    //href="@password">Have you forgotten your password?</a>', array('@password' =>
    //url('user/password'))));
}
}


texts: adding twig variable in html.html.twig from module

texts:
I'm looking to add a twig variable, which is set in a module, and render it in the html.html.twig template file for my theme.

In my module file I use the hook_preprocess_html() function where I render and set the twig variable like so:

function insusite_cta_bar_preprocess_html(&$variables) {
 $output = \Drupal::theme()->render('insusite_cta_bar_actions', array('items' => $itemsOutput, 'panels' => $panelOutput));

 $variables['cta_bar'] = $output;
}

Then in the html.html.twig template file in my themes folder I simply render the new cta_bar variable like so:

<!DOCTYPE html>
<html{{ html_attributes }}>
 <head>
  <head-placeholder token="{{ placeholder_token|raw }}">
 <title>{{ head_title|safe_join(' | ') }}</title>
  <css-placeholder token="{{ placeholder_token|raw }}">
  <js-placeholder token="{{ placeholder_token|raw }}">
 </head>
 <body{{ attributes }}>
  {{ page_top }}
  {{ page }}
  {{ page_bottom }}
  {{ cta_bar }}
  <js-bottom-placeholder token="{{ placeholder_token|raw }}">
 </body>
</html>

This doesn't render anything at all.

However, if I add preprocess_html() function to my .theme file then it DOES work, problem is we're using drupal as a multi-site system so I'd have to find a way to add this in to every theme's html, is there a way to do this?


texts: Show field label when using tokens in "Global Custom Text" field in Views?

texts:
How can I show the field label when using tokens in Global field in Views.

To reproduce:

In a view:

1) Add field: title-field and enable to "Create a label" with value "My title".

2) Add field: Global Custom Text. In this field I use the token [title_field] for the text.

In the result the label is not shown. The token just print out the value but not the label. Even when I checked  "Create a label" with value "My title" for the title-field

Can I get this? I know that this can be done with the views_php module but, I don't want to enable this module just to workaround this.


texts: Display 2 contents types fields in 1 view

texts:
I am trying out Drupal 7 - and am a complete noob, so please bear with me!

I have a content type - 'film' which displays various fields about a film and another called 'venue' which displays data about a screening of a film.

I wanted to merge the display of content types film and venue so that they display in the same screen (all the fields in one screen). Is this possible? Do I do it with views? I have heard of relations, but I'm finding it all confusing.

Thanks.


texts:
I have used Views to create a view Display a summary by contextual filter.

O/p

View settings like

Needs

There are only two option for sorting "ASC" or "DESC".

But i need to show like

Pass(4)

Fail(2)

Waiting(1)

Tried for

function hook_views_query_alter(){

}

But did not get how achieve this.

VIEW QUERY

SELECT field_data_field_bid_test.field_bid_test_value AS field_data_field_bid_test_field_bid_test_value, COUNT(crm_core_contact.contact_id) AS num_records
FROM
{crm_core_contact} crm_core_contact
INNER JOIN {users} users_crm_core_contact ON crm_core_contact.uid = users_crm_core_contact.uid
LEFT JOIN {field_data_field_bid_test} field_data_field_bid_test ON crm_core_contact.contact_id = field_data_field_bid_test.entity_id AND (field_data_field_bid_test.entity_type = 'crm_core_contact' AND field_data_field_bid_test.deleted = '0')
GROUP BY field_data_field_bid_test_field_bid_test_value
ORDER BY field_data_field_bid_test_field_bid_test_value ASC


texts: How to autoload classes from a 3rd party PHP library

texts:
I would like to use a 3rd party PHP library in my module and I wanted to ask what I need to do to autoload the classes?

Example:
Drupal\my_module\MyClass
wants to instantiate
ThirdPartyNamespace\Something\Else\Class1

The official Drupal 8 documentation doesn't really deal with more complex namespacing scenarios.


texts:
I'm creating a custom drush command in my module but it's not being seen. Wondering if someone would know why. The module is enabled. It seems the hook_drush_command() is never being called for my module, but I see it being done for other modules. I've tried clearing cache.

bir.drush.inc is located in /bir/drush directory

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

  $items['bir-process-images'] = array(
      'description' => dt('Process images on image server.'),
      'aliases' => array('birpi'),
      'arguments' => array(
          'days' => dt('Number of day(s) in the past to begin processing.'),
          'nids' => dt('Comma separated list of node ids to process.'),
      ),
      'required-arguments' => array(1),
      'options' => array(
          'days' => dt('Number of day(s) in the past to begin processing.'),
          'nids' => dt('Comma separated list of node ids to process.'),
      ),
      'examples' => array(
          'drush bir-process-images --days=7' => dt('Process images from 7 days ago to now.'),
          'drush bir-process-images --nids="2409,2309,5896"' => dt('Process images for given node ids.'),
          'drush birpi --days=7' => dt('Process images from 7 days ago to now.'),
          'drush birpi --nids="2409,2309,5896"' => dt('Process images for given node ids.'),
      ),
  );

  return $items;
}

When I type $ drush help at the command line, my command is never shown. I tried printing out the $items array in the function and it never even gets there. If I print $items out in another module, for example search_api, it prints to my screen. So, for some reason it's simply not picking up that I'm calling the hook in my file. Or, not seeing the file?


texts: How to show/hide "printer-friendly version" link according to workflow states?

texts:
There's a review content type on my site with a workflow: I use 'draft' and 'completed' workflow states.

I'd like to create a printer-friendly and pdf-version of 'finished' reviews only, so I'd like to hide the links generated by Print module in any other case.
I tried to modify MYTHEME__preprocess_node() to achive this with this code, but it didn't work:

if($vars['field_review_workflow'][0]['value'] == '13'){ //sid of 'finished' state
  show($vars['elements']['links']['print_html']);
}else{
  hide($vars['elements']['links']['print_html']);
}

How could I do it properly?


texts: Assign previous migration destination id in prepareRow

texts:
Working on migration of 6 to 7 where 2 websites are being merged into one. This is being done using migrate module.

There are duplicate users in 2 source sites and intended result is that the user that exists from the 1st migration should be linked as destination id on the second without being updated.

We already have migrations set up for 2 sites and site #1 is imported.  When importing users from site #2 we want to essentially keep the same user from site #1 and link all content from site #2 to be owned by user from #1.

Can this be done in prepareRow and how ?


texts:
I want to theme Panels using Zen Grids for layout.

Question:

Since all content in Panels appears in the 'content' div, what is the most flexible way to use Panels to place content anywhere on the page?

EG. Right now, my content-item that is styled with 'region-sidebar-first' is appearing in the main content section (of course).

Do I use
 - Panels Everywhere?
 - Mini-Panels?

I don't want to over-complicate things. Is there some way of configuring Panels to place content within ANY div within the body section of a page? I'd like to avoid using too many other modules etc.. and keep it very clean.

Ideal Scenario:

I place all the content-items inside a ONE column layout with Panels : (layout not important, but Panels does it's magic to create content based on Context etc... )
I style each content-item using 'css-properties' inside Panels, and choose CSS from Zen Grids
I use SASS to create a responsive layout via Zen Grids

Thanks in advance,

PW


texts: Displaying Taxonomy Term Field for Multiple Entries on a Taxonomy Term List View

texts:
I'm using a view to override my taxonomy term pages to display content fields.  One of those fields is another taxonomy term (applicable divisons).  Displaying the titles of terms applied to the content is no problem (multiple field settings).

The problem comes in here.  I need to display icons that represent each of those terms that is an image field in the term itself (division icon).  I added a relationship to the view (Content:Taxonomy Terms on node).  I can then add the field, but it limits it to one of the terms/icons and it doesn't have a "multiple field settings" area.

I've searched for this quite a while and it's probably an obvious answer, but it's one I can't find or figure out.

Answer:
This isn't pretty, but it's getting me the data I want.  It needs to be cleaned up.  Thanks for the help!

<?php
foreach($data->field_field_applicable_divisions as $mydata) {
    if (isset($mydata['raw']['tid'])) {
        $term = taxonomy_term_load($mydata['raw']['tid']);
        echo "
";
        echo "field_division_icon['und'][0]['uri']) . "' title='" . $term->field_division_icon['und'][0]['field_file_image_alt_text']['und'][0]['value'] . "' alt='" . $term->field_division_icon['und'][0]['field_file_image_alt_text']['und'][0]['value'] . "'class='term-image' />";
        echo "
 ";
    }
}
?>

Also, to get a legend in the header or footer:

<?php
foreach(taxonomy_get_tree(7) as $icon) {
    $term = taxonomy_term_load($icon->tid);
    echo "
";
    echo "field_division_icon['und'][0]['uri']) . "' title='" . $term->field_division_icon['und'][0]['field_file_image_alt_text']['und'][0]['value'] . "' alt='" . $term->field_division_icon['und'][0]['field_file_image_alt_text']['und'][0]['value'] . "'class='term-image' /> - " . $term->field_division_icon['und'][0]['field_file_image_alt_text']['und'][0]['value'];
    echo "
 ";
}
?>


texts: Button with Drupal Behavior jQuery Conflicting with AJAX 'Add More' Button on Unlimited Cardinality Field

texts:
I have a form with an unlimited cardinality field that creates an 'Add more' button to add more fields. I also have a separate pair of fields. One of these fields has a value prepopulated on starting a new form, the other field is another unlimited cardinality field with an 'Add more' button & is blank on page load. I have attached a Drupal Behavior jQuery function to a button that I have added in a custom module with hook_form_alter: this jQuery sets the value of the second of the pair of fields to the value of the first when the custom button is clicked. This works. And the 'Add More' buttons for the unlimited cardinality fields work as well. However, after the custom button has been clicked once, the 'Add More' button will no longer create a new field, & I get the following errors in my logs:

Apr 25 02:56:36 lucifer drupal: https://somesite.com|1366880196|php|111.111.111.111|https://somesite.com/system/ajax|https://somesite.com/node/add/inventory-stocking-ticket|1||Warning: implode(): Invalid arguments passed in form_error() (line 1649 of /hosting/somesite/com/htdocs/cms_sandbox/includes/form.inc).

Apr 25 02:56:41 lucifer drupal: https://somesite.com|1366880201|php|111.111.111.111|https://somesite.com/system/ajax|https://somesite.com/node/add/inventory-stocking-ticket|1||Notice: Undefined index: #ajax in ajax_form_callback() (line 379 of /hosting/somesite/com/htdocs/cms_sandbox/includes/ajax.inc).

Here is my code for the custom button:

$form['field_ending_weight_garbage']['und']['garbage_no_change'] = array(
  '#type' => 'button',
  '#value' => t('No Change'),
  '#attributes' => array('onclick' => 'return (false);'),
  '#name' => 'garbagenochange',
);

And the code for the behavior:

(function ($) {
  Drupal.behaviors.noChange = {
    attach: function (context, settings) {
     $('#edit-field-ending-weight-garbage-und-garbage-no-change').once('noChange', function() {
      $('#edit-field-ending-weight-garbage-und-garbage-no-change', context).click(function () {
     var a = $('#edit-field-starting-weight-garbage-und-0-value').val();
     var b = $('#edit-field-ending-weight-garbage-und-0-value').val();
     if (b == "")
     {
       $('#edit-field-ending-weight-garbage-und-0-value').val( a );
     }
     else
     {
       $('#edit-field-ending-weight-garbage-und-0-value').select();
     }
        return false;
      });
    });
   }
  };
}(jQuery));

Which is attached in an after_build function like so:

drupal_add_js(drupal_get_path('theme', 'corolla').'/js/inventoryNoChange.js');

I'm using jQuery 1.5 by means of jQuery Update module, uncompressed. What could be causing this?

Edit: I've managed to eliminate the first error by adding the custom button like this:

$form['field_starting_weight_garbage']['und'][0]['garbage_no_change'] = array(
  '#type' => 'button',
  '#value' => t('No Change'),
  '#attributes' => array('onclick' => 'return (false);'),
    '#limit_validation_errors' => array(),
  '#name' => 'garbagenochange',
);

So, it's on the first field in the pair rather than the second, & it's at $form['field_starting_weight_garbage']['und'][0]['garbage_no_change'] rather than $form['field_starting_weight_garbage']['und']['garbage_no_change'].

But the ajax error persists, & the 'Add Another' functionality is still broken. I should note that it only throws the error & fails seemingly randomly. I can add several extra fields with the 'Add Another' button, but then it breaks, throws the error, & won't add more fields.

I've determined that it is not the Behavior/jQuery that is breaking things. Simply adding the custom button with no behavior attached to it causes the problem. Still hoping someone can shed some light on this.


texts: 7 - FAPI: form_set_error messages on bottom of page or dialog box

texts:
My ajax FAPI multi-step form is rather large, the error validation message are located by default at the top. But users can't see these messages as they are clicking submit on bottom of a large form (scroll down).

Editing the $messages in the template has no effect on de FAPI vailidation.

Is there a way to place it in a dialog box or at the bottom?


texts: Add intro text before profile 2 form in the registration page

texts:
I have a site that use profile 2 to add some field in the user registration page (/user) and via LoginToBoggan I can ask email x 2 and password x 2.

Now I need to insert a little introductive text before profile2 fields, like a phrase that explain why I need to ask that fields to the user.

How can I create it?