texts: Views - display node referenced by user profile field

texts:
Office is content type

User accounts have a Node reference to Office, field_office.

I need to create a view which displays Office->name where Office->nid = Current_User->field_office

I can't believe something this simple is so difficult to setup. I've setup another view where User->field_office = Project->field_office. In that case I created two relationships:

Field: Office
(field_office) Content: Office (field_office) - reverse (to User)

And a Contextual Filter

(field_office) User: Uid

Where the default value is current logged in user's uid.

That was easier since both fields are the same (field_office). But I can't figure out how to link a field to a Content nid.

Update

It would be simple if I could just create a Contextual filter on Content: nid and set the default value to User: field_office. I can't figure out how to do that though. The only contextual filter option which might support that is PHP code, but what would I tell it to return? This doesn't seem to work (breaks AJAX)

$user_data = user_load($user->uid);
return $user_data->field_office['und']['0']['value'];


texts: Get the node title conditionally in a view rewrite field

texts:
How can I get the field for the title of the content?

In twig I need to do this (for jssor slider) :

{% if field_titre_url_externe is not empty  %}
  {{ field_titre_url_externe }}
{% else %}
  {{ field_title }}
{% endif %}

but field_title is showing nothing, so what is the name of this?

EDIT :

I'm talking about the title of a node , article or content type

In my frontend, the title has the class views-field-title

See this image for more details (that's what I want to do):

Access the field_url_externe is not working actually... Accessing this field will solve my problem


texts: How to pass multiple values in setArguments() and render view?

texts:
I want to pass multiple values in setArguments() and render view. I'm using below code but it's showing only 1 value instead of multiple.

 public function _ajax_generate_request_view(array $form, FormStateInterface $form_state) {
  $view = \Drupal\views\Views::getView('play_center_generate_request');
  $view->setArguments(array('23','46'));
  $view->execute();
  $render_view = $view->render();
  $ajax_response->addCommand(new HtmlCommand('#view_wrappers', $render_view));
  return $ajax_response;
}


texts: How can I avoid the installation directory appears in the site URLs?

texts:
I installed Drupal 7 through the hosting service tools, which installed Drupal inside the drupal1 folder. All the site URLs contain the folder name.

How can I avoid the URLs contain that folder name? For example, instead of http://example.org/drupal1/about-us, the page should be available as http://example.org/about-us.

I've been able to only set the default front page alias to the root.


texts: How does 'access content' permission string works?

texts:
I've written a question and gotten an answer. The is fine but not fulfill my requirements.
The question is below:

It will be helpful, if anyone explain the full meaning of the string 'access content' because I've not found 'access content' string on '/admin/people/permissions' page. On the other hand, if I use following code, it will be work.

function custom_menu_menu(){
    $items = array();
      $items ['status'] = array(
        'title' => 'My Status',
        'menu_name' => 'main_menu',
        'page callback' => 'status_page',
        'access arguments' => array('access content'),
      );
    return $items;
}

/*
  *Definition of the menu callback function.
  */
function status_page() {
    return 'Hello world!';
}

My Questions:

Is 'access content' a 'permission string'? if answer is 'yes' then please explain how does it works? [note: it is not listed in '/admin/people/permissions' page. So, How determinate that user's rules has this permission]
What is the meaning of 'access content' permission? example: 'Page: Create new content' permission means if user has this permission then user can create 'Page' content but if user has 'access content' permission then what can do user on this link page.


texts: Have the same rendered output, whether the video is a local or remote ressource

texts:
I need to let contributor either upload video or link to some remote streams (youtube).

For this, I use media (and media_youtube) module.

I works well for remote ressources, however when I try to upload a video instead, the video appears as a link, on the front (though I tried to fumble with the manage display settings for this peculiar field).

I tried to implement jwplayer for the local videos, but it did not work this time. I also had a look at mediafront module, but as far as I know, it does not handle "local" videos (I may be wrong, but it seems overkill).

Have you been facing such a problem before, that is render a consistent display (a player with the same dimensions), regardless of the source (local or remote) ?
Can you point me to some resources ?

Thank you.


texts:
Views comes with a bunch of filters, but seems to be missing "Does not contains any word". I am looking for a way to achieve a similar function with Views but can't find anything relevant. I found some suggestions for this function on Drupal Forums but there never came a solution.

Why I need this? I am looking to display visitor counts in my dashboard by using access logs via the Core Statistics module. There are a lot of crawlers though and I'm filtering their IP addresses out by hand. The problem is I need to add a new filter in Views per IP Address. It would be wishful to add one filter and fill in all IP addresses in one line.


texts: How to tell Drupal to look for templates in module directory?

texts:
I'd like to provide template implementation in my module and allow themes to override it. Basically, I add a suggestion by this simplified code:

function attach_preprocess_node(&$vars) {
  $vars['theme_hook_suggestions'][] = 'node__test';
}

(I don't want to use hook_theme to add a new theme because I want to reuse preprocess node functions. The theme name are awkward but I don't want to write node_attach_% to avoid confusion with node type.)

Then I use hook_theme_registry_alter() to add module path:

function attach_theme_registry_alter(&$theme_registry) {
  $path = drupal_get_path('module', 'attach') . '/themes';
  $theme_registry_copy = $theme_registry;
  _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'node', drupal_get_path('module', 'node'));
  $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
  if (!isset($theme_registry['node']['theme paths'])) {
    $theme_registry['node']['theme paths'] = array();
  }
  if (!isset($theme_registry['node']['theme paths'])) {
    $first_element = array_shift($theme_registry['node']['theme paths']);
    if ($first_element) {
      array_unshift($theme_registry['node']['theme paths'], $first_element, $path);
    }
    else {
      array_unshift($theme_registry['node']['theme paths'], $path);
    }
  }
}

However it does not work. That means: the file themes/node--super.tpl.php is not used. It is used only if I copied it to the theme folder.


texts:
I get informed that webforms didn't work anymore. I switched recently to a new server copying database and druapl installation folder to the new server.

What happens is that when webforms using, the fields (dates, numbers, etc) do not come up. I noticed that in the modules list are some incomplete entries like above:

I checked the CCK modules folder and reinstall the folder (cck-5.x-1.12), still the same.

I use CCK too for some fields in content types and it still works for creating and editing content, but when I create a new content type with a CCK field, it fails.

This site is scheduled to migrate to version 7, but meanwhile with version 5 should work.

Any idea where to search for reason that the (sub)modules are blank and propably won't work ?


texts: How to port vertical tabs functionality for custom node module to Drupal 7?

texts:
I have a custom module (written for Drupal 6) which defines a new content type. In Drupal 6 I have used several fieldsets and Vertical Tabs module to have the custom node form more clearly laid out. It looked like this

$form['event'] = array(
    '#type' => 'fieldset',
    '#title' =>  t('Event'),
    '#weight' => -2,
);

While porting that module to Drupal 7, I altered that section to use the now-in-core functionality to

M$form['event'] = array(
    '#type' => 'fieldset',
    '#title' =>  t('Event'),
    '#weight' => -2,
    '#group' => 'vt_event',
    '#collapsed' => true,
    '#collapsible' => true,
);
$form['vt_event'] = array(
    '#type' => 'vertical_tabs',
);

This indeed works just fine, when converting up to three fieldsets to the new structure. However, my form is more complex and I need at least five additional fieldsets. But as soon as I convert the fourth fieldset to enable it for vertical tabs, I suddenly get 500 server errors.

Does anyone have any idea why this is happening? It's always the fourth fieldset when it breaks the site and it's regardless which fieldset is the fourth (I tried to enable three other fieldsets first, but again it breaks on the fourth one which worked before).


texts: How to do a date countdown (to a future date)?

texts: How would one go about doing a date countdown (something like this: https://www.mupromo.com/?kbid=4722). I know I'd need to create a block...and I have boilerplate code for that, but I was wondering whether there's a module that already does something similar...or any other pointers you can give.


texts: JSON:API to Migrating Taxonomy References isn't mapping

texts:
OK, for a number of reasons I'm doing a Drupal 8 - Drupal 8 migration using the JSON:API module on the source site.  I've run into an issue attaching taxonomy terms to nodes.  Here's as far as I've gotten :

1) I created a vocabulary called "Photo Categories"

2) I've created and run import_drupal_taxonomy_photo_categories to import the terms.  This works perfectly.  I have manually checked to ensure they all get in.  I use the UUID as the migration's unique identifier.

3) I have a content type called Photos, it has a field called Photo Category which references the Photo Categories vocabulary.

4) From the source JSON in the relationships section I see this:

"field_photo_category": {
   "data": [
     {
       "type": "taxonomy_term--photo_categories",
       "id": "84c1e8bd-16f7-429f-b299-50fe43297d47"
     },
     {
       "type": "taxonomy_term--photo_categories",
       "id": "00931a31-d129-4c55-a962-f7ba11fed5a4"
     }
  ],
  "links": {
    "self": "https:\/\/seanreiser.com\/jsonapi\/node\/photo\/1396b571-0ece-4a07-ab17-7327e030dfb5\/relationships\/field_photo_category",
    "related": "https:\/\/seanreiser.com\/jsonapi\/node\/photo\/1396b571-0ece-4a07-ab17-7327e030dfb5\/field_photo_category"
  }
}

5) In the source > Fields section of import_drupal_type_photo I have:

-
  name: field_photo_category
  label: 'Field Photo Category'
  selector: /relationships/field_photo_category/data

6) In the process section I have:

  field_photo_category:
    plugin: iterator
    source: field_photo_category
    process:
       plugin: migration_lookup
       migration: import_drupal_taxonomy_photo_categories
       source: id

As I understand it this should loop through the field_photo_category.data and do a migration lookup on each id.  But nothing is getting mapped.

I have verified that the ids match the ids in the data section match the UUID from the taxonomy term JSON.  I have checked the database and verfied that ids appear in migrate_map_import_drupal_taxonomy_photo_categories.soure1 and they map to the appropriate tids.

I have installed the migrate devel module and when I run the migration with --migrate-debug this is what the destination section look like:

  'field_photo_category' => array (2) [
        array (1) [
            'source' => string (36) "84c1e8bd-16f7-429f-b299-50fe43297d47"
        ]
        array (1) [
            'source' => string (36) "00931a31-d129-4c55-a962-f7ba11fed5a4"
        ]
    ]

