texts: Avoid access to profiles (user/%user/view)

texts:
I want to avoid access to user/%user/view, so only admins can see profiles. At first I tried with changing the permission user_view_access without any luck.

I tried to use the hook hook_menu_alter:

53 function mymenu_menu_alter(&$items) {
54   $items['user'] = array(
55     'access callback' => 'user_access',
56     'access arguments' => array('access administration pages'),
57     'type' => MENU_NORMAL_ITEM,
58   );
59   $items['user/%user_uid_optional'] = array(
60     'access callback' => 'user_access',
61     'access arguments' => array('access administration pages'),
62      'type' => MENU_NORMAL_ITEM,
63   );
64   $items['user/%user/view'] = array(
65     'access callback' => 'user_edit_access',
66     'access arguments' => array('access administration pages'),
67     'type' => MENU_NORMAL_ITEM,
68   );

It doesn't work neither. Do you have any hint?


texts: Blocks only visible to Admin, despite clear permissions

texts:
This problem concerns two related content types: Vendors and Resources (which are products sold by the Vendors). I have set up a Views block, "Resources by vendor", to display on all Vendor pages.

It uses a contextual filter with a relationship to the Resource NID, and works perfectly when logged in: when you go to a Vendor page, you see the Vendor's information (from the node), along with a list of Resources offered by that Vendor (from the block).

However, when I log out, that block is not visible.

As far as I can tell, I have all the appropriate permissions set correctly:

  On the Block configuration: Roles - not restricted.
Also tried checking off all roles; still no change.
On the View: Access - None.
Also tried Permission: View published content, and Role: (all roles checked) with no effect.
In Permissions, all roles are allowed to view published content; no restrictions on viewing the Resource or Vendor content types

Can anyone think of what I might be missing?


texts: How do I programmatically populate longitude and latitude fields when Geolocation used in content type

texts:
I am using the Geolocation module and I have created a custom content type (we'll call it Bookshop), which contains a field called location and is of type Geolocation.

I can already programmatically create the custom content type instance and programmatically populate the title field.

    $node=Node::create(
      'title'=>'Shop 1'
    );

    $node->save();

How would I go about populating the the Geolocation field content (e.g. the longitude and latitude fields in the Geolocation field)?  e.g.

    $node=Node::create(
      'title'=>'Shop 1'
      'Geolocation field'=>array ('latitude'=>'1', 'longitude'=>'2.33'),
    );

An approach such as the one above does not appear to work?


texts: how to create file programmatically only login users download it

texts:
I want to create file programmatically ,I want only authenticated user can download it and direct access return  403 to them.
I search and saw How Can I Make File Downloads Available Only to Authenticated Users? but my files not field files(not record in file table) and programmatically I created them with:

    $temp1=variable_get('file_public_path').'/export';
      if(!file_prepare_directory($temp1,FILE_CREATE_DIRECTORY)){
          drupal_set_message(t('Problem in write file in directory'),'error');
          return;
      }
    $filename='Export-giftcard-'.time().'.csv';
        $filepath=$temp1.'/'.$filename;
    //    $filepath='sites\\defauls\\files\\Export-giftcard-.csv';
        $df = fopen($filepath, 'w');
        if(!$df){
            drupal_set_message(t('Can not write file in').$filepath,'error');
            return;
        }
        fputcsv($df,array('code','credit'));
   fclose($df);
    $path = file_create_url($filepath);
    drupal_set_message(t('Export done. ') . '' . t('Download export file') . '');

after rooby answer I update my question

I set private file system to system/files/export and  in my code use it
$temp1 = variable_get('file_private_path');
also I implement hook_file_download

function mymodule_file_download($uri) {
  // Check if the file is controlled by the current module.
  if (!file_prepare_directory($uri)) {
    $uri = FALSE;
  }
// I will put my conditions later
      $info = image_get_info($uri);
      return array('Content-Type' => $info['mime_type']);
}

but when I try to click on link to download file return Forbidden to me.I think mymodule_file_download not run when I try to access system/files/export/myfile.csv


texts:
If I need to add custom fields only to user profiles, is it better to create a module that uses the field API, or a module that uses its own code to show the custom fields at a custom URL and to save the data in its own database table?

The field API doesn't implement the permissions necessary to decide which fields are visible to which users; is that a reason enough to implement custom code?


texts: Any modules for editing files in the browser?

texts: I need a way to edit any file in my template directory, but not through a local editor and then by using FTP, but by using my browser. I was wondering if anybody knows a Drupal module or another product that lets you do this.


texts: What is the correct REST call for a REST services with 3 parameters?

texts:
In Drupal 8 I created a view (viewrestname) which lists 3 fields (userid/key1/key2). I added a rest service (let's say \Rests) to this.
Then I added a contentual field userid to it.

When I now call

\Rests\viewrestname\1

I get the correct JSON back.

When I add the other two fields as contextual filters and call

\Rests\viewrestname\1\key1 or
\Rests\viewrestname\1\key1\key2

I get a page not found error.

My questions:

How to change the rest call to e.g.

\Rests\viewrestname?userid=<>?key1=<>?key2

or
How to get this call running:

\Rests\viewrestname\1\14\15

where 14 is key1 and 15 is key2

Note: When I use the preview button in the view it is working correct.


texts: How to hook into fivestar_ajax_submit function?

texts:
I have to add custom HTML element for rate stars and I tried to this with alter fivestar_custom_widget form and set:

$form['actions']['submit']['#ajax']['callback'] = 'MODULE_fivestar_ajax_submit';

I created MODULE_fivestar_ajax_submit function where I call original fivestar_ajax_submit.
My problem is that I can't instruct $form to use my function in place of original code.

-- edit --

In MYMODULE_form_alter() I'v got:

if ($form_id == 'fivestar_custom_widget') {
    $arg0 = arg(0);
    $arg1 = arg(1);
    if ($arg0 == 'node' && !empty($arg1) && ctype_digit($arg1)) {
        $node = node_load($arg1);
        $form['votes_counter'] = array(
            '#markup' => '
' . format_plural($node->field_rating[LANGUAGE_NONE][0]['count'], '1 vote', '@count votes') . '
'
        );
        $form['#submit'] = array(
            'MYMODULE_fivestar_form_submit'
        );

        $form['actions']['submit']['#ajax']['callback'] = 'MYMODULE_fivestar_ajax_submit';
        $form['#submit'] = array('MYMODULE_fivestar_ajax_submit');
    }
}

and submit function:

function MYMODULE_fivestar_ajax_submit($form, $form_state) {
    $result = fivestar_ajax_submit($form, $form_state);
    $result['#commands']['data'] .= format_plural(100, '1 vote', '@count votes');
    return $result;
}


texts: Programmatically creating users attach profiles to correct uid on localhost but uid 1 on production

texts:
While programmatically importing thousands of users from an old site, I'm facing this very strange behaviour. The code snippet below correctly attach commerce customer profiles to the created users on localhost site, but attach them to uid 1 on production site !

localhost is a strict copy of remote site : git clone for code and Backup and Migrate DB copy The users are imported uploading and parsing a csv file in a custom form, connected as admin

$new_user = array(
  'name' => $new_name,
  'pass' => $pwd,
  'mail' => $email,
  'init' => $email,
  'status' => 1,
);

$account = new stdClass;
$account->roles = array(
  DRUPAL_AUTHENTICATED_RID => 'authenticated user',
  9 => 'client',
);

if ($saved_user = user_save($account, $new_user)) {
  dpm($saved_user, $new_name.'/'.$saved_user->uid );
  //VERY STRANGE HERE (ON PROD SITE ONLY) see screen capture below
  //the dpm title prints $saved_user->uid as a new uid
  //but "inside" dpm $saved_user->uid is 1 !
}

//create user commerce profile
$profile = commerce_customer_profile_new('billing', $saved_user->uid);
$profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
//... add profile values ...
$profile_wrapper->save();

Localhost : expected uid when dpm($saved_user, $new_name.'/'.$saved_user->uid );

Production site : uid 1 instead. The user is created with the new uid though, but uid 1 is passed then to commerce customer profile


texts: Unable to change the background image in theme

texts:
I am trying to change the background image provided in the theme. Below is the CSS snippet from style.css file:

.toplayer{
  background: url(../images/theme.png) right no-repeat;
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 100%;
  z-index: -1;
}

I put the new background image in the same directory and tried to change the background by overwriting the above CSS in following way:

background: url(../images/background.png)

After clearing the Drupal cache, I reload the page, but I don't see the new image. At the same, I tried to access the image from my browser, and got the following error:

Forbidden

You don't have permission to access /new/themes/drupal_theme/images/background.png on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Later on, I moved theme.png and rename the background.png as theme.png but I still see the old background image.


texts: How to save the webform data to custom table?

texts: I designed a student registration form using webforms module. My requirement is to save data from the form to table student. How can i achieve this? Is there anyway to mention this in configuration file?


texts: how to assign different default images to different roles

texts:
I have only two profiles, public and registration but I have different roles and would like to add an appropriate default image for each role.

Must I create a separate profile for each role to implement this?


texts: What is the encoding for JSON:API operators?

texts:
I'm trying to filter JSON:API results based on the "greater than" operator (>).
The filtering documentation lists the operators:
\Drupal\jsonapi\Query\EntityCondition::$allowedOperators = [
  '=', '<>',
  '>', '>=', '<', '<=',
  'STARTS_WITH', 'CONTAINS', 'ENDS_WITH',
  'IN', 'NOT IN',
  'BETWEEN', 'NOT BETWEEN',
  'IS NULL', 'IS NOT NULL',
];

But it also notes that the symbol operators need to be encoded:
&filter[a-label][condition][operator]=%3D  <- encoded "=" symbol

Which "encoding" is this referring to? What is the encoding for the other operators (>, >=, etc.)?  How do I look them up?


texts: How do I maintain aspect ratio of scaled image with max-width?

texts:
When I use an Image Style that scales the original image, Drupal 7 (now 7.14) prints the height and width attributes in the img tag whereas before it didn't.
So before, my CSS img {max-width: 100%;} preserved the images aspect ratio when displayed in a small box (i.e. on a mobile screen), but now clashes with height and width attributes. Drupal generates enclosing boxes with no explicit height so the result is an elongated distortion.
What can I do - preferably with CSS alone, but in a template file's php if necessary - to preserve the aspect ratio?


texts: How to provide default value with PHP code for a field in Views 3

texts:
So I'm trying to create a View, displayed in a Block, that will show a list of nodes that reference the same parent node as the node I'm currently in. The reference is a custom field using the References module. I'm on Drupal 7 with Views 3.

I figure I'll setup a Contextual Filter on my custom field (field_ref_photo_gallery) and I need to provide a default value via PHP code.

How should I write that PHP code in the most Drupal 7-ish way?

Should I go with something like:

return node_load($nid)->field_ref_photo_gallery['und'][0]['value'];

(I'm not even sure that would work. I just threw that together in this post)

Or is there a field API function I should be calling?


texts: How to detect if a user is in a specific directory/accessing a specific path?

texts:
For example I need to know if a user is in this directory http://example.com/directory; the value should return true if the use is on any of the following pages:

http://example.com/directory/cars
http://example.com/directory/homes
http://example.com/directory/homes/howtosell
http://example.com/directory/food/seafood
http://example.com/directory/food/seafood/fish


texts: Is there anyway to cross reference a view?

texts:
I have View1 where I would like to add a filter which stops any rows appearing if there are rows in View2.

I thought I would have been able to execute some PHP as a filter, but I can't see any options for that.

Is there any way to use another view as a filter?


texts: How do I get a field label in different languages?

texts:
In a module (not a template), I need the label of a specific field in multiple languages.

$entity->getFieldDefinition('myField')->label() gives me the label in current/active language (let's say, English).

What doesn't work as expected is the following:

$entity->getTranslation('fr')->getFieldDefinition('myField')->label()

I would expect the label in French. Instead, I get the label English. How to get the French label?


texts: How to exclude forms from processing by Hide Submit module?

texts:
According to module description this is possible.

However I didn't find how to do it and I did not able to exclude form by any way, e.g:

http://drupalcode.org/project/hide_submit.git/commit/8aab1ab


texts: How to order search results based on author field content

texts:
I am using Drupal 8 search views, I would like to order the search result so that the content that's author has field "X" filled out should be ordered first and all other content where the author has field "X" empty shows up after. How can I achieve this with views
I made a relationship between the content and the author. I can access field "x" in the fields part of views, but it does not show up in the "filter" or "order by" parts.


texts:
I have taxonomy vocabulary called “Groups”, with 3 terms. I have two content types that both use a Groups term reference field. These content types are called “Media” and “Links”.

When displaying “Media” (node), I have an embedded view that shows “Links”. How can I only show “Links” that have the same terms as the actual “Media”?

Is it possible to do with contextual filters?


texts: Drupal 7 views filter content by owner on/off checkbox

texts: I create View with Leaflet map, I have filters content by taxonomy terms (checkboxes), but I can't figure out how to create on/off checkbox content filter by the owner to show only own added content. Does anyone have any experience of creating such type of filter?


texts: Changing the number of search results per page with the core search module

texts:
What is the best way to change the number of search results per page when using the core search module?

I have both Drupal 6 and 7 sites that I would like to do this with.

In Drupal 6, the value 10 is hardcoded in  do_search().

In Drupal 7, the value 10 is hardcoded in the hooks, eg node_search_execute(), and there isn't a tag added that can uniquely identify the query for altering.  The idea has been floated in the issue queue, but as of 2013-01-30, nothing has been committed yet.

In the past I have hacked core and handled upgrades with patch management using the normal methods.


texts: How to configure Context to set active on Menu item

texts:
This other SO post says that Context provides this functionality out of the box, but when I add settings which seem reasonable, the active and/or active-trail classes are not set on my menu items.

How am I supposed to configure Context to set the active and/or active-trail on my menu items?

Here is my set up:

I've added some terms to the standard Tags taxonomy. For example: Surf, Skate, Volleyball.

I've used Pathauto to set dynamic paths for my taxonomy terms. blog/Surf, blog/Skate, etc.

I created a Menu with an item called Surf with a path of blog/Surf, as well as for Skate and Volleyball, etc.

I added that menu to the Highlighted region of my site.

When I browse to blog/Surf, my menu item does not receive the active nor the active-trail class so that I can style it appropriately to show the user that is where they currently are in the site.

I tried creating a Context for it and guessing at how it should be configured.

How do I get the active and/or active-trail classes on my blog/Surf menu item?


texts: How to remove partricules and apostrophes in url

texts:
I'm using drupal 8 and Pathauto.

I have title of the type (in French) Personnes d'Allemagne, I would like to delete d' to have like url personnes-allemagne.

Pathauto removes the apostrophes well, but preserves the particle before, which gives people-dallemagne.

I tried to add in the words to delete d' or just d, but it does not work. Pathauto continues to delete only the apostrophe and not the d.

I thought of replacing the apostrophe with a dash, but I would prefer to delete particle and dash.

Someone has a solution?


texts: Can I test code contained in module files?

texts:
Generally a module file contains hooks and doesn't have any class nor namespaces. What I have studied so far is that PHP Unit testing is possible only when the code is contained in classes.

Can I write unit tests for module files?


texts: How to stop infinite loop on hook_node_grants

texts:
I am using hook_node_grants to provide access to a realm based on whether someone is an 'owner' of a node. The issue is that menu_get_object() may call hook_node_grants recursively.

function hottopics_node_grants($account, $op) {
  $grants = array();
  ...
   try {
      $node = menu_get_object();
    } catch (Exception $e) {
      // URL mustn't be the correct format.
      return $grants;
    }
   ...
    // Is the person a member of the administrator group, or the owner of the parent node?
    if (module_invoke('hottopicsresearch', 'display_moderated_research_access_callback', 'update', $node)) {
      $grants['view_hottopics_manager'] = array(1);
    }

    return $grants

The code recurses at $node = menu_get_object(). Drupal-7.


texts: custom field - How to get saved term selected for entity_autocomplete

texts:
I've looked all over, and for my level of understanding, I can't figure out how to get the stored value of an entity autocomplete field targeting taxonomy term type. I thought I could do something similar to what I have for select field, but it breaks the page. This is for a custom field...

    $element['description_term'] = array(
      '#type' => 'entity_autocomplete',
      '#target_type' => 'taxonomy_term',
      '#selection_settings' => [
        'target_bundles' => [
          'descriptors'
        ],
      ],
      '#title' => t('descriptor'),
      'default_value' => previously-entered-value,
      // this didn't work... '#default_value' => isset($items[$delta]->descriptor) ? $items[$delta]->descriptor : NULL,
      '#required' => FALSE,
  );


texts: How do I programmatically translate a webform?

texts: Is it possible to add translation for webform programatically in Drupal 8. We have a webform with more than 100 questions and radio options. It is very difficult to manually add translation each time a new translation is provided. So we were thinking of using a CSV file TO programmatically add new translations for the webform, but I could not find a way to do so.


texts: Is there potential performance loss by using multiple nodeapi calls instead of one?

texts:
I have a fairly large site with multiple custom modules. I've started to split some of the larger modules out into smaller more maintainable ones.

I have one particular module that I'm splitting into three. It has a hook_nodeapi function that does various different things, would there be much of a performance loss in splitting one nodeapi call into 2 or 3? Has anyone done any benchmarks on this subject?


texts:
How do I put a block in a form?

My searches on this site and on google only have lead to questions of putting a form in a block. I want the opposite. I have a form definition array in a module, and I want to add in an existing block.


texts: I wanna know how to add regions on a zen drupal 7 theme. I'm using the neptune sub-theme. I have altered the .info file. But i cant find the layout.css to adjust the region sizes.


texts: Can not get inline entity form to work with commerce product and room rooms_unit_type

texts:
I have added an Entity Reference field to a Commerce : Product Type that uses the Inline Entity Form widget.  The reference is to the Bookable Unit Type bundle that is created by the Rooms (more specifically, the Rooms Unit module which comes with Rooms).

I have attempted to add the following to function inline_entity_form_entity_info_alter(&$entity_info)

$entity_info['rooms_unit_type']['inline entity form'] = array(
  'controller' => 'CommerceLineItemInlineEntityFormController',
);

The entity reference form never shows when creating new or editing a product.  If I use the autocomplete widget, I am able to select an entity (although that does me no good).

Thanks for any help.


texts: How to create multiple nodes using Rules once?

texts:
I have a content type named Run that have two entity reference

entity reference field named participants which reference user.
entity reference field named examinations which reference content type Examination.

I want to use Rules to create multiple nodes of content type "Results" for each user "participant" referenced in "Run". the number of Results nodes equals the number of examination.

So I created a rule that fires when the user views the node of type run and I made a loop through examination and I created results node. This runs OK for the first time. But when the user views the node again the nodes are duplicated n times as per number of node views.

Any suggestions how I can make the rule run once per user? Or any other work around.


texts:
for a Drupal7 document root which is served though a reverse proxy such as http://www.example.com/info, then the site should have a $BASE_URL setting of http://www.example.com/info, and that should result correct loading of file assets.  Is that correct?

As a result, that site source would contain links like
  http://www.example.com/info/sites/default/files/logo.png
and
  http://www.example.com/info/misc/jquery.js?v=1.4.4
and

and
  http://www.example.com/info/my_alias_to_node_333

Just wanting to clarify expected behavior, as we can (at the moment) only get to the proxy context in a production environment; in non-production environments, we hit the site directly at the document root, without the reverse proxy, and have a $base_url setting, accordingly.


texts:
I have a page that is displaying a form, and I want to add some text to the top of it.

I create my own module for the form, and have it set up like this:

function hook_menu(){
  $items['page'] = array(
    'page callback' => 'form_function',
  );
}

function form_function() {
  $form = drupal_get_form('return_form');
  return $form;
}

function return_form(...){
  $form['element'] = ...
    .. ;
}

I want to add onto this form with a paragraph or two to go above the form.  I looked at the form api for something i could use from '#type' but I found nothing.  Any suggestions are welcome.


texts: Creating child nodes when creating parent

texts:
I'm trying to implement creation of child nodes programmatically in hook_submit when creating parent nodes according to the parent node field value. Here is the idea.
Parent node: field_stages (unlimited count). I want to create new "stage" nodes when I've added new parent node and save a reference to these child nodes in parent, although the references should not be editable and visible in add/edit form and node view. How it can be implemented in drupal?


texts: Theming views and overwriting the default file upload display

texts:
Theming views in Drupal 7 can be very tedious to newbies. In the following example, a seemingly simple task has become an overwhelming research project into the innards of Drupal! Hoping an experienced drupalite can make quick sense of this.

In our example view we are outputing a product list to a page. One of the fields is a file type where the user uploads a PDF file. To gain maximum control of the layout, we were trying to utilize 'Rewrite the output of this field, and want to create a link to the PDF file with text inside of it that says Download PDF. Sounds simple!! However, so far it has not been.

Because this view is a list of a certain content type, node theming doesn't appear as one of the potential options for template theming. See bottom of the post for potential theming file name conventions that Drupal is offering up.

Also, this may be something easy to do with a hook in the theme's template file, but as of now, that is a little confusing as well and I'm not sure where to look for that solution.

So, for this post, we're hoping to get a clearer picture into the stock views management system. However, all suggestions are welcome!

Here is the code that resides in the rewrite section of the view for the Content-PDF field:

Here are the relevant Replacement Patterns:
[field_pdf_upload] == Content: PDF
[field_pdf_upload-fid] == Raw fid
[field_pdf_upload-display] == Raw display
[field_pdf_upload-description] == Raw description

The problem,
[field_pdf_upload] - gives you a PDF icon, a link to the PDF and it names the title of the file. If I could figure out how to replace the file name inside the href tag with "Download PDF", then this would be essentially solved. I've tried many options in the replacement patterns and what not, but nothing has worked yet. I tried stripping HTML and then adding the direct path to the file and that worked, but if the upload has spaces in it, the path breaks.

If I had access to php in this section, I could do something like this

$fid = [field_pdf_upload];
$file = file_load($fid);

Maybe there is a way to do this and I'm just not getting it?
I am going to start a separate jquery option thread for this in a second, bare w me and it will be written soon.

An alternate method would be to alter one of the theme suggestion templates listed under Advanced->Information - Below is the list of options.

Display output: views-view.tpl.php, views-view--product-landing.tpl.php, views-view--page.tpl.php, views-view--product-landing--page.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--page-1.tpl.php, views-view--product-landing--page-1.tpl.php

Style output: views-view-unformatted.tpl.php, views-view-unformatted--product-landing.tpl.php, views-view-unformatted--page.tpl.php, views-view-unformatted--product-landing--page.tpl.php, views-view-unformatted--default.tpl.php, views-view-unformatted--default.tpl.php, views-view-unformatted--page-1.tpl.php, views-view-unformatted--product-landing--page-1.tpl.php

Row style output: views-view-fields.tpl.php, views-view-fields--product-landing.tpl.php, views-view-fields--page.tpl.php, views-view-fields--product-landing--page.tpl.php, views-view-fields--default.tpl.php, views-view-fields--default.tpl.php, views-view-fields--page-1.tpl.php, views-view-fields--product-landing--page-1.tpl.php

Field Content: PDF (ID: field_pdf_upload): views-view-field.tpl.php, views-view-field--field-pdf-upload.tpl.php, views-view-field--product-landing.tpl.php, views-view-field--product-landing--field-pdf-upload.tpl.php, views-view-field--page.tpl.php, views-view-field--page--field-pdf-upload.tpl.php, views-view-field--product-landing--page.tpl.php, views-view-field--product-landing--page--field-pdf-upload.tpl.php, views-view-field--page-1.tpl.php, views-view-field--page-1--field-pdf-upload.tpl.php, views-view-field--product-landing--page-1.tpl.php, views-view-field--product-landing--page-1--field-pdf-upload.tpl.php

Can anyone recommend a method and sample code for accomplishing this task?


texts:
My site works fine in local system, Upload code and database in server show Error.

Fatal error: Class 'SelectQuery' not found in /*/includes/database/database.inc on line 813


texts: What file contains the queries of customized views?

texts:
I am trying to understand a previous theme in a website and one view shows different results from expected. Then, I want to check whether the query is being generated wrongly or not.

Are there a file in the Views module that contains the queries for my customized views?


texts: How to add a field for each taxonomy term or entity reference chosen in Content Type?

texts:
I have a content type ‘Product’. When the user add a product it is necessary to choose a Store (a taxonomy term or another content type). After stores are chosen, it is necessary to add the directly url to that product in that store. More than on store is selectable and he could add or remove another. There are more data in Store type.

It is something like one to multiple to one for each I think…

Product01   > Store 1 > URL01
            > Store 2 > URL02

Product02   > Store 1  > URL03
            > Store 10 > URL04

My options are:

1) Create a field with multiple values. So if the user choose 3 stores he adds 3 fields to that link.
Problem: It is not directly associate and if he changes orders it will associate de wrong url and chaos will happen.

2) Using Conditionals field (Taxonomy Term)
Problem I could not make it work with multiple selected store and for each new term I need to create a specified field.

3) Entity Reference (Content Type)
Can’t find a way to associate multiple select to adicional fields.

X) Rules?
Too much crazy for me, could not even begin thinking with that…

Any help?


texts: How to let a role be able to administer part of permissions?

texts: For example, uid 1 grants role A some permissions as Article: Create new content, Basic page: Create new content, then users with role A can grant these 2 permissions to other roles in the same interface as /admin/people/permissions.


texts:
I'm creating my very first Drupal module (Drupal 7, btw) and I'm almost done with it. There is one last thing and that is that I need to get the values from multiple checkboxes.

My module list certain nodes and each of them gets a checkbox using a foreach $nid. All using the Form API.

Now, when the form is submitted, only one (1) value is returned - and as of now, not even the one that I check, but the last nodes ID.

Perhaps it is because each new value replaces the previous(?). Or something is wring with my code. Someone in the IRC channel told be that the forms checkbox returns an array of the values, but I'm trying to use foreach of that value, without any success.

What could be the problem?
Here is my code - shorted down.

function my_module_cmp($a, $b) {

  $a = (array) $a;

  $b = (array) $b;

  return strcmp($a['name'], $b['name']);

}

function my_module_form() {
$url = taxonomy_get_term_by_name(arg(1));
foreach($url as $term) {
    $tid = $term->tid;
}
$term = taxonomy_term_load($tid);
$name = taxonomy_term_title($term);
$terms = taxonomy_get_tree(3,0,1);
usort($terms, "my_module_cmp");
$counter = 0;
$result = taxonomy_select_nodes($tid);
foreach($result as $nid) {
    $form[$nid] = array (
        '#type' => 'fieldset'
    );
    // title
    $form[$nid]['title'] = array (
        '#markup' => '
' . $node->title . '
',
    );
    // checkbox
    $form[$nid]['company'] = array (
        '#type' => 'checkbox',
        '#title' => t('Check the nodes balbla'),
        '#title_display' => 'attribute',
        '#return_value' => $nid,
        '#default_value' => 0,
        '#prefix' => 'Skicka förfrågan till företaget >>',
        '#suffix' => '',
    );
$counter++;
}
return $form;
}

    function my_module_form_validate($form, &$form_state) {
// Validate that a company has been checked, at all
$valid_company = $form_state['values']['company'];
    if (!$valid_company) {
    form_set_error('company', 'Forgot to check something');
    }
}

function my_module_form_submit($form, &$form_state) {
$company = $form_state['values']['company'];
drupal_set_message('
'.print_r($form_state['values'], 1).'
'); // Check out the values

foreach ($company as $nid) {
    // Get the node from nid
    $node = node_load($nid);
    // Get the author of that node
    $user = user_load(array('uid' => $node->uid));
    drupal_set_message(t('DEBUG node:'.$nid.', user: '.$user->name.','.$user->mail.'')); // TEST

    // Check if the mail has been sent and show a message based on that
    if (drupal_mail('my_module', 'token', $user->mail, language_default(), $message, $from, TRUE)) {
        drupal_set_message(t('Offert been sent %name',array('%name' => $user->name)));
    }
    else {
        drupal_set_message(t('Error'));
    }
}
}


texts:
I have the following path defined in my routing.yml:
path: '/department/{department_node}/qualifications/{qualification_id}'

I need to translate that route into other languages, for example into Spanish:
path: '/departamento/{department_node}/titulaciones/{qualification_id}'

department_node would be a "department" node
qualification_id would be a dynamic id from a web service
So the result should be:
en: /department/department-title/qualifications/99
es: /departamento/department-title/titulaciones/99

As the qualification_id is a dynamic value, I can't create an alias, as I would have many after a while and they would be out of date. Does anyone know any method of translating the routes in this case?


texts: Retrieve select option value in webform-mail.tpl.php (7.x-4.x-dev)

texts:
I have a custom mail template in Webform so values can be in a table for copying/pasting into Excel.

I want the value of the select option fields instead of the key (doing manual entry for webform creators would be too tedious). I can't seem to get to those values.

Any help would be appreciated.

Here's my current code for webform-mail.tpl.php:

<?php
    print $node->title;
?>

<?php print ($email['html'] ? '
' : '') . t('Submitted on [submission:date:long]'). ($email['html'] ? '
' : ''); ?>

<?php
foreach ($node->webform['components'] as $key => $component) {
    if (isset($submission->data[$key][0])) {
   $key_converted = ucwords(str_replace('_',' ', $node->webform['components'][$key]['form_key']));
    print '
'. $key_converted .'' . ($submission->data[$key][0]) . "
";
}
}
?>


texts:
I'm used Field collection to add content type as field with unlimited but i want to alter this form fields for adding #autocomplete_path on each field
so i'm added the autocomplete for the first field as
 $form['field_1']['und']['0']['field_1']['und']['0']['value']['#autocomplete_path'] = 'admin/path/autocomplete';

when i add more field collection field i want to added the same autocomplete for the next fields
any solution for this ?
Thanks in advance!.


texts: Expose filter by country (but limit options to only those in DB)

texts: I would like to filter my searches by country. However, I would like to avoid selecting (manually) all of the countries associated with each node. Is there a way to list in a drop-down only the countries currently associated with nodes?


texts:
I want to show a custom block, only when log in has failed.
So from visibility settings I have to put a PHP code that returns TRUE only when the login has failed.

But how could I "catch" that event? Do I have to use variable_get(..)? And if yes, how could I use that?with what attributes?

Thank you.


texts:
I've searched a lot of this but all kind of cache issues appear not related to this. If this has already been asked I apologize.

I just want to know if this is an embedded feature or a module is needed for this.

My homepage has 12 VIEW blocks with very complex queries so you could imagine that non caching them is not an option.

Some of the views retrieve the latest nodes so my question is: when a user creates a new node, is there a way to clear the block cache on new nodes? If I cache the block for an hour, the rest of the users won't see the new node until an hour passed.

Thanks


texts: Commerce Feeds: Multiple values in one field or multiple fields?

texts:
Goal
What I'm trying to ultimately accomplish is create tiered pricing based on quantities.
The client is selling different prices depending on quantity. I'm trying to figure out what is the simplest way to store, access and represent this data using fields. While at the same time i'm importing them through commerce feeds.
About my feed/data
I have a CSV table header with the columns "P1 Price," "P2 Price," and "P3 Price." There are also "P1 Qty," "P2 Qty," and "P3 Qty."
Thus, P1 Price corresponds to P1 Quantity, etc.
My question
Would it be simpler, in terms of less complex rules or views configuration, in the long run if i created separate fields to store each price/quantity, or if I combined them into one field that stores 6 different values?
My primary considerations include, scalability, maintainability, etc.


texts: Limit duration (length / time) of Uploaded Video

texts:
I have a website that uses the Video module to allow users to upload videos. I want to limit the duration(both minimum and maximum) of the video that the user uploads.

For Example:

Users cannot upload videos that are more than 10mins and less than 5mins. So the duration of their videos should be in-between 5 to 10mins.

Thanks in advance...


texts: Preprocess function for targeting the home page

texts: What's the preprocess function for targeting the home page in a Drupal 8 site? Can I use a preprocess function that is called only for the home page?


texts: Why do Drupal core functions get node object instead of nid as argument?

texts: Most (if not all) of Drupal functions accept $node object instead of $nid as argument, like node_type_get_name($node), so we should first write node_load($nid) and send its long output to the functions, whereas they can call the node_load() function themselves and reduce number of developers' codes. What's the reason?


texts: How to create one entity and assign the same entity as field to new entity programatically

texts:
-I need to create one entity (need to do coding)- that I created already, now want to create  another entity, lets say "Entity 2"( term(taxonomy, param1, param2, description( it will have multiple values- multiple description).
Now I need to add entity 2 as field for entity 1. Entity 1 can have multiple entities of type "Entity 2"


texts: need path of an image created using an image style

texts:
<?php
  $node=node_load(3);
  $theme_img = file_create_url($node->field_theme_image[$node->language][0]['uri']);  //origional image path
  print $theme_img;
?>

I am trying to load an image in "page--front.tpl.php", which was created from a content of node value 3.
Using above code, I am able to get origional image url. But I need path of image created using image style (home_theme)


texts: Gallery pagination: next/prev button loop same page items (views_navigation)

texts:
Hope someone has resolved this:

Scenario:
I'm on a gallery (of 3) with several pages, when clicking on any image a page opens with a bigger version of that image.

http://example.com/gallery/bol-dor-mirabaud-2013-18?position=18&list=tgC1oEBhnrxlk2VVDsHkgtUdKBxNwQ7ZbidEqXmpxVc

I can navigate by clicking on Next which will continuously load in order all images in that gallery even if they are in other pages (pagination).

Problem:
If I click on a page, lets say  page 2: http://example.com/gallery/611?page=2
and the click on the image will do the same as described before but when clicking on prev/next will loop only between images on that page.

How I get it to work like the default page? noticed the list parameter is always changing after page load and maybe there's a way to set that to a fix variable like gallery id?

I'm using drupal 7.41 /PHP 5.4.39 / views_navigation 7.x-1.2-beta2

Thanks


texts: Why is Drupal displying missing core tables for an external DB?

texts:
I'm using an external non Drupal DB to import some data from. The importing itself work, but I also get error like the ones below:

Uncaught exception thrown in shutdown function.

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table &#039;lager_db.semaphore&#039; doesn&#039;t exist: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] =&gt; 480420510502a64252605e0.49437518 ) in lock_release_all() (line 269 of /srv/www/002/drupal/includes/lock.inc).

Why is Drupal even looking to base tables in that Database and how do I get rid of these errors?

My DB setup in settings.php:

$databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => '002_db1',
    'username' => '002_u1',
    'password' => 'password',
    'host' => 'localhost',
    'prefix' => '',
    'collation' => 'utf8_swedish_ci',
  );

$databases['lager_db']['default'] = array(
    'driver' => 'mysql',
    'database' => 'lager_db',
    'username' => 'username',
    'password' => 'password',
    'host' => '192.168.60.130',
    'prefix' => '',
    'collation' => 'utf8_swedish_ci',
  );


texts: generate or extract a automatic thumbnail for a video file using Video module in drupal 7

texts:
I need to show a video thumbnail of a video file which the admin upload using the video module.

I have a content type called MEDIA.I have created field as with following settings.

   LABEL             NAME           FIELD   WIDGET           OPERATIONS

   Upload Videos    field_video Video   Video Upload    edit    delete

Here The following setting I have set for the Upload videos label

         UPLOAD VIDEOS FIELD SETTINGS

These settings apply to the Upload Videos field everywhere it is used.

    Number of values: 1

   Upload destination
   Public files:checked

Enable auto video conversion:checked
 Convert videos automatically using FFmpeg or Zencoder. You can define presets at preset        settings to automatically convert videos to web compatible formats eg. FLV, MP4. Make sure   to configure your transcoder settings to make this work properly.
Video thumbnails
Automatically extract thumbnails from video (with fallback to manual upload):checked

  If you choose Automatically extract thumbnails from video then please make sure to      configure your transcoder settings to make this work properly.

Here I have checked the Automatically extract thumbnails from video  check box and I have saved it.

I have configure the transcoder  setting as follows.(I am working on windows XP)

  Video transcoder
    FFmpeg:checked
  Select a video transcoder will help you convert videos and generate thumbnails.

    Zencoder is unavailable: The Zencoder API module has not been setup properly.
   PATH TO FFMPEG EXECUTABLE
    FFMPEG:C:/xampp/htdocs/newsite/ffmpeg/bin/ffmpeg

   Absolute path to FFmpeg executable.When you install a new FFmpeg version, please clear the caches to let Drupal detect the updated codec support.
   VIDEO THUMBNAILS
    Path to save thumbnails:videos/thumbnails

    Path to save video thumbnails extracted from videos.
    Number of thumbnails:5

    Number of thumbnails to extract from video.
    Save all thumbnails in {file_managed} table
    Save all auto-created thumbnails to the {file_managed} table. Change file status as PERMANENT

Then I created a new media article where i upload the video from my system and But what happens the video thumbnail is not extracting from the video which I upload.

Can anyone help me.Please forgive me for my english


texts:
I'm using the Webform module to gather contact, and support information on our webpage, but we've got a serious problem.

When I export the data using the download feature in the module, it exports the date as TEXT, which means I can't sort or filter in Excel. This is a HUGE problem, and it doesn't give me any sort of options to change how this should be exported.

To clarify, Webform is exporting a date such as "Jan 24 2013 - 14:53" which DOES NOT convert to date in Excel because Excel doesn't understand that date format. Excel requires something like "9/9/12" in order to convert to a date format.

How do I get Webform to export a date in a format that is understood from Excel?

I am using Drupal 6, if this makes any difference.


texts: Hide top search box in OpenPublic based on OpenOmega 7.x-1.0 (default theme)

texts:
I am new to Drupal and am trying to hide the top search box that comes with a default install of OpenPublic since it blocks my title.

My issue is, when I click

Configure Layout
Site Wide Before
Edit and then the X....it only removes it temporarily.

After I click "Done" and then "Save Changes", the box reappears.

I can add the Search block to other parts of the site, like the footer, but I don't see the top box referenced anywhere in site Blocks.  It seems to be buried somewhere in "Main page content".  When I try to edit that box, I can't find a setting that relates to search in "Main page content"

EDIT:
Here is what my "themes" section looks like:


texts: How to properly delete fields, programmatically?

texts:
I have two content types on my site and I just deleted all the nodes using $node->delete().

For one of the content types, I noticed that the node body fields did not get deleted, nor did one of the custom fields I made for the content type. All the fields for my other content type were deleted .

So I researched and found the field_purge_field() function. I am not sure how to actually use the function, which is defined as function field_purge_field(FieldConfigInterface $field).
Can someone describe how I would actually load a field and then delete it in this manner (or in a better manner)?

Could I just truncate the tables?


texts: After insert data to table, updating data in home page drupal7

texts:
I have a insert_data module that used to insert data to category table, and I also have a module named mysite that has a function named “function mysite_preprocess_panels_pane(&$variables) “  is used to render data to panel.tbl.php.

My question is how can I call function “mysite_preprocess_panels_pane(&$variables)” from mysite module.

My purpose is after inserting data to table I want to show update data in home page(panel.tbl.php). I am new to drupal I need help or suggestion.
Thanks

Insert_data module

function insert_data($fn,$data) {
    $reply='';
    $status =1;
    $cid = db_insert('category') // Table name no longer needs {}
    ->fields(array(
   'name' => $data['name'],
   ))->execute();

   module_load_include('module', 'mysite', 'mysite');
   function mysite_preprocess_panels_pane();
   $reply= (array('status' => $status,'category' => $cid) );
   return $reply;
}

Calling mysite_preprocess_panels_pane() without parameter will be fine?

Mysite module

function mysite_preprocess_panels_pane(&$variables) {
    $query = db_select('category', 'n');
    $query->fields('n');
    $items = $query->execute()->fetchAll();

    $variables['ar'] = $items;
}

Panel.tbl.php

a
    <?php
        if (isset($variables['ar'])) {
             foreach (array_keys($variables['ar']) as $name) {
             print render($ar[$name]);
        }
     }

?>


texts:
I am trying to make a reservation system for equipment in a laboratory.
People reserve equipment by creating "reservation" nodes that are tagged with the taxonomy term "Equipment".
In the "create reservation page" the referenced taxonomy field is a dropdown list.

On the other hand I have a table view with all the equipment with its corresponding taxonomy term.
I would like to have in a third column a link to the "create reservation page" and  I would like that in the "create reservation page"  the corresponding taxonomy term in the dropdown list is already selected.
Any idea how to succeed?


texts: I'm using Drupal 7.14 with QuickTabs 7.x-3.4. I have a couple of views with feeds attached to them. I've also set the "Attach To:" field for these feeds. The ones that aren't inside a QuickTab are working fine, but the ones inside QuickTabs won't display their RSS icon. How can I get the views inside QuickTabs to also display their RSS icon?


texts: Is there is any module which creates new users by reading a spreadsheet/excel file?

texts: Could anyone tell me if there is any module which creates new users by reading a spreadsheet/excel file? I have added few more fields to the user registration form, and that might make this a bit tricky! Any suggestions would be helpful.


texts: How to restrict access to view node revisions with Organic Groups

texts:
Does organic groups restrict access to node revisions as well as the nodes themselves?

I have a node page with a view of the revisions output in a block in the sidebar. OG restricts access to the node itself if the user doesn't belong to that node's group however they can see the revisions in the block.

I have tried creating my own OG permission but the organic groups permissions aren't usable in the view restriction. Not sure what else to try?


texts:
taxonomy_select_nodes returns all the nodes tagged with a given tid. This function checks the taxonomy_index table.
That table stores the tid and the nids on which it is tagged.

Let's say I have some custom entities with terms on them AND a user entity with terms on it, how do I get all the entities tagged with a given tid? Can this be done in 1 query/function?


texts: How to show field collection items with comma separated in views?

texts:
I have profile type programmer. This profile type having a field 'field_collection' type named language.

In the field collection we have two fields

Language
Year of experience

Now I am going to create a view that will show all the users associated with that profile type(programmer). I want to add an field(language) in that view which will have all the languages with comma separated.

NOTE : I don't want to show 'year of experience' in the field, just want to show the 'language' only.
Ex : C++, PHP, JavaScript


texts: Automatically cycle through full-page nodes

texts:
Looking to implement something that will loop through nodes in the system. I'm not looking for carousel functionality, but instead want to load/display full-page node content, wait, and then load/display the next node.

The end result should be kinda like a TV channel, presenting nodes of various content types on big TVs in the common areas of our building.

I've got some ideas for how to build this, but would like to ask if there is a module that already accomplishes something similar?


texts: How to efficiently check if taxonomy has children

texts:
I am checking if a taxonomy term has children using taxonomy_get_children and I wonder if this is the most efficient way of doing it.
Since the function returns all the term objects, I believe it is not very efficient.


texts: Image File Upload via REST case Error 500 response due destination directory not set

texts:
I'm struggling to upload images to the Drupal 8 site via REST. Finally, I managed to deliver the file to the server, but then the error 500 rased due destination folder not set.
I can't figure where to define this destination directory: in request JSON data or header, or somewhere else in the settings.php or somewhere in REST configuration?
Here my code in Python:
def create_drupal_image(session, oauth, media_name, image_path):
    file_size = os.stat(image_path).st_size
    with open(image_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read())

    payload = {
        "filename": [
            {
                "value": media_name + ".jpg"
            }
        ],
        "filemime": [
            {
                "value": "image/jpeg"
            }
        ],
        "filesize": [
            {
                "value": str(file_size)
            }
        ],
        "type": [
            {
                "target_id": "image"
            }
        ],
        "data": [
            {
                "value": "data:image/jpeg;base64," + str(encoded_string)
            }
        ],
        "_links": {
            "type": {
                "href": oauth.base_url + REST_TYPE_FILE_IMAGE
            },
        }
    }
    return create_drupal_entity_impl(session, oauth, ENTITY_FILE_URL, payload)

def create_drupal_entity_impl(session, oauth, url, payload):
    payload_str = json.dumps(payload)
    # print(payload_str)
    endpoint = oauth.base_url + url
    # Set all required headers
    headers = {
        'Content-Type': 'application/hal+json',
        'Accept': 'application/hal+json',
        'Authorization': 'Bearer ' + oauth.access_token
    }
    # Post the new node (a Contact) to the endpoint.
    response = session.post(endpoint, data=payload_str, headers=headers, verify=oauth.verify)
    return handle_create_response(response)

Edited this source core/lib/Drupal/Core/File/FileSystem.php line 488 in order to print the $destination, and it appears to be empty. See '' in the server log below:
AH01071: Got error 'PHP message: Uncaught PHP Exception Drupal\\Core\\File\\Exception
\\DirectoryNotReadyException: "The specified file 'temporary://filemDIAwD' could not be copied
because the destination '' directory is not properly configured. This may be caused by a problem
with file or directory permissions." at /var/www/vhosts/web.site/core/lib/Drupal/Core/File
/FileSystem.php line 488'

Tried to define 'file_private_path' folder in settings.php, added 'tmp' folder under 'sites/default/files' but with no result. What am I missing here?


texts: How to validate fields in paragraphs form widget?

texts:
I have a profile paragraph with two fields, one is a node reference field, referencing profile nodes and another one is a simple text field (field_name). When the editor is adding a profile paragraph entity, he should provide one of the two fields, the reference or the name. As none of them is a required field I want to add a custom validation on form submission (not on autosave), which checks if one of the fields was provided and otherwise show an error.
So far I have found how to add the validation callback:
/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 */
function helper_field_widget_paragraphs_form_alter(&$element, &$form_state, $context) {
  if ($element['#paragraph_type'] === 'profile') {
    $element['#element_validate'][] = '_helper_profile_paragraph_validate';
  }
}

/**
 * Validate profile paragraph values.
 *
 * @param array $element
 *   Form element to be validated.
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 *   The state of the form.
 */
function _helper_profile_paragraph_validate(array $element, FormStateInterface &$form_state) {
  // TODO: validate code
}

What I didn't figure out is how to effectively validate and set the form error. I guess the code would be similar to ParagraphsWidget::elementValidate() but I was not able to get it work. Any help would be appreciated.


texts:
Suppose I have 100 nodes in language of English, I am going to import another 100 nodes with different language but same content.

I want to ask is there any module can establish the relationship between two node(with different language), as a result I can change to another language of the existing node by clicking the language switch button?

Thanks


texts:
I was testing my users accounts on my site, and login works fine for my admin account I created with MySQL in terminal.

But when I try to create a new account with the registration form I have, it shows the succeed message I created:

  Thank you for registering

Still the succeed message is shown, the account isn't created and an error occurs:

  Unable to send email. Contact the site administrator if the problem
  persists.


texts: Difference between router path and link path?

texts: I have recently started looking into the drupal menu system. I am not able to understand the difference between a router_path and the link_path. Both point to the same location in my installation.


texts: Using code field to display field from referenced entity

texts:
I have a content type of 'facility' which has an entity reference field ('manager') to a user. The user has a field 'telephone'.

Is it possible with a code field to display the manager's telephone number on the facility node?

I have played around with this but don't seem to be having any joy. I have looked for examples but can find none, so am beginning to think this isn't possible.

Any suggestions or advice most welcome.

(posted here at the suggestion of DS maintainer aspilicious)

Thanks,
Martin


texts: Can I create a link to a nodes taxonomy page?

texts:
I have a page that has a single category applied to it, for this example, "Self Help Books".

I want to put a place on content type that display a "view all [insert category here]" that links to that category listing page. I was hoping I could do something like:

view all %taxonomy:books%

and it would pull in the category for anything using that content type. I'm using the panels modules so I had planned on placing this in a panel the content type was using. Is any of this possible?

I thought about creating a block and placing that in a panel in the panels module.

(also, if you can't tell, I'm pretty fresh to Drupal.)


texts:
Is there a way to dynamically change the facet block title on each page based on the field label of the specific content type? The same field has different labels in each content type.

For example if we have in ‘Content type 1’ a field with Machine name: field_1 and label ‘AA’ and the same field in ‘Content type 2’ with label ‘BB’ when we are on Content type 1 page the facet block mast show AA and when we are on Content type 2 page it mast show BB.

I found a way to change the title with CSS using the Code per Node module, but it is not automatic and I have to insert the code in each content type. It doesn't seem to be right. There must be a better way.

I use this CSS in each content type.

.block-facetapi-”THEBLOCKID” .block-title {
  visibility: hidden;}
.block-facetapi-”THEBLOCKID” .block-title::after {
  content: 'Label B';
  visibility: visible;}


texts: Limit/nullify entity reference query/loading of select options, if using hook form alter to populate with ajax

texts:
I have added an entity reference field to a profile2 profile entity. The entity type referenced by this field will contain thousands of results (university courses). I have used hook_form_alter to add an ajax callback to the university field which is selected before the course field. Selecting the university first, then populates the course field (which is disabled initially) with the courses available only at the selected university. Since I do not want my courses entity reference field loading thousands of courses on load, I need to nullify the query or hook into the function that populates this field. I have seen entity reference limit module but don't intend to use it.
How can I achieve this? Thanks


texts: Should I use the theme layer or a module to create a complex, static page?

texts:
We have a few pages like the following on my site, everpurse.com: https://everpurse.com/home

They contain moderately complex markup and CSS. My approach to creating these pages is to create a module that uses hook_menu() to create a menu callback. The callback itself returns a render array containing something like:

return array(
  '#theme' => 'ep_homepage',
  '#attached' => array('css' => array(...)),
);

The module provides an ep-homepage.tpl.php template file that contains all the markup, including language, HTML, etc. The #attached CSS file styles everything.

It seems, though, that the proper "Drupal way" to do something like this is to put all the CSS and markup in the theme directory, and all the language inside of t(), and expose the language via preprocessed variables in the module. But there are a number of reasons I don't like this approach:

Some of the language is very markup-heavy. There may be sentences like Available now for a limited time only. Putting this into the module mixes module concerns with theming concerns.
The CSS in the theme gets aggregated, which means it will be loaded on every pageload—including pages that don't use it. (That is, by putting page-specific CSS into the theme, you sacrifice the benefits of using #attached.)
Even when putting all the markup into the theme, the page callback has to return something. But if the theme is taking care of all the markup, what should the page callback return? Just theme('ep_homepage')? This would mean the module should create an empty implementation of the ep-homepage template, and allow the theme to override it with a template of its own, right? This seems like such a silly workaround and a bunch of extra work, just to meet Drupal best practices.

So, I guess my question is: what is the Drupal best practice for a page like this? (And I'd rather not use Page Manager/Panels, since the markup is so complex that I'd rather edit it in a Git-controlled template file than via the Panels UI.)


texts: Use form id as part of a form input twig file name

texts:
Problem
I would like to have a theme suggestion for form elements (e.g. input, select, etc) that includes the form's ID. This would be nice for when I only want to make changes to the elements of that form and no other forms.
Currently I can use input.twig.html or input--textfield.twig.html for overriding a textfield. Therein lies the problem, neither of these theme suggestions are specific enough to only target the textfield for a specific form. I'm looking for the ability to have input--textfield--[FORM_ID].html.twig file.
Futhermore, it would be ideal to have a theme suggestion as follows input--[FIELD_NAME]--[FORM_ID].html.twig as this would allow a per field per form override.
Research
I have been unsuccessful in my research for finding a solution to this problem. Also, I am confused why this is not already in the theme suggestions (this is most likely to do my lack of knowledge on the twig system).


texts:
I created a website with some content nodes in D8. Right now, all the nodes are on the same level, however, I would like to achieve something like this:

- Products
- - Product A
- - Product B
- - Product C
- About Us
- - Offices
- - Contact

Naturally, I would like the nodes' URLs to respect the hierarchy, so that there would be URLs like mydomain.com/products and mydomain.com/products/product-a and so forth.

I know about Node Hierarchy being available for 7, but it seems there's no such solution for D8 - however, since this is such a basic requirement, I suppose there's a way how to do this I don't know about. So, how to? Is the book module maybe the right solution for this?


texts: I want to allow my end users the ability to save custom css (sass would be better) along with the page content that they edit in a WYSIWYG. I know they can put styles inline but sometimes it's useful to be able to use css selectors instead. Is there a module that will allow this?


texts: How to import Custom Post Types of wordpress into Drupal?

texts:
I've a wordpress site with around 500+ posts of a Custom Post Type with some custom fields attached to them.

I want to migrate them to Drupal. I've tried using wordpress_migrate. But it doesn't seem to work! This module didn't even seem to recognize the Custom Post Types. How can I import them?


texts:
I am developing moderation workflow using Workflow modeule. I have created different states for that. And using rules module I am putting node into one of the state based on certain event. It is working fine.

Now to emulate the Moderation process, I wanted to hide workflow tab (that appears on node page) when node is in certain state, and to display tab only when node is in one of the given states.

Is there any way I can achieve this?

-- Many thanks for your time.


texts: Services 3: Setting taxonomy terms on node creation/update

texts:
For a custom node type, I have defined a field that is to hold an unlimited number of values from a taxonomy vocabulary that I defined.

This is what it looks like:

[field_taxonomy] => Array
  ( [und] => Array
      [0] => Array
        ( [tid] => 13 )
      [1] => Array
        ( [tid] => 14 )
      [2] => Array
        ( [tid] => 15 )
  )

This is the JSON I pass to the server during node creation (as per [1]):

'field_taxonomy':
  { '11':
    { 'tid': '11'} }

This format is accepted (i.e. no 406, which I get if I try to mirror the above structure), but when I look at the node on the server, the field does not contain any terms.

What does my request have to look like so I can succesfully set taxonomy terms on a node?

[1] What will be the post parameter when specifying vocabulary term?


texts: Pre process a template that uses layout display

texts:
I want to preprocess a user account display. I want to manipulate a field value at display time.
for example, i want to change:
field_prefered_color: redto :
field_prefered_color: red - Cool, that is used 5 times today.
If I don't use layout builder I can easily change that in
function mymodule_preprocess_user(&$variables) {
  $variables['content']['field_prefered_color'][0]['#context'][['value'] .= t(' - Cool, that is used @times times today,['@times' => $times]);
}

But when I use layout builder, where can I find field_prefered_color to manipulate its output?


texts: variable_del wildcard when uninstalling a module

texts:
I have lot of variables created in a module. Is there any wildcard when deleting variables using variable_del.

Ex1: variable_del($key . '_campaign_text_*');
Ex2: variable_del($key . '_campaign_text_%');

Will any of these workout?


texts: How to hide node title while in edit without automatic nodetitle module?

texts:
Actually in hook nodeapi(op:presave) I'm setting my own custom title so I want to hide the title field from the node edit form.

It does not work if I use automatic nodetitle module since it is also changing the title.

What is the best way to hide the title without using automatic nodetitle module?


texts: Working on Drupal and Drush with teammates

texts:
I'm currently working on a website using Drupal 8, with 3 other members in my team.

We use git as a versioning system, and we very often work at the same time on different branches.

Here is the problem :

If we all use local databases, then it's a mess when we have to merge our code, because we have to isolate the parts of the database that have changed, and create a patch, or re-create the changes ourselves a second time.
For example if I have created many static pages, I have to create them again, or export the part of the database containing them.
If we choose to share a database to avoid that problem, then every time someone runs the drush cr command, everyone's website gets synched to their last changes, erasing every other changes from other teammate, which can be very confusing and annoying.

What is the right solution here?


texts:
So I've got this "nice" Drupal 7 site and there is a node with a large (70is) fields that the user fills in. There is a script that hides and shows certain questions depending on the previous answer. It works fine in IE9, FF, Chrome and Safari but in IE8 it gives this error:

A script on this page is causing Internet Explorer to run slowly. If it continues to run, your computer might become unresponsive.
Stop running script? YES/NO

There are only around 10 lines of my code being run, the rest is written out by Drupal. Is there a way to split up the script or speed it up? Or should I avoid using Drupal to write javascript and custom code it?
EXAMPLE
In the node/add I have code like this:
$form['group_section_one']['field_permit_number']['#states'] = array(
        'visible' => array(
            ':input[name="field_do_you_have_a_permit[und]"]' => array('value' => '1'),
        )
    );

To show the "permit number" field if they answer Yes to "Do you have a permit?". I do a similar thing for another 60 fields sometimes they depend on up to 4 field values.
That then writes out javascript which equates to around 100 lines all up. I wouldn't have thought that would freeze up the browser though...


texts:
I am facing an severe issue with Drupal instance. I am trying to clear the cache and the page is redirecting to error page.

This site can’t be reached
The connection was reset.
ERR_CONNECTION_RESET

Please help.


texts: I would like to know how to add to a template file a blog post content rendering code so that all blogs will be displayed whenever that template is rendered.


texts: how to set date field not to display past date

texts:
In a content I need a date field for which I have used Date module. Widget type used for this is popup calender. But when the calender popup appears I want to display only today's date and future dates, I don't want to display any of the previous date, not even a single day.

How could this be achieved?


texts: How to configure an editorial role with viewer-only unpublished node revision access in Workbench

texts:
I need to declare an editorial reviewer-type role that:

will have access to view unpublished content, and
does not have node edit permissions to the content types which the role does have the above permission to view.

This seems to work okay for new unpublished node drafts by just granting the Workbench Moderation permission: 'View all unpublished content', but node revision drafts (.../node/123/draft) throw an Access Denied error.

It seems that it is not currently possible to set up a view-only, role-based user access allowance using the Workbench config settings and the combined Node and Workbench permissions grant options.

The only option that I can figure out are that in order for a role to be able to access an unpublished node revision draft page, it must have the permission 'Node -> [content type] -> Edit any content', which essentially strips the read-only, view all unpublished restriction/allowance.

The question is:
Does anyone know of an existing methodology or solutions option for achieving the desired result of configuring a user role that has view/read-only permissions allowance of in a Workbench moderated environment?

I can think of several 'right way' approaches, from custom code-based Rules implementation to some invasive custom module API intervention, as well a some hacky shortcuts that are most definitely 'not the right way', but I was just hoping that someone may have some insight into something obvious that I am overlooking or a solution that has been done already that could be twiddled with.

The only thing that I could find on d.o the was relatively close was an abandoned, unfinished and overly-complex sandbox project: Workbench State Permissions (https://drupal.org/sandbox/isampo/1955252).  This looks like it had some good ideas, but probably was a bit over too much in implementation.


texts: View only displays nodes that has comments when adding comment count field

texts:
On drupal 8 I am facing an issue with views.
I created a view listing all nodes of a certain content type.
I added basic fields, Title, Date content was created, and a read more link.
The view works fine with these fields, but when i add Comment Statistics: Comment count, all nodes that don't have any comment don't show up in the view.
It only lists nodes that received comments.

Any idea on how to fix this ? Am I doing something wrong ?

Thanks


texts:
I am looking to build a Drupal 8 website that requires the notion of a content type (a job) that has fields for adding tasks that can be assigned a due date and be ticket off when completed.

Then I'll need to be able to show all the tasks on a calendar view, overdue reminders, repeat tasks etc.

Can anyone point me in the right direction as to how I could approach configuring this with core functionality or modules for Drupal 8?

Sincerely,

Andy


texts:
I got a drupal 8 home page wich works fine but all my content on that page is in the same textbox like this image here:

How can I make it so I can seperate this content and still show it under each other on the home page? This makes it way easier to edit and add new content to the page instead of editing this huge textbox of html code I got now.

I just want it so you can just press the "add content" button and it adds a new html section to the page where you can create a image slider or something and this stacks up under the content that allready  has been added.

If i press the add content now it creates a new node/# page wich I dont want. I just want the content on the home page if i press the add content button there.


texts:
I have Drupal 8.4 running on Windows Server 2016, and when trying to use an upload field on a content type I get this error

The file phpC128.tmp could not be saved. An unknown error has occurred.
File upload error. Could not move uploaded file.

I deleted the files folder and IUSR, account PHP is running under, recreated it for this month as expected, but this still errors out. I see the file in c:\windows\temp but it doesn't make it to my site folder. IUSR has full control to the files folder and the 2018-06 folder.

In IIS, the AppPool is running under ApplicationPoolIdentity as well.


texts: Next/previous links in a view based on contextual filter in the url

texts:
I have a page view in a Drupal 7 view with contextual filters in the URL.  something like /events/%1/%2 - the first parameter is the year, the second is a taxonomy term. So /events/2014/3 is all the events in 2014 in category 3.

I want to provide next and previous links based on the year (the first filter parameter). Is this even possible?


texts: How to get site url with twig in Views custom text?

texts:
In Drupal 8 I try to get the absolute site url in a Views custom text field.

I added {{ url('view.frontpage.page_1') }} which gives me example.com/node

Drupal docs say {{ url('view.frontpage') }} would do it, but it just gives me wsod and throws an error like so:

AH01071: Got error 'PHP message: Uncaught PHP Exception Symfony\\Component\\Routing\\Exception\\RouteNotFoundException: "Route "view.frontpage" does not exist." at /../../docroot/core/lib/Drupal/Core/Routing/RouteProvider.php line 187\n'

Any ideas?


texts: How to update user fields from a custom module form?

texts:
I need to simply update some user fields from a custom  module form.

I try this but it doesn't works :

/**
 * Submit the register form
 *
 * @param array $form
 * @param FormStateInterface $form_state
 * @return array|RedirectResponse
 */
public function submitForm(array &$form, FormStateInterface $form_state)
{
    // Create a new user
    $values = $form_state->getValues();

    // User from Drupal\user\Entity\User;
    $user = $this->ctrUserManager->getCurrentUser();

    if($user){

        $user->set('mail', $values['mail']);
        $user->set('field_last_name', $values['field_lastname']);
        $user->set('field_first_name', $values['field_first_name']);
        $user->set('field_civility', [$values['field_civility']]);

        $violations = $user->validate();

        if (count($violations) === 0) {
            $user->save();
            \drupal_set_message('Your profile has been updated');
            return $form;
        }
    }

    \drupal_set_message('Error during user profile update', 'error');

    return $form;
}


texts: View results to show results in language of current page, but if no translation available show original language?

texts:
I need a view to display results based on the following:

if the content has a translation available in the language of the current page, show that one
if the content DOES NOT have a translation available in the language of the current page, then show the original source of the content

The same content item can be shown only once, regardless of language (i.e. if the content is shown in english then it cannot also be shown in spanish in the same view).

Thanks for the help.

EDIT: Additional information.

Most* content is sourced in English and some of it is translated to Spanish. There are three pieces of content, however, who's original language is Spanish and do not have an English translation.

So, when viewing the aggregation page in Spanish, I should see the three Spanish articles as well as all of the other English articles, but I should see the English articles who have a translation in Spanish have their Spanish translations rendered. I should also see all of the English articles who don't have Spanish translations.

When viewing in English, I should see all of the articles in English with the exception of the three Spanish articles who should be rendered in Spanish (since it's the only available language for those articles).

EDIT: Image showing configuration of the view currently.

EDIT: Image showing available filter options for Original language.


texts: Apache solr + Facet API, can I filter with node title?

texts:
I am trying hard to find a text facet to filter the results by node title. Is it possible?

I tried the following method but facet is not appearing on the search page:

function biyixia_apachesolr_field_mappings_alter(&$mappings, $entity_type) {
  // Enable indexing for text fields
  $mappings['text'] = array(
    'indexing_callback' => 'apachesolr_fields_default_indexing_callback',
    'map callback' => '',
    'index_type' => 'string',
    'facets' => TRUE,
    'facet missing allowed' => TRUE,
    'dependency plugins' => array('bundle', 'role'),
    'hierarchy callback' => FALSE,
    'name_callback' => '',
    'facet mincount allowed' => FALSE,
    'multiple' => FALSE,
  );
}


texts:
I want to write a function inside a module that will return last 20 contents of type X . is there any drupal ready function ? or shall i use queries ?

THanks


texts: Is putting content in the codebase or the database better for performance?

texts:
I recently created a website footer using a block template. Some of the footer's content was entered through the block's wysiwyg (stored in the database), but other code-heavy elements were placed in the block template file (stored in code). I've noticed that the footer block loads slow at times. Other times, the content inserted through the wysiwyg loads a few seconds before the content that was inserted in the the block template.

I'm curious, is storing html content in the database better for performance than storing html content in template files?

EDIT: After I posted this, I also realized that the footer is being rendered with Blocks whereas the rest of the page is being render with Panels. I'm not sure if that would have any effects of its performance.


texts: Theming a views field output using views-view-fields.html.twig

texts:
I am trying to customize a views output on a view page to wrap the fields in custom markup. I need to group a set of fields to achieve the desired layout like so:

Example:

       {{ field.[field_name_1].content }}

       {{ field.[field_name_2].content }}
       {{ field.[field_name_3].content }}
       {{ field.[field_name_4].content }}

This is what I have come up with so far:

{% if view.projects_page -%}

        {{ field.field_project_image.content }}

        {{ field.field_project_header.content }}
        {{ field.field_sub_header.content }}
        {{ field.field_short_project_description.content }}

{%- endif %}

This doesn't throw any errors but also doesn't seem to work because
 {% if view.projects_page -%} does not target the view in the way I thought it would.

So the question is - How do I detect the view with a conditional so I get the output desired above?


texts:
Is there a way to resave all items in a particular menu batch-style?

I'm trying to avoid saving each menu item manually, there are so many of them...


texts: Select from list or create other structured data in form field

texts:
I want to let users choose from a list of checkbox items, and I want users to be able to build their own options, if the options they want aren't in the list of checkboxes.
I'd like users to have the ability to build as many "custom" selections as they'd like.

The value is compound, so http://drupal.org/project/select_or_other won't cut it.

Is there a good module for this or a FAPI approach? It seems like this is close.

Here's a pseudo interface for illustration:

Select:

[] 1 liter(s)

[] 2 liter(s)

[] 1 gallon(s)

[] 2 gallon(s)

Or other(s):

[  (textbox that accepts number)  ]  [ (dropdown that lets you choose liter(s) or gallon(s)) ] [Add] <--a button


texts:
I add some fields to default user fields,like  phone,address,city,... , I want If user edit or filled up his user information in user/uid/edit when submit ,if there is not any commerce shipping profile, create a profile to him/her, and if there is , update default shipping profile ,
how can I achieve this job?
I know I can create  profile with something like below code

 $new_profile = commerce_customer_profile_new($type);
  $wrapper = entity_metadata_wrapper('commerce_customer_profile', $new_profile);
  $wrapper->uid = $account;
  $wrapper->commerce_customer_address->country = $country;
  $wrapper->commerce_customer_address->name_line = $name_line;
  $wrapper->commerce_customer_address->first_name = $first_name;
  $wrapper->commerce_customer_address->last_name = $last_name;
  $wrapper->commerce_customer_address->organisation_name = $organisation;
  $wrapper->commerce_customer_address->administrative_area = $administrative_area;
  $wrapper->commerce_customer_address->sub_administrative_area = $sub_administrative_area;
  $wrapper->commerce_customer_address->locality = $locality;
  $wrapper->commerce_customer_address->dependent_locality = $dependent_locality;
  $wrapper->commerce_customer_address->postal_code = $postal_code;
  $wrapper->commerce_customer_address->thoroughfare = $thoroughfare;
  $wrapper->commerce_customer_address->premise = $premise;
  $wrapper->field_bcg_customer_phone = $phone;
  commerce_customer_profile_save($new_profile);

but my question is , how can set it as default, after user edited (updated) if there is default profile , update it also

appreciate any help


texts: How to disable Commerce, but still have the module for later use?

texts:
So I have a client that needs the ability to have a store without the actual eCommerce right now. Later, the client will enable the checkout/payment features of Commerce and run it like normal. So basically:

1) Client still needs the catalog, create products, show products and pricing, etc.
2) A customer can't actually purchase anything, there is no cart, you can't checkout, etc.

Is it as easy as disabling the cart submodule? Or would hiding the add to cart buttons and requiring higher levels of auth to view /cart? I've thought of both but don't know what would be foolproof.

I know I can just create custom content types that will do the same thing as creating products, but I know in about six months or so they want to turn the ecommerce on and I don't really want to have to convert everything to products and do all the work then. I'd like to just create the products normally right now and just flip a switch later.


texts: Lost all JS and CSS on updating the module?

texts: I had added JS and CSS in the views module using the .info method. Made JS and CSS file in the views module file (as sites/all/modules/views/jsfile.js & sites/all/modules/views/cssfile.css) and attached it through views.info file. It was working fine. But today got an update notification of views module and updated the views and those all customized css & js things gone. Code was small so I made it again. But what is the right way to do this? So on update it will not go away? I believe adding css & js by .info method also a one of standard method.


texts: View item duplicates based on total views

texts:
I have a view that simply loads all the latest articles but I ran into some strange problem. Each time I visit an article, the view count increases but this also means that a certain article will appear in the as much as the count shows.

For example:

View:
- Article 1
- Article 2

When I click on Article 1 my view updates to:

View:
- Article 1
- Article 1
- Article 2

I hope this is clear enough to understand.

Note: maybe worth mention I'm setting up a service so in my json api I get the same results


texts:
I used composer create-project drupal-composer/drupal-project and have happily been using composer install composer require and composer update to keep my development system up-to-date and moving it around different development machines.

However, the upgrade to Drupal 8.1.0 from 8.0.6 was clumsier that I'd expected. Is there a slicker way of upgrading all the symfony dependencies than this?

composer require drupal/entity:8.1.0-alpha2 drupal/core:8.1.0 \
    symfony/process:~2.8 symfony/console:~2.8 symfony/event-dispatcher:~2.8 \
    symfony/yaml:~2.8 symfony/translation:~2.8 symfony/validator:~2.8 \
    symfony/serializer:~2.8 symfony/routing:~2.8  symfony/http-foundation:~2.8 \
    symfony/http-kernel:~2.8 symfony/dependency-injection:~2.8 \
    symfony/class-loader:~2.8

drush @mysdevsite updb

drush @mydevsite cr

BTW
This current (25 April) sole answer to the duplicate question didn't work for me. e.g. - drupal/entity 8.0.1 requires drupal/system <8.1.0 -> satisfiable by drupal/core[8.0.6, 8.0.x-dev]. caused Your requirements could not be resolved to an installable set of packages. So I had to require each of 8.1.0's dependencies in turn just the same as without the --update-with-dependencies option. Painful.


texts: Triggering a Google Analytics Event on Form Submit

texts:
I'm trying to trigger a Google Analytics event when the user submits a form that is in a block.

My goal is to track conversions when the user signs up to the Campaigner contacts manager and email list software.

I'm using the Google Analytics module  (7.x-2.0) and the following code

<input name="SubmitButton" value="Submit" id="SubmitButton" class="btnStyle"   style="background-color:#77738e;color:white" type="submit" onclick="_gaq.push(['_trackEvent','Form Submit','Campaigner Subscribe','EJ Now',1,false]);">

That gives me an error in Firebug: "ReferenceError: _gaq is not defined". So I tried adding var _gaq = _gaq || []; to the onClick function.  That removes the error, but the event does not show up in Google Analytics Real Time.

Is the _gaq object not properly registered by the Google Analytics module?

This is my website  You can test the form using a fake email.  The form is Energy Justice Now and is in the top of the right column.

Update:
I have since implemented the Google Analytics Event Tracker module and the example module that comes with it. I see events being triggered in Firebug console, but I do not see them in Google Analytics (even after waiting 12 hours).

The Google Analytics module appears to be operating fine and I get analytic results for the website.  It is just that I cannot get the event tracker to work.


texts:
I need to add smart Google translate plugin from Here , where is the best place in code, so I could add it to header, somewhere here?

It is a header, but should I add it to html.tpl.php or somewhere else?


texts: Accidentally deleted uploaded files, now I can't remove missing files from node

texts:
So I made a bit of an mistake and accidentally deleted some uploaded files via FTP. In the backend, when I try to remove the missing files from the node itself, it presents an error "The website encountered an unexpected error. Please try again later." Upon checking the error logs it says:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri': INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1384489746 ) in drupal_write_record() (line 7166 of /Applications/MAMP/htdocs/fung/includes/common.inc).

Any ideas how to fix this?


texts: Add options to the FORMAT drop down in CKEditor?

texts:
How can you add block formats to the Format drop down in CKEditor? There used to be an input in D7+WYSIWYG as to what was allowed.

No matter if I check or uncheck "Limit HTML to the following tags:", I cannot get the cite tag to show. Therefore, when using the blockquote button, I cannot highlight any text in it and change the format to cite.

How can I add the ability to change a piece of text to the cite tag within a blockquote or p tag?

Note: styles, html source buttons are out of the question.


texts:
I have an external oracle db I'd like to use to show data in views. Has anyone used the OCI8 module, if so, (sorry for my ignorance) how do we see the data? Do I need to create a custom module and hook into it? I cannot find any how to on this.

The readme says: 1) Build out OCI8OracleSelectQuery class which will mimic Drupal's SelectQuery. This would include writing an oci8_db_select() function to create these

Where do I do this? Thanks!


texts: Using different DS layouts with the Context module

texts:
I have build a "build mode" called "anonimus_profile" in admin/build/ds/modules/nd/buildmodes.

I went to admin/build/ds/layout/profile2/anomimos_profile, and configured the fields.
I enabled the Context module, and configured the options.

The conditions are the following ones:

Node type: profile2
User role: anonymous user

The reactions are the following ones:

Nd build-modes: Anónimos profile

I saved the context, and cleared the cache, but the anonymous user doesn't see anything different.

Am I missing anything?


texts: How do I display a modal dialog on page load, with working title and dialog options, using OpenModalDialogCommand?

texts:
I'm trying to display a modal dialog containing some simple markup on page load. I'm getting the expected markup to load, and the dialog appears. However, the dialog title always displays "Loading..." and the options (width, specifically) don't appear to work.
I've got the following in my controller:
public function modal() {
  $config = \Drupal::config('popup.settings');
  $title = $this->t('Fnord');
  $content = [
    '#type' => 'processed_text',
    '#text' => $config->get('content')['value'],
    '#format' => $config->get('content')['format'],
  ];
  $options = [
    'dialogClass' => 'popup-dialog-class',
    'width' => '75%',
  ];
  $response = new AjaxResponse();
  $response->addCommand(new OpenModalDialogCommand($title, $content, $options));

  return $response;
}

...and the following javascript:
(function ($, Drupal, drupalSettings) {
  $(document).ready(function () {
    var ajaxSettings = {
      url: '/popup/modal'
    };
    var myAjaxObject = Drupal.ajax(ajaxSettings);
    myAjaxObject.execute();
  });
})(jQuery, Drupal, drupalSettings);

The result:

The width should be about 1152px on my screen, but is instead an even 600px; I assume that's a default, and that my $options array isn't overriding it as I would expect.
On the theory that this is only expected to work if the dialog is opened by a click event, I tried setting the dialog options in the javascript:
var ajaxSettings = {
  url: '/popup/modal',
  dialogType: 'modal',
  dialog: { width: 300 }
};

...however, the result was identical. What am I doing wrong?


texts: Send list of node title and body via email to users

texts:
I have a question and answer site.

I would like to send via email a list of the node title and node body of all questions created over a period e.g 24hrs or 1 week to users on my site.

I do not know which module(s) would allow me select nodes of type question and then send the list via email to users on my site.

Thank you in anticipation


texts: How to add OR conjunction between field conditions in EntityFieldQuery

texts:
Possible Duplicate:
  Using OR with EntityFieldQuery

I have this code in my module:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'activity')
    ->propertyCondition('status', 1)
    ->fieldCondition('field_file_blackwhite', 'fid', $fid)
    ->fieldCondition('field_file_color', 'fid', $fid);
$nodes = $query->execute();

It should retrieve nodes with a certain fid in either "field_file_blackwhite" OR "field_file_color". Actually it querys not with OR but with AND so no nodes are found.

How can I use "OR" conjunction between both "fieldCondition" conditions?
I have tried with delta value but no luck.


texts: Expandable Tree Menu with parent links inactive

texts:
In Drupal 7 I am trying to have a tree menu that the parent items expand/contract on click, but I do not want the parent items to be a page link. I have tried DHTML Module and it does not work how I expected it to work.

I am even willing to try a solution where the tree menu is fully expanded but the Parent Item is not a link, just static text.

Suggestions?


texts:
I have written a custom module which generates a PDF when a Webform is submitted and mails it to the admin. I am using the Print module to generate the PDF. The problem is, it seems to use the user's permissions when generating the PDF, and not the admin's. This is generally ok for authenticated users, but for guests, it just fails completely.

I have enabled "Access the PDF version" and "Access own webform submissions" permissions for all users (anonymous and authenticated), but I guess "own" still checks for a user ID and fails for guests.

The Print module uses this code to get the content of the $node from the url

$node = new stdClass();
$node->body = menu_execute_active_handler($path, FALSE);

And here is how I am using the Print module to generate the PDF contents

module_load_include('inc', 'print_pdf', 'print_pdf.pages');
$pdf_url = 'node/' . $nid . '/submission/' . $sid;
$file_content = module_invoke('print_pdf', 'generate_path', $pdf_url);

When it's a user with permission (authenticated), this works fine, it generates and mails the PDF successfully. The contents of $node->body are fully populated.

However, when it's a guest, the contents of $node->body is just an integer. Is there any way for me to tell it to bypass the permissions when generating the PDF? Or is there a better, secure way around this?


texts: How to access cookies in Views PHP Code filter?

texts:
I have a view that will display nearby locations.

The center coordinates would come from a cookie (lat,lng).

I am trying to get the cookie with $_COOKIE, but I get an error saying that it is not set.

How would i access that cookie and return in for a proximity filter i Views (Using the Location module)?


texts:
I have a problem with Drupal 8. I have enabled the default contact form and I have added two custom fields.
Currently, the form send a mail with my two fields at the end of the mail. I want to change that order but I don't know what to do.

I have used a custom submit thanks to that line in my form alter.

$form ['actions']['submit']['#submit'][] = 'module_contact_submit';

But now I am lost and I don't know what to do in my submit function. Maybe there is a twig template for the mail?

Thank you for reading this and helping.


texts:
I need to provide the option for sorting on the basis of nodeviewcount.
The criteria is that if any text is provided for search, the search results will be displayed according to maximum number of nodes viewed.


texts:
What I want to achieve?

I've got a menu with lyrics / blogs, and I want each entry to appear as a sub menu item.

example:

[Main menu]
    Blog
        Dooms day
        Get to daddy
    Lyrics
        Your mom
        Brothers and systers
        Stack overflew

So, when I add some blog post or lyrics, there is an option to add them into a menu, however each entry add with weight 0, and they actually appear in ascending order.

So, I want to create a view, and just select the title but and order them by descension on the Update time.

I can make them display in the main content window, but I've got no clue how to actually place them as submenu entries.

Any ideas?


texts: Making an ecommerce photography competition website

texts:
This has been bugging me for days, I just can't wrap my head around this situation/process and how to make it work in Drupal.

I'm making a photography competition website where a user who signs up and buys a role has the choice to upload 3(costs £4), 10(costs £6) or 20(costs £10) images but each image needs to be a part of a competition category, so say someone uploads 3 images, one is for black and white category (taxonomy term), one is for wide angle and one is for sport, each image needs to be tagged with the correct category, of which im using taxonomy terms. But how do i go about this?

Firstly limiting the user to said amount of photos? I was thinking they buy a role (there are 3 roles), role one allows to upload 3 images using the content type 3 images, role two allowed to upload 10 images on a node and the final content type is '20 images' and they can upload up to 20 images using that content type, each user though must be able to categorise each individual image using the taxonomy vocab already created called Photo Categories. How the hell do i tag each individual image so that they are categorised and ready for viewing/judging later on??

Should I do this on the user profile instead? So that when they buy their role, they can then upload the amount of photos that they are allowed to? This will still mean I have the problem of assigning each image to a taxonomy term.

Also, is purchasing a role the best way to go about this? Now that you know what I am after what are your thoughts? I know Drupal can do this 'out of the box', i'm just struggling to see what workflow the end user will go through to achieve all of this.