texts: Programmatically change placeholder text of form input

texts:
Inside a custom block plugin I'm creating, I programmatically load the user form and return it like so

public function build() {
    $fb       = \Drupal::formBuilder();
    $userform = $fb->getForm("Drupal\user\Form\UserLoginForm");

    $render = [
        '#type'       => 'container',
        '#attributes' => [
            'class'      => ['row', 'expanded'],
            'id'         => ['login-page-block']
        ],
        'userlogin' => [
            '#type'    => 'html_tag',
            '#tag'     => 'h3',
            '#value'   => 'Welcome Members!',
            'caption'  => [
                '#type'   => 'html_tag',
                '#tag'    => 'p',
                '#value'  => 'To access member-exclusive content on our website, you must login.',
            ],
            'form' => $userform,
        ],
    ];

    return $render;
}

It creates labels for the inputs for Username and Password, but I'd rather ditch the labels and put 'Username' and 'Password' as placeholders inside the input fields. However I'm not sure how I would go about doing that. I performed a die(print_r($userform)); to get a list of fields in the array but I didn't see anything applying to the array.

Is there a way to place placeholder text inside the text input fields of a form that was programmatically retrieved and rendered?

UPDATE: I attempted changing the placeholder by writing

$userform['keys']['#attributes']['placeholder'] = t('Username');

But that didn't seem to do anything.


texts: How to access $vars['some'] variables in html.tpl.php template

texts:
In the template.php, I am using the following code for mytheme_preprocess_page().

 // Return nid for node of type "interface_configuraitons".
    $nid_config = db_select('node', 'n')
        ->fields('n', array('nid'))
        ->fields('n', array('type'))
        ->condition('n.type', 'interface_configuraitons')
        ->execute()
        ->fetchCol();
    //load the configurations
    $configurationNode = node_load($nid_config);
    $interfaceConfig = array();
    $interfaceConfig['driver_url'] = $configurationNode->field_driver_url['und'][0]['value'];
    $interfaceConfig['driver_port'] = $configurationNode->field_driver_port['und'][0]['value'];
    $vars['interfaceConfig'] = $interfaceConfig;

While $interfaceConfig is initialized and available in any of the page templates, it is NULL in the html.tpl.php template. I was trying to run mytheme_preprocess_html() without success.

How do I get this preprocessing take place, so it is available in the html.tpl.php template file?


texts:
I'm working on displaying information about users on their profile pages.

I want to display a field; if this field is not completed then I display a text message, else, I display its value.

I've written this code:

<?php
     $username = $user_profile['field_username'];

     if($username == "") {
       echo 'Please enter a user';
     } else {
       print render ($user_profile['field_username']);
     }
?>

I get this error:

  Undefined index : field_username

But the code is working properly.


texts: What module controls Commerce Kickstart 2 add to cart popup?

texts: I have installed the demo store Commerce Kickstart 2. Going through and changing things here and there somehow I've affected the popup functionality. It no longer fires when adding something to your cart. I'm thinking I may have just turned off the module that controls this? Or maybe it's a setting I clicked off?


texts:
I try to add the possibility to order by column in the header of my table element.

I started to use Drupal 8 and I can't find any clear documentation about table on the API site to do what i want...

Thanks in advance.


texts: How to programmatically render a webform to display specific Elements

texts:
I have tried this way but not able to hide "confirmation_id" element.

public function buildForm(array $form, FormStateInterface $form_state, $sid = NULL) {

$my_webform_machinename = 'request_form';
$my_form = \Drupal\webform\Entity\Webform::load($my_webform_machinename);
$my_form['elements']['flexbox_layout']['confirmation_id']['#access'] = FALSE;

return [
    'form' => [
    '#type' => 'webform',
    '#webform' => $my_form,
    '#sid' => $sid,
    ],

];

}


texts: Drupal Rest Service - Create node problem

texts:
I'm using POSTER add-on (Firefox) to create a node.(REST service). I couldn't able to create node having select/checkbox item. Getting following error in response.

["An illegal choice has been detected. Please contact the site administrator"]

How to resolve this? I'm able to create node if post data doesn't contains select/checkbox data. My problem is exactly related to the following link. But I couldn't find solution.

drupal 7 + services 3 - inserting nodes with select fields

If I replace 'und' to 'en' in json format, the node is being created but with null values.

I've found following messages under Recent log messages.

Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain()
Warning: Illegal offset type in isset or empty in list_field_validate()
Illegal choice in LABEL element.

Here 'LABEL' is the label(name) of the filed


texts: Commerce Product Collection View Block: What Determines CSS For Each Header Link?

texts:
In Kickstart 2 there is a view called collection_products which displays a list of products in a given collection, grouped by category.

There is a header which uses a Block display to give anchor links to each Category Header on the page. The format of the fields is 'Unordered List' yet the fields are styled as

...not

...as I would like.

How do I change the generated styling of these? I've searched all over the view and can't find it.

HEAVY EDIT. Big Thanks to J. Reynolds!

The issue is that this view is actually a list of group headings. The reason it displays as it does is that it's showing a list of all categories... each as a 'Title'...

...for each category and then a -hidden- list of the products.

So it's not that each 'row' is being themed not as a list, but that what I -thought- was a 'row' is actually a 'title'.

So: What I need to do is create an unordered list with the -title- of each category (the Grouping No. 1) as the actual li using each of these headings.

How do I do this?

BONUS: Is there a way to get Drupal to not even generate that hidden UL of products? It seems wasteful, not just for the client, but at the server.


texts:
I need to update webform from 8.x-5.0-beta18 to 8.x-5.1  but unfortunately, I cannot use Composer because it is not possible to install it on my server due to server restrictions.

This also apply to:

Clientside Validation 8.x-1.0-rc3 to 8.x-1.0
Poll  8.x-1.1 to 8.x-1.2
SMTP Authentication Support   8.x-1.0-beta3 to 8.x-1.0-beta4

as they all appear in the admin/reports/updates/update

Is there anyway to do it manually?


texts: How do views Contextual Filters behave with Pathauto?

texts:
I have Pathauto installed, so URLs to nodes are not like node/3. My question is that if I write a View with a contextual filter for looking for node/3, will it work?

Note: This contextual filter is in a block. See this question.


texts: How to access the nid of selected node using nodereference textfield?

texts:
I'm using drupal 7.28 and node reference 7.x-2.1

I need to know the nid of a selected node using cck node reference field, not de #default_value of the field but a new one

I've added ajax to the field to perform further tasks with the selected node nid

after I've selected a node with the nodereference cck field, if I use dpm($form_state['input']) the field nid is null

where I should seek (at $form_state) to find out the nid of the selected node ?


texts: Is there a way to make the comment module email the administrators when a comment needs approval?

texts: I'd like to be notified whenever comments are made on the site which require administrator approval before publishing; basically, I'd like to know when something new appears in the Approval Queue. I can't see any obvious settings for this.


texts: How to display node image in page header for custom theme?

texts:
I'm extending the Tweme theme (a Bootstrap subtheme) and I want the "banner_image" field on the node page to be displayed in the header.

The page.tpl.html template from Tweme has the markup for the header, but this doesn't work because (I believe...) that template doesn't have access to the $content variable:

print render($content['field_review_nationality']);

The node.tpl.html template does have access to $content, but the header isn't present in that template.

Where/how do I render my "banner_image" field?


texts:
I'm using the module GMap but am having an issue with the maps that are generated on my drupal site.

I click the pin, and all I get is "Loading..." and the following error pops up in the console:

  Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://map/node/load/11/0. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

I have yet to find an example of someone coming across this issue, so I'd appreciate any help.

EDIT - I know the issue might revolve around the "remote resource" obviously it is trying to pull it from http://history.arvadahistory.org/map/node/load/11/0 rather than just http://map/node/load/11/0. Is there something I might be missing from the configuration?


texts: How can I flag content programmatically?

texts:
The Flag module is still in development for Drupal 8, but it's working nice. However, I didn't find how to add a flag programmatically; the API documentation seems to speak of the Drupal 7 version.

How do I programmatically add a flag?


texts: How to have search results from a views defined block display on page?

texts: I have created a custom search block with Views 3 in Drupal 7. I would like the results of that search be displayed in a page (like the default drupal search block) and not in the block itself (which seems to be the default behaviour for views). How do I accomplish this? I think I am missing a setting somewhere but can't find it.


texts:
I have a job_post module, which defines the "job_post" content type.

In this module I have hook_unistall() which calls node_type_delete() to remove that content type.

After uninstalling, I have the following error from the Comment module:

  Notice: Trying to get property of non-object in comment_node_type_delete() (line 343 of ....\comment.module).

I have this error because the $info variable in node_type_delete() is set to FALSE.

Why when my module is installed and when I am printing var_dump(node_type_get_type('job_post')) on any page, I have an object, but when I'm trying to print the same code in my unistall function I get FALSE and this error?

job_post.install

/**
 * Implements hook_install().
 */
function job_post_install() {
  node_types_rebuild();

  $types = node_type_get_types();
  node_add_body_field($types['job_post']);

  $body_instance = field_info_instance('node', 'body', 'job_post');
  $body_instance['type'] = 'text_summary_or_trimmed';

  field_update_instance($body_instance);
}

/**
 * Implements hook_uninstall().
 */
function job_post_uninstall() {
  $instances = field_info_instances('node', 'job_post');
  foreach ($instances as $instance_name => $instance) {
    field_delete_instance($instance);
  }

  // Force rebuild of the node type cache
  // as Clive suggested didn't help
  // _node_types_build(TRUE);

  node_type_delete('job_post');

  field_purge_batch(1000);
}

job_post.module

/**
 * Implements hook_node_info() to provide our job_post type.
 */
function job_post_node_info() {
  return array(
    'job_post' => array(
      'name' => t('Job Post'),
      'base' => 'job_post',
      'description' => t('Use this content type to post a job.'),
      'has_title' => TRUE,
      'title_label' => t('Job Title'),
      'help' => t('Enter the job title and job description')
    )
  );
}

/**
 * Implement hook_form() with the standard default form.
 */
function job_post_form($node, $form_state) {
  return node_content_form($node, $form_state);
}


texts: In nodereference field of a content type, Is it possible to show the content type name added with the autocomplete results?

texts:
In nodereference field of a content type, Is it possible to show the content type name added with the autocomplete results ?

Example :