So, my question, what am I doing wrong?  I have the rest of this part of my migration laid out and this seems to be the final obstacle.

Thanks in Advance


texts: Debugging with var_dump -> where does the output go?

texts:
Me and a colleague had a D7 problem to handle, $_SESSION were being lost for anonymous users.  Because this is all happening on a staging server in a corporate environnment, devel module has been ripped out in preparation for the push to production. My colleague starts inserting var_dumps() in a  forms validate function, but the results don't show to screen.

He figures the validation is not being called, but I tell him about how Drupal suppresses output during rendering, I have experienced this many times.  Adding a die in the validate function confirmed that the function was in fact being executed,  except the question remains ->  why / how is output suppressed when echoing / var_dumping in functions?

Debugging with var_dump is probably not the most recommended or effective method, I just want to know what it is that prevents ouptput.


texts:
i want to set

Site building
Site data management
Site configuration
Site users management
Store administration
Reports

as menus as admin login, else it show other menu bar.

Home
Search
Mark List
Contact
Help

so can any one suggest how will I achieve this.
cheers.
Sanjay Dev


texts: Use an exposed filter as contextual filter on another view

texts:
The question is a pretty simple one, I've created a page-view with an exposed filter. The page-view itself contains a block-view. I was wondering if the value of the exposed filter (which is in the url) could be used as a contextual filter in the block-view.

So far I've tried 'get content ID from url' and  'get raw value'  but neither seem to work as the block-view returns no results.


texts:
My users can submit Recipes (a custom content type). I want to create a contest to let my users vote for their unique favorite recipe.

To vote, users (anonymous users) have to go to the page of the recipe they want to vote for and clic on "I vote for this one" to vote for it. If they go to another recipe page, they won't be able to vote for it because they would have already voted for another recipe.

Do you have any idea about how to do it ?

I know how to do it with a poll inside a block but I want to have a vote button inside each recipe page.


texts:
I am trying to convert my installation to a Drupal multi-site.
I have the original site (www.original.com) with a settings.php file under the sites/default folder. I want to add a new site by adding the following files.

sites/original2.com/sites.php
sites/original2.com/settings.php

I can access both URLs, but they use the default.settings.php file.
I have not changed anything in NginX as both URLs are resolved from Drupal on my docker instances.


texts:
It's good to see the Link field type in D8. It takes a URL and (optionally) link text.

I'm adding a multiple links field to a content type and would like users to be able to provide some styling clues as well: e.g. this link is the primary one, this one needs a download icon. Basically let the user add CSS classes to each of the links in the same way they can add urls, text to each link they enter.

Is there a way to adding a new part to the field type?

