texts: Remove Selected button not working on files generated using file_save_data

texts:
I am using file_managed field having multiple set to true. I am saving the submitted files in database table in bytea format.
buildform :
$form['test_pdf_1'] = array(
            '#title' => t('Upload Field 1(PDF only)'),
            '#type' => 'managed_file',
            '#multiple' => TRUE,
            '#upload_validators' => array('file_validate_extensions' => array('pdf'), 'file_validate_size' => array(52428800)),
            '#upload_location' => 'public://node_files/',
        );

submitForm :
if(!empty($form_state->getValue('test_pdf_1'))){
            $test_pdf_1 = $form_state->getValue('test_pdf_1');
            foreach($form_state->getValue('test_pdf_1') as $test_pdf_1_val){
                array_push($to_delete_fids,$test_pdf_1_val);
                $test_pdf_1_file = \Drupal\file\Entity\File::load($test_pdf_1_val);
                $test_pdf_1_uri = $test_pdf_1_file->getFileUri();
                $test_pdf_1_contents = file_get_contents($test_pdf_1_uri);
                $test_pdf_1_file_name = $test_pdf_1_file->getFilename();
                $push_array[] = array('boiler_req_id' => $form_state->getValue('boiler_req_id'), 'type' => $form_state->getValue('type'),'field_no' => 1, 'file_content' => $test_pdf_1_contents,'file_name' => $test_pdf_1_file_name);
                file_delete($test_pdf_1_val);
            }
        }

foreach($push_array as $val){
            $sql = \Drupal::database()->insert('node_transform')
                ->fields($val)
                ->execute();
        }

Using the above code File content is successfully saved in table along with filename. The physical file is removed from its storage location and the file_managed entry is also deleted.
Now when regenerating the file_managed field using file_save_data function the files are generated and shown properly, but the remove selected functionality is not working on the generated file. Whereas is new file is uploaded again, remove selected is working fine on the newly uploaded file.
Db query with file fields :
$results = $query->execute()->fetchAll();
            foreach($results as $val){
                $fileContent = $val->file_content;
                $destination = 'public://node_files/'.$val->file_name;
                $file = file_save_data(
                    $fileContent,
                    $destination,
                    FILE_EXISTS_REPLACE
                );
                $file->setTemporary();
                $file->save();
array_push($f1,$file->id());

File managed Field regenerated :
$form['test_pdf_1'] = array(
            '#title' => t('Upload Field 1(PDF only)'),
            '#type' => 'managed_file',
            '#multiple' => TRUE,
            '#upload_validators' => array('file_validate_extensions' => array('pdf'), 'file_validate_size' => array(52428800)),
            '#upload_location' => 'public://node_files/',
            '#default_value' => (!empty($f1)) ? $f1 : array(),
        );

What am i missing? The remove ajax is not working on regenerated file but working fine on new files if uploaded. Please suggest.


texts: Admin Module frontpage has gone - How do I get it back?

texts:
I took the liberty to upgrade to v7.25 today; four hours later (after trying to get back to where I was 8 hours before) I had to used Backup and Migrate to restore my previous v7.24. I've tried numerous update.php attempts but my Admin Module page just will not show via /admin/modules path. I can get admin/uninstall but any attempt to get back to /admin/modules gives me a black white screen so I cannot manage any modules.

Can anyone suggest a solution. I'm aware of Drush and have it to hand, but not too aufait at present (I'm on an Ubuntu desktop with localhost).

I do get a PDO error starting as:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'has_children' in 'field list':......

if that has any influence.

Thanks.


texts:
If I have a series of existing content types in a website and I want to update those content types using a new Feature module (I added some fields), what is the correct method?

Add the entire node?  Will this update the existing content type?
Add just the new and/or modified fields?

Also, these content types were originally created by hand and not by a Feature module.  I just want to add the new fields using the Features module


texts:
In Drupal 8, there is a 'Home' link in the "Main Navigation" menu provided by core. However, you can only disable this link, you cannot delete it.

How can I remove it? I don't need it and would rather just delete the menu link but the admin is prohibiting it. I had an issue where a content editor tried to set the menu link of a node to 'Home (Disabled)' by mistake - which caused a WSOD I have not yet diagnosed (somewhere when rendering the menu and/or breadcrumb on the page). Changing the menu link to <Main Navigation> root fixed this behavior, but I don't want it to happen again, so, I would like to delete it.


texts:
I created a vocabulary where terms have an image as additional field.
I want to show the image instead of the term name in the node page. How can I do this?
In Drupal 6.x, I would load the term and display it, but I guess in Drupal 7 with field API there must be a better way to do this.


texts:
I find that in Drupal 8 we can specify the submit/validate callbacks as objects. So I was wondering, if we are form-altering a certain form, how do we specify the submit callback as an object?

Like if we suppose we have a class in a file like:

/src/Form/FormHelper.php

namespace Drupal\mymodule\Form

class FormHelper {
  public static submitHelper(array &$form, FormStateInterface $form_state) {
    ... Some codes here...
  }
}

Now can I reference this function in a hook_form_alter()?
If so, how?

This is how it is done right now, like in the Drupal 7 way.

$form['#submit'][] = 'submitHelper';

Of course, this helper function was in the module file itself.

Also I'd like to ask if this is a good practice in Drupal 8 to separate these callbacks, and put them in a separate class file, so that the module file remains clean and lazy loading works properly.


texts: Store array of ids in a field programmatically?

texts:
Devel noob here. I am writing a module where I need to stash a list of entity ids in a field on a different entity. I've created a field on an entity type programmatically and have it set as field type list(integer), but I'm stuck at actually working with the field data.

How can I add/edit entity ids in the field list programmatically?

For context, this is a Commerce submodule and I am adding to a field on the line item created after submitting an add to cart form. Using dsm($form_data) in a submit handler I added to the add to cart form, I see that the line item object is already stored in $form_data['line_item'] and the data I need to get to would be stored at $form_data['line_item']->field_entity_ids. By this point, I already have my array of ids, I just need some guidance on how to store them properly in the field.

Thanks in advance! :)


texts: How to migrate field value within same nid?

texts: I need to migrate address field value to paragraph field within same nid. I have migrated address field to paragraph item, but now I need to map that previously migrated paragraph item to paragraph field. Major blocker is that I need to migration of field value within same content. Values in migration_map table is being stored but destination field value is not getting populated.


texts: How to hide a field group fieldset programmatically in drupal 8?

texts:
I have a Field Group fieldset named group_p_payment as machine name. I want to hide this based on the user. I tried the following code:

        $user = \Drupal::currentUser()->getRoles();
        if(!in_array("Administrator", $user) ||  !in_array("administer", $user)) {
         $form['group_p_payment']['#access'] = FALSE;
        }

But it didn't work it. How can I hide the fieldset?


texts: working on a website with Book Module in Drupal 7 bartik theme

texts:
I have a few questions: Using Drupal 7 , bartik theme Book module

I want each user to see the previous weight field when he wants to add a new page in a book so that they can put the weight by increasing one and it can be organized well. I wanted the body to display this but don't know how to get the values as it will be progressive and different for each book.
In spite of enabling contact form in module and adding my category and in Main menu, the contact form is not seen when clicked in menu item.
There is a Add new comment in the main content area which is not visible in the structure, blocks region so do not know where to control it from as the comments once posted are seen with the book page and sometimes not.
How to make the site more presentable as there is no place to change the appearance of the content area e.g to add a border to the main content area, or to centrally align the content, or change the color of the area where there is just the main content. I tried changing the color in the appearance and it changed the whole display area next to the sidebars and the middle area in all.
Also Is there any way I can align the book pages alphabetically as per the title?
I have the Book navigation bar put in the first sidebar and was wondering, what happens when the number of books increases than the display area? Does a scrollbar appear automatically?
I am also wondering if I should deploy the site which is still locally being made and add the changes in the hosted site? But there is a upgrade waiting but it does not allow me to upgrade as it is not available this time. Should i upgrade and then deploy? Will I have to make the changes I have made in certain files, do one more time after upgrading as the files will change too?

Thank you and I appreciate the time you will put into looking into this matter.Also u can always pick a question and answer that alone.
Urvashi


texts:
I cant find a link where I can add for people in a group to be able to leave the group.

back in the older version it was something like og/member/group_id, but that doesnt work anymore.

I'm using drupal 7 with OG version = "7.x-2.0-alpha2"


texts: How to add multiple js files in hook_field_widget_form()?

texts:
When I load two JS files using drupal_add_js() as can be seen in the code marked "After", it does not show alert() text on page load and also when I click on the button created in the form to load fancybox (popup) it shows

$.fancybox is not a function

When I just add taxonomy_fancybox.js it shows alert, so my question is
How can I make sure both fancybox.js and taxonomy_fancybox.js are loaded.

Before

/**
 * Implements hook_field_widget_form().
 */
function taxonomy_fancybox_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  drupal_add_js(drupal_get_path("module", "taxonomy_fancybox") . '/taxonomy_fancybox.js');
}

After

/**
 * Implements hook_field_widget_form().
 */
function taxonomy_fancybox_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  drupal_add_js(drupal_get_path('module', 'fancybox') . '/fancybox.js');
  drupal_add_js(drupal_get_path("module", "taxonomy_fancybox") . '/taxonomy_fancybox.js');
}

taxonomy_fancybox.js has

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

      alert('enters');

      $('#edit-select-terms').click(function (e) {

        e.preventDefault();

        $.ajax({
          url: '/ajax/fetch-vocabularies/',
          success: function (data) {
            $.fancybox(data);
          }
        });

      });

    }
  };
}(jQuery));


texts: How can I suppress "CSS file not found" errors on production?

texts:
"One or more CSS files were not found or does not exist" errors are being displayed to users on production.  Of course I should fix the source of these errors, but in the meantime, I would like to suppress this error message.

On admin/config/development/logging, I have set Error messages to display to None.  Is there some other step I need to take to suppress these errors?

I have also cleared all caches (Drupal, Redis, Varnish) but the error (only present on some pages) is still being displayed to authenticated (non-admin) users.


texts: add field in admin>content that show if entity is translated

texts:
I'm looking for a field that i can add in the admin>content view.
I want to know if the entity (News items) is translated or not. (Dutch(default) and English)
Now i always have to click edit article to see if the article is translated.

