texts: In Drupal 7, do database queries need to be enclosed by double quotes?

texts:
I am migrating custom modules from Drupal 6 to 7. Since the database API changed it's quite a lot to do. During this I stumbled upon a problem regarding quotes. I am used to enclose strings in PHP with single quotes, so in Drupal 6 I wrote

$q = 'SELECT * FROM {node} WHERE type = "page"';

However, without any pattern (as far as I could detect) some of these queries fail in Drupal 7. When changing the above line to

$q = "SELECT * FROM {node} WHERE type = 'page'";

it suddenly works. But I couldn't find any information if this quoting style is required by the new DAL. Anybody got further information on that or can confirm my observation?


texts: I'm looking for a best practice: should contributed modules use $this->t() or t()?


texts: How do I remind users to pick an avatar?

texts:
I use the Avatar Selection Module to provide a list avatars my users can choose from. I don't want to make choosing an avatar required, but I'd like to have a persistent reminder for users who have not picked an avatar for themselves.

How can I identify users who have NOT chosen an avatar and use Context (or something else) to conditionally display a message in a block like, "Hey you haven't chosen an avatar yet. GO HERE (User Form) to choose one."?


texts:
How to change the font size for a piece of code that is displayed as part of a web page?

Specifically, my web page contains a Python script, displayed using SyntaxHighlighter. The default font size results looks okay, but some code lines are a bit too long so that a horizontal scroll bar appears. To get rid of the scroll bar, I would like to reduce the font size of displayed code by 1 pt or so. For consistent appearance, I would like to impose a uniform setting for the entire web site.

Web search gave the answer: use Firebug to find out which css are active, then modify them. However, in my page Firebug finds no active css (under the CSS tab, it just says "There are no rules. You can create a rule."). The code fragment is embedded in
..
, which is embedded in several
..
, which is embedded in a table. At no level I see a font-size setting command.

Which adminstration submenu allows me to change the font size for specific displays? Or which configuration file should I edit?


texts:
I can't seem to query on a field of type "numeric".

From hook_schema:

'id' => array(
  'description' => "ID",
  'type' => 'numeric',
  'unsigned' => TRUE,
  'precision' => 20,
  'scale' => 0,
  'not null' => TRUE,
  'default' => 0,
),

if I do something simple like the following code, I don't get anything.

$query = db_select('tablename', 't')
  ->fields('t', array('nid'))
  ->condition('id', $id, '=');

However, if I execute the following query on PHPMyAdmin, I get a row.

SELECT * FROM `tablename` WHERE id = 195755377227337728;

I did try to type cast the id with (int) $id, but that didn't work either.

Do you have any thought?


texts: Display taxonomy terms and nodes together

texts:
I have a taxonomy with some terms and subterms and a content type Product, for example:

Term1

Subterm1A

Subterm11

Subterm1B

Term2

Subterm2A
Subterm2B
Subterm2C

Term3

Subterm3A
Subterm3B

Products can be assigned in every level of the taxonomy (terms, subterms, etc.).
If I enter in the Term1 page, I'd like to display a list of the subterms and also the list of Products assigned to Term1 (subterms and Products are at the same level).
How can I achieve this?

Thanks a lot!


texts: How to create and send via email a PDF file with rules?

texts:
I need to create and send via email a PDF file with Rules using Drupal 7. I need to send it as an attachment, not as a link.

I found this post,  Generate PDF with Print PDF and send in email, but Views PDF MIMEMail is a D6 module.

How can I do this?


texts: How to get child terms based on parent terms between two different taxonomies

texts:
I have created two vocabulary

Program
Topics

I want to load the topics based on the program selection.

It looks like category and subcategory.

I created some program like java, .net, PHP
and I created some topics like session (php), inheritance(java), cookie(php).

So now I want to list all the topics which are coming under a particular program.

Can you tell me which  drupal function used to get all the terms under parent terms.?

Note: taxonomy_get_children not working because I am using two vocabularies


texts: User picture preview is not updating with $form_state rebuild

texts:
To user profile form I have added a custom submit function.

In that submit function I'm setting the $form_state['rebuild'] value to TRUE.

When I change the user picture and click the save button, it does not update the picture preview.

Then When I reload the page again manually, it updates the picture preview.

What can be the problem and how can I fix this?

I'm using the default picture field. All other fields are updating.


texts:
I'm trying to update the URL on a successful webform submission, with an inline ajax confirmation. The form works and submits fine and I already have a custom Drupal ajax command to history.push setup, but cannot figure out how to hook into the confirmation flow.

I have tried:

Adding a custom callback to $form['actions']['submit']['#submit'] and returning an ajax response from that callback
Adding a custom handler, but can't see where I could add the functionality necessary

Thanks.


texts: Mark only event's start date and end date in event calender

texts:
I want to mark only the start date and end date in the event calendar. For example, if the event starts from 5th of a month and ends on 17th of the same month. I need to show the text event1 opening on 5th  and event1 closing on the 17th.

An event calendar is instead shown as follows.

I'm using FullCalendar for this.

How can I achieve this?


texts:
I am using Drupal 7. Is it possible to to redirect the "/sites/all/files" directory to
just "/files". Also, would it be better to just create a new directory /files and copy the files over. But, I would have to change a lot of links in my content that access those files.


texts: Updating Commerce Kickstart’s Contrib Modules

texts:
What is the recommended way to update outdated Drupal contrib modules? The Commerce Guys doing a great job to keep Commerce secure and updated. However there’s always a Contrib Module update around. For the most part this isn’t an issue. Most of the Contrib Module updates are maintenance fixes. However what about security fixes for Contrib Modules? Usually I don’t touch the /profiles/commerce_kickstart/modules/crontrib folder and I am waiting until a new Commerce Kickstart release is published.

Does Commerce Kickstart uses special Contrib modules? Can I update ctools, Webform myself?


texts:
I am using the Calendar module. I was asked if it was possible to take the calendar page and put it inside of another.
I'm not so sure about this.
How would I add this to be inside the Content region of the other page?
I see how it is possible to add the Calendar block to the Content region of the page but that is not what these people want...they want the full Calendar view inside of another page!
Any ideas how I would go about doing this?

This is the Calendar module installed in Drupal 6.


texts: Translate taxonomy term programmatically

texts:
How can I translate a taxonomy term programmatically in drupal 8?
I found how to get the translated taxonomy term programmatically? but this is only related to d7.


texts: How to access the filepath of an image from a view on a content type

texts:
I have a problem Accessing the file path of an uploaded image. I'm trying to create a custom Carousel and build it up in a Drupal Block. I'm pulling the array created from the view of the content type like so:

$slides = views_get_view_result('slide');

foreach ($slides as $slide) {
    echo $slide->_field_data['nid']['entity']->field_slide_image['und'][0]['uri'];
}

My problem is that URI prints out "public://someimage.jpg" instead of "someimage.jpg" or "sites/all/images/someimage.jpg." I know I could do a string replace on this, but Drupal must have a way of getting the right file path to the image. Any suggestions?


texts: My hook_menu_alter() and page callback don't get triggered

texts:
This question relates to How do I redirect a taxonomy menu item to another path?

I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback.

function material_menu_taxonomy_page_callback($term) {
  dsm('Entered material menu callback');
}

function material_menu_menu_alter () {
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_menu_taxonomy_page_callback';
}

I placed a code line dsm("Altering"); in the callback to see where in the process the callback is being called, but it never shows up.

I am fairly certain that I have the code correct.

The hook has the name of the custom module.
The callback name is correct.
the callback is in the same file as the hook
I have turned the module off and then on so that I can be sure that Drupal knows about mymodule_menu_alter
And I have flushed the caches.

My assumption is that mymodule_menu_alter()' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that mydsm()` message should display at the top of the page requested by the menu.

While Clive's test indicated in his answer worked, my revisions did not. Following Clive's answer recommendations I revised the code as follows.

material.info file contained in modules subdirectory = sites/all/modules/Custom/material

name = Materials
description = Redefine the path for materials menu
package = CR-Hub
core = 7.x
; Includes
files[] = material.module

material.module file in same subdirectory

function material_taxonomy_page_callback() {
  drupal_goto('taxonomy/term/1');
  // return 'Entered material menu callback';
}

function material_menu_alter(&$items) {
  // return 'Entered Material Menu Alter';
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback';
  return $items;
}

When I select any menu item neither drupal_goto(), or return 'any text' lines redirect the selected path from the menu item.


texts:
I want to display the number of unpublished comments in a template. I don't want to execute unnecessary queries on the database. Is there an already available function for this that I can use in page.tpl.php?

function comment_count_unpublished() {
  $count = db_query('SELECT COUNT(cid) FROM {comment} WHERE status = :status', array(
    ':status' => COMMENT_NOT_PUBLISHED,
  ))->fetchField();
  return t('Unapproved comments (@count)', array('@count' => $count));
}


texts:
How the functionality of auto loading the next post when you reach the end of a content is reached.
This functionality is seen in Quartz which is built on Wordpress. Most probably they are using the Auto Load Next Post plugin.

Is there any module or a way by which this can be replicated in Drupal (Drupal 8 if possible)?


texts: How to provide upload function for users

texts:
Possible Duplicate:
  How to allow users upload images to existing nodes?

How might I go about providing a page for authenticated users to upload image files to the server?


texts:
How can I add HTML tags into menu title?

I'm also tryed the following code.

function adminimal_theme_preprocess_menu(&$vars) {
  if ($vars['menu_name'] === 'main') {
    $vars['items']['standard.front_page']['title']='<i class="icon-home"></i>';
  }
}

It also converts tags into HTML entities.


texts: Why is the fivestar rating displaying/suggesting 4 out of 5 stars when no votes have been made?

texts:
When adding a node which has a fivestar field and there are no votes yet, it shows 4 out of 5 stars as "on". Is this intended/ normal?

In my preprocess_page hook:

<?php
if (isset($node->field_rating)) {
                $field = field_view_field('node', $node, 'field_rating', array('label' => 'hidden'));
                $rating = render($field);
                $vars['title_rating'] = $rating;
            }

which gets rendered like this (with no votes made yet):

            Cancel rating

            Give it 1/5

            Give it 2/5

            Give it 3/5

            Give it 4/5

            Give it 5/5