(EDIT: I've put the answer into a custom module)


texts: How to display the entity ID next to the title of an ECK entity

texts:
I have an entity template that starts like this:

<div class="<?php print $classes; ?>">

<?php print $title; ?>

But now I want to display the entity ID and the UUID next to the title.
<?php print $entity_id; ?> or <?php print $entity_id; ?> display nothing.

Do I need to preprocess something?


texts: How do you programmatically enable a payment method?

texts:
I have enabled the payment method module I want to use.  I am using Authorize.net.

However, by default it is disabled in the Payment methods listing.

In my module, I want to enable the payment method module for use when my module is installed.


texts:
I'm trying to install a third-party library in Drupal 8 by doing 'composer update'. I get this:

I have made it seemingly impossible for it not to be able to delete .editorconfig:

But I still get the same error. What should I try next?


texts:
I have created a custom module in Drupal 8. There should be some fields invisible by default; when a user clicks on More Options, the field should display. When user clicks on Fewer Option, the fields should be hidden again.

How can I achieve this in a Drupal 8 form?


texts: Rule to remove two specific items from commerce cart

texts:
I am using Drupal commerce and I try to make a rule to remove two specific line items from the cart. However, the most I can achieve is to empty the whole cart.

Can this be done with rules?


texts: How to resolve the Composer related error shown using the Drush DL command?

texts:
I am working on MAMP and I have already installed a Drupal 7 site in my local machine ( not using Drush or Composer ). Then I have installed Composer and Drush ( Installing Drush on MAMP ). Now my Drupal site is under htdocs folder and it's working. If I run "drush" from htdocs via the command line, then it's shown a bunch of help command list.

But if I am trying to install any module using drush dl Module_Name then it gives me an error like so:

  [error]  dl has been deprecated. Please build your site using Composer. Add new projects with composer require drupal/[project-name]. Use https://www.drupal.org/project/composer_generate to build a composer.json which represents the the enabled modules on your site.

Can anyone tell me what the problem is? Do I need to install a fresh Drupal 7 site via Composer?


texts: Url called from flash asks from a logged user to login again

texts:
I have a flash animation in a block which has a link to a different page in my site. The problem is that even if the user is logged in my website, the link when it opens, asks for credentials again. Any ideas how to overcome this problem?

I use the following code for the block:

<p>
  <object align="middle" height="380" width="100%">
    <param name="scale" value="exactfit" />
    <param name="quality" value="high" />
    <param name="wmode" value="transparent" />
    <param name="movie" value="/sites/default/files/flashes/main_tools.swf" />
    <embed height="380" pluginspage="macromedia.com/go/getflashplayer"; quality="high" scale="exactfit" src="/sites/default/files/flashes/main_tools.swf" type="application/x-shockwave-flash" width="100%" wmode="transparent"></embed>
  </object>
</p>


texts: Drupal 7 Forms API radios value not saving to the $form_state array after submitting

texts:
I have a form where I am using radio buttons and when I use integers as the index, the form is saving and passing the value just fine. However if I use a string as the index it is saving nothing in the $form_state['storage']['values'].

Example - This works as expected:

$testArray = array(0 => 'test1', 1 => 'test2', 2 => 'test3');

$form['step0']['testthis'] = array (
    '#type' => 'radios',
    '#options' => $testArray
);

After submitting this example the $form_state will look like (with array index 2 selected):

- Form Storage -
Array
(
    [values] => Array
        (
            [step0] => Array
                (
                    [testthis] => 2
                )

        )

)

Example - This does not work as expected... for me!

$testArray = array('test01' => 'test1', 'test02' => 'test2', 'test03' => 'test3');

$form['step0']['testthis'] = array (
    '#type' => 'radios',
    '#options' => $testArray
);

After submitting this example the $form_state will look like (with array index test03 selected):

- Form Storage -
Array
(
    [values] => Array
        (
            [step0] => Array
                (
                    [testthis] =>
                )

        )

)

I expect it to output

- Form Storage -
Array
(
    [values] => Array
        (
            [step0] => Array
                (
                    [testthis] => test03
                )

        )

)

Any insight would be most appreciated!

Thank you.

Edit: I forgot to mention that the HTML element is output just fine. So using the string index the element looks like:

<input type="radio" id="edit-step0-testthis-test3" name="step0[testthis]" value="test03" class="form-radio">


texts: Redirect after logout based on a query string

texts:
I have an URL http://localhost/drupal/user?ReturnTo=.....

i would like to check that query string "ReturnTo" and if that exists, then I want drupal to load that URL, that URL will be a fully qualified URL which could be another domain, Example https://www.google.com

How to achieve this, i tried to use "Configure an advanced action" arbitrary PHP script, but always getting errors


texts: Finding variables available in preprocess node or node.tpl.php from cck fields

texts: Would really appreciate help resolving this. I am using D7 and the devel module is not an option, for some reason it causes some problems with my site. I have looked into the contemplate module but see it isn't supported in D7, otherwise it would be great. Is there any quick way for me to see all my variables so I can utilize them in a preprocess function?


texts: How can I leave empty values in gmap field?

texts: I use gmap module to display a map on nodes that I want to have a location. On some nodes I don't want any location, and on those I don't want the map displayed at all. I tried to set default value in lat/long-fields to NaN or leave them empty, but then I get error when I save the node. Is there any way I can choose to display the map or not?


texts: How can I enable HTML output for checkbox options?

texts:
I am adding theme styling settings and I would like to have associated color to the checkbox in themes setting form. So far, i haven't been able to do so, because the output strips inline styling and then external styling is being reset for the admin view. How do you enable html output of the text next to the checkbox?

Here is my code so far:

function THEMENAME_form_system_theme_settings_alter(&$form, &$form_state){
       $form['theme_style'] = array(
        '#title' => 'Theme Style',
        '#type' => 'fieldset',
        '#collapsible' => FALSE,
        '#collapsed' => FALSE,
    );
    $form['theme_style']['color'] = array(
        '#title' => t('Color Skin'),
        '#type' => 'checkboxes',
        '#options' => color_schemas(),
//        '#process' => array(),
        '#pre_render' => array(),
        '#post_render' => array(),
        '#format' => array('text_format' => 'full_html'),
    );
}

function color_schemas(){
   $colors = array(
        'blue' => htmlentities('Blue'),
        'black' => 'Black',
        'maroon' => t('Maroon'),
        'grey' => t('Grey'),
        'white' => t('White'),
    );
    return $colors;
}

Here i try different things. To set the text format in '#format' attribute. I also attach 'id' element so could style in external style sheet but those are reset by admin imported CSS. I also try convert all html entities and output which works but it doesn't render the html correctly


texts: Problem with JS converting module form d6 to d7

texts:
I am converting a module from d6 version to d7 and I encountered some javascript problems.In the following code below .each() function isnt getting fired.But the its going till the .attachVote function for sure. Is this correct way to do it, or am I missing something?????

(function ($) {
/**
 * Create the smackdown object/namespace.
 */
Drupal.smackdown = function() {};

/**
 * Attach the smackdown behavior to nodereferences on the page.
 *
 * @param context
 *   The jQuery object to apply the behaviors to.
 */
Drupal.behaviors.smackdown = {
 attach: function(context, settings) {
    if (typeof Drupal.settings.smackdown !== 'undefined') {
        var field_1 = '.field-' +        Drupal.settings.smackdown.field1.name.replace(/_/g, '-');
         var field_2 = '.field-' +  Drupal.settings.smackdown.field2.name.replace(/_/g, '-');
         if (Drupal.settings.smackdownPerm == 1) {
             Drupal.smackdown.attachVote(context, field_1 + ' .field-item a');
             $(field_1 + ' .field-item a').attr('rel', Drupal.settings.smackdown.field1.nid).addClass('smackdown-processed');
            Drupal.smackdown.attachVote(context, field_2 + ' .field-item a');
            $(field_2 + ' .field-item a').attr('rel', Drupal.settings.smackdown.field2.nid).addClass('smackdown-processed');
        }
    else {
         Drupal.smackdown.attachNotice(context, field_1 + ' .field-item a');
         Drupal.smackdown.attachNotice(context, field_2 + ' .field-item a');
     }
   }
 }
};

/**
 * Attach the smackdown behavior to a particular link.
 *
 * @param context
 * @param selector
 *   jQuery selector for links to attach behavior to.
 */
Drupal.smackdown.attachVote = function(context, selector) {
 $(selector, context).each(function() {
     var $element = $(this);
     // Attach the on-click popup behavior to the element.
     $element.click(function(e){
     Drupal.theme('voting', $element);
     var nid = $element.attr('rel'); // not compatible with clean urls
     var sid = Drupal.settings.smackdown.sid;
     var params = {'cid':nid, 'sid':sid};
     // post nid and context to smackdown/vote
     ajaxOptions = {
       url: Drupal.settings.basePath + 'smackdown/vote/' +  Drupal.settings.smackdown.token,
      dataType: 'json',
      data: params,
      success: function(json) {
        // we put the location into a variable so that it can be changed by other modules
        location.href = json.location
      }
    };
    $.ajax(ajaxOptions);
    return false;
  });
});
};

Drupal.smackdown.attachNotice = function(context, selector) {
 $(selector, context).each(function() {
   var $element = $(this);
   $element.click(function(e) {
    Drupal.theme('notice', $element);
    return false;
   });
 });
};

Drupal.theme.prototype.voting = function(element) {
  var output = "
" + Drupal.t('Voting...') + "
";
 element.parent().css({'background-color':'#ffc'});
 return element.parent().append(output);
   };

Drupal.theme.prototype.notice = function(element) {
  var output = "
" + Drupal.t('You do not have  sufficient rights to vote.') + "
";
 element.parent().css({'background-color':'#ffc'});
 return element.parent().append(output);
 };
})(jQuery);


texts:
I have a field in the View called Dealer Name. Dealer Name is populated from a list that looks like this:

#111 | Dealer 1
#112 | Dealer 3
#113 | Dealer 3

I need this field to be Alphabetically Sortable but when I apply sortable it sorts on the ID. What befuzzles me is that in the HTML only the Name is printed not the ID so how does it know to sort on the ID? (see below)

<td class="views-field views-field-field-da-dealer">
    Dealer Name
</td>

How can I change this behaviour to sort on the Name?


texts:
I have created about 11 webforms in my website. Now I want to add recaptcha challenge in all of them.

I have installed the captcha module and recaptcha module. recaptcha is coming in all these forms. The problem is form gets submitted even if challenge is not taken. Below is yml file of a sample webform I have created

test_field:
  '#type': textfield
  '#title': 'Test field'
  '#required': true
captcha:
  '#type': captcha
  '#captcha_type': recaptcha/reCAPTCHA


texts: How Can I add a Hierarchical taxonomy Select in views filters and when editing content in Drupal 7

texts:
I have created a taxonomy vocabulary called Cars makes  and models  with a structure similar to this:

    -Car Make
    ----Car model
    -----------Year

I want to give the customer, options  to sort them in a View , like many cars sites do:
 a customer choose first the Car make, and automatically models from this make shows in a second level list.
But I want also to use this functionality in the (add content )page,  so when customer  try to sell a car, he will not need to scroll a very large list with makes and  models in the same field.
I cannot use Hierarchical Select. As many topics in this site suggest, because it doesn’t work for exposed filters in Views, with  Drupal 7:
http://drupal.org/node/1170192

I have spent hours and days, trying to fix this issue without any success, my options are very limited:

Turn back to Drupal 6, Just  to use HS with Views exposed filters.
(not a brilliant idea)
Use other CMS like Joomla, in fact there  is
many  Joomla plugins offering this functionality:
http://extensions.joomla.org/extensions/vertical-markets/vehicles ,
but then I will lose all the power of Drupal taxonomy.
Add autocomplete functionality to the views filter and Use
Autocomplete term widget , in the (create content page) , but this
is not very user-friendly method for no experimented users. More,
Autocomplete term widget will allow the creation of new terms, and
I do not want users to accidentally create new terms when they enter
an incorrect model  or make  in the field. Maybe I can correct this
using Content Taxonomy
module(http://drupal.org/project/content_taxonomy), which can deny
the creation of new terms. But this is not a global solution to my
problem.

Is there a module or any JavaScript or PHP snippet  to fix this ?


texts:
What's the best way/module I can use to automatically create subsites, like drupalgardens.com.

Is there a module to do it? Can I use drush for this?


texts: Single signon with Microsoft Outlook Webmail

texts:
I am using Drupal 7. I wanted to create Intranet pages where staff/employees can log in with their credentials. Is there any way so that they can log in with their https://login.microsoftonline.com/ login individual account?

I know OAuth Connector Module, HybridAuth Social Login are used for Twitter, Linked In, or Google connectors, but I am looking for a module which can connect with Microsoft Outlook Webmail.


texts: EntityMalformedException Error in profile2 module

texts:
I have installed profile2 module in my site.

After a user is registered, While opening his/her profile page.

The site throws error page like this.

In status report it shows the following error.

EntityMalformedException: Missing bundle property on entity of type profile2.
in entity_extract_ids() (line 7844 of /var/www/html/drupal/includes/common.inc).

But after i edit the user and saved it, without any alteration its working fine.

Any fix for this ?


texts: How to set translated variables' values from settings.php (or similar)

texts:
When using the Variable translation module (part of the Internationalization suite), how can I set the value of a translated variable from the  site's settings.php file ?

Using the $conf in the settings.php works, but off course it can only be used when the value of the variable is the same in all languages.

I'm looking for a solution that could be used to achieve the same goal of the $conf in the settings.php file: defining the values of variable at execution without the need store the values anywhere else. One use case is to assign different values to variables depending on the execution environment (as set in an environment variable).


texts: Target individual items of a multi-value field in my page template

texts:
I created one field for an image and In the field setting, I made allowed number of values to 2 (please find the attached screenshot

)

So my question is, how can I add both the images in a different div tag in my page template.

Or, how can I target first and second image in my page template.


texts:
When users forget their password they click on the reset password link. There, they enter their username, or password, and a mail goes to their inbox, instructing them on what to do.

The instructions say to follow a link that resets the password, and then redirects them to their user profile to enter a new password. Although they enter a new password, the next day (and everyday) the system doesn't recognize the password, and they have to reset it again.

Why does this happen?

How does the "reset password" work? Does it check the access date to see if the day has changed, or does it use some kind of flag to let the system know the password is valid only for one day?


texts: Facets blocks populated with incorrect field data and strange behavior

texts:
I'm building a product catalog with faceted search. I'm using Search API, Search API Database Search, and Display Suite.

I've created a search server as well as an index which indexes four fields that I'm interested in filtering by (artist, country, printing, subject).

My problem is that the facets set on the individual fields have erroneous data in them (data pulled in from other fields, splitting the names of artists, etc). Then when you click the facets, the contents of the facet change by removing or changing fields from the list of options in the individual facet block. Interestingly, in the artist facet clicking on an erroneous field (e.g. a brand in the print type facet) produces no results (yes is available as an option).

Part of this maybe my data quality in the db, I do have Artists' names as two words in a single field.

So, I'm curious why the facet options change when clicked, but much more so as to why my facets are messed up.

Thanks in advance.


texts:
Problem

I want to style the default upload buttons. How should I go about doing this?


texts: Is it possible to get original configuration when another Config Split is activated? (CONDITIONAL SPLIT is used)

texts:
I have dev and prod environments.

I use payment getaway. There are different api keys for dev and prod envs, it's like test and live mode of the payment method.

There is active dev config split configuration which contains some config with test api keys (CONDITIONAL SPLIT).

So it means, there is also original config witch contains live api keys.

Is it possible to get programmatically both values (original and dev) for some specific configuration?


texts: How do you replace text surrounded by a custom delimeter with  around it?

texts:
Overview

I want to have action asterisks in my posts. Basically, asterisks surrounding certain words. Examples: *gasp* or *giggle*

Simple enough. Now I could type that exactly into the editor but it needs to be styled via CSS. This of course calls for span tags.

However, I don't want to have to surround the text with span tags every time. Too tedious. I'll be using this often.

So, how can I make it so Drupal takes some text and replaces it with span tags surrounding it?

In Other Words...

I want to be able to write simple custom tags around text like:

[=gasp=]

and then have Drupal automatically convert it to:

*gasp*

A Possible Solution?

I've been led to the Custom Filter module and this seems closest to what I want. Now, it's already installed but in trying to add a 'rule', the module asks for the 'Pattern' to look for and the 'Replacement text'.

The problem is I am terrible with regular expressions.

Assuming this module is the right path, can someone tell me what to put in these two forms so the filter works? I have been holding this off for months because I was scared to ask for help.

If the Custom Filter module isn't what I need, what is the solution?

On a sidenote

I don't know what's a good custom tag to use. I came up with [=gasp=] but maybe you can recommend something better? Just as long as its short. I already use Markdown and don't want it to conflict with it.

Either way, thanks for any help in advance.


texts: Develop a module that adds a new content type with custom fields

texts: How do I start to develop a Drupal 7 module that adds a new content type with some custom fields, so it generates all the output I want?


texts: How to make footer static in Zen theme using zen grid

texts:
I used a Zen theme as my base theme which enables me to use zengrid to define my custom layout.  The thing is every time I move away from front page, the footer custom layout is disappeared, it only shown in the front page.

How do I make it static so it show up on every page and not just the front page.?


texts: How to add classes to BODY tag dynamically based on page path/depth?

texts:
How to add classes to the body tag dynamically such as this example below?

-Home
-Cities
--Melbourne       <body class="melbourne">
---Theme Parks       <body class="melbourne theme_parks">
---Restaurants       <body class="melbourne restaurants">
--New York       <body class="new_york">
---Theme Parks       <body class="new_york theme_parks">
---Restaurants       <body class="new_york restaurants">
-Contact Us       <body class="contact_us">

Drupal newbie here and without programming background. Therefore, I'd much appreciate if you could be as detailed as possible when sharing a solution.


texts:
How can I add a custom form menu link to the administrative menu programmatically?

I am trying to add this form as admin menu link like content, structure and module.


texts: is there any way to make the webform components labels translatable?

texts:
Just wondering how to make the webform components labels translatable.
I found this post with a link to a sandbox project but I don't where to download the module: Make Webform multilingual (i18n) aware through contributed modules

I also find this function to just make what I need but it doesn't work, maybe with a few change it will work: Source: work around

function module_name_form_webform_client_form_xx_alter(&$form, &$form_state) {
  foreach (element_children($form['submitted']) as $element) {
    // Pass each webform component title through the t() function.
    $form['submitted'][$element]['#title'] = t($form['submitted'][$element]['#title']);
  }
}

The function provided  by @lenni does the job but I get these error messages.

  Warning: strlen() expects parameter 1 to be string, array given en
  drupal_validate_utf8() (línea 1600
  de/Applications/MAMP/htdocs/tonisacristan.com/includes/bootstrap.inc).

  Notice: Array to string conversion en filter_xss() (línea 1366 de
  /Applications/MAMP/htdocs/tonisacristan.com/includes/common.inc).

  Notice: Array to string conversion en format_string() (línea 1552 de
  /Applications/MAMP/htdocs/tonisacristan.com/includes/bootstrap.inc).

The source of the problem is a Markup component. This function is working fine.

function webform_extras_node_view($node, $view_mode, $langcode) {
  if($node->type == 'webform' && $view_mode == 'full') {
    // translate the webform component labels
    foreach(element_children($node->content['webform']['#form']['submitted']) as $key){
      //to skip Markup components
      if($key != 'my_markup_component'){
        $node->content['webform']['#form']['submitted'][$key]['#title'] = t($node->content['webform']['#form']['submitted'][$key]['#title']);
      }
    }
  }
}


texts:
I was wondering what is the correct alternative of .inc files in Drupal 8? That is to say, if I want to create some functions that should be only be loaded when required, like it was with module_load_include() in D7. Though this function is still there in D8, I hear that this is not the best procedure. Is that so?

I have read somewhere, that using PHP traits is considered a better practice here. However, not sure if useing a trait inside a .module file is a good approach.

Any help?


texts: Unable to show the Uploaded Image by the user in user submitted form for node

texts:
On my site, we have a form which directly adds data into one content type. When user submits the form, all the field data is inserted. It's working fine except the Image field.

What I want is that the image field is automatically uploaded and is shown as automatically uploaded in the node admin. In the code below, I am providing a static image just to make it work and it still doesn't :(.

I have been banging my head on it for hours and hours and I'll be very thankful if you can provide me with any hope or solution ....

So with the following code, I've been able to upload the Image in the public://tmpprofiles folder. The problem is that file_copy is not working and throws an exception in error log that that

File http://yoursite.com/sites/default/files/tmpprofiles/anewimage.png could not be copied because it does not exist.

But it does exist!!!!

I don't why it is saying that. I guess it means that all the code is working except the last two lines. Those are the lines which will attach the image to the node and therefore would show this image as an uploaded image in the node admin.

Please discard my meh code if you've a better way of doing this.

Code

  $path = './sites/default/files/animage.png';
  $filetitle = 'newimage';
  $filename = 'anewimage.png';

  $file_temp = file_get_contents($path);

  $file_temp = file_save_data($file_temp, 'public://tmpprofiles/' . $filename, FILE_EXISTS_RENAME);

  $tmp_file_path = 'public://tmpprofiles/' . $filename;

  $file_path = file_create_url($tmp_file_path);

  $file = (object) array(
    'uid' => 1,
    'uri' => $file_path,
    'filemime' => file_get_mimetype($file_path),
    'status' => 1,
  );

  //These two lines don't work.

  $file = file_copy($file, 'public://another');
  $new_moment_node->field_profile_photo[$new_moment_node->language][0] = (array) $file;


texts:
I have a blog set up on my site, when I visit a page it delivers a 200 as it should, however when I visit a page that should not be there, it delivers a 403.

Example:

domain.com/blog/good-url/ = 200

domain.com/blog/bad-url/ = 403

The second example should be delivering a 404, any ideas where this could be coming from?


texts:
This question is related to https://drupal.stackexchange.com/questions/193603/solr-views-flag-newly-flagged-users-do-not-appear-in-search-results

Because previous question can be difficult to understand I'm trying to simplify things.

If I understand SOLR - Drupal integration well, every entity is represents as Document in SOLR.

How to invoke update of document for specified entity?

List of modules that I'm using for search page (a View)

dependencies[] = date_facets
dependencies[] = facetapi
dependencies[] = facetapi_bonus
dependencies[] = search_api
dependencies[] = search_api_facetapi
dependencies[] = search_api_location_views
dependencies[] = search_api_solr

I need to update SOLR document when user flag another user (Flag module).


texts: How to Get Views field template to be used in replacement patterns?

texts:
I'm using a template file like (views-view-field.tpl.php) to modify the output of a specific Drupal 7 Views Field.

I'm trying to modify the field and then use it back in the Views visual editor as a replacement pattern. The problem is it uses the original $output when it is used as a replacement pattern in the other fields' rewritten output (instead of using what I modified in the themed template file).

Is there anyway to do this? I'm trying to avoid going in and theming the other fields just to use the modified first one.


texts:
I have a tree of research topics, such as Mathematics/Algebra/subtopics.

The users should not be able to edit too broad topics such as Algebra, but have the permissions for smaller subtopics.

Should I do it as one big Book or as several books classified by taxonomy (which takes only broad terms such as Algebra), with smaller subtopics implemented as book pages?


texts: I am new to Drupal and working for a customer. He wants me to change the title of the front page. I just cannot figure out how to get there. I have no problem with the rest of the pages on the site.


texts: Geocoder not working with “Geocode from another field”

texts:
I'm trying to make Geocoder work but encountered the following issue: I installed Geocoder 7.x-1.2, and I want to use it with content from another field, namely Location 7.x-3.0-rc2. I installed Leaflet to try to display my nodes. When I create new nodes, the Geofield is not filled in anymore(it remains empty whatever the address I try to use). I installed Address Field 7.x-1.0-beta4 instead of Location but the same issue persisting.

Are there common issues that would make the geocoding fail? If not, is there a procedure to try to debug this?


texts: Is it possible to embed Drupal content within a different type of Drupal content?  I ask this question in the context of having Drupal maintain hundreds of product listings, each with a price.  Occasionally, we need to update those prices.   I am exploring ways of updating those prices within having to touch the base content.  It would be nice to create new prices for the new year, and at the appointed time, switch to those prices, rather than having to go through a tedious and time consuming process of updating them on, e.g. Jan 1.


texts: I can't get the token from /rest/session/token

texts:
I'm trying to get CSRF token in http://mydomain/rest/session/token and I didn't get anything.  When I put http://mydomain/session/token I got one token, is it the same token I should get in rest/session/token?  What do I need to enable in Drupal in order to get the token from "rest/session/token"?
Thanks.


texts: Views module core patching inside a sub-site

texts:
I have a multi-site setup like below:

abc-parent/sites/all/modules/views
abc-parent/sites/pqr-child/modules/views (consisting core patching done in views)

When i do the above i get errors like cannot redeclare function

I wanted to do a core patching for views inside just 'pqr-child' site so that customization remains only to pqr-child and not for all the sites inside 'abc-parent'

Can anyone please help me achieve the above.

Thanks.


texts: When webform block submitted send email to node author and site admin -how?

texts:
This is scenario which I try to reach on my website for free blogging:

There is created universal webform Contact author with fields name, email and text which is as block (display webform as block checked) displayed under every blog node type.
When reader submit this block, submitted values are send as email to author of blog post (node author), site admin (me) and possibly to submitter (reader) email.

Is there any possible solution involving webform? What's best combination of modules to do it so, if not webform (I prefer some webform solution)?

Update: For Webform 4.x I use token [current-page:node:author:mail] for "E-mail to address" in "E-mails" tab. You can find more details in this tutorial I wrote.


texts: How to preserve element type validation upon adding custom element validation?

texts:
I have ConfigFormBase.
It has a form element with '#type' => 'entity_autocomplete'.

When I add my custom element validation by '#element_validate' => [[get_class($this), 'validateReferencedItemExistence']] the original element validation which comes by the element type (Drupal\Core\Entity\Element\EntityAutocomplete::validateEntityAutocomplete) won't be added anymore.

After spending hours in the jungle of the FormBuilder class code I finally found the corresponding lines:

   if (isset($element['#type']) && empty($element['#defaults_loaded']) && ($info = $this->elementInfo->getInfo($element['#type']))) {
      // Overlay $info onto $element, retaining preexisting keys in $element.
      $element += $info;
      $element['#defaults_loaded'] = TRUE;
    }

I find this kinda bad approach, that you cannot extend the list of the validation items. What is the reason behind it?

How could I make a workaround / solve this issue?

(Just by calling Drupal\Core\Entity\Element\EntityAutocomplete::validateEntityAutocomplete in my custom validation I would create an unnecessary depedency in my code. (Just think about if they change their way of validation with a different function))


texts: Customizing views exposed filter drop down list with css

texts:
I have a view with few exposed filters. They are all "choose 1 term" type of filters with appearing dropdown list when you click on right side of them.

I want to style appearing dropdown lists. It looks ok in  chrome, but it's especially ugly looking in IE. Also, i can't find them in the code, they just dissapear when i try to "inspect" them.

How can i customize those drop-down lists' appearances? Do they have any css classes? Any other ideas?


texts: How to add a default Field when creating a Content Type?

texts:
I use to add a image field every time I create any content type. Just wondering if is there any way to add this field by default when the content type is created.

I found the http://drupal.org/project/content_type_extras module which provides some additional features to content types, but it doesn't include this feature.


texts: How to change the order of the fields returns by field_info_instances() function?

texts:
I am using field_info_instances() function to get all the fields of a content type and display it in a csv file.

but the problem is I can't change the order of the fields return by this function.

Any one who know how to change the order of the fields?


texts: How to customize the map used on gmap module (node locations)

texts:
When gmap module and location module are installed, there is a page called "node locations", which display all node with a location field (filled) in the site.

How can I customize the google maps parameters? I want to disable the satellite map (and options in top right), enable street view, and change the zoom widget..

Thank you


texts:
I have tried as many options as I can imagine but none of them prints anything except:

{{ content }}

However, I require individual fields for more control over theming.

I am using a custom block type and the following function.

function THEME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  // Block suggestions for custom block bundles.
    if (isset($variables['elements']['content']['#block_content'])) {
    array_splice($suggestions, 1, 0, 'block__bundle__' . $variables['elements']['content']['#block_content']->bundle());
  }
}

The template is working fine. I can hard code some random text and it is displayed. I just can't display the field values.

How do I print an individual field in block.html.twig?


texts:
I am using profile2. In main profile type I have created some fields. Now according to my project need I want to use display suit for manage display. I followed instruction according to link, but no effect. If I do some changes in manage field it is showing but if I do any changes in manage display it is not effecting.For example in my first screen shot designation is above full name that i have set by manage display but in front end full name is above

Please help me if some one sort out this issue.
Thanks in advance


texts:
I have just switched over a site live and I'm having problems regenerating the XML sitemap.

When I try, I get:

You are not authorized to access this page.

The URL is: www.example.com/batch?op=start&id=207

What could be causing this?

Thanks

EDIT:
I have created a new role with every single permission and assigned the user I'm logged in with to this role. Still no luck1


texts:
I have some modules in 8.8.5 that need an major update.
What is the best practice without loosing data or settings?

For example:
drupal/admin_toolbar          1.27.0          2.2.0

Do I need to uninstall the module in de admin backoffice Drupal?
If so, I first need to uninstall both modules: Required by: admin_toolbar_tools, adminimal_admin_toolbar
Finally uninstall admin_toolbar
Composer remove drupal/admin_toolbar
Composer require drupal/admin_toobar
Drush updatedb
Drush cr

Is that the correct way?
Or can I simply remove the old version with composer and require the new one?


texts:
I have the Views Slideshow module running a slideshow of 4 items in it and the background image is set to an image style that scales to 695px height (and no width setting). This also happens when I set it in the view to "original size" which is around 1140x698)
However, when the slideshow is running it changes the  element values (in views-slideshow-cycle-main-frame-row.html.twig) to give the style of
position: absolute; top: 0px; left: -677.969px; z-index: 4; opacity: 1; display: none; width: 627.969px; height: 514.98px;