I have a content type named Article which has a node reference field (Related content -> field_related_documents), So that this article will referenced to other nodes.

While creating an article, by entering 'help' in 'field_related_documents' I am getting autocomplete results (titles of referenced nodes) like below

helpsystems - rules
Decision management Help
Using help menu
Help support glossary

Instead, I like to show results like below

Page | helpsystems - rules
HelpSystems | Decision management Help
Page | Using help menu
Document | Help support glossary

ie) autocomplete results should display title of other nodes added with their related content type.

How should i achieve this ?


texts:
At some point in an update in the last few months, Drupal (7) started routinely triggering attached behaviours twice.

At first I thought "this is my fault, my behaviours should check to see if they've been run in this context already", and I set about using jQuery's once() (and other such solutions).

However I'm convinced now that this is a wider problem. e.g. the admin_menu module generates 2 admin menus.

Has anyone found this and the cause of it and a solution (beyond patching every module in use to check for duplicate calls)? I'm not sure where to start looking!

Nb. I've said "drupal" is doing this, I suppose it could be a contrib module that's causing the behaviour. I've seen it across several sites (I manage a dozen or so)


texts:
I have a select box in my drupal form and i want to call a spesific php function whenever the select option is changed. How can i achieve this?

this is my code so far:

function langSelect_form($form, &$form_state) {
    $form['langSelect'] = array(
       '#type' => 'select',
       '#options' => drupal_map_assoc(array(t('English'), t('Norsk'),t('Samisk'))),
    );
    return $form;
}

thanks!


texts: Replace 'page' twig template for controller/url

texts:
I have a page generated with custom controller.
It's special page, so i need to remove all sidebars, headers and logo, for that page, and use custom design/layout.

How can i replace 'page' twig template for that url/controller?


texts:
I have created a view with an exposed filter. In my display I have an Using tokens section that I do not want to display:

Using the theme developer this is the closest I can get to it:

So it seems to part of views bulk operations. How can I get rid of this text?


texts: How would I get taxonomy info using the taxonomy term ID, in order to theme it?

texts: I need to be able to extract a taxonomy array and use it to create links.


texts: get the permission must the user have to access to the 'Access denied ' page

texts:
i'm working on a drupal 7 online payment module ,

and i need to know if there is a Drupal 7 function that can track (each time and for all the users) if 'the logging online user' is requesting an 'Access denied ' page , and then get the permission must the user have to access to that page

  PS: i'm creating a drupal payment module , the payment will be by
  roles , for exemple ( user1 can create 'Blog content type' just if he
  has the permission on that, if not i i need to know which 'Access
  denied ' page he is in and it's role so i can show him a message to
  buy this role depending on the price in the database) all what i need
  is the string permission of the page

thanks in advance ^_^


texts: How to display the 'Request New Password' page for Administrators.

texts:
What I'd like to do is have the exact same page as /user/password (when not logged in)  that the 'Administrator' Role could use and send out emails to existing users.

However when logged in you get a 'Password reset instructions will be mailed to'  message.  I've had a hunt for a module or how to do it programmatically but can't find a solution.

Many Thanks


texts:
I hate asking a vague question like this but I'm really at loss as to my current problem. I'm setting up a new site and image uploads fail on my production site (both in custom and content type forms). The failure occurs when a file is sufficiently large (greater than ~4mb). I believe the failure has more to do with something timing out rather than a limit to file size. At my office where the connection is good I can upload an 8mb image but on my slower home connection I can't upload more than a 4mb image. The upload seems to consistently timeout at about 20 seconds.

When the upload fails the form itself doesn't provide any feedback. The little blue spinner just disappears and the remove button never appears. The only feedback I receive is through the browser's console. I'm getting a HTTP Result Code: 400 error. Paths are good because like I said I'm able to successfully upload when the image or file is sufficiently small.

My relevant php settings are:

max_execution_time 300
max_input_time -1
post_max_size 18M
upload_max_filesize 16M

I'm able to confirm these php settings through a phpinfo.php page so I'm reasonably confident it's not this.

I'm running Drupal 8.7.6 on CentOS7 with PHP 7.2.21.

Does anyone have a good guess as to what my problem could be? I'm sorry this is vague and most likely not an issue with Drupal. Thanks, I appreciate any hints you might provide.


texts: Display Suite Custom Field - Date Format Help

texts:
I'm trying to format a date field inside of a DS custom field. I'm printing the field from the entity object, and the value is a string. I've tried passing it through date_format but that doesn't work. Any help would be appreciated.

<?php print '
' . $entity->title . ' - ' . format_date($entity->field_start_end_date['und'][0]['value'], 'medium') . '
'; ?>


texts:
I try to insert new field (title) into field_collection_field_widget_form like this:

 $element['title_collection'] = array(
                    '#delta' => $delta,
                    '#name' => 'title',
                    '#type' => 'textfield',
                    '#title' => t('Collection name'),
                    '#default_value' => 1234
                );

I have problem to set default_value for my field. I use default module field collection.

I tried use $field_collection_item->title (my variable into db)
But problem is that I can't change value in form.
When i change 333 => 222 form sent 222. What I do wrong?


texts: Drupal views contextual filter: use last argument as filter value

texts:
I would like a views contextual filter to only use the last argument in the url.    Given the following taxonomy structure, I would want /term-a to return Term A1 and Term A2 only (which works fine).  However, if the url is /term-a/term-a1 I would want only Term A1a to be returned, which isn't working, it's still returning Term A1 and Term A2

Within views, I don't see a way to use the last part of the path for the filter.  I tried to remove the argument from the path and then use the following as a default argument:

$path = arg();
return array_pop($path);

Here is the sample term hierarchy:

- Term A
  - Term A1
    - Term A1a
  - Term A2
- Term B
  - Term B1
  - Term B2

Just to reiterate what is returned:

The path /term-a returns:

Term A1
Term A2

The path term-a/term-a1 returns:

Term A1
Term A2

The path /term-a1 returns:

Term A1a


texts:
I have installed Drupal 8 as multi-site using Composer (as described by kalose). Basically, the folders created as subdomain-folders have been replaced with a symbolic link to the respective sub-domain folders in /sites.
I have 2 websites on 2 sub-domains, sub1.example.be/web and sub2.example.be/web.
In the public_html directory, I placed an index.php file with the following code.
header ("Location: https://sub1.example.be/web");

It works fine.
Where can I put a similar index.php file to redirect users who use the old link (sub2.example.be) to sub2.example.be/web?
Is there any other alternative to achieve the same?


texts: Trigger an action at a specific time using Trigger and Rules

texts:
I would like to run an action once a specific $_SESSION variable is set. In both Trigger and Rules, I do not find a description on how to do something like that. Can anybody help me, or at least hint at a website explaining this?

I am looking for an easy way to initiate a call at a specific time (think of as a Drupal alarm clock); my idea was to put the time in a $_SESSION variable and fire the alarm clock once $_SESSION['alarm'] == strtotime("now").

In case that this should just not be possible: I would also be happy with a trigger that fires whenever I go on a certain page.


texts: How to keep modal open after form submission?

texts:
I use Bootstrap theme for D7 site. On a front page I have a simple form which can be filled by anonymous user. When user submits form he is forced to register to move forward. I saved $form_state['values'] into $_SESSION to use them later and added some attributes to Submit button

'#attributes' => array(
    'data-toggle'=> 'modal',
    'data-target'=> "#register-modal",
    'data-backdrop'=>"static",
),

But form submission forces page reload and closes modal window. 'data-backdrop'=>"static" attribute doesn't work in this case. Is there any chance to submit form without page reload (i'm not an expert in AJAX) and keep modal opened?


texts: No schema for my_module.global error on unit test

texts:
I got an existing Drupal 8.2.x project with existing unit tests. When I run a sample unit test, I get the error (real module name redacted):

No schema for my_module.global

This doesn't seem to be related to the my_module.schema.yml file, or any DB schema that I can tell. Drilling down, I got this output for the $definition variable in \Drupal\Core\Config\TypedConfigManager.php, which the unit test calls up (among others):

array (
  'label' => 'Undefined',
  'class' => 'Drupal\\Core\\Config\\Schema\\Undefined',
  'definition_class' => '\\Drupal\\Core\\TypedData\\DataDefinition',
  'type' => 'undefined',
)

For core modules the class is Drupal\\Core\\Config\\Schema\\Mapping. Note that the error complains about a schema for my_module.global, which is one of the YAML config files for this module (can't tell how else it's related).

The question is, what does this schema mean exactly, and where do I set it for my module?


texts: Trying to make a filter taxonomy menu with multiple vocabularies

texts: I'm currently having trouble getting a taxonomy menu to act as a product display filter.  Actually I think I may need multiple menus as my products need to be filtered by: category, price, and color. I can do the filters separate, but they need to stay active together such as a filter with a category of 'all' and a price of 0 to 99 and color of red.  I am hoping to get this working somehow with views rather than recoding, but that is an option as well.  I'm still a little new to Drupal, and this is my first Drupal commerce kickstart site.  Using Drupal 7 and commerce kickstart 1.


texts: Unnecessary showing admin content in main theme

texts:
In one of my sites I have the bug: when I submit some admin forms, for example after editing a view, or create a taxonomy vocabulary the result page appears in the main site theme instead of admin theme.
If I simply visit these admin pages, for example /admin/structure/taxonomy they appears in admin theme as designed. Also these admin pages is showing in admin theme if i refresh them after form submitting.

So the front-end theme appears only after form submitting on only some cases. For example taxonomy vocabulary creation has this bug, but taxonomy term creation does not have it.

No themekey or some similar modules installed.

What can be a cause?


texts: How to exclude recursive module dependencies?

texts:
Is there a way to exclude dependencies of dependencies? For example:
my_module.info contains
dependencies[] = views

dependencies[] = ctools

my_sub_module.info contains

dependencies[] = my_module

On the module display page my_sub_modue will have my_module, views and ctools as dependencies. I know this is the desired outcome in 99% of all situations but I was curious to know if there were a way to have only my_module (or items explicitly stated in the info file) as the dependency for my_sub_module.

Thanks


texts: Is there a module for creating a web directory like Dmoz?

texts: I need to be able to organize different sets of content using the taxonomy. The user can visually click through the different layers of the directory and find what there looking for. I want to have full control over the way the categories are arranged and styled.


texts: How to use subgroups in drupal_add_tabledrag()