texts: Form - Prepopulate and hide field with given argument

texts:
I have two content types: City and Request.
Request is entity referenced to city.

Now i created a custom themed node /berlin.
On this page i have a button that says "send request", which brings you to the node/add/request form.

The form should now somehow pre-populate the field "field-city" with the previously selected city entity/node.

Additionally the field should be hidden.

Could you guys point me in the right direction?


texts: How to transform data from the Google Analytics Reports module into charts?

texts:
I'm using Google Analytics Reports to bring in Google Analytics data into Views, this works fine, but I'd like to display this data as a chart.

I've tried with two different charts modules: Charts and Google Chart Tools. Both require you to use Aggregation in views to group the data, but this isn't something the Google Analytics Reports module supports.

Can anyone recommend a way around this or a different approach?


texts: Is there a way to alter output/markup for a field in node edit view?

texts:
I am looking for a way to alter field output when rendered in the normal edit view.

I have looked at the hook_quickedit_render_field function which helps out in quick edit mode but are there something similar for the normal edit view? Drupal 8.


texts: Rendering drupal login form in a modal window

texts:
I need to display the login form in a modal window when a user clicks a link on my website. I am doing that using jquery ui dialog currently.

However, once the user logs in, i don't want a page refresh instead i just want the modal window to get reloaded with some content.

how do i achieve this?


texts: How do I write an additional field formatter for an existing field

texts:
I would like to write a new field formatter for an existing field type. I don't want to replace any existing formatters but offer a new option.

Or am I better off using a theme_preprocess_field() to do minor alterations? But this seems to be harder to maintain and I'd like to keep my content editors options open (and in the GUI).

Can someone point me to an example of the proper way to do this?


texts: How do I convert a render array to plain HTML?

texts:
I have a render array with a list of items.

$array = array(
  'list' => array(
    '#items' => $items,
    '#theme' => 'item_list'
  )
);

I tried to use it with ajax_command_html(), which works perfectly with a simple HTML string, but it doesn't work when it gets a render array.

Can I somehow convert this render array to an HTML string to use it with that function?


texts: Disable registration on commerce checkout

texts:
According to https://docs.drupalcommerce.org/commerce2/user-guide/checkout/allow-register-at-checkout the 'Login or continue as guest' checkout pane should have an option 'Allow registration'. In my environment with the latest commerce 2.12 however I can't find this option. Why is this option not shown?

I don't want to allow registrations on my site and only allow guest checkout. How can I achieve this?


texts:
I am trying to add custom fields for a Quiz Component (Multiple Choice Question). However, when I go to Home>Admin>Structure>Content types, the only types that appear are Article, Basic page and Quiz (non of the components). I can add my own content type but cannot seem to get the already existing content types to appear in this menu.

In short, how do I control what content appears on this menu.

Thanks for your help and sorry for the noob question. Just getting started out.


texts:
I'm interested in created a sort of "deploy" script. I basically want it to take a fresh drupal install (plus my versioned work in sites/) and disable and enable modules as needed and then automatically configure the site.

The first part is easy with a simple script and drush. The second part is the part I'm not so sure of. I can manipulate the database directly (again, using drush) and run queries against it, but I wonder if that is a bad way to do it since the schema of modules can change when they are updated (though I think core will stay mostly the same in 7.x).

I'd like to be able to script things like the CSS/JS aggregation settings or the Facebook APP ID/Secret in fboauth. Is there any "safe" way to do this without worrying about module updates breaking the script?


texts: get last element in URL(menu item) generated by hook_menu

texts:
I have created a URL/menu item via hook_menu, and in the proprocess_html I'd like to get my item (last element in the URL) (/test) without using arg(0).

I can do it in PHP but I was wondering how it was possible to get this with drupal.

end(explode("/", request_uri()))

this code is actually bad, there could be URL such as ?test=ok

Cheers,


texts:
I am trying to make a part of my form display depending on the state of a select box. The select box code is:

$form['product_type'] = array(
    '#type' => 'select',
    '#title' => t('Product Type'),
    '#options' => array(
      'a' => t('a'),
      'b' => t('b'),
      'c' => t('c'),
    ),
    '#required' => TRUE,
  );

I then have a field when I only wan to show it when the value is b or c.

$form['problem'] = array(
    '#type' => 'textarea',
    '#title' => t('Problem'),
    '#states' => array(
      'visible' => array(
        array(
           ':input[name="product_type"]'=> array('value' => 'b'),
           ':input[name="product_type"]'=> array('value' => 'c'),
        ),
      ),
    ),
  );

What is happening is that what ever the last value in the page is being used.
I have found the following pages https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_process_states/7 & https://drupal.org/node/1464758 but am still lost.


texts: How to delete all data in one field of a particular content type?

texts:
We have a content type basic page that has a Date field (field_bp_date). We want to use the hook_update to delete all data in this field. We are having trouble figuring out what is the best way to simply delete all data in the field_bp_date field on the basic page content type?

Ideally we would like to do the following:

function mymodule_update_7001(...) {
    $content_type = 'page';
    $fieldDataToDel = 'field_bp_date';

    //some function/hook to delete all the data
    ....
}


texts: How often i should re-build and re-submit xml sitemap for news website?

texts:
I have an website that get news from RSS Feeds. I build every day 2-3k articles and now i have almost 160k links.

So, how often i should re-submit the xml sitemap; (currently i do this job every hour)


texts: Programmatic filefield value/Default Filefield value

texts:
I have a module that takes a file uploaded to an entity, changes it and then saves the new version on my server in a folder based on the user id and entity title.

$where = 'private://' . $user->uid . '/';

This is all working fine.

I would like to have a field on the entity that displays this new file (it's an audio file).

I have tried writing the process of attaching the file into the module itself several times but have had no luck.

My next idea was to have Rules do this for me but unfortunately when it comes to setting the data value for a filefield Rules will not let you use PHP or Tokens so all I can do is set it to the value of an existing filefield.

My third idea was to have the entity's field have a default value and use tokens that reflect the location of the file e.g [uid]/[title] but filefield does not allow default values.

I have also tried writing a module that updates the entity field values but I can't seem to get this to work either.

Does anyone have any ideas on where you go from here? Does anyone know how this can be done?


texts: Are there Get/Set methods for addressing commerce line_items and order object properties?

texts:
Are there get/set functions/methods for all line item and order properties?

I find myself manipulating line items thus:

$line_item->commerce_unit_price['und'][0]['currency_code'] = $whatever;

I was thinking there must be a better way to (ie. without addressing array members?) My concern is that the structure may change as Commerce develops.


texts: I am using Drupal 8 Commerce 2 Onsite payment gateway with USAepay payment gateway. I do not want to store credit card details in the database, even it should not save last 4 digit last of card number. Is there any way?


texts:
I want to make a small modification to the ubercart cart page in my theme.

A typical item row on the cart page looks like this

[remove button] [product image] [product title] [quantity field] [row total]

All I want to do is move the [remove button] to the right hand side after [quantity field].

How can I do this?


texts: What are efficient solutions to prevent a huge amount of panes in a Panel?

texts:
Using Panels for some years I still have one question that I struggle with.

I have set up a Panel with a special layout, with a filter on a specific bundle type.

I have more than 10 views content panes that I want to show in that panel, but each one on its own entity.

So the obvious solution is to add Pane Visibility Rules to each of the panes, which filter by URL of the entity.

I think this is neither efficient nor userfriendly. It's hard to manage for more than 10 panes and have a clear insight about all the visibility rules of each pane.

I thought about using ViewField module for the entities showing a specific view, and still allow them to use the Panel. As far as I can see, that does not allow for the use of the Panel pane context tokens.

Suggestions are very welcome.


texts: Users complain they can't "click on anything" on my Pressflow site

texts:
The users of my site complain they cannot click on anything on my site, which runs Pressflow.

If that makes any difference, I am using some Nginx Caching, and the server config from the Barracuda Aegir project.
I can't seem to figure this out, or reproduce it in another site.


texts:
I have a routing.yml file which has the following path:
 path: '/downloads/{path_dir}'

it works fine when the url is /downloads/diana for example.

but when the url is /downloads/diana/cast then it says "page not found"  .
How can i make this work an unlimited amount of subdirectories?


texts: Conditional field in node type depending on user profile

texts:
I have a site with two user profiles (group/single). I have a node type repertoire with a field function which I only need for the profile single (mandatory field). Is there a way to hide this field when a user with profile group is adding a node? I don't want to make two different content types with only one little difference.
Thanks in advance!


texts: Can I store media files in the private directory?

texts:
The normal behavior, described also in Give access to private files to certain role? seem to be the following.

  Once configured, files stored in the private directory are inaccessible via a direct link; however, if Drupal constructs a link to the file, the file will be accessible to anyone who can see the link.

Does it work for media type fields?
How can it be configured?

I would like the files to be accessible only from users who authenticate themselves using CAS.


texts:
What I want to do is give a possibility to the user to save as many images as he likes. For this, I have created a specific field type

    $fields['photo_ids'] = BaseFieldDefinition::create('map')
  ->setLabel(t('Photos'))
  ->setDescription(t('The photo ids of the Item entity.'))
  ->setSettings([
    'max_length' => 50,
    'text_processing' => 0,
  ])
  ->setDefaultValue('');

here I want to save, add, delete IDs of pictures. Not sure if this is the best approach to this problem. The problem is I can't find the way in Drupal 8 to serialize/deserialize and save these data into the database;


texts:
I need to create an exposed filter to a view that should handle the content's post date and more specifically the year. So I need a jump list that should contain values like '2009', 2010', '2011' etc.

I read Exposed Post date filter on views and it's all very helpful but I cannot figure out how to automate the starting date so it can be the year of the oldest content posted an the ending one the year of the newest.

Any help?


texts: Commerce Kickstart 2 - Views title not displayed

texts:
When using views on Commerce Kickstart 2, the view title is not displayed. Is there any reason for such a behaviour, am I missing something?
The opening HTML is below.

Configure

Edit

Delete

Manage display


texts: Is there a way to input the data of multiple content types all on the same page?

texts:
I have three content types: student, course, and student_takes_course (student_takes_course have two reference fields that points to the student and course content types).

To input a new student_takes_course record, I would first have to go to the student content type and input a new student record, and then go to the course content type and input a new course record, and only then I can go to the student_takes_course content type and input a new record that have references to the newly inputted student and course records).

