texts:
I am using user_save() to migrate users from another application into Drupal, but my profile fields are not updating.

Does anyone have any suggestions as why this isn't working, or how I can get it to

        $newUser = array(
          'name' => $row->user_name,
          'pass' => $row->user_password, // note: do not md5 the password
          'mail' => $row->user_email,
          'status' => 1,

          'profile_title'=>$row->user_title,
          'profile_firstname'=>$row->user_first_name,
          'profile_lastname'=>$row->user_last_name,
          'profile_jobtitle'=>$row->user_job_title,
          'profile_orgname'=>$row->user_organization,
          'profile_telno'=>$row->user_contact_no,
          'profile_faxno'=>$row->user_fax_no,
          'profile_streetaddress'=>$row->user_address1.$row->user_address2,
          //'profile_address2'=>sanjay,
          'profile_city'=>$row->user_city,
          //'profile_state'=>sanjay,
          'profile_postalcode'=>$row->user_postal_code,
          'profile_country'=>$row->iso,
          //'profile_stateprovince'=>$row->sanjay,
          //'old_user_id'=> $row->user_id,
          'init' =>$row->user_initial,
        );
        user_save(null,$newUser);


texts: How do I export/import all the relations created by Relation module?

texts: There are standard procedures to export/import relation types, but not for the relations themselves. At least, I couldn't find any. Am I missing something obvious?


texts:
I successfully setup hybridauth module with drupal & it works fine. Now I want to fetch some details of logged in user.

There is a documentation on doing this using graph api here. However, when I try this in a drupal module its not working. What is the right way to interact with the module?

 $facebook = $hybridauth->authenticate( "Facebook" );
 $response = $facebook->api()->api('/me/friends');

Below is the error returned.

Fatal error: Call to a member function authenticate() on a non-object in /var/www/html/dev/shophoc/v1/sites/all/modules/shophoc/shophoc.module on line 4


texts: Display video transcode PRESET options in Node Edit form

texts:
I need to be able to expose the video transcoding preset options within Node Edit pages. Currently, the Video module allows me to choose/change the Presets site-wide in Video modules settings page under admin/config/media/video/presets.

I have multiple presets with different video duration options. I am trying to let users to choose a preset option within node edit page and apply the video duration preset upon saving the node. I have it set to auto convert the video file upon saving the node. (example below)

I've copied below(video.field.inc) to display the options within the node edit page but it doesn't get applied. -- The video transcoding process is broken.

$selectedpresets = array_filter(variable_get('video_preset', array()));
  $presets = Preset::getAllPresets();
  $presetnames = array();
  foreach ($presets as $preset) {
    $presetnames[$preset['name']] = $preset['name'];
    if (in_array($preset['name'], $selectedpresets)) {
      $presetnames[$preset['name']] .= ' (' . t('default') . ')';
    }
  }
  $form['presets'] = array(
    '#title' => t('Presets'),
    '#type' => 'checkboxes',
    '#options' => $presetnames,
    '#default_value' => !empty($settings['presets']) ? $settings['presets'] : array(),
    '#description' => t('If any presets are selected, these presets will be used for this field instead of the default presets.'),
    '#access' => $hastranscoder,
  );


texts:
When I embed an image into CKEditor text I can choose alignment options. When I embed a Media Image I cannot choose alignment, but a Media View. A media View allows me to specify image size (via image style) but not alignment

Embedding an Image does not add the image to the Media Library and it would be nice to only use Media Image embedding so as to manage the site's media library of images.

What is the preferred way of specifying the alignment of embedded Media?

Background

I am switching over to simply using core Media modules in Drupal 8.8. I have ditched what I was previously using:
*  Embed
*  Entity Embed
*  DropzoneJS entity browser widget
*  Entity Browser
*  Entity Browser IEF


texts: Allow access to private files only to Drupal, rest all 'access denied'

texts:
I have a drupal 7 installation with PDF module on NGINX server. I have a PDF.js field configured in all of the content types, PDF uploads through this goes to private (I NEED this as private). pdf.js viewer shows a 403 when upload path is set to private. But works fine when upload path is changed to public.
I tried modifying .htaccess (my drupal is currently on localhost, also accessible through an IP):

Order Deny,Allow
Deny from all
Allow from localhost
Satisfy Any

Also,

Order Allow, Deny
Deny from all
Allow from localhost

Also tried IP address in place of localhost, still nothing. I want pdf.js viewer to display private pdf files, but the pdf files should be inaccessible through their direct URL to both anonymous as well as authenticated users.


texts: how to have conditional required fields through hook_form_alter?

texts:
Here is basically what I'm trying to do.
If the draft field is present I would like to make the name field not required.

if($form_state['values']['field_draft']['und'][0]['value']){
  $form['field_name']['und']['#required'] = FALSE; }

Is this even possible? I tried after_build but it doesn't work.  If not, is there a better way to add draft functionality through hook_form_alter.

Thanks!


texts:
Is there a way of recording changes made to a Drupal site in a log?

Im working as part of a team and some members are off site. We're running into issues where changes are made to the path pattern of nodes by other members, and it would be really useful to be able to check what changes have been made recently. Even better would be to know which admin user made the changes. Thanks


texts: How to style the Views pager with Twitter Bootstrap 'pagination' class

texts:
I have

1

2

...

I would like to style it using bootstrap

1

2

...

How do I alter the output using

MYTHEME_pager(&variables) {

return theme_pager($variables);
}

?
Here is the content of $variables.

EDITED
So far I can somehow alter it by copying from views.inc the function function theme_views_mini_pager($vars), but I encounter the following blockers:

there is no similar theme function for full pager
there is no way to change the wrapper class item-list or to add pagination class aside.

Here below is the return of theme_views_mini_pager($vars)

return theme('item_list',
  array(
    'items' => $items,
    'title' => NULL,
    'type' => 'div',
    'attributes' => array('class' => array('pagination')),
  )
);


texts: How to use a date format in hook_entity_presave

texts:
I am using hook_entity_presave to combine the values from a date field and a text field in another field.
To do so, I need to format the date first. I would like to use one of the date formats defined in admin/config/regional/date-time for this. How do I do this?
Here is how I get the date field value, which outputs the date format as YYYY-MM-DD:
$entity->get('field_date')->getString()


texts: Override page template and preserve administration navigation bar

texts:
Short version; I am trying to override the default page.html.twig (in D8) for a controller from my module and the following examples I've found have not worked:

https://www.drupal.org/node/2499827
Override html.twig.html within custom module

My company is developing a custom module to embed a React app we originally built for another system inside the admin side of Drupal. As such, we would like to keep the admin navigation visible but the main body of the page should just be the react app.

So far, I have successfully embedded the app as the content of a page, but still have the page's header, footer, breadcrumbs, etc. I'm not sure if I'm declaring my module's theme incorrectly, or if my naming is wrong for my template, or something else.

Thanks in advance!

Module name: my_module

my_module.info.yaml

name: Overriding page module
description: "Module with a template that overrides the default page.html.twig"
package: mystuff

type: module
core: 8.x

my_module.module

function my_module_theme() {
    $theme['page__my_module'] = [
        'template' => 'page--my_module',
    ];

    return $theme;
}

my_module.routing.yml

my_module.content:
  path: '/hello'
  defaults:
    _controller: '\Drupal\my_module\Controller\HelloController::content'
    _title: 'Hello World'
  requirements:
    _permission: 'access content'

templates/page--my_module.html.twig