Search for hours on the internet but no result.  (i did installed the admin view module so i could edit the admin>content view)

Hopefully someone could help me out with this.


texts: How to remove marker from openlayers map

texts: I have Drupal 7 installation with Openlayers and Geofield (I am using Openlayers as the widget for Geofield). I am able to add new points and show them on the map, however I am not able to remove points from the map once they are edited. I guess that the answer might be pretty simple and I might be doing something wrong, however I can't figure it out!


texts: RuntimeException: Unable to determine class for field type found in the configuration

texts:
My website got this error, while updating from Drupal 8.3.7 to Drupal 8.4.0, and I am unable to solve it.

  The website encountered an unexpected error. Please try again later.
  RuntimeException: Unable to determine class for field type 'webform' found in the 'field.storage.node.webform' configuration in Drupal\field\FieldStorageConfigStorage->mapFromStorageRecords() (line 157 of core/modules/field/src/FieldStorageConfigStorage.php).


texts: How can I add custom field validation for one of the fields "within" an addressfield?

texts:
I'm attempting to implement one of the answers to this question on validating whether there no double-byte characters present.

Here is what I've done so far in my custom module:

function CUSTOMMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'profile_gen_node_form') {
    $form['#validate'] = 'CUSTOMMODULE_location_doublebyte_validation_handler';
  }
}

And then:

function CUSTOMMODULE_location_doublebyte_validation_handler($form, $form_state) {

This is where I'm stuck.  Addressfields include much more information than normal fields; they seem to be like a collection of fields.  Here is a screenshot of the output of dpm($form):

I want to check strlen() and drupal_strlen() of the value of the "locality" piece of my addressfield but I can't figure out how to do that.

I tried something like this:

if(strlen("field_gen_loc_current['und']['0']['locality_block']['locality']") !== '0') {
    form_set_error('locality', t('No double-byte input.'));
}
}

But, while this doesn't produce an error, it also never causes the validation to fail.


texts: Display add to cart form / +product from node template

texts:
I have a custom node template based on a custom content type and I want to display products with their "Add to Cart" buttons from this custom node template.

In the content type (actually a field collection), I added the Product reference. In the template (node--{content type}.tpl.php) I do this type of thing:

$wrapper = entity_metadata_wrapper('node', $node);
// Since it's a field collection, I loop these:
foreach ($wrapper->field_content_group as $group) {

  //Now each "$group" has the fields I want to display

  //I permit N products (not just 1), so I can get product information,
  //like price for example, like this:

  if($group->field_featured_product) {
    $product_references = $group->field_featured_product->value();
    foreach($product_references as $product_reference) {
      $product = commerce_product_load(intval($product_reference->product_id));
      $price = entity_metadata_wrapper('commerce_product',
                                       $product)->commerce_price->value();
      print $price_display = commerce_currency_format($price['amount'],
                                                    $price['currency_code'], $product);
    }
  }

}

I don't need to alter the display, I'm happy with that. I'd like to just call something that prints the product, price, etc., along with the "Add to Cart" button. I'm thinking I call commerce_product_load and then some method(s) that gives me the completed form. Is there such a thing that I can call?

NOTE: Yes, I know about separation of concerns and that code is best placed outside of the template file.


texts: Group entity reference field by a field on those entities

texts:
I have a content type of Location that has a list (text) field with options for Full Service or Quick Stop.

On another content type, I have an entity reference field that pulls in all the locations (using a select list widget).

On the node creation/edit form, I am trying to group those locations with optgroups into Full Service and Quick Stop based on the value of the nodes in the entity reference field (i.e. a location with field_location_type of "Quick Stop" would go into the Quick Stop optgroup).

Right now I am manually sorting them with the following, but it would be nice to do it automatically via my field_location_type field so that new options are automatically added.

$form['field_location']['und']['#options'] = array (
   'Full Service' => array(
      19 => 'Main Street',
      20 => 'Oak Hills',
      21 => 'Cherry Trail',
    ),
    'Quick Stop' => array(
      22 => 'Montreal',
      26 => 'Washington Place',
    ),
);


texts: How can I trigger a rule when there's no more scheduled content?

texts: I have a Drupal 7 blog where I write content in advance and publish it using the Scheduler module. I'd like to be able to write a rule to send me an email when the site has published the last scheduled node available. I have a View set up which lists all the scheduled nodes, but I can't figure out how to get the result count of that view into the condition of a rule. I've got Views Bulk Operations and Views Rules installed, but I can't figure out how to use either of those how I need to.


texts: Exclude from displaying, when we fetch data from db

texts:
My requirement is like: I am retrieving some data from 2 tables of a db,and displaying. Now I want to exclude from displaying,those data which is not present in third table. So how can i achieve this please suggest me. I tried like following code,after this I am not getting.

 function viewlist_boatpassengers(){

    if((isset($_COOKIE['viewlistsuccess']) && ($_COOKIE['viewlistsuccess'] == true)) || (user_is_logged_in())) {
      $result = db_select('capcup_boat', 'n')
          ->fields('n', array('boat_id', 'boat_name', 'contact_person_first_name', 'contact_person_initials', 'contact_person_surname'))
        ->execute();
        while($record = $result->fetchAssoc()) {
          $listresult['boats'][] = $record;
        }

      $result = db_select('capcup_passenger', 'n')
          ->fields('n', array('passenger_uid', 'passenger_fname', 'passenger_insertion', 'passenger_lname'))
        ->execute();
        while($record = $result->fetchAssoc()) {
          $listresult['passengers'][] = $record;
        }

      $result = db_select('capcup_boat_to_passenger', 'n')
        ->fields('n', array('passenger_uid', 'boat_id'))
        ->execute();
        while($record = $result->fetchAssoc()) {
          $listresult['boatpassengers'][] = $record;
        }

      if(isset($listresult['boatpassengers'][0]['passenger_uid'])){
        echo '<pre>'; print_r($listresult['boatpassengers'][0]['passenger_uid'])  ;exit;

      }
      echo '<pre>'; print_r($listresult)  ;exit;
      $list_page = theme('viewlist_boatpassengers',  array('listresult' => $listresult));
      return $list_page;
    }

If passanger_uid is present in the capcup_boat_to_passenger table then that data should not displayed.


texts: Can I add a description for Ubercart catalog categories?

texts:
I am working on an Ubercart store with several products with a hierarchy of categories.

I'm wondering if it is possible to add a description at the top of the catalog page for each category?

I know that each category is a taxonomy term with which I can set its description, but I can't see any way of displaying that. I've also looked at the option of using a custom block and using a token in the block body but tokens don't seem to be recognised in the block's body.

Any ideas?

Thanks,
Alan


texts: Extend twig template from differnt theme (parent)

texts:
I created a sub theme of the bootstrap theme. In one of my twig-files I would like to extend a twig template from the parent like this:

{% extends '@bootstrap/menu/main--main.html.twig' %}

This doesn't work and I'm getting the message that main--main.html.twig is not defined.


texts: Ubercart - Sale approval required before payment

texts:
Durpal  6, Ubertcart 6.x-2

We are selling table space to vendors at an upcoming convention. We want to let them apply but wait for admin approval before they can pay. I've been searching for several days but cannot find a solution.

Is there a way to require admin approval of a sale before moving to the payment process?

Edit: I have no way of telling that they are vendors until they purchase a vendor table.


texts: How do I avoid the maintenance screen on database errors?

texts: As I'm working on a D7 site, I'll occasionally hit a database-related bug in my code. When this happens, I get thrown to a version of my site's maintenance page; the error information doesn't show up on the page, but just in Watchdog. This makes sense for a production site, but it's a pain during development. Is there any way to turn this behavior off, so that the error messages show up on the page I'm working on? Thanks!


texts: Relative links on local setup not workin

texts:
Im currently working through some problems putting a drupal 6 site I inherited onto my local machine for testing and development purposes. My server environment is IIS7.5 and I am working with a drupal 6 installation

The latest problem I have relates to some (but not all) links on the site

on my local site my links are resolving to a URL www.example.com/ whereas I want them to resolve to localhost:456
but on my live site those same links seem to be relative as when I type in the IP address of the server all the links in the site look like 159.xx.xxx.xx/page-title and if I put in the URL they all look like example.com/page-title

~I have set teh base_url in settings .php to localhost:456 in my local set up.

I cant understand how they are relative on the live site but seem to be hardcoded on the local site?

the links are being created like so:

l(t('Trading Platforms'), 'product', $menulnk_class);

all help greatly appreciated


texts: How use feeds importer to pull inline images into node page

texts:
I've looked at the feeds image grabber module, but it sounds like this will place the images in associated fields on the node. The client really wants the images to be inline. I'm using Feeds, Feeds Importer with the Common syndication parser. The field I'm mapping to is Text format: Full HTML.

This seems like it should be a solved process, I'm just not sure what direction to take.


texts: Drush not being found although installed [ubuntu 11.04]

texts:
Utilising an Ubuntu (currently 11.04) box for WebDev in my SoHo, it's primarily for Drupal V7 projects using pure Linux LAMP and not any xamp, wamp models. I have a number of Drupal installs for dev and self-learning etc and hence Drupal version installs and modules change. I installed Drush 4.4 via the Ubuntu Synapatic manager and it installed seemingly ok, but when I try to run Drush from the Dash Home (HUD), nothing appears to load or run.

I'm the only user on the computer so I have all priviledges etc and all my Drupal projects are in var/www/ in order to emulate any future live web models. In order to be more efficient in updating Drupal and modules, I'd rather use Drush for Drupal updates as updating 6-8 projects is too labourious. Can anyone shed some light on why Drush is/or not running and what I need to do to simplify it's loading (a simple desktop link creation would be great). My current Linux experience is some 24 months having crossed over 100% from MS Windows O/S, but my DOS CLI experience was also then poor, so my knowledge was limited (but growing). Thank you.


texts: What variable is responsible for the default admin bar on top of every default Drupal theme?

texts:
This is basically my html.tpl.php -

</head>
<body>
<?php print $page; ?>
</body>
</html>

What do I need to add to make that horizontal admin bar appear?


texts: How to hide views UI reaching number of limits of searches

texts:
I'm developing a D8 site. I am using a custom views plugin to query data from a remote api by searching a business ID.

My scenario: User is only allowed to enter 3 attempts of business ID in a search view. If 3 attempts fails, I want to hide the views UI from the page for 24 hours. What's my purpose? To give difficulty for others to guess my business ID.

This is a duplicate question with: How to use Rules to limit the number of searches to pull data from a remote API, but on another perspective.

I wasn't able to implement it using Rules, and I'm guessing if we can do it on front-end coding. Does anyone have an idea to implement this?


texts: Best way to define entity and additional custom logic (CRUD) in module

texts:
I want to create a new content type, e.g. company. This company needs an additional field which is a multiple file upload field. When the full node of the content type is displayed, I want to run some code in a controller which reads the uploaded files, executes logic and sends information to the twig template. However I'm unsure how to proceed. As far as I can see there are three options (of which the first isn't really an option):