texts:
I am trying to implement a form that is themed with drupal table drag using subgroups. My form consists of a list of 'employees' that need to be assigned to different 'departments'. The order of the employees does not matter once they are inside a department.

The admin/structure/block table is similar to what I am looking for but with just the select box for region and no weights.

I've looked through the documentation here: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_add_tabledrag/7 and I've also studied the admin/structure/block table code but after several hours of trying different combinations - I am stuck!

The block module uses custom JS and a template tpl file for outputting the table. I think this doesn't take full advantage of Drupal. Therefore, this solution should make use of theme_table and #ajax (for the region select fields).


texts:
I'm using the basic Drupal Search module (search.module) and I want to customize the SQL of the search. I don't know how to go about doing this.

There are two things I want to edit in the SQL:

1) Have the search return ONLY nodes with start dates (event_start_date) AFTER now.

And

2) Return results in ascending order.

Pretty basic stuff.

Perhaps I need to use another search module entirely. I don't know.

Any thoughts or suggestions?


texts: Using Views Slideshow to display images with specific url links

texts:
I'm new to Drupal and I'm using version 7. I have created a Banner content type, to which I have added an Image field and a Link field (using the Link module). I have allowed theupload of multiple images, and adding of multiple links in this content type.

I then used Image Link Formatter module, which adds a formatter to display an image with a link. This works fine when I add a Banner content type and preview it. However, I want this Banner to be displayed by the Views Slideshow.

Unfortunately, I can't get things to display correctly when setting up a view block. If I choose to display the content, then it renders all the banners in a single slide (as might be expected). If I select the banner image field only, and choose the Image Link Formatter, it displays the banner images but not the links. I tried adding the link field as a hidden item too, however this has no effect.

As an alternative solution, I tried following this tutorial - here, it says to use the Rewrite Results option 'Output this field as a link' for the banner image, which I did and set to the link field. This didn't work as expected either though - the mapping multiplied the amount of banners, and output each banner with each link. For example:

Banner 1 - Link 1
Banner 2 - Link 1
Banner 1 - Link 2
Banner 2 - Link 2

What am I doing wrong here with the 2 approaches I tried, and what would be the recommended way to accomplish what I require?


texts: Can you get the itok value programmatically?

texts:
I appreciate the 7.20 security measure that requires a itok parameter for generating new images, but I need to expose that to Services / AJAX driven projects.

Can you get the image token programmatically so that JavaScript can build valid image urls for any size dynamically?

I would like to avoid $conf['image_allow_insecure_derivatives'] = TRUE; unless someone has a project to apply this same security measure on a user session level as opposed to per image


texts: How can I overidde html.html.twig in a module?

texts:
I have an application that is two parts: a website front-end and a restful back-end I can do with AngularJS.
The restful part is done by a module and I need to override html.html.twig.

How do I achieve this?


texts: Adding Ajax to Webforms in Drupal 7 - Ajax Submit

texts:
I'm using Webforms 3.x and Drupal 7.x.

I'd like to be able to use Drupal 7's Ajax features to provide a confirmation message via Ajax on submit.

To achieve this, I'm hoping to modify my form using a HOOK_form_alter.

The $form array provides the submit element at $form['actions']['submit']. If I add an ['#ajax'] attribute here, the action takes effect when submit is actioned by the use, and the callback function specified is called.

It seems that webform initiates two callbacks from

$form['#submit'][0] = webform_client_form_pages

$form['#submit'][1] = webform_client_form_submit

My question is, how can I initiate the necessary webform callbacks on Ajax submit?  I'm not totally familiar with webform, or how it deviates from standard FAPI (or if it does at all).

Any advice appreciated.


texts: How do I get the file path of a document?

texts:
I'm using views-view-fields.html.twig  to display content. I can print the file name using fields.field_module_field_name.content, but the code below outputs not only the file name, but also the path to where it's stored (It also displays the other fields in the module). I'm trying to take the path and set it as an href to the document for viewing/downloading.

I was tasked to complete this module.Everything about it is dynamic, so I need to be as generic as possible. Let me know how if more information is needed. I'll try my best to provide them.

{% for field in fields -%}
  {{ field.separator }}
  {%- if field.wrapper_element -%}
    <{{ field.wrapper_element }}{{ field.wrapper_attributes }}>
  {%- endif %}
  {%- if field.label -%}
    {%- if field.label_element -%}
      <{{ field.label_element }}{{ field.label_attributes }}>{{ field.label }}{{ field.label_suffix }}</{{ field.label_element }}>
    {%- else -%}
      {{ field.label }}{{ field.label_suffix }}
    {%- endif %}
  {%- endif %}
  {%- if field.element_type -%}
    <{{ field.element_type }}{{ field.element_attributes }}>{{ field.content }}</{{ field.element_type }}>
  {%- else -%}
    {{ field.content }}
  {%- endif %}
  {%- if field.wrapper_element -%}
    </{{ field.wrapper_element }}>
  {%- endif %}
{%- endfor %}

Sample output above would be in the following format.

status, title, date and time, file name, file path


texts: Unable to get all the sub-menu's in the data compare

texts:
I am trying to add a rule for comment view for which under the actions I click on data compare.As per the tutorial, I have to click the drop down list and choose node.

Whereas when I repeat the exact same steps from the Conditions->data compare I got some lesser menu option :

Now my problem is that as I don't have the node option to choose how am I supposed to complete the tutorial.

This kind of missing options appear quite frequently (when I tried to add an action/replacement patterns/ I had to choose the node type whereas in the options list there was no [node:type]. Again after 24 hours when I re-try this I get the [node:type])

I don't get the reason which is causing this problem. After doing the troubleshooting steps like re-login, clear browser cache, flush cache the options list is still the same.


texts:
I am trying to configure a site to send emails using the Contact Us form. At the moment, my understanding is that some PHP modules are required for that. I have already created the Contact Us forms and entered the 'recepient' addresses.

Could someone tell me how I should configure the PHP to do that? The site is running PHP 7.0.12


texts: Why do I need to use .live() in Drupal Behaviors?

texts:
I am trying to be a good boy and use Drupal Behaviors to manage my JavaScript. My understanding is that one of the advantages of using Behaviors is that it frees you from having to use .live() to bind event handlers to dynamically created elements. However, I find that I have to use .live() all the time. What am I doing wrong?

Here is a simple example of what I'm talking about:

Drupal.behaviors.MySearch = {

  attach: function (context, settings) {

    var searchBox = $('#my-search-box');
    searchBox.append("<input type='text'></input>");
    searchBox.append("<button>Search</button>");

    $('#my-search-box button').click(function(){
      console.log("This does not work.");
    });

    $('#my-search-box button').live('click', function(){
      console.log("This does work.");
    });

};


texts: What are Hooks in Drupal and can I learn and use them if I've yet to learn PHP?

texts:
Whenever I try to read about what are Hooks in Drupal, and how to manipulate forms or content with them, the text seem not to deal with the UI at all, but mostly with coding... Maybe I did not encounter the right reading material about UI-Hook relationship?

Can someone please detail in simple words and  a simple example?

What are Hooks?
Do you use them via UI or only through Coding?
Do I need to know PHP to use a module such as Hook form-alter?


texts: db_query or db_select for getting content type fields

texts:
Originally I was doing something along the lines of $query = "SELECT {}" and then $result = db_query($query). This method works fine for most of my queries until I needed to get the field values and fid from a specific content type. And then be able to call these values when printing inside HTML. Can anyone provide an example of how I would do this?

I had something along the lines of:

<?php
$query = "SELECT node.nid AS nid, 'node' AS field_data_field_news_node_entity_type, 'node' AS field_data_field_news_date_text_node_entity_type, 'node' AS field_data_field_news_teaser_node_entity_type, 'node' AS field_data_field_news_body_node_entity_type, 'node' AS field_data_field_news_video_node_entity_type, 'node' AS field_data_field_news_video_image_node_entity_type, 'node' AS field_data_field_mypdf_node_entity_type
    FROM node
    INNER JOIN field_data_field_news_is_featured ON node.nid = field_data_field_news_is_featured.entity_id AND (field_data_field_news_is_featured.entity_type = 'node' AND field_data_field_news_is_featured.deleted = '0')";
?>

$result = db_query($query);

<?php foreach ($result as $row) : ?>

    <div class="featuredArticle">
        <?php print $row->field_mypdf_value; ?>
        <?php print $row->field_mypdf_fid; ?>
    </div>

<?php endforeach; ?>


texts: Organic Groups - Group members list (with content profile) with views

texts:
http://ruh.kz/groups/ruhkz under the title - Участники группы - is placed a view block that displays members of this group. I've used a default view → og_recent_members, but it doesn't works for content profile. I need to display a CCK field from content_profile module.

Tried to set in filters - content type:profile, and in fields selected Content:field_photo, but it doesn't works. Displays nothing.

How to display CCK imagefield (Profile Photo) instead of usernames in og_recent_members views block?


texts: Turn off cron and hook_cron for every module in Drupal

texts:
How can I turn off cron and disable implement of hook_crons in every modules in Drupal
my site is Drupal 6
Thanks


texts:
First of all I'm using drupal 6.19.
I'm trying to add adsense on my site unsuccessfully. =/
I want to put my adsense on a CCK field but isn't working.
When I put the code on a block everything works fine. But in a CCK field I'm in trouble.
Both, block and CCK field, are set to input format FULL HTML.
I don't know why doesn't work in the CCK field. Can anyone help me?


texts: How to add ShareThis link field into View

texts:
I have a view and I want to add ShareThis(module enabled) link to each result of the view.
How this can be achieve so that any of the result row of the View will be shared on social networking sites.


texts:
I would like to allow user when creating new content (an event) to assign (from drop down) one of the locations defined in his profile (Profile2)... Is there a module which could help? If not any hint how to solve it in custom module?
Im thinking entity reference field could do if it was possible to create list of location for each user...
Maybe it is simple but beyond my drupal skills... ;)
Locations are nodes referenced with entity reference but not necessarily created by the same user


texts: How to show a Views attachment in other region or create a block acting as attachment?

texts:
I have a view with two displays: page and attachment. The exposed filters are the same for both the displays, and I used the Inherit exposed filters in the attachment settings.

I want to put the attachment in a specific theme region. How can I print the attachment in a different region?

The "pink" box is the attachment, which contains a Leaflet map. The user can select either one of the filters and see the results in the box map and the page below (node1, node2, node3, ...).