{#
  Taken from https://api.drupal.org/api/drupal/core%21themes%21seven%21templates%21page.html.twig/8.2.x
#}

      {{ page.header }}

    {{ page.pre_content }}
    {{ page.breadcrumb }}

      {{ page.highlighted }}
      {% if page.help %}

          {{ page.help }}

      {% endif %}

WHY DOESN'T THIS TEMPLATE GET USED!?

      {{ page.content }}

src/Controller/HelloController.php

<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloController extends ControllerBase {
    public function content() {
        return array(
            '#type' => 'markup',
            '#theme' => 'my_module',
            '#markup' => $this->t('Hello World!')
        );
    }
}

UPDATED

Thanks to @kiamlaluno, I found I could use the theme suggestions hook to tell drupal what theme to apply. I changed my_module.module to:

<?php

function my_module_theme_suggestions_page(array $variables) {
  $path = explode('/', trim(\Drupal::service('path.current')->getPath(), '/'));
  if (isset($path[0]) && $path[0] == 'hello') {
    return 'page--my-module';
  }
}

function my_module_theme() {
    $theme['page--my-module'] = [
        'template' => 'page--my_module',
    ];

    return $theme;
}

and removed the #theme item from the controller's render array. It works now!


texts: How to add custom text settings to a custom theme?

texts:
I'm working on a custom theme called "YingYang". I didn't make the theme, but I have to do some stuff with it. The theme has custom text settings which is bassically some pre-set content.
It looks like this

Now my question is: How can I create a new text setting for this theme?
I've been searching for a while in the drupal UI and in the code, but I can't find anything about it.
Thanks!


texts: How to inherit base class dependencies without redefining theme in child class service arguments?

texts:
The current system
I have a set of services classes that extends the same base class ex:
class NodeHandler extends ContentEntityHandlerBase {}
class ParagraphHandler extends ContentEntityHandlerBase {}

and this base class receives these dependencies:
class ContentEntityHandlerBase extends ControllerBase {

 public function __construct(EntityTypeManager $entityTypeManager, RequestStack $requestStack, PermissionsService $permissionsService, LoggerChannelFactoryInterface $loggerChannelFactory) {
    $this->entityTypeManager = $entityTypeManager;
    $this->request = $requestStack->getCurrentRequest();
    $this->permissionsService = $permissionsService;
    $this->loggerChannelFactory = $loggerChannelFactory;
  }

So for each child class ex:(NodeHandler , ParagraphHandler) I need always to inject the parent class dependencies ex:
services:
  sacd_rest_api.node_handler:
    class: 'Drupal\sacd_rest_api\service\NodeHandler'
    arguments: ['@entity_type.manager','@request_stack','@sacd_user.permissions','@logger.factory']
  sacd_rest_api.parapgraph_handler:
    class: 'Drupal\sacd_rest_api\service\ParapgrapHandler'
    arguments: ['@entity_type.manager','@request_stack','@sacd_user.permissions','@logger.factory']

The problem
I don't want to re-inject the parent dependencies each time I create a service class that extends it unless I want to inject a new dependencies that is not inherited from the Base Class for ex:
services:
  sacd_rest_api.node_handler:
    class: 'Drupal\sacd_rest_api\service\NodeHandler'
  sacd_rest_api.parapgraph_handler:
    class: 'Drupal\sacd_rest_api\service\ParapgrapHandler'

So in order to prevent re-injecting the base class dependencies for all baseClass child service ex: (NodeHandler and ParagraphHandler) so I have use the create() factory method but this doesn't work:
class ContentEntityHandlerBase extends ControllerBase {
 public function __construct(EntityTypeManager $entityTypeManager, RequestStack $requestStack, PermissionsService $permissionsService, LoggerChannelFactoryInterface $loggerChannelFactory) {
    $this->entityTypeManager = $entityTypeManager;
    $this->request = $requestStack->getCurrentRequest();
    $this->permissionsService = $permissionsService;
    $this->loggerChannelFactory = $loggerChannelFactory;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('entity_type.manager'),
      $container->get('request_stack'),
      $container->get('sacd_user.permissions'),
      $container->get('logger.factory')
    );
  }
}

Question ?
is there any way to ineject the Base Class service , when defining a child class service (NodeHnadler , ParagraphHandler) wihout using the arguments: part in the service definiton ?


texts: How can I turn off the caching for a Paragraph type?

texts:
I'm rendering an array whose URL is dependent on a $_GET variable.
Where the variable is present and valid, I want to serve an iframe with the _GET variable as part of the URL. At the moment the cache is capturing the variable and preventing different value being passed to the page.
In my module I have this:
function MY_MODULE_preprocess_paragraph__iframe(&$variables) {
    $query = @$_GET['e'];
    /*...*/
}

But the value $query is staying the same until the caches are cleared.
Is there a better way of capturing the $_GET variable, or a way of preventing the value from being cached?


texts: Add an image field from buildForm() with preview

texts:
I created a custom form, and I would like add an image field.

I can do that via this code.

$form['main']['image'] = array(
  '#type' => 'managed_file',
  '#title' => t('image'),
  '#default_value' => array(10),
);

I can upload and remove the image from my form. However, when I upload an image, I haven't this preview.
I mean, when I create a content via the Drupal UI. I can add a pre-configured "image" field. When I upload an image via this "image" field, I have a preview of the image.

And here, when I create the field element programmatically, I haven't a preview of the image when I upload it.
What code should I use to get the preview of the image when I upload it via my image field?


texts: I want to create a node field that is only editable upon node creation. Once the node has been created, the field of that node will no longer be editable.


texts:
I try to render the last comment  from a list of comments.

I try {{ comments|last }} ---> no result.

Then {{ comments|reverse }} ---> this render them

Then {{ comments|reverse|first }} ---> no result

The above part is  solved.See anser 1. Pls if annyone have a solution for rendering the last comment in views.

I like to achieve the same in a view. There is a relation filter that output the last comment. But I think I do something wrong.


texts: How do I play Vimeo videos using video embed?

texts:
The drupalgap video embed field plays youtube videos https://github.com/signalpoint/video_embed_field/blob/7.x-1.x/video_embed_field.js:

$.each(items, function(delta, item) {
    var src = item.video_url.replace('watch?v=', 'embed/'); //structure of youtube
    var width = drupalgap_max_width();
    var height = width * .75;
    var attrs = {
      width: width,
      height: height,
      src: src,
      frameborder: '0',
      allowfullscreen: null
    };
    content[delta] = {
      markup: ''
    };
});

How can I play vimeo videos given the video_url structure below?

[{"video_url":"https://vimeo.com/157728217","thumbnail_path":"public://video_embed_field_thumbnails/vimeo/157728217.jpg","video_data":"a:21:{s:4:\"type\";s:5:\"video\";s:7:\"version\";s:3:\"1.0\";s:13:\"provider_name\";s:5:\"Vimeo\";s:12:\"provider_url\";s:18:\"https://vimeo.com/\";s:5:\"title\";s:19:\"costs and revenues1\";s:11:\"author_name\";s:3:\"max\";s:10:\"author_url\";s:29:\"http://vimeo.com/user47459015\";s:7:\"is_plus\";s:1:\"0\";s:4:\"html\";s:191:\"\";s:5:\"width\";i:1280;s:6:\"height\";i:720;s:8:\"duration\";i:492;s:11:\"description\";s:0:\"\";s:13:\"thumbnail_url\";s:46:\"http://i.vimeocdn.com/video/559067454_1280.jpg\";s:15:\"thumbnail_width\";i:1280;s:16:\"thumbnail_height\";i:720;s:30:\"thumbnail_url_with_play_button\";s:139:\"http://i.vimeocdn.com/filter/overlay?src=http://i.vimeocdn.com/video/559067454_1280.jpg&src=http://f.vimeocdn.com/p/images/crawler_play.png\";s:11:\"upload_date\";s:19:\"2016-03-04 09:37:12\";s:8:\"video_id\";i:157728217;s:3:\"uri\";s:17:\"/videos/157728217\";s:7:\"handler\";s:5:\"vimeo\";}","embed_code":null,"description":"desc of video JS client"}]

 [{"video_url":"https://www.youtube.com/watch?v=Q86V-UHaw6Y","thumbnail_path":"public://video_embed_field_thumbnails/youtube/Q86V-UHaw6Y.jpg","video_data":"a:1:{s:7:\"handler\";s:7:\"youtube\";}","embed_code":null,"description":""}]2016-05-27 08:42:32.365 Name of App[1120:18676] [{"video_url":"https://www.youtube.com/watch?v=Q86V-UHaw6Y","thumbnail_path":"public://video_embed_field_thumbnails/youtube/Q86V-UHaw6Y.jpg","video_data":"a:1 {s:7:\"handler\";s:7:\"youtube\";}","embed_code":null,"description":""}]2016-05-27 08:42:32.366 Name of App[1120:18676]

UPDATE:

The line below adds "embed" within the vimeo link. Unfortunately, the video does not render in DrupalGap.

var src = item.video_url.slice(0, 17) + '/embed/' + item.video_url.slice(-9);

UPDATE 2:

There is some info how to embed vimeo videos.

https://developer.vimeo.com/apis/oembed

I noticed that the src parameter is called "url". I changed this in the attributes and passed different video links (e.g. https://player.vimeo.com/video/157728217) as url, but nothing worked.

Here is the stringified content variable from the DG video embed field:

2016-06-01 08:52:13.752 Name of App[1642:30309] content:{"0":{"markup":""}}


texts:
i am using drupal 7 . and i am trying to upload image progrmatically .. here is my code

$image = file_get_contents('http://drupal.org/files/issues/druplicon_2.png'); // string
$file = file_save_data($image, 'public://druplicon.png',FILE_EXISTS_REPLACE);
print_r($file); exit

and here is my output

stdClass Object
(
    [fid] => 4
    [uri] => public://druplicon.png
    [filename] => druplicon.png
    [filemime] => image/png
    [uid] => 1
    [status] => 1
    [timestamp] => 1378142542
    [filesize] => 0
)

now here filesize is 0 . as file doesnot contain any data.  i am working on local m/c.  here is no issue of permission.
Does anybody tell me how to solve this

Thanks


texts: Updating Views Module Not Working 7.x-3.13 --> 7.x-3.15

texts:
Drupal has been telling me to update my views module from 7.x-3.13 to 7.x-3.15.

Everything seems to work fine. However, when I return to the admin pages, I receive "No update information available. Run cron or check manually." I proceed to run cron and Drupal simply tells me that I need to update the module again.

I've manually updated to the newest version (7.x-3.15) and even to the dev version (7.x-3.x-dev). In both cases, Drupal continued to tell me I needed to update the module.

Any ideas what's going on?


texts: adding rel attribute to image link in a node

texts:
I have a few images in a node that can be opened in a fancybox lightbox. I would like to link those images together to create a gallery. To do so I need to add a rel attribute to my image link. How can I do this?

I tried editing the field.tpl.php template, but without any luck.

Help would really be appreciated.


texts: Custom tokens and/or text filters for consistent link look?

texts:
I have a site with a range of products. In order to ensure an easy input for the content editor and a consistent look throughout the site, I thought I'd make an input filter that would replace any occurrence of

[prod:product-name]

with a link to the node presenting the product (product-name == product code here). On output, this would be changed into, say:

Real [product-name]

However, I have doubts as per the efficiency side of such a solution, namely because - product-name would have to be a value of a field on the content type. Thus, for each replacement, Drupal would have to comb through all nodes, load each of them and perform a test to find a match. Quite database-intensive as I imagine.

So another thought was to provide a custom token. But would that change anything? Would it work within text fields, or would I have to use hook_node_view_alter to invoke the replacements?

What would be your strategy to provide this kind of tokens?


texts: Drupal override search form: how to debug hook failure?

texts:
In the past I've always been able to override the theme form using the method mentioned http://drupal.org/node/154137.

function YOURTHEME_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'search_block_form') {
        $form['search_block_form']['#title'] = t('Search');
    }
}

However, this doesn't appear to be recognised in the template.php of my latest theme. It hasn't been an issue in the past - what is the best way to debug why the hook doesn't appear to be activated?


texts: Download count of file in table of files

texts:
So I wanted to add date alongside the size of the file in filefield table of files so I added this snippet to templates.php

function mytheme_file_formatter_table($variables) {
  $header = array(t('Attachment'), t('Size'),t('Upload Date and Time'));
  $rows = array();
  foreach ($variables['items'] as $delta => $item) {
    if ($item['timestamp'] == 0) {
      $item['timestamp'] = 1234567890;
    }
    $rows[] = array(
      theme('file_link', array('file' => (object) $item)),
      format_size($item['filesize']),
      format_date($item['timestamp'],'custom','Y/m/d - g:i'),
    );
  }
  asort($rows);
  return empty($rows) ? '' : theme('table', array('header' => $header, 'rows' => $rows));
}

It works just fine but I also need to show the download count of the file, and I have no clue on how to do this. Thanks


texts:
For my project, I have a custom module, a features module and a custom theme. I want to keep all in a single Git-Repository.

The problem is: modules need to be in sites/all/modules, themes in sites/all/themes.

I know, I could bundle both in a profile. But I am already using a special profile. And as far as I know, there is no way to inherit a profile.