I can create an entity type through the admin interface, and create a new node.html.twig template file, however this lacks the ability to execute custom PHP logic and send the information to twig, as i only have the twig template.
I can create a content type in a module and define the fields through the admin. If i understand correctly, this can be done through drupal generate:entity:content with the Drupal Console.
I can create a module in which I define the content type, and hard-code all the fields. This is less flexible but maybe a stronger option: if something happens with the database I don't have to recreate the structure.

Both option 2 and option 3 can be viable. I've used Symfony2 before and using that I would take option 3, however it seems this option is over-complex in D8. If I understand correct in D8 fields should be defined through the admin interface. And a custom template can be created in the module eventually.

How should i tackle this issue? Which option is best? What is the best way to create a controller, which is used in displaying an entity/content type which is created via the D8 admin interface?


texts:
i setup two sites site 1 and site 2 by using drupal multi site functionality.site1 i consider as the master site and site 2 consider as the slave. some contents in both sites have similar content.when updation made in site 1 its reflect in site 2(only similar contents) for this i try to share the DB. while i try to execute following steps i get following error while i see the site pages

"You are not authorized to access this page. "

i follow this steps:

1.create a db prefix like this $db_prefix = "master_" in site 1 and $db_prefix = "slave_" in site 2.

i set the cookie $cookie_domain = 'site2'; in site 1.
Then i add prefix like way in site 1
$db_prefix = array(
node' => 'master_',
'node_access' => 'master_',
'node_counter' => 'master_',
'node_type' => 'master-',
);

above thing i did site2 also instead of using 'master_' i use 'slave_'
is there any thing missed out in my con fig.any one guide me do this.
thanks......


texts: Products do not show under category in Commerce Kickstart

texts:
I am building a site on top of Commerce Kickstart, no demo.
I created a category, but when creating a product of that content type it does not show under the category.
I do provide a menu link to the product but it still does not show.
I can see it from Manage Products.
What am I missing?


texts: Installation profile similar to openatrium but focusing on projects

texts: I'm looking for an install profile (or Drupal based app) similar to Open Atrium, but focus on projects rather than on contacts and tasks; something that is similar to Basecamp.


texts: How can I stop the cron tasks from being triggered by site visitors?

texts:
My site's logs show that cron is triggered if someone visits the website. This is slowing down the load time for the first visit.

The cron is configured to run each 3 hours here: Administration » Configuration » System » Cron.

How can I run the cron scheduled and not triggered by visitors?


texts: I created a field with the field type "file" I now have to convert this to "image" field type. The field has already content so I cannot not delete and recreate a new one. How can I do this programatically using the hook_update in my module?


texts: Having trouble understanding hook_theme()

texts:
I'm going through the Drupalize.me tutorials on module development, but I've come across something that has me a little stumped. In the module, called "spy_glass", we created a basic theme hook like so:

function spy_glass_theme() {
  return array(
   'spy_glass_item' => array(
       'arguments' => array('title' => NULL, 'data' => NULL),
       'template' => 'spy-glass-item',
    ),
  );
}

Which is all well and good. It eventually gets called by spy_glass_page() which uses the theme hook to create to loop through an $information array, which is formed elsewhere and consists of 2 keys: title, and data.

function spy_glass_page($node) {
    $information = _spy_glass_serious_spying_business($node);

    $content = array();
    foreach ($information as $item) {
        $content[] = array(
            '#type' => 'markup',
            '#markup' => theme('spy_glass_item', $item),
        );
    }
    return $content;
 }

All good. Everything works as expected later when its passed to a spy_glass_preprocess_spy_glass_item() function and printed to a template. But here's what I don't understand. What the heck is this line of code doing in spy_glass_theme():

 'arguments' => array('title' => NULL, 'data' => NULL),

I've removed it and it literally changed nothing at all. Everything still works perfectly. What is the purpose of this?


texts: How do I create a multi-select checkbox field in a content entity?

texts: Trying to figure out how to have 'Desktop', 'Mobile', and 'N/A' as check boxes on a config entity form in drupal 8, where I can select one or more options.


texts: Getting the user ID of the user who created a taxonomy term

texts: I need to get the user information of the user who created a taxonomy term. How can I get it?


texts: After drupal 6> 7 upgrade attached pdf links not visible

texts: After upgrade fromn 6 > 7  attachment information is not visible in nodes.  Data exists in dbase.  What is best approach to re-connecting pdf, mp3 and other attachments to specific nodes. (2000 or so)


texts: Skip checkout process if special field has value

texts:
I want to skip the checkout process and node has bin publish for free product, but my module is not working!

Any pointers greatly appreciated

<?php
function MYMODULE_node_submit($node, $form, &$form_state) {
  global $user;
  if (in_array('administrator', $user->roles)) {
    if ($node['field_noeagahi']['und']['0']['value'] = 1) {
      $form_state['values']['commerce_node_checkout_skip'] = True;
      $node->status = 1;
    }
  }
  return $form;
}


texts: delete users and all its related records

texts:
Is there a way I could run mysql query from the backend to delete all the users and its related records except master-login.

There are some modules that help to do it or a via drush command but I am trying to do this from the backend database.

I am not sure about the how all the tables are maps. instead of figure it out I am trying to get a quick help here.


texts: Drupal 7 Views url translated alias with contextual filter

texts:
I want to translate the url of my view. So I've made a translated alias for it. But when I add a contextual filter I get a 404 error.

For example: I've a view with the url example.com/overview with alias example.com/overzicht this works. This works also example.com/overview/[category], but this doesn't work: example.com/overzicht/[category]

How can I fix this?


texts: How do I add a link to a menu from a module in Drupal 6?

texts:
I'm creating a drop down menu with nice menus, but I'm having a problem programatically adding a link to the menu from modules. I have defined the menu in the Administration section under Site Building > Menus and can get it to work fine if I add a link manually, but I can't get any links from modules to show up. Here is my code from module_menu():

  $items['node/%node/jobs'] = array(
    'title' => 'Jobs',
    'page callback' => 'job_applications_form',
    'page arguments' => array(1, 'node'),
    'access callback' => 'job_applications_user_access',
    'access arguments' => array('site_owner', 1),
    'menu_name' => 'menu-dealer-menu',
    'type' => MENU_NORMAL_ITEM,
  );

The menu's name is menu-dealer-menu. I am using Drupal 6, and upgrading to 7 is not an option right now, and won't be for the next couple of months.


texts: How to flag a View's item (with AJAX) when hovering or clicking it?

texts:
In my previous question How to mark a Message as 'viewed' when a user sees it in a View?, I explained that I'd like to flag a Message when it's hovered or clicked in a View. @Geoff suggested to create an AJAX callback in his answer, but I've no idea how to accomplish that.

How can this be done? Is this the easiest approach?


texts: Adding custom content to sidebar in admin section's node edit page

texts:
I want to add a custom image to the sidebar of the edit node page in the admin section.

Is there a hook that can allow me to do this?

Edie: I should point out the the image I want to show is dynamic and will be different for each page - determined by a conditional statement which will need to have access to the data of the node I am editing.


texts:
I’m running Ubuntu 14.04.5 with Drush v 8.1.8 and I can’t seem to execute Drush without using sudo. For example if I try to execute ‘drush cc all’ without sudo, I get:

‘Directory /home/myuser/.drush/cache/default exists, but is not writable. Please check directory permissions. ‘
‘Directory /home/myuser/.drush/cache/complete exists, but is not writable. Please check directory permissions.   ’

If I then manually modify the permissions on .drush and everything under it to 777, the next Drush command will work but the one after that will fail with the same error. I also tried ‘chown -R myuser:myuser ~/.drush’.  Same result.

I thought perhaps I installed Drush incorrectly, so I tried removing and then re-installing it three different ways:

Using this approach: https://www.drupal.org/node/1248790 (sudu apt-get install drush).
This way: http://docs.drush.org/en/master/install/ (executing php to load Drush from a remote file)
Finally by installing Drush using method (2) and then moving Drush into my home/bin folder and chown -R to me.

All of them have the same result — drush doesn’t work without sudo. There’s no reason I can think of why this should be. What’s even weirder is if I chown of .drush (and everything under it) to me, then execute drush without sudo, it will change ownership of directories under .drush/cache to root. I don’t even know how that’s possible since I’m not root!

Please let me know how I can get Drush to work without root privileges.
Thanks.


texts: Drupal Commons add a view handler to display all subgroup content of a group entity

texts: I've search a lot about how to add a view handler to display all subgroup content of a group entity (og_group module) for Drupal Commons 7.x-3.30. But with the answers that i've found sincerely i couldn't accomplish nothing... i.e. this https://www.drupal.org/node/1997988 Other suggestions? Thanks a lot for your precious help


texts: How to handle refunds / returning goods with drupal commerce

texts:
i'm just trying to figure out whatcould be the bestway to handle "refunds" and the return of the shipped goods with Drupal Commerce.
Is there some custom modules for that?How would you handle this case?


texts: Use another field value as condition in Entity Query

texts:
I'm performing in Drupal 8 an entity query that searches for nodes that have not been changed since x days, where x is a numeric node field (node.field_days).
So I would like to perform a query like:

$query = \Drupal::entityQuery("node")
  ->condition('changed', strtotime('-node.field_days days'), '<=');