You see that even though the image's width is closer to 1140px it is only showing 627px.  It doesn't resize the image, it crops it to this shape.  Instead I want the image to stretch across the page (regardless of how wide it is).
I need to find out

Where does this setting come from (image settings? coded in the module itself?)
How to change this so that it overwrites only for this View (homepage_slider) for this theme (if the settings are in the module or even the core)?

I am still new to theming with Drupal so if need to add a page, please help me with what to name it and where to put it if at all possible.  Or for additional code, goes into what file?
Thank you for your help!
UPDATE:
It IS using jquery.cycle.all.js and there are Advances settings in a CASE statement  in views_slideshow_cycle.js but it is in the /modules folder and I think it would get overwritten when there is an update.
So how or where do I make changes to this setting for this specific View that will persist between updates?
Thank you.


texts:
There is a code
define('SPAMBOT_DEFAULT_BLOCKED_MESSAGE', 'Your email address or username or IP address is blacklisted.');
How to make the phrase 'Your email address or username or IP address is blacklisted.' translatable? (with t).


texts: How can i change the form default value but not via hook_form_alter

texts:
I have a question about add a node which have a specific field!

I create two buttons on different page called A,B.

When User touched the A button,i redirect the user to the node_form page.

The specific field default value will be set as ValueA.

When the user touched the B buttons,the value of the specific field will become ValueB.