And yes, I know I could use symlinks. But they tend to create issues with path structures.

So is there another, maybe a "Drupal" way to bundle modules and themes in one directory?


texts: How to prevent users from being registered when their username contains a space?

texts:
I'm trying to prevent a user from being saved with Rules when he/she tries to use a username that contains a whitespace. I've already read How can I disallow spaces in usernames? and used the User restrictions module to achieve this, but I'd like to use Rules to do some other stuff (e.g. checking that the username doesn't have more than 20 characters).

So, what I'd like to do is showing an error message on the page and keep all the filled in information in the form without saving it. Is it possible to do this?

This is the Rule I'm currently using:

Event: Before saving a user account.
Conditions: NOT Execute custom PHP code. <?php preg_match('/\s/',$account->name) == 1; ?>
Actions: Show a message on the site.


texts: Two levels of options in add to cart form

texts:
I am working with a project of sofas. Clients can choose the size and the fabric. In each fabric there are several colours.
What I need is that the client chooses the fabric and then the form shows the colors of the selected fabric so the cliente can choose too.
Is that posible?


texts: Batch API and curl or file_get_contents() issue in Drupal 7?

texts:
Has anyone ever experienced issues with curl or file_get_contents() when using the batch API?
I'm trying to import nodes from a remote data source via batch API; I used file_get_contents() during one phase of development, but then it stopped working.

I can assure that neither curl or file_get_contents() is working, and that they work outside of batch API. Could it be related to how batch API makes its calls via AJAX? The really odd part is that it was working while I was trying to figure out how to get images into a field.

I know it's a really obscure question but I was hoping that someone else had experienced this before.


texts: Rule to autopopulate node reference field and redirect after content creation

texts:
I'm trying to make a rule so that when a node of content type X is created, a node of content type Y is also created and is automatically populated with a nodereference field to the nid of content type X that was created. Then the user should be redirected to the edit form of the node of content type Y that they just created.

My rules configuration looks like this right now:

Event: After saving new content

Condition: Content is of type X

Actions:

Create a new entity of content type Y
Set a data value: set the node reference field on new node of content type Y nid of new node of content type X
Page redirect: URL: [entity-created:edit-url]

Everything works as expected except the redirect (which I thought would be the easiest part). Both nodes get created and the node reference field is set correctly. But I get a page not found error with the following messages:

  Notice: Undefined property: stdClass::$nid in node_tokens() (line 112
  of /web/xxxxxx/www/modules/node/node.tokens.inc).

  "content type X" "title of new content of type x" was successfully created

  The requested page "/node//edit" could not be found.

I've also tried node/[entity-created:nid]/edit for the page redirect. Same exact problem. I have no idea why it's not plugging in the nid of the new node of content type Y in between node/*/edit.


texts: how to access an aggregated views field?

texts:
I have a view with one field called production hours.

I have several rows in this view but have used the sum aggregation setting.

The only value I get is the total of all the values in the field production hour.

Im now trying to access that total value via php.

So I add header, if I select text area I can use the field using tokens, but if I try and insert that token into php code nothing happens.

All I want to do is get the sum of field production hours and output the total but convert it to days instead of hours.

Thanks for any help


texts:
I've looked through all similar issues reported but none of them solves my problem. I always install drush with composer and installing 6.4.0 is working just fine, but when I install dev-master then I get the error

Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see README.md

Composer is at the latest version.

When I go to ~/.composer I never get a ./vendor/ directory as suggested by answers to other questions.

My environment is Ubuntu 14.04 and I'm using PHP 5.5 - any idea what else could be wrong?


texts: User's to edit roles and permissions for any user less privileged

texts:
Our website needs to allow staff (staff role) and editors (editor role) to be able to edit the accounts and roles of authenticated users and all other users with roles less privileged than their own role, without being able to edit the accounts and privileges of users of a higher privilege level.

Here is an example of hierarchy of our user roles:

admin (super-user, developer only)
editor (organization's admin and non-development high-level user, many privs)
staff (organization's staff users, some special privs)
member (user with special access privs)
authenticated user (regular user)

Currently, if I allow users to edit user accounts and assign roles, they are able to not only assign themselves to top-level administrator account, but also de-assign the administrators and change their passwords, etc.

This post asks a similar/related question which is slightly different but also does not have an answer. I assumed the Drupal Core had a built-in functionality that allows for this by considering the order of roles, so I am wondering if I did something wrong.


texts: Different view page based on taxonomy depth?

texts:
I'm wondering if there is a way to show a different view (or view part) based on the current depth of the term level?

Example I have a bunch of categories and subcategories. For the categories I want to show a page that is just the name of the category, once I go in to the next level (subcategories) I want the name and the image and description or whatever you have.

Is there anyway to do this? I have a page view that is mapped to category/% so we would get category/% ** CATEGORY */% * SUB CATEGORY **


texts: Getting an element of a CCK field to use and modify in hook_form after_build