I know that condition takes as value a string and not a db column, but is it possible to use entity query with a dynamic value?


texts: Static page on main domain and Drupal on subdomain

texts:
In my installation, I'm utilizing Drupal's awesome capability to run on multiple subdomains using one code base. Each subdomain has its own database. So, I only need to have a static page on the main domain (root) but Drupal running on subdomains.

How do I do that? I know that I could modify the .htaccess file to make it look up for index.html first, but that would affect the subdomains.

Thanks.


texts: How to promote nodes to front page using MySQL command line

texts: What is the command to promote unpromoted nodes to front page using MySQL command line? I want to promote 200 nodes at once. The node type is "story."


texts:
I am running Drush version 6.2.0 and the latest Drupal 8 beta on Dreamhosters. When I run drush cc all within the sites directory, I receive the following error immediately after executing the command:

  Fatal error: Class 'Drupal\Core\Session\AccountInterface' not found in
      /home/mywebsite/mywebsite.com/core/includes/bootstrap.inc on line 63
      Drush command terminated abnormally due to an unrecoverable error.

  Error: Class 'Drupal\Core\Session\AccountInterface' not found in
      /home/mywebsite/mywebsite.com/core/includes/bootstrap.inc, line 63

Why does it happen? How can I fix this?


texts: How to get node content in an sql query?

texts:
I see that in D6 the node table has only the title of the node. How to query database to get  the body (content) of a particular node?

Update: I figured out the content bodies are stored in node_revisions table.


texts:
I'm cutting my teeth on custom view templates.. specifically:

views-view-table--MYNEWVIEW.tpl.php

I've copied the default template code into this file. When it's looping through the rows, building the table cells, I'm not sure how to tell which field I'm on to be able to put that single field on a new row.

Here's a link to what I'm trying to accomplish.

Views - Custom Field Layout?

Obviously, I'm not very knowledgeable yet on modifying view templates, so I'm hoping someone could direct me to resources/examples of working with the various variables available. I've enabled the Devel module and have sprinkled  snippets around, but I'm not grasping how I would tell which field is current in the foreach loop.

Thanks. Bill


texts:
I am using field_view_field() to render a product image.
I have a condition where I want to display only one image for the product not other images of that product. How can I do this?


texts:
I'm currently converting some of our custom forms API elements into Drupal 8 equivalents, however I'm running into a couple of issues.

Firstly I don't seem to receive a 'triggering_element' back in my $form_state in the element process, it's there in the ajax callback - but not in the process, it was there in D7 and allowed me to implement different logic in the process function for different buttons / form controls being used. I'm not sure if there's a different way to grab it but $form_state->getTriggeringElement() returns null whilst in the element process, even if it's processing following an ajax event.

Secondly the $element['#id'] changes on each process now, as there could be multiple instances of this element within one parent form I was using the ID as a means of trying to ensure each ajax wrapper was unique. Now that the ID changes the ajax request works once, then never again (as the #id has changed, but the wrapper/container in the markups ID is the same). Is there a different way I should be targetting my wrappers in D8?

I've stripped down and included some of the code which will hopefully offer an insight into what I'm doing.

Any assistance would be greatly appreciated!

class AddressSelector extends FormElement
{
  public function getInfo(){
    ...
  }

  static function test_module_address_selector_process($element, &$form_state, &$form)
  {
    $element['postcode'] = array(
      '#type' => 'textfield',
      '#title' => t('Please enter your postcode and click find address'),
    );

    $element['lookup_btn'] = array(
      '#type' => 'submit',
      '#value' => t('Find address'),
      '#ajax' => array(
        'callback' => 'Drupal\test_module\Element\AddressSelector::test_module_address_selector_lookup_cb',
        'wrapper' => $element['#id'] . '-lookup-wrapper',
       ),
    );

    $element['wrapper'] = array(
      '#attributes' => array(
        '#id' => $element['#id'] . '-lookup-wrapper',
      );
    );

    $entered_postcode = isset($element['#value']['postcode'])
            ? $element['#value']['postcode'] : FALSE;

    if($entered_postcode){
      $address_opts = test_module_lookup_postcode($entered_postcode);

      $element['wrapper']['select_address'] = array(
        '#type' => 'select',
        '#options' => $address_opts,
        '#title' => t('Please select your address'),
      );
    }
  }

  static function test_module_address_selector_lookup_cb($form, &$form_state){
    $f = $form;
    $triggeringElement = $form_state->getTriggeringElement();
    // I'm unsure if there's a neat way to do this - I need to find this 'instance' of the element in the
    // parent form so I'm able to return the correct chunk of form, in this case the wrapper.
    for($x = 0; $x < count($triggeringElement['#array_parents']); $x++){
      $f = $f[$triggeringElement['#array_parents'][$x]];
      if($f['#type'] == 'address_selector'){
        $ele = $f['wrapper'];
        return $ele;
      }
    }
  }
}


texts: Admin denied access to Ubercart Store when running Ubercart SSL

texts:
I am running the Ubercart SSL module (not Secure Pages) for my Drupal 7.12 site.  I am unable to checkout an order as admin, and I get an access denied message when I try access my store.

Ideas?


texts: How to hide exposed sort if view return empty result?

texts:
I have a view with an exposed filters and sorting. They are displayed as a separate block.

I want to hide only sorting widget if view return empty result (filters must left)

How to achieve this?

The problem is that when exposed form is rendered its view isn't executed yet - so i can't determine if view has any result.


texts:
I have a Drupal 7 site, where there is a normal static block at the top of my content region. This is basically an advertisement with some full html content. Now I want to have a second similar block, and I'd like to keep them switching periodically somehow.

Before jumping on to coding something with javascript, I'd like to ask around to see if there is any easy solution for this, maybe a module for rotating ads?

(I know there are some themes that come with this feature out-of-the box, but I like my theme, so would not switch that for this minor thing)

Thanks!


texts: We are planning to provide an RSS feed (from a Drupal site) to someone who is going to display it on their site. Is there a way to limit access to only this specific site or maybe provide an embed code they can use to display the feed on their site?


texts: how to use a relative path with form API image_button?

texts:
I'm building a module in D6 that renders a form to a custom template (also within the mod).
I need to use an image for the submit button, but I'm having trouble with the path to the image.

$form['submit'] = array(
'#type' => 'image_button',
'#src'  => 'sites/all/modules/custom/mymodule/images/show-my-score-button.png',
'#value' => t('Show My Score'),
'#submit' => array('mymodule_submit'),
'#redirect' => '',

);

This is the code I have in place, and it is functional. However I can't use the path as it's shown since I don't know where my module will end up.

How can I make the image show in my module while using an image path that is relative to my module?
I'd love to have something like "/images/show-my-score-button.png" but it doesn't work.


texts:
I know we can easily redirect a path to another path with Redirect module, but what I want to do is more complicated,  my condition is when the user has a specified IP and the route is matched with to a specified path redirect it.

Pseudo code what I'm looking for is

if $path='xxxxx' and $user_ip = 'yyy.yyy.yyy.yyy' redirect to 'zzzzz'

how I can implement this, what I need is where is the best place to implement this?


texts: "An AJAX HTTP error occurred" when sending an email via VBO (view bulk operations)

texts:
An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /batch?id=42348&op=do StatusText: OK

Running Drupal 7, using amazon SES to send emails. Get the above error message every time I send an email via VBO which is bizzare because the message response code is 200, the status is OK and the email is successfully sent.

Any idea why I might be getting these errors?


texts: Ubercart Authorize.Net checkout loops back to cart page

texts:
I am trying to process an Ubercart order using Authorize.Net. I go through the Checkout and Review pages. When I submit the cart for credit card processing, I get returned to the Checkout page.

The only error I can find is:
    page not found  09/23/2014 - 17:39  cart/sites/all/themes/metroblocks/images/int.png

I think maybe the cart solution has an incorrect relative path somewhere to go to cart/../sites/all....

At one time I tried getting Commerce to work, but couldn't install Kickstart. I deactivated Commerce, but didn't uninstall it. Don't know if there is a conflict between Commerce and Ubercart.

Could someone please explain how I might troubleshoot/resolve this issue?

Using Drupal 7.32, Ubercart 3.7 on a shared hosting server, Apache2.


texts: How to add a field widget for multiple file upload?

texts: Is there a module that provides a multiple file upload (Drag and Drop) widget? If there isn't, how can I build one? Will it require a special setup for the server stack (LAMP)?


texts: Is there way to rearrange node on front page?

texts: I tried use weight module but it arrange node only on admin interface. Is there way set weight to node on front page?


texts: Where is the interface for translating strings that modules pass to t(), in Drupal 7?


texts: Filter content by field with multiple values and different content type

texts:
I have 3 different content types:

exhibitions
events
programs

All 3 content types have a hashtags field (a taxonomy term field).

I have a view with the following filter criteria.

content type = "exhibitions, events, programs"

I created another content type (general hashtags) and it's only possible to create a single node of this content type.

This content type has a filter hashtags field (another taxonomy term field), where users enter all the hashtags they want.

I have a page called "hashtags" and I want to show all content filtered by the filter hashtags field, but I have four different content types.

I tried:

filter criteria: "filter hashtags" is one of (options), is all of (options)
relationship: hashtags and contextual filters: filter hashtags (tried with "taxonomy term ID from URL" and "content ID from URL")
relationship: filter hashtags and contextual filters: hashtags (tried with "taxonomy term ID from URL" and "content ID from URL")

None of them works.

Is there a better way to achive this filter options?

I don't want to expose filters to visitors. I want a BO option only.

Edited -------------------------------------------------------------------------------------------

Maybe this can help to explain better my problem.

I want to achive the same result as exposed filter, like this eg.

BUT I don't want to expose this filter, instead I want this option as backoffice option where content editor can choose what hashtags will appear/filter.


texts: Is there a way to remove a menu item from the active trail without removing it from the menu parent?

texts:
I'm a relative newcomer to Drupal and I'm not sure how to handle this. On this page:

http://staging.stvincentdepaul.net/volunteer

You can see that Volunteer is highlighted in the main nav but so is Today. If you hover over those L1 links, you'll see that each one has a Donate and Volunteer button. These are all part of the main navigation menu in the admin section so each Donate and Volunteer button falls under each L1 link. The Today section was the last to have Donate/Volunteer added so it is attaching the active-trail class to that link since it can only have one.

Is there a way to keep those Donate/Volunteer links in the menu but not part of the active trail?


texts: Searching for a general approach for passing custom lists of node IDs as an argument to Views 3.x

texts:
I need often to exclude (or limit to) a custom list of nodes from a view. I used to enter the PHP logic directly in the php argument code text area, but this is getting difficult to mantain. I would like to store the logic in a module or template.php.

What I need is a general approach for returning a list of nids (nid1+nid2+nid3...) in the php argument code of the view.
I have tried using the approach described here, but I can make it work only for block displays, not for page displays.

For example, I have a content type where nodes can arbitrarily be restricted to authenticated users using the Content Access module per-node settings. I need to display in a view only those nodes, excluding the ones that are visible to the anonymous users. Since there is no filter for this in views, I have built a simple function to retrieve the node IDs and store them in a variable (nid1+nid2+nid3...).

I am struggling to find out where to put this logic (theme_preprocess_views_view(), custom theme_preprocess_func(), mymodule_preprocess_func(), etc.) in order to be able to use this variable in any view PHP argument code.

TL;DR: I need a general approach for returning a list of nids (nid1+nid2+nid3...) in the PHP argument code of the view, saving the php logic in a module or theme.


texts: How to allow users to 'add' values to a multi-value field but not edit any previously add values?

texts:
I have a field called 'Remarks' on an ECK entity (not a node) and Role A is allowed to leave remarks but I don't want them to edit previous remarks, I just want to give them the option to add one. Note: they are not the author or owner of the entity. Right now, I use an Edit Page Variant for this entity that they have access to and where this form for 'field_remarks' appears. The problem is that the previously added remarks are still showing up and therefore now they can still edit someone else's remarks.
potential solution 1
I would probably be possible to hide the fields that already contain values with jQuery but that is not really the Drupal way, I believe.
potential solution 2
Could it possibly be done with a Rules component that adds the value (text) to this field programmatically? And if so, how and where to show a text field that would accomplish that?


texts: Set entity reference target_id in migration yml

texts:
I migrate Drupal 6 to Drupal 8. In Drupal 8 I have content type that has field with type Entity reference that reference specific taxonomy dictionary. I can't find out how to set Entity reference field target_id in yml migration file. I have tried:

field_my_field:
  plugin: iterator
  source: field_my_field
  process:
    target_id:
      plugin: default_value
      default_value: 19

I would expect that code above set Entity reference (field_my_field) to reference term with id 19 (that already exists). There is no error (or message) and default_value plugin is called correctly a returns 19. But in migrated content is not reference set.

I tried to set reference manually and then dump it and result was:

[field_my_field] => Array
  (
    [x-default] => Array
      (
        [0] => Array
          (
            [target_id] => 19
          )
      )
  )

I have tried lot of other ways how to set entity reference target_id but nothing actually work. Do anybody know how to set entity reference target_id in migration yml file?


texts: The website encountered an unexpected error due to installing custom module

texts:
I have created and installed custom module without additional code[with mymodule.info and mymodule.module].But after I created

  mymodule.links.menu.yml and mymodule.routing.yml i am grtting error like "The website encountered an unexpected error" code mymodule.links.menu.yml

   mymodule.admin_form
     title: Upload IELTS Test Dates
     parent: cedar.admin_index
     weight: 100
     route_name : mymodule.admin_form

and code inside mymodule.routing.yml

 mymodule.settings:
   path: '/admin/config/services/migs'
   defaults:
     _controller: '\Drupal\quotesapi\Controller\MymoduleController::settings'
     _title: 'My module settings'
   requirements:
     _permission: 'administer site configuration'

I checked the watchdog and found a RouteNotFoundException. How do I fix this?


texts: How do I add attributes to CSS in theme.info?

texts:
I'm try to add a stylesheet switcher.  This requires the following CSS files to be included on the site.
<link rel="stylesheet" type="text/css" href="styles1.css" title="styles1" media="screen" />
<link rel="alternate stylesheet" type="text/css" href="styles2.css" title="styles2" media="screen" />
<link rel="alternate stylesheet" type="text/css" href="styles3.css" title="styles3" media="screen" />

theme.info reference some CSS files. How can I a rel and title attributes?
stylesheets[all][] = common/css/small.css
stylesheets[all][] = common/css/medium.css
stylesheets[all][] = common/css/large.css


texts: How to make Drupal instance store the files as "public:"?

texts:
I am trying to use the http://drupal.org/project/gdoc_field module but it is not working as appearently Google can't access them... I am uploading them from my machine by using the browse functionality.

How do I make the files uploaded via this Field type public, so they are accessible by Google and therefore display in an iframe?


texts: Creation + Drag and drop of groups of fields with CCK

texts:
I have an image field with unlimited number of values but they relate to each-others in sets like this:

1a
1b
1c
2a
2b
3a
3b
3c
3d

My goal would be to create a text field before the first image of each set and to be able to drag and drop each set without effecting the order inside each set.

It would look like this:

Header for 3
3a
3b
3c
3d
Header for 1
1a
1b
1c
Header for 2
2a
2b

Is there a module that provides a similar functionality?
Unfortunately multi-groups doesn't cut it for me because it just pairs the text field with the image field...


texts:
I'm using form_alter to play with the node form for a specific content type. This content type has many different fields and I'm also using Field Collection module to organize all these fields & logic, if that makes any difference.

Apparently, there are some incompatibilities between the Field Collection & Field Dependencies modules so I thought I might be able to build a similar field dependency functionality with my own module.

I've created a validation function for the form. My problem is that I'm trying to access $form_state values that users insert in the form in order to validate these values but I think I'm doing something totally wrong here:

function _mymodule_my_validation_function($form, &$form_state){
    $short_field_name = $form_state['values']['long_field_name'];
    if (empty($short_field_name) || $$short_field_name == '') {
        form_set_error('error','That field cannot be empty!');
    }
}

Unfortunately this validation script doesn't work. To be more exact, I

dpm($form_state);

in my form_alter and $form_state doesn't even contain 'values' (shouldn't it be present but empty?).