But is there a way to input the student and course and student_takes_course records all on the same page?


texts: How can I develop a custom theme from scratch?

texts:
I wonder how to develop a custom theme from scratch. I understand the overall structure of Drupal theme. I've created an .info file and enabled the theme through the admin interface, but I get a blank screen.

I haven't yet coded any of the theme files. I'm unable to define html.tpl.php, page.tpl.php, node.tpl.php, region.tpl.php.

I do have empty css, js and images folders. In my templates folder I've an empty html.tpl.php, page.tpl.php, node.tpl.php, region.tpl.php, field.tpl.php.

Any suggestions?


texts: I am new to drupal. I want to show a module that refresh every 3 seconds and displays the other existing user details with their photo graph .


texts:
Can anyone suggest how I might detect when a node has been updated via jquery?

I know jquery is a client-side technology but I really need to utilize jquery(ajax) to alert my users when a node is updated.


texts: Exclude results in view that appear in attachment

texts:
I'm using a view with an attachment to create a block that shows a featured news item with a large picture at the top and the rest of the news with just thumbnails beneath it. The featured news item is in an attachment, and the thumbnails are part of normal block view. The featured news item is whatever news item has 'featured' selected and is the most recent. However as it is now the base view block will redundantly display the news item again even if it's featured above.

I understand that in the base block view I could just do 'if not featured' but many items can have the featured field checked when only the most recent is displayed.

I've looked at creating custom view filters but I was having trouble understanding how to make them and I worried that I was moving in the wrong direction.

Is there a way to exclude a result in a view that appears in an attachment?


texts: Do I need to use drupal_mail after the hook_form_contact_site_form_alter?

texts:
I have added on field in my site wide contact form through this code :

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

    // Add a phone number field to the contact form.
    $form['phone'] = array(
    '#type' => 'textfield',
    '#maxlength' => 20,
    '#title' => t('Your phone'),
    );

    // Define the order of the top level elements on the form (include those from contact_site_form().
    $order = array('name', 'mail', 'phone', 'subject', 'cid', 'message', 'copy', 'actions');

    // Order the elements by changing their #weight property.
    foreach($order as $key => $field) {
    $form[$field]['#weight'] = $key;
    }
    }

Now Do I need to add drupal_mail with phone number into it or Drupal will consider it automatically ? As I am new to drupal I don't know much about it.


texts: How to make a hierarchical categories of a view's nodes?

texts: I want to have hierarchical categories of a view's nodes,where categories will be taxonomy terms of the nodes.How to do that?


texts: How do I send data to a template page on form submission?

texts:
I am building a weather API in Drupal 7, and I am unable to send weather report to my custom template file. Everything is working fine but the result is not displayed; everything is working as expected except result display.

.info

name = BM Weather API Part 2
description = Display the current weather condition of a specific location
package = BM API
version = VERSION
core = 7.x

.module

<?php
function BM_weather_API_part2_theme() {
  return array(
    'BM_weather_API_part2' => array(
      'template' => 'BM_weather_API_part2',
      'variables' => array('msg' => NULL),
    ),
  );
}

function BM_weather_API_part2_menu() {
  $items['BM_weather_API_part2'] = array(
    'title' => 'Weather API - Part 2',
    'page callback' => 'BM_weather_API_part2_view',
    'access arguments' => array('access content'),
    'file' => 'BM_weather_API_part2.pages.inc',
  );

  return $items;
}

.inc

function BM_weather_API_part2_view() {
  $dis = drupal_get_form('BM_weather_API_part2_form');
  return $dis;
}

function BM_weather_API_part2_form() {
  $form['location_name'] = array(
    '#title' => 'Location',
    '#type' => 'textfield',
    '#description' => 'Enter Location Here.',
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Get Weather Report',
    '#submit' => array('BM_weather_API_part2_get_weather_report'),
  );

  return $form;
}

function BM_weather_API_part2_get_weather_report($form, &$form_state) {
  $loc_name = $form_state['values']['location_name'];

  if (ctype_digit($loc_name)) {
    form_set_error('BM_weather_API_part2_character_required', t('Please Enter Proper Location Name.'));
    return;
  }
  elseif ($loc_name == '') {
    form_set_error('BM_weather_API_part2_character_required', t('Please Enter Location Name'));
    return;
  }

  $freport =  get_weather_from_google($loc_name);

  return theme('BM_weather_API_part2', array('msg' => $freport));
}

function get_weather_from_google($loc) {
  // $finalreport contains the final report coming from google
  return  $finalreport;
}

.tpl

print $msg;


texts: How do I find out what controls access to a page?

texts:
I'm surprised by finding that I can't access [some-path] on my site, and I don't know what to do?

Where do I begin searching? What is the fundamental most level to start from?


texts: Rotate Specified # of Views Results on a Time Based Schedule

texts: I have 1000 results in a View Block. It contains a title and a teaser body. I want to be able to show 10 different results every week. How can this be done using Views? Or is there additional modules I would need?


texts:
In entity browser I tried uploading a file which is not supported. So I got the valid error message.
But it does not convert the html tags which are being generated from token.
Following is the code from core File module.
function file_validate_extensions(FileInterface $file, $extensions) {
  $errors = [];
  $regex = '/\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i';
  if (!preg_match($regex, $file->getFilename())) {
    $errors[] = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => $extensions]);
  }
  return $errors;
}

This error message when searched in translations is shown as:

Only files with the following extensions are allowed: %files-allowed.

which is perfectly fine.
But this is how it is being displayed on page:

How to debug this?


texts: How to remove "catalog" from Ubercart Catalog View URL

texts:
I need to remove the word "catalog" from the URL when viewing a category of products. I am using the stock uc_catalog view. Its Page (Table) display has a URL of "/_catalog". What can I change so that the word catalog will be completely excluded?

For example, I'd like my category URLs to be like so:

  mysite.com/shirts

  mysite.com/pants

instead of:

  mysite.com/catalog/shirts

  mysite.com/catalog/pants

Thanks!


texts:
I want to display, let's say, three additional SKUs (e.g., skuredring3 and skuredring4) similar to the one of the displayed product (e.g., skuredring).

Is this even possible?


texts:
I'm checking a drupal site with YSlow and I get a "Grade E on Use a Content Delivery Network (CDN)" with this message:

  "There are 43 static components that are not on CDN."

Just wondering if the cdn will help to improve this situation.


texts: Organic Groups - define content type to be of Group type

texts:
I am using the Organic Groups module and am following the readme file. I am on step 2 and already struggling...

Create a new content type via admin/structure/types/add. Call it "Group", and
   define it to be of Group type.

How do I define it to be of Group type?

I have enabled the following modules:
Entity Reference    7.x-1.0
Organic groups  7.x-2.0
Organic groups access control   7.x-2.0
Organic groups context  7.x-2.0
Organic groups field access 7.x-2.0


texts: Updated drush, but status shows old version

texts:
I have a D7 site running in a Vagrant VM.

I was getting the following error when attempting to run drush updb from the site folder:

  Command updatedb needs a higher bootstrap level to run - you will need
  to invoke drush from a more functional Drupal environment to run this
  command.

  The drush command 'updb' could not be executed.

I simply couldn't figure out why this won't run, so I thought I'd update drush. It was on 8.0.0-rc4.

I updated via composer on my local machine, and when I type drush --version it shows 8.1.12.

But, when I run drush status it still shows 8.0.0-rc4, and to top it off, I still cannot run drush updb

What is going on here?

I have tried running drush --uri=mysite.local updb but that doesn't help either.


texts: How do I remove the classes from the pager item-list in Drupal 7?

texts:
I am in a Drupal 7 theme development where we need to over write the pager theme where the class "item-list" needs to be removed.

My current item-list HTML

« first

‹ previous

1

2

3

next ›

last »

And I need something like this

« first

‹ previous

1

2

3

next ›

last »