texts:
I have a partially working solution for using hook_form after_build on a CCK field. The field has various elements (it's created with a custom module but I don't want to modify that so I've created a small overrides module to do some trivial form alter stuff.) I've been at this a good part of the day and finally had some luck adding some simple text to the field so I am know I'm getting close.

In the main module, the CCK field has various elements. Once such element is:

$element['week_night'] = array(
    '#type'          => 'textfield',
    '#title'         => t('Week Night'),
    '#default_value' => isset( $element['#value']['week_night'] ) ? $element['#value']['week_night'] : NULL,
    '#attributes'    => array( 'class' => 'rate-widget-rate-field' )
  );

I am targeting the field itself in my overrides module as such:

<?php
function rates_override_form_alter(&$form, $form_state, $form_id) {
  //drupal_set_message($form_id);
  //dsm($form);
  if($form_id == 'ldisilink_property_node_form'){
    $form['#after_build'][] = '_rates_override_after_build';
  }
}

function _rates_override_after_build($form, &$form_state) {
  // This works so we know we are good to this point:
  $form['field_rates']['#prefix'] = 'do stuff';
  // Now we want to change the label on week_night but it's not working.
   $week_night = $element['week_night'];
   $form['field_rates'][$week_night]['#title'] = 'My new label title';
  return $form;
}

What I am trying to do is alter the label for the element week_night.  Using dsm($form) I've tried various combinations of:

   $week_night = $element['week_night'];
   $form['field_rates'][$week_night]['#title'] = 'My new label title';

... but it's not working yet, but I think I'm close.


texts:
Hello i asked this on stackoverflow and was refered to here. I hope you dont mind me copying and pasting it. thanks

Hello i don't really know where to ask this on drupal so i hope you all don't mind me asking it here on your fine site. Everything ive asked before has been resolved by your good selves so i thought i'd give you a try on this. Thanks.

I was hoping to just hide my breadcrumb when viewing the taxonomy term view created by Views. I do use Custom Breadcrumbs module but from what ive read that just edits the output and not the breadcrumb appearing or not. Here's an example of my view-
http://onlinebanter.com/general-chat

As you can see it's pushing the centre of my page down so as it isnt lined up with the sidebar. I dont really need it in these views. All help appreciate from your vast combined knowledgebase.

Thanks

Reg


texts:
I'm building a form that is being built by pulling information from an api and loops through it. The issue I'm having is I cant seem to pass the information to the submit page.

Here is a snippit of my code, let me know if you need more:

// Loop through resources and make fieldset for each.
for($i = 0; $i < count($resources['subscriptionResources']); $i++){
  $resource = $resources['subscriptionResources'][$i];

...

  $form['resources'][$resource['resourceID']]['add-qty'] = array(
    '#type' => 'radio',
    '#title' => t('Upgrade'),
    '#return_value' => 1,
    '#default_value' => 0,
    '#disabled' => FALSE,
    '#prefix' => "

",
    '#suffix' => t("	"),
    '#attributes' => array(
      'name' => 'upgrade',
    ),
  );

...
So the outcome is, I get three different forms each with a radio button. They are all connected due to the 'name' attribute, so only one can be selected at any given time.

But when submitting, the default_value stays 0 and return_value stays 1 for all three. I'd like some way to display the information of the 'checked' radio to the submit page. Currently I'm seeing nothing (if default_value is 0) or everything is default_value = 1.

Again, let me know if you need more information.

Thanks!


texts:
I'm trying to use the RESTful service for creating a node with Javascript using the script below, but I only receive a 400 (Bad Request) error. I have enabled all the formats and set permissions for authenticated users.

The reports shows the following error:

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: No route found for "GET /entity/node": Method Not Allowed (Allow: POST) in Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest() (line 163 of /Applications/MAMP/htdocs/comedinewithme/vendor/symfony/http-kernel/EventListener/RouterListener.php).

Do I need to set an authorization in the header? Isn't this what the csrf token is for though? And how should this be formatted? I'm completely lost!

function getCsrfToken(callback) {
  jQuery
    .get(Drupal.url('rest/session/token'))
    .done(function (data) {
      var csrfToken = data;
      callback(csrfToken);
    });
}

function postNode(csrfToken, node) {
  jQuery.ajax({
    url: 'http://example.com/entity/node?_format=hal_json',
    method: 'POST',
    headers: {
      'Content-Type': 'application/hal+json',
      'X-CSRF-Token': csrfToken
    },
    data: JSON.stringify(node),
    success: function (node) {
      console.log(node);
    }
  });
}

var newNode = {
  _links: {
    type: {
      href: 'http://example.com/rest/type/node/article'
    }
  },
  type: {
    target_id: 'article'
  },
  title: {
    value: 'Example node title'
  }
};

getCsrfToken(function (csrfToken) {
  postNode(csrfToken, newNode);
});


texts:
I have a hook_menu as follows :

/**
 * Implementation of hook_menu().
 */
function conditional_fields_menu() {
  $items = array();

  foreach (node_get_types() as $type) {
    $content_type = content_types($type->type);

    $items['admin/content/node-type/' . $content_type['url_str'] . '/conditional'] = array(
      'title' => 'Conditional fields',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('_conditional_fields_admin', $content_type['type']),
      'access arguments' => array('administer conditional fields'),
      'type' => MENU_LOCAL_TASK,
      'weight' => 5
      );
  }

  return $items;
}

How can i convert this to conditional_fields.routing.yml in d8 ?

what i tried :

Drupal 8 conditional_fields.routing.yml snippet

conditional_fields.admin:
  path: 'admin/content/node-type/{this is unknown}/conditional'
  defaults:
    _form: '_conditional_fields_admin'
    _title: 'Conditional fields'
  requirements:
    _permission: 'administer conditional fields'


texts: Multiple field value amount based on role

texts:
I am looking to add a single image field to a content type, and allow a different amount of images based on a users role.

Business Free User can upload 1 image (as profile pic)
Business Silver User can upload 3 images
Business Gold Users can upload 9 images

I've been searching high and low for a module to swoop in and save the day, but im not having much luck. Has anyone found something that can do this for me?

I'm using the field permissions modules to hide fields based on role. The fall back here would be to have 3 images fields, one for logo, one for 2 more images (to make 3) and one for 6 more images (to make 9) but I'm building a pretty big site here and would like to reduce the amount of fields where I can.


texts: how to override output in preprocess function

texts:
I am trying to override the path of events created by the fullcalendar module. I am having some issues, and came up with a very general Drupal question:

In a preprocess function, I can modify the $variables array as needed. However, this doesn't necessarily effect the rendered output. Besides for creating a template override (which I don't think I can do in this situation, as fullcalendar does not define a tpl file), can it be modified in a preprocess function?

Here is the code I am trying to use:

function tma_corp_preprocess_fullcalendar(&$variables) {
  foreach($variables['element']['content']['events'] as $event) {

    $event['#event'][0]['#path'] = 'hello2';
    dpm($event);
  }
  dpm($variables);
  //when I look at variables, it has set the path to 'hello2', but the link for each event remains as it was before this change
}


texts:
I want to use an API that gives me the path between two points. I know the value of latitude and longitude.

How do I get path, latitude and longitude of points of in between path?


texts:
I want to give content editors the ability to add a Feed of some sort (Maybe Twitter, Tumblr, etc) to a particular node.  I'd like to use Paragraphs because I want them to be able to drop this Feed in between various other pieces of content.

The Paragraph Bundle would just have one field to accept the resource URL.  I would do all the necessary processing behind the scenes and would send the formatted content back to the node via a twig template.

I've got a version working using a block instead of a paragraph bundle, and I'd like to use the same custom module to allow for a paragraph, but I'm unsure in Drupal 8 how best to structure this.

The best I can come up with, is a preprocess function of some sort- preprocess_node, or preprocess_paragraph (which I think exist in D8) that would kick off the whole thing, but I was wondering if there was some kind of base Entity class that has a method I can overwrite or something. (Similar to how the BlockBase class has the "build" method.)


texts: Drush Make doesn't do anything (Windows)

texts:
I've been trying to use drush make on a very simple test project (an empty folder containing just the make file) to see how it works, but nothing happens. In the shell, there's a one second delay after I press ENTER, and then the empty prompt comes back. There's no error or confirmation message, and nothing changes in the test folder (not even en empty folder is created).

The command I use is simply: drush make test.make.yml test
(Of cource I'm already in the correct folder when I type this command.)

If I omit the last parameter (e.g. drush make test.make.yml), then drush waits one second, then asks if I want to "make new site in the current directory ? (y/n)". But if I press Y, still nothing.

drush make -h shows the expected help information.

I'm using drush v.6 on a Windows 8.1 xampp local setup. The usual drush commands (e.g. drush dl views, etc) work fine, though. (As far as I can tell anyway: I'm not an advanced user.)

I tried with the example file provided in the drush/make documentation, and I also tried to simplify the content of my make file to the max:

api: 2
  core: 7.x
  projects:
    drupal:
      version: 7.36

Still nothing.

Is there something I'm missing?


texts: Drush command to download AND enable a module

texts:
To download and install a module, I run:

drush dl module_name
drush en module_name -y

I put that in a Bash script function, and just call "drin module_name" to simplify.

function drin(){
  drush dl $1
  drush en $1 -y
}

Is there a one-line command in Drush to download and enable a module?


texts: How can I manage a users collection of products?

texts:
I am pretty new to Drupal, and I am tasked with creating a Drupal 7 site that has a lot of products; I need to enable users to maintain a list of the products that they own/have.

Basically I need the ability to take a list of products and allow a user to check off the ones they have and the ability to save this data associated with the user. Is there a module that I should take a look at, or can someone point me in the right direction?


texts: How can I add a variables to my page.html.twig file?

texts:
I'm trying to add a variable that i can use in page.html.twig that will add a class to the header region if a field in the node exists.

In template_preprocess_page() i've tried doing the following and have not been able to add a variable:

function theme_preprocess_page(&$variables){
  $variables['header_attributes']['class'] = [];
  $variables['header_attributes']['class'] = array_merge($variables['header_attributes']['class'], ['myClassHere']);
}

I based this off the example for menu preprocess but no new class was added to the  ta


texts: Select data from database when submitting a form

texts:
I'm trying to learn how to make select queries with Drupal, so I made a form, and when I submit the form I try to query the database and get some results, but instead I'm redirected to an error page, here's how I select nodes from DB :

function my_module_form_submit($form, &$form_state)
{
    $query = db_select('node', 'n')->extend('PagerDefault');
    $query->condition('type', 'myContentType');
    $result = $query->execute();
}


texts:
I have a strange problem - on my local installation none of the forms are getting submitted.

I can access forms and when I click submit, page just reloads and nothing happens. That applies for all configuration forms, as well as node save/edit forms. Strangely, I can log in.

I don't really know where to look. Any suggestions?


texts: How can I remove the space between fields show in a view that are output with a custom template?

texts:
I have a view that has two fields, A and B.  Both of these fields are modified using a views-view-field--myfield.tpl.php file.

In my output, I want the fields to be displayed as:

  AB (no space in between the values)

However, no matter what I do, it seems that Views puts a space between the two fields.  I am using an Unformatted list and under Settings I have unchecked Add views row classes as well as Add striping (odd/even) rows classes.  This has no effect on the spacing.

Under Settings for Fields, I have unchecked Provide default field wrapper elements.  Again, the spacing remains.

I tried rewriting the results of the fields by inputting [field_fieldA][field_fieldB] under Rewrite the output of this field, but, while this output is shown in the preview in the Views admin interface, it is overwritten by the views-view-field--myfield.tpl.php file for the relevant field.

How can I output two values, both of which are output via template files, without a space between them?


texts: Is it safe to comment out dependencies in a feature modules .info file?

texts:
I used features to migrate config and content (with uuid features) from a dev site to a live site.

Now its there, I dont want the features anymore. Or perhaps partly, but I'd rather rebuild the features on the live site from scratch.

However, if I disable a dependency in the feature, that thing - content, content type, menu, whatever - actually gets removed from the system. As intended. But I dont want that.

Is it safe to just comment out all dependencies from the feature modules .info file ?


texts: Set default selected radio button on webform

texts:
I have a standard contact page created using webform, which has a set of radio buttons. How can I make one of the radio buttons selected by default?

This quesion is similar, but it relies on the refering link, which I would rather not.
Set default radio button on webform


texts: Recurring payments & Paypal Recurring profiles

texts:
I have a couple questions.

First - I have another site - Magento-based - that I'm currently using to handle a membership site. I'm trying to convert it to Drupal 7, and I've got it all configured and ready to go. However, when I get a new subscriber it's coming through as a PURCHASE and not a subscription. I've got each product set up with a recurring fee under "features" and it's set to be monthly. Here is the text from the feature:

"Recurring fee - When [SKU] of this product is purchased, add a fee for $15.00 charged first after 1 months and every 1 months after that unlimited times."

I used the basic set up steps in this video:

http://www.youtube.com/watch?v=Vd6Y4f4TnnU

I'm not sure what's going to happen here. I'm not seeing a recurring profile in Paypal like I did with Magento. Can someone help me understand the progression and workflow here?

BTW - I'm using D7 and Ubercart 7.x-3.1

Second - I need to know what is the mechanism that makes the recurrence charge fire. I've been testing, and the monthly renewal/recharge date has come and gone, but there was no charge made to the account. I know that the payment gateway works, because I've tested that a few times, it's just that the recurring charges are not happening and I don't even know where to begin to look, because so far as I can tell, as noted above, things are set up to charge monthly and recharge monthly.

My setup is virtually identical to what's described in the video.

Any ideas?

Thanks in advance for the help.


texts: How can I get the email field value from a webform and use the rules module to send mail on submit event?

texts:
How can I get the value of the email field value in a webform and apply it in

rule > action > send email > to address

I have tried using a token but could not get the value.


texts: How to avoid duplicate entries when changing the text inside t() function in Drupal 7

texts: I am using t() function in modules and templates. But when I need to correct the original English text, I find that I have two rows in the database (I manage it through i18n translating interface manager). One is the original text and the other the corrected one. I delete the old one and translate the new one. Is this the standard procedure? Could there be a better way of translating, for example with a module based on numerical ID or something to avoid duplicate or obsolete strings?


texts: Drupal 7 Themeing - template.tpl.php vs template.php - variables

texts:
I am interested in learning what disadvantage, if any, there are in calling variable fields directly within the template.tpl.php files.

Is it ok to place a field variable within the template.tpl.php file if doing it as simply as:

<?php
//--------------------------------
// COLOR
if(!empty($content['product:title']['#product']->field_taxonomy_color['und'][0]['taxonomy_term']->name)): ?>

    <?php
        $max_length = count($content['product:title']['#product']->field_taxonomy_color['und'])-1;
        for($x = 0; $x <= $max_length; $x++){
            echo '
'. $content['product:title']['#product']->field_taxonomy_color['und'][$x]['taxonomy_term']->name .'
';
        }
    ?>

<?php endif; ?>

My understanding is that this code should be placed a preprocess function and called into the tpl.php file such as:

TEMPLATE.PHP

function theme_preprocess_node(&$variables) { $variables['color'] = ... }

TEMPLATE.TPL.PHP

<?php echo $color; ?>

If this is the case, how would i return all values of the loop from template.php into template.tpl.php?

---------EDIT---------
Should I create complex logic within its own field--template.tpl.php file, set the field to a variable in template.php and call upon the variable inside the node--template.tpl.php?  Would there be a problem with creating over a hundred field--template.tpl.php files?


texts: Drush error on core update "corrupt (wrong md5 checksum)"

texts:
I'm getting this error when I try to update core with Drush:

File drupal-7.41.tar.gz is corrupt (wrong md5 checksum).  [error]
Updating project drupal failed. Attempting to roll back to previously
installed version.   [error]

I've tried to refresh and clear all the caches I can think of (drush rf, drush cc all, drush cc drush) but the error continues.

Any ideas?


texts: Merge two fields using Display suite, like views inline fields

texts: Is there a way to merge two or more fields using Display suite, like Views inline fields? What I mean is - if I have the fields "Author", "Publication date" and "Article series", then I would like to display them as "Author1 | 01-May-2012 | Learning series" etc.


texts: How can I print messages in a Panel layout template?

texts:
Printing the drupal messages in page.tpl.php is easy:

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

How can I go about doing a similar thing in my Panel layouts?

Notes:

I realise there is 'status messages' pane you can use - I wish to avoid this since admin staff will forget to include it on new pages
I definitely wish to do it in the Panel template because there is a section above where the messages should display that is set by the admin staff
I have tried simply putting that code into mylayout.tpl.php, it didn't work

Here's an example of what I am trying to do:

Is there something I can do in a pre-process function to get this to work?

EDIT:

Thanks to @Beebee I rediscovered the template_preprocess_LAYOUT function in my layout's .inc file and added

$variables['messages'] = drupal_get_messages();

now both $variables['messages'] and $messages exist when the template is called but they contain an array of messages rather than the usual rendered output in a string.


texts: Node reference field share between two content types

texts:
I have Two Content types Store and Deals and one Vocabulary named as Outlets. Outlet has many terms. I have added outlets as a term reference field to stores content type, and title field of store content type is added as a node reference field to deals.

1.Store content type
When I am adding a new store I am selecting some outlet terms for it and saving it.

2.Deals Content type
In Deals content type when I am creating a new deal
I am selecting any store in dropdown, which I have added here as a node reference of store content type.
What my concern is now while selecting any store title I want its corresponding outlets to be displayed here, so that if I wish I can uncheck some of them and then save.

Any help would be much appreciated.Please find the screenshot for better understanding.

Top Image is the store content type adding a store carters
Second image is the deals content type I am selecting the store which I have previously added in stores, now while selecting carters the corresponding outlets should get selected


texts: How to call ctools modal window from mycustom.tpl.php?

texts:
I need to show a modal window on click from my mycustom.tpl.php

Here is my code in mycustom.tpl.php

False Positiv1e

In my module file :

$items['modal/%ctools_js'] = array(
    'page callback' => 'modal_callback',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

 return $items;
}

function modal_callback($ajax) {
    ctools_include('ajax');
    ctools_include('modal');
    ctools_modal_add_js();

    $form_state = array(
      'ajax' => TRUE,
      'title' => t('MyModule Modal Form'),
    );

    // Use ctools to generate ajax instructions for the browser to create
    // a form in a modal popup.
    $output = ctools_modal_form_wrapper('modal_form', $form_state);
    // If the form has been submitted, there may be additional instructions
    // such as dismissing the modal popup.
    if (!empty($form_state['ajax_commands'])) {
      $output = $form_state['ajax_commands'];
    }

    // Return the ajax instructions to the browser via ajax_render().
    print ajax_render($output);
    drupal_exit();

}
function modal_form($form, $form_state) {
  $form = array();

  $form['new_link_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Link text'),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

  return $form;
}

But when I am clicking on the button, Modal window Breaks and print $output array as below


texts: Why are some contrib module functions not recognized?

texts:
I can't seem to get the latest twitter module to work with my site.

I have a custom module that does some sanity checks on user-imported twitter accounts and my site keeps failing at this point. After some digging I noticed the twitter module functino twitter_account_load() is not recognized at all.

Devel test code to reproduce:

dpm(module_load_all()); // returns 1
dpm(module_exists('twitter')); // returns 1
dpm(twitter_account_load('@twitter')); // returns white screen of death

Apache error log:

  PHP Fatal error: Call to undefined function twitter_account_load() in /var/www/mysite/httpdocs/sites/all/modules/contrib/devel/devel.module(1285) : eval()'d code on line 4, referer: http://my.site.com/devel/php

Drupal Version 7.26
Twitter Version 7.x-5.8

What I have tried so far:

Cache cleared
Twitter module upgrade to latest 5.8
Cache cleared
Twitter module reinstall
Cache cleared
...

Nothing worked.

Any idea why?


texts: How to make a rule for limiting one product per cart

texts:
Can anyone help me?
I want to know how to make a rule for limiting one product per cart. I found rule for limiting qty only but not order item.

I found this with code Drupal Commerce Shopping cart limit
But I want to do it with rule ...


texts: Apache solr filter based on array values

texts:
Has anyone succeeded in filtering array values using Apache solr? I have nids as an array, programmatically I want to use the array to filter the solr based on the 'entity_id'.

I tried something like

  $solr = apachesolr_get_solr();
  $query = apachesolr_drupal_query("custom", array('q' => ''),'sort_label asc', 'search/site');
  $query->addFilter('entity_id', '[10915 11013]');
  $response = $query->search();

But I don't get the desired results, somewhere the apachesolr_search or apachesolr module seems to be adding quotes to the filter values something like

webapp=/solr path=/select params={sort=sort_label+asc&start=0&q=&json.nl=map&wt=json&fq=entity_id:"[10915+11013]"&rows=10} status=500


texts: Is it possible to prevent a View from executing until the user has chosen filters?

texts:
I have a rather complicated View (created with the Views module) with about a dozen filters on it, all exposed to the user. The View is very heavy on CPU, and I would like to prevent it from running until the user has applied his filter choices.

One suggestion for dealing with this is to make a filter "Required": then the exposed filter will be empty when the View is first run and as a result will force the user to apply filter values explicitly.

The problem is that the filters are almost all dropdown lists, so they get a value applied automatically and don't therefore stop the View from running. Does anyone know some other way to do this?


texts:
How can I automatically attach/create fields to an entity when I enable a module that provides entities?

For example, I want my Entity to have an Image field, and a handful of text, date, and number fields ready to roll.

I see field_create_field and field_create_instance, do I need to define them or can I use whats already defined as fields in Drupal and just give them labels and default values?


texts:
I have created a Module to make blob file available for Download in Drupal 7 .

Below my code for .module file

<?php

function blobfile_block_info() {
  $blocks = array();
  $blocks['blobfile_block'] = array(
    'info' => t('Blob Files Download'),
  );

  return $blocks;
}

function blobfile_block_view($delta) {

      $query = db_select('health_policy_document_upload_dtl', h)->fields('h');
      $result = $query->execute();

      $content ='';
      while($record = $result->fetchAssoc()) {

          $filename = $record['Document_Name'];
          $file     = $record['Document'];
          $type     = $record['Document_Type'];
          $size     = filesize($file);

          header("Content-length: $size");
          header("Content-type: $type");
          header("Content-Disposition: attachment; filename=$filename");

          $content .= "".$filename."";
          $content .= "
";
      }

    return array(
      'subject' => t('Bids'),
      'content' => $content
    );

}

Please guide me where I went wrong.


texts:
I was able to successfully take a back up of D7 site and then restore to target D7 site. When I visit the site, I get an error

  This page isn’t working. ...com is currently unable to handle this
  request. HTTP ERROR 500.

Added the code in settings.php:

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

  Fatal error: Cannot redeclare views_views_plugins() (previously
  declared in
  /home/.../public_html/sites/all/modules/views/includes/plugins.inc:15)
  in
  /home/.../public_html/sites/all/modules/hjhkjhj/views/includes/plugins.inc
  on line 402

How can I fix the error to bring my site back up?


texts: How to programmatically create entity with certain language applied to fields?

texts:
I am programmatically creating some content during profile installation and since Drupal uses "en" langcode during this period I am getting the language from config and it is working fine.

The issue I have is that I am creating a node and I will end up with it being in English. So I have set the "langcode" property of the node during creation which worked as expected. But the fields are not responding to this fact(I have only the body field attached).

So I have tried to key the value(s) by the langcode(Drupal 7 style) but it resulted in the field not being populated in DB at all.

The node entity nor field item list nor field item have methods for setting the langcode so I am unsure how to proceed with this.

Any ideas?

This is my code:

// Create 'terms of service' page
  $tos = entity_create('node', [
    'type' => 'page',
    'title' => t('Terms of service', [], ['langcode' => $langcode]),
    'uid' => 1,
    'status' => 1,
    'langcode' => $langcode, // this is working on node only
    'defaultLangcode' => $langcode, // no change on field
    'activeLangcode' => $langcode, // no change on field
    'body' => [
      $langcode => [ // this is not working
        [
          'value' => '<p>' . t('This is a placeholder. Please edit this page and use your own text.', [], ['langcode' => $langcode]) . '</p>',
          'summary' => '',
          'format' => FULL_HTML_FORMAT
        ]
      ]
    ]
  ]);
  $tos->save();

I have found setLangcode() method on the FieldItemList but that didn't work as well.

I have tried to save the node without body, then set the body and save the node again, but the field is in English again(and the node in installed language). Is it possible that this is kind of a (edge case)bug that relates to language manager?

I have checked the entity constructor and this is also not working:

'body' => [
      $langcode => [
        [
          'value' => [
            'value' => 'some text',
            'summary' => '',
            'format' => FULL_HTML_FORMAT
          ]
        ]
      ]
    ]


texts: Email field does not show up when I view node, only when I edit

texts: I have an email field in an entity. The text field is there when I edit the entity but it does not display when I view the entity. How do I get it to display when viewing?


texts: 404 when using named placeholders for variable parts of Panels path

texts:
I'm creating a landing page using a custom content type in Drupal 7, I've set up the views and had everything working correctly, but then I decided to change something at the last minute and add named placeholders to my URL. For some reason I'm receiving a 404 when calling the specific URL.  Do I have to do anything specific to my contextual filters in views or in Contexts, so that the URL actually works?

I have this set for my landing page /publications/magazine/2014/SPRING (/Publications/Magazine/%field_year/%mag_issue)
I have a custom date format set to year only for the date field and have a taxonomy vocabulary called seasons (fall, winter, spring summer)

For my contextual filter, I have Content: Has taxonomy term ID using Raw Value with the specific vocabulary set, one of my views requires this. That's really the only unique thing here. I'm working locally at the moment, so i dont have a url, but any suggestions would be helpful, spending 3 hours so far trying to figure this out.


texts: How do deploy existing website on digital ocean?

texts: I do not find appropriate instruction on how do deploy local drupal 8 website on remote server hosted on digital ocean. I found only on how to install new website but not putting existing. Does anybody deploy such a website?


texts: Getting the 'The website encountered an unexpected error. Please try again later.' error during an update

texts:
I recently updated my Drupal 8 installation, and for some crazy reason my site now displays a white screen and this line of text when I go to it:

The website encountered an unexpected error. Please try again later.

I have no idea why. It's driving me absolutely crazy. When I check my site's error log, I see the following error. Anyone have any clue how to fix this? I've been trying to find answers to an entire day now:
> Additional uncaught exception thrown while handling exception.
> Original
> Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
> The service "commerce_cart.cart_subscriber" has a dependency on a
> non-existent service "messenger". in
> Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences()
> (line 58 of
> /home/oowxas5qe9i2/public_html/shop/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php).
>
>     Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(Array)
> (Line: 42)
> Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processDefinition(Object)
> (Line: 36)
> Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->process(Object)
> (Line: 102)
> Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object)
> (Line: 587)
> Symfony\Component\DependencyInjection\ContainerBuilder->compile()
> (Line: 1284) Drupal\Core\DrupalKernel->compileContainer() (Line: 873)
> Drupal\Core\DrupalKernel->initializeContainer() (Line: 18)
> Drupal\Core\Installer\InstallerKernel->initializeContainer() (Line:
> 465) Drupal\Core\DrupalKernel->boot() (Line: 414)
> install_begin_request(Object, Array) (Line: 114)
> install_drupal(Object) (Line: 44) Additional
> Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
> You have requested a non-existent service "theme.manager". in
> Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition()
> (line 817 of
> /home/oowxas5qe9i2/public_html/shop/vendor/symfony/dependency-injection/ContainerBuilder.php).
>
>     Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition('theme.manager')
> (Line: 455)
> Symfony\Component\DependencyInjection\ContainerBuilder->get('theme.manager')
> (Line: 674) Drupal::theme() (Line: 22)
>     _drupal_maintenance_theme() (Line: 710) drupal_maintenance_theme() (Line: 967) install_display_output(Array, Array, Array) (Line: 264)
>     _drupal_log_error(Array, 1) (Line: 570)
>     _drupal_exception_handler(Object)