Is there a different best practice for validation node form fields instead of dealing with the $form_state['values'] array?

Also, I need to be able to see the values submitted by users each time the node form is submitted. Currently, I dpm($form) in my form_alter function and everything is returned on the node/%/edit page as expected. But how can I catch submitted values on the node/% page after submitting the node form??

Update:
When I call dpm($form_state) within my validation function I get what I need if the form doesn't validate (as we still are on the same node edit page). But how can I receive the (new/changed) values that users entered in the form fields in case the form is submitted successfully and user is directed to content list page?


texts: When the admin changes(Add/Remove) roles of the user, how to get assigned and removed roles of that user?

texts: There are more than 20 user roles(Editor,approver,new admin..) in the  project. Whenever the admin assign/delete the role to user then the user should be notified with email. Email should say Hey Prabhakar You have been assinged to following roles or you have been removed from following roles.


texts: Moving the Up/Down Vote Widget to end of content

texts:
I am brand new to Drupal but not to OOPHP.  I am assuming responsibility for a site which uses Up/Down Vote 6.x.

The issue is that the posts are very long and hold many many images and it doesn't look like the module supports any widget position other than at the top of <div class="content">.

I would like to move it to just above the footer links of the node, after the content.

I have been googling this without success.  Can anyone advise me or direct me to the relevent docs?


texts:
Im making a CMS for a client who will be copying and pasting content into the body of nodes. I want to remove certain markup from coming through (eg inline styles) but allow other markup (p and br tags).

With the html filter I can stop certain markup being displayed but its still there in the content when you edit the node. Is there a way of stopping some markup from coming through at all? Thanks


texts: how to enable actions of workbench moderation in node edit screen

texts: I am unable to bring actions (Unpublish this revision) in node edit screen. How to bring state change setting in custom node edit form


texts: How to programmatically add default values to existing nodes of a specific content type

texts:
On a Drupal 7 site, I have a content type that is populated with existing nodes. Later, I added a new boolean field (that is required). The existing nodes now have a blank value for this field.

How do I programmatically populate these nodes with a default value?


texts: Drupal PHP views - how to reference nested braket array variables?

texts:
I did a dpm() on the path variable i have and I'm running into the issue of figuring out how to reference this variable. When I do a print_r() on the variable it shows that its [[path]]

I'm not sure how to reference that. I thought it might be $var[['path']] but that doesnt work.


texts:
I have a content type with a Date text field. User can enter from and to dates to control when  this node will display. In my views filter, I'm adding both the from and to fields. 'From' is less than or equal to now and 'To' is greater than or equal to now.

The resulting query is not combining the range of dates, so all nodes show up in the result set.

Can I resolve this with just Date module? I don't want to use scheduler.

Drupal 6
Date 6.x-2.9


texts: How to add active class to title which is loaded via views in block

texts: I have created content type XXX, via views I collected all titles of XXX content. That all titles works as links, I want to add active class to title which was clicked in block. It should works as menu item.


texts: Best way of translating fixed text in Drupal 7

texts:
I am using t() with context to translate strings for a multilingual site. I would need a user to translate all language strings, but she/he does not need to know Drupal, just will feel an Excel. The problem is that I must provide the original string, the context, and the URL where it appears, and I do not know how to extract them from the database, as the string is stored as a BLOB. I am using this trick of function but still do not get the URL. Any help will be appreciated.

In the function I am copying and pasting all t() ocurrences that I have added in modules, template.php, etc.

function My_Module_list_translations(){
    $translation[] = t2('All', array(), array('context' => 'listado_sabias'));
    $translation[] = t2('Write one or more words', array(), array('context' => 'formulario_noticias'));
    $translation[] = t2('CATALOGUE', array(), array('context' => 'menu-personalizado'));

    echo "
";
    foreach($traduccion as $value){
        echo '
' . $value["contexto"] . '	' .  $value["es"]  . '	' .  $value["en"]  . '
';
    } // foreach
    echo "
";
} // function

function t2($string, $empty, $context){
    $array_dev["contexto"] = $context["context"];
    $array_dev["es"] =  t($string, array(), array('context' => $context["context"] , 'langcode' => 'es'        ));
    $array_dev["en"] =  t($string, array(), array('context' => $context["context"] , 'langcode' => 'en'
       ));
    return $array_dev;
} // function


