texts: How to set a field value from parent template in Twig?

texts:
I have node--article--teaser.html.twig which calls image-formatter.html.twig to printout the field_image. Everything works fine except that I don't want the field_image itself to be a linked. i.e image-formatter.html.twig should not find a url to only print an img tag.

I have tried the following in node--article--teaser.html.twig:

{#{ content }#}
  {% set content.field_image[0]['#url'] = null %}{% endset %}
  {{ content.field_image }}
    {{ label }}

The second line causing the following error:

  Twig_Error_Syntax: Unexpected token "punctuation" of value "." ("end
  of statement block" expected) in
  "themes/saidbakr/templates/node--article--teaser.html.twig" at line
  78. in Twig_TokenStream->expect() (line 87 of vendor\twig\twig\lib\Twig\TokenStream.php).

While {{ content.field_image[0]['#url'] }} prints the url without any problems!

The image-formatter.html.twig code is as the following:

{% if url %}
  {{ image }}
{% else %}
  {{ image }}
{% endif %}

There is no any suggestion from twig debug about any alternative template for image-formatter.html.twig

Also using Theme Hook image_formatter as saidbakr_preprocess_image_formatter will not be an option because it is not possible to know the view context, i.e teaser or full, or content types to restrict this interaction for articles type. I think that the most simple way is from Twig, but how?!


texts: How do I backup my site w/o the command line?

texts: Nearly all the documentation on backing up my Drupal site seems to require using the command line.  My hosting service does not provide command line access.  How do I backup my site without using the command line?


texts: How to retrieve a shipping service settings field in Views

texts:
My client needs a very specifically formatted file that displays order details. I'm using Views Data Export for this, and everything seems to be going well except for when it comes to the shipping information. I'm trying to show the Shipping Service name field for the shipping method that was used, but there's one catch: The client needs to use their company's codes for this field, not the default ones that come with the shipping module.

For example, if a customer used FedEx Ground, the field would need to display "FDXGRDCOL" instead of the default "FedEx Ground" name listed on the commerce/config/shipping page. One solution I had hoped would work was by renaming the Shipping Service's rules name in the Settings fieldset (admin/config/workflow/rules/components/manage/commerce_shipping_service_fedex_ground), but it seems that because shipping methods are not entities, I can't access stuff like this. I have attached a photo of this:

Any ideas?


texts:
I have a test module located under site/all/modules/custom.
First, I did uninstalled the module, cleared cache.
then , I did moved the test module to modules/custom folder which is a new
location to put Drupal 8 module.

After that, I have enabled the test module, then Clear All Caches.
Now, Drupal 8 keeps says can not find the test module under old location (site/all/modules/custom).

I thought Drupal 8 probably stored path in a DB table, but i am unable to find the table.
Can any one tell a solution about How to fix above problem?


texts:
I used ckeditor without Drupal.

There I can call this to configure it in js file:

CKEDITOR.replace( 'myEditor', {
        stylesSet: [
        { name: 'header', element: 'p', attributes: { class : 'head' } }
        ]
    });

But in drupal CKEDITOR is undefined. I have tried Drupal.settings.ckeditor, but still undefined. Is some way how to enable it?

I need to create specific styles for one Content type field in admin and I need to do it in my module without CMS. Is some way how to achieve it?

Thank you


texts: Views Table with Taxonomy Terms for Columns and Rows

texts:
I have a content type for manuals that has a vocabulary for "Model Year" and another for "Model Name" with a file upload that is for owners manuals for the specific Model Name + Model Year.

I want to push this content type into a view to provide a table where the years are columns and the model names are rows with the resultant cells having the download link.

---------------------------------------
        | 2016     |  2015   |  2014   |
---------------------------------------
Model 1 | download |download |download |
---------------------------------------
Model 2 | download |download |download |
---------------------------------------
Model 3 | download |download |download |

I've been wrestling with the views all night and the table. I can't seem to get close to what I want. I've tried making sure all the taxonomy terms were added as a relationship.

If I use fields and bring the content of the year and the model forward I can display them, but not as columns, only rows and not as rolled up results in a year - so 10 2016 column instead of one 2016 columns with 10 rows.

I've tried the Views Flipped Table module, but that didn't solved the problem.


texts: $base_url is set in settings.php but Security Review flags it still

texts:
I get this message in Security Review report:

  Base URL is not set in settings.php

even though my settings.php code has this:

$base_url = 'https://www.mysite.com';

I cleared caches several times, run CRON, alert message still shows up. I've googled for some time, no luck in finding clues about this. Any help would be appreciated.

UPDATE: If I change to http:// then the message disappears, but my secure login for administration doesn't work. Is there a way to define the $base_url as either http or https?


texts: Can Ckeditor use relative paths for images?

texts:
I am building a drupal 7 site on my localhost with ckeditor (7.x-1.13), HTML Purifier (7.x-1.0).

I realized that when my ip changes on the network, the links to the images I upload from ckeditor are broken. As I checked the html source, I saw that they are absolute urls and are using the previous ip as a part of them. Now that the ip is different, they are broken.

I need to develop the site and enter most of the content on localhost and if I cannot solve this problem, things will get complicated when I move the site to the server.

After reading a related question (D7 - Losing images when moving site location; placeholders point to old absolute path rather than relative path) I tried installing pathologic (7.x-2.11) module, checking the settings for text formats, clearing the cache with no result.

Is there a way to make ckeditor to use relative paths for images? Would it have any disadvantages?


texts: Primary admin actions block on view dissapears if change path

texts: There is a "primary admin actions" block in the seven theme (provided by the Drupal 8 standard install profile) which only shows up if my view if the path is "admin/content"  but if I change the path to anything else, the block is gone.  where is this configured ?


texts:
I'm testing the rooms module. It's a great module.

It has a page to performs a searches to get availability information of the rooms (mysite/booking) . I need this page to be available as a block.
So that I can put the searcher anywhere.

Anyone using this module to help to do it?

I just found how to get the block. But now I can't get the validation working properly. If date are no chosen an error page is shown.

Any help please?

I think it could be very useful to have this block working properly.

Look for the file: rooms/modules/rooms_booking_manager/rooms_booking_manager.module

At the end add this:

/**
 * Implements hook_block_info().
 */
 function rooms_booking_manager_block_info() {
  $blocks['booking_searcher'] = array(
    'info' => t('Room Booking Manager'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function rooms_booking_manager_block_view($delta = '') {
  if (user_access('access rooms_booking_manager blocks')) {
    $block = array();

        // Prepare to return the $block variable with subject (title) and content (output).
        $block['subject'] = 'Search block';
        $block['content'] = drupal_get_form('rooms_booking_availability_search_form');

    return $block;
  }
}


texts: Drush pm-download removing the destination folder

texts:
I'm creating a system to easily create new Drupal sites, using drush.
When I'm creating a new site, I just point the path where drush should create it and run drush pm-download drupal-7.12 --destination=/var/www --drupal-project-rename=test11 (example) on it.
I saw that drush deletes the folder and then creates it again. Most of the time I still need the files that are in the folder (e.g. 404.html, 403.html etc)

There's any way I could use pm-download without deleting the current files in the folder?

Thanks

-- Info:

Drush version: 5


texts: Custom URL using Taxonomy and Custom User information (Real Name)

texts:
Secondly, in the future I'm looking to organise Users by Taxonomy and having the url path relate to that:

/?q=taxonomy-tag-here/user-fullname-here (not username, would be a custom field on the registration form).

How hard would this be to do, are there any modules that can do this, or would I have to create one?

I'm new to Drupal, but I've worked with Wordpress and Joomla a lot in the past and I'm looking to move onto Drupal, so please, be patronising when you explain!


texts:
I have a loop populating multiple render arrays, and my output is not appearing as expected.

      $count = 0;
      foreach ($result as $row) {
      //do stuff

      if ($is_a_link_list) {
         //do more stuff

        $id = 'link_list_a' . $count;
        $content[$id] = array(
         //render array - link list
        );

      } else {

        $id = 'promo_list_a' . $count;
        $content[$id] = array(
            //render array - title
        );
        $id = 'promo_list_b' . $count;
        $content[$id] = array(
            //render array - body
        );

      }
      $count++;
    }

So in a given result set I'd expect:

---promo list title
   promo list body

---link list
   =item1
   =item2
   =item3

(more results)

What I'm getting:

---promo list title
   promo list body

---link list
   =item1
   =item2
   =item3

   promo list body
---promo list title

---promo list title

---link list
   =item1
   =item2
   =item3

   promo list body

---link list
   =item1
   =item2
   =item3

So does the key of the render array matter? (Other than needing to be unique)

Looking at the markup output it's apparent that I need to render my render arrays as list items; I think this means a nested render array?

HTML source:


texts: How to add number format function in decimal results in views 3

texts:
I am displaying some float value in my view. How can I make them till two decimal places?

Is there a way to add number_format function in view results?


texts: add css class to row with specified field value in views

texts:
I have a View, and when a certain field in the result has a specific value, I want to add a CSS class to that row.

How I can add css class to the matching row in views result in table result mode directly in views pages, without template files?


texts: How can I display custom user information on a page that is not a profile page?

texts:
I'm looking to display User information on an individual page, pulling custom fields to display the information.

For example, if a visitor of the site come across a user page, it would display:

Name (not username)
Pictures that they've uploaded
An about me paragraph

Maybe a few other custom fields in the future, but the main part is that I need to know how to call these from Drupal.

I'm new to Drupal, but I've worked with Wordpress and Joomla a lot in the past and I'm looking to move onto Drupal, so please, be patronising when you explain!


texts: Access denied to sites/default/files/styles/slide when adding items to mediabox field

texts:
I have a field called field_property_slideshow which is type of mediabox to add image gallery to a node. This was working fine until last week (may be after the updates). I am breaking my head to resolve this issue since a week time. My issue is exactly same or similar to this issue. I tried the solutions given this issue but I did not get the luck.

According the accepted solution I added
$conf['image_allow_insecure_derivatives'] = TRUE; in the
settings.php Also according to another solution I changed
sites/default/files/styles/slide/public folder permission to 777

To give more information this folders owner is ftpuser (is user name and group name) who is owner of this folder and www-data is this group member

I replaced the module files with the older version from the backup but it gives me same problem. The same thing works on my wamp environment

This is my error log

Type        page not found
Location    http://www.mysite.com/sites/default/files/styles/slide/public/?itok=EO40h_nX
Referrer    http://www.mysite.com/node/115/edit
Message     sites/default/files/styles/slide/public


texts: How do I get a field rendered with translated labels?

texts:
I have a node I render with the following code.

$render_controller = \Drupal::entityManager()->getViewBuilder($node->getEntityTypeId());
$render_output = $render_controller->view($node);
echo \Drupal::service("renderer")->render($render_output);

The rendered field labels are always in the original language (for example, German), even if I use $node->getTranslation("en").

I find it difficult to get translated labels to render properly. I've searched through the source code all the way from back to front to find an answer. I see my translated field label in the frontend under "/admin/config/regional/config-translation/node_fields" so it must be stored somewhere.

How do I access it or even better render the whole field correctly?

Neither $field->getLabel() nor $language_manager->setConfigOverrideLanguage($language) helped. Somehow Drupal must think it's very clever and uses some default language I don't want. I want to pick a specific language and render that. I would expect that usinggetTranslation()` on the node really gives you everything in the right language, but it doesn't happen. Why?


texts: After webform submission restrict/greyout certain fields when user goes back in to edit

texts: On my Drupal 7 instance I am letting anonymous users "edit own webform content" or "access own webform results." The thing is, I want one or two of the fields to become un-editable after the initial submission. Once they click through the link in their confirmation email to edit their submission, I want the email and company name fields to be greyed out but all other fields to be editable. What is my path of least resistance?


texts:
I have to upgrade Drupal core to 8.4 with Composer. Drush version is 8.1.12.

I use Docker4drupal for my local development environment. How do I update Drush to 9 within my docker container setup, so I can upgrade Drupal to 8.4?


texts: How to embed a node's NID in the title of a node?

texts:
I know the Automatic Nodetitles module exists, but it is only for Drupal 7.

Is there a method of automatically assigning the title with the NID upon clicking submit? I know that the NID doesn't exist until the submit button is hit. How would one embed the NID in the title?

What hook would one use?


texts: How to serve content type for authorized users as for anonymous?

texts:
I have content type "book". It's nodes are huge and it's takes a long time to format them by input filter. Caching works only for anonymous users.

So my goal is to give authorized users the cached version without APC, Cache Router (using a shared hosting).

I tried to change actual uid in template.php like so:

function mytheme_preprocess_page(&$vars, $hook) {
    if (isset($vars['node']) && $vars['node']->type == 'book') {
        global $user;
        $user->uid = 0;
    }
}

But it didn't help.


texts: "b.handleError is not a function" on image remove/upload

texts:
I was not able to upload/remove CCK field images from the UI; when I looked at the console in Firebug, it said, "b.handleError is not a function." When I look for this error on Internet, I keep getting redirected to http://drupal.org/node/1064890, but this has a patch for Drupal 7.

Has anyone faced something similar?
More importantly, was this fixed?

I am using Drupal 6, and the following modules:

jQuery UI 1.7.3
jQuery Update 1.5.2


texts: How to use Git with Drupal 8 when using composer

texts:
I am working on an OpenSocial project and its installed via composer. I am having a folder structure as below:

 - composer.json
 - composer.lock
 - html
  (Drupal Installation.)
 - vendor
  (Dependencies)

When creating, should I add the all files including composer.json and vendor to git or just add the content of html directory?

Note In some cases, for example in a normal D8 installation the composer
 files and vendor directories are in the same directory as Drupal installation.


texts: How do I access a custom variable in block.tpl.php?

texts:
I created a custom module that defines a block. In hook_block_view(), I have the following code.

$block['content'] = theme('item_list', array( 'count' => $count));

How can I get the value of $count in block.tpl.php?


texts: Return table and item-list, but only table is displayed

texts:
$build['table'] = array(
  '#theme' => 'table',
  '#header' => array('A','B','C'),
  '#rows' => $items
);

$build['itemlist'] = theme_item_list(array(
  'items' => $products,
  'attributes' => array('id' => 'my-custom-listing','class' => 'custom-class another-custom-class'),
  'title' => "Bonieren:",
  'type' => 'ul',
  'container_id' => 'bonieren',
));

return $build;

Above is my code. The problem is that only the table is being shown on callback. Why does it happen?


texts: How to pass query parameter in form submit?

texts:
I have a form :

function buildForm(array $form, FormStateInterface $form_state) {
    $form['edit'] = array(
          '#type' => 'textfield',
    );
    $form['submit'] = array(
          '#type' => 'submit',
          '#value' => t('Go'),
          //'#markup' => "
Go
",
        );
    return $form;
}

Now I want is; when I submit form,$form_state->getValue('edit'); should get appended as a query parameter in form route.

Let's say my form route is:

mymodule.admin_page:
  path: '/mypage'
  defaults:
    _form: '\Drupal\mymodule\Form\myform'

And when I hit submit button of form, the route should get changed to /mypage?word=$form_state->getValue('edit').

I tried below approach, but it is throwing error:

Created 1 more route with a parameter:

mymodule.word:
  path: '/mypage/{word}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\AdminController::myfunction'

And in my form submit function,

function submitForm(array &$form, FormStateInterface $form_state) {

    $data = $form_state->getValue('edit');
    $url = Url::fromRoute('mymodule.word',['word'=>$data]);
    $form_state->setRedirectUrl($url);
   }

But when I hit submit button, it is giving me error,

  Uncaught PHP Exception
  Symfony\Component\Routing\Exception\MissingMandatoryParametersException:
  "Some mandatory parameters are missing"


texts:
Back in Drupal 7 I've created exposed filter with Year from date field. (Selet list).

View all
2017
2016
2015
etc...

And when creating such filter we had options like on this picture:

BUT, now in Drupal 8 I cannot see that is supported.

I've installed Better Exposed filters but only thing is that I can select datepicker instead of plain text field for this filter, but I need select list and only years.

If it's not possible yet, where I can find examples of creating custom exposed filters or something like that?


texts: Is there a risk of having xmlrpc.php on my site?

texts:
I recently noticed that all of my sites have the file xmlrpc.php.

Searching it led me to "Gain Control of WordPress by Exploiting XML-RPC", and also to "Drupal Core - Critical - Multiple Vulnerabilities - SA-CORE-2016-001".

I'm running Drupal 7.56.

Does this file pose a threat whatsoever to my site?
Should I just delete it to be safe?

If I should keep it, what added benefit does it give me?


texts: How to add classes to every X number of node in a array

texts:
How do I write a preprocess_node function to add a class to every second/third node it generated?

Scenario: add .last to every 2nd node, so that i can apply margin-right: 0; for the last column in the row.


texts: How can I filter a view according to another view's results

texts:
I have one view with two display: "latest news" and "populer news"

I want show two block side by side like mashable.com.

I can easily do that of course but one problem. There are same news both block.
I want to hide news in the "latest news block" according to "populer news block".

How can I do that?


texts: Drupal 7 Wildcard menu like txt-txt-% is not locating

texts:
I wanted to create wildcard menu like text-text-% in drupal 7.

But It works for if the menu is like text-text/% how can I make the above menu format to locate the action.

 $items['pin-code-%'] = array(
        'title' => 'Country list',
        'description' => 'Country pincode',
        'page callback' => 'country_pincode',
        'access callback' => true,
    );


texts:
I've got some form input fields in a paragraph whose visibility need to be dynamically toggled by the value of a another field. This can be done with the states API and the HOOK_field_widget_WIDGETTYPE_form_alter hook.

My problem is that the paragraph is nested inside another paragraph, and I don't know how to get the delta of the parent widget, in order to build my selector name for the states API.

My node has a paragraph field_pagebuilder, which contains another paragraph field_row. All toggleable/dependant fields are inside the same sub-paragraph. This is the code I've got so far:

function wt_pricetable_field_widget_paragraphs_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
  if ($element['#paragraph_type'] == 'pricetable_frontend') {

    $deltaSelf = $context['delta'];
    //////////////////////////////
    $deltaParent = 0; // FIXME: how to I get this?
    //////////////////////////////
    $element['subform']['field_pt_showroom']['#states'] = [
      'visible' => [
        [
          'select[name="field_pagebuilder['.$deltaParent.'][subform][field_row]['.$deltaSelf.'][subform][field_pt_tablemode]"' => ['value' => 'single_room'],
        ],
      ],
      'required' => [
        [
          'select[name="field_pagebuilder['.$deltaParent.'][subform][field_row]['.$deltaSelf.'][subform][field_pt_tablemode]"' => ['value' => 'single_room'],
        ],
      ],
    ];
    $element['subform']['field_pt_hiderooms']['#states'] = [
      'visible' => [
        [
          'select[name="field_pagebuilder['.$deltaParent.'][subform][field_row]['.$deltaSelf.'][subform][field_pt_tablemode]"' => ['value' => 'multi_room'],
        ],
      ],
      'required' => [
        [
          'select[name="field_pagebuilder['.$deltaParent.'][subform][field_row]['.$deltaSelf.'][subform][field_pt_tablemode]"' => ['value' => 'multi_room'],
        ],
      ],
    ];
    $element['subform']['field_bem_modifier']['#states'] = [
      'visible' => [
        [
          'select[name="field_pagebuilder['.$deltaParent.'][subform][field_row]['.$deltaSelf.'][subform][field_pt_tablemode]"' => ['value' => 'multi_room'],
        ],
      ],
      'required' => [
        [
          'select[name="field_pagebuilder['.$deltaParent.'][subform][field_row]['.$deltaSelf.'][subform][field_pt_tablemode]"' => ['value' => 'multi_room'],
        ],
      ],
    ];
  }
}

My problem is the $deltaParent - how can I retrive it?


texts: Accessibility : Broken Skip Link Error on "Skeleton" Theme

texts:
I installed the "Skeleton" theme and found it has a "Broken Skip Link" by using "wave.webaim.org". How can I find and fix where is this "Broken Skip Link"?

You can find this Skeleton demo at "http://demo.drupalizing.com/skeleton"

and the "Broken Skip Link" error at "http://wave.webaim.org/report#/http://demo.drupalizing.com/skeleton/"


texts: How to attach a list of fields to an entity

texts: I have a node, and I'm looking to attach a list of fields to it. The number of fields should be dynamic. I realize I can create a new content type, and use entity reference module to build a list of related nodes, but I feel like that's overkill. I really just need to attach simple list (or list of fields). Is there a way to do this? or am I misunderstaning


texts: I had created a page called Analysis and then created a view with exactly the same name and /path. Did I confuse Drupal? I then deleted the Analysis page to have only a view at that path but am getting a page not found whenever I visit the link even though preview is showing the right thing.


texts: I only want to modify one tpl.php for a theme, do I need to copy the base theme?

texts:
I only need to have one tpl.php added to a theme,but the theme I am using is not my own.  If I still want to have this theme as my "base" and then create my own theme with the tpl.php using a theme suggestion I want, how do I get this to work.

I have tried setting the base theme as the default and then creating my own theme with the tpl.php I want and enabling it, but it isn't working. If this is the correct way to do this, what is the minumum needed in the .info file and the folder for this to work?


texts:
I'm trying to do a left join but it isn't working.

I have 2 tables:

TABLE profile
- uid
- pid

TABLE field_data_field_naam
- entity_id
- field_naam_value

I want to select the field_naam_value where uid is equal to .. and pid equal to entity_id. My normal query looks like this:

SELECT fdfm.field_naam_value, pf.uid
FROM field_data_field_naam fdfm
LEFT JOIN profile pf
ON fdfm.entity_id=pf.pid
WHERE pf.uid = 4

When I execute this on my database it works. Then I have this:

$naam = db_select('field_data_field_naam', 'fdfm')
     ->fields('fdfm', array('field_naam_value'));
$naam->leftJoin('profile', 'pf', 'fdfm.entity_id = pf.pid');
$naam->condition('uid', 4)
     ->execute();

And when I do the following:

foreach ($naam as $record) {
    die;
}

nothing happens... (he doesn't kill the app). Also tried to add ->fetchAll() but no success.


texts: No content showing in Taxonomy term template

texts:
I'm having one of those problems that makes no sense, and I've run out of ideas.
I have several pages using Taxonomy term template, and the system works great, as long as views caching is turned off. If I turn on views caching, visitors, and authenticated users see the page as having no content. However the admin can see the page content. I have checked and rechecked all the permissions, and I can't find any reason why cached content is being seen only by the admin, and it happens only on any Taxonomy term template pages.


texts:
I'm trying to create content with REST, everything worked correctly until we need to an entity Reference field,I add it to my content type and in want to pass entity referenced nid to it with

Part of my code :

    formValues.gender = parseInt($('input[name=optradio]:checked').val());
    var postData = {};
    postData.title = [{'value': formValues.name }];
    postData.field_enroll_email = [{'value': formValues.email}];
    postData.field_gender = [{'value': formValues.gender }];
    postData.field_phone_number = [{'value': formValues.phone }];
    postData.field_course_ref = [{'value': formValues.nid }];
    if(formValues.ac != "") {
        postData.field_academic_certificate = [{'value': formValues.ac }];
    }
    if(formValues.ec != "") {
        postData.field_english_certificate = [{'value': formValues.ec }];
    }
    postData.type = 'enroll';
    jQuery.ajax({
        url: "/entity/node",
        method: "POST",

my entity referenced machine name field is field_course_ref and I tried following method (formValues.nid contain nid of Node that I want to referenced it )

    postData.field_course_ref = [{'value': formValues.nid }];

How can I fill entity referece field with REST ?


texts: Mac XAMPP Drush 'needs a higher bootstrap level to run'

texts:
I have installed Drush on a Mac and can use it to download modules for the drupal projects I have in XAMPP. However serveral drush commands like drush up give a needs a higher bootstrap level to run error message. How do I get around this issue?

Pauls-iMac:mysite Trotter$ drush up
Command pm-update needs a higher bootstrap level to run - you will   [error]
need to invoke drush from a more functional Drupal environment to run
this command.
The drush command 'up' could not be executed.                        [error]
Drush was not able to start (bootstrap) the Drupal database.         [error]
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for
details.
 * connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
 Drupal version        :  7.38
 Site URI              :  http://default
 Database driver       :  mysql
 Database hostname     :  localhost
 Database port         :
 Database username     :  root
 Database name         :  mysite
 PHP executable        :  /usr/bin/php
 PHP configuration     :
 PHP OS                :  Darwin
 Drush script          :  /Users/Trotter/.composer/vendor/drush/dru
                      sh/drush.php
 Drush version         :  7.0.0
 Drush temp            :  /tmp
 directory
 Drush configuration   :
 Drush alias files     :
 Drupal root           :  /applications/xampp/xamppfiles/htdocs/mysite
 Site path             :  sites/default

The drupal sites work fine, just not with Drush. I have tried forcing 127.0.0.1 instead of localhost.

I notice that my issue is very similar to MAC -> Drush higher bootstrap level?. The answer supplied by ChristophWeber sounds promising, but does not include enough information more me to be able to try it. For example I cannot find my .bashrc file which I gather should be in my home directory, and if I needed to create it myself I'm not sure what should be in it.


texts:
I created a content type and it has many nodes. And I wrote a custom module to show nodes on the front page.

My nodes order:

 $themeurl = '/drupal/'.path_to_theme().'/images';
    $sql = "SELECT * FROM `node`
            LEFT JOIN `field_data_field_anasayfa_catwalk` ON `field_data_field_anasayfa_catwalk`.`entity_id` = `node`.`nid`
            WHERE type = 'designers_albums'
            AND `node`.`status` = 1
            AND `node`.`language` = '".$language->language."'
            AND `field_data_field_anasayfa_catwalk`.`field_anasayfa_catwalk_value` = 1
            ORDER BY `node`.`created` ASC";

But now, I installed the Weight module and want to sort by weight. How can I change this option?
Thank you.


texts: How to get the URL of an entity being created at hook_entity_insert() stage?

texts:
I'm trying to send an email "someone added content" with the URL to the entity as the message body.

function MYMODULE_entity_insert(EntityInterface $entity) {
  if ($entity->getEntityTypeId() === 'node') {
    switch ($entity->bundle()) {
      case 'contact':
        MYMODULE_mail_notify_admin($entity);
    }
  }
}

function MYMODULE_mail_notify_admin($entity) {
  $mailManager = \Drupal::service('plugin.manager.mail');
  $module = 'MYMODULE';
  $key = 'contact';
  $to = 'secret@secret.com';
  # $to = \Drupal::currentUser()->getEmail();
  $params['message'] = $entity->toUrl()->getUri();
  $params['title'] = $entity->label;
  $langcode = \Drupal::currentUser()->getPreferredLangcode();
  $send = true;

The problem is that $entity->toUrl()->getUri() gives an error, "This URL has a Drupal route, so the canonical form is not a URI".

How do I get the URL from a URL object?  Is this a problem because the entity hasn't been created yet, and the route hasn't been assigned?


texts: Facet API: grouping indexed values into several drop-down facets

texts:
I have an indexed field which contains values in such a form:

CPU: Intel Core i5
CPU: Intel Core i7
...
Memory: 4 GB
Memory: 8 GB
...
Video card type: Integrated
Video card type: Nvidia
...

I would like to display these as several drop-down lists, e.g:

Title: CPU  with values: Intel Core i5, Intel Core i7, ...
Title: Memory with values: 4 GB, 8 GB, ...
Title: Video card type  with values: Integrated, Nvidia, ...

Any suggestions would be welcome on how to implement this.
Thank you very much in advance.

Best regards,
Laszlo


texts: How to hide content when first displaying the view (Views contextual filter)

texts:
I am on drupal 7.56 and using Views to display some content based on a filter.

I am trying to not display content when the user opens the page for the first time. I want to make sure the user only displays values that will be related to the filter. My filter is on the Title and is a Search box.

I know that it is possible to reach that goal with contextual filter. I did it once, but can't do it again.

Can somebody help me make that views work like that ?


texts: Updating all existing user's custom field

texts:
I am fairly new to Drupal development and ran into a problem when trying to create a cron to update the value on a custom field for all the existing users.

Here is the code, when I click run cron it does nothing. I do no see my value in the custom field I created on any of the users.

/**
* Implementation of hook_cron().
*/
function testingdev_cron()
{
  $users = entity_load('user');
  foreach ($users as $user)
  {
    $user->field_my_field = 'test';
    user_save($user);
  }
}


texts: Suggestions for adding Advanced Search features to a block (using the dashboard)?

texts:
Is it possible to do the following:

Add a Search box to a block through the dashboard?
Have an Advanced Search on multiple fields in that block?
Have the results of the search open in a new page?

I understand that there are options to do this with code, but my client would like to manipulate as many areas as possible through the dashboard.

Any suggestions?


texts: How can I leave Subject as blank when fill nothing in the subject field of a comment?

texts:
When we fill nothing in the subject field of comment, drupal will use the comment body as the value of subject. See the code in CommentForm::buildEntity

// Validate the comment's subject. If not specified, extract from comment
// body.
if (trim($comment->getSubject()) == '') {
  if ($comment->hasField('comment_body')) {
    // The body may be in any format, so:
    // 1) Filter it into HTML
    // 2) Strip out all HTML tags
    // 3) Convert entities back to plain-text.
    $comment_text = $comment->comment_body->processed;
    $comment->setSubject(Unicode::truncate(trim(Html::decodeEntities(strip_tags($comment_text))), 29, TRUE, TRUE));
  }
  // Edge cases where the comment body is populated only by HTML tags will
  // require a default subject.
  if ($comment->getSubject() == '') {
    $comment->setSubject($this->t('(No subject)'));
  }
}

I still need to show Subject if it's been filled, while leave the Subject as blank when the user fill nothing in. To programmatically change the default behavior, we may need to override the function after buildEntity take place, otherwise buildEntity will override it again to the comment body. Is it possible to do that?


texts: fatal error when i want to disable apachesolr module

texts:
I see an error when i want disable apachesolr module.
what should i do?


texts: Any security issues accessing $_POST and returning values from it in AJAX commands?

texts:
Just wondering if there needs to be any sanitization here:

/**
 * Implements hook_ajax_render_alter().
 */
function my_module_ajax_render_alter(&$commands) {
  if (isset($_POST['_triggering_element_name'])) {
    $commands[] = array(
      'command' => 'myCustomCommand',
      'data' => $_POST['_triggering_element_name'],
    );
  }
}


texts:
I have a SMTP Authentication Support 7.x-1.0 module in D7. Its enabled and configured correctly with permissions.

Emails are not getting delived, I dont know what is the issue here.
Am I missing something here?

Tried/checked following things:

SMTP server is running, tested it. From command line emails are getting delivered.
No change in any of the core Drupal 7 modules and in SMTP module.
No errors found in drupal reports/ smtp logs

This is what I am getting when I try to check SMTP test email.

- SMTP.module is active.
 - The configuration options have been saved.
 - SMTP.module is active.
 - A test e-mail has been sent to    testemail@mycompanydomain.com.
 - You may want to check the logs for    any error messages.

Following is the debugging output.

SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 mycompanydomain.com ESMTP Postfix "
SMTP -> get_lines(): $data is "220 mycompanydomain.com ESMTP Postfix "
SMTP -> FROM SERVER:220 mycompanydomain.com ESMTP Postfix
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-mycompanydomain.com "
SMTP -> get_lines(): $data is "250-mycompanydomain.com "
SMTP -> get_lines(): $data was "250-mycompanydomain.com "
SMTP -> get_lines(): $str is "250-PIPELINING "
SMTP -> get_lines(): $data is "250-mycompanydomain.com 250-PIPELINING "
SMTP -> get_lines(): $data was "250-mycompanydomain.com 250-PIPELINING "
SMTP -> get_lines(): $str is "250-SIZE "
SMTP -> get_lines(): $data is "250-mycompanydomain.com 250-PIPELINING 250-SIZE "
SMTP -> get_lines(): $data was "250-mycompanydomain.com 250-PIPELINING 250-SIZE "
SMTP -> get_lines(): $str is "250-ETRN "
SMTP -> get_lines(): $data is "250-mycompanydomain.com 250-PIPELINING 250-SIZE 250-ETRN "
SMTP -> get_lines(): $data was "250-mycompanydomain.com 250-PIPELINING 250-SIZE 250-ETRN "
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $data is "250-mycompanydomain.com 250-PIPELINING 250-SIZE 250-ETRN 250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $data was "250-mycompanydomain.com 250-PIPELINING 250-SIZE 250-ETRN 250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $str is "250-8BITMIME "
SMTP -> get_lines(): $data is "250-mycompanydomain.com 250-PIPELINING 250-SIZE 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME "
SMTP -> get_lines(): $data was "250-mycompanydomain.com 250-PIPELINING 250-SIZE 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME "
SMTP -> get_lines(): $str is "250 DSN "
SMTP -> get_lines(): $data is "250-mycompanydomain.com 250-PIPELINING 250-SIZE 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN "
SMTP -> FROM SERVER: 250-mycompanydomain.com 250-PIPELINING 250-SIZE 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.1.0 Ok "
SMTP -> get_lines(): $data is "250 2.1.0 Ok "
SMTP -> FROM SERVER:250 2.1.0 Ok
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.1.5 Ok "
SMTP -> get_lines(): $data is "250 2.1.5 Ok "
SMTP -> FROM SERVER:250 2.1.5 Ok
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "354 End data with . "
SMTP -> get_lines(): $data is "354 End data with . "
SMTP -> FROM SERVER:354 End data with .
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.0.0 Ok: queued as 29B7262 "
SMTP -> get_lines(): $data is "250 2.0.0 Ok: queued as 29B7262 "
SMTP -> FROM SERVER:250 2.0.0 Ok: queued as 29B7262
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "221 2.0.0 Bye "
SMTP -> get_lines(): $data is "221 2.0.0 Bye "
SMTP -> FROM SERVER:221 2.0.0 Bye


texts: Display children of taxonomy term in parent taxonomy page

texts:
i would like to print the children of taxonomy term in its parent taxonomy page.
For example there is a news portal and under Sports taxonomy term page i would like to print the children of Sports term:
SPORTS
football #basketball #tennis ...
and then the latest nodes...
How can i achieve this?


texts:
I am getting a PDO exception error when I am trying to delete a status update. There is a sub module in statuses module, Statuses Comments Flag Integration; maybe it has some problem.

(In addition I am getting the _The module providing this flag wasn't found, or this flag type, fbss_comment, isn't valid_ error when trying to enable "comments like flag".)

Maybe I have to create a table. How do I create the table for this error? I know I have to run an sql query in phpadmin.

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'project_kickstart.flag_content' doesn't exist: DELETE FROM {flag_content} WHERE (content_type = :db_condition_placeholder_0) AND (content_id IN (SELECT fbss_comments.cid AS cid FROM {fbss_comments} fbss_comments WHERE (sid = :db_condition_placeholder_1) )) ; Array ( [:db_condition_placeholder_0] => fbss_comment [:db_condition_placeholder_1] => 50 ) in fbss_comments_flag_statuses_delete() (line 20 of C:\Users\taimoor\Sites\devdesktop\project_kickstart\profiles\project_kickstart\modules\contrib\statuses\submodules\fbss_comments\fbss_comments_flag\fbss_comments_flag.module)

I have mentioned the additional error because i think they are related.


texts:
can we use one argument for two contextual filters OR
can we create and pass dynamic argument from one filter to another by using validation php code in first one?

drupal7.com/location-map/region-or-type-field-here

i want to use contextual filter for region and type fields for same argument.


texts: Hide columns depending on checkbox state with Javascript

texts:
I have a form with a fieldset where I created a simple checkbox:

$form['my_fieldset']['my_checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => t('my title'),
    '#default_value' => 1,
    '#disabled' => FALSE,
);

Then, in other fieldset, I have a tableselect with these columns:

slot1
slot2
slot3

The data for these columns is as below:

'slot1' => array(
    'data'=> array(
        '#type' => 'select',
        '#title' => 'Slot1',
        '#title_display'=> 'invisible',
        '#default_value'=> '',
        '#value' => 'slot1',
        '#options' => $my_options,
        '#name' => 'slot1',
        '#attributes' => array('class' => array('update-slot1')),
    ),
),
'slot2' => array(
    'data'=> array(
        '#type' => 'select',
        '#title' => 'Slot2',
        '#title_display'=> 'invisible',
        '#default_value'=> '',
        '#value' => $emulator_data['slot2'],
        '#options' => $cards_available,
        '#name' => 'slot2[' . $emulator_data['container'] . ']',
        '#attributes' => array('class' => array('update-slot2')),
    ),
),
'config' => array(
    'data'=> array(
        '#type' => 'select',
        '#title' => 'config title',
        '#title_display'=> 'invisible',
        '#default_value'=> '',
        '#value' => 'config',
        '#options' => $my_options,
        '#name' => 'config',
        '#attributes' => array('class' => array('update-config')),
    ),
),

What I need is to hide 'slot1' and 'slot2' columns if the checkbox is checked and hide the 'config' column if it's unchecked, using javascript.


texts: The wrapper of Text field is changing after adding a new item in a field collection

texts:
I face a issue in my code in drupal 7. I alter a field_collection module. I have unlimited field collection (field_smart_objectives) that has two field collections (field_smart_objective_task and field_tms_task). field_tms_task is unlimited and has a select list that fire an ajax callback when the selection change and it will update a text field in field_smart_objective_task. My form as in the image below

This is my code

function field_collection_form_alter(&$form, &$form_state, $form_id) {
global $user;

if($form_id == 'employee_performance_node_form') {

$weightCount=0;
$maxField=0;

 $delta_tn=0;
$delta_tn  =$form['field_smart_objectives']['und']['#max_delta'];

while($maxField<=$delta_tn){
    $delta_tn_ud=0;
    $delta_tn_ud = $form['field_smart_objectives']['und'][$maxField]['field_tms_task']['und']['#max_delta'];
    $delta = 0;
    $Count_progress=0;

    while ($delta <= $delta_tn_ud) {

           $content_type= $form_state['values']['field_smart_objectives']['und'][$maxField]['field_tms_task']['und'][$delta]['field_task_progress']['und'][0]['value'];

          if($content_type == "0")
           {
              $Count_progress= $Count_progress + ( 100 / $delta_tn_ud);
           }

    $form['field_smart_objectives']['und'][$maxField]['field_tms_task']['und'][$delta]['field_task_progress']['und']['#ajax'] = array(
          'callback' => '_user_ajax_check',
          'wrapper' => 'test_entity_callback'.$maxField,
          'method' => 'replace',
          'effect' => 'fade',
          'event' => 'change',
        );

        $delta++;
}

           if($delta_tn_ud==0)
          {
           $form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und'][0]['field_so_progress']['und'][0]['value']['#value'] = $Count_progress;
         }
         else
        {
            $form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und'][0]['field_so_progress']['und'][0]['value']['#value'] =$Count_progress;
        }

    $form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und']['#prefix'] = '
';
    $form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und']['#suffix'] = '
';

$maxField++;
}

function _user_ajax_check($form, &$form_state) {
 $delta_tn=0;

  $delta_tn  =$form['field_smart_objectives']['und']['#max_delta'];

  return $form['field_smart_objectives']['und'][$delta_tn]['field_smart_objective_task'];

}

We I change the select value of field_tms_task select list, it update the text field and it works fine. My issue is when I add another field_smart_objectives and try to change the select value of the first field_smart_objectives

$form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und']['#prefix'] = '
';

$maxField should be zero, but it change to 1. Could Anyone tell me why it is happen?

Thank you


texts:
I'm trying to debug an issue with a delete query not happening. I've added logging before the query, after the query and I'm logging the return value of the query. Everything looks right, the only problem is that the rows are still in the database.

It's a simple query, I can't see anything wrong with it:

$result = db_delete('cloud_files')
  ->condition('uri', $uri)
  ->execute();

I've checked the $uri in every way I possibly can and it's right. I've tried executing the delete query by hand and it works just fine. The table name is correct, the field name is correct, the $uri is correct. I don't know what else to check.

I've used the Devel module to log the queries and while it logs queries that happen both before and after this query, it doesn't log this query at all. However, I've got error_log() calls before and after the query so I know this code is being run and it reports that it is running successfully.

I've even added code to select the data before deleting it and it works!

$select = db_select('cloud_files', 'cf')
                ->fields('cf')
                ->condition('uri', $uri)
                ->execute();

$entry = $select->fetchAssoc();

error_log("entry: ".print_r($entry, true));

That works, it prints out the row I'm trying to delete.

dqp() doesn't work for delete queries, so I don't know of any way of getting the truly final sql being executed.

I've made sure that if I connect using the mysql command line client from the drupal host with the user/password in the drupal config that all of the commands work.

How do I debug this? What is going wrong?

EDIT:

Is there any kind of transaction happening during a delete action? Could this behavior be the result of those delete queries happening in a transaction that gets aborted?


texts: Save form when user refreshes page from browser or click on any anchor tag inside page

texts:
I have made a form in drupal.

What I want is when the browser unload the page from any click whether by clicking on anchor tag or from browser refresh buttons I want to save data of my form through js/ajax or anything possible in drupal.

If any more explanation needed please do ask me. Thanks in advance.

I was trying do this by browser 'unload' event and 'beforeunload' event. But unable to save data of my form because browser doesn't wait for anything writtent inside and just ask for confirmation. Any help will appreciated.

This what I was trying to do:

$(window).bind('beforeunload', function() {
  return 'Do you really want to leave?';
  //coming here instead of it what i want
  //is save the form then return if user says yes and no the don't save the form.
});


texts:
I have this very simple implementation of hook_node_access

function applx_node_access($node,$op,$account){
    drupal_set_message($node);
}

This returns

applx_application
forum
article
page
forum

And because of this i am not able to proceed further. I'm not sure why it prints the name of all bundles.


texts: welcome page before main page (home page)

texts:
How do I redirect the users who want to visit my site to a PHP page that has a link to index.php?

When someone go to example.com they should see a PHP page (e.g. a welcome page) where they would find a link to access the front page.


texts: How to remove search on Site and leave only search on Content? When I use search on Site it says "Search is temporarily unavailable. If the problem persists, please contact the site administrator". When I search on Contents, it is OK.


texts: How to find Image URI in Kint via .entity in the node tree

texts:
I am working on Drupal 8 finally and using the replacement for Krumo which is Kint. It packs a lot more information in than Krumo did, and came with a bit of confusion.

While trying to get the image uri of an image that was rendered via a content type, the uri was not listed. I did however find an answer here Get Image URL in Twig .

And I saw that my reference needed .entity.uri.value prepended to it. This worked, but after further inspection of my node tree in kint I could not find anything the led to .entity as a reference. So how do I found out what to appended to my node tree reference if it is not listed?


texts: Wrong path when moving from MAMP multisite to remote website

texts:
I have different sites in MAMP, each of them being located in ../htdocs/
i.e. ../htdocs/site1, ../htdocs/site2, ../htdocs/site3, etc.
In some page of site1, I have something like

Petit retour aux sources : comment tout a commencé

Le golfe du Morbihan en 2008

En 2009, cap sur l'archipel de Glénan

Cette année (2010), c'est Bénodet !

Et pourquoi pas Stockholm en 2011 ?

2012, l'année des cairns du golfe du Morbihan

En 2013, tranquillement sur la Vilaine...

Golfe du Morbihan « agayne » en 2014

2015 : encore le Golfe mais en famille

Then, I move site1 to web provider and ../htdocs/site1 becomes www (root of the web site).
And, of course, URLs such as "/site1/node/36" don't work anymore :-(
How can I solve that?


texts: How do I verify a block can be shown in the current page?

texts:
I created a normal block and configured it using the following settings.

I don't want to show the block on node/2 and node/3, for example. I want to get the block render, but verify first the block can be shown on the current page.

// 1 is the block ID.
$block = block_load('block', 1);
// I want to verify if the block can be shown on the current page before getting the renderable array.
$renderable_block = _block_get_renderable_array(_block_render_blocks(array($block)));

I can verify $block->pages contains the path for the current page, but I think there is a proper way to do that. I am sure there is a core function to which I can pass the block object and the current path.

What core function should I use to verify the block is visible in the current page?


texts: sub directory multisite just redirecting to default after first page

texts:
I have a sub directory multisite setup on a sub domain. (locally with mamp everything is running fine), but on my live server, i can only reach the first (home) page of the multisite site, and when going anywhere (q?=user/login), i get directed to the default site.

site is dev.mysite.com/www.example.com

i have softlink in the drupal root - www.example.com -> ./

in sites.php i have

$sites = array('dev.mysite.com.www.example.com' => 'example.com',);

and of course the structure is sites/example.com

nothing like a cookie address in the settings... i dont know what else could be wrong. Using the same htaccess, the default, that was working locally for me.

i did notice something interesting that could be a clue. I have a logo image embedded in the page template. (img src="<?php print base_path().path_to_theme(); ?>/img/logo.png")

so locally the source prints as:

img src="/www.mysite.com/sites/example.com/themes/example/img/logo.png"

and on the server it looks like

img src="http://dev.mysite.com/www.example.com/sites/example.com/themes/example/logo.png"


texts:
There is a way to prevent the editing of my custom contet type from UI?
I have created my custom content type programmatically and I added a few fields and field groups.
The content type and fields must not be editable by UI but only from code.
I have tried to use the property 'locked' in hook_node_info() but without results, the content type is editable yet.


texts: Show block content inside custom node template

texts:
I've created a custom template (node--<mytype>.tpl.php), and I'd like to display the calendars from the Availability Calendars module. I don't understand how to load them.
I've tried with this code, but it doesn't work.
$block = module_invoke('availability_calendar', 'block_view');

Can you help me?


texts: Content View to sort results to match the users Profile 2 taxonomy term

texts:
I have a taxonomy term that gets assigned to a content type via entity reference, and the Drupal user, via Profile 2.

I want to add a filter to a content view that matches the 2 up, so if you filled in your user profile saying you only interested in x, have a view that only show content that was assigned with the same term.

I have tried adding author, profile2, taxonomy term relationships etc without any luck. Any pointers would be greatly appreciated.


texts: Selling per-node access without creating two entities

texts:
I want to create a Pay-per-view site under Drupal.

I followed the instructions of Commerce guys, which combines the use of Drupal Commerce and Content access.

But this solution means creating two entities: a product display + the paying article. It raises several problems: two nodes with the same name, two nodes as we can comment...

I would thus want only one node, with a visible teaser before purchase, then all the text after purchase.

My question : how to selling per-node access without creating two entities ?


texts: Search box result => node add (searched string = node title)

texts: What I want to achieve is quite simple, when performing a search trough the search block , instead of receiving the message "your search yielded no results" when the searched string is not in the DB I would like to have the possibility to add it as a node (question box "do you want to add yes or no?) , so the searched text would be the new node title.


texts:
I've been searching high and low for a feeds module that will show Facebook and Twitter feeds with the Views Modules (Drupal 7.x). With Twitter using oauth, many Drupal 7 social feed modules haven't caught up to using oauth yet. The main reason I want to use views with the social parsers is because I want to use animation(like slide show) to show each social feed as it comes in.

I have found Social Parsers for Feeds that will work with views module but none that will work for Drupal 7.x

Does anyone have any suggestions that will allow social feed modules to be used in the views moudle?


texts:
I want Authenticated users to be able to add content (a custom content type). However, they should not see all the fields.

Users with a Role of "manager", should be able add/edit this content type, and see all the fields.

I've created a custom module, using hook_theme and hook_form_alter to hide the display of fields, but i don't know how to do this based on user or role. With the module active, even the admin user is blocked from seeing all the fields.

What is the best way to setup a custom node edit form based on Role, or at minumum, bypass for the Admin user?

For example, I have hide the form fields in erp_reco--node-form.tpl.php, and hide the revision, author, comments etc in hook_form_alter.

How do i hide fields then based on Role?

 function cct_erp_reco_theme($existing, $type, $theme, $path) {
return array(
    'erp_reco_node_form' => array(
        'arguments' => array('form' => null),
        'path' => drupal_get_path('theme', 'ERP').'/templates/forms',
        'template' => 'erp_reco--node-form', 'render element' => 'form',
    ),
); }

function cct_erp_reco_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'erp_reco_node_form') {
$form['revision_information']['#access'] = false;
$form['options']['#access'] = false;
$form['path']['#access'] = false;
$form['comment_settings']['#access'] = false;
$form['author']['#access'] = false;
$form['path']['#access'] = false;
$form['menu']['#access'] = false;
}
}


texts: How can I redirect users to the order information after adding product

texts:
This is the goal:
Once user click on a link, product needs to be added to the basket, and order information page needs to appear, so user can fill it.

I've created a controller, and everything works, unless the user in anonymous.
In that case, a "You are not authorized to access this page." error appears, and product is not added.
However, (not sure if this is important), if the user visits a product first (just visit, without additional interaction), and then visit the link there is no that error. Also, if there are some items already in the added (with classic buttons), everything also works, for anonymous users as well.

I've used this to add the product:
https://www.drupal.org/node/2866020

Shortly, it creates order item, and adds with cart manager.

and at the end, I've added

$cart_id = $cart->get('order_id')->getValue();
$cart_id_value = $cart_id[0]['value'];
$response = new RedirectResponse('/checkout/' .$cart_id_value.'/order_information');
$response->send();
return;

Any help or guidance will be appreciated.

Thanks


texts: Creating a caption for images in Drupal 7 Media module

texts:
Is there a way to create a caption field on images? I have seen in the latest Media module you can add your own fields on images now but I can't seem to get them to output in the WYSIWYG module correctly or on the final page.

Modules
 - Media 7.x-2.10
 - WYSIWYG 7.x-2.4
 - IMCE 7.x-1.11


texts: How to add page restrictions for blocks in frontpage?

texts:
I have several blocks in my homepage : 2 statics and 1 with a pager.

I want to hide a static block when paging my homepage (after page "0").

I saw something similar in How can I show a block in a view page, excluding it's paginated pages but I do not know exactly what to put in the PHP code regarding the homepage : '' or '/' (instead of 'news' in this example) ?

<?php
$url = request_uri();
$pos = strpos($url, "page");
if ($pos === false && arg(0) =='news') {
return TRUE;
}
?>

I tried also this code that I saw on this answser : How to add page restrictions for blocks in drupal? but it does not work for me.

<?php
if (arg(0)=='/' && is_numeric(arg(1))) {
return TRUE;
} else {
return FALSE;
}
?>

My website is : http://femme.bonsplansdemarc.fr/


texts: How do I attach CSS styles to all the pages?

texts:
i have a theme installed his name is 'businessplus_lite' i want to add some custom style to my sub theme , but i can't see any css applicable , can anyone help me please !

  .info.yml

name: mysub-theme
type: theme
description: 'my sub-theme Commissions'
core: 8.x
base theme: businessplus_lite

libraries:
  - my-sub-theme-name/my-sub-theme-style

  libraries.yml

my-sub-theme-style:
  css:
    component:
      css/components/style.css: {}


texts: I am building a user profile page and i would like to show what polls the user has voted on.  Showing polls the user created is easy, but is there a way to keep track of their votes?


texts: How do I convert the text value of the node:field_frequency to the ISO-8601 (Biennial -> R/P2Y) in DKAN 1.14?

texts:
I have Dkan 1.14 distribution installed on Drupal 7.67. Also catalog file generation (catalog.xml) is configured for harvesting.
When setting up data mapping between Drupal and Open Data entities using the Drupal web panel's API editing section (/admin/config/services/odsm/edit/dcat_v1_1) to get the value of the <dct: accrualPeriodicity> element, I use the placeholder [node: field_frequency].
As a result of catalog file generation in the structural element dct:accrualPeriodicity
returns a text value of type dkan_frequency (for example, Daily), but I would like to get the values converted to iso-8601 (R/P1D, respectively).
How can I achieve this behavior using only the Drupal web control panel?
Related links:

A DKAN 1.14 module, which implements the necessary conversion functions:
https://github.com/GetDKAN/dkan/blob/7.x-1.14/modules/dkan/dkan_dataset/modules/dkan_dataset_content_types/dkan_dataset_content_types.module
Recommendations regarding the mutual correspondence of the textual values "field_frequency" and the notation for them in accordance with ISO-8601
https://project-open-data.cio.gov/iso8601_guidance/#accrualperiodicity


texts: Fallback to local images when Cloud Files breaks?

texts:
I'm using the Cloud Files module which uses the Rackspace Cloud Files PHP API to store all uploaded files on Rackspace Cloud Files (a CDN). It all works very well.

However, today, Rackspace itself had an outage related to their API and it caused my entire site to break. I absolutely can't have this happen when my site is finally live. Is there any way to keep the files locally as well as in Cloud Files so that if there is a problem I can flip a setting in the admin pages and it'll start using the local files so that the site continues working while Rackspace works on the problem?


texts: How do I group and add space between checkboxes?

texts:
I need to group the checkboxes and put some spacing between each group.
They need to look like this:

item1
item2

item3
item4

I can easily add an additional field to the options array specifying which group each item belongs to but I how do I render them this way?
I imagine I would have to do this by adding classes. But how do I do that?


texts: How to create custom pages for http 500 and 410 status errors?

texts:
In the site information section in the configuration, there is an option for setting the 404 page. But How will I set a custom page for http 500 and 410 error pages?

Is there any specific module for this? OR I have to create a custom tpl file in some pattern? Any idea?


texts:
Admitted, I don't truly understand Displaysuite.

What I need, is, something of the following:

foreach (get_certain_nodes(), $nid) {
  $node = node_load($nid);
  $rendered_node = call_displaysuite_to_render_the_node($node, 'build_mode_foo');
  $output .= $rendered_node;
}

The missing link is how to render the node, using a predefined build mode. Or am I doing it wrong?


texts: Extending a year range of a popup calendar

texts:
Good day

Is there a way I can extend a year range of a popup calendar in drupal 7?


texts: Check if a panel page is enabled programmatically?

texts: I need to be able to verify if a panel page (which is just a variant of a ctools page) is enabled or disabled.  How would one do this, programmatically?  If it is disabled, how would one enable it, programmatically?


texts: drupalLogin in functional JavaScript tests passes locally but fails on Drupal.org?

texts:
During functional JavaScript testing one can create and login a user by using the following code:
$this->testUser = $this->drupalCreateUser(['permission']);
$this->drupalLogin($this->testUser);

This works fine when testing locally with PhantomJS. However after uploading this code to drupal.org it keeps failing randomly (sometimes 1 test, sometimes 2) with the following error:

User dOGIV5Iu successfully logged in.
Failed asserting that false is true.

This appears to be coming from the assertion in BrowserTestBase::drupalLogin, which should normally check that the user is logged in correctly.
$this->drupalGet('user/login');
$this->submitForm([
  'name' => $account->getUsername(),
  'pass' => $account->passRaw,
], t('Log in'));

// @see BrowserTestBase::drupalUserIsLoggedIn()
$account->sessionId = $this->getSession()->getCookie($this->getSessionName());
$this->assertTrue($this->drupalUserIsLoggedIn($account), new FormattableMarkup('User %name successfully logged in.', ['%name' => $account->getAccountName()]));

How come that a test function does work locally, but not on Drupal.org? Even stranger is that this function is used throughout multiple core tests without issues. And why is this assertion failing randomly?


texts:
Is there a way to only grant a role access to certain content?
So that every user given that role can access what they need without others being able to, while still being limited from accessing content that only other roles can access?

Also is there a way to automatically grant new roles to users as a result of performing certain actions?
Just like how some forums work where you can only start new threads when you've written 10 replies? Only this will be people being able to access a new level of the site when they have say uploaded a file or corresponded with a certain person and that person has given a thumbs up?
The latter I suppose could come in form of you being granted a role when a certain level is reached that enables you to give other users roles up to a certain limit?

Cheers,
Thor


texts: Should I still prevent caching of pages with an Address Field?

texts:
On the Address Field module page it says there can be problems with Drupal‘s cache and anonymous authors:

  Address Field should work on any entity type, but if you use it on an entity type that can be created or edited by anonymous users (such as a user account field present on the registration form), you should ensure pages where the form is present are not cached by Drupal. Drupal's core page caching and its AJAX form refresh used by this module do not work together.

  The recommended solution for now is to use the Cache Exclude module to tell Drupal which pages not to cache, such as user/register.

So I should prevent that pages get cached which allow anonymous users to enter an address.

I tried to find out more about this problem and found the issue Prevent Drupal from caching pages with forms that include an address field widget. In comment #14 it says that this issue is resolved in Drupal 7.27 (because of the fix to SA-CORE-2014-002).

Now I wonder if the linked issue is about the quoted problem (and the project page could remove this advice), or if I should still prevent caching for these pages (maybe for some other reason not talked about in that issue)?


texts:
I'm not sure what I've done wrong, but I just noticed that the front page of my site isn't showing the pager at the bottom so that visitors can get to older posts.

http://www.theresatutors.com/

I don't remember changing anything to hide this anywhere. What would cause this? Where can I look to turn it back on?

I've been searching trying to find a solution, but all of the pages that show up in my searches are people trying to hide the pager, not show the pager. :/

As far as I can tell I'm not overriding the mainpage in anyway or using Pages or anything like that. Just the standard Drupal homepage with standard Drupal blocks.

My theme settings for Bartik are set to allow 10 posts per page. I have 16 posts which are Published and Promoted to Front Page.

Any help is appreciated.


texts: Question regarding SearchAPI and Index performance/scaling

texts:
I have a site that will need to deal with thousands of nodes. it's an internal site, not public facing, with a daily concurrent user base of no less than 80 and no more than 100 users.

I am trying to figure out how to deal with search and indexing. The Big problem is I need facets and whatnot, but I also need instant data retrieval. So users can't wait for indexes to catch up. can one index via  SearchAPI near instantly?

On average, there might be 2-300 new nodes created per day, every day, by users, and an additional 5-600 nodes created per day+ through automated imports (Feeds).

I was thinking of just using straight views, and trying to do search filters, but it's not scalable and after a few months to a year it would be quickly unmanageable.

TL:DR: Many many nodes per day need indexed search with facets (SearchAPI and FacetAPI using ElasticSearch). Near instant retrieval required. If a user creates a node, they need to be able to see that node in the index within a few seconds or less.

Alternatively, thinking out loud, could I have it submit the new node to the index on every new node addition?


texts: How Can I change the machine name of product type

texts: How can I change the machine name of product type (in drupal commerce ) after it created and has several content , as example I has tv porduct type I want to change it to LCDTV , How can I change it?


texts: Add and/or option to Drupal Views' Contextual Filters?

texts: How can I add the "and/or" option to Drupal Views' Contextual Filters panel? I added it to Filter Criteria, but I can't seem to get it for Contextual Filters.


texts: How to give custom function in D8 custom field widget class?

texts:
I have created custom fields using field,field widget and field formatters.
One of the field I have created is a button. What I need is to write the submit handler for that button.

This is my CertfieldDefaultWidget.php

namespace Drupal\certfield\Plugin\Field\FieldWidget;

use Drupal;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
/**
 * Plugin implementation of the 'CertfieldDefaultWidget' widget.
 *
 * @FieldWidget(
 *   id = "CertfieldDefaultWidget",
 *   label = @Translation("Certfield select"),
 *   field_types = {
 *     "Certfield"
 *   }
 * )
 */
class CertfieldDefaultWidget extends WidgetBase {
  /**
   * Define the form for the field type.
   *
   * Inside this method we can define the form used to edit the field type.
   *
   * Here there is a list of allowed element types: https://goo.gl/XVd4tA
   */
  public function formElement(
    FieldItemListInterface $items,
    $delta,
    Array $element,
    Array &$form,
    FormStateInterface $formState
  ) {
      //print_r($items[$delta]->cert_fqdn);
      //exit();

 $element['cert_fqdn'] = [
      '#type' => 'textfield',
      '#title' => t('Fully qualified Domain Name'),
      '#value' => isset($items[$delta]->cert_fqdn) ?
          $items[$delta]->cert_fqdn : null,
      '#empty_value' => '',
      '#placeholder' => t('Fully qualified Domain Name'),
    ];
    $element['privatekey'] = [
      '#type' => 'textfield',
      '#title' => t('Private Key'),

      // Set here the current value for this field, or a default value (or
      // null) if there is no a value
      '#default_value' => isset($items[$delta]->cert_key) ?
          $items[$delta]->cert_key : null,

      '#empty_value' => '',
      '#placeholder' => t('PrivateKey'),
    ];

    // City

    $element['csr'] = [
      '#type' => 'textfield',
      '#title' => t('Certificate Signing Request'),
      '#default_value' => isset($items[$delta]->cert_csr) ?
          $items[$delta]->cert_csr : null,
      '#empty_value' => '',
      '#placeholder' => t('Certificate Signing Request'),
    ];
    $element['cert_crt'] = [
      '#type' => 'textfield',
      '#title' => t('Server Certificate'),
      '#placeholder' => t('Server Certificate'),
    ];
    $element['create_cert_btn'] = [
      '#type' => 'submit',
      '#title' => t('Server Certificate'),
      '#placeholder' => t('Server Certificate'),
    ];

$element['create_cert_btn'] = array(
    //'#name' => implode('_', $element['#parents']) .'_create_cert_btn',
    '#type' => 'submit',
    '#value' => t('Create/Renew Cert'),
    '#callback' => '_certfield_button_action'
        );

    return $element;
  }

} // class
?>

In my certfield.module OR CertfieldDefaultWidget.php file I have a function like as below

function _certfield_button_action(&$element, $form_state, $button){
}

But none of them is called when clicks on the Button .Please help me to find out a solution .


texts: How to create a query to get some products related with the identified user?

texts:
I want make a query for get some products related with the identified user. The type contain has a taxonomy field called 'operating system' and the main profile has also it. For example: If a user has a 'Android Phone' he has to see all products that have this operating system.

Anyone know how can I do it?

I have tried with many modules and I'm looking in the database now.


texts: An illegal choice has been detected. Please contact the site administrator in views exposed filters

texts:
I am using filter criteria in views for displaying data based on the input selected by the user.
Actually the drop down values in filters are node values of two content types.When I add content to those respective content types the drop down values are updating but in filter criteria configuration the newly added node values are not being checked as shown below diagram

Even though the above node value is not being checked, the same value is being added to particular drop down as shown below.

If I check all values individually and manually and check the option Limit list to selected items the error not displaying but the problem is when I am adding another node value (for example LOS3) the drop down values are not updating.

I have googled it for this error and I have applied some patches which worked for some of them but no result.

How to overcome this issue?


texts: How to rewrite this theme call to drupal_render

texts:
I have this call to the theme function in my code :

print theme('image_style',
            array(
                'path' => $news_image['uri'],
                'style_name' => 'thumbnail',
                'alt' => $news_image['alt'],
                'title' => $news_image['title'],)
            );

However in the theme function documentation you can read :

  Avoid calling this function directly. It is preferable to replace
  direct calls to the theme() function with calls to drupal_render() by
  passing a render array with a #theme key to drupal_render(), which in
  turn calls theme().

So, how do I rewrite the above simple function using drupal_render ?


texts:
I have a content type 'leg' and a template node--leg.tpl.php.
I'm using sky theme. I have a custom module as well, let's say for example, mymodule.
I put the template file into sites/all/modules/mymodule/theme. And I created a hook_theme and hook_preprocess_node.
But my template is not invoked as expected. I cleared all caches.

function mymodule_theme(){
    // The base theme registers node.tpl.php.
    $templates['node'] = array(
        'arguments' => array('elements' => NULL),
        'path' => drupal_get_path('module', 'mymodule') . '/theme',
        'template' => 'node--leg',
        'preprocess functions' => array(
          'template_preprocess',
          'mymodule_preprocess',
          'mymodule_preprocess_node',
          'mymodule_process',
        ),
    );
    return $templates;
}

function mymodule_preprocess_node(&$vars, $hooks){
    if($vars['type'] == 'leg'){

    }
}

When I put my template file into sites/all/themes/sky/templates and changed path in hook_theme to that location, it works.

function mymodule_theme(){
    // The base theme registers node.tpl.php.
    $templates['node'] = array(
        'arguments' => array('elements' => NULL),
        'path' => drupal_get_path('theme', 'sky') . '/templates',
        'template' => 'node--leg',
        'preprocess functions' => array(
          'template_preprocess',
          'mymodule_preprocess',
          'mymodule_preprocess_node',
          'mymodule_process',
        ),
    );
    return $templates;
}

I would like to know it is a right way or not.
I should not place my template in the sky theme folder, am I right ?


texts:
I have nearly this exact case but as it applies to Drupal 8:
 Store token replacement values in the database rather than tokens themselves).

I have a content type 'article' with a 'body' field which has been populated with tokens via the Token Filter module.  I believe the code should be something like found here https://www.drupal.org/project/drupal/issues/2043055 but can't get it to work.

function MYMODULE_node_presave(Drupal\Core\Entity\EntityInterface $node) {
  if ($node->bundle() == 'article') {
    $body = $node->get('body')->value;
    $token = Drupal::token();
    $body = $token->replace($body);
  }
}

Thanks for considering, -c


texts: How can I use user fields in panels title

texts:
This seems to be basic but I cannot get my head around it and I am rather stuck. I am trying to have a panel override in D7 on the user profile page and access a few fields that I have defined in a user profile type (first name and surname in profile2)

I have added a context of the profile type in the panel and set the title to use the content pane title. I add the profile field, how can I set this field to be the panel title?

Any help welcome please.


texts: Form Submit - Populate Title Before Validation

texts:
I have no idea why I cannot find an answer to this.  I've been able to do this with other fields except the 'title' field.

I have a form which I need to automatically populate the title field.  I don't want the user to populate it, so I'm hiding it by wrapping it in a  that's hidden.

I used hook_form_alter() to add a callback function to the form's #submit array, but those functions are called after the validation.  This would result in an error telling the user to enter a title.

Now I'm trying to use hook_form_alter and adding a validation callback function to the BEGINNING of the array like so:

function previous_meetings_form_alter(&$form, $form_state, $form_id)
{
    //Hide the title field
    $form['title']['#prefix'] = '
';
    $form['title']['#suffix'] = '
';
    //Callback function to execute before validation
    array_unshift($form['#validate'], '_previous_meetings_set_meeting_title');
}

Here is the callback function that is being called but NOT working:

function _previous_meetings_set_meeting_title(&$form, &$form_state)
{
    $form_state['values']['title'] = 'SOMETHING';
}

What am I doing wrong?  Can I set values in a validation callback?  Is there a right approach to this?

Thanks!


texts:
I am testing the boost module out, it is a great performance enhancement for the site I am working on.

However I would like to be able to get boost to clear it's cache using drush. Drush cc all doesn't seem to do this. And looking in the boost module code, there doesn't seem to be a cron command for it. Am I missing something or is this currently not implemented?


texts:
Every page of my theme will need to use jquery UI. I know it's included with Drupal 7, but I can't really decipher Drupal's way-too-technical documentation.  It looks like the only way to do it is with the template.php file.  But since I don't understand that file, I'm trying to avoid doing it that way.

Is there another way, or should I just try the template.php file?


texts:
I have set my auto URL allies to something like this "store/[node:nid]/[node:title]"

having node title in url will make it more human readable and better SEO.
the issue is I want to be able to access the node using this url "store/[node:nid]" only

here is the question again

my url is "www.site.com/store/1234/title"

I want this url to work as well "www.site.com/store/1234"

and even this "www.site.com/store/1234/new-title"

and even this "www.site.com/store/1234/wrong-title"

cheers
cheers


texts: How to change the value of a row in views

texts:
I've views formatted as table with a pager of 10 items pr page, in which I've a field called type, depending on that type, I need to modify the other field, show text.

I've tried using PHP global field, but when I put that it is not showing the checkboxes from the second page.

I've tried hook_views_pre_render, but did'nt see any good example to change the field.


texts: create a menu based on the parent of a drupal book

texts:
I've been working with the book module bundled with drupal 7 and have a question.
Say i have a book x, and this book contains 4 pages which each have 2 children giving a structure like this:

Book x

Subheading 1

Page 1
Page 2

Subheading 2

Page 1
Page 2

Subheading 3

Page 1
Page 2

Subheading 4

Page 1
Page 2

What I want to do is create a menu that will sit at the bottom of the page which displays links based on these 4 subheadings, i.e. if you were viewing Subheading 1 the menu would display links to the 2 child pages of the subheading. Is this possible?


texts: D7 Fullcalendar: drag/drop/resize returns 404 error

texts:
when I drag/drop or resize an item, the js console returns:

Failed to load resource: the server responded with a status of 404 (Not Found)

localhost/drupal7/fullcalendar/ajax/update/resize/380

Failed to load resource: the server responded with a status of 404 (Not Found)

localhost/drupal7/fullcalendar/ajax/update/drop/380

Of course the changed items are not being saved.

Any ideas? Everything else is working fine. Im using the latest version of the fullcalendar library and the latest version of the fullcalendar module.


texts: How do I find out the user name and password for an existing account?

texts:
MY site was created and maintained from a developer I cannot contact, and I need to know the username/password the developer used to access the site.

How can I achieve this?


texts: Facet blocks are not shown with Facet API Pretty Paths activate

texts:
I've enabled Facet API Pretty Paths and the Face blocks are not shown once I select a category.

For example: the Facet Blocks (color and prices) are not shown for the link: /products/field_brand/simple-threads-68

These are:
Drupal 7.44
Facet API Pretty Paths: 7x-1.4
Profile: Commerce Kickstart (commerce_kickstart-7.x-2.38)

Thanks,
Araujo


texts: How to validate the headers of a csv uploaded with cck filefield?

texts:
I need my users to upload a csv, using a cck filefield. I then wish to confirm they have the correct order of columns.

My research led me to believe that writing a custom validator for the filefield, was the best option. I have used this as a resource: https://drupal.org/node/546146 for writing it...

I then used this for an example of how to open a csv and read it: http://oliverhuynh.wordpress.com/2011/06/21/drupal-batch-csv-importing-template/ ...

I'm very new to this and lack the insights to spot what i'm doing wrong... Here's my code:

function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  if($form_id == 'stocklist_node_form') {

    $form['field_stocklist'][0]['#upload_validators']['stocklist_validation'] = array();
    return $form;
  }

}

/**
 * The validation for the file.
 *
 */

function stocklist_validation($field) {
  // variable for error messages
  $errors = array();

  // do some processing on the field / file
  $filepath = $field->filepath;
  global $base_url;
  $fileurl = $base_url . '/' . $file_path;
 // Open the file
      if ( $handle = fopen($fileurl, 'r') ) {
        $line_count = 1 ;
        $first = TRUE ;
        if ( $line = fgetcsv($handle, 4096) ) {

        // Validate the headers

         if ( $line[0] !== 'manufacturer' ) {
            $errors[] = t('Unable to verify uploaded file !filepath. Please ensure the file has the correct file type, column names and information.', array('!filepath' => $field->filename));
         }
        }
        fclose($handle);
      }

// in case of error, add error message

          return $errors;
}

I would really appreciate any help or pointers... I feel I'm one step away from finishing it but running out of google searches... It doesn't matter whether I upload a valid or invalid file, it just throws the defined error message... Why is it doing that?

edit:

Here is a screenshot using devel whilst viewing a 'stocklist' type node. Thought it may help...


texts: How to display configuration updates when deleting fields programatically

texts:
I am working on a module that adds it's needed fields automatically when you enable it's function  in the UI for specific entity types. It also deletes it's needed fields when you disable it's function for an entity type. (I'm not talking about when you enable the module)
We are doing this with the following on a checkbox form that displays the entity types that can have the function:
foreach ($values['product_variations'] as $key => $value) {
  foreach ($neededFields as $neededField => $data) {
    $field_storage = FieldStorageConfig::loadByName('commerce_product_variation', $neededField);
    if (!$field_storage) {
      FieldStorageConfig::create([
        'entity_type' => 'commerce_product_variation',
        'field_name' => $neededField,
        'type' => $data['field_type'],
        'settings' => $data['settings'],
        'cardinality' => $data['cardinality'],
      ])->save();
    }
    $field = FieldConfig::loadByName('commerce_product_variation', $key, $neededField);
    if (!$value) {
      if ($field) {
        $field->delete();
      }
      continue;
    }

This works fine, except that (from what I understand) Fields API automatically deletes the FieldStorageConfig when the last instance of a field is deleted. This would not be a big deal except when the FieldStorageConfig is deleted programmatically, any view that has these enabled fields will be deleted along with it. Whereas if you delete the fields manually though the UI, the view will just be disabled as this was added in this issue.
Even if I were to address this behavior when deleting programmatically, I would still like to display the message when there are changes to the configuration as we are still removing field instances which can result in the loss of data.

Are you sure you want to delete the field?
This action cannot be undone.

Configuration Updates
The listed configuration will be updated:

Is there an EventSubscriber to display this message, or would I need to copy the source code for this and add it to my module?


texts: Remove  tag after form tag in user register form Drupal 7

texts:
I have added this code to template.php

function mytheme_theme(&$existing, $type, $theme, $path){
  $hooks = array();
   // Make user-register.tpl.php available
  $hooks['user_register_form'] = array (
     'render element' => 'form',
     'path' => drupal_get_path('theme','mytheme'),
     'template' => 'user-register',
     'preprocess functions' => array('mytheme_preprocess_user_register_form'),
  );
  return $hooks;
}

function mytheme_preprocess_user_register_form(&$vars) {
  $args = func_get_args();
  array_shift($args);
  $form_state['build_info']['args'] = $args;
  $vars['form'] = drupal_build_form('user_register_form', $form_state['build_info']    ['args']);
}

also I have created user-register.tpl.php with this

test

but the result is

<form class="user-info-from-cookie" enctype="multipart/form-data" action="/user/register" method="post" id="user-register-form" accept-charset="UTF-8">

    test

</form>

How I can remove the div tags between form and span.

Thanks


texts: Module with multiple Blocks in multiple files

texts:
I've created a module which creates 2 blocks.

function my_module_block_info() {

  $blocks['blockA'] = array(
    'info' => t('blockA'),
    'cache' => DRUPAL_CACHE_PER_ROLE,
  );

  $blocks['blockB'] = array(
    'info' => t('blockB'),
    'cache' => DRUPAL_CACHE_PER_ROLE,
  );
  return $blocks;
}

function my_module_block_view($delta = '') {
  switch ($delta) {
    case 'blockA':
      $block['subject'] = t('subjectA');
      if (user_access('access content')) {
          $block['content'] = 'HelloA';
      }
      return $block;
      break;

    case 'blockB':
      $block['subject'] = t('subjectB');
      if (user_access('access content')) {
          $block['content'] = 'HelloB';
      }
      return $block;
      break;
}

Everything good so far. Here is my question:

I would like developers to create blocks using the same module (20 more blocks). How can I add a new block with its view without modifying the my_module.module? Is there a way to extend and include .php files that declare other blocks? So, instead of having a huge my_module.module file, I can have multiples .php files (one for each block).

Thank you in advance


texts: How can I export and then import taxonomy terms?

texts:
So I built my own custom entity type (we'll call it notes). And on my notes I have fields that use taxonomy terms, however when it comes to exporting the data out on individual fields, it shows the data, but when I restart the site and re-import everything, the taxonomy terms don't get imported with it.
Taxonomy terms is pretty important and a core with Drupal, so I don't understand why we can't export and import them easily like with the other data.
So I end up with fields that do not have taxonomy terms or is reported as missing.
Is there a way I can do this so when I import, the taxonomy terms get imported too?


texts: Testing installation profile with custom tasks

texts:
For a large project, we are using a code driven development workflow. We are using a custom installation profile to install and configure the contrib and custom modules used on the project. The ensure correctness of this profile, we need to test it like any other module.

Currently, we use a SimpleTest test case that looks like this which worked good so far.

class FooTestCase extends DrupalWebTestCase {

  protected $admin_user = null;

  public function getInfo() {
    return array(
      'name' => 'Foo Profile',
      'description' => 'Ensure that the Foo profile configure the site.',
      'group' => 'Foo',
    );
  }

  public function setUp() {
    $this->profile = 'foo';
    parent::setUp();
  }

  //Test methods ...
}

The site has to be multilingual, so in order to install and enable all the required language, I added a custom profile task using hook_install_tasks. The task works fine when executed from the browser. But it is not executed when DrupalWebTestCase::setUp` is run. So we are unable to test its effect to ensure they are not lost whatever the refactoring our profile will go through in the future.

Since languages installation require translations loading, the task itself use batch processing.

I'm looking for both a way to have this particular task executed in FooTestCase:setUp and more generally to have all the (non interactive tasks) in my profile executed.

For reference, here is the code for the task

function foo_install_tasks($install_state) {
  return array(on
    'foo_install_import_locales' => array(
      'display_name' => 'Install additional languages',
      'display' => TRUE,
      'type' => 'batch',
      'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
    )
  );
}

function foo_install_import_locales(&$install_state) {
  include_once DRUPAL_ROOT . '/includes/locale.inc';
  include_once DRUPAL_ROOT . '/includes/iso.inc';
  $batch = array();
  $predefined = _locale_get_predefined_list();
  foreach (array('nl', 'de') as $install_locale) {
    if (!isset($predefined[$install_locale])) {
      // Drupal does not know about this language, so we prefill its values with
      // our best guess. The user will be able to edit afterwards.
      locale_add_language($install_locale, $install_locale, $install_locale, LANGUAGE_LTR, '', '', TRUE, FALSE);
    }
    else {
      // A known predefined language, details will be filled in properly.
      locale_add_language($install_locale, NULL, NULL, NULL, '', '', TRUE, FALSE);
    }

    // Collect files to import for this language.
    $batch = array_merge($batch, locale_batch_by_language($install_locale, NULL));

  }
  if (!empty($batch)) {
      // Remember components we cover in this batch set.
      variable_set('foo_install_import_locales', $batch['#components']);
      return $batch;
  }
}


texts: Caption, prev next, play and pause not displaying

texts: I am using a Views Slideshow module to create a slideshow on the homepage. For the Image filed, I've enabled the the caption, Create prev/next controls, Create play/pause button etc... However, none of these seem to be displaying. What am I missing?


texts: how to display Persian date in webform module

texts:
I have problems to display a Persian date (Jalali Calendar System) with the Webform module

The errors I get are the following:

  The entered date must be @start_date or later.
  The entered date must be @end_date or earlier.

I want to be displayed in the yaer field  (1350  to Current year)


texts: how to generate view data from sql query?

texts:
i need to create a view that display last post for each user to make them into carousel, i do many search but no pure response. than i will try to generate my view from this sql query:

SELECT *
FROM `node`
WHERE `type` = 'post'
AND `nid`
IN (
SELECT MAX( `nid` )
FROM `node`
WHERE `type` = 'post'
GROUP BY `uid`
)
LIMIT 0 , 30

Any Idea?


texts: Why direction nav transition not working on Flexslider module?

texts:
I am using the following modules: Flexslider module (version flexslider 2.2), FlexSlider Views Slideshow Module and Views, in Drupal 7.

I build the slideshow, and define the Direction Nav (prev / next).

when I looked at the demo of the flexslider, I saw that these is a transition to the arrows when they are appearing and disappearing- it looks they are coming from the sides when I hover, and they going out when I stop hover.

unfortunately, I don't see any transition on my slider, and the the arrow just appear and disappear.

When I checked, I notice that the problem is that when I stop hovering, and then immediately hover again, I see that the transition is in fact happening, but it's only visible if I hover immediately again.

Does someone know what is the problem and can you help me solve this issue?

here is the direction nav code:

/* FlexSlider Default Theme
*********************************/
.flexslider { margin: 0 0 60px; background: #fff; border: 4px solid #fff; position: relative; -webkit-border-radius: 4px; -moz-border-radius: 4px; -o-border-radius: 4px; border-radius: 4px; -webkit-box-shadow: 0 1px 4px rgba(0,0,0,.2); -moz-box-shadow: 0 1px 4px rgba(0,0,0,.2); -o-box-shadow: 0 1px 4px rgba(0,0,0,.2); box-shadow: 0 1px 4px rgba(0,0,0,.2); zoom: 1; }
.flex-viewport { max-height: 2000px; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; transition: all 1s ease; }
.loading .flex-viewport { max-height: 300px; }
.flexslider .slides { zoom: 1; }
.carousel li { margin-right: 5px; }

/* Direction Nav */
    .flex-direction-nav {*height: 0;}
    .flex-direction-nav a  { display: block; width: 40px; height: 40px; margin: -20px 0 0; position: absolute; top: 50%; z-index: 10; overflow: hidden; opacity: 0; cursor: pointer; color: rgba(0,0,0,0.8); text-shadow: 1px 1px 0 rgba(255,255,255,0.3); -webkit-transition: all .3s ease; -moz-transition: all .3s ease; transition: all .3s ease; }
    .flex-direction-nav .flex-prev { left: -50px; }
    .flex-direction-nav .flex-next { right: -50px; text-align: right; }
    .flexslider:hover .flex-prev { opacity: 0.7; left: 10px; }
    .flexslider:hover .flex-next { opacity: 0.7; right: 10px; }
    .flexslider:hover .flex-next:hover, .flexslider:hover .flex-prev:hover { opacity: 1; }
    .flex-direction-nav .flex-disabled { opacity: 0!important; filter:alpha(opacity=0); cursor: default; }
    .flex-direction-nav a:before  { font-family: "flexslider-icon"; font-size: 40px; display: inline-block; content: '\f001'; }
    .flex-direction-nav a.flex-next:before  { content: '\f002'; }


texts: problem merging views row-data into Drupal.settings

texts:
I have a custom view and a custom row template.
For each row, the template defines a variable $rowdata.  For example:

> row #0:  $rowdata = array(0=>array('a','b'), 1=>array('a','c'))
> row #1:  $rowdata = array(0=>array('a','b'), 1=>array('a','d'))
> row #2:  $rowdata = array(0=>array('x'), 1=>array('x'))

What I Am Trying To Accomplish

I want merge the rowdata from all the rows:

   $merged_rowdata = array(
      0=>array('a','b'),
      1=>array('a','c'),
      2=>array('a','b'),
      3=>array('a','d'),
      4=>array('x'),
      5=>array('x')
    )

and store the result in Drupal.settings.mymodule.$viewID.merged_rowdata:

Drupal.settings.mymodule.$viewID.merged_rowdata = array(
  0=>array('a','b'),
  1=>array('a','c'),
  2=>array('a','b'),
  3=>array('a','d'),
  4=>array('x'),
  5=>array('x')
)

(Note:  All rows have the same value for $viewID)

What I Tried

I tried placing the following code in my row template:

drupal_add_js(array('mymodule' => array($viewID => array('merged_rowdata' => $rowdata))), 'setting');

But this does not merge the rowdata in the way that I want, as described above.  Instead, it replaces $viewID with the row_index:

Drupal.settings.mymodule = array(
  0 => array('merged_rowdata'=>array(0=>array('a','b'), 1=>array('a','c'))),
  1 => array('merged_rowdata'=>array(0=>array('a','b'), 1=>array('a','d'))),
  2 => array('merged_rowdata'=>array(0=>array('x'), 1=>array('x')))
)

I found that if I replace the variable $viewID with a string literal, eg 'myview':

drupal_add_js(array('mymodule' => array('myview' => array('merged_rowdata' => $rowdata))), 'setting');

then the rowdata gets merged in the way that I want:

Drupal.settings.mymodule.myview.merged_rowdata = array(
  0=>array('a','b'),
  1=>array('a','c'),
  2=>array('a','b'),
  3=>array('a','d'),
  4=>array('x'),
  5=>array('x')
)

Anyone know how I can get my desired result?  Is there some way to "tell" drupal_add_js that the variable $viewID has the same value for all the rows?

Background

My style template loops through each row of the view output, and executes the row template on each row.  Here is the code for my style template:

<?php foreach ($rows as $id => $row): ?>
  <div>
    <?php print $row; ?>
  </div>
<?php endforeach; ?>


texts: Can I remove the "summary" from the "Text (formatted, long, with summary)" widget?

texts:
When creating a new content type, by default it has the Body field, which has a Field type of Text (formatted, long, with summary).  For this content type, I don't want authenticated users to see the summary.

What's the proper way to hide the "edit summary" part for non-admin users?  Or, am I better off deleting the default Body field and creating a new custom field?