texts: Benefit of running custom query over views

texts: I have a content type and some nodes. I am displaying latest 10 nodes from these content type through views block display. Is there any benefit if i add a custom SQL query to display latest 10 items. I will use the same SQL query that i got from view.


texts: How can I add static text into a Views exposed filter block?

texts:
I have a views exposed filter block that I'm using as a search form. I'm wondering how I can display static text within the block. Here's what my Block looks like:

Essentially I want to display the title (Find A Venue) to the left of the fields, and then display the word "or" between the two. If somebody knows how to move the block title to the left of the filter fields instead of above, I suppose that that would serve my purpose well enough as well. Although, it would be nice to know how to display the static text regardless.


texts:
Currently my D6 site relies heavily on Memcache and apc to deal  with high load of a busy social site. The memcache is on a single webserver and  the database on another server.

So I am wondering, apart form being persistent (hence no need for a warm-up), whether Redis makes authcache redundant and hence avoids security issues?


texts: How to do a hard redirect when in Ajaxified form?

texts:
I have an Ajax multistep form and I want to redirect user to specific route when some conditions are met (specifically if the user is inactive for more than N seconds and the form is submitted after this limit).
I wanted to do the redirection in the validation handler but no luck. So I tried with a submit handler but still no luck. I'm quite buffled.
I tried to return a redirect response, I tried to set redirect response on the form state, I tried to set redirect on the form state, I have tried to disable form state rebuild, I have tried to copy the goto action logic and use an event dispatcher, I tried to unset the \Drupal\Core\Form\FormBuilderInterface::AJAX_FORM_REQUEST from request but still no luck.
I could maybe return the redirect in an Ajax callback as redirect command but I want to make this work with disabled JS so invoking window.location would not be enough.