texts: How to know from variables tu use them in a custom code

texts:
I know it's a newbie question, but it's take me a lot of time to find a a small code for a small fonctionality.

for example I wanted to make the address phone field required, I didn't know how to know the arrays keys.

        <?php
/**
 * Implements hook_field_widget_form_alter().
 */
function organize_address_field_widget_form_alter(&$element, $form_state, $context) {
  if(!empty($element['#addressfield'])) {
    $element['country']['#weight'] = 100;
    $element['phone_block']['phone_number']['phone_number']['#required'] = TRUE;

  }
}

I tried devel to find it but without result.

So my question,after finding the good hook, how I can know the variables to use.

Is a general question to help me to learn module development.


texts: Exporting settings in a code with Features / Strongarm - how to detect right variables - config ones

texts:
Many modules does not support Features, so I need Strongarm module to export config in the code. But in situation where i have many contrib modules, it seems tedious work. not all variables are named after module.

More important, how can I know which variables are used for settings, as I noticed some vars are not used for settings but may be user/module specific, and I need to aviod them.

I want to Strongarm only variables that have to do something with the config.

Is it done by researching modules one by one ? What are your experiences (It would be nice if I could filter variables that are used only in config :) )


texts:
I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900.
The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

UPDATE:
Thanks to Leymannx for contributing and attempting to help. As per your suggestions, I tried the following but without success:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => idate('Y'),
    '#default_value' => 1988,
];

Note: The problem is that both the start and end fields refuse all my efforts to configure the value and default_value. So, for the start field, I expect to see 1988 but instead that form field displays 1900.


texts:
I'm trying to implement the Google CSE Search Results code on a page that I created called search-results. When I implement the code using CKEditor (PHP mode) and save the page, the code does not show up when the page is rendered?

I was able to enter the Search box code no problem but I cannot seem to get the search results code to load on a page? I created a static html page and it works fine but will not work when I create the page in CKEditor. I also tried creating a block but this did not work?

How can I get the Google CSE Search results code snippet in a Drupal page? I'm not interested in using any of the Drupal modules for CSE as I don't like the way they render the results.


texts: Block showing Parent Taxonomy Term of current Node

texts:
Ok my taxonomy is setup like this:

Holiday Cards
Trees
Bears
Religious