So i cant user hook_node_form_alter.

I want to write the code at the myform_submit() because of touching the button.

How can i do that?

Are there any method which can change the form value not via the form_alter()?

Please Help Me fix this problem! Thank you!


texts: How to print user role id with dynamic variable of language?

texts:
How to make this code dynamic  initially its printing only user role id for english language only ,if my current site having more then 10 to 20 languages how to change this code to dynamic

         global $user;
 global $language;
      //$lg =$language->language;
     dpm(user_load($user->uid));
    $user_fields = user_load($user->uid);
      //echo $user_fields->field_role['en'][0]['value'];

       $lg = $user_fields->language;
         //echo $lg;

     echo $user_fields->field_role['$lg'][0]['value'];

if i replace the ['en'] with ['$lg'] nothing is printing


texts: Modifying integer field to decimal gives error when editing field information

texts:
I have implemented php code to update a field from integer to decimal. However when trying to modify the field name from UI, it gives error:

Attempt to update field Maximum Temperature failed: field_sql_storage cannot change the schema for an existing field with data.

The system behaves well when editing existing field data or creating a new one.

Please find the code executed via hook_update_N() below:

/**
* Modify the integer field of nursing notes temperature field
* to decimal field with precision and scale
*/
function ji_custom_update_7001() {

  // Manual database changes.
  db_query("UPDATE {field_config} SET type = 'number_decimal'
      WHERE field_name = 'field_nursing_note_max_temp'");

  $new_field = array(
    'type' => 'numeric',
    'precision' => 10,
    'scale' => 2,
    'not null' => FALSE,
  );

  db_change_field('field_data_field_nursing_note_max_temp', 'field_nursing_note_max_temp_value'
    , 'field_nursing_note_max_temp_value', $new_field);

  db_change_field('field_revision_field_nursing_note_max_temp', 'field_nursing_note_max_temp_value'
    , 'field_nursing_note_max_temp_value', $new_field);

  // Clear caches.
  field_cache_clear(TRUE);
}


texts: Creating a ticket system with core only. How to modify fields on full_content view without reloading?

texts:
I'm trying to create a ticketing system with Drupal 8 core. I know Drupal 8 has quick edit module, but that doesnt seem to be working in D8 core. Below is a very basic ticket I made as it just contains:

ticket subject (title)
ticket body
assigned to
status
priority

When viewing a ticket or node, I want to be able to be able to ajax edit the status, priority, and assigned to fields. These are dropdown options or taxonomy reference fields. Right now one would have to click on "edit" to edit the node itself to make these changes. But how would one edit these on the same page without reloading to a new page?

I was thinking of using views and exposing the edit form for the same node, but that doesnt seem like its doable.


texts: Create custom signup block with mailchimp module?

texts:
I'm looking for code examples for creating custom mailchimp signup forms that use the mailchimp api integration provided by the mailchimp module.

Context: I have a D7 site using a standard embedded sign-up form for mailchimp. I just recently switched the site to https, which unfortunately causes some browsers (e.g. firefox) to throw a scary message when a user clicks the submit button on the sign-up form, because standard mailchimp embedded forms can only use http.

The mailchimp module uses the mailchimp API, which allows secure connections, so that's the obvious solution. And the mailchimp module automatically provides a block for each list. But the module makes assumptions that I don't want. So, instead of the automatic block provided by the mailchimp module, I'd like to create my own block(s) with a sign-up form that uses the api, so that I have more control over the look and feel of the form.

Also, I know the webform mailchimp module provides a mailchimp component for webform, (there's a good write up here) but I'd like to explore creating my own forms as a first step.


texts:
Is there a way to change edit link for Nodes?

Currently Edit looks like this: [node/node_id/edit]

I required to look like this: [node/edit/node_id]


texts:
I'm trying to build my own sorting function implementing hook_facetapi_sort() and sorting the following data by weight.

name, weight
dog, -2
cat, 1
zebra, -5
dolphin, 3
bee, 5

The code I wrote so far is the following one.

function zoo_facetapi_sort_animal(array $a, array$b) {
  $a = db_query("select weight from {animal} where name = :a", array(':a' => $a['#markup']))->fetchAssoc();
  $b = db_query("select weight from {animal} where name = :b", array(':b' => $b['#markup']))->fetchAssoc();

  $a_value = (isset($a['weight'])) ? $a['weight'] : 0;
  $b_value = (isset($b['weight'])) ? $b['weight'] : 0;

  return strnatcmp($b_value, $a_value);
}

The result is what I expected.

zebra
dog
cat
dolphin
bee

I get the following error message.

  Warning: uasort(): Array was modified by the user comparison function in FacetapiWidget->applySorts() (line 230 of /var/www/zoo.dev/sites/all/modules/facetapi/plugins/facetapi/widget.inc)

How do I avoid getting that message?


texts: Views' taxonomy term page by content type

texts:
I have two regular content type Article & Blog, both share a term reference field field_tags. When I use Taxonomy term view that come with Views module, it display tags term in both content type.

For example, there are two Article nodes tag as health and three Blog nodes tag as health. Then if I use Taxonomy term view to display health term, it will display five nodes: two Article nodes and three Blog nodes.

Is there a way to separate the display result by content type? For example, if user click on health term on an Article node, Taxonomy term view will only display two Article nodes and if user click on health term on a Blog node, Taxonomy term view will show three Blog nodes.

Prefer not to use an extra module or adding different tag field for Blogs content type. Thank you for helping!


texts:
I've successfully managed to hide "View" tab on node page with this code:

/*
 * Implements hook_menu_local_tasks_alter().
 */
function mymodule_menu_local_tasks_alter(&$data){

    foreach ($data['tabs'][0]['output'] as $key => $value) {
        if ($value['#link']['path'] == "node/%/view"){
            unset($data['tabs'][0]['output'][$key]);
        }
    }
}

but when I enter the frontpage this error is displayed:

  Notice: Undefined offset: 0 in custom_alter_menu_local_tasks_alter()...
  Warning: Invalid argument supplied for foreach() in custom_alter_menu_local_tasks_alter()...

This line that causes the error is the following.

foreach ($data['tabs'][0]['output'] as $key => $value) {

I don't know what is wrong with the code. On frontpage there are no tabs and I don't have custom coding there.

I'm using Drupal 7.


texts: Automatically import data from Google spreadsheet using feeds module

texts:
I have data in a Google docs spreadsheet. To import that data I currently have to download the spreadsheet as a csv file and then import using the Feeds module.

What I am trying to work out is if there is someway to automate the process? Is there some way to have feeds access the spreadsheet directly from Google docs?

Would appreciate some step by step instructions on how to set this up. Note that I already have feeds setup to manually import a csv file, so the issue at hand is how can I set it up so that feeds can retrieve the data directly from Google docs at regular intervals?

Note that the data is stored as regular Google doc spreadsheet, so solution needs to make sure that the document retrieved is in CSV format (is that possible by using a certain URLs structure?)


texts:
I have a module I wrote that prints dynamic data for JavaScript variables.

function javascript_api_page_attachments(array &$page) {
$page['#attached']['html_head'][] = [
        // The data.
    [
        '#type' => 'html_tag',
        // The HTML tag to add, in this case a  tag.
        '#tag' => 'script',
        // The value of the HTML tag, here we want to end up with alert("Hello world!");.
        '#value' => javascript_api_print_parameters(),

    ],
    // A key, to make it possible to recognize this HTML  element when altering.
    'hello-world'
];}

My problem is when Drupal caches the page.Need to stop caching my pages in drupal.

How can I avoid the output of my module is cached?


texts: Add a facebook login button in login/register page

texts: I am using Simple Fb Connect module for logging in using facebook. It adds an extra tab for facebook login in my login page but not in register page. I want instead add a button to these pages for facebook login. How can I do that?


texts: Creating a semi-static default date field (fixed month and day, year=NOW)

texts:
I have a date field that needs an unusual default date:  fixed day and month, but year=thisyear.  That's outside the standard default date options.

I didn't want to write a custom module for one form field, so I tried this in template.php

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

  if($form_id == 'qic-node-form') {  // form to make a new QIC entry

  $QICdefault= date('Y')."-12-01";
  $form["field_qic_join"]["und"][0]['#default_value']['value'] = $QICdefault; // set the default  join date to YYYY-12-01

  }   // This is in template.php so will only show if form is displayed using the theme template

}

But there is no sign of the form field default changing. :-(   What am I missing?


texts: Ubercart: Change the product display form label "SKU"

texts:
How would you change the display of SKU? (Which hook manages the product-node display?)

I need sku to output to display "Model #". on a product node page

Drupal Version 6.2x


texts: "Theme info" checkbox not showing on non-admin pages

texts: I'm using the Theme Developer module. When I enable it, the Theme info checkbox shows up in the admin pages, but it doesn't show on the non-admin pages (e.g. Home page). There aren't any JS errors from the console. What could I be missing to make it appear?


texts: How to create a message with message stack when user becomes a member of a group module group?

texts:
Hi currently I try to code a custom module for notification based on message stack module.
Now I'm searching for the event or hook to perform some custom code when the user becomes a member of a group.
I want to create a message based on the message stack like "the user John Doe became a member of group xxx. Visit group xxx."
Unfortunately I didn't found something like that in the module docs, so I ask here.
Thanks in advance for your help


texts: How to display node when view contains only 1 item?

texts:
I have a custom view which displays all nodes of a specific content-type off the main menu.  You can click on any of the teaser headers and see the individual node data.

I have been asked to display this drill down-detailed view if there is only 1 item in the main view rather than forcing the user to click through another layer to get to the detail view.

Any thoughts on how to hook into this and which hook to call to override the defined view and jump directly to the node view?


texts: how to use more then one content type filter in same views in drupal 7?

texts:
I have two content types animal and fruits.
In animal content type fields description .
content type = animal

conditions:

date = 2015
user = login
If a record exists that satisfies the above 2 conditions:

show description..

Then the system should then get the “body” data field value  from the content type “fruit” where the following 2 conditions are satisfied:

•   “Type” date field value = “apple” AND
•   “Title” data field value = “appple is my fav”.

then body show "
for ex : some content like fsdf lfdjldf


texts: how to add wrapper div for a image via image formatter in drupal 7?

texts:
I am creating custom formatter for images using hook_field_formatter_settings_form() in drupal 7.. I need to add wrapper div for my custom formatter. Means when I select this formatter then image should be wrapped by div.
for example .


texts: Recommended tools/techniques for monitoring for spam attacks on multi-site and shared servers

texts:
I'm managing a number of servers with dozens of Drupal sites, some with a single multi-site Drupal installation and others with dozens of separate Drupal installations. We're constantly running into the issue of one site having a lax registration or comment policy and getting overrun with node spam to the detriment of the entire server.

Addressing the spam isn't a problem once we can detect the issue (CAPTCHAs and user registration approval usually knock out most of the attacks) but most of these sites have inexperienced administrators who aren't savvy enough to notice these attacks underway and we only detect them several months in when the damage to performance and SEO has already been done. Better security policies would also obviously help and we usually try and address any potential security issues during the site build but we don't usually try and prevent the client from enabling comments or adding new features, etc.

Any recommendations for how to monitor multiple Drupal sites to detect an attack like this before it gets too far? I've seen a number of 'drupal watch' modules and services like Drupalmonitor.com or NewRelic but they seem more focused on module updates, etc. Possible signatures for a spam attack would probably be an excessive amount of comments or nodes over a given period, coming from the same server, excessive load on a specific table, etc.


texts: How to move files already uploaded to a new subfolder?

texts:
I've got a bunch of files in sites/default/files that I'd like to move to a sites/default/files/subfolder to avoid a big mess.

The fields uploading files have been configured to put them in the right folders in the future. What I'm looking for is a solution to organising files already uploaded.

Any suggestions?


texts:
I created a module for flagging entities automatically when created or updated.
There are some errors in my code because only nodes work.
If a user "user1" creates a node, the flag will be in his name. I want the flag to be done automatically on behalf of the site administrator.
How do I get the administrator to automatically flag?
use Drupal\flag\FlaggingInterface;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\user\Entity\User;
use Drupal\commerce_store\Entity\Store;
use Drupal\commerce_product\Entity\Product;
use Drupal\group\Entity\Group;
use Drupal\node\Entity\Node;
use Drupal\comment\Entity\Comment;

/**
 * Flag node.
 */
function admin_task_notify_node_update(Node $node) {
    $flag_id = 'moderate_node';
    $flag_service = \Drupal::service('flag');
    $flag = $flag_service->getFlagById($flag_id);
    $flag_service->flag($flag, $node);
}


texts:
Is there a convenient way to ask a particular database object to print its query?

Every now and then, I write a DBTNG db_op() in a module, and far to often, I don't quite get the queries right.

I know that devel can output the query log, but that's all queries, which, in this type of situation, is a problem more often than not.

I want to do

$result = db_select('node', 'n')->fields('n')->execute();
dpm($result->queryWithParameters);
dpm($result->finalQuery);


texts: How to attach a JS library to page or block with #attached?

texts:
I have seen something like the following document for forms:

$form['myelement']['#attached']['libraries_load'][] = array('myAwesomeLibrary');

However, this does not work in render arrays for pages or blocks.  At least, not in Drupal 7. When attaching a JS library to a render array in a page or block, should I use the 'libraries_load' or 'library' key within the '#attached' array?  Neither seem to work.

Of course, it's possible to use the 'js' key along with libraries_get_path, but I'm not sure that's best practice for Drupal 7, and it doesn't really take advantage of the path in hook_libraries_info.


texts:
I'm working on a page where the backend needs to work in different languages.

That's why I started translating individual labels in the configuration translation (/admin/config/regional/config-translation). After I looked at the first changes, I realized that the terms were not translated.

I went back to the translation page and see that my changes have been overwritten with the original language again.
So I re-translated and saved the term, which showed a success message. Then I called the translation again and it was again the value of the original language there.

Is the translation generally broken or do I have to do a specific setting?


texts:
I've to redirect users, after updating a node, to /node/NID path and not to /node/NID/latest (I'm using content moderation).

I've tried to add this on hook_node_update() but have been ignored (without warning or errors):

if (!$entity->isNew()) {
    $path = URL::fromUserInput('/node/' . $entity->id())->toString();
    return new RedirectResponse($path);
}


texts: Update radio button options after AJAX callback

texts:
I'm working on a form that submits via an AJAX callback that handles some class-toggling and populates a results table.

Here's the callback that each input from the form calls:

public function myCallback(array &$form, FormStateInterface $form_state) {
    $response = new AjaxResponse;
    // Omitting for brevity: Call to an external API and get a JSON result set
    // Build a render array of results from API call and store in $content
    $response->addCommand(new HtmlCommand('#results',$content));
    return $response;
  }

I now need to add a pager to the form results and I'd like to have the options update as a user adjusts the other filters. I can't seem to get my form to rebuild with new options, though.

Here's the pager element:

$form['pager'] = [
      '#type' => 'radios',
      '#title' => $this->t('Page'),
      '#options' => [
        // Number of options should update based on the response from the AJAX callback
      ],
      '#weight' => '2',
      '#ajax' => [
        'callback' => [$this, 'myCallback'],
        'disable-refocus' => true
      ]
    ];

Is there any way to do this through an AJAX response?


texts: Correct analysis for "Mismatched entity and/or field definitions"

texts:
Drupal 8 sometimes displays a warning in site status

  Mismatched entity and/or field definitions

There has already been a question about this and the answer is to run drush entity-updates.  I can't find any description of a solution directly from the GUI.

I have run the command several times and it works fine.  But I don't understand the point of Drupal printing this warning, rather than Drupal solving the problem automatically (by executing whatever the entity-updates command does).

Please can anyone tell me

Is there any analysis that I should do before running entity-updates?
Is there any reason I shouldn't write a cron hook that will call entity-updates automatically?
Should I raise an issue against Drupal core to request that Drupal runs the clean-up automatically rather than printing a warning?


texts: Access rights for file upload in private section

texts:
On my Drupal 8 site, I want to use the Webform module with file upload.
It works, if I use public file space (within the web root directory), but fails on private file space (outside the web root directory, strongly recommended for security reasons).

Drupal log file contains the following error messag.

  The upload directory private://webform/testform/sid could not be created or is not accessible

If I create the needed subdirectories within private (e.g. webform/testform/sid ) directly using the terminal, the upload itself works, but the submission fails, because the webform module was not able to move the file to a newly created submission directory.

On my local development machine all works fine, but on the server it fails.
I think it is more a server-configuration issue.

Other modules are able to work with the private files directory.
The access-rights are 755 as recommended. Trying to temporary set the file permissions to 777 doesn't fix it. Trying to add the private files path to the open_basedir directive doesn't fix it.

Normal file upload works on this machine; therefore file_uploads and other PHP directives are correctly configured. The error is not directly connected to file uploading, but with creating directories in the private filespace.

What can I try next to get it working?


texts: Multiple Views on a page - How to exclude already shown nodes?

texts:
I'm showing many nodes on a page using a few different Views blocks with Panels.

For example there is a "Top Story" block that shows the latest sticky article. Then there are blocks for certain Sections (taxonomy) and important Special Sections (another taxonomy).

A node can appear in both blocks if it has a Section (say, Culture), a Special Section (News) and it may also be Sticky (so it's up in the Top story block too).

The problem here is that I can't just utilize offsets to hide things, but would need something that excludes nodes from later views that have already been shown. Older sticky nodes naturally should push down to their respected blocks when newer Nodes come etc.

Another way to put it:

Let's say we have Views, A, B, C and D. If a node is already in A, it wouldn't show up in B, C and D. If it's shown in B, it would not show up in C & D. It should be hierarchical from "promotion" style blocks to more simple listings when going lower on the page.

Is there any ready solution that would help me achieve this? I'm familiar with module coding, hooks etc so that sort of solutions are open to me as well.


texts:
I would like to create a full page with a custom module. I mean a page that should not reside within the larger Drupal page. How can I achieve this?

This is the code I am using.

mymodule.module

 function mymodule_menu() {
   $result = array();
   $result['mymodule'] = array(
     'title' => "Some Title",
     'page callback' => "mymodule_function",
     'access callback' => true,
     'type' => MENU_NORMAL_ITEM,
     'weight' => 1,
   );

   return $result;
}

function mymodule_function() {
  print theme('my_custom_template');
  exit;
}

function mymodule_theme() {
  return array(
    'my_custom_template' => array(
      'template' => 'mymodule-page',
    ),
  );
}

mymodule-page.tpl.php

<html>
    <head>

    </head>
    <body>

        Hello World
    </body>
</html>

This works fine enough, but is this the correct method?  I also wonder how I would include forms (submit data, retrieve data, display that data, etc)?


texts: Let users review draft copies before publish

texts:
Is there a way to set permissions to allow users to preview an unpublished node before our a content editor publishes it? Our working group is rather small so Workbench may exceed what we need.

Would setting up a group, giving them permission to view a Content Type but not edit (and therefore publish or un-publish) be an acceptable solution? Would there be any unforeseen drawbacks? Could anyone lend their experience to such an option?


texts: How do I change the original language in PHP files and Twig files?

texts:
I have installed a Drupal 8.5 site in French (monolingual). Then, I added content.

Of course, there are many strings in the PHP files of my custom theme/module I pass to t(). There are also many strings in the Twig files I translated with {{ 'a string'|trans }}.

After a while, I added English.

Unfortunately, I discovered that all the strings (interface) I just mentioned are seen by Drupal as English string.

For example, using the Translation template extractor module, I don't have the choice to extract the strings in English. I have only 2 options for the extraction: Language independent template and Template file for French translations.
When I use the Translation Management Tool module, all the locale sources strings have Original language under the English column and Not translated under the French column.

How do I tell Drupal that all my strings (PHP and Twig) are French strings?
Alternatively, what is the process to be able to export/translate in English, and import files (PO or XLIFF) into my site?


texts: Querying Matching User Data With Drupal and mySQL

texts:
I'm using Drupal 7 with the current mySQL version. I've got a custom profile field table that includes an entity_id (which corresponds to the user id) and a value field, which has one of a number of text strings that users can select as a personal interest. The number of strings a user can select for their profile is variable.

I need to query out the logged in user's list of interests, then query out any users who have any matching interests and their user id. I have a query/subquery script that basically works:

$subquery = db_select('table')
    ->fields('table', array('value'))
    ->condition('table.entity_id', $user->uid, '=');

$query = db_select('table', 't')
    ->fields('p', array('entity_id', 'value'))
    ->condition('value', $subquery, 'IN')
    ->condition('entity_id', $user->uid, '<>')
    ->orderBy('entity_id', 'ASC')
    ->groupBy('entity_id');
$result = $query->execute();

This query returns multiple rows:

entity_id     value

entity_id     value

entity_id     value

entity_id     value

What I need is:

entity_id     value, value, value, value

entity_id     value, value

entity_id     value, value, value

I've searched and searched and cannot figure out how to do this. Can anyone help?


texts: How to update the database schema without losing existing data

texts:
I have a custom module with my_module.install file defining my two data tables in mysql. Module is already installed and I am able to save data from forms into them. Now my requirements changed and I need to create a third table in the same module. How do I approach the reinstall of the module.

1) Prepare MYSQl scripts to backup the existing data into temp tables and after uninstall and reinstalling the module, copy back the data into tables from temp tables.

2) Looked into https://www.drupal.org/project/backup_migrate not compatible to drupal core version I am using 8.6.0

3) Any other modules or ideas?