texts:
I am trying to accomplish the following in a views accordion style.

  Here is what I am putting in the rewrite field

[field_event_date_1]

[title]

[field_time_slot_1]

  Here is what gets rendered

        Tuesday, November 3, 2015
Example title description goes here
1A - 10:00 - 11:30 AM

HTML5 spec allows div styling in anchors. Can anyone point me in the right direction?


texts:
Is there any way of getting a node by its post type? I've tried with the following code, but it doesn't really work.

$query = \Drupal::entityQuery('front_page_slider');

As far as I read on tutorials, it should work when the content type is front_page_slider. Instead, it returns an error.

  The "front_page_slider" entity type does not exist.


texts: content access does not work after changing domain

texts:
after designing and developing a website I changed its domain. Now any of the permissions are not working. every thing is OK appearently but the functionality is not OK at all.(I mean all the checkboxes and settings are correct but anonymous users have access to all contents!!)

I am using content access module and check the  Enable per content node access control settings  option in content type setting.


texts: How to pass argument in ctools_modal_form_wrapper?

texts:
A very strange issue come across while using ctools_modal_form_wrapper and ctools-use-modal. I have written a menu item and passed two arguments in it.

$items['a/b/c/d/e/%/edit/%ctools_js'] = array(
    'page callback' => 'generate_tpls_callback',
    'page arguments' => array(5,7),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'tpl_popup_create.inc'
  );

Now in this callback I am getting both 5th and 7th argument. But when I pass it to $form_state, form is unable to get this 5th argument. I will explain you more with the help of code.

function generate_tpls_callback($cid, $ajax) {
    if ($ajax) {
        ctools_include('ajax');
        ctools_include('modal');

        $form_state = array(
            'ajax' => TRUE,
            'title' => t('Display box to change title'),
            'cid' => $cid,
        );
        $output = ctools_modal_form_wrapper('myform', $form_state);
        if (!empty($form_state['ajax_commands'])) {
            $output = $form_state['ajax_commands'];
        }
        print ajax_render($output);
        drupal_exit();
    } else {
        print_r("helloooo");
//
    }

}

So, the issue is, when I click a link say "generate tpl" a popup appears that contains form items. I want the above 5th argument appears in this form. i.e. $cid. How can I do this. Please help.


texts: Why doesn't the pagination work for a comment type, but it works for the other one?

texts:
I have a custom content type with multiple comment types.

Query comments
Discussion comments

I set the pagination limit for the both the comments as 10. The node detail page, when the number of comments exceeds 10, shows the pagination. For the discussion comments, only 10 comments are shown, even if they are more; no pagination is shown.

Why does this happen?


texts:
I am trying to log in on a Drupal site, but the site doesn't have the login block enabled.

How can I find the URL for the login form?


texts: print description title tag in flex slider

texts:
I want to print image field title inside the .

eg.

i don't know how to do it. it print

Here is my code on node--gallery.tpl.php

    <?php
        $imgcount = count($node->field_gallery_images['und']);
            for ($i = 0; $i < $imgcount; $i++) {
        $image_uri = $node->field_gallery_images['und'][$i]['uri'];
        // url
        $masthead_raw = image_style_url('showcase_720', $image_uri);
    ?>

    <li data-thumb="<?php print $masthead_raw; ?>"><img class="flex-img img-responsive" src="<?php print $masthead_raw; ?>"/>

    <?php } ?>

Please Help.


texts: Am using custom breadcrumb  module for breadcrumbs in drupal .Is there any option to reduce the length of my active title?


texts: Display register form to logged in users

texts:
I am on Drupal 7. When users log into a Drupal website, they aren't allowed to see the register form anymore. That is the regular behavior and I understand the reason why Drupal behaves like that.

But I have a specific situation in my website. I need users in a specific role to register new users. I will create an invisible field in my form that will tie these new users with the UserId of the "parent" user creating them. Maybe I will use the User Reference module. There is no problem here, I can do that.

The question is: how can I get the register form to be displayed to logged in users in a specific Role without giving them the "Administer users" rights? I don't trust these guys to give them that much access.

Thank you!


texts: Groups share the same name; I need to tell them apart

texts:
Using Organic Groups for the first time and I've run into an issue.

I'm building the group hierarchy and I have two groups with the same name. Right now it's only two groups but there is the possibility of this happening again in the future. Obviously I cannot rename one of them.

Here is the general hierarchy:

Level 1 (Brand) with 2 groups

Level 2 (Location) with 15 groups

Level 3 (Property) with >50 groups

I have one location that is shared on both brands so I have two groups with the same name that are technically different because the parent group is different.

How do I differentiate between the two groups?


texts:
In a view, I have several fields that I would like to link to the original content. The title field's default behaviour is like this, but I want to have the trimmed body and the image fields to behave the same way too.

For this, using the content:path field and then rewriting the other fields using this one as a token has been recommended here. But this gives me the Drupal path, not the URL alias.

Another idea is to use Global Redirect module and to set it to always use URL aliases. But this obviously requires to install yet antoher module. I am hoping to manage without it.

The content pages behave according to the URLs so I need to have the aliased ones.

Is there a way to get the URL aliases in views link fields?

(I am using Drupal 7.23, Views 7.x-3.7 and Pathauto 7.x-1.2)


texts: html.tpl.php is deleted and the site is down!

texts:
I'm mid-versed in WordPress, but newbie in Drupal, developing a Theme from scratch. I started with page.tpl.php, then extended the design with a custom front-page (page--front.tpl.php). Then for a custom structure I made html.tpl.php, after heard about it from a Drupal geek. But I found no connection with it to the site and Shift+Delete it. And my site is down now.

To retrieve the site, I copied the page.tpl.php and renamed it to html.tpl.php. But till there is nothing but an alt text of my logo. I even can't get access to the /user, Clearing cache section. But cleared the browser cache with no hope.

Developing environment: WAMP 2.1, localhost


texts: What is the best-practice for managing Aegir sites in Git?

texts:
I know there is a million ways this could be done, I'm more looking for the "best-practice" of how this "should" be done.

I have an Aegir setup with 4 different Drupal platforms.
Within each platform there are several Sites.
There is also modules/themes in the "all" directory that are shard between the sites.

How would one one manage these platforms/sites in Git?

Should we create 1 repo for the entire "platforms" folder?
A repo for each platform folder?
A repo for each platform folder and a repo for each site?
A repo for each site and a repo for each "all" site?

What would be the best practice for this?

thanks!