So the goal is to display a node belonging to 'Trees' but in that node I need to have a block that shows the Parent Item of 'Holiday Cards' (along with the description of 'Holiday Cards'.

I have attempted to use views to accomplish this but I keep hitting a wall.  Can someone please walk me through, step-by-step, what I am missing in order to accomplish this seemingly simple task?


texts:
We moved to Drupal from another CMS about a year ago, and we still get 100s of "page not found" log entries each day for paths that were for our old site that don't exist on the new site. By checking IPs, I have concluded that most of these are from Google's indexer, but not all.

I add redirects when I can, but most of the links are to some meaningless tokenized path that our old CMS used. I feel like there is probably something I should be doing to flag bad paths for Google/SEO/whatever.

Is there a best practice for what to do with old broken links?


texts: How to organize a lot of related blocks for facet search programatically?

texts:
I am experimenting with Solr search and the Facet API, and I've created a search page that now has about a dozen facet blocks on it.

Right now it just looks like Block 1, Block 2, Block 3, Block 4, etc.

I would like to group these into categories, such as Category A (Blocks 1-3), Category B (Blocks 4-9), and Category C (Blocks 10-12).  Ideally these categories would be collapsible.

I already have way too many modules on my site so I want to avoid adding a new module (such as Block Group) to do this.

In this case, is CSS the way to go, or is there some aspect of Drupal that can help with this?


texts: I created a new content type which anonymous users are allowed to create. However, they can only do so if they are authenticated into Facebook. What is a good way of associating the particular node with the user? Right now Drupal is assigning a uid of 0 to these anonymous users. Is it possible to overwrite that uid with the id of my Facebook login table? How else can i create a relationship?


texts: In Views, how can I show only the results for content that has been tagged with two taxonomy terms?

texts:
I'm using Drupal 7:

I have a taxonomy term view that uses two contextual filters (i.e. taxonomy/term/%/%). Under 'Relationships' I have selected: 'Content: Taxonomy terms on node'. Under this relationship I have selected two vocabularies. Under 'Contextual Filters' I have selected: '(terms) Taxonomy term: Term ID'. Within the contextual filter I've selected 'Display contents of "No results found"' under 'WHEN THE FILTER VALUE IS NOT IN THE URL'.

The reason for two contextual filters is because the content is tagged with two term reference fields each of which correspond to a different taxonomy vocabulary.

The problem is that the results I get are not filtered by the second taxonomy term.

For example, if some content has been tagged with 'board of directors' (tid = 29) and 'people' (tid = 34) then everything that is tagged with 'board of directors' displays under taxonomy/term/29/34 even if they have not been tagged with 'people'.

How can I configure my view so the results are filtered according to two taxonomy terms?


texts: Pulling in a title from multiple content types

texts:
Currently I have 3 content types: Program, Chapter, Item. The program content type has a node reference field to contain multiple chapters and the chapters content type has a node reference to contain multiple items.

I now have a view that lists some items, but I also want to pull in the program title that is referencing that item.

For example:

Program = Fruit
Chapter = Pear
Item = Cutting a Pear

I want to list the title of "Cutting a pear" and also the program "fruit" title.

In my view for my items I tried creating a relationship to tie in the "program", but the only relationship that I can use is the "Chapter" because I guess its directly related to the item. The program is not tied to it in any way.

Any ideas how I can pull in the program title information when its not directly related to the item?


texts: What is the difference between "content type" and "custom content type"?

texts: Can anyone explain to me the difference between content type and custom content type?


texts: How do I show a coupon code to customers?

texts:
I've enabled a Ubercart Discount Coupons module in my eshop site and created some coupons with multiple one-time use only codes for testing purposes.

Now I would like to get one of the active coupon codes to customer who submits a newsletter registration form. Are there any functions to retrieve one of unused coupon codes?


texts:
Hello i was hoping to make some of my blocks accordian style.
JQUERY ACCORDIAN WIDGET

I know there is a module for this but that only does whole block regions and i was looking at styling individual blocks. Also the module doesnt seem to work too well for me so anyhows...here we be.

I followed intructions from this page-
jquery accordian d6

Ive got jquery update going and i can see i have version 1.3.2

I have added

jquery_ui_add('ui.accordion');

to my template.php. Then i added-

to my page.tpl. and then added this (as a test) around my right hand sidebar (although i would like to put it around individual blocks but i think i would just add this to block.tpl (for each block)

<?php print $sidebar_second; ?>

When i view my page which you can view here-
My website

i see that everything seems to be in order, i think, but no accordian behaviour. I will go and start adding the css to my block.tpl's.

Can anyone see where i am going wrong?

Thanks


texts: Which tables are safe to omit from sql-sync?

texts:
I sync my database with drush sql-sync @dev @live and the other way round. Can I omit the following tables safely, like in my drushrc.php from sql-sync?

$options['structure-tables'] = array(
   'common' => array(
     'cache', 'cache_filter', 'cache_menu', 'cache_page',
     'cache_admin_menu' 'cache_block', 'cache_coder',
     'cache_content', 'cache_form', 'cache_hierarchical_select',
     'cache_location', 'cache_update',
     'cache_views', 'cache_views_data',
     'ctools_css_cache', 'ctools_object_cache',
     'history', 'sessions', 'watchdog'
   ),
);

Additionally I wanted to exclude variable_cache and views_object_cache if that is safe.

Is that a good practice? Is there a list of tables somewhere on drupal.org for all modules?


texts:
Recently, I migrated Drupal 7 to Drupal 8 using the Migrate upgrade module, but the views aren't migrated.

Is there any method to import views from Drupal 7 to Drupal 8?


texts: Recreate the Management menu during migration

texts: I've just done the upgrade from Drupal 7 to 8 (on a site that was updated from Drupal 5 to 6, 6 to 7...) and the management menu seems to be a bit of a mess. An attempt at trying to fix it up left it worse off and I'm wondering if there's a way to just have Drupal re-create the menu from scratch. I don't care about its customization, it would just be good to go back to the defaults.


texts: hook_node_insert() and drupal_goto conflicts with each other?

texts:
I find some strange problem. I use hook_node_insert(). In order to create the other node after the user create the specific node! Then, I redirect the user to the other pages
But there are some error messages that i can't figure out!

the below code is my hook_node_insert()

function campaign_node_insert($node)
{
    global $user;
    global $base_url;

    if($node->type=="my_content_type")
    {

            $userid=$user->uid;

        /**

                My code is right here !

               **/

               drupal_goto('/user/'.$userid);

          }
}

My error Message is as belowed :


texts: Button with different value and label / text

texts:
in Drupal 8, I want my form display such a (submit) button:

<button name="name" type="submit" value="value">Not the value</button>

So basically, the button value (that will be submitted) shall be different than the button text / label (following that solution).

Is that possible with the Form API? If yes, how?


texts: Webform submission via URL supplied data

texts:
Is it possible to submit data to a webform by providing the data in the URL of the webform page - or some other means of remotely providing data?

I have no idea if anything like this is possible but I am trying to keep email records within Drupal rather than use a simple script.


texts: how to add custom classes and div to drupal search form.. i want to change complete layout of the block

texts:
I want to set following HTML layout in my search form.

<form>
    <input class="sb-search-input" placeholder="Enter your search" type="search" value="" name="search" id="search">
    <input class="sb-search-submit" type="submit" value="">
    <img src="<?php echo $theme_path;?>/images/search_icon.png" alt="">
</form>

but when i render the form using module invoke i got all classes and divs that are associated with search block,i want the above HTML to be applied to my search block.


texts: How to load a taxonomy term with case-sensitive?

texts:
I used this

    $this->termStorage->loadByProperties(['name' => 'test']);

I got two terms: Test, test.
I want to get only one: test

This is working without case-sensitive:

    $this->termStorage->getQuery()->condition('name', 'test', '=')->execute();

    \Drupal::database()->select('taxonomy_term_field_data', 't')
      ->condition('t.name', 'test')
      ->fields('t', ['name'])
      ->execute()
      ->fetchAll();

    \Drupal::database()->query("SELECT name FROM taxonomy_term_field_data WHERE name='test'")->fetchAll();


texts: How to get new password by mail instead of password reset url (Forgot password)

texts:
When we click on "Forgot your password" and enter email id, Drupal will send password reset URL by mail.

But is it possible Drupal send any random password by email instead of URL?

I have checked Registration Password Token but this will helpful for new user registration only.

Is there any module available?


texts: Mails are sent to users when the payment transaction fails

texts:
If the payment fails, for example because the bank account has an insufficient balance or an incorrect password is entered, the e-mails are sent to the users. After the payment method completes, it is redirecting to the "Complete" Page with the "Transaction has been declined" message.

How can I restrict the e-mails sent to users?


texts: I am looking for a way to easily implement an Integer field with webforms that can do mobile number validation (US numbers only). I am aware of http://drupal.org/project/webform_validation that can do numeric validation but looking for a more direct solution. If its a hook, that works as well.


texts: Redirect Using Rules Based on Account Role

texts:
Further to this previous question, https://drupal.stackexchange.com/questions/1790/redirect-users-after-login-depending-on-the-users-roles I am trying to accomplish a similar redirect on a D7 whereby once a user with a specific role type has logged in, they are redirected to a homebox (using the Homebox module) page of 1 of 2 types (1 Teacher; 2 Student) and the homeboxes nodes are named accordingly: 1) teacherhomebox, 2) studenthomebox using URL aliases. I have been following Johan Falks tutorial http://vimeo.com/28804544 (many times now!) and thought I understood what appears to be a simple task, but after testing either of the said roles, my redirects do not show the relevant (after login) user homebox as the primary page and simply stays on my custom Panel 'landingpage' I have setup as the primary welcome site homepage. Of course they do log in and it shows their account link on the header (which I'll remove later) I'm not sure what or why the redirects are not working, maybe I've not put the correct account select in the Rules UI but FYI and for testing purposes (using a student role) the setup is as such:

Event:
User has logged in

Condition:
User has role(s) (parameter: Role= student, match=ANY)

Actions:
Element: Page Redirect (parameter: URL: studenthomebox)

I have in the URL redirect Value, put "studenthomebox"

I would also like to add that I am trying to create a 'homebox' dashboard as per drupal.org and would be happy to acheive the same along with using the Rules module (with homebox) and would prefer to stay using Rules given the option.

Any help is very much appreciated as I'm after many hours, rather confused now.


texts:
I have the following content types: hotels, and taxonomy terms; in hotels I have a taxonomy field.

How do I retrieve the taxonomy term ID in a node? Is it possible to retrieve the self and parent taxonomy term ID and name?

I have also tried this, but it does not work.


texts:
I receive this error message when I try to fetch data from the Database Table of a custom form and print it in a table format in Drupal 9.
User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core\lib\Drupal\Core\Render\Element.php).
Drupal\Core\Render\Element::children(Array) (Line: 349)
Drupal\Core\Render\Element\Table::preRenderTable(Array)
This is my code controller.php File code:
<?php
    namespace Drupal\ad_form\Controller;
    use Drupal\Core\Controller\ControllerBase;
    use Drupal\Core\Database\Database;

    class ad_formController extends ControllerBase{

        public function getAdList(){

            $query = \Drupal::database();
            $result = $query->select('ad_form_submissions','e')
                    ->fields('e',['id','name','gender','product','quantity','price'])
                    ->execute()->fetchAll(\PDO::FETCH_OBJ);

            $data = [];

            foreach($result as $row){
                $data = [
                    'id'=> $row->id,
                    'name'=> $row->name,
                    'crop_category'=> $row->gender,
                    'crop_type'=> $row->product,
                    'quantity'=> $row->quantity,
                    'price'=> $row->price
                ];
            }

            $header = array('ID','Name','Gender', 'Product', 'Quantity', 'Price');

            $build['table'] = [
                '#type'=>'table',
                '$header'=>$header,
                '#row'=>$data
            ];

            return [
                $build,
                '#title'=> 'Submit Ad List'
            ];

        }

    }

How to resolve this issue and fetch the Data Correctly? I'm a Beginner, So please try to simplify the answer.


texts: PDO Deadlocks Galore on the Semaphore table

texts:
I experience frequent deadlocks on the semaphore table that look like this:

  PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: DELETE FROM {semaphore} WHERE (name = :db_condition_placeholder_0) AND (value = :db_condition_placeholder_1) AND (expire <= :db_condition_placeholder_2) ; Array ( [:db_condition_placeholder_0] => variable_init [:db_condition_placeholder_1] => 298999494f343fc583c3e2.30542255 [:db_condition_placeholder_2] => 1328824262.5293 ) in lock_may_be_available() (line 181 of /var/www/drupal/includes/lock.inc).

This site sees fairly heavy traffic. Is the load the cause of this? Is this due to a faulty module? Is this something in Drupal core?

Most importantly, are there precautionary measures I can take to avoid this?


texts:
I'm looking to use Backup and Migrate modules to port over my website. However, even when I go and install a fresh install, update all the modules and activate them accordingly, and finally restore my database, I come out with a white page with the error below. I've done some searching around online here and elsewhere looking for a solution to the following error, and while I've found similar things none have been able to help me resolve this error:

Fatal error: require_once(): Failed opening required '/var/www/html/profiles/acquia/modules/ctools/plugins/export_ui/ctools_export_ui.class.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/includes/bootstrap.inc on line 3168

From what I've read thus far, I am getting that this is basically telling me the something doesn't exist and needs to be added into the PHP. That's where things have begun to get foggy as I continue to push through.

Thanks in advance!


texts:
I have created the Custom registration form module using the form API as per the requirements. I have also inserted the records in the database using form alter functions. Now I need to create an edit registration form  for the logged users.

My suggestion on this is:

Create edit_reg form module with form controls
Retrieve the records of logged users
Pass the values to defalut value of form controls

Is the above method good? May you suggest me any other method to edit the form API?

I am using Drupal 7.


texts: How useful is it to use the latest Composer version to maintain my sites?

texts:
I am trying to determine the best way to maintain a Drupal 8 site. I am new to Drupal, PHP and Composer, but I am learning.

I believe that my goal is to maintain my Drupal 8 site using drupal-composer/drupal-project (https://www.drupal.org/node/2718229).

I am using a shared hosting plan, but I have shell SSH access. I notice that my hosting provider already has /opt/cpanel/composer/bin  in my command line path. That version of composer is 7 months old. (Composer version 1.1.1 2016-05-17). I have PHP 5.6.29 via the command line.

It's possible for me to install the latest version of composer (1.3) in my user directory, and then to override the hosting service's path. I want to know whether it's worth the extra trouble to do so.

Purely from the standpoint of maintaining my Drupal sites (and not from the development point of view; I won't be making my own modules any time soon), how useful/critical would it be to have the latest stable version of Composer available to me?  My guess is that the hosting service won't be updating Composer often (maybe once or twice a year).

Does a somewhat out-of-date version of Composer impose limitations on how effectively it can manage Drupal and Drush updates?


texts: How to configure Drush launcher on mac sierra?

texts:
I´ve installed drush on my mac sierra following the instructions from http://docs.drush.org/en/master/install/ but when i try run a command drush, this indicate the next instruction:

The Drush launcher could not find a Drupal site to operate on. Please do *one* of the following:
    - Navigate to any where within your Drupal project and try again.
    - Add --root=/path/to/drupal so Drush knows where your site is located.

I am new in drush and I not understand this instruction. Is needed create a new file?? what´s the name? what is the code that content this file?

Maybe I need to modify any file on my mac???  what can I do to run drush from my drupal sites?


texts: How to add a script to checkout (for affiliate partner programme)?

texts:
Original question:
I want to add a script to an order on checkout completion or even better with the rule 'when an order is first paid in full'. But I don't know how or where exactly.

Why I need it:
we want to use an external affiliate partner programme for PPS (pay per sale). So when a customer is coming from site A to our shop and orders somthing, the owner of site A gets a certain percentage of the sale.
In order for that to work, I need to add a script to the checkout. Or better add the script when the order is paid in full. I use tokens for the UID, order number and total amount in the script I got from the external affiliate partner.

The script looks like this:

<script type="text/javascript" src="https://track.adcocktail.com/tracking_sale.php?t=s&kid=xxxx&lv=0&bestid=[commerce-order:order-number]&wert=[commerce-order:commerce_order_total]&beschreibung=[commerce-order:mail-username]"></script>

I tried adding it by a rule "add a variable" (on checkout completion) but that doesn't do anything.
When I add the script to the order as a text field in the checkout, I can't use the tokens (they aren't recognized) and the script is run every time I do something to that order so it appears more than once in the affiliate overview.

Does someone know how I can make this script work ?

(I hope my question is clear. If not, just ask.)

Drupal Commerce Kickstart 7.x-2.25
Drupal 7.38

EDIT:

I don't need to activate the script on checkout completion, but 30 days after the order is paid in full. So after the 30 days the customer legally has to return goods. And that's not so easily done as adding the script on checkout completion.

Does anyone has an idea on how to make a rule for it ?


texts: How to add extra custom attributes in Linkit Profiles?

texts:
I need to add my custom attribute in Linkit profile.

For eg. I have a linkit module and I want to add my custom attribute called 'Ajax attribute' in /admin/config/content/linkit/manage/default_linkit/attributes/add
So, I can open my ajax model in an overlay, frame, etc.

How can I achieve this scenario, Any leads?


texts: Domain Access and mother website arguments

texts:
I am thinking of creating a series of websites based on one mother website using the Domain Access module, like this:

www.domain1.com linking to www.motherwebsite.com/argument1

www.domain2.com linking to www.motherwebsite.com/argument2

www.domain3.com linking to www.motherwebsite.com/argument3

etc. Each child domain will show the content associated with this domain (but created on the mother website) depending on argumentN.

So, my question is how can I capture the argumentN data to deliver the corresponding content (in Views, Blocks, Panels etc)? I guess I won't be able to use the URL for that as the argument data will not be part of the child domain's URL...

Thank you


texts: Dynamic select lists (dependent dropdowns)

texts:
I created 2 dependent dropdowns in Drupal 7. In the first dropdown you need to choose the device, in order to see its attributes in the second dropdown.

When an option from the first list is selected, the Ajax throbber appears but it doesn't seem to be working and I don't get the appropriate options in the second dropdown.

I have read all examples and resources I could find online, but I haven't found how to fix this. Any help would be very much appreciated.

Below I attach the relevant code. Apologies in advance, I am new in Drupal.

function my_module_getdevicesfromrooms() {
  $dropdown1 = array();

  $tabdelimited = file_get_contents("http://.../tabdelimited");

  // some code
  return $dropdown1;
}

/**
 * The device name is required in order to get the attributes using this function
 */
function my_module_getattributesfromdevices($test) {
  $dropdown2 = array();
  $tabdelimited = file_get_contents("http://....");
  // some code

  return $dropdown2;
}

function my_module_form_ajax($form, &$form_state) {
  $form['#prefix'] = "
";
  $form['#suffix'] = "
";
  $options_first = my_module_getdevicesfromrooms();
  $value_dropdown_first = isset($form_state['values']['my_module_deviceurn']) ? $form_state['values']['my_module_deviceurn'] : $options_first;

  $state2 = my_module_getattributedfromdevices($value_dropdown_first);

  $form['my_module_deviceurn'] = array(
    '#type' => 'select',
    '#title' => 'Device',
    '#options' => $options_first,
    '#default_value' => $value_dropdown_first,
  );

  $form['my_module_apply'] = array(
    '#type' => 'button',
    '#title' => t('Apply'),
    '#default_value' => t('apply'),
    '#ajax' => array(
      'callback' => 'my_module_ajax_callback',
      'wrapper' => 'nodes-div',
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );

  $form['my_module_attributes'] = array(
    '#type' => 'select',
    '#title' => t('Attributes'),
    '#options' => $state2,
    '#default_value' => variable_get('my_module_attributes', ''),
  );
  return $form;
}

function my_module_ajax_callback($form, $form_state) {
  return $form;
}


texts: Display menu items deeper as second level. (show as expanded doesn't actually expand menu items)

texts:
I have a menu that needs to be 3 levels deep. The last level never shows up. All menu items are set to 'Show as expanded'. But if go look at the html of the li items that make up the menu, I see <li class="collapsed" >menuitemname </li>

This problem occurs in bartik as well as b2nature (the one that the site should go live with)

Keep in mind that I made really really sure that under the menu configuration, I set each and every menu item as 'Show as expanded'.

Update The problem even seems a little tougher than I would think. I made a script that changed all of the class values that said 'collapsed' into 'expanded'. After checking the HTML I can see that the script works, but even with all the classes set to 'expanded' still no level 3 to be seen.

Here's the script for what it's worth

window.onload = function(){

    var mainMenu = document.getElementById('block-menu-block-1');
    var menuItems = mainMenu.getElementsByTagName("li");

    for (var i=0; i < menuItems.length; i++ ){

        var attributes = menuItems[i].getAttribute('class');
        var arrayAttributes = attributes.split(' ');
        for (var j=0; j < arrayAttributes.length; j++ ){

            if (arrayAttributes[j] == 'collapsed'){
                arrayAttributes[j] = 'expanded';
                }
            }

        var newAttributes = arrayAttributes.join(' ');
            menuItems[i].removeAttribute('class');
            menuItems[i].setAttribute('class', newAttributes);
        }
}

Update: I can confirm that this problem must be due to a bug.

I reconstructed the same menu on another site(locally this time). When I would put the block of that menu in any region, the expanded menu items just show up because I checked the 'Show as expanded'-checkbox in the configuration after clicking '+ Add link'.
It didn't matter if the expanded menu items had actual nodes as path or  as path. All worked just fine.
Then I also reconstructed the same menu on my problem-site just starting from scratch but the problem persisted.

Update The 3rd level also isn't there in HTML. I also installed and configured the Menu Blocks module to see if this would be of any help but it isn't.


texts:
My Firefox has just updated to version 17.1. When I try and login I get this message:

  Access denied
  You are not authorized to access this page.

The URL does however recognize my account as it contains /users/myusername

I can log in fine in older versions of Firefox, and Internet Explorer. I however get the same problem in Safari version 4 Public Beta (528.16).

Does anyone know a fix for this? I have tried rebuilding permissions but it didn't help.

I am running Drupal 6.


texts: Switch style plugin of a view based on results

texts:
I would like to create a view, which would display it's result with style plugin Unformatted if there is only 1 result, but would use Bootstrap Accordion style plugin, if there are more of them. I tried to do it like this:

    name == 'some_view_name') {
        if (count($view->result) > 1) {
          $view->style_plugin = 'ViewsBootstrapAccordionPluginStyle';
          $view->style_plugin->plugin_name = 'views_bootstrap_accordion_plugin_style';
          $view->style_plugin->options['title_field'] = 'title';
          $view->style_plugin->definition['path'] = 'sites/all/modules/views_bootstrap/plugins/accordion';
          $view->style_plugin->definition['theme path'] = 'sites/all/modules/views_bootstrap/templates/accordion';
          $view->style_plugin->definition['file'] = 'ViewsBootstrapAccordionPluginStyle.inc';
          $view->style_plugin->definition['theme file'] = 'theme.inc';

        }
      }
    }

The result is this error:

Fatal error: Call to a member function render() on a non-object in .../sites/all/modules/views/theme/theme.inc on line 49

What am I doing wrong?

EDIT: Probably almost everything. $view->style_plugin has to be an object, that was the reason of the error above. So I modified the code to this:

<?php
function my_module_views_pre_render(&$view) {
  if ($view->name == 'my_view') {
    if (count($view->result) > 1) {
      $bs_accordion_style = new ViewsBootstrapAccordionPluginStyle;
      $bs_accordion_style->plugin_name = 'views_bootstrap_accordion_plugin_style';
      $bs_accordion_style->options['title_field'] = 'title';
      $bs_accordion_style->definition['path'] = 'sites/all/modules/views_bootstrap/plugins/accordion';
      $bs_accordion_style->definition['theme path'] = 'sites/all/modules/views_bootstrap/templates/accordion';
      $bs_accordion_style->definition['file'] = 'ViewsBootstrapAccordionPluginStyle.inc';
      $bs_accordion_style->definition['theme file'] = 'theme.inc';
      $bs_accordion_style->options['grouping'] = array();
      $bs_accordion_style->row_plugin = $view->style_plugin->row_plugin;
      $bs_accordion_style->definition['theme'] = 'views_bootstrap_accordion_plugin_style';
      $bs_accordion_style->view = $view->style_plugin->view;
      $bs_accordion_style->display = $view->style_plugin->display;
      $view->style_plugin = $bs_accordion_style;
      $view->style_options['title_field'] = 'title';
    }
  }
}

That almost works. It results in this error (1 per view result):

Recoverable fatal error: Object of class stdClass could not be converted to string in include() (line 21 of .../sites/all/modules/views_bootstrap/templates/accordion/views-bootstrap-accordion-plugin-style.tpl.php)

How can I correct this?


texts: How do I add a  class based on the visibility of a block?

texts:
Is there a way to add a CSS class to the <body> tag based on the visibility of a  particular block on a page?

We have certain blocks that are visible on specific pages. It would be nice to be able to change CSS styles for related content depending on whether they are present.

How can I achieve this?


texts: Translated taxonomy term in contextupal filter not validating

texts:
I have a translated taxonomy term:

And have a simple view:

With a contextual filter on the translated taxonomy term:

Which works in english:

But not in french:

Any idea ?


texts: RewriteRule causing internal redirect limit error

texts:
I am trying to server a static HTML site from /sites/default/files/staticsite and make it available via a subdomain. I'm hosting the site on Acquia Cloud, and their docs describe Maintaining a static microsite alongside Drupal's docroot.

This solution is working, with the exception of index.html page (homepage) which returns a 404.

http://subdomain.example.com/ returns a 404
http://subdomain.example.com/index.html success

The setup describe in the docs

I have added the required domain to my Acquia Cloud dashboard so the server will accept requests for the subdomain.

I have updated docroot/.htaccess with the following RewriteRule to redirect requests to the static files. The following rules are the first lines in the .htaccess file.

<IfModule mod_rewrite.c>
  RewriteEngine on
  # Only serve the static site for a particular host.
  RewriteCond %{HTTP_HOST} ^subdomain\.example\.com\.au$ [OR]
  RewriteCond %{HTTP_HOST} ^dev-subdomain\.example\.com\.au$ [OR]
  RewriteCond %{HTTP_HOST} ^stage-subdomain\.example\.com\.au$
  # Don't loop anything targeting the actual mask directory, to allow
  # for linked scripts, stylesheets etc in the static HTML
  RewriteCond %{REQUEST_URI} !^/sites/default/files/staticsite/
  #Any requests that made it this far are served from the /staticsite/ directory
  RewriteRule ^(.*)$ /sites/default/files/staticsite/$1 [PT,L]
</IfModule>

The files have been uploaded to sites/default/files/staticsite

Things I've tried

I thought DirectoryIndex must be disabled for these directories so I tried adding DirectoryIndex index.html in both /sites/default/files and /sites/default/files/staticsite but neither have had an effect.

I tried elevating the DirectoryIndex directive to the top of the existing /sites/default/files/.htaccess file, as well as placing it last. Neither fixed the 404 error.

I've tried removing the /sites/default/files/.htaccess and adding a new .htaccess file with just DirectoryIndex index.html to test if the SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 was impacting things. No change still got 404.

I've tried adding the [END] flag to the RewriteRule to stop the current rewrite process and subsequent rewrite processes, but still got the 404.

Log entries

When making a request to `http://subdomain.example.com/ I see the following entry in the Apache error log:

  Request exceeded the limit of 10 internal redirects due to probable
  configuration error. Use 'LimitInternalRecursion' to increase the
  limit if necessary. Use 'LogLevel debug' to get a backtrace.

I'm unable to define 'LogLevel` because Acquia Cloud do not provide access to the server config, virtual host, and directory contexts which this directive can be defined in.