This is a screenshot of the view page as it is now.

Either of these solutions could work for me:

Be able to display the attachment display in another region, then the
page display under it
Have a block that functions in the same way as an attachment and
inherits all exposed and contextual filters in the way an attachment
would do

I tried to use views_embed_view() in a custom PHP block. The block shows correctly the attachment, but the filter doesn't work with the new block.

$view_name = 'indoor';
$display_id = 'attachment_1';
print views_embed_view($view_name, $display_id);

I think the problem is the AJAX parameter view_dom_id passed to the block.

This is what i want:


texts: Uploading images gives a "403 Access Denied" error

texts:
I just updated my site from 7.10 to 7.22 and now I am getting a Access Denied error on images that i'm uploading. My files folder is already 777 and everything else in there. Anyone know how to resolve this issue or what is causing it exactly?

I added the following into my settings.php file:

$conf['image_allow_insecure_derivatives'] = TRUE;

It got the images access denied error fixed, but this leaves your site insecure and undoes what it was suppose to secure.


texts: Feeds: how to populate a 'File' field from a path/filename in csv file?

texts:
I've got a csv file I'm using the Feeds module to convert to nodes.  It's going pretty well, but I have many documents (max of 1 per node, though) that need to be associated with my nodes.

I have the filename in the csv file (and can easily prepend any path necessary), but I'm having trouble figuring out if/how it is possible to get Feeds to match up the files.


texts: Hooks for altering Views block output in Drupal 6

texts:
I have a View in which i mention 3 fields then i displayed as a block.

I want to want to change value of these fields.

  Which hook will i use so i can change content to fields on page load ?

  I tried  hook_view, hook_block, they don't help me.

Thanks


texts: Cannot change date input format in views exposed filter

texts:
I am unable to change the date format for an exposed field in views. I am using BEF datepicker popup. I overrode the jquery settings to get it to enter a UK date in the dd-mm-yy format but because views is expecting it in mm-dd-yy form, the results of the filter are wrong.

This problem is addressed in this discussion https://www.drupal.org/node/1409120 but supposedly has been fixed for other people in Date 7.x 2.x. I am using BEF 7.x-3.0-beta4, Date 7.x-2.9-alpha1+2-dev, and Views 7.x-3.8, and the problem isn't fixed. I can't see any extra options in the view settings or in the config menu to change the date format.

The field name is field_activity_date_time and I have created a custom module with the following code, based on other stackoverflow suggestions (I don't have a max and min field, just a single date)

function hook_form_views_exposed_form_alter(&$form, &$form_state) {
    if($form['#id'] == 'views-exposed-form-test-page') {
       $form['field_activity_date_time']['#date_format'] = 'd/m/Y';
      }
    }
}

I have tried a number of different possibilities for the array key, such as 'activity_date_time', and 'views_field_activity_date_time', none of which worked. This date field is coming from a CiviCRM table which may be why the other suggestions haven't worked, but it feels to me more of a drupal problem than a civicrm one.

as suggested by harsh in the comments, I have used a different hook, but the problem still persists...

function HOOK_form_alter(&$form, &$form_state, $form_id){
  if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'test' && $form_state['view']->current_display == 'page') {
     $form['activity_date_time']['#date_format'] = 'd/m/Y';
     echo '<pre>';
     print_r($form);
     echo '</pre>';
 }
}

This gave me the following

Array
(
    ...

    [activity_date_time] => Array
        (
            [#type] => textfield
            [#size] => 30
            [#default_value] =>
            [#attributes] => Array
                (
                    [class] => Array
                        (
                            [0] => bef-datepicker
                        )

                )

            [#date_format] => d/m/Y
        )
)


texts: How can I prevent 'Error messages' to be shown to anonymous users?

texts:
Like any Drupal site, my site also shows red notifications from time to time...

The problem is that when these notifications are error messages, they appear at the bottom of the site in a new "Pseudo-reigion"... I use the term "Pseudo-region" because they establish a new "Region" under the site.

It's not really a region but rather a white area with an H1 and some text under it. It is displayed with the word "Error" (as a title, using a <h1> HTML tag), and the text below it is "The website encountered an unexpected error. Please try again later.". This is how it looks like in my site:

So my single aim is to not display these error messages (and this whole "Pseudo region" actually), at least for anonymous users, since it's uglyfies my site.

I've tried to use the following CSS syntax but with no success:

body.not-logged-in div.messages.error {display: none !important;}

This "error" pseudo-region is extremely problematic since it appears even in cases when I hide the notifications themselves via the "Disable messages" module.

I'm sure this error is native to Drupal but I've already tried everything I know to remove it, so any help is appreciated.

An important note

It's a long story why, but disabling the errors through /admin/config/development/logging doesn't help in this case. I'm looking for a solution which is either CSS, a Javascript (not jQuery) tweaking of the css by the text itself, or, some change in the Drupal PHP code that will prevent to program of printing this error.


texts: How to change URL alias when importing books?

texts:
I am importing some books and would like the url to reflect the category name i.e. sample.com/fishing-books/booktitle where fishing-books is the product category.

There is a field on the URL alias page (patterns): Default path pattern (which applies to all content types with blank patterns below) which I'm trying to make it work, but I haven't been successful. I want something like [cat]/[node:title], but it doesn't work.


texts:
according to current documentation of for change alter quicktabs should use this method
in my module

mymoule_quicktabs_alter(&$quicktabs){
    $quicktabs->default_tab=2;
   }

when i print result with dsm  it changed applied, but it not apply to visual output of quicktabs.

tell me how i can change quicktabs default tab ?
tnx


texts: I would like to be able to use a region which is to contain the title of the current node. In the default theme the title is output in the main content, but I want it in this custom region instead. But I cannot find a block for the node title. Can I create it?


texts: Unable to run update.php or update modules from web interface

texts:
I would really like to be able to install module updates through the web interface or run update.php when needed without changing settings.php, but something seems to be broken in my setup because it tells me I am not authorized to do so when I try.

In all attempts to make this work, I am using UID1, which besides any special properties that user has, it is an administrator which has the "Administer software updates" permission. In settings.php I have: $settings['allow_authorize_operations'] = TRUE; set explicitly, but I have also tried it in the default, not set, state which is also TRUE.

If I set $settings['update_free_access'] = TRUE; then I can run update.php, but that doesn't seem to help with the module updates and I would rather not have to change that setting every time I need to do an update.

I have tried all of the usual things I have seen mentioned including:
- Rebuild the user permissions
- Cleared the session table in the db
- Verified correct permissions on relevant files/directories
- Looked through various server logs for any obvious failures

My first real clue came from looking at the log an noticing that the "access denied" entry is tied to the anonymous user instead of the user I was logged in as. I have tried digging through the code a bit to see if I could track down where it is losing track of my user, but I am in a little over my head at that point. Obviously, the authentication is working in general because I am able to log in the admin site and do most things.

Has anyone had any idea why Drupal would lose knowledge of the logged in user just while trying to do update type operations?

Version: Drupal 8.7.6

Update:
I have looked a little more into the code to try to track down my problem. As seen from the logs, the problem is not that my user doesn't have permission but rather that when I run those specific actions, drupal momentarily doesn't see me as being logged in. In the file core\authorize.php there is a method that gets called: authorize_access_allowed(Request) which is mostly checking to see if the logged in user has the 'administer software updates' permission. In that method, it doesn't believe I am logged in. As far as I can tell, there are two ways it might pull the user out of that passed in Request (reading PHP_AUTH_USER out of the get headers or getting the UID out of a cookie). The get headers are definitely not there, and while there is a session cookie, it doesn't seem to be able to pull a UID out of it. I have not been able to find the code that parses the Session string.


texts:
I'm using breadcrumbs generally throughout my Drupal 7 site and all working well.

However, for news articles, I don't want to have to add each into the menu structure as over time, this will be a little out of control.

I'd like content of the type = news to have

Home > News > Title

with an active link back to my /news page.

Is this possible whilst still using the normal breadcrumb for other content?


texts:
I'm using the Services module to produce a REST API.  According to the official documentation, there is a way to version services resources.  I believe version here means supplying a single API (e.g. example.com/api) and allowing clients to specify which version they want per resource with headers.

So I think that means that these two requests would return different results, despite living at the same URL:

Version 1.0:

POST /api/v1/system/set_variable HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json

Version 1.2:

POST /api/v1/system/set_variable HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json
services_system_set_variable_version: 1.2

I cannot make this work for the life of me.  Here are the steps I took:

Enabled the system/set_variable service

Added the following code to mymodule.module (cribbed directly from services.versions.api.php)

.

function _system_resource_set_variable_update_1_1() {
  $new_set = array(
    'help' => 'Create a node with an nid test',
  );
  return $new_set;
}

function _system_resource_set_variable_update_1_2() {
  $new_set = array(
    'help' => 'Create a node with an nid optional prams.',
    'args' => array(
      array(
        'name' => 'name',
        'optional' => TRUE,
        'source' => array('data' => 'name'),
        'description' => t('The name of the variable to set.'),
        'type' => 'string',
      ),
      array(
        'name' => 'value',
        'optional' => TRUE,
        'source' => array('data' => 'value'),
        'description' => t('The value to set.'),
        'type' => 'string',
      ),
    ),
  );
  return $new_set;
}

Cleared cache
Attempted to use the system/set_variable service with postman.
Saw that the system/set_variable service was working

Attempted to use the system/set_variable  service without arguments, per _system_resource_set_variable_update_1_2
Saw that arguments were still required

So what am I doing wrong here?  I'm pretty sure I followed all the instructions.


texts:
I am new to drupal and I am realy stuck.
Module - Quiz
The scenario is - While taking quiz from app suppose i left it in middle and resume it from web then it is working fine but when i ends the quiz through my app it gives the result but again if i open it in web it goes to last question.

Pls provide some solution.

Thanks


texts: How to apply .diff and .patch file by SSH?

texts:
I use Drupal 7 and I read every article about applying patches, but I don't understand how to apply patches to Drupal files using SSH. I am administrator of a Linux server that hosts a Drupal site.

Can anybody help me?


texts: Is there a module that creates a jquery-like bar that displays system messages at the top of the page?

texts: Is there a module that creates a jquery-like bar that displays system messages at the top of the page. (exactly like the large, red bar on this site (stack exchange)?


texts: Making Twitter 1.1 API requests on site with OAuth and Twitter modules

texts:
I've setup a Twitter app and placed the appropriate Consumer Key and Consumer Secret strings in the settings of admin/config/services/twitter/settings.

I'm able to make twitter 1 api requests just fine, such as drupal_http_request('https://api.twitter.com/1/statuses/oembed.json?id=507185938620219395'); Using api.twitter.com/1.1, however, causes a 215 Bad Authentication error.

Obviously I'm not passing the necessary data to authenticate myself, but how do I go about doing that? All my google searching comes up with Drupal situations utilizing modules which do everything from the UI, or code examples which use php libraries such as Twitteroauth.

I should add that I am running a localserver test site and have setup my app's callback as both http://127.0.0.1:8000/twitter/oauth or the domain name I have setup in etc/hosts on my linux server. Neither seem to help, but both are accepted just fine in the twitter settings.

Lastly, I have been getting the following Notice on admin/config/services/twitter:

  Notice: Trying to get property of non-object in user_access() (line
  808 of /var/www/twitcher/modules/user/user.module). (as well as lines
  820, 821, 827 and 830)

I only began seeing this 2 days ago, and have been unable to figure out exactly what is causing this (I've seen other threads about the same notice, usually relating to Administrative Views, but nothing on the Twitter module).

What is preventing authorization here?


texts: Add class to template based on boolean field

texts:
I want to add a class to my custom Display Suite template if a boolean field is checked on the form. I have the following code:

if (isset($node->field_boolean_field[LANGUAGE_NONE][0]['value']) == 1 ) :
    $class = 'this-is-the-class';
endif;

And then in the appropriate place:

<a href="#" class="<?php print $class ?>">link

This always returns the class regardless of whether the boolean field is checked or not though.

link

Any thoughts on what I could be doing wrong here?

Many thanks


texts: Unable to add css class to a Panels region

texts:
I wish to add custom css classes to specific regions in a panels page.

I understand from this question Add a class to a panels pane
that I should be able to do this pretty trivially from the settings menu on the pane or region itself, however, there is absolutely no option to do so.

I am using panels 7.x-3.5 with Panels Bootstrap in Drupal 7.

No matter what layout setting I use - Boostrap, custom style etc - I never get any option to add css classes.

The boostrap settings has a handful of drop down boxes, the custom style settings has a heap of options but no ability to add css classes.

Do I need to over-ride a template somewhere? This should be trivial...


texts: How can I programatically prevent users from saving the same entity twice in a row?

texts:
My server sometimes gets overloaded, and sometimes people press the "Save" button on an entity creation page several times, which results in multiple versions of the same entity being created.

So, I want to prevent users from saving the same entity (an entity that has the exact same field content as the immediately previous entity saved by the user).

One fix is to get a better server.  I'm working on that.

Still, I would like to programmatically prevent users from saving the exact same entity twice in a row.  In my specific use case, this entity is a new private message from the Private Message module.

Is there a "best practice" way to do this?

Here is what I have considered.

On hook_entity_presave(), query the database and check if the last entity saved by the user had the same values.
Add an entity reference to the user profile for the last saved entity, and update the user profile entity reference field with the value of the new entity every time it is saved.  When saving a new entity, check it against the values of the entity reference entity.


texts: Modifying login/user panel position in a theme

texts:
For our site, we're looking at designing a relatively simple log-in widget/panel. We want it to be in the header of our site (for reference, we're modifying the excellent "Orange" Drupal theme), and we want to design it in the following way:

When a user is logged out, it merely shows the log-in form. It would sit in the upper right-hand corner, embedded in a rectangular shape.
When a user is logged in, it would show a "Welcome Back, $USERNAME$!", with an avatar, a message counter for private messages, and a few links for managing a profile, accessing a shopping cart, etc.

My question is, where do I start with all of this? As far as I'm aware, documentation for this type of thing appears to be a little bit sparse. What do I need to do in order to set up this small widget so that it:

Sits in the correct position.
Displays the user avatar, links, etc.
Replaces the default log-in form?

Do I need to go into Panels and Views and try to build a custom log-in form there? Do I need to write it all in CSS and jQuery? What's the best way to approach this?


texts: What is the purpose of the ['moved to'] array variable in Views $data array?

texts:
I'm learning how to do views handlers and looking over a few modules and noticed that there is a 'moved to' array variable set sometimes. I have the following line in the bulk views operations module:

$data[$info['base table']]['views_bulk_operations']['moved to'] = array('views_entity_' . $entity_type, 'views_bulk_operations');

What is this line doing by setting the 'moved to' array to array('views_entity_' . $entity_type, 'views_bulk_operations') ?

Below i have a new handler I made by copying similar part of the code from the bulk views operations module into the flag list operations module and changing a few things. When setting the moved to array, it breaks the above handler. why and what is the purupose of the moved to array setting?


texts:
When i dpm that $vars, in classes key, there is no r_style class, whyyyy? I tried clear cache through devel module, but still the same, what i am doing wrong?

name = JH Template
core = 7.x
engine = phptemplate

styles[all][] = css/style.css
settings[bg_style] = 'r_style'

theme-settings.php

function jh_process_html(&$vars) {
    $vars['classes'] .= ' ' . theme_get_setting('bg_style');
    dpm($vars); // in classes string isn't r_style class
}

EDIT: the real question is, why theme_get_setting('bg_style') returns NULL

SOLVED: that jh_process_html function must be in template.php file, but i don't understand that drupal :D, because that function was executed even in if it was in theme-settings.php, but actually just sometimes and it causes some fails like that theme_get_setting returned null. I don't know why this happened, but it's really funny after so many years of development of drupal, this magic happened.


texts:
I need to implement the functionality of sorting the content listed to the user based on attributes like alphabetically, popularity or price (ascending/descending). These attributes can also be custom. I need to have it has a widget. I don't exactly know what this functionality is called so apologies if I'm not being clear.

I also need to display text like "Displaying % of %" on top the list which, as far as I've seen, views don't do by default.

An example could be this website.

I'm using Drupal Commerce (D7).

So is there a module for this?


texts:
I'm trying to use the links__system preprocess function to output a menu as a select element, unfortunately though $link['href'] appears to output the URL in a format like:

node/2

Even though the URL alias is set to something like:

nice-url

The code I'm using in my template.php file is as follows:

function THEME_links__system_MENU_NAME($variables) {
  $html = '<select name="" id="dropdown-menu">';
  $html .= '<option class="" value="home">Select Item</option>';
  foreach ($variables['links'] as $link) {
    $html .= '<option class="" value="' .$link['href'].'">'. $link['title'] .'</option>';
  }
  $html .= '</select>';

  return $html;
}

I've had a look at the $variables variable passed to this function, just to make sure I'm not referencing the wrong thing - but it doesn't appear to contain any other items in the array that contain the correct URL alias.

When using the default menu code output by Drupal it picks up the URL aliases and uses them.

What am I doing wrong here?


texts: Redirect comment permalink to their corresponding node paths

texts:
Is there any way in drupal to  redirect comment permalink to their corresponding node paths or url alias?

I want to redirect all comment/x paths to their corresponding node-path. And it should handle pagers as well. If your comment is in the second page (when you have set a comments-per-page value in node type settings), it should be like

http://example.com/comment/111 to http://example.com/node/123?page=1#comment-111

http://example.com/comment/111 to http://example.com/node/123#comment-111
http://example.com/comment/112 to http://example.com/node/123#comment-112

Thanks in Advance!


texts: HTML tags being removed after theme_preprocess_node

texts:
I am using theme_preprocess_node to modify an HTML tag, but the tag is being stripped somewhere in the theme layer.

mytemplate.twig

{% if node.field_embedded_media.value %}
  {{ content }}

mytheme.theme

    function mytheme_preprocess_node(&$variables) {
      if ($variables['view_mode'] == 'ebook_export') {
        $contentBody = $variables['node']->get('body')->value;

        $pattern = '/<drupal-media/';
        $replace = '<drupal-media data-view-mode="markdown_link"';
        $contentBody = preg_replace($pattern, $replace, $contentBody);

        $variables['content']['body'] = array(
            '#markup' => $contentBody
          );
        }
     }

Original input (node body value):

<drupal-media data-align="center" data-entity-type="media" data-entity-uuid="269d4491-9866-403c-90e3-c1298e9857de"></drupal-media>

This is some text.

<drupal-media data-align="center" data-entity-type="media" data-entity-uuid="269d4491-9866-403c-90e3-c1298e9857de"></drupal-media><pre>

This is some more text.

dpm($contentBody) in mytheme_preprocess_node (this is what I want to output, and it's correct here)

<drupal-media data-view-mode="markdown_link" data-align="center" data-entity-type="media" data-entity-uuid="269d4491-9866-403c-90e3-c1298e9857de"></drupal-media>

This is some text.

<drupal-media data-view-mode="markdown_link" data-align="center" data-entity-type="media" data-entity-uuid="269d4491-9866-403c-90e3-c1298e9857de"></drupal-media>

This is some more text.

Actual HTML output on page render (this is what I get, and the <drupal-media> tags are gone)

This is some text.

This is some more text.

The <drupal-media> tags got stripped.  How do I prevent them from being stripped?  I don't understand enough about the theme layer to determine where this is happening.


texts: Generating a random number without duplicates on blog comment

texts:
A section of my site is a blog where I allow comments. Each comment has a thumbnail associated with it. If the commenter is a user, then their profile photo is used. If they are anonymous I have a pre-determined photo in place. I want to be able to randomly generate a thumbnail for these anonymous users, but also have no duplicates.

I asked this question here and now have a random thumbnail being generated, but the problem is that there are still duplicates. And it looks like because the comment.tpl.php file is being read on each comment that the random numbers are not being remembered.

How can Drupal remember the number so that it doesn't use it again?

My Code:

$numbers = range(0, 19);
shuffle($numbers);

print "
";
print "";
print "
";


texts: How do I add a node add link ( for a different content type ) in the node add form (drupal 7)

texts:
I'm overriding the node add / edit form using panels. One of the fields that I have added is using the auto complete widget (it is a node reference field). I also want to add a link underneath the autocomplete field to add a new node (one of the referenced nodes). I'm wondering if there is a way to add this link.

If it's not possible within panels, perhaps it is possible someone can give me an idea of how to add this sort of link to node add form using templates.


texts: Overwriting database with backup from older Drupal version?

texts:
I have a database from a live site I need to bring over to a development site.

live site = d7.7, outdated modules, but is obviously up to date with all the recent ubercart orders

dev site = d7.15, all modules updated, but is missing the latest ubercart orders

I had been migrating the live DB over to the dev site periodically, but now that the dev site is running newer modules and core, I'm wondering if its still safe to move migrate the database from the live 7.7 site.

can I migrate the database and simply run update.php afterward to catch up?

ubercart orders are really the only thing im concerned about. also, ubercart is one of the modules that has been updated on the dev site.

Complete list of modules that have been updated on the DEV site. Some of these required the running of update.php

Drush
CTools
Ubercart
Views
Entity
Token
Securepages
Rules
Admin Menu
Node Export
UUID
Pathauto
Gallery formatter
Twitter Pull


texts: Replacing a certain character pattern in a textfield when saving an entity

texts:
I got an entity type containing a long text field. If a user types in a certain character pattern ("xX" for example), this string "xX" should replaced with "×" (the proper symbol for multiplication) after saving the entity.
I looked at hook_field_presave and hook_field_attach_presave but don't know how to use correctly.

This is the code i tried in a custom module:

function replace_multiplication_symbol_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($field['name'] == 'field_technical_description') {
    foreach ($items as $delta => $item) {
      if (isset($item['value'])) {
        $items[$delta]['value'] = str_replace('xX', '&times;', $items[$delta]['value']);;
      }
    }
  }
}


texts: Displaying a list of image thumbnails, with click-through

texts:
So, a few days ago I asked this question, Drupal 7 Site for Displaying PPT or JPG.  Since that time I have been studying up on Drupal 7 and learning more about what I REALLY want.

Here's what I am trying to do:

Upload a bunch of images (around 150)
Have a number of pages which list images including a thumbnail and comments.  (These pages are roughly 'image galleries', I think)
Let users browse each of the 'galleries'/lists, and click through on the ones they want to view in detail.  Also, users can add comments at this point.
If the user saves a comment or clicks a back button, they return to the gallery/list

So, I think I need to create a new content type for the images, including comments.  Then a View, which displays as a list.  Does this sound right?

Also, what's the best way to create each of the image nodes?  Do I need to use the Insert module?  And upload the images one by one?

Any pointers much appreciated!


texts: I am using og_menu 7.x-3.x-dev I am trying to create some default links to the og menu, but links are not adding.With a new group node its creating the og menu but the default links are not coming.Do I need to apply any patch? Thanks in advance. On the og menu settings page I have checked the "Automatically create a OG Menu for new Organic Group" checkbox and in the default links section I have tried adding absolute url and internal drupal path but no success.Am I missing some settings.


texts: Why am I unable to send an email order using the Ubercart and Smtp Authentification module?

texts:
After Ubercart checkout submitting order, I get this error:

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

I am using the SMTP Authentication Support module, I configured it correctly. Test mails work. So the error lies probably within Ubercart.

On Drupal /admin/reports/dblog, I get this interesting error log:

  Error on sending e-mail (from admin@xxxxx.com to
  admin@xxxxx.com.com).

it tries to send the mail to the sender mail? Very weird!

How to get this resolved?


texts:
I have a view slideshow that I managed to set up by following these instructions.

I want to use a responsive slider plugin instead of the jQuery Cycle plugin in Views Style Settings. How can I use this JavaScript code to create the slideshow.


texts: How to place all form buttons on top of the page, before the form, in all forms?

texts:
Since these forms can get quite big sometimes, especially with a lot of files attached and default preview for them.

Related, but not the same: How can I display a form button on top of the form?


texts:
Looks like we have two versions of jQuery loading. Hence the "(...).once is not a function" errors in the console. jquery.once is definitely loaded but only for the first version of jQuery.

Nightmare.

How do I track down where the second one is coming from... (rhetorical question)?

~~ FIRST UPDATE

Having established this is a theme problem, what could be missing that would prevent selected files from uploading with the rest of the comment?

~~ ORIGINAL POST

This has me completely stumped.

I have attached a file field (not media, for reasons) to a comment type.

I attach a file to a new comment, and save.

The comment is saved. The file is not. And there are no errors. None.

Nothing in the Drupal log at all.

It's not a permissions error, because no error message and because I tried with a node type and that worked fine. I've tried both private and public, same thing.

Examining the DB shows that there is nothing in the field table, or in the file table.

The files I'm using are test files I use all the time, they aren't too big just standard PDF files. (And the file type is correct - but like I said, there are no error messages anyway.)

We are doing some fancy stuff with themes, but for the file field only standard Drupal formatting is being applied. (I checked thoroughly with Twig debug switched on.)


texts:
I have some records imported to my module tables. Some of this data is synchronized to drupal nodes by creating and updating existing nodes of specified type. This operation is made each time new import is done. The problem is, it produces around 60 000 nodes for every new import and it is quite a lot. Synchronization takes hours and operations through Views takes ages or crashes.

Is there any way to store my data only in my tables and serve them from this tables as nodes? Some way to only creates nodes with some properties set as language and title, and then provide data for fields directly from my tables?


texts: 'Any' result set for Exposed Filter w/ limited list is not limited

texts:
I have an exposed filter for a taxonomy vocabulary. The filter settings are

Single Filter
Operator: Is one of
Limit list to selected items: On
Selected vocabulary terms: a subset of the full, flat (non-hierarchal) vocabulary

Assume selected terms term1, term2, term3
Assume non selected terms non1, non2, non3

The filters UI appears and is accurate, and it is functional when a filter is selected. However, when the - Any - option is selected, all objects from the vocabulary are displayed - all of the term# objects are displayed along with the non# objects.

I've tried adding a second (non-exposed) filter that does is one of for each of the term# terms. With this, the - Any - option is correct but none of the other selected filters in the drop down work.

How do I get only the selected term# elements to show when the - Any - option is selected?


texts:
I would like a different set of twig templates be used for all content that exists on a sub-domain of a website regardless of content type.

eg:

mysite.com/article (Main site theme)
sub.mysite.com/article (New templates)

Is there any way to do this?


texts: looking for views gallery module compatible with lightbox module

texts:
I would like to achieve a behaviour like this:

At the bottom of the screen there are thumbnails. Above them is a big image styled for 800x600 which changes after clicking a thumbnail. When the user clicks on the big image, then an overlay with lightbox opens and the image is not 800x600 but full size, scaled to screen. There are working Next and Previous buttons on the lightbox (not necessarily linked to the underlying thumbnails gallery).

How to achieve it? I am interested in a solution working either out of the box or having  clear tweak instructions. Any gallery module and any lightbox will do, as long as they are compatible and have next/previous buttons working.

So far I tested Views Galleriffic and Lightbox2 and Colorbox, using patch from here and I managed to open the big image in original size using lightbox2 and colorbox. However, Previous and Next buttons are not working in either case.


texts:
I would like to disable the cache of that specific part of the node content.
Is it possible?

I'm aware I can disable the cache for the node itself using:

$build['#cache']['max-age'] = 0; // users
\Drupal::service('page_cache_kill_switch')->trigger(); // anon users

But I indeed would need to only deactivate for the body content.

Any ideas?

Thanks


texts: How do I add a class to a specific input type?

texts:
Using Drupal 8. I am trying to add class="input" to an input with type="text"; any other type (i.e type="button") should not have that class added. I modified input.html.twig to the following:

<input{{ attributes.addClass('input') }}/>{{ children }}

The problem with this is that it adds the class to all input types. Is there a way to specify the input type in which the class should be added in Drupal 8?


texts: Advice on how to fix Workbench Moderation error messages

texts:
(n00b drupal person)

I seem to be suffering the problems described in https://drupal.org/node/1966908 and https://drupal.org/node/1966920.

Basically I have installed the following:

drupal-7.26.tar.gz
media-7.x-1.4.tar.gz
views-7.x-3.7.tar.gz
ctools-7.x-1.3.tar.gz
workbench-7.x-1.2.tar.gz
workbench_access-7.x-1.2.tar.gz
workbench_media-7.x-1.1.tar.gz
workbench_moderation-7.x-1.3.tar.gz

It all seems to be configured OK, but when I switch to My Workbench -> Create Content I get the following warning/error message:

  Notice: Undefined index: #contextual_links in
  contextual_pre_render_links() (line 140 of
  /home/apache/drupal-7.26/modules/contextual/contextual.module).

  Warning: Invalid argument supplied for foreach() in
  contextual_pre_render_links() (line 140 of
  /home/apache/drupal-7.26/modules/contextual/contextual.module).

  Notice: Undefined index: #contextual_links in
  contextual_pre_render_links() (line 140 of
  /home/apache/drupal-7.26/modules/contextual/contextual.module).

  Warning: Invalid argument supplied for foreach() in
  contextual_pre_render_links() (line 140 of
  /home/apache/drupal-7.26/modules/contextual/contextual.module).

  Notice: Undefined index: #contextual_links in
  contextual_pre_render_links() (line 140 of
  /home/apache/drupal-7.26/modules/contextual/contextual.module).

  Warning: Invalid argument supplied for foreach() in
  contextual_pre_render_links() (line 140 of
  /home/apache/drupal-7.26/modules/contextual/contextual.module).

Would very much appreciate some help with:

Confirmation I've got the right bugs
Some advice on fixing it... should really be using git patch rather than installing the updated modules to fix ?


texts: How to include javascript, which is dependent on an external library, to a page rendered by a custom module?

texts:
Edited

I want to draw an SVG circle on my page with d3.js. I have constructed a skeleton custom module and I am returning the following render array from src/Controller/MyModuleController.php:

namespace Drupal\my_module\Controller;

class MyModuleController {
  public function myModule() {
    return array(
      '#markup' => '

',
      '#attached' => array(
        'library' =>  array(
          'social_statistics/circle',
        ),
      ),
    );
  }
}

In my libraries.yml (located in the root of my module folder) I have:

circle:
  js:
    circle.js: {}
    dependencies:
      - social_statistics/d3

d3:
  remote: https://d3js.org
  version: 4.x
  license:
    name: BSD
    url: https://opensource.org/licenses/BSD-3-Clause
    gpl-compatible: true
  js:
    https://d3js.org/d3.v4.min.js: { type: external, minified: true }
    # d3.min.js: { minified: true }

In circle.js, (also located in the root of my module folder) I have:

d3.select("#data-vis")
  .append("svg")
  .append("circle")
  .attr("cx", 30)
  .attr("cy", 30)
  .attr("r", 20);

I'm getting the below error in the console, which suggests circle.js is being loaded, but not the d3 library dependency?

  Uncaught ReferenceError: d3 is not defined


texts: "admin/content" filters not available anymore

texts:
In the Content page (/admin/content), in Drupal 7 there was a feature allowing to filter by content type, status or language:

It doesn't seem to be available anymore in Drupal 8.

Someone know if there is a module recreating this feature?


texts: Display price on Views for product variation

texts:
I'm confused, how to display on Views just one price for product with variations? I have product with 2 variation, and both prices are displayed, like:
Price: 1-Price for 1-Variation-Product , Price: 2-Price for 2-Variation-Product
I mean the created from me some custom view-page, like "/all-products" (like some catalog page) where are displayed all of products or goods with their prices. And for the products with variations I see, that there will be displayed all of prices of this product.
In the Settings of View-Page ("/all-products") I have in Format section: "Show:Fields | Settings".
In RELATIONSHIPS:
Variations: Product variation
(Variations: Product variation) Product: Product
And in Fields I have:
(Variations: Product variation) Product variation relationship: Price
where in the Setting I have:
"Use entity field rendering"
There are no Setting to handle multiple values.
If I check out "Use entity field rendering" then will be shown some settings for handling of multiple values, but in this case it will be no price displayed on view-page (/all-products), because the prices are rendering from product entity, as I understand.
So, this is the problem
In addition: the product with variation has all the same price, not different prices for different variation.
What is teh best way to handle it?
I have Drupal 9, Commerce 2
Thanks


texts: LoadTest fail due to "chmod(): Operation not permitted"

texts:
I downloaded and installed a new Drupal 8 site via Composer.
I generated a new module using Drupal Console.
I tried running a phpUnit functional test of the newly generated module, and it keeps failing due to some folder permission:

  Exception: Warning: chmod(): Operation not permitted
  Drupal\Component\PhpStorage\FileStorage->createDirectory()() (Line: 168)

What grind my gears is that it was working OK a few days ago. Something is clearly wrong with my system, I just don't know what that is, or what changed since then.

I'm running a WSL with Apache 2.4.37 (PHP Version 7.2.12-1+ubuntu18.04.1+deb.sury.org+1).

I have all the detailed steps to reproduce the case, my full phpinfo, and some more relevant information in this gist I created.

I spent the last few days browsing for a known solution, and some cases appear to be similar, but none of them seems to hit the spot.

I am using Windows 10.0.17134.407; the tests from the browser are passing. All the files and folders on the project are owned by 'zoio' (user and group); the file permissions for folders and files in modules, sites/default/files, and sites/simpletest are set to 0777.

I tried to follow the tips on this WSL issue, but I just ended up with a different failure, still related to permission and ownership.

  Drupal\Tests\sandbox\Functional\LoadTest::testLoad()
  Exception: User warning: mkdir(): Permission Denied
  Drupal\Component\PhpStorage\FileStorage->createDirectory()() (Line: 174)
   /mnt/c/www/temp/d8_temp/web/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php:51 (...) /mnt/c/www/temp/d8_temp/web/modules/custom/sandbox/tests/src/Functional/LoadTest.php:33
  ERRORS!
  Tests: 1, Assertions: 1, Errors: 1.


texts: User input dropdown list sanitization in drupal 7

texts:
For Drupal 7.
I  am using a custom search form with more than 6 drop-downs. I would like to sanitize the user select value before passing to the query.Now a days there are many tools available to edit the option value and inject some malicious codes(Firebug etc.).

I tried to validate user input by  mysql_real_escape_string($_POST['field_value']);But mysql_real_escape_string  returns no output or not working .May i know what is the real issue?.Could you please help me to validate user inputs?

thanks...
hary


texts:
I'm currently using Drupal 8.2.3 for my website design. My aim is to use it for publishing my blogs to social media sites, such as Facebook, Twitter, LinkedIN, etc. With that in mind, i'm using image styles to create OpenGraph and Twitter meta tags in my blog posts to properly display content on various platforms.

The problem comes when I make a change to the imagestyle. When I flush the contents, it doesn't automatically regenerate the imagestyle content for my metadata. Is there a way to automatically regenerate the imagestyles and content?

Any help much appreciated.


texts:
I am looking a module which will give each user an option to create links to various social networks profiles they have.

I found Follow module but for D7 it says it is very unstable.


texts: User name in view arguments and title of page

texts:
I created a content type named "Post" and allowed certain roles to add posts on my website.

I also created a view that displays these posts, as a page and block view.
Now, I want to add a contextual filter to display posts from specific authors, but in filters I find only the author UID so that my URL is post/1 and so on. Is there a way to have user name instead of user ID as wildcard in the URL?

I also want to set the page title such as "Posts of [user-name]", but I don't know if it is possible to do.

I'm very sorry, but I googled for this but I found nothing.


texts: How to add css class to these form fields?

texts:
I wan to be able to add certain css class to all the text fields in my content edit forms. here is a picture of what i can see using Devel:

Those arrays under the "Und" are for the fields I want to add the class. I have tried to do this with the following:

function iclub_form_article_node_form_alter (&$form, &$form_state) {
dpm($form);
$form['field_body']['und']['0']['#attributes']['class'][] ='addRecactor';

foreach ($form['field_paragraph']['und'] as $i) {
    if (is_numeric($i)) {
        echo $i .'</br>';
        $form['field_paragraph']['und'][$i]['field_myparagraph']['und']['0']['#attributes']['class'][] ='addRecactor';
        foreach ($form['field_paragraph']['und'][$i]['field_myparagraph']['und'] as $y) {
            if (is_numeric($y)){
                $form['field_paragraph']['und'][$i]['field_myparagraph']['und'][$y]['#attributes']['class'][] ='addRecactor';
            }
        }
    }
}

but this does not work for all the fields and I think it is not the solution as it is not robust.

How may I be able to add the class to these fields?


texts: How to set value after the page redirecting?

texts:
My scenario is set Taxonomy value after the page redirected.

if(($weight === "Above 90") && ($height === 'Above 7.0"')) {
    $form_state['redirect'] = $base_path . '/example/other/redirect-1';
    $term = taxonomy_term_load('371');
    // echo '<pre>'; print_r($term->description); die;
    print render($term->description);
 }

Here, Once the condition is satisfied, its redirecting to the (/example/other/redirect-1)page.  But, the Taxonomy value is not displaying in this page.

I am not sure, whether I am doing in a right way, or Please guide me to solve this issue ?


texts: Main Navigation Menu: Throwing out the old and making a new

texts:
I've fought blood, tooth, and nail with the built in Main Menu in Drupal 7, and finally I've given up.

What I've done instead is implemented a block which I've placed into the Main Navigation area, and used pure CSS to control the menu. So far, I think it looks and works great.

There's only a few problems:

The company which I am writing this site for has a few users with administrative privileges whom only have a very small and limited knowledge of HTML.

I've installed the CKEditor (WYSIWYG HTML editor) module for the blocks, which has made everything much easier for them, but whenever they edit the raw HTML for the menu (which they don't like doing) this editor removes all of the CSS classes from the menu and destroys it.

Also, because of my block approach to the menu, they don't have the very nice Configure Links page that you would have with the built in menu.

What I would like to do:

I would like to make a new menu module which will work like the built-in Main-Menu, yet not extend it (I've tried both Superfish and NiceMenus, both of which extend the built-in menu, essentially inheriting all of its bugs).

I would like to make a Configure Links Administrative Page that will allow an administrator to configure the links as you would for the built-in main menu.

My Question:

Does anyone know how to view the source for the Main-Menu module, or if a replacement Main-Menu module exists that I can cut and hack apart?

So far, I haven't been able to find any of the source for the Main-Menu module or any replacements. I've only found extension modules like Superfish and NiceMenus.

If nothing exists yet, would anyone be able to point me in the direction of where to start, or (this may be too much to ask) walk me through how to do it and work on this project with me? I am very new to Drupal (I didn't know what it was two months ago) yet I have some extensive knowledge in software engineering.

I understand this has been tried several times, and proposed several times, yet I've not been finding any follow-ups to these questions. I thought this post might have been helpful, but I felt like I was just running in circles after reading it...

Thanks for the help everyone! I'll be looking forward to your responses!


texts: Any flexible customizable theme for display configuration via panels?

texts:
Recently, I have been trying to design pages using panels and mini-panels. I followed some tutorial online, but the method used was a bit questionable. Since I am a newbie at this, I crashed my system beyond all repair, lol, but I managed to export valuable configuration and reload it on a fresh install. So, I am happy enough with that...

I have been playing with changing colors under Bartik, but honestly, that won't be enough...

I am looking for a flexible theme that will allows me to easily design the layout of pages from scratch using panels (most preferably). Ideally, I should be able to configure colors and fonts easily and the basic template should be simple and elegant. I want to load my own pictures to customize it (i.e., no preloaded pictures or they should be made removable).

Basically, the site is about sharing tips. Users will be able to put comments and vote for posts made by an editor. Nothing crazy.

Does anyone have a good recommendation to make for Drupal 7? Is there any such thing as a newbie-proof template? Thanks.


texts:
I'm trying to execute a python script from Drupal using this:

exec('/usr/bin/python name_of_the_script.py')

But it does not work. Although, if I'm on the php console (php -a), then it works fine.

The name_of_the_script.py file has all the permissions.

I thought maybe it was the python command that didn't have all the permissions.

So I checked it with this command:

which python
ls -lisa /usr/bin/python

  694 0 lrwxrwxrwx 1 root root 9 2011-03-09 18:41 /usr/bin/python -> python2.6

Similarly I also used this command:

ls -lisa /usr/bin/python2.6

  369 2240 -rwxr-xr-x 1 root root 2288240 2010-04-16 10:06 /usr/bin/python2.6

It seems everything is OK.

Do you have any suggestions?


texts:
I want to have an URL which calls a View, for instance:

www.example.com/products

This will be the URL for a View called products_list

If I want to filter the products by category, I could clone the View page, add a Contextual filter based on Taxonomy, and with a URL indicated as /products/% I could use

www.example.com/products/Brand-1

to filter the products of brand "Brand 1".

But what if I want to use a completely different View, with a layout different from the above, for just the special case of some brands, i. e.,

www.example.com/products/Special-Brand

I want the above URL to use a completely different View. How can I manage to do that in the simplest possible way?


texts:
I am getting the following error on my D7 site:

PDOException: SQLSTATE[40001]: Serialization failure: 1213
Deadlock found when  trying to get lock; try restarting transaction:
INSERT INTO {node} (type, language, title, uid, status, created, changed, promote, sticky)
VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2,
:db_insert_placeholder_3, :db_insert_placeholder_4,
:db_insert_placeholder_5, :db_insert_placeholder_6,
:db_insert_placeholder_7, :db_insert_placeholder_8); Array
(
[:db_insert_placeholder_0] => baby_clothes
[:db_insert_placeholder_1] => und
[:db_insert_placeholder_2] => Boys clothes and swing
[:db_insert_placeholder_3] => 1
[:db_insert_placeholder_4] => 1
[:db_insert_placeholder_5] => 1333240131
[:db_insert_placeholder_6] => 1333240131
[:db_insert_placeholder_7] => 1
[:db_insert_placeholder_8] => 0
)

in drupal_write_record() (line 6975 of includes/common.inc).

I have a module that saves nodes programatically on cron run.  There is the possibiliy that two nodes could save simultaneously.  Is that what could be causing this? The table locking mechanism is not working correctly to prevent collisions? If I put the site in maintenance mode and just run the batch of nodes to be saved, this never happens. Thoughts? thanks!


texts: How to set a multi-value image field's default value from author's profile field on a node create form?

texts:
On /admin/config/people/accounts/fields page, there is an optional multi-value image field field_proof_images. There is a content type Proof, I reuse the field_proof_images in Proof.
Then on /node/add/proof page, I want the field_proof_images to be automatically filled with the images from field_proof_images in the user accounts.

How to make this in Drupal 7?


texts: How to utilise watchdog or how to debug webform error

texts:
I have a webform that integrates into CiviCRM such that the webform is used to save data into the Civi system.  The following error is generated when hitting submit (although data is saved in the results tab of the form):

The lease helpful error message in the word - unless you only have one field =/

Any ideas as to how I can decipher which field is causing the issue e.g. use Watchdog or something to see what the query is or why the error is appearing.  I don't have access to the mySQL server logs.


texts:
Drupal 7. WYSIWYG module, CKEditor as chosen library, Video Filter module.

When I manually type in the video filter code, it works. When I add the video filter button to the toolbar for my CKEditor profile, it works. But when I go to enter content and I click the video filter button in the CKEditor toolbar, it opens a new window and attempts to access a page that doesn't exist on my site, giving me the error The requested page "/video_filter/dashboard/wysiwyg_ckeditor" could not be found. Googling the error is unhelpful.


texts: How do you programmatically hide a field based on another field on a custom content type?

texts:
I have built a custom content type that has a boolean field called 'Hide images'. There is also an images field that displays all images at the bottom of the node. I'd like to setup a way so that depending on the 'Hide images' field I can decide whether to display the images field. Is there a way to edit this via a template?

I saw in page--node--contenttype.tpl.php that I could render($page['content']); but I couldn't actually see how I could choose what content to display.


texts: How to transfer field content of a view to a another view as a filter by clicking this content entry

texts:
Example:
View 1, field "city", content "Berlin"
By click on "Berlin" ->
opens View 2 (filter on "Berlin") in a separate block.
Is this feasible? How do you do that?

Btw: activating the second view in a block by a click - it seems impossible, isn't?
Which way: Make view per page and then -> into a block???


texts: Adding a validation step via hook_form_FORM_ID_alter()

texts:
I am trying to add a custom validation function to an existing form. I am using hook_form_FORM_ID_alter() to edit the form. I am then adding a new function to the #validation array. When I use dpm()  and print out $form['#validation'] I can see that my function is there. However the validation step is not running. If I dpm() in the validation function it is not hit.

/**
 *  Implements hook_form_FORM_ID_alter().
 */
function mymodule_form_mycustomdorm_form_alter(&$form, &$form_state, $form_id) {
    $form['#validate'][] = 'mymodule_test';
    dpm($form['#validate']);
}

function mymodule_test($form, &$form_state) {
  dpm($form_state);
}


texts:
Can somebody help mi with use of node_type_get_types() in Drupal 8?

Code in Drupal 7

function node_type_get_types() {
  return _node_types_build()->types;
}

Code in Drupal 8

function node_type_get_types() {
  return NodeType::loadMultiple();
}

This was my code in Drupal 7. How to now use node_type_get_types in Drupal 8?

$options = array();
  foreach (node_type_get_types() as $type) {
    $options[$type->type] = $type->type;
  }


texts: I have this issue on my drupal status report. How do I get rid of the warnings on Advagg?


texts: Print a list of checked form options in TWIG

texts:
I need to print out a list of checked form options in a TWIG template in Drupal 8.

I'm using Better Exposed Filters, and editing the views-exposed-form.html.twig template.


texts: How to access all of the properties related to Commerce Line Item entity in a rule?

texts:
I wonder how I can access all of the line item properties in Rules?

For example in a Rules event "Before saving a line item" I can show a debug message of the line item.
It has different properties such as commerce_display_path and data->context->entity which however aren't available in Rules ie. I cannot set them as variable for later processing.

How could I make these properties available to Rules? I've tried to add different conditions to make sure the "whole entity" is loaded to Rules but still I cannot access these properties.

EDIT 1

I've now tried to develop a solution to provide this data to Rules.
Following enables only entity(field collection item) id and entity revision and nothing else. I thought that it would provide the whole entity and it's properties (or at least so I understood from documentation that all that entity__property_info returns).

EDIT 2

Now I can set a message on site that presents host entity properties. However, I cannot use those properties in any other rules functionality eg. I cannot create variable from field regarding field collection item i.e. I still cannot make use of them. Why the properties are available for message but not for anything else?

function mymodule_entity_property_info_alter(&$info)
{
  if (isset($info['commerce_line_item'])) {
    $info['commerce_line_item']['properties']['host_entity'] = array(
      'label' => 'Host entity',
      'type' => 'field_collection_item',
      'description' => t('Host entity of a line item.'),
      'getter callback' => 'mymodule_get_host_entity_callback',
      'setter callback' => 'entity_property_verbatim_set',
      'computed' => true,

    );

 $bundles['field_collection_item'] = array('label'=>'Field collection item', 'properties'=>entity_get_all_property_info('field_collection_item'));
    dpm($info['commerce_line_item'], 'line item in entity info alter');
  }
}

function mymodule_get_host_entity_callback($entity, array $options, $name, $entity_type)
{
  dpm($entity, 'line item entity in Rules callback');
  $wrapper = entity_metadata_wrapper($entity_type, $entity);

  $host_entity_id = $wrapper->data->context->entity->entity_id->value();
  $host_entity_type = $wrapper->data->context->entity->entity_type->value();

  $host_wrapper = entity_metadata_wrapper($host_entity_type, $host_entity_id);
  $host = $host_wrapper->value();

  return $host;
}

function mymodule_set_host_entity_callback($entity, array $options, $name, $entity_type)
{
  $wrapper = entity_metadata_wrapper($entity_type, $entity);

  return $wrapper->host_entity->value();
}


texts: Add an attribute to a specific tag in text body of page

texts:
I would like to add an attribute to a specific tag in the text body of a page.

I was thinking in this direction:

add MYTHEME_preprocess_field(&$variables) to template.php
apply regular expression to the right field (but which one? $variables['items'][0]['safe_value']?)

Can anyone give me a specific working example of applying a regular expression to the body field of a page?

Thanks!


texts: How to join another table via altering view query as exposed filter

texts: Hi I have created a view and exposed the view with node title. Searching is done on title and its working fine. But I have a requirement that when some one searches through title, the search text should also be matched to body field and if the content is found in any of the field it should display result. Like if the search text is not in title but found in body it should display the result as found.Please help


texts: How to redirect to another URL if visitor is anonymous when clicking a menu?

texts:
I used the following code to redirect anonymous visitor to a login page:

<?php
  global $user;
  if ($user->uid) {
    print "Submit now...";
  }
  else {
    print "Submit now...";
  }
?>

But I can do this only in a block. What I want is put a Submit menu in the main menu and if anonymous visitor click the link he/she will be redirect to:

http://www.sourcecodester.com/user?destination=submit

after he/she login, he/she will be redirect again to the submit page as defined in the URL as "destination=submit".

Is this possible in main menu?


texts: Pass node field value to view filter in a block

texts:
Background

For the node type article I want to display a block view of map markers generated from a content type called sted (places). For the content type article I have made a entity reference field (multiple values allowed) called kartreferanse (map reference) where you can pick multiple nodes of the type sted (places). So far so good. I have also made a view in a block that displays markers for all the content types sted (places) using a Geolocation - CommonMap. Now I want to pass the reference field to the view to show only the places picked in the field kartreferanse (map reference) for the current node. I have tried using contextual filters (field_kartreferanse: Content) Content: ID with no luck, and/or tried building a relationship using field_kartreferanse: Content in the view.

The question

How can i pass the ID of the current node (article) to the view (in a block) and use the entity reference field in the article to show right node IDs in the map block view?
Do I also have to make some filter-criteria for this to work? (field_kartreferanse: Content) Innhold: ID (= [Content: Nid])
(Later I will have to make this view work in a multilingual site.)

(Drupal 8, local install / mamp, geo locationfield, views 8.1.10)


texts: Does Drupal 7 support connecting to DB using MySQLi?

texts:
I have tried to connect to Mysql DB using Mysqli by declaring 'driver' => 'mysqli' inside DB array in settings.php but I get the following error:

Warning: require_once(/srv/http/my-domain/includes/database/mysqli/database.inc): failed to open stream: No such file or directory in /http/www/my-domain/includes/database/database.inc on line 1688

Thanks.


texts:
Programmatically assign a node to an organic group is following my previous question which I have found the solution for Drupal 7, but I am now looking for the same issue in Drupal 6.

How can I programmatically assign a node to an organic group?

I have tried the following and neither of them worked (assuming $target_group is the group ID that I want the $node to be assigned to).

$node->og_groups = array($target_group => $target_group);
node_save($node);

$group = node_load($target_group);
$node->og_groups[0] = $target_group;
$node->og_groups_names[0] = $group->title;

What is the proper way to do this?