edited after the suggestion:
I have created the below function in  mymodule.install file and also edited mymodule_schema() method and run drush updatedb. Still no db changes as expected table is not getting created. Not able to look into system table to get the recent version number as mentioned elsewhere because that table is not available in my current local DB.

   function mymodule_update_8601(){
    $spec = array(
    'fields' => array(
     'application_setup_id' => array(
     'type' => 'serial',
     'not null' => TRUE,
     'description' => 'Primary Key: ID',
     ),
    ),
   );
   $schema = Database::getConnection()->schema();
   $schema->createTable('application_setup', $spec);
  }


texts:
We are using LoginToboggan. How can I send an email to Administrator when Users change their name?

I looked at Rules, but the only Rule action which seems close is

"After updating an existing user account"

Is there a (simple) way to program a custom action which sees that the Name field has been changed?

TIA

{ "rules_notify_sales_on_username_change" : {
    "LABEL" : "Notify Sales/Administrator On Username Change",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "email" ],
    "REQUIRES" : [ "rules", "mimemail" ],
    "ON" : { "user_update" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "account" ],
          "roles" : { "value" : { "11" : "11", "7" : "7", "2" : "2" } },
          "operation" : "OR"
        }
      }
    ],
    "DO" : [
      { "mimemail_to_users_of_role" : {
          "key" : "userupdate-sales",
          "roles" : { "value" : { "6" : "6", "3" : "3", "20" : "20" } },
          "active" : 1,
          "from_name" : "User Update",
          "subject" : "User updated their account information",
          "body" : "An existing user has updated their account. \r\n[account:name] \r\n[account:mail] ",
          "plaintext" : "An existing user has updated their account. ",
          "language_user" : 0,
          "language" : [ "account:language" ]
        }
      }
    ]
  }
}


texts:
I am trying to alter my search form. I am following tutorial to learn drupal theming.
I want to replace the search button with an image :

function mytheme_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
$form['actions']['submit']['#type']= 'image_button';
$form['actions']['submit']['#src']= drupal_get_path('theme','MYTHEME').'/images/search.png';
$form['actions']['submit']['#attributes']['class'] [] = 'btn';
}
}

What i get in my page is the following result :

<input class="btn form-submit" type="image" id="edit-submit" name="submit" value="Search" src="http://mysite.com/sites/mysite.com/themes/MYTHEME/images/search.png">

However i want :

class="btn"

And not

class="btn form-submit"

Did i miss something ?

Thanks !


texts: Why doesn't a cloned theme work as the original theme?

texts:
I've cloned a theme, by duplicating and renaming it, in /sites/all/themes/. When I switch to the new theme, portions of the theme, a slideshow, don't work.

It looks like views_get_view_result() in template.php is not returning anything. Is there some configuration I need to set up per theme?

I'm new to Drupal and I am helping out a friend. The site is using Drupal 7.


texts:
I am using Drupal url field in which I input any external url of an MP3 file hosted on Twilio Server and I then use html5 audio tag to render it as an audio file in node display. Everything looks fine until my client asked me to calculate the duration of the audio and display it as a column in my views.

Is there any way I can achieve this?

Thanks!


texts: How to create search indexes by path in Drupal 8?

texts:
For a relatively small Drupal 8 website, I need to enable a search box, with multiple indexes based on the path or menu value.

For example; the main menu has 2 menu items linking to basic pages: Employers and Employees, and rest of the website pages are created under these two pages, and each page has a menu item with matching hierarchy.

Employers

Section A

Sub-section A-1
Sub-section A-2
Sub-section A-3

Section B

Sub-section B-1

Section C

Sub-section C-1
Sub-section C-2

Employees

Section D

Sub-section D-1
Sub-section D-2

Section E

Sub-section E-1
Sub-section E-2
Sub-section E-3
Sub-section E-4

Section F

Sub-section F-1
Sub-section F-2
Sub-section F-3

I need to be able to search only in Employers or Employees. And the search results must be limited to those indivual landing pages.

Thoughts?


texts: How can I add a wrapper to a group by in Drupal 8 views?

texts:
I have a (drupal 8.3) view using group by that outputs html like:

Category 1

Category 2

I would like to hook or template the group by to use a wrapper and achieve:

Category 1

Category 2

Any ideas how I can accomplish this using Bootstrap theme?


texts: Automatically adding paid membership products based on field values with Ubercart and Content Profile

texts:
I'm in the early stages of building a client site that is heavily centred around paid membership. Depending on a fairly complex set of rules, members will join the site and be charged different amounts for their annual membership based on fields they fill in on the signup form.

I am using Ubercart and Content Field Profile to create a custom membership form. The membership boils down to having 1-many products added during the sign up, based on the values entered in the form.

Is there a way I can do this without coding it all myself using submit or validate hooks and uc_add_product or similar?


texts: Show Block view of Restricted Content Type

texts:
I have a content type of Events which i make restricted for anonymous users via content_access module. But on the home page there is a block view of most recent Events. I don't want that block view to be hidden from anonymous users. I have selected all roles in the view settings so that i should show but i think because of contect_access restrictions on Event Content Type its not displyaing the block.

How can i show that block ?

Thanks


texts:
I am trying to login users programmatically in Drupal 8. Here goes my code:

if(isset($uid)) {
  $user = User::load($uid);
  user_login_finalize($user);
  $user_destination = \Drupal::destination()->get();
  $response = new RedirectResponse($user_destination);
  $response->send();
  exit(0);
}

I am getting the message 'Session opened for...' in watchdog. But the user is not logged in. Can someone tell me whats wrong with my code?


texts: How to remove Home title from the home page?

texts: There are several posts on a similar question. Despite that, I couldn't find the best way to resolve it. Display Suite is installed but don't see option to turn off page title. Our home page content type is Slider. I can see the html code using Inspect Element on Firefox. Don't know where the page is to remove it.


texts: Setting #states property for a field_collection item added with the add_more button

texts:
This is a D8 question as the solution in Using #states with field collection doesn't work for D8.

Here are the solutions I have tried, but none of them was working:

1- Adding an after build function for the field_collection element

$form['my_fc_field']['#after_build'][] = 'my_fc_field_after_build';

=>The function is not called when the "add_more" button is pressed

2- Adding an after build function for the field_collection item element

$form['my_fc_field']['widget'][0]['fc_item_field']['#after_build'][] = 'fc_item_field_after_build';

=>The function is not called when the "add_more" button is pressed

3- Altering my field_collection widget

function artprod_field_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
  $field_definition = $context['items']->getFieldDefinition();
  if ($field_definition->getName() == 'my_fc_field') {
    $widgets_that_need_states = &$element['my_fc_field']['widget'];
    $childs = Element::children($widgets_that_need_states);
    foreach ($childs as $child) {
      $widgets_that_need_states[$child]['value']['#states'] = array(
        'visible' => array(
          "select[data-drupal-selector=\"xxxx\"]" => array(
            'value' => 'yyy'
          )
        )
      );
    }
  }

=>The function is not called when the "add_more" button is pressed

Conclusion: with all of those 3 methods I could set the #states property to the already constructed element, but not for the added elements.


texts:
I'm trying to add multistep form functionality to a node creation form via a form alter. My (abbreviated) code follows:

function mymodule_form_FORM_ID_alter($form, &$form_state)
{
        if (!isset($form_state['storage']['step']))
        {
            $form['actions']['submit']['#submit'][] = 'my_form_submit';
        } elseif (isset($form_state['storage']['step']) && $form_state['storage']['step'] == 'step-two')
        {
            $form['foo'] = array(
                '#type' => 'textfield',
                '#title' => 'Add foo',
            );
            $form['actions']['#type'] = 'actions';
            $form['actions']['submit'] = array(
                '#type' => 'submit',
                '#value' => 'Register',
                '#submit' => 'step_two_form_submit',
            );
        }
}

function my_form_submit($form, &$form_state)
{
    if (!isset($form_state['storage']['step']))
    {
        $form_state['storage']['step'] = 'step-two';
        $form_state['rebuild'] = TRUE;
    }
    //so far so good
}

function step_two_form_submit($form, &$form_state)
{
    //This code never runs
    drupal_goto('/');
    dd('step two ran');
    //etc
}

The second step of the form loads as I would expect along with a submit function. The submit callback, however, is never called. Am I making a mistake by nuking the entire $form array? (The $form_state array, which is what I really need to hold onto, remains intact.) I feel like I'm very close but am missing something substantial.


texts: Best practice: content types with unique machine names

texts:
We have a module install script that auto-generates content types.

The content type machine names are based on text field data inputted by a user using a custom form. For example:

User title = 'Technical' => Auto-generated machine name = technical_comp

User title = 'Specialist Claims' => Auto-generated machine name = specialist_claims_comp

… and so on.

For the module to be robust, it needs to create unique 32 character machine names where there are two text fields with the same data.

Is there best practice around this?

I was thinking something along the lines of:

User title = Technical => Auto-generated machine name = a1_comp

User title = Specialist Claims => Auto-generated machine name = a2_comp

… which would give us plenty of scope but would require some kind of content type count.


texts: Is Search API module 'English-speaking' only?

texts:
I am developing a multilingual (English-Ukrainian) Drupal website using Entity translation module. Everything went smooth before I tried to use the search module. I have Search API, Database search, Search API Entity Translation and Search API Entity Translation Database Search enabled and configured.

As far as I understand, only the English version of content is being indexed. All search queries in Ukrainian have zero results.

As an experiment I added some English words to the page in Ukrainian and used them as search terms. To my surprise, the page containing these words immediately appeared in search results. Furthermore, when performing the same seach from the English version, the English version of the Ukrainian-language page containing these keywords was retrieved (there are no such keywords in English version).

Is it possible for Drupal search to index content in Ukrainian (or other cyrillic language)? Are there any guidelines or tutorials how to acheieve this in multilingual environment organized with Entity translation?

UPDATE:

Continue experiments.  I have three nodes, all of them translated. After disabling "Search API Entity Translation Database Search" module the situation changed. Two of nodes have their Ukrainian versions indexed only, the third one has only English version indexed. I have re-indexed the website several times. All three nodes and their translations are similar.


texts: Does anyone know how to add link such as about us in the footer region. i am using the zen theme. Further, How do you redirect people to the login or register page from pages such as upload, thus if they are not logged in.


texts: Transfer data from view query hook to view template

texts:
Under certain conditions I modify a view's query with a ..._views_query_alter hook.
In my view template, I want to display a notice when this alteration has been made.
What is the correct way to transport such information into the view?
The hook gets the $view object as first parameter, but which of the view variables is the right one to contain such custom data?


texts:
I am using Cube Portfolio to display portfolios.

The "View Larger" button link shows the correct link.

But when I click on the button,

the pop up image went wrong.

How do I find out the problem?

I look into the code, there is a weird link.

The portfolio section was created in Views. Drupal version is 7.


texts: Table not creating while installing a custom module in Drupal 7

texts:
I am creating a simple module. In that module I need to save the values in a table and I have created an .install file to create the table when the module is installed.

While installing the module, it is not creating the table and it gives a PDOException Error. I am unable to find the issue with my code.

The error message:

  PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unsigned NOT NULL COMMENT ' AMOUNT', rate unsigned NOT NULL COMMENT 'R' at line 3: CREATE TABLE {sampletest} ( id INT unsigned NOT NULL COMMENT 'My unique identifier', amount unsigned NOT NULL COMMENT 'AMOUNT', rate unsigned NOT NULL COMMENT ' RATE', time unsigned NOT NULL COMMENT '  TIME', PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT ' table'; Array ( ) in db_create_table() (line 2717 of H:\xampp\htdocs\drupal7\includes\database\database.inc) ;

Content of the .install file :

<?php
/**
* Implements hook_install().
*/
function sampletest_install() {
 drupal_install_schema('sampletest');
}
/**
* Implements hook_install().
*/
function sampletest_uninstall() {
  drupal_uninstall_schema('sampletest');
}
/**
* Implements hook_schema().
*/

function sampletest_schema() {
  $schema['sampletest'] = array(
    'description' => t('EMI table'),
    'fields' => array(
      'id' => array(
        'description' => t('My unique identifier'),
        'type' => 'int',
        'unsigned' => true,
        'not null' => true,
      ),
      'amount' => array(
        'description' => t('AMOUNT'),
        'type' => 'bigint',
        'unsigned' => true,
        'not null' => true,
      ),
      'rate' => array(
        'description' => t('RATE'),
        'type' => 'bigint',
        'unsigned' => true,
        'not null' => true,
      ),
      'time' => array(
        'description' => t('TIME'),
        'type' => 'bigint',
        'unsigned' => true,
        'not null' => true,
      ),
    ),
    'primary key' => array('id'),
  );
  return $schema;
}


texts: Get file ID and path to use in View template

texts:
I am working in my Row style template (views-view-fields--MYVIEW--block-1.tpl.php). I need to get the file ID and path of an image. The image field is a multi field, so I need to get all of the images for each row. How do I do this?

I also will need to get the delta value of each image.

I try using kpr($variables) but I can't click to expand:


texts: Move code from template file to custom module

texts:
I would like to move portions of code from template files to custom module. But i fail do find descriptive guide for such task. Idea is to migrate complex db queries and EntitiyFieldQuery out of the tpl.php files. For example:

$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', 'predmet_clanak')
  ->fieldCondition('field_taxonomy_choose', 'value', 1 , '=')
  ->fieldCondition('field_vrsta', 'tid', 241);

$result = $query->execute();
$nodes = entity_load('node', array_keys($result['node']));
foreach ($nodes as $node) {
  print ('

');
  print drupal_render(node_view($node, 'teaser'));
  $nodelink = ltrim(url('node/' . $node->nid), "/");
  print ('
');

  $imageLink = '';
  print l($imageLink, $nodelink, array('query' => array('iframe' => 'true', 'width' => '800', 'height' => '700', 'format' => 'popup'), 'attributes' => array('class' => t('colorbox-load gumb')), 'html' => TRUE));
  print ('
');
}

This code fetches collection of nodes (when conditions are met) in custom tpl.php file. I have been advised not to create complex queries in tpl files, but do not know yet best practices to do so.

I guess, module will firstly need to know context where i want this to occur? And after i do  this in the module, do i need to pass this to the template.php first?


texts:
I have a content type = news and 5 normal page.
Content type news have 5 taxonomy term that the user can select and chose when write a news.
Each of the 5 normal page have 1 taxonomy term on it.

I want do a view (block) that show only the news that have the same taxonomy term.

My previous solution was to do a view for each taxonomy term but i don't like it because i have 5 block.

Thanks