texts: AJAX append content via link on existing page

texts:
I am trying to recreate the functionality of the ajax_link example in the Examples for Developers module.  Here is the code I have so far:

In animal_licence.module:

function animal_licence_menu() {
  $items['buy-animal-licence/animal'] = array(
    'page callback' => 'ajax_link_response',
    'access callback' => 'user_access',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
    'file' => 'animal_licence.inc',
  );
  return $items;
}

In animal_licence.inc

function ajax_link_response($type = 'ajax') {
      if ($type == 'ajax') {
        $output = t("This is some content delivered via AJAX");
        $commands = array();
        $commands[] = ajax_command_append('#content', $output);
        $page = array('#type' => 'ajax', '#commands' => $commands);
        ajax_deliver($page);
      }
      else {
        $output = t("This is some content delivered via a page load.");
        return $output;
      }
    }

The ajax link on-page is:

Click here

When I visit /buy-animal-licence/animal/ and click the link I get the ajax spinner and it eventually times out with the following:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /buy-animal-licence/animal/ajax/
StatusText: OK
ResponseText:...

I'm not sure where to go from here, any suggestions would be much appreciated.


texts:
We would like to target a webform field "email" so that it only has readonly option when the field uses the logged in users email address.

The webform email field has an option to "Set the default value of this field to the user email, if he/she is logged in." and to toggle a "readonly" option.

How would we go about achieving this?


texts: I need to create a custom feeds processor. Basically my client will upload a csv file they have received from amazon or some other source and it will create an order for them. It will allow them to manage all their orders in one place. I know I need to create a custom feeds processor but am unsure on how to do that?


texts: How can a theme be looked in sites/my_custom_website?

texts:
How do tell Drupal 8 to look for themes and custom modules in a directory called sites/my_custom_website?

I know this type of code is added to the themes and modules directory at the root level. I have a special case where this code needs to is separate from the git repository and away from the original build.


texts:
Hi i've just started building a site on Drupal 7.31 and i'm following my normal procedure i've used loads of times. One of the things I have on most sites is an introduction just beneath the title.

I add an introduction field to the Basic Page content type and in page.tpl.php I print it out using:

<?php
    if (isset($node)) {
      if ($node->type == 'page') {

        print '<h2>';
        print render(field_view_field('node', $node, 'field_introduction', array('label'=>'hidden')));
        print '</h2>';

      }
    }
?>

It's never caused any problems before, on any previous version but for some reason this time round I get this error:

Strict warning: Only variables should be passed by reference in include()

Any ideas why?


texts:
This favicon generator (recommended here) generates multiple favicon png files and code for the <head> section of your HTML pages. This is said to be better than a single favicon file which might not display correctly in some devices.

But I think "Path to custom icon" in D7's /admin/appearance/settings only accepts a single favicon file.

If so is there a way to use multiple favicon png files?

If I can only use a single image what is the best practice for the format of the file?


texts:
I am trying to implement the OpenID Connect SSO as outlined in Nik Vahalik’s YouTube video and in Patrick Dawkins’ Tutorial.  I have gone step by step through their implementation instructions as well on the documentation page (https://www.drupal.org/node/2274367).

I have the OAuth server running on one Drupal Instance.  I have the client login setup on a different Drupal Instance.  I have the sso.php located in the root of each Drupal instance.

When I click “Login with Generic” on the client site, I get an error that says “Not Found The requested URL /oauth2/authorize was not found on this server.”
The URL bar shows this as its attempted destination:
https://devcondrupal.genieve.com/oauth2/authorize?client_id=devdrupalclient&response_type=code&scope=openid%20email%20profile&redirect_uri=https%3A//devdrupal.genieve.com/%3Fq%3Dopenid-connect/generic&state=7a4e2dc4a66e3aa3b4531b5d523f6371

I am using self-signed SSL certificates on both the OAuth Server site and on the Client site.

I don’t know where to begin troubleshooting the issue as this is my first experience with OAuth / OpenID and there is not much information out there on the web (Drupal-wise).

Thanks for your help.


texts: Drupal Site Migration from FreeBSD 12 to Ubuntu 18.04 SQL database unknown behavior

texts:
I am currently trying to migrate the Drupal Site from FreeBSD 12 to Ubuntu 18.04. All the configurations are copied and moved to Ubuntu 18.04. Everything seems fine and I was able to create the Drupal Site with Ubuntu 18.04, but whenever I clear the cache on the new site, it seems like the page settings are gone and the content goes all over the place. Also, the newest content gets erased as well. I usually use mysqldump command line to dump the mysql database and restore the backup with the mysql command line. I have also tried downloading phpmyadmin to dump and restore the mysql database, but the issue is still present. This is a critical issue on the site, because installing a new module automatically deletes  cache.

Drupal Version: 7.59

I am guessing when the mysql database is dumped, the newest content and page settings goes into cache..? I am not really familiar on how mysql saves the database. Any help would be a great help for me to proceed with the migration. Thank you!


texts:
Are there any way to disable the taxonomy pages? I saw a question that restricts access to them (Original question).

But I dont want the "access denied" message to be displayed, I want to remove the pages completely.


texts: Any benefits for using fields as opposed to properties

texts:
I have a module that pulls data constantly from an external source, from up to thousands of different items with over 50 properties.

The data is being collected every 15 minutes.

The problem is that writing each property to a Drupal field seems to take a great deal of time - so many joins. It seems like it would be more efficient to save these values as properties on the entity.

Is there any downside to doing that? What are the strengths and weaknesses of keeping everything a property on the entity table rather than making each one a field?


texts: How to alter the languages available in a form

texts:
I have a multilanguage site. When I go to edit a node, all the languages of the site are available. I only want some of the active languages to appear in the dropdown for certain users (for various complicated reasons).

In Drupal 6 I did this:

function example_form_alter(&$form, &$form_state) {
    //example_language_list returns an array in the from of   ("en"=>"English") etc
    $languages = example_language_list($form['#node'], TRUE);
    $form['language']['#options'] = $languages;
    if (count($languages)==1) {
        $form['language']['#disabled'] = TRUE;
    }
}

Any idea how I do this in Drupal 7?


texts:
I have create a little fotogallery where I display only the first 3 images, the first "big" on the left side and the other two (small, width / 2 of the big one) on the right side. All images are "linked" to colorbox.
If I click on one of these 3 images colorbox "run" (ok, perfect).

Via a div in a absolute position style I have added this phrase "See all NUMBER images". Now I need to link this "phrase" to the event that run colorbox from the first image (the big).

How can i do this ?


texts: How can I get major version updates with drush pm-update?

texts: I often check for updates to my modules using drush pm-update.  However, this check does not check for succeeding major versions.  For example, if I am using Mollom 1.1, drush pm-update will not alert me that there is a 2.3 version available as well.  Is there a way to tell drush to give me all possible updates, including major versions?


texts: Let's say we have a section /latest-projects with a menu block listing nodes sorted descending by their post date. Thus, the first item will often change and be the freshest one. Is it possible to make the /latest-projects alias always link to (= open) the top-most node?


texts: Update customer billing address within custom pane

texts:
I am writing a custom CheckoutPaneBase within Commerce 2 that incorporates shipping and billing information. My goal would be to update the customer's billing address, that is stored as billing profile, programmatically. I looked at the billing information Pane and see that they use:
  $billing_profile = $this->order->getBillingProfile();
      if (!$billing_profile) {
        $billing_profile = $this->entityTypeManager->getStorage('profile')->create([
          'type' => 'customer',
          'uid' => 0,
        ]);
      }
      $billing_profile->populateFromProfile($payment_method_profile, ['data']);
      $billing_profile->save();
      $this->order->setBillingProfile($billing_profile);

But rather that populate from $payment_method_profile, I would like to add my own fields' values. I am not sure how I can populate an array to push to populateFromProfile or setBillingProfile or the field values.
Any help or hints?


texts: What is the best way to set up demo for Drupal themes and live switch between them?

texts:
I want to set up demo for Drupal themes and live switch between them with top drop-down menu.
Examples what i mean (navigate to the top bar and change theme live with a theme switcher):

http://themefuse.com/demo/wp/my-journey/

http://demo.themebrain.com/#anis

How can i repeat that with drupal, what is the best practice?
The problem is: if i develop a theme on my localhost, then install on the server drupal with this theme enabled - that is simle.
Then a develop second theme, and want to setup live preview with the same drupal installation BUT with another demo content.

So i need create another demo content BUT when the number of themes in development increase to 10-20 it will be a nightmare to remember what block or node is intended to appear with whith theme. Simple way is to setup different drupal each with one theme, BUT it's bad to accumulate the same code and db on the server.

In addition, i want to provide user with full drupal package (drupal setup with modules and database to import) to allow fast reproduce demo. So i don't want admin's interface clutter.

Possible modules i tried: http://drupal.org/project/themekey but it doesnot provide dropdown for switching
http://drupal.org/project/switchtheme but it shows the same content, i need it to show nodes and blocks for some theme only.


texts: How to save the previously selected option in the selection box, the default value strays

texts:
Please help to understand what the problem is. I created a field Select to list in the comments to type of material field values I needed my, I redefined options list in the Custom Module

$query = db_select('node', 'n')
        ->fields('n', array('type', 'uid', 'title', 'nid'))
        ->condition('n.type', 'brigada_type', '=');
     $result = $query->execute();
     $brigade_list = array();
        foreach($result as $value){
             $brigade_list[$value->nid] = $value->title;
        }
        $form['field_select_brigade']['und']['#options'] = array(0 => t('- Select -')) + $brigade_list;

After I select a value from the list and create a comment I check it, and then only published but during the inspection the default value strays.

before

after


texts: I have a custom entity and i don't have any fields in the entity.Instead what i have is:- Adding custom entity page has a form where we have several fields where we are able to fill all the fields in the form.Now the problem which i m facing is is: how to display the entity added  on my_entity/% page?


texts:
I was experiencing weird GD library issues with Drupal 8, when the site tries to generate thumbnails from image style. I am using Docker PHP.

The error is simply saying Error generating image. I checked the logs, but I didn't find anything helpful.


texts:
Hopefully some wise Drupal guru will be able to help me with this one.

I'm using menu and menu block to output a side menu in Drupal 7.  Using Panelizer, on a basic page I can customize display and add a view pane (Case study: Teaser), which will display a list of case study teasers:

I can add a case study content type, which provides a menu link.  The problem is over time there will likely be hundreds of case studies, and it will look unwieldly to have hundrens of children/sub-pages in the menu.

I could list the links and disable them from the menu (and also keep the breadcrumb path):

However, various admin and editors will be using this, so ideally I'd like some functionality whereby sub-pages do not appeaer in the menu when a Case Study content type is used, but the breadcrumb path is still shown:

If anyone could point me in the right direction, I'd be eternally grateful :)


texts: Why is #attached library load not working, but drupal_add_library works?

texts:
This question is specific to D7:
I'm trying to load in jQuery UI modal into the theme. I've put the following in my THEMENAME_preprocess_html:

$variables['page']['content']['#attached']['library'][] = array('system', 'ui.dialog');

This isn't loading the library at all.

DPM-ing the $variables array after the above line shows that it's all added correctly (There's even other stuff in there like, addthis.js):