texts:
My clients really really insist that the path of the cart pages will be store/* instead of cart/*

Also, an alias is not good enough. They want a totally unrelated page to appear in the path: cart

Crazy? yes. Challenging? you bet.


texts: In Commerce Line Items quantity field which is an integer field, user can not enter more than 9999, what should i do to unlimit the field?


texts:
Let me see if I can explain what I need.

1) I need some tabbed buttons listed first:

View All | Category 1 | Category 2 | Category 3

2) For each button, clicking the tab should opens an area to display:

Other tabbed buttons (to the left).

Current | Future | Past

Each of the buttons/views has a grid and a table display each (to the right).

Grid | List

Those are all views (example: Category 1 - Current - Grid format view, Category 1 - Current - Table format view).

I can probably use quicktabs module to display my top level tabs, but how to achieve #2?


texts: How to know if a specific role can access a page?

texts:
I have Drupal set up and some module enabled.
Specifically I have the translation_overview module installed.

Now I want to give a specific role access to those pages so they can see what needs to be translated.
So I gave them access to 'View translation overview assignments' but when I ask a person with this role if she can see it, she tells me she cannot.

I am an administrator, so I can obviously see everything in there.
But how can I see what other roles see?


texts: How to recenter a geolocation google common map in views after an ajax boundary filter execution?

texts:
On Drupal 8.97 with all updated modules, I have a View that uses a Geolocation Google Common Map as an attachment. The map acts a boundary filter, but after the filter executes Drupal.ajax(ajaxSettings).execute() via /modules/contrib/geolocation/modules/geolocation_google_maps/js/geolocation-common-map-google.js, I am unable to re-center the map to ANY coordinates, including the user's location.
Before the ajax call, map.getCenter() works, and so does manually inputting coordinates, like map.getCenter({ lat: -34.397, lng: 150.644 }), but afterwards, no dice. The custom re-center buttons I created still register clicks, and if console.log the map object afterwards, I can't see any changes to the map object...and indeed some of my other custom map controls (like zoom in and out) still work after the ajax execution. I'm baffled.
I have looked at the ajaxSettings object too, and have attempted to change some of those center related properties before executing the Drupal.ajax(ajaxSettings).execute() command as above, but I still can't get the map center to change (though I don't quite know if I'm looking at the right properties...there's hundreds of them). The map can still be panned around with a mouse of course, but I ultimately would like for users to be able to re-center to their location...and I would like to programmatically recenter and execute a search using the center of city locations without having to reload the page, so it's kind of critical that I get this sorted.
Thank you in advance for your help.


texts: Creating specific taxonomy terms the Drush way

texts:
is there a way to create specific taxonomy terms the drush way?

the docs mention only a number argument to generate dummy terms.

http://www.drushcommands.com/drush-7x/devel-generate/generate-terms

i have around 150 terms (city - country (parent) - region (parent)) in one location taxonomy vocabulary. would be great if i can write the syntax in a text editor and use this to populate the vocabulary.

thx for any suggestions!


texts: Trying to get COUNT(*) from custom content type with EntityFieldQuery

texts:
How can I retrieve the 'count(*)' from a query in drupal 7?  The query needs to include a custom content type and a custom field.

Notes

Custom Content Type: employees
Custom Field Name: field_employees_email
As a note, I'm looking to add

WHERE field_employees_email = 'example@example.com'

to the query...

So far, I have something like:

$query = new EntityFieldQuery;

$result = $query
     ->entityCondition('entity_type', 'node')
     ->propertyCondition('status', 1) // Getting published nodes only.
     ->propertyCondition('type', 'employees') //Getting 'employees' type only.
     // How do I include custom field as part of query?
     ->execute();

Also, is there an easier way than

$total = count($result);

to return the COUNT(*) from the query?


texts:
I know how to use Drupal's Menu and how to manage rights to access them function of profiles but I need to show secondary menu function of urls.
For example:
- A partner menu is only shown in page where url starts with /partners/
- This partener menu becomes beneficiary if url starts with /beneficiary.

Do you idea how can I manage it ? I cannot usse session :-(

Thank you.


texts: Create update table of features vs plans

texts:
I am looking for a way to achieve this with minimum custom module work.

Imagine a table with features listed down the left, and the plan names are going across the top as headings. Where these columns and rows meet is an icon to say whether this plan has that specific feature.

The ability to add new features needs to be possible easily through Drupal.

I was thinking of creating a plan content type and then the feature could be a field collection with a boolean, and some other data (a booleon on its own is not sufficient).

The issue with this is that you can't reuse field collections, so that would mean creating a field collection for each feature, not very user friendly and too much work for the end-user when they have to add a booleon, and a couple of other fields, also the template file would need to be modified to allow for this new field.

My next thought was to set the field collection as unlimited and then have the features as taxonomy terms, to then use hook_form_alter to first pull in the taxonomy terms and then pre-populate a term reference field for each instance of the field collection.

However this gets a little complicated when you think about a scenario in which someone adds a new feature as a taxonomy term. The custom module would need to look at the fields on the node in the field collections and check to see if the term exists already.

Maybe this would work, but is there a better way?


texts: Set weight for JavaScript files loaded via theme.libraries.yml?

texts:
Im loading a JavaScript file via my theme's libraries.yml file. How can I change the weight of this file?

I need the file to load before the core and module's JavaScript files. If I set header: true then this happens, but I still want to load the file at the bottom of the page.


texts: How to add image field to custom content type?

texts:
I am new to Drupal and I was trying to create a custom content type via programming. I have used the following code:

$content_type = node_type_set_defaults($slideshow_images);
node_add_body_field($content_type, $t('Body'));
node_type_save($content_type);

to achieve the title and body of the content type. How can I add an image field to this?


texts: Custom module pages not rendering when added to admin menu

texts:
I have a custom module that outputs some sql reports in a table with a csv button.  These are SQL tables that are not accessible via views which is why I had to make this module.
Now when these links are accessible through the frontend (ie do not have 'admin' in the path ) the page and table's contents render just fine.
$items['custom_report/glp_report'] = array(
'title' => 'GLP Report',
'description' => 'Report for Guided Learning Pathways.',
'page callback' => 'op_reports_page',
'access callback' => 'op_reports_permission',
 //'theme callback' => 'op_theme',
'type' => MENU_NORMAL_ITEM,
);

When I switch this to an admin path only the table headers render but no content.
$items['admin/custom_report/glp_report'] = array(
'title' => 'GLP Report',
'description' => 'Report for Guided Learning Pathways.',
'page callback' => 'op_reports_page',
'access callback' => 'op_reports_permission',
 //'theme callback' => 'op_theme',
'type' => MENU_NORMAL_ITEM,
);

Theme_debug is on and I can see that on the frontend the bootstrap block.tpl serves the table correctly

however on the admin page it loads block/block.tpl

Hypothesis
Drupal Admin theme is different than the frontend theme.  For whatever reason, this new theme uses a different template and that different template can't render my output.
Approach 1 Create custom template for the page
So I wanted to force a custom template hoping that would fix the module override:
Here is the page callback:
function op_reports_page() {
$page = drupal_render(drupal_get_form('op_reports_form', 'glp'));
$page .= op_reports_table('glp');

$page = array
(
'op_reports_page' => array
(
// Note - we will register theme_my_page in the next step
'#theme' => 'glp_reports',
'#contents' => $page,
),
);

return $page;
}

Here is the theme_hook:
function op_reports_theme()
{
  return array
  (
    'glp_reports' => array
    (
      'variables' => array('contents' => array()),
      'template' => 'op_theme', // don't add .tpl.php
    ),
  );
}

Template file:

<?php print t('My Page'); ?>

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

Outcome
While this renders for frontend, on the admin I get a blank content section.
Approach 2 force the theme through the hook_menu
Using the theme callback you can tell Drupal how the page should be rendered
Hook Menu:
  $items['admin/custom_report/glp_report'] = array(
    'title' => 'GLP Report',
    'description' => 'Report for Guided Learning Pathways.',
    'page callback' => 'op_reports_page',
    'access callback' => 'op_reports_permission',
    'theme callback' => 'op_theme', //name of bootstrap extended theme
    'type' => MENU_NORMAL_ITEM,
  );

Outcome
Blank page on admin page
Approach 3 hook_custom_theme
Hook_custom_theme should override any theme with the machine name theme
  function op_reports_custom_theme(){
    return 'op_theme';
  }

Outcome
Blank page on admin page
Ask
So while I appreciate getting stripes on my Drupal white belt, I would really just like to know the best way to make my custom module render output on an admin path.


texts: hook_form_alter and fields in user_profile

texts:
I know how to use hook_form_alter, but I'm little confused how to achieve this:

In user profile there are tabs "View" and "Edit".

In edit I can alter the form using switch statement on user_profile_form and adding a fields, but they don't appear when I click on "View" tab.

Let's say I'm adding a new field into the user_profile_form:

    <?php

    /*
     * Implements hook_form_alter().
     */

    function my_module_form_alter (&$form, &$form_state, $form_id) {
            switch ($form_id) {
            case 'user_profile_form':

    $form['account']['skype_title'] = array(
            '#type' => 'markup',
            '#markup' => '
Skype edit
'
            );

            $form['account']['skype'] = array(
            '#type' => 'textfield',
            '#title' => t('New Skype'),
            );

                  //krumo($form);
            break;

    }
}

How can I display this field into "View tab"?

Should I use another hook for this?


texts: VIews Exposed Filter - custom query on date field

texts:
I have a content type with a date field. I further have a view with an exposed filter for this date field.

In the view I don't want to filter for a specific date range but for any or no value set.

In Views in the settings for exposed filters on date fields I couldn't find an option to simply filter for whether this field has been filled in or not.

I suppose I need to alter the form and query, so that I can filter the view result for nodes where this date field has been set, respectively left empty.

I already managed to alter the form but I have no idea how to alter the actual query to make this form do what it is supposed to.

This is what I have so far:

if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'my_view' &&
    $form_state['view']->current_display == 'page_3') {

    $form['field_my_date'] = array(
      '#type' => 'select',
      '#options' => array(0 => t('- Any -'), 1 => 'No', 2 => 'Yes'),
      '#default_value' => 0,
      '#title' => t('date is set'),
    );
}

I am really thankful for every hint on how to accomplish this.


texts: How can I add Taxonomy Term to a Node's Breadcrumb?

texts:
The Node has attached a single Term.

Current breadcrumbs rendered

[HOME] >> [NODE_TITLE]

Want to render like this.

[HOME] >> [TERM] >> [NODE_TITLE]


texts:
I've got a bunch of internet links with the properties "Name", "Description", "URL", "Banner (image)" and "Category".

What is the best approach in Drupal to get these organised? Should I create a content type for it and then use e.g. Views etc. to format the output or is there a better way, maybe a module?


texts: search results page in custom layout using Display Suite

texts:
I'm pretty new in drupal. I'm using Drupal's core search module for search functionality in my website. Now. I need to customize search results display page to my website theme.
For this I've googled and find that this can be done if you change tpl.php files, but I don't want to change any template files for this. I've also found that Display Suite is most appropriate for this so I go fot it. I found display suite search page under admin/structure/pages. (Image 1) I've edit this page layout and create variant as per my page layout requirement. search form and search results taken from widgets. (Image 2)

Now the problem is I cannot see search results in search results block. How can I display search results in that block. Or is there any other way to achieve this as per my theme layout. Any suggestions or tutorial links will be appreciate..

Thanks in advance...


texts:
Running phpcs --standard=DrupalPractice in several modules *.info.yml file I get a warning message:

All dependencies must be prefixed with the project name

I've seen some modules that use the module name as prefix

dependencies:
  - modulename:modulename
  - modulename:submodulename

Others when it belongs to Drupal core:

dependencies:
  - drupal:modulename_already_in_core

Others when it belongs to always Drupal (doesn't taking into account if the module is in the core or not):

dependencies:
  - drupal:modulename

Which is the right syntax? Should I use "drupal" always? Just when the module is in Drupal (core)? What is the aim of this requirement?

Thanks!

More info: https://www.drupal.org/project/coder/issues/2854781


texts: How to do simple subtraction in Computed Field?

texts:
I'm trying to calculate the price difference between old price and new price, and if the price has dropped to display by how much, both Nominally and in Percent.

So, basically these are 2 simple formulas that should look like this:

  NOMINAL PRICE DROP = field_price_original - field_price_new

  PERCENTAGE PRICE DROP =  ( (field_price_new - field_price_original) /
  field_price_original ) * 100

I tried setting this up through Rules (unsuccessfully), but it seems that doing it through Computed Field will not be so heavy on the server.
Using Computing Field I have the following formula:

  $entity_field[0]['value'] =
  array_pop(array_pop(field_get_items($entity_type, $entity,
  'field_price_original'))) -
  array_pop(array_pop(field_get_items($entity_type, $entity,
  'field_price_new')));

The number is set as float, 10.2.   But for some reason it doesn't work.

Can someone please help and provide the correct syntax for Computed Field?


texts: Is it better to use module_invoke_all(), or  module_invoke() and module_implements()?

texts:
Using module_invoke_all('some_hook') is easy, but is this better for performance?

foreach (module_implements('some_hook') as $module) {
  $data = module_invoke($module, 'some_hook');
}


texts:
I have a List Field on a Content Type. Just after that I have a Group Field. I'd like make it visible in relation to the value on the previous List Field.

To sum up, to use Conditional Field Module also for a Group Field.

How is the best wat to do this?


texts:
I have a preprocess_page function that applys classes to my content if there is a sidebar or not.

  if ($vars['page']['sidebar']) {
    $vars['content_classes'] = 'cool-class';
  }

  else {
    $vars['content_classes'] = 'super-cool-class';
  }

Can I do a similar with adding class if its the front_page. I want it to be included into this one but I do not seem to find the right way to do it.

Thank you very much,


texts: Possible to add a organic group role programmatically?

texts: Im trying to programmatically add OG group roles and assign permissions through an update hook. Is this possible?


texts: Is it possible for an administrator to delete pending user relationship requests (between users)?

texts:
I am using the User Relationships module on Drupal 7.  I have a relationship, let's call it "Best friends," which requires the mutual approval of both users involved.  However, sometimes users send way too many requests, and I would like to delete these manually from an admin account.

I tried creating a view that shows all pending relationships of type Best friends and adding Status link as a field-- however, the Status link returns empty.  I also couldn't find any option to list user relationships on the admin screen.

Is there any way to quickly manually delete pending user relationship requests from an admin account?


texts: What is causing the unusual output when trying to create charts in Drupal 7 using the pChart library?

texts:
I have been trying to display graphs to users in my Drupal 7 website, by using the PHP library pChart   (which comes with a lot of documentation also). Using the libraries module, I have successfully enabled the pChart library.

Then I tried a basic example that came with the downloaded pChart library. Below is the code that I added in a node with the PHP filter enabled,

<?php
$name = "pChart2.1.3";
if ($path = libraries_get_path($name)) {
include($path.'/class/pData.class.php');
include($path.'/class/pDraw.class.php');
include($path.'/class/pImage.class.php');
}
/* Create your dataset object */
$myData = new pData();

/* Add data in your dataset */
$myData->addPoints(array(1,3,4,3,5));

/* Create a pChart object and associate your dataset */
$myPicture = new pImage(700,230,$myData);

/* Choose a nice font */
$myPicture->setFontProperties(array("FontName"=>$path.'/fonts/Forgotte.ttf',"FontSize"=>11));

/* Define the boundaries of the graph area */
$myPicture->setGraphArea(60,40,670,190);

/* Draw the scale, keep everything automatic */
$myPicture->drawScale();

/* Draw the scale, keep everything automatic */
$myPicture->drawSplineChart();

/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.basic.png");
?>

However, with no errors, warnings or notices, I only get the below unusual output:

My Question: So what is this and what am I doing wrong?


texts: How to render input fields in a custom page template page

texts:
Running into a development wall here. How does one render form/fields in a custom page?

e.g.

I've created a custom page called page--node--add--article.tpl.php (a custom page to style the editing of the article content type) though I cant render any individual input/forms as part of my overall site design.

All I can do is do  <?php print render($page['content']); ?> which loads the entire content and does not allow me to style between the different fields.

Objective: Split the article creation into two DIVs for a mobile theme that gives me a part one and then via jQuery fade (or slide) to the part 2.


texts: One path alias for differents / multiple internal path?

texts:
The problem is when a menu item points to a restricted page, the anonymous user can't see the menu link.

So I was looking for a way to setup a path alias so it would point to two internal path => one for anonymous and one for logged users.

Is this solution possible? Do you see another way to show restricted menu item to guests ?


texts: Change role of indirectly referenced users with Rules

texts:
I have two content types: Courses and Teachers (with a node reference field between them) and actual users are connected to Teachers with a user reference field. I'd like to assign users to a drupal role when they (the Teacher content they are refered to) refered to a Course.
I can do it easly with a Rule if the node reference field has only one value but I can't cope with multi-value field.
I have built this rule so far:

{ "rules_oktato_hozzaadas_oktato" : {
"LABEL" : "Oktat\u00f3 hozz\u00e1ad\u00e1sa - oktat\u00f3",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Oktat\u00f3" ],
"REQUIRES" : [ "rules" ],
"ON" : { "node_update--course" : { "bundle" : "course" } },
"IF" : [
  { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_teacher" } },
  { "OR" : [
      { "entity_has_field" : { "entity" : [ "node:field-teacher:0" ], "field" : "field_related_user" } },
      { "entity_has_field" : { "entity" : [ "node:field-teacher:1" ], "field" : "field_related_user" } },
      { "entity_has_field" : { "entity" : [ "node:field-teacher:2" ], "field" : "field_related_user" } },
      { "entity_has_field" : { "entity" : [ "node:field-teacher:3" ], "field" : "field_related_user" } }
    ]
  }
],
"DO" : [
  { "LOOP" : {
      "USING" : { "list" : [ "node:field-oktato" ] },
      "ITEM" : { "teacher_oktato" : "Tant\u00e1rgy oktat\u00f3i" },
      "DO" : [
        { "drupal_message" : { "message" : "Kurzus oktat\u00f3i: [teacher-oktato:field-related-user]" } }
      ]
    }
  }
]
  }
}

This setup works as I would like to but [tantargy-oktato:field-csatolt-user] is not available in 'change user's role' action. I can choose there only the individual field-teacher entries (:0, :1 etc.)


texts: Why does "Cancel People Account" not work?

texts:
I have Drupal 7 with Devel installed running over PHP internal server and MySQL.
All user operations work correctly except Admin>People>Cancel Account operation.

This leads to the overlay Add User and a Cancel Accounts button.
If I select the option: Delete the account and its content and press Cancel Accounts.

This leaves the overlay(displays the home page of the user)

All I want at this point is to be in the backend Overlay and show the message Changes saved or something similar.
When I return to Admin People overlay, the user is still there.

Has anyone experienced a similar problem - and do you have a solution?

Thank You.
-Robert.


texts:
I'm trying to send HTML emails from a module and I'm using drupal_mail().
It's not possible to send HTML email with just drupal_mail() (see here), and I've installed Mimemail. However, the email is still being stripped of all HTML tags.
Do I need to make any extra calls in the email template, or is there something else I've forgotten?
Set-Up
Mail System

format() -- mimemail system
mail() -- SMTP module

Mimemail

Email Format: Filtered HTML (My filtered HTML allows
 and
 tags.
Include all site stylesheets.

SMTP module

Allow HTML formatted emails

drupal_mail
tellafriend_mail($key, &$message, $params) {

  $message['headers']['MIME-Version'] = '1.0';
  $message['headers']['Content-Type'] = 'multipart/mixed;';
  $message['headers']['Content-Type'] = 'text/html;';
  $message['subject'] = t('This is a test email');

  $message['body'][] = t("This is a test email")."

".t("This should be a new paragraph.")."

".t("And a third paragraph.")."
";
  $message['params']['attachments'] = $params;
  }


texts: How to get the Eva Field of a content type in hook_preprocess_node using entity_metadata_wrapper?

texts:
There are two content types called A and B in my website and there is an entity reference from B to A. I created an EVA views which displays information of both A and B and it works well. because there is an entity reference from B to A, an EVA Field has been added to the manage display of content type A. here it is (content type album equals to A and sub-album equals to B):

I'm going to theme the nodes of A, this is my code :

function MYTHEME_preprocess_node(&$variables){
switch ($variables['node']->type){

    case 'album':
            $suggest = "page__node__album";
            $variables['theme_hook_suggestions'][] = $suggest;
            $wrapper =  entity_metadata_wrapper('node',$variables['node']);
            $variables['title']= $wrapper->title->value();
            $variables['field1']= $wrapper->field_album_field1->value();
            $variables['field2']= $wrapper->field_album_field2->value();
            break;

}

}

this code saves fields of content type in $variables array but I don't know how to get the EVA Field which is attached to the content type A. How do I can get that as variable?


texts:
I am developing a product catalog by means of taxonomy, and want to use URL aliases to better reflect the hierarchy. For example, I have a taxonomy product in the following branch:

category/subcategory/product

The thing I'm sort of surprised is that I have to paste the complete URL path instead of having it automatically glued up out of the aliases of the parent branches, ie. category + subcategory + product

Is there anything I'm doing/understanding wrong? Is that what you guys been through and accepted "as is"?

Artur


texts: How to programmatically copy Webform handler config?

texts:
I would like to copy the Webform handler from 1 Webform into another. I can get hold of Webform settings via:
/** @var \Drupal\webform\WebformInterface $webform */
$webform = \Drupal::entityTypeManager()->getStorage('webform')->load('example_webform_id');
$webform->getSettings();
=> [
     "ajax" => false,
     "ajax_scroll_top" => "",
     "ajax_progress_type" => "",
     "ajax_effect" => "",
     ...

However that doesn't include the handler config that I would need and a way to save its new config as well.
I also tried it via the handler object itself:
/** @var \Drupal\webform\Plugin\WebformHandlerInterface[] $handlers */
$handlers = $webform->getHandlers('example_webform_handler_id');
$handler = $handlers->getIterator()->current();
$handler->setConfiguration($new_handler_config)->save();

for which it appears that there is no save() operation in the handler class:

Error: Call to undefined method ::save()

Any way I can do this programmatically that you may know of?


texts: Is there an analogue of drupal-like jquery plugin for a tree view with drag and drop functionality?

texts:
I am trying to find a jquery plugin with the same functionality as drupal`s standard tree view with infinite nesting used for all kind of taxonomy terms managing and etc.

Is there an analogue of such kind of plugin and maybe you could point me what is the basic of it?


texts: Create Taxonomy vocabularies and terms in installation profile

texts: I'm creating a Drupal installation profile(drupal 6) and want to create taxonomy vocabularies and terms. How to create taxonomy vocabularies and terms in installation profile?


texts: User Login with Email Address - Services

texts:
Drupal login form allows users to enter their username or email to login into the site.

I need to achieve the same thing with services. But services allows users to login with username (not working with email).

JSON format for User Login (works).

{"username":'myusername', "password":"mypassword"}

But how can we do login using "email" as username? I've tried the following JSON formats

Input:

{"username":'myusername@gmail.com', "password":"mypassword"}

Response:

["Wrong username or password."]

Input:

{"mail":'myusername@gmail.com', "password":"mypassword"}

Response:

["Missing required argument username"]

According to this link, I need to tweak the services modules to achieve this requirement.

Is there any way to achieve this?


texts: Restrict translation and editing of node to one language

texts:
Edit
I found this in Workbench Access issue queue:
https://www.drupal.org/project/workbench_access/issues/2982941#comment-12670744
It seems as if I need to deactivate the translate *bundle* *node* permissions, because if those are set, the permission will be short circuited and no other access restrictions may apply, and create a hole bunch of new *translate *bundle* *node* *language* permissions on my own. In my case we have 15 node types and 6 languages. That would result in 90 new permissions. That is overwhelming.
Original Question
I'm trying to restrict the access to creating and editing of nodes in the Drupal admin section to only one language for a user. I didn't find a module which provides for this feature. Is there any module that does this?
I then tried to create my own module. I came up with this solution
File: custom_i18n_access.module
<?php

use Drupal\node\NodeInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;

/**
 * Implements hook_node_access().
 *
 * Prevent editor role to edit and/or delete fr/en nodes. Quick and dirty.
 */
function custom_i18n_access_node_access(NodeInterface $node, $op, AccountInterface $account)
{

    $roles = $account->getRoles();

    if (in_array('administrator', $roles)) {
        return AccessResult::neutral();
    }

    if ($op !== 'update' && $op !== 'delete') {
        return AccessResult::neutral();
    }

    // Access should be restricted only if this permission is set
    if (!$account->hasPermission('custom_i18n_access_restrict')) {
        return AccessResult::neutral();
    }

    $current_language = \Drupal::languageManager()->getCurrentLanguage();
    $lang             = $current_language->getId();

    if ($account->hasPermission("custom_i18n_access_{$lang}_allow")) {
        return AccessResult::neutral();
    }
    return AccessResult::forbidden();
}

File: custom_i18n_access.permissions.yml
permission_callbacks:
  - Drupal\custom_i18n_access\Permissions::permissions

File: src/Permissions.php
<?php

namespace Drupal\custom_i18n_access;

class Permissions {
    public function permissions() {
        $languages = \Drupal::languageManager()->getLanguages();

        $permissions["custom_i18n_access_restrict"] = [
            'title' => t("Restrict language access"),
            'description' => 'Restrict the edit access of nodes',
        ];

        foreach($languages as $lang) {
            $permissions["custom_i18n_access_{$lang->getId()}_allow"] = [
                'title' => t("Allow to edit @lang content", ['@lang' => $lang->getName()]),
            ];
        }

        return $permissions;
    }
}

This custom module successfully restricts the editing and deleting of existing content to only the language I specified in the permissions. But it does not prevent new translations of the content into  other languages.
As I see it, the HOOK_node_access hook is not called for every language when on the translations subtask page. How can I achieve this? Is there a different hook for that? I didn't find any help online.


texts:
I'd like to have a menu show as expanded regardless of whether it is checked or not in the UI (or always checked when a new menu item is created by a user)

I have been looking at hook_menu_links_discovered_alter

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Menu%21menu.api.php/function/hook_menu_links_discovered_alter/8.1.x

  expanded: (optional) If set to TRUE, and if a menu link is provided
  for this menu item (as a result of other properties), then the menu
  link is always expanded, equivalent to its 'always expanded' checkbox
  being set in the UI.

How could I implement this?


texts:
I am using drupal_goto and url methods to try and direct the user to a page.

url returns a string like "/whatever/example" and then I pass that into drupal_goto and they get sent to

localhost//whatever/example

I checked the value for $base_url in settings.php that has no trailing slash. what else could cause this behavior?


texts: How to fix warning message related to Pantheon module?

texts:
When I am running update.php, I am getting warning message. I am sure this is showing because the module was deleted without uninstalling. I am unable to find the Pantheon module or the module for which this warning is related.

  User warning: The following module is missing from the file system: pantheon.   For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1143 of /homepages/46/d644118784/htdocs/includes/bootstrap.inc).


texts: What does a/ and b/ stands for in patch header?

texts:
The first line of patches always has this kind of code:

diff --git a/i18nviews.inc b/i18nviews.inc

or

diff --git a/plugins/views_plugin_localization.inc b/plugins/views_plugin_localization.in

What does the a and b  stand for?


texts: New role assigned on user account update

texts:
I'm thinking about writing a condition ("has new role(s)") using the Rules module to send an email to user to whom a new role is assigned. I need to know how to actually code this...

If (user has a new role(s)) {

  //   do something

}

I think that, by comparing whether a user has a role before saving and after saving or updating the content, one could tell whether a new role assigned. But I can't figure out how to code it and what API I should use. Please advise.


texts:
I've got a problem with the dynamic address field. Maybe it is a problem with the feed-importer, not quite sure about that.

I've imported customers to my database, in the view, name and address are displayed correctly but when i click on edit, those fields are empty. Seems like they are correct in the database.


texts: filter by taxonomy term = taxonomy term of referencing nodes

texts:
I have a node type 'hotels'. These nodes have a reference to a vocabulary 'regions' and a field 'hotel_images'.

And I have a node type 'region_page' with also the reference to the vocabulary 'regions'. In these nodes I integrate a view with images of the field 'hotel_images'.

This view should be filtered by the 'regions'.

In case the node (type: region_page) is set to term 'xy' of the vocabulary 'regions' - only images of hotels for which the term 'xy' is also set should be displayed.

How can I do this?


texts: sidebar region invisible for administrator drupal7

texts:
region--sidebar_second.tpl.php is my sidebar template page, which contains the html structure for sidebar region. This sidebar region is visible for anonymous user and sidebar region is empty when log in as administrator.

Checked the permissions section, but there is no sidebar section settings there. What is the reason for sidebar region to be invisible for admin user?


texts: How to change price in shop based on location? If in US then US dollars etc

texts:
I really hope that someone can help me out here..

We set up our shop with drupal commerce, but we ran into a problem regarding currencies..

On old shop (Custom) we had option enabled if visitor is in US, currency will be set to US dollars else GBP.

Any advice on that? Im sure that somehow this could be done.. Maybe with geolocation?

Or if you have any other ways to do this, I will be happy to see what we can do.

Thanks for any advice!


texts: Overriding css file in theme.info not working as expected

texts:
I am trying to remove nice menus css, as per the notes in my Zen theme .info file.
I have added the below to the info file, and I haven't provided replacements in my theme so they should be removed.

stylesheets[all][] = nice_menus.css
stylesheets[all][] = nice_menus_default.css

However they are still being imported. Cache cleared.

Thanks

EDIT: I'm aware this can be achieved using hooks, but would like to do it at theme .info file level, unless I am mistaken and it is not possible to remove contrib module .css in the theme .info file.


texts: How can I set the help text as an input placeholder on the user login form?

texts:
On the user login form, I am trying to take the "help text" and make it an input placeholder (so that the help text shows up in the input and disappears when the user enters their username and password).

Here's my code:

function mymodule_form_user_login_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['name']['#placeholder'] = $form['name']['#description'];
  $form['pass']['#placeholder'] = $form['pass']['#description'];
//  $form['name']['#description']['#access'] = FALSE;
//  $form['pass']['#description']['#access'] = FALSE;
}

This adds the placeholder correctly but it doesn't hide the help text, so the text appears twice (in the input and below the input).  In Drupal 7, I just set access to false, but in Drupal 8 the description is an object so I don't know what to do.


texts: In which table should I save the value of system_settings_form in Drupal 7?

texts:
I am using Drupal 7 and creating a form with some fields like position.

function mycustom_form($form, &$form_state){
  $form = array();
  $form['position'] = array(
   '#type' => 'textfield',
   '#title' => t('Position for the magnifier'),
   '#options' => array('left' => 'Left', 'right' => 'Right','up'=>'Up','down'=>'Down'),
   '#required' => TRUE,
  );
  return system_settings_form($form);
}

When I click on save with any position selected, these values are saved. So I am not getting where these values are saved and how to use these values in a JavaScript file... I am saving these values in a database.


texts:
I'm trying to debug a route that should work like the one(s) used by the private: file scheme (i.e., a path like system/files/path/to/file, where path/to/file is an arbitrary string that may contain '/' characters).  I more or less copied the the router definition.  For private files:

system.private_file_download:
  path: '/system/files/{filepath}'
  defaults:
    _controller: 'Drupal\system\FileDownloadController::download'
  requirements:
    # Permissive regex to allow slashes in filepath see
    # http://symfony.com/doc/current/cookbook/routing/slash_in_parameter.html
    filepath: .+
    _access: 'TRUE'

For my "knock-off", which uses a custom scheme called 'session:':

file_example.files.session:
  path: '/example/file_example/files/{filepath}'
  defaults:
    _controller: '\Drupal\system\FileDownloadController::download'
    scheme: session
  requirements:
    # Permissive regex to allow slashes in filepath see
    # http://symfony.com/doc/current/cookbook/routing/slash_in_parameter.html
    filepath: .+
    _access: 'TRUE'

As near as I can tell, my route is never matched; yet the private: case works. What's different here?  How can I debug how the router makes its decisions?

Part of what I need to know is just what route got picked when the private: scheme actually works.  So it would be handy to get a link to the current route. This is a fairly obvious thing to do, but I can't find a reference in the docs.  How can I determine what the "current route" is for current request?


texts:
I have a menu listing different links and on some of the links, I want to trigger a notification to the User. I'm working on drupal 7. Also please let me know what modules I would need in the process.

Thanks!


texts: Display a link to create new content when content missing (via Contextual Filters)?

texts:
I'd like to give users the option to create new content when a certain contextual filter is missing on a panel.

e.g. I have my reviews on a panel. When a review is missing I'd like it to display a block/link to submit a new review.

However my only options are to hide the view, give a summary etc.

How do I do this?

I've found the option for 'No Results Behaviour', but I can't hook into the contextual filter (and then use a relationship to grab a term name). I've also found this work around:

https://www.drupal.org/node/1895724

But I'm struggling to re-write the code to pull the term name out of the term id in the contextual filter.


texts: Path Breadcrumbs adds unwanted space in link path, why and how can I avoid it?

texts:
I added in the link path field for a breadcrumb the following:

%site:url%node:tax-title-for-url-construction

"%node:tax-title-for-url-construction" is a custom token which returns a taxonomy title like "Xbox 360" in a cleaner way "xbox-360".

So the links should look like http://domain.com/xbox-360 but it return the following http://domain.com/ xbox-360 Note the space between site url and tax title, but there is no space in the link path field within the breadcrumbs configuration. So where does this space come from?

Here is the code from my custom token:

<?php
$node = node_load(arg(1));
$rtaxidarray = field_get_items('node', $node, 'field_plattform');
$rtaxid = $rtaxidarray[0]["tid"];    // taxid sauber
$term = taxonomy_term_load($rtaxid);
$name = $term->name;
$small = strtolower($name);
$clean = str_replace(" ", "-", $small);
return $clean;
?>


texts: Confused about Owl carousel with Paragraph

texts:
I'm very new to Drupal and not (yet) familiar with the terms and namings.

I came across a web site in Drupal 8 that uses Paragraph. I'm trying to reproduce the slideshow that apparently uses Owl carousel. But I'm confused about how they made that slider:

(These images slide from right to left)

In the Inspector, the code shows that Owl carousel used in the div wrapper and each item. But there is no owl included in the template twig file.

Inspector screenshot:

Template twig file:

{{content.field_title.0}}

{{content.field_description.0}}

       {% for item in paragraph.field_client_image %}

        {% endfor %}

              {{ content.field_button.0['#title'] }}

I assume the below code generates the classes owl-item, owl-item cloned:

{% for item in paragraph.field_client_image %}

{% endfor %}

Anyone can enlighten my candle?

PS: I have access to all templates files and even have access to the site: no Owl carousel module installed but the libraries is present.

Thanks for your time.


texts: how to refresh a view content pane each time a group of tabs is clicked without page refresh

texts:
Hi guys I need some help, I have used Swiper in my views to create a slide of contents, and have a views content pane which brings 4 items at a time sorted randomly. A random sort works with a page refresh but i want this view to get updated without page refresh when a user changes the slide in content section.

I have tried JQuery Ajax Load module but it doesn't support views.

Any suggestions will be appreciated.

thanks


texts:
I am a newbie to drupal 7 and just started working with it a couple of months ago. My problem is I am making a "webform" where the user filling the form should upload his image. But as there is no such field I am not able to understand how to do it.....

I also tried the "entityform"  but as I install it and enable it, the edit links all over my website starts throwing an exception...

So please help me. Any help will be appreciated.

Thanks in advance.


texts: Uploaded image is not being deleted after refresh

texts:
I have a content type with a field type image. When I create a new node of that content type and click the browse button and then upload the image and immediately I refresh the page, every field is empty (that is ok), but the file remains in the files folder even after I run cron.

I checked the database and the file is set in the table file_managed with the status 0. Is weird because after the cron the uploaded image should be removed.

Any clue? Thanks!


texts:
This was quite easy on Drupal 7. You could just use Webform. In Drupal 8, I'm not so sure.

I have nodes of type "Business". I want a form to appear on this page, that when filled in, it must send an email to the business. The "Business" content type has a field on it called "Business Contact Email Address". This is where the mail must go...

I was thinking of:

Finding a way to do it using the inherent Drupal 8 contact forms... any clues as to how?
Creating a new content type called "Node Contact Form" that references a node and then use Rules to mail the field on the referenced node.

Is there an easy way to do this?


texts:
I have my own validation on user form login like this :

if ($form_id == 'user_login') {
        $form['#validate'][] = 'wemusic_user_login_validate';
        $form['#submit'] = array();
        array_unshift($form['#submit'], 'wemusic_user_login_submit');
    }

function wemusic_user_login_validate($form, &$form_state){
    $username = $form['name']['#value'];
    $user = user_load_by_name($username);
    if ($user){
        if($user->status == "1"){
            $form_state = array();
            $form_state['uid'] = $user->uid;
            user_login_submit(array(), $form_state);
        }else{

            drupal_goto('registration/confirm', array('query'=>array(
                'user'=>$username,
            )));
        }

    }else{
        drupal_goto('user/register');
    }
}

with this code CAPTCHA failed , how can I call CAPTCHA validation in my custom function ?


texts: Distinguishing user-supplied translation strings

texts:
I'm working on a site which was developed in English, now it is being translated into German.

The customer has been entering some of the German strings using the translation interface admin/config/regional/translate/translate and I am able to export them from admin/config/regional/translate/export.

My question: is there a way for me to see, either in the .po files or somewhere else where the translation came from? I want to focus in on the translations which have been done by hand by my customer so I don't do them again.


texts: Accessing a taxonomy term id as token for field_target_nodes in message stack

texts: I am using the Message Stack (https://drupal.org/project/message). We have a message type that uses a field_target_node field. The node type (forum) being referenced has a taxonomy/vocabulary connected to it. I can access the vocabulary terms name as tokens in the message -- but what I really need is the vocabulary term id. I can't really figure out how to access that...


texts: How to get a friend's education and work history information using FBoauth module

texts:
Is there any way to get friend's education history and work history? I tried to send permission friend_education_histroy and friend_work-history on fboauth.fboauth.inc file. But I got an error.

How will I pass the permission to Facebook and get my friend's info?


texts: How to deny certain terms from being allowed in autocomplete field?

texts:
I'm looking for a way to restrict my users from creating certain terms that do not belong in that particular field.
I want them to be able to add terms on the fly, but I also want to deny certain terms from being used.

Some examples of this could be swear words, or more specifically in my case abbreviated words.
(MN, WI, MI - I want to force them to use - Minnesota, Wisconsin, Michigan)


texts: Install Drupal in a subfolder of an existing website

texts:
I have a question about drupal installation in a subfolder: We have an existing website running on Magento. Now for some special functionalities we need to build some drupal pages, which all should be in a subfolder.
Example.
Main URL is (Magento): www.mysite.com
Drupal installation: www.mysite.com/specialpages
all other pages are still Magento as today, e.g. www.mysite.com/page1, www.mysite.com/folder1/page12 etc.

Is it possible to install drupal in this subfolder?

thanks for any help / information


texts:
On a website i am currently working on in drupal, on one of the node edit forms, I have a validate function: like so:

$zip_code = $form_state['values']['submitted']['field_address']['postal_code'];
    if(!preg_match("/^([a-ceghj-npr-tv-z]){1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}$/i",$zip_code)) {
        form_set_error('address', 'Please Enter a valid postal code');
    }

and when this item does not validate on the form, it shows the error, but breaks all the styling for the form, it gets completely broken, items floated everything in the wrong places, wondering if anyone know anything about this ?


texts: How do I control the visiblity of an exposed filter in a taxonomy term view?

texts:
I've activated the "taxonomy term" (the one that has the description "A view to emulate Drupal core's handling of taxonomy/term.") view and I need to use it to:

expose a filter to the user
only display it on certain taxonomy
pages

My example is this: I've got two vocabularies that are both being controlled by this view. We'll call them Restaurants and Working Locations. Both are "places" with phyical locations and I use the taxonomy display pages to list the various locations. I've also added an exposed filter that users can use to select a particular region for different "restaurants", but I do not want that filter to be on the "working locations" at all. I'm not sure how to achieve this. I've looked at Views Dependent Filters, but I can't get it to work the way I'd like.

So my question is how can I use the exposed filter to show on some taxonomy view pages, but not on others? The traditional filters of content type have not worked.

I'm looking at Rules, and or Contexts to see if this might be an option but I've still not found anything.

Any reason why the "exposed filter as block" option is not available to me in this view?

Thanks in advance.


texts: Is there any way to force a custom block in the Custom Block Library to invalidate cache on edit update?

texts:
I have created custom blocks in the Custom Block Library and placed instances of the blocks on a page in Block Layout.  The blocks get cached for anonymous users.

Editing the custom block and saving does not invalidate the cache for those instances of the blocks. Looking in the "cache_render" table I see that caches for blocks get created through the Custom Blocks Library are set to never expire as a default with no options I can see available in the admin UI.

I have to actually "Flush All Caches" using the Devel module to have the changes appear, or another way I have found is to go to the Block Layout page and click the "Save Blocks" button without changing anything.  The cahces for all the blocks will invalidate.

I don't want to give access to Devel to an average content manager or have to try to explain that they have to do a non-obvious extra step to have their block content changes appear.  Am I missing a setting in the UI that will invalidate the cache of those blocks on edit save?

I can cobble together a module that would add an extra submit handler that would invalidate the cache using \Drupal::service('cache_tags.invalidator')->invalidateTags() if I can get the cachetags for all instances of the block on save ... but I'm not sure how to get that info, and that just seems like a hack.

I'm hoping I'm just missing something.


texts: How to remove the containing "response" tag from GET output

texts: It seems whenever Drupal 8 generates an XML output it gets wrapped in <response> tags. I'm defining a custom rest resource (e.g. like this) and can see no way of modifying this containing tag. The service which is consuming the XML feed breaks when it encounters this tag. Is there anyway I can remove it?


texts: How to add a link to slide elements in MD Slider?

texts:
I have used the MD Slider module (which is Mega Slider, a paid module) in my websites to create slideshows.

But there is no default option to create a link for each slide.

Is there any way to hyperlink a slide?


texts:
Does anyone know how I can force a user to register before being allowed to join an organic group?

Presently, my users receive a link which takes them to a page with a join button. Once they click on the button they are either added to the group as registered members or presented with an "error" message which states they need to register for anonymous users.

I would like to automate the process for those anonymous users.


texts: Drupal for a portfolio- Images as nodes or something else?

texts:
I am creating a portfolio using Drupal. I was wondering about best practice for handling images.
Would it be best for me to have each image as a node and then create a view and display in a slideshow, or is there a different way that images can be handled - e.g. have a collection of images attached to a node of 'gallery'?


texts: How to get field value of form before submit?

texts:
I am trying to get the value of group_name field once data entered by user before submitting the form. Then only I can access the db, where the entered data is exist in db or not using query. If exists, it shows the data of that id (selected group name id) on the below fields dynamically.
Here is my code:

   public function buildForm(array $form, FormStateInterface $form_state) {
     $form['group_name'] = array(
       '#type' => 'textfield',
       '#title' => $this->t('Name of Group (e.g. name of school, organization, business, etc.)'),
       '#validated' => TRUE,
    );

   /******get the entered group name here********/

    $form['gi_additions_changes'] = array(
       '#type' => 'textfield',
       '#title' => $this->t('If any additions or changes need to be made to your group info above, please let us know'),
       '#validated' => TRUE,
    );

    $form['add_group_name'] = array(
       '#type' => 'textfield',
       '#title' => $this->t('Name of Group (e.g. name of school, organization, business, etc.)'),
       '#validated' => TRUE,
       //'#default_value' => ($get_form_data) ? $get_form_data->group_name : ''
    );
  return $form;
 }


texts: How can I tell in a custom handler if a submission is new?

texts:
I need to do some actions after a new submission for a webform is created. So I have created a new handler, and I'm using the function:
public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission)

But this functions triggers whenever I edit the webform too. Is there a way to know if it's a new submission?


texts: How do I insert content fields above title in a content type template?

texts:
While customizing node--mycontenttype.tpl.php full view, I wanted to insert a couple of fields above the main page title. Can this be done in node--mycontenttype.tpl.php? or should I step up into the page--whetever level of suggestions?

This if:

<?php if (!$page): ?>

seems to never be true for that full view I'm using. I'm afraid I don't understand this flag enough.
Any hints, please?


texts:
I am using Drupal 7 to develop a REST API to create an iPhone app. The basic feature for this app user login and logout process. I am using the User module. The authentication process involved is session authentication. JSON is the output format used for the API.

How do I customize the JSON output from the login service? I am getting a bunch of other information which I don't require. I am not sure how to add more tags to the JSON format. Can anyone point me to the files where the information is?

For example, for a wrong username and password I get the following output:

  Status 401 Unauthorized - Wrong username or password

  ["Wrong username or password."]

I would like to change the output to have something like {status: 0, message: 'Wrong username and passowrd'}.

Can anyone help me?


texts: Content type with a field of multiple values of other content type (1-n relation)

texts:
What should be the approach for the common cases where we need a content type with a field of multiple values of other content type? The typical "1 invoice as n invoice lines" where invoice is a content_type and *invoice_line* other content type.
I did some research and I'm confused because there are: Relation, References, Entity References...
(For Drupal 7)

Thank you.


texts:
I have a custom entity type with a "yield" field. I would like to allow users to see the custom entity (full content view-mode) and change "yield" value to regenerate it with calculated values from the yield changement.

I started with a new fieldFormatter for my "yield" (number_decimal) field. The formatter extends DecimalFormatter and builds a little form object instead of displaying a simple markup.

$element = [
  '#type' => 'form',
  '#tree' => TRUE,
];
$element['yield'] = [
  '#type' => 'number',
  '#title' => $this->t('Change yield'),
  '#default_value' => floatval($this->numberFormat($item->value)),
  '#value' => floatval($this->numberFormat($item->value)),
];

$element['submit'] = [
  '#type' => 'submit',
  '#value' => $this->t('Change'),
  '#submit' => ['changeYield'],
];

Form is defined in the full content view, and a click on the submit button send the form. I think this is not the correct way to add a form because #submit callback is never called. I tried different syntax, with static or non-static callback, but it doesn't work.

I would like to find an elegant solution, not hacking and adding JavaScript custom code.

Now the ideal solution is attaching #ajax callback to rebuild the data without sending the page, but I don't know if it possible and if dependencies will be not to strong, because changes done on another fieldFormatter item's values.


texts: Rule fails to send email to billing address

texts:
I'm trying to create notification emails which are sent when the checkout has been completed. (Drupal Commerce module)

I added a rule to send the email to site owner. It works.
I created a new rule to send email to to the customer's billing address. I Used [commerce-order:mail] replacement pattern as suggested, but unfortunately the email fails to arrive.

What could cause this problem? I even considered add new data selectors, but couldn't find anything fitting to add.


texts: Unable to change theme that applies to view

texts: In a drupal page view under advanced=>Theme:Information=>Change Theme, I'm able to select a theme from the dropdown. Custom templates I've created go bold as expected. But when I save the view and check the theme information, it always reverts to the site default theme. I've tried this with a custom theme I created and a view themes that came with my installation.


texts:
I am trying to filter a development profile in a view where it only shows the developers of the project. I have the filter set on published and only with taxonomy terms "Developers", but the view keeps displaying literally everything published, as if its ignoring the taxonomy filter.

Has anyone ran into this problem and know how to fix it? I am using Drupal 7.


texts:
I'm trying to automatically launch a dialog box containing an iframe if the user's cursor gets within 25 pixels of the top of the browser window.

In the code, a simulated click of a hidden button should open a dialog box which then loads an iframe containing information inside of a hidden div. However, the code doesn't seem to be executing. What am I doing wrong?

I'm working with Drupal 7. I'm sure there's a far more elegant way of accomplishing my goal, but bear with me right now.

<?php
drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js','external');
drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js','external');
drupal_add_js('jQuery(document).ready(function() {
    jQuery(document).mousemove(function(e) {
      if (e.pageY<=25) {
     jQuery("dialog_trigger").trigger("click");
        jQuery("#dialog_trigger").click(function()
        {

        jQuery("#dialog").dialog("open");
      });
    }
    });
});
    jQuery("#dialog").dialog({
        autoOpen: true,
        position: "center",
        title: "         ",
        draggable: true,
        width: 800,
        height: 700,
        resizable: false,
        modal: true,
    });', 'inline');
?>

<div id="dialog" style="display:none;" title="Dialog Title">
    <iframe frameborder="0" scrolling="yes" width="700" height="650" src="http://google.about.com/b/2013/04/01/google-nose.htm" style="padding-left:50px;> </iframe>
</div>


texts: Field Entity Autocomplete filter the published nodes

texts:
my problem is that I have a custom form with an autocomplete entity field for the search.
The problem is that the field shows me both the published fields and those that do not. Is there any filter or parameter to prevent this from happening?

$form['my_element'] = array(
'#type' => 'entity_autocomplete',
'#placeholder'=>'Search',
'#target_type' => 'node',
'#selection_settings' => [
    'target_bundles' => array('products'),
  ],
);


texts: does node_save wait until end of php session to create db record?

texts:
Is it possible/expected that node_save() does not create a new record until the current php session is complete?

In other words, if i have a set of nodes to create and i need to check something that is based on the entire list of nodes prior to creating each one; the ones i am creating in my script will not yet be included in the full list?


texts: Translate label of Comment Body with String Override

texts:
I'm using i18n and string overrides for translating fields in the front end. I opened up the comment-section for several content types and it's working great. The only thing is: I can't find a way to translate "Comment" to german to "Kommentar".

I just found out, that the Comment-Form doesn't get a specific language-tag. So it is und(efined) which leads to the english word Comment.

The easiest but a little dirty way to fix that is to translate it by hand with the hook_alter_form in the template.php

Is there a more cleaner way to do that?

Thanks


texts: Fetch data from database and show in custom block

texts:
I have created my own simple block.I want to show some data from user table of database of logged in user to the block.I want to show it programmatically and not want to use any module. How can I do that?
One more question related to block is, can I add my custom theme to my custom block (like .tpl.php file for custom module)?If yes how can I do that?


texts: How to validate numbers in a webform custom composite element

texts:
I have a Webform with a custom composite, and there I have a element which type is Number and i want to validate this element.

If I check required when the field is empty it show a message that the field is required, but if I put letters in the field show the same message when it should be that the field is not valid because it has letters.

I know how to do this with a textfield element but this element is not inside the custom composite with a regular expression . And even if i change the custom composite element from Number to Textfield I can not do it this, can not be validated individually.


texts: Redirect anonymous users to login when they try to access home page for omega sub theme

texts:
I would like to redirect my anonymous users to login when they request my Drupal website. I have found many solutions for many themes but not for omega's sub theme. I like my site to limit for authenticated users.

When I used this rule:

{ "rules_test" : {
    "LABEL" : "Test",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "init" ],
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "1" : "1" } }
        }
      }
    ],
    "DO" : [ { "redirect" : { "url" : "user\/login" } } ]
  }
}

browser shows:

  The page isn't redirecting properly.

What 's I missing?


texts:
I got this error after migrating from Drupal 6 to Drupal 8.1.3.

  Drupal\Component\Plugin\Exception\PluginNotFoundException: The "php" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core\lib\Drupal\Component\Plugin\Discovery\DiscoveryTrait.php).

How can I fix this error?


texts: Feeds node import does not seem to call appropriate hooks to clear page from cache

texts:
I use Feeds for node import, but this does not refresh page content for anonymous users on my site.

Are there some hooks not being called by Feeds on node creation that should flag the page as dirty in the cache?

Feeds creates some node content hourly. The D7 site has a (home) Page containing a Block with a View of this content. There is some basic caching enabled on the site (Cache pages for anonymous users, Cache blocks, Minimum cache lifetime - none, Expiration of cached pages - none). I'm also using Memcache which should be transparent.

When I create new content or even edit existing content by hand that would show within this View, then the Page containing the Block updates for both registered and anonymous users.
But if I use Feeds to create this same new node content, then the page never updates after new content node is created.
If I clear all caches by hand, then of course the new content will show up within the page.