Direct link: http://i.imgur.com/iTeynMR.png

Obviously all caches were cleared. At this point the console shows an error that dialog is not defined. But as soon as I add this (in the same function, just below the #attached line):

drupal_add_library('system', 'ui.dialog');

then the dialog modal opens and starts playing nicely. Am I doing something wrong with #attached? I'm really puzzled as to why one's working and the other doesn't. Ideally I'd like to use #attached in the cases where the variables array gets cached and the preprocess doesn't get called.


texts: How to get referenced entity fields from another content type in single node template

texts:
I have a content type called "Resources", this is referenced from another content type called "Projects".

I can get simple text fields in my single node--project.html template for example -

{{content.field_project_linked_resource[0['#node'].field_resource_title[0].value }}

How do I get more complex fields like image and file fields?

This does not work for example -

{{node.field_project_linked_resource[0].entity.field_resource_pdf_1.entity.uri.value }}

Thanks for any help!


texts: How to close comments with just 1 click?

texts:
My site editors want a quick way to close comments on a particular node, i.e. they just want to click a button on an item, rather than having to click edit, then select the comment settings tab, then click the "closed" box.  (This is for Advanced forum, but I guess it could apply anywhere).

I have a feeling this should be fairly easy to do but I can't work out how to do it. Any pointers you can give would be appreciated. (I am using the Flag module and thought flag actions would be a simple way to do this, but closing comments doesn't seem to be an available action).


texts: Views Data Export: Export to XLS with column labels?

texts:
The fields gets exported to XLS, but no labels are generated for every field, but missing field labels. Labels are set for every field in the field option.

Should be:

Field Label 1 | Field Label 2 | etc.
====================================
Data 1        | Data 2        | etc

But now it's just fields with no column labels

====================================
Data 1        | Data 2        | etc

Is it a setting I'm missing out in Views or tpl.php templates needs editing?


texts: How to change/set/assign parameter's value for an entity query?

texts: Say you have an entity query which you're going to use in a loop so that only parameter(s) value(s) changes on every iteration. Is there a way to prepare this query and change the value of the parameters?


texts: Hide CCK fields for users without references with node

texts:
I have a role "worker".
I have one content type "task" that can be viewed just by "workers".
"Task" has 3 fields:

field-A: a user reference field to select a "worker" user;
field-B: one textfield that can be view from any "worker";
field-C: one textfield that can be view just from "workers" related to the node using field-A.

How can I set permissions to let users view just the fields they are allowed to?
Content_permission just has a per role granularity, so I can't use it in a dynamic context and with many categories.
User Reference Access just set permission to the whole node.
I'm looking for something like Taxonomy Access, but with a per field granularity.


texts: How can I use the Date tools without requiring an end date?

texts:
I used the Date module's Date Tools (admin/content/date/tools) to add a date field to an existing content type. When I go to create a new node, it displays both a From date and a To date. When I go the Manage Fields section for the content type, I only see one date field.

Is there any way to make it display only a single date field when creating new content? I don't want to allow users to choose a date range, rather only a single date.


texts: Grant permission for publishing options without full 'administer content' permission

texts: As the question says. I'm working on a news site, and authors should be able to create a full piece and be able to chose whether to publish or not. How can you do this?


texts:
I am new to Drupal and am facing an issue where any theme that I try to install will fail with the following message:
Installing light_skeleton
An error has occurred.
Please continue to the error page

An AJAX HTTP error occurred.
HTTP Result Code: 403
Debugging information follows.
Path: /core/authorize.php/core/authorize.php?batch=1&id=4&op=do_nojs&op=do
StatusText: Forbidden
ResponseText:
403 Forbidden
403 Forbidden
nginx/1.9.10

The root folder is owned by www-data:www-data and I have given the directory 775 permissions. I have also tried to give it a full access using chmod 777 but without success.
I have checked the logs of nginx and php but there are no errors displayed. The site itself, using the standard theme, works without any issues.
After getting the error, I get:
Notice: Undefined index: log in update_authorize_install_batch_finished() (line 291 of core/modules/update/update.authorize.inc).
Warning: Invalid argument supplied for foreach() in update_authorize_install_batch_finished() (line 291 of core/modules/update/update.authorize.inc).
Notice: Undefined index: log in update_authorize_install_batch_finished() (line 332 of core/modules/update/update.authorize.inc).
Notice: Undefined index: tasks in update_authorize_install_batch_finished() (line 333 of core/modules/update/update.authorize.inc).
Installation failed! See the log below for more information.


texts:
In Drupal 7, we can use a template file like page--user--register.tpl.php, or we can register our own template file.

How we can do it in Drupal 8?


texts: How can I use a views template to modify the titles of taxonomy links?

texts:
I have a view that shows a field which is a taxonomy term reference set to display each term as a link.  The taxonomy names are quite long so I want to rewrite them using a views template.

I made a template like this:

foreach ($row->field_field_ad_purpose as $data):
  if ($data['rendered']['#title'] == 'Apples, oranges, pears, and strawberries'):
    $data['rendered']['#title'] = 'Fruits';
  print $output;

Using dpm(), I was able to confirm that the #title is in fact shortened.  However, printing $output prints out the original title.  I also tried printing $data, but this just gives Array.  What is the function to call to print out the term as a link?


texts: How to have a view field that searches node title, body and everything about node

texts:
I am looking at replacing the core search module with a custom view. I would want a field that lets users search all the content by keyword(s).

What's my best option, preferably a module that does this in a user friendly way.


texts: Drupal 7.2: Horizontal & Vertical Tabs- HOW?

texts:
Using d7.2.  I'm looking to create this setup, possibly w/ JQuery (or something similar that would provide real time tabs w/o refreshing the page).

         Popular        Visits       Comments      Recent

Category 1

Category 2

Category 3

Category 4

So the user would click on one of the category tabs on the left side (vertical), and then they can sort w/ the links at the top w/ real-time refresh/results, no page refreshing or loading required.

I like the look of JQuery tabs- but want the best solution here. By best I mean easiest, lightest, and most compatible with most browsers.

I can setup various views to execute the searches/results- but do I make those 'pages', or 'blocks'? How do I create the tabs and links for sorting?

Thanks for all the help guys!


texts:
I created a Custom View block in  Drupal 7 which it is simply pulling random "Did you know Tips" for visitors. I created a mini pager for the block to allow visitors to toggle through them (Ajax enable as well for the asynchronous refresh of the block)

Everything is working accordingly except one tiny issue... I have 2 Pagers on my home page??? One is the mini pager under the block which is desired, but an additional Full pager is created at the bottom of my main page. Oddly, it's only found on the main page!!! No other nodes pages have this issue.

It seems that the behavior is along the lines that the additional pager is being "promoted to the front page" however, the content type has that excluded. Is there a way to hide this additional pager in template.php / views-view.tpl.php? Perhaps I missed something along the way?


texts:
In Drupal 7 you can take a theme function and override it.

For example if I want to override theme_form_element, I would place it in  my template.php as MYTHEME_form_element.

The only problem is that I then have to copy the entire theme function into my template.
For example, for theme_form_element, there is over 60 lines of code.

This seems overkill, if I only want to do something simple as add a class to the attributes array.

Is there any way to only include the part of the theme function I want to override and tell Drupal to refer to the rest of the built in function?


texts: how to avoid commerce price to be rounded

texts:
I need to add an optional insurance field to my order total amount.

For that I use a fee which is calculated and added to this amount.

Everything is ok except that when I continue to checkout, this amount is rounded to the superior .5

For example I have a total amount of 282.00€, I add 1% for insurance, fee is calculated as 2.82€ and when I arrive to checkout, it's rounded to 2.85€...

I don't want this amount to be rounded, in Euro you can have cents, so 1% is 1%, not 1.x %...

Is it possible to disable this rounding operation ?

Thanks in advance for your answers


texts: Migrate + Access $row values in a custom progress plugin

texts:
I use migrate/migrate_plus modules fo import datas from xml file.
I want create a custom progress plugin to alter a value. I want to use a second value from the row to alter my first value.
In my custom module, and inside my "transform function" I tried to call the $row values without sucess.

here is my code:

use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\MigratePluginManager;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

/**
 *
 * @MigrateProcessPlugin(
 *   id = "convert_my_data",
 * )
 */
class ConvertMyData extends ProcessPluginBase {

/**
 * The row from the source to process.
 *
 * @var \Drupal\migrate\Row
 */
protected $row;

/**
 * {@inheritdoc}
 */
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {

dpm($row)
...

But, dpm($row) don't render any results/datas. Is there a solution to call the other datas of the current row?

Thanks for your help.


texts: How to get node id on hook_page_build(&$page)

texts:
I wrote a hook like so:

function john_page_build(&$page)
{
  $akeys = array_keys($page['content']['system_main']['nodes']);
  print $akeys[0];
}

On pages with urls like http://mysite.com/page/43, it will print the node id for that page.  However, on a page with url like http://mysite.co/page/43/done?sid=2, drupal gives a warning saying that $page['content']['system_main']['nodes'] does not exist.

Is there a consistent way to get the node id WITHOUT parsing the url?


texts: How to allow for manual HTML & CSS changes?

texts:
I'm using CK Editor to insert a table into my content (Body field).

I would like to set a background color, so I extended the style="width:100%" to be style="background-color: #FFEEE4; color: black;width: 100%". And this by clicking on Switch to plain text editor.

But now, once I save, the background-color style disappears again (Test Format FULL HTML). How can I make it stick?