texts: Views listing of content types a user is allowed to create

texts:
My site allows any user to register but I can verify who they are and then assign a role if I am satisfied.

Can anyone tell me how I can list the content type(s) a user with a particular role is allowed to create? Is this accomplishable via Views?

I also need to detect if they are allowed to create content and display a message to them if they are not.

Thanks.


texts:
I am using Omega / Delta / Context, and am trying to make the content zone a little wider than its surrounding regions using negative margins but the

.container-12 { margin-left: auto; margin-right: auto; width: 1200px; }

class overrides my attempts to change margins or width with CSS via class names (ie, using Theme Settings => Zone and Region Configuration => Context Section => Content Zone => Configuration => Additional zone classes)

How can I accomplish this?


texts: Image / File AJAX form fields not saving

texts:
I built a AJAX form so that users can setup their user profiles after logging in. All basic text fields work/update fine. But I can't for the life of me get a image field (Picture) or file field (PDF Resume) to save.

The appropriate widget is displayed, and it allows me to upload the files (both image, and pdf) no problem. I can even see a preview of the image once it's uploaded. The files are definitely in the media section of the content admin page. BUT when I refresh the ajax form page the fields are empty again. Why is it not applying the uploads to the users profile fields?

All other fields update fine.

The form:

<form action="<?php print $ajax_form['#action']; ?>" method="post" id="<?php print $ajax_form['#id']; ?>-header" accept-charset="UTF-8">

<?php print render($ajax_form['user']['field_user_picture']); ?>
<?php print render($ajax_form['user']['field_resume']); ?>

<div class="single-line">
<?php print render($ajax_form['user']['field_user_first_name']['und'][0]) ?>
<?php print render($ajax_form['user']['field_user_last_name']['und'][0]) ?>
</div>

<?php print render($ajax_form['user']['field_user_title']['und'][0]) ?>
<?php print render($ajax_form['user']['field_user_location']['und'][0]) ?>
<?php print render($ajax_form['user']['field_user_summary']['und'][0]) ?>
<?php print render($ajax_form['form_build_id']); ?>
<?php print render($ajax_form['form_token']); ?>
<?php print render($ajax_form['form_id']); ?>
<?php print render($ajax_form['actions']); ?>
<input type="hidden" name="part" value="header"/>
</form>

and then:

 $form['account'] = array(
 '#type' => 'value',
 '#value' => $account,
 );

 $form['#action'] = '/ajax/' . $id . '/' . $type;
 $form['#id'] = 'ajax-form';

 $form_key = 'user';
 $form[$form_key] = array(
'#type' => 'fieldset',
'#title' => 'none',
'#parents' => array($form_key),
);
field_attach_form('user', $account, $form[$form_key], $form_state, LANGUAGE_NONE);

Thank you VERY kindly in advance,
Alex


texts: Send out a unique (unprotected) link per user

texts:
I'm the admin of a Drupal site with 200+ users. I sort of rolled into this, so I'm no Drupal expert, although I've managed to understand it quite good now.

This is a site for our sportsclub and we want all existing users to confirm their membership (of the club) for the coming season.

We would prefer to do this a simple as possible and send each user a link which, when clicked on, will confirm their renewal. Ideally, this is a link with some sort of unique hash, so we can make it unprotected. This would avoid having to log in.

We want to do this (keep it as simple as possible) because we've noticed a lot of members just don't do it (go to the site, log in, go to the correct page if not already there, and click the yes link to renew).

Is this possible (with a module perhaps)? Sending out a unique link per user?


texts:
I have list of courses of course content type in a view. I want to add "add course" button with every listing of node in view.
When a user is logged in he can add a course to its profile information. so that profile information shows all the added courses from view in the profile. For example: List of courses taken by user.
I have used entityreference module to attach nodes to user profile. But I have no idea how to do it from a view listing.

How do I add a node from a view to user profile field?


texts: Can't disable module when it defines an field type used by a custom entity

texts:
I have created a module that creates a custom entity (using hook_entity_info etc.), defines a field type (using hook_field_schema and hook_field_info), and then creates an instance of the field type with my custom entity (using field_create_field and then field_create_instance).

This all works great until I try to uninstall the module and am told "Drupal (Field type(s) in use".

Whilst this is true they won't be in use once the module is uninstalled!

Short of going into the DB and starting to delete rows out of the field_config and field_config_instance table how do I get round this problem?

Here I am creating the field instance in hook_enable:

function emtr_enable() {

    field_cache_clear();
    field_associate_fields('emtr');

    if(field_info_field('emtr_denominations')) return;

    $field = array(
        'field_name' => 'emtr_denominations',
        'type' => 'field_emtr_denominations',
        'cardinality' => FIELD_CARDINALITY_UNLIMITED,
        'translatable' => FALSE,
    );
    field_create_field($field);

    $instance = array(
        'field_name' => 'emtr_denominations',
        'entity_type' => 'emtr_safe_check',
        'bundle' => 'emtr_safe_check',
        'label' => 'Denominations',
        'required' => false,
        'widget' => array(
            'type' => 'number'
        ),
        'settings' => array(
            'target_type' => 'emtr_safe_check',
            'handler_settings' => array('target_bundles' => NULL),
        ),
        'display' => array(
            'default' => array('label' => 'inline', 'type' => 'number_integer'),
        ),
    );
    field_create_instance($instance);
}

And here is my uninstall hook:

function emtr_uninstall() {
    if ($instance = field_info_instance('emtr_safe_check', 'emtr_denominations', 'emtr_safe_check')) {
        field_delete_instance($instance);
    }
    if (field_info_field('emtr_denominations')) {
        field_delete_field('emtr_denominations');
    }
    field_purge_batch(100);
}

And hook_field_schema:

/**
 * Implements hook_field_schema
 */
function emtr_field_schema($field) {

    $columns = array(
        'denomination_value' => array(
            'type' => 'int',
            'not null' => FALSE,
        ),
        'denomination_tid' => array(
            'type' => 'int',
            'not null' => TRUE,
            'default' => 0,
        ),
    );
    $indexes = array(
        'denomination_tid' => array('denomination_tid'),
    );
    return array(
        'columns' => $columns,
        'indexes' => $indexes,
    );
}

Just in case my hook_field_info and hook_entity_info are in a pastebin here.


texts: What cache should be cleared for front end theming work?

texts:
When theming I work with CSS files and templates files. What cache should I clear while retaining performance?

And what would be the equivalent drush command?

I think drush cc all clears too many things right?


texts: Undesired toggle effect with #states and checkboxes

texts:
I'm working on a patch for the Login Disable module, and on the settings page, I want to have two mutually exclusive options so that when one is checked, the other is unchecked. Using the FAPI #states value, I have the following code:

function login_disable_settings_form($form, &$form_state) {
  $form = array();

  $form['all_users'] = array(
    '#type' => 'fieldset',
    '#title' => t('All Users'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  $form['all_users']['login_disable_is_active'] = array(
    '#type' => 'checkbox',
    '#title' => 'Prevent user log in',
    '#description' => t('When active the user login form will be disabled for everyone. For roles granted bypass rights they must use the access key defined below.'),
    '#default_value' => (bool)variable_get('login_disable_is_active', FALSE),
    '#states' => array(
      'unchecked' => array(
        ':input[name="login_disable_individual"]' => array('checked' => TRUE),
      ),
    ),
  );

  $form['all_users']['login_disable_key'] = array(
    '#title' => t('Access key (optional)'),
    '#description' => t('For added security, a word can be required to be added to the URL.'),
    '#type' => 'textfield',
    '#size' => 10,
    '#default_value' => variable_get('login_disable_key', 'admin'),
  );
  if (!empty($form['login_disable_key']['#default_value'])) {
    $form['login_disable_key']['#description'] .= '<br />' . t('The URL to use to log in is: @url', array('@url' => url('user/login') . '?' . $form['login_disable_key']['#default_value']));
  }

  $form['all_users']['login_disable_message'] = array(
    '#title' => t('End-user message when login is disabled'),
    '#description' => t('The message to display to users when login has been disabled.'),
    '#type' => 'textfield',
    '#size' => 80,
    '#default_value' => variable_get('login_disable_message', t('Member access has been temporarily disabled. Please try again later.')),
  );

  $form['individual'] = array(
    '#type' => 'fieldset',
    '#title' => t('Indivdual'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  $form['individual']['login_disable_individual'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable on user profile'),
    '#description' => t('Checking this box allows disabling individual logins on user profile pages.'),
    '#states' => array(
      'unchecked' => array(
        ':input[name="login_disable_is_active"]' => array('checked' => TRUE),
      ),
    ),
  );

  $form = system_settings_form($form);

  return $form;
}

So as I see it, my code should just uncheck a checkbox when the other checkbox is checked. I also want the option that neither is checked.  However, what's happening is that they are working as a toggle, in that if I uncheck one, the other one is being checked, which is prohibiting the third option of neither of them being checked. Can anyone tell me why I'm getting this effect?

Thanks.


texts:
I want to display an SVG image as SVG code to easily change its color using CSS. I installed the following modules: SVG image, SVG Formatter, SVG image field, SVG Image Responsive, and SVG Sanitizer. Then in the view field, I select SVG Formatter, then I chose Output SVG inline, Sanitize inline SVG, Set image dimensions.

As result, the following XML was shown in the page.

<?xml version="1.0" encoding="UTF-8"?>

How can I fix that?

These are the view settings.

This is the view output.


texts: Redirecting anonymous user to specific page

texts:
I have a view (d7, views3) that is set up as a table with several fields and the far right column is a global custom text field containing some html like this in the text box:

Enroll

When an anonymous user comes to that page and clicks on that link, it forces them to the login page.  But then after they log in, it takes them to their main user page instead of the node that they would have gone to if they had been logged in.  Is there a way to send the user to the page they should have gone to after login ??


texts: Why doesn't the "Edit" option always appear?

texts:
I have a site with several custom entities. For one of the entity types, most objects are fully functional, viewable, usable, but on the entity list page do not offer the Edit option.  As my admin user, user 1, I can edit them using a custom form, but not from the default entity_form.

My EntityAccessControlHandler.php starts with:

$roles = $account->getRoles();
if (in_array('administrator', $roles)) {
  return AccessResult::allowed();
}

Why does the Edit option get suppressed?  I cannot find corrupted data in these nodes.

At this point, I have a workaround, using a custom form, but am trying to understand the depths of drupal at work here :) !


texts: Is there a way to position my Article title in Drupal 8 teaser?

texts:
I have In teasers  and other custom display types I would like the image to appear above the title.  However, when I try to manage the display fields from the admin menu there is no way to change the  title or byline.

In other words  the only field I choose to display from that menu is image, but on the page the title, date and author appear.

 <title>
 Submitted by <author> on <date>

Is there a way outside CSS to move these things around


texts: Only display image field when administrator approves it

texts: I'm building an advertising website using Drupal 7, in my case anyone can add an advertisement without any restriction, except that the images should be hidden first until the website admin approves it.


texts:
Is there any way to use dependency injection in a conditional way, i.e. only if a service exists similar to \Drupal::hasService().

I have a created a service in module A and in module B I have an EventSubscriber that should use the service from module A, but only if present of course.

Static I would do sth. like:
    if (\Drupal::hasService('module_a.my_service')) {
      \Drupal::service('module_a.my_service')->mymethod();
    }

Is there any possibility to do this when injecting the service?


texts:
[![enter image description here][1]][1]I have a content type of "School."
I have a content type of "Event" that contains an entity reference to "School" so that events can be linked to schools.
I can create a view block that filters by the school, when the block is placed on the node of the school, using contextual filters.

The problem:
Starting with the built-in "Basic Page," I added an entity reference to "School" so that "Basic Pages" can be linked to a "School," and be subpages of the "School."
How do I filter a view of "Events" that when placed on a "Basic Page" the "Events" block view will filter based on the entity reference, "Schools," that is shared between the "Event" and "Basic Page?"  I am looking to have an "Events" subpage that lists all the events of that individual school.
I am trying to avoid having to create separate block views that use filter criteria of each individual school.  I was hoping to use contextual filters.

Thank you


texts:
I am looking to create something similar to this http://www.smartoplug.com/partsearch I need my view to sort based off of multiple parameters. So if you select ford in the make, the models dynamically change to only show models that are referenced in ford i.e. F150, F250 etc.

I've looked into hierarchical select, and simple hierarchical select, but it doesn't look like what i am wanting to accomplish


texts: Why can't I uninstall a module if I deleted a field type in a content type?

texts:
I have an installation of Drupal 7. I installed Field Collection module. I created a content type (Books), added a collection type field, and created a View showing these data. Now, I deleted the collection type field in Books, and now I am not able to uninstall the module. I have run cron and cache delete to no avail. The message displayed in the modules page is the following.

Field collection

  7.x-1.0-beta11+13-dev
  Provides a field collection field, to which any number of fields can be attached.
  Requires: Entity API (enabled)
  Required by: Drupal (Fields pending deletion)


texts: How do I get the database value of a text field with $content?

texts: I need to output a raw link from within a text field, without all the "field-" divs, in node.tpl. I've tried <?php print render($content['field_download_link']['LANGUAGE_NONE']['0']['value']); ?> but nothing displays.


texts:
I need better methods of ruling out cheaters in anonymous voting contests.  I'm using VotingAPI + vote_up_down, and those use ctools in some fashion for ajax.  I'm looking for any suggestions that could push me in the right direction.

I've not done must custom code, and from the looks of it the parameters are hardcoded into everything, so this appears to be a nontrivial modification (aka total hack).


texts: How to assign role(s) for a new user based on node_field?

texts:
I am in a process of finishing a workflow. I have done the most things with rules. To my surprise I found a feature is missing in this great module ...

I have created a content type called "my_cont_type". A content of this content type will be created only once by admin. A link will be provided for the admin to go and change the option whenever he wants.

It has a field called "my_field". It is a list box type where user can select multiple options. The options are "Role1" , "Role2", and "Role3".

On creating this content or after created admin can go and edit the same.
After edited the same from that time the new user who all registering or created they have to come under the corresponding role selected in that node. I have those three roles already in my application.

For example:

When Role1 and Role2 is selected the new user has to register with these roles1&2 enabled.
When Role1 and Role3 is selected the new user has to register with these roles1&3 enabled.
When Role3 is selected the new user has to register with only roles3 enabled.

Can I accomplish this using the Rules module?

I tried but I doesn't find any attributes regarding node or content type in condition when using the "After new user saved" event.


texts: Defaulting a value for a new boolean field added to an existing content type with content?

texts:
We have a Drupal 8 site. For one of our features, I added a boolean field called 'Pinned' to a our Blog Post content type.

As I added the filed as a filter criteria to views, I noticed that, no matter what configuration I selected, Is equal to + True, Is equal to + False, Is not equal to + True, Is not equal to + False, my view preview, which had had results, suddenly gave no results. I thought surely one of these combinations must apply to at least one node.

I added the 'Pinned' field to the fields of the view to examine the values, and removed it from the filter criteria. It turns out that the field was technically NULL, from the join-- there was no record in node__field_pinned.field_pinned_value.

To further test, I edited one of our blog posts nodes. When I checked the 'Pinned' checkbox, the value in the view became 1. When I then unchecked the checkbox and saved the node, then value became 0.

Trying to think of ways to auto-populate the field, I made the 'Pinned' field required.

But, all that did was make it necessary to check the checkbox when editing or adding a Blog Post.

This didn't solve my problem, and seemed to make the field redundant anyway. You can't save the node without checking the checkbox; you have to check it.

Edit going off Grapple's answer, I found that if I changed the widget to "Check boxes/radio buttons" on the "Manage form display" page of the content type. This does allow you to set a default value, but it does not auto-populate existing node field values, nor does it auto-populate the form widget for existing nodes.

It only auto-populates the form for new nodes.

It seems like a boolean field with a checkbox widget is meant for situations where the user cannot advance without checking the box, such as accepting terms of service, etc.

As it is, it is difficult to use, because we have hundreds of Blog Posts, and it's pretty labor intensive to edit each one and check, then uncheck the box. We only want a few pinned posts, but we can't have views of unpinned posts being empty.

Is there a way I can add a Boolean field to a content type with existing nodes and have it auto-populate with values?


texts: Drupal 7 Theming: Generate styles to a file instead of inline

texts:
In my field.tpl.php, I have used PHP to write a string of CSS. The content of the string varies according to the field options.

I then add this string of css to my theme using drupal_add_css(). The style is then added to my theme, but it is added inline.

Is there a way to make the string of CSS to be written to an external stylesheet instead?


texts:
I need to secure the user profile information, which contains predefined & custom fields such as username, profile picture & phone number.

I do need to encrypt & store it in DB. And then decrypt to display output.

Do anyone know, does encryption for fields is possible?


texts: Product category filter on the /products page

texts:
I've been looking for a while but I can not seem to find the correct way to tackle the following problem.

On my products page, where all the products are, I have the standard drupal commerce kickstart filters. One of those filters lets me filter the shown products depending on which category they belong to. Now, I have somewhat of a hierarchy

Term
-child Term
--"grandchild (child of child)

(see image below)

now I'd like to be able to show for example the "Kastanje" product when i click on "Vloeibaar". Show the child product when clicking on the parent.

So far, i have had no idea how to do this and have tried pretty much everything i can think of in the "configure facet display" option.

Anyone who has an idea on how to do this?


texts: Keyword research does not find any keywords under keyword stats

texts: I've installed module SEO Tools including all its 'sub modules". One of them being they Keyword research module. Now, in order to find keywords I'm supposed to be able to the Keyword stats tab from admin/structure/kwresearch/keyword_report, enter a keyword and hit submit. I don't get any results, I just see "No keywords were found." - even when I submit a keyword like bike for example. Why is this? what am I missing?


texts: Form data not being entered into the SQL statement

texts:
I have created a form which is not entering the data I enter in the fields into the sql statement. I just got the error:

  user warning: Duplicate entry '' for key 'PRIMARY' query: INSERT INTO subscription_info (first, last, email, phone) VALUES ('','','','') in C:\EasyPHP-5.3.8.1\modules\drupal620x120318224310\sites\all\modules\email_form\email_form.module on line 124.

Here is the code:

function email_form_my_form($form_state) {
  $form['info'] = array(
    '#type' => 'fieldset',
    '#title' => t('Personal Information'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  $form['info']['first'] = array(
    '#type' => 'textfield',
    '#title' => t('First name'),
    //'#default_value' => $form_state['values']['first'], // changed
    '#description' => "Please enter your first name.",
    '#size' => 20,
    '#maxlength' => 20,
   );

   $form['info']['last'] = array(
     '#type' => 'textfield',
     '#title' => t('Last name'),
     '#size' => 20,
     '#maxlength' => 20
     //'#default_value' => $form_state['values']['last'], // added
   );

   $form['info']['email'] = array(
     '#type' => 'textfield',
     '#title' => t('Email address'),
     '#size' => 30
   );

  $form['info']['phone'] = array(
    '#type' => 'textfield',
    '#title' => t('Phone Number'),
    '#description' => "Format: 555-555-5555",
    '#size' => 10,
    '#maxsize' => 10
  );

  $form['subscription'] = array(
    '#type' => 'fieldset',
    '#title' => t('Subscription Information'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE
  );

  $form['subscription']['content'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Events'),
    '#description' => t('Please chose which events you would like to follow'),
    '#options' => array(
      'Baseball' => t('Baseball'),
      'Basketball' => t('Basketball'),
    ),
  );

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

  $form['clear'] = array(
    '#type' => 'submit',
    '#value' => 'Reset form',
    '#validate' => array('email_form_my_form_clear'),
  );

  return $form;
}

function email_form_my_form_submit($form, &$form_state) {
  //unset($form_state['storage']);
if (db_query("INSERT INTO {subscription_info} (first, last, email, phone) VALUES ('%s','%s','%s','%s')", $form_state['values']['info']['first'], $form_state['values']['info']['last'], $form_state['values']['info']['email'], $form_state['values']['info']['phone'])) {
      //$form_state['values']['subscription']['content'] use this later...
      drupal_set_message(t('The form has been submitted.'));
}
else {
      drupal_set_message(t('The form had an error in it.'));
    }
  }
}


texts: Filter Content Cronologically Based on Current Month

texts:
I'm working on a project where the user wants to display upcoming shows. They want to display these shows in three blocks. Each block would list shows for the nearest month, in order.

For example, if the the current month is January, and the upcoming shows were in February, April and June each block would list the shows in the month. (Block 1 = February, Block 2 = April, Block 3 = June)

I was originally thinking of creating three block views. I would filter the first view's date field so that it is equal to the month, the second view's date field so that it is one more than the month, and the third view's date field so that it is two more than the month.

However, since the client's shows are not every month, the shows would only appear until they fit that specific filter. The example above would not show any upcoming shows until it was February, and would leave the second and third columns blank.

All I could think of was to create a block view for each month, but the client would have to arrange them every month.


texts: How to pass parameter to 'options list' attribute in hook_rules_condition_info?

texts:
I am declaring a condition in which I have the following parameters:

            'node_type' => array(
            'type' => 'text',
            'label' => t('the node type'),
            'options list' =>/*'entitystep_get_list_node_types'*/ 'node_type_get_names' ,
            'restriction' => 'input',
        ),
        'node_field' => array(
            'type' => 'text', //TODO: find or create node_field datatype? *node_element?
            'label' => t('the node its field to be checked'),
            'options list' => 'entitystep_get_fields'

// TODO: check how to pass a parameter to the entitystep_get_fields!!! ($node_type)
            ),

In the 'entitystep_get_fields (on the bottom) I have to pass the selected node_type (=the first parameter)

These are the functions I need to call:

function entitystep_get_list_node_types() {
    $types = db_query("SELECT n.type FROM node_type");
    return types;
}

 function entitystep_get_nodes_by_type($node_type) {
        $nodes = db_query("SELECT * FROM node WHERE type=" . $node_type );
        return $nodes;
    }


texts: How update programmatically node entity with empty field_image?

texts:
i need to make an import from one mysql table in my base.

I create node with :

$value= array(
                'type' => strtolower($typeProduit),
                'field_1'=>"test",
                'title'=>"test",
                'body' => array(
                    'value' => "test",
                    'format' => 'full_html',
                ),
                'field_2'=>"",
                'field_3'=>"",
                'field_4'=>"",
            );

 $nodeEntity=\Drupal::entityTypeManager()
        ->getStorage('node')
        ->create($value);

    $nodeEntity->save();

All node are create and if i have an image, i add it to my $value before save() :

$value['field_image_video']=array(
                    'target_id' => $fileImageVideo->id(),
                    'alt' => $catalogue->titreVideo,
                    'title' => $catalogue->titreVideo,
                );

if i have no image, i do nothing for this field.

I need to update some node programmatically after this first step.

And when i just try to change the title like this :

     $nodeEntityUpdate = \Drupal::entityTypeManager()
                    ->getStorage('node')
                    ->load(273);

     $nodeEntityUpdate->title="blabla";
     $nodeEntityUpdate->save();

if node don"t have image field set, i got this error :

  PHP Fatal error:  Call to a member function getFileUri()

If node has image, update work.

How can i set my image_field to null ?

i try to set my image field like that on creation :

$value['field_image_video']=array();

But that didn't work.

this image field is set to unlimited values


texts:
CKEditor inserts extra <p> tags when users enter a newline.

How do I disable this automatic paragraph tag?


texts:
I've trying to get the querystring from within a module.

I've tried the following.  However the following always returns A

exporter/directory?l=o

$l = "A";
if ( !empty($_SERVER['l']) ) {
    $l = $_SERVER['l'];
}

/* edit */

    $l = "A";
if ( !empty($_GET ['l']) ) {
  $l = $_GET ['l'];

}


texts: Metatag OpenGraph for youtube video using Embbed Video field module

texts:
I cannot find a way to make Metatag Opengraph use the correct tokens for sharing video content type on Facebook.

My field is field_video and I am using it in video in opengraph. Since this is not working, can I at least make the image representing the video shared? Is it stored in Drupal? In tokens there is no thumb token for it.

I am using Drupal 7, the Video Embed Field module, and the Metatag module 7.1.4.


texts: pages accessible only by specific groups

texts:
I have made those pages on my Drupal 6: Alpha, Bravo, charlie, Delta. At time of writing, those pages are visible by anybody.
I need that those pages are visible only for limited groups, for example:
Alpha is visible only for group One and Two
Bravo is visible only for group Two and Three
Charlie is visible only for group Two and Three
Delta is visible only for group Three.
I have other nodes and other groups on the Drupal installation that needs to stay untouched, I need to change permissions only for those four pages, and of course their menu links need to reflect that (so each group will see only the menu links that they have granted access)
How can I do that?


texts: How to get a fixed picture in the field without affect by responsive effect?

texts: I want to get this picture fixed on original size. Please refer to this picture. There is a picture showing up a drill. I want to make it keep on 100x59px. When I adjust the browser's window, the responsive effect is that I want but the picture will shrink its width. Here is the webpage. I also use this command:grep -inR image-style-cu-product-list /mydrupalcssdirectory. I can't figure out why I did't get this specific CSS? Are there any methods to keep this picture fixed on 100x59px. (At least I want the width able to be fixed.) The solving method is not limit in CSS. Wish a help. Thanks.


texts: How do I alter the title display with hook_user_view?

texts:
/**
 * Implements hook_user_view().
 */
function my_statistics_user_view($account) {
    $account->content['statistics']['daily_avg'] = array(
        '#type' => 'user_profile_item',
        '#title' => t('Daily average'),
        '#markup' => 'Hello',
        '#attributes' => array('class' => array('daily-avg')),
    );
}

The above code renders:

Daily average
Hello

in a user's account profile. I would like to render it inline, like this:

Daily average: Hello

How is this done? Thanks.


texts: How do I show an already hidden field of a custom content type to a specific authenticated user?

texts:
I have a custom content type whose fields are Name, Description, and URL which is hidden by default. I want to show the latter field to the authenticated users who have flagged the node containing it. (I installed the Flag module for the flags.)
The flagging and displaying the flagged items are working fine. The only thing I am having trouble with is the hidden URL.
Can anyone guide me on how I can do this?
I looked into using the Rules and the Conditional Fields modules, but I don't think they would help and they seem to be an overkill for this particular task. I also looked into implementing hook_page_alter(), but that didn't help either.


texts: Hook into password change on user update

texts:
Question in short: How do I hook into password change in order to get plaintext old and plaintext new password when password change is accepted?

What I have tried so far: I tried hook_form_alter with

$form_state->getFormObject()->getEntity()

but this gets me only a hashed password.

What I want to do / context: I use the user's password to encrypt and decrypt some (very few) field values which I don't want to have plain text saved. User has to enter his account password in a custom form to decrypt/view a value.

When a user changes his password, the encrypted values should be automatically updated: decrypted with the old password, encrypted with the new one.

(I'm aware of the fact that these encrypted values are lost when user forgets his password and uses password reset.)


texts: i would like to use features module to export products. The commerce_features module gives a way to do the products types and other things but not product itself. It does not show up under content section or anywhere I can see. How to use features module to export products? How do you export products from one environment into another? Thank You for any help


texts: Disable all notice errors on a drupal 6 site

texts: I'm updating a drupal 6 site and getting hit with alot of notice errors. how can i silence these non vital errors. Usually just get undefined index and warning/notice messages


texts: drupal 7: new field with dynamically generated select list from PHP code

texts:
I have a new node type where a user is asked who he or she knows from the site.  They are to be presented with a select list with the names of the existing users on the site.

When creating this new select list field in Drupal 7, I noticed that the PHP snippet is gone so I cannot dynamically generate the select list text and values.  Is there some Drupal way (Views?) to do this without having to download the CCK (development status) module for Drupal 7?  The CCK module is not ready for prime time in Drupal 7.  I understand that their rationale to remove PHP snippets are for security reasons (http://drupal.stackexchange.com/questions/2509/what-are-the-downsides-of-using-custom-php-code-in-blocks-nodes-views-args).  The Drupal team would not leave us hanging without this common functionality, right?!??!


texts: Create a view block that shows list of nodes that references same node as current node

texts:
I have two content types. "Article" and "Collection". Any article can be placed into collection. Also when you create collection, you can select articles to be placed into collection. So I have created "collection" as node reference field in "Article" content type, and "article" as node reference field in "Collection" datatype.

Now when I am on any article page, I want to create view that shows other articles from the same collection. I have tried adding "collection" as relationship and contextual filter as "NId" with relationship with "collection", but it is listing all articles that is having any collection(may reference to other collection) and not the articles that belongs to collection of current article.

Am I doing something wrong?

Please suggest.

-- Thanks for your time.


texts:
I am building a Drupal Commerce site and I had the weirdest request:

Upon creating a new product, the client want's to select the product's category from a select list or something similar. This should result in the first part of the product's SKU, say

"CAT007"

Then he want's to select another attribute for that specific product which produces the second part of the SKU, say

048

So the complete SKU of the product would be CAT007.048 thus resulting in a unique identifier. The reason for this is that he doesn't want to look within huge arrays in order to produce the correct SKU.

My problem is that I can't seem to find a decent solution with which I can give the client access and management over the arrays.

Can anyone come up with something?

EDIT something that came to mind was taxonomy terms that contain a field with their SKU prefix/suffix. The problem that arises from that is how can I pass the tid from the user's selection (javascript) to the php side in order to do a term_load() and get the field's value.


texts: Migrating files from multiple paths with the migrate module

texts:
I am trying to take a bunch of files and turn them into nodes that link to those files in my system. Now when I say a bunch I am talking about thousands, if not tens of thousands of files. So I need a way to do this which includes using multiple directories as the source. Mainly one directory with multiple sub-directories to recurse through.

So I decided to go with the migrate module. In my module setup that creates the migration script I have a schema declared for an intermediary table. This table will hold all of the path information for each file I want to import.

I then (in the install function hook) loop through the image directory recursively and gather a list of file names and paths. Then I stick the information into the intermediary table. This table is what I then import from.

The only problem is that when mapping the file fields I am unable to figure out how to get it to get the source path from each entry. It seems to want me to specify a flat path where all the files will reside and that won't work.

Is there a way to get it to get the full source path from the intermediary table?

This is using Drupal 7 and Migrate 2.2.

Here is the mapping information I am trying. The jpg_uri field is where that source path should be coming from (I just can't seem to figure out how to make that happen).

$jpg_arguments = MigrateFileFieldHandler::arguments('',
  'file_fast', FILE_EXISTS_RENAME, NULL, array('source_field' => 'jpg_name'),
  array('source_field' => 'jpg_filename'), array('source_field' => 'jpg_filename'));

$this->addFieldMapping('field_image', 'jpg_uri')
     ->arguments($jpg_arguments);


texts: Override the body field with another field in hook_node_view

texts:
I have a node type that can be scheduled. Before the start time the page will redirect to another. This is all custom functionality and is currently working.

Now I need to create a coming soon page to allow the page to be active before the start time but not show any of the details.

I've created a coming soon field in the node and I have the logic set up correctly but I am struggling with the render array.

function MODULE_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'TYPE') {

    // admins see the page no matter what
    if (!user_access('administer site configuration')) {

      // if not started, show coming soon page
      $coming_soon = FALSE;
      if (!STARTED) {
        $coming_soon = field_get_items('node', $node, 'field_coming_soon_body');
        if ($coming_soon) {
          $node->content['body']['#object']->body[$node->language][0]['value'] = $coming_soon[0]['value'];
        }
      }
    }
  }
}

This however still shows the actual body of the page and not the coming soon page. I really want to do this in hook_node_view as well.

How can I go about replacing the content of the page with this single field?


texts: Show calculated value at the bottom of every node for a specific content type

texts:
I am beginner in Drupal. I am using different content types and views for my project. Here for specific content type I have created number of fields. Two of the fields are integer field type.

I want to calculate those two fields and show the calculated values at the bottom of every single node for a specific content type.

How can I achieve it? using views or by any other way.


texts:
I created a custom block plugin to allow users to easily customize various elements of the block using configuration options in panels.

public function build(){
    return array(
        '#type' => 'markup',
        '#title' => '
Test
',
        '#markup' => '
configuration['my_plugins_style'] . '>' . $this->configuration['my_plugins_string'] . '
',
    );
}

However I would like to customize elements of the title of the block as well. The title is automatically encased in between h2 tags and I'd rather the user choose what type of tag to encase the title. I attempted adding the markup within the '#title' options but that just renders all the markup as text.


texts: Aggregator module block shows up only to registered users

texts:
I am using the aggregator module for D8, I have created a few blocks with feeds from various media outlets. The problem is that the blocks show up only to registered users of the site. How can everybody see them?

Thank you.


texts: Prevent caching of variable in twig template

texts:
In my custom page.html.twig I have a variable that adds an alert bar to the page if the user is expired. This is based on a custom user field.

It's  generated here in my custom_theme.theme file like so.

function custom_theme_preprocess_page(&$variables){
    $uid = \Drupal::currentUser()->id();
    $current_user = \Drupal\user\Entity\User::load($uid);
    $now =strtotime('now');
    $paidThrough = strtotime($current_user->field_expiration_date->value);
    if($paidThrough < $now){
         $variables['alert'] = 'Your account has expired';
    }
    $variables['#cache'] = [
        'max-age'  => 0,
        'contexts' => ['url.path']
    ];

}

and then inside my page.html.twig file I have

{{ alert }}

{{ page.content }}

Even though some users have been updated to no longer see the alert, they still see it on the home page. If they click around to different pages they no longer see the report, but on the home page they always see it. I'm guessing they no longer see it on other pages because those pages were not cached for them. Also I'm using the page manager and panels plugins for many of these pages including the home page.

Why would twig variables be cached for authenticated users? Is there a way to prevent twig variables from being cached?

I did see a similar post here
Twig/Drupal caching and dynamic variables
But I'm not sure how that would work or how to implement that.

UPDATE: It was mentioned that using $variables['#cache']['contexts'][] = 'url'; would be problematic but if this is a dynamic alert box that appears on every page wouldn't that be necessary?

UPDATE 2: Actually it occurred to me that I'm already using

$variables['#cache']['contexts'][] = 'url';

in my own way here

$variables['#cache'] = [
    'max-age'  => 0,
    'contexts' => ['url.path']
];

But that didn't seem to resolve the issue. Unless 'url' and 'url.path' makes a difference.


texts: Where do I place custom PHP code (functions, classes) when creating a theme?

texts: WordPress has a place for it - functions.php, which is included automatically. Is there one for Drupal?


texts: URL Alias for Taxonomy for multiple child terms

texts:
I am having a problem setting up the url alias for a vocabulary with recurring child terms.
So for instance the vocabulary consists of categories and locations.

Category 01

All
Location 01
Location 02

Category 02

All
Location 01
Location 02

Category 03

All
Location 01
Location 02

At the moment I have 2 separate vocabularies of event categories and event locations.
For the node url I have setup the alias as

events/[node:field_event_category]/[node:field_event_location]/[node:field-event-start:value:custom:Y-m-d]-[node:title]

Now where I am stuck is setting up the url alias for the category and location.

Can anyone help with the best way to setup the vocabulary and url aliases? - Thank you.


texts: How do I force unique values within a multi-value set?

texts:
When programming my own field and autocomplete widget, how can I ensure that each delta has a unique value?

I would like to handle the case as much silently as possible, so to not bother user with validation errors. Most gladly I would just prohibit the autocomplete test from returning the duplicate matches but as far as I can see, the autocomplete function does not accept any context, just the search string.

Should I then keep the already selected values in a session variable - would it be the Drupal way?


texts: Default views argument that can't be overriden?

texts: I have an argument comparing the current user ID to a field to determine what nodes to show, but all you have to do to impersonate another user is enter the argument in the address bar thus circumventing my default value. Is there a way to make an argument only ever use the default value and not exist as far as the address bar is concerned?


texts: Custom placeholder markup when leveraging #lazy_builder in elements

texts:
Using bigpipe.

To avoid blocking page loads for long-lasting API calls, etc, I implement:

$element = [
  '#lazy_builder' => ['service.admin:method', []],
  '#create_placeholder' => TRUE,
];

and it works great! The page loads, and once the service returns the render array, it gets popped into the placeholder.

However, the placeholder span is empty and does not provide the user with any useful status. My goal is to have the empty placeholder replaced with a message (i.e. 'Loading data..'). This is proving more difficult than I assumed - I feel like I must be missing something.

My first crack was manually defining the placeholder:

$element = [
  '#markup' => 'Loading data..',
  '#attached' => [
    'placeholders' => [
      'Loading data..' => [
        '#lazy_builder' => ['service.admin:method', []],
      ],
    ],
  ],
];

This generates the desired content, but blocks any elements further down of it from loading until the method returns - pausing with half the page rendered. I assume it pushes the lazy_builder into the render process where it isn't as useful for this purpose.

I skimmed through core and couldn't glean any examples of this.

Is there an easy way to add text to the placeholder? This cannot be a novel need.

Warm Regards.


texts: Is there a hook for custom line item before rules price calculation?

texts:
I have a complex calculation for item price in a custom line item that I'd like to keep in code rather than rules. Is there a hook that gets called before cart calculation so I can set unit price?

Where is cart pricing calculation done in commerce? trying to find where it's run in source.

Drupal 7 (using kickstart 2)


texts: How to cleanup Wordpress media tags after migration?

texts:
After migrating from Wordpress to Drupal with the Wordpress Migrate and Migrate modules, content still contains media tags:

[[{"type":"media","view_mode":"media_large","fid":"4202","attributes":[{"class":"media-image","typeof":"foaf:Image","style":"","width":"339","height":"305"}]}]]

What is the best way to strip them out?


texts: "Experimental modules found: Place blocks" but I am using core 8.6

texts:
I am using Drupal 8.6.2. When I open the status report I see the following warning:

  Experimental modules found: Place Blocks. Experimental modules are provided for testing purposes only. Use at your own risk.

I researched this issue and found that place blocks has been part of Drupal Core since 8.2.

When I check the list of installed modules then I see no reference to a module named place blocks or block-place. I also ran drush pm-list and grepped for place and block. Is it possible that my database contains some outdated dangling reference to this module? How can I clean up my Drupal installation and get rid of this warning?


texts: Fivestar Field That Shows Average of Other Fivestar field

texts:
First of all, I'm quite new in Drupal 7 and I've almost Zero
  knowledge in coding.

I've create a custom content type (Review - Machine Name: review) with 4 Fivestar Field :

Support - Machine Name: field_support
Performance - Machine Name: field_performance
Value - Machine Name: field_value
Overall - Machine Name: field_overall

I've also created 4 Fivestar Voting tag:

rating_support
rating_value
rating_performance
rating_overall

I want the Overall field to display the average of the other three Fivestar Field. I've followed exactly as written here.

Here is the code that I've used on my template.php:

/**
 * Implements hook_form_alter().
 *
 * Hide average fivestar field from review edit/create form.
 */
function bartik_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'review_node_form') {
    // Hide average field, this field is calculated upon node_presave.
    $form['field_overall']['#access'] = FALSE;
  }
}

/**
 * Implements hook_node_presave().
 *
 * Calculates average vote rating.
 */
function bartik_node_presave($node) {
  if ($node->type == 'review') {
    // Get values from 3 axis.
    $rating_support      = entity_metadata_wrapper('node', $node)->field_support->value();
    $rating_value      = entity_metadata_wrapper('node', $node)->field_value->value();
    $rating_performance    = entity_metadata_wrapper('node', $node)->field_performance->value();

    // Calculate and set average axe.
    $rating_overall      = ($rating_support + $rating_value + $rating_performance) / 3;
    // @info: Can't use entity_metadata_wrapper, because '->set' not supported on this field.
    //entity_metadata_wrapper('node', $node)->field_overall->set($rating_overall);
    $node->field_overall['und'][0]['rating'] = $rating_overall;
  }
}

But The overall fivestar rating field displaying 'no votes yet' after publishing content. How can I fix this, Have I done something wrong?


texts: Why is my library not attached when programmatically rendering a block?

texts:
I have this block:

public function build() {
  $build = [
    '#attached' => [
      'library' => [
        'mymodule/mylibrary',
      ],
    ],
    '#markup' => '<!-- see template -->',
  ];

  return $build;
}

Somewhere I am rendering this block via custom text filter:

{{ '[embed:block:mymodulemyblock]' | text_format }}

This is my text filter that replaces the "token" with the rendered block:

public function process($text, $langcode) {
  if (preg_match_all('/\[embed:.+\]/isU', $text, $matchCodes)) {
    foreach ($matchCodes[0] as $index => $token) {
      $parts = explode(':', $cleaned);
      array_splice($parts, 0, 1);

      $entityType = trim($parts[0]);
      $entityId = trim($parts[1]);
      $viewMode = isset($parts[2]) ? trim($parts[2]) : 'full';

      if ('block' == $entityType) {
        $rendered = '';

        if ($block = entity_load('block', $entityId)) {
          $replacement = entity_view($block, 'block');
          $rendered = drupal_render($replacement);
        }
      }
      $text = str_replace($token, $rendered, $text);

    }
  }
  return new FilterProcessResult($text);
}

It works fine, except the block's library isnt attached. Not even when I add this inside the block template:

{{ attach_library('mymodule/mylibrary') }}

When I place the block in the block layout it works fine.

Why isnt the library attached?

Edit

This is how I register the template for the block itself:

function mmodule_theme($existing, $type, $theme, $path) {
  return array(
    'block__mymodulemyblock' => array(
      'render element' => 'elements',
      'template' => 'block--foobar',
      'base hook' => 'block',
    ),
  );
}


texts: How to show search results in view within panels?

texts:
I created view & content pane that has many filters and also search term field.
In addition, I created a page with page manager and panels, that present this search view (content pane), with more different panels.

My goal is to have search field, on the header of the site, that will be available to user in any time. when the user will decide to use this search field, it will direct them to the search page I created (using page manger & panels), and will show the search results on this specific page.

Can I do that?
If so, can you please explain me how?

I read on how to that using views alone, but I couldn't understand how to that with the use of page manager and panels all together.

Thanks.


texts:
I have been trying to import my taxonomies (structure with fields) via Taxonomy CSV import/export module and was able to import it but I am having difficulties when trying to import the fields (id) too. To clarify further, below is the structure of my taxonomy and data sample (The excel table I am trying to import).

Data sample (Data around 5k rows):

Rosera  AA07    Bouer   AA0703     Dana     AA070301
Malina  AA02    Azazi   AA0200     Daman    AA020002
Malina  AA02    Azazi   AA0200     Haritan  AA020003
Malina  AA02    Azazi   AA0200     Haritan  AA020003
Malina  AA02    Afrin   AA0203     Afrin    AA020300
Malina  AA02    Cerlo   AA0204     Aghtrin  AA020401

I imported the term structure as below (in the same vocabulary):

-Rosera
  -Bouer
    -Dana
-Malina
  -Azazi
    -Daman
    -Haritan
  -Afrin
    -Afrin
  -Cerlo
    -Aghtrin

I have added "ID" field in my vocabulary to import ID to it for each term.

Problem: How can I import the ids to the terms I imported?


texts: commerce_order_status_update() doesn't update the order status

texts:
After the order is paid in full (or not checkout is complete if there is no payment required and I ever get that working) I need to do a bunch of processing to set up the product the user has just bought. Only once that is done can I say the order is complete and I thought this would do it

commerce_order_status_update($order, 'completed');

But it doesn't change the order status. They are always left as Pending.

How do I programmatically change an order status from pending to completed?


texts: Redirect url is not working even if enabled

texts:
I am in upgrade phase of my site. After upgrade the redirect url is not working even if the status is enabled and no changes in redirect database the redirection url has stopped working. if I save them again without making any changes then the hash value of redirect table is changed and it started working again.

PS: I am not getting any error log for the same.

Is there anyway to fix such issue?


texts: How do I include a JavaScript file and pass the value of a PHP variable with a single function call?

texts:
I'm trying to pass a PHP variable to my JavaScript file. The file is js/backgroundConfig.js, it's in the theme directory, and this is the content of the file.

(function($, Drupal){
  Drupal.behaviors.backgroundAnimation = {
    attach: function(context, settings) {
      alert(Drupal.settings.variableName);
      alert(Drupal.settings.basePath);
    }
  };
})(jQuery, Drupal);

Drupal.settings.basePath is displayed correctly, but I've no idea how to pass variableName from template.php. I've tried a couple of methods but none of them work.

There are tons of examples on the web but none of them contains the filename and the settings together. Like this one:

drupal_add_js(array('variableName' => 'value'), 'setting');

Alright, but where I should put my filename? I always add my JavaScript file like this.

drupal_add_js(path_to_theme().'/js/backgroundConfig.js');

How do I combine it together?


texts: How to filter URLs for embedded IMG tags?

texts:
This is a great presentation about Drupal security. They were talking about ways to only allow  tags from certain trusted domains.

Any ideas how to do that? I couldn't find a D7 module for that.


texts: How can I make Search API search field collections?

texts:
I have a content type called Basic Page with a few fields (title, description, page body), one of which (page body)is a field collection with a field called 'Section Body'. I created a view called Search Page that searches all my content (including other content types), then added my Field Collection Item datasource to my index and added the Section Body field (with type Fulltext) to the Fields section of my index.

After reindexing all of my content, I went to my view and added 'Field Collection Item >> Section Body' to the 'Search fields' section of my Fulltext search option in my view's Filter Options.

To test all this, I added in the unique term 'testterm123' to my content title, cleared the cache, and searched for the term. The test content returned successfully, so I know that the title is being searched for successfully. I repeated this process for description, and that worked as well. However, it did not work for my field collection field Section Body and nothing was returned.

So I'm confident that I indexed everything correctly, but the Field Collection field is not being searched. Has anyone run into this and if so, what did you do to fix it? Does anyone have any ideas on how to fix this or solutions to attempt?


texts:
I have a doubt about the functionality of Drush Features commands when it works with git:

Before I do a git pull, can I do drush fu example? Will this command overwrite the changes of the feature coming with the pull and drush fr example will not work properly?

Thank you.


texts: How can I add more than one pointer to a map?

texts:
I want to create a block which has search functionality for looking up locations. I want to be able to add a pointer to the map at the searched for location.

It should be able to add more than one pointer to the map based on what is searched for.

An example of pretty much exactly what I'm looking for the input of locations can be seen here:
http://www.mapcustomizer.com/

Does anybody know how to do this?

Thanks


texts:
I wanted to try out the Single Page Website module for Drupal 7

I followed the instructions and all seemed to work well, except my anchor links wouldn't work i.e. it wouldn't scroll down the page when I clicked on them.

What might have been the problem there? The only anchor that seemed to work, was the link to a view.

Any ideas where I might have gone wrong or what I might have missed? Any experiences?


texts: Menu Block - How to make a new menu automatically available?

texts:
How to automatically set a newly created menu as available so that it can immediately be used when configured for "the menu selected by the page"?

I've tried setting the 'menu_block_menu_order' variable through code, upon a new menu creation, but haven't figured it out.

What's the best way to automatically set a new menu , or all menus, as available?


texts: How to display custom table without using views?

texts:
I have tried it to display the table by using core PHP concept and it display the table but at the top of the page now i need to display inside my page my current display is below

and my code for view is

function testing_db_viewall($form, &$form_state){
    $result = db_select('infobox_new')
    ->fields('infobox_new', array('name','emailid','contactno','nid'))
    ->execute();

    $entries = $result;
    $output ='';
    $rows = array();

    foreach ($entries as $entry) {
    // print_r($entry);
    // echo "<br>";
        $rows[] = array( $entry->name, $entry->emailid, $entry->contactno, l('edit','examples/edit/'.$entry->nid), );
    }
  // Make a table for them.
    $header = array(t('Name'),t('Email id'), t('Contact No'),t('edit'));
    $output .= theme('table', array('header' => $header, 'rows' => $rows));

     echo $output;
}

I want to display my table after my title i.e. "Custom Table View"

Thanks in advance


texts: How to create a theme that handle articles in different categories?

texts:
I am creating a theme that has many categories which have two types of handling articles.
For example:

Categories (A,B,C,D,E) will show articles in two column
Categories (F,G) will show articles in only one column
These articles will show in home page in a different manner

I had already created page.tpl.php as well as page--front.tpl.php, I also created a node--article.tpl.php. So am I able to do this with drupal theming? or it is not possible?


texts: Single webform submission creates multiple submission entries

texts:
I've got a number of webform forms on a website and when a user submits a form, it creates 2-3 duplicate entries in the database. Everything in the entry is the same, timestamps et al.
I'm sure it is not because of 'accidental' multiple clicks on the submit button, because I've tried it myself multiple times and the results are always the same.
Any help/tip/suggestion is greatly appreciated, because this is very annoying.
I'm using Drupal 8.9.13 and webform 8.x-5.25
Thanks in advance.
Stephan


texts: Change the URL of a node based on parent path

texts:
So let's say I have a basic page node.

I want to have this as an entity reference inside another content type - let's say an event content type.

So let's say that the event content has a url like baseurl.com/eventblahblahblah

When a user clicks over to the basic page that is the reference on node eventblahblahblah, I want them to go to baseurl.com/eventblahblahblah/basicpagenodehere - this needs to be the URL in the browser.

In addition, basicpagenodehere can be in multiple references - so if basicpagenodehere is also referenced by event2blah, then I want it to also be located at the url baseurl.com/event2blah/basicpagenodehere

I'm looking at possibly doing this with alterRoute -

class RouteSubscriber extends RouteSubscriberBase {
  /**
   * {@inheritdoc}
   */
  public function alterRoutes(RouteCollection $collection) {
  }
}

But I'm not sure if this is the correct place to do it.

This link suggests maybe PathProcessor, but I don't think that would change the actual URL on the node at the end of processing:

How to alter and rewritte current path programmatically in Drupal 8?

So how do I set a dynamic URL based on referring node?


texts: Node cache never expires and can't be cleared

texts:
BEFORE YOU ASK: I can't use Drush, this is a shared hosting, but I can use Composer.
In the constant struggle with Drupal 8.9 (8.9.11 to be exact) I've stumbled onto yet another issue: I have a simple node page with some company info and it remains cached forever. When I change and save it, I as an admin can see those changes. Anonymous users however still see the previous version.
And it's not just for a couple hours - it's been days.
I do not have any custom modules, nor cache-related contrib modules, in htaccess mod_expire settings are set to default.
I've tried many things - clearing cache in Performance panel, truncating cache tables in the database, completely disabling Internal Page Cache and Internal Dynamic Page Cache modules, saving the node again, running cron. Absolutely nothing helps. It seems impossible to clear the cache for anonymous users.
What else can I do? Are there any modules? Is it possible to write a script, maybe change some settings flag?
It's definitely related to URLs, as the moment I change that page's url, it can be viewed in it's updated state, but when I change it back, content reverts to it's cached state.


texts: How can I collapse the *sidebar first* region when the browser width is less than 900 pixels wide?

texts:
How can I collapse the sidebar first region when the browser width is less than 900 pixels wide?
Within the theme's .info file the following is set:
settings[sidebar_first_width] = 4
How can I programatically change the above to 0 so that the sidebar first region does not take up any space within the page when the containing browser wide is less than 900 pixels wide?
One possible approach is to utilize the media query at the bottom of the themes associated .css file so that the sidebar first region is collapsed when less than 900 pixels based on the following link:
http://www.alistapart.com/articles/responsive-web-design/
but I am not sure if this is the best approach or what css to put in that would do this as an example from the above link:
@media screen and (max-device-width: 480px) {
  .column {
    float: none;
  }
}

John


texts: Want to show url like termname (parent)/[termname] (Child: referenced by node) /node (node which is referenced to particular term)

texts:
Having problem to show url like termname (parent)/[termname] (Child: referenced by node) /node (node which is referenced under particular term)

i want this http://www.example.com/pets/cats/diseases/4-normal-diseases-of-kittens

here pets is parent term name
cats is child of parent 'pets' term name
diseases again sub term name of 'cats'
'4-normal-diseases-of-kittens' is article term referenced to diseases

Thanks in advance


texts: adding image field to "Taxonomy term view"

texts:
I try to create a product catalog instead of using drupal commerce in drupal 7 with current updates.
I create product types related to categories which are taxonomy terms.
I create a menu as taxonomy terms.
If select a taxonomy terms from menu , it is listed all products under that terms.
Listing is controlled by taxonomy term view. There we can control only node title.
I want to find a way to add image related to that node also. Is there a module for that purpose? Or how could it be achieved?
Regards,


texts:
I've installed the FooTable module but I can't enable it. The error message when I try to enable it is this:
"The FooTable jQuery plugin is missing. See README.md for instructions on how to download and extract it. (Currently using FooTable Not found)"

But I've already installed and enabled the jquery plugin but the error message appeared again.

I followed the README.md instructions about the directory where I have to place the zip file downloaded on https://github.com/bradvin/FooTable but the error message appeared again.

What else can I do?

What are the other modules similar to FooTable?


texts: Image shows on home page, but not on article page

texts:
I am using Open Outreach. When I create an article the image I uploaded appears on the home page, but does not appear when I click the link for that article.

From what I've read, it looks like it has something to do with Configuration/Media/File System. My public file system path is set as sites/openoutreach-7-x-1-19.dd/files. Do I need to change this? If so, what do I change it to?

Log message:

Type    page not found
Date    Thursday, June 4, 2015 - 9:43am
User    admin
Location    http://openoutreach-7-x-1-19.dd:8083/sites/openoutreach-7-x-1-19.dd/files/styles/medium_large/public/Portulaca%20grandiflora.jpg?itok=OP-6w24x
Referrer    http://openoutreach-7-x-1-19.dd:8083/article/june-3-2015-newsletter
Message sites/openoutreach-7-x-1-19.dd/files/styles/medium_large/public/Portulaca grandiflora.jpg
Severity    warning
Hostname    127.0.0.1

There is no medium_large folder in my styles folder. Do I need to create one?

Thanks!


texts: What is causing pathauto to generate unwanted text in these URLs?

texts:
I have configured pathauto to generate URLs for content according to this pattern article/[node:author]/[current-page:title]-[node:nid]. article is a literal input, to reflect the content type description Site Article not token generated.

The content type description is Site Article

The node title is: this is a title

The author's name is: nodecreator

The node id is: 101

When I generate the URL alias using the pattern article/[nodecreator]/[current-page:title]-[node:nid], the resulting path 's article/nodecreator/edit-site-article-this-is-a-title-101. The last section on the URL shouldn't be prefixed by edit-site-article.

What could be the cause?


texts: Exclude node from search API results based on values in existing fields

texts:
My content node includes a verified checkbox that's marked by a human reviewer who then also enters a date. The node is verified only when the box is checked and the date is entered. A content node may be published before it is verified.

How can I keep an unverified content node from appearing in search API results?

One solution is to add a search API exclude entity field to the content node and to set the value of the exclude field in a presave hook based on the verified checkbox and date. This isn't difficult, but it seems there should be a more straightforward way of accomplishing what's needed.

I've looked at modules, but those I've seen don't seem to fit the need. I imagine I'm just missing something obvious, but what is it?

I don't think it's relevant, but I'll mention that I'm using Solr search.


texts: How can I create this sort of path structure?

texts:
Before I go ahead and implement my site's architecture, I'd like to check whether or not it's valid.

I have two taxonomy vocabularies that I want to use as part of my Pathauto settings. My site is a local accommodation guide, so I'd like to implement a URL structure like this:

mywebsite.com/cottages/Whitby/Little-Cottage
mywebsite.com/holidayapartments/Scarborough/Seaside-Apartment

                  ^                 ^             ^
                  |                 |             |----- Accommodation name
                  |                 |------------------- Location name
                  |------------------------------------- Accommodation type

Which follows the syntax mywebsite.com/[accommodation type]/[location]/[accommodation name]

Up until now, I've found it impossible to do this using just taxonomy tokens. I always end up with paths that look wrong.

A way around this seems to be to set each accommodation type as its own content type (for example, 'cottage' content types, 'holiday apartment' content types etc), instead of just having one 'accommodation' content type as I currently have then set the path settings for each content type like so:

Cottage content types: cottages/[termpath-raw]/[titlepath-raw]
Holiday apartment content types: holidayapartments/[termpath-raw]/[titlepath-raw]

Whilst this seems to produce the result I want, it feels more like a compromise than the correct solution. Before I go ahead and do this, I want to check that there isn't another way of setting up the path structure that I want using taxonomy tokens.

I'm also wondering what happens when I introduce multiple vocabularies for those content types - how will I ensure that the location vocabulary doesn't get replaced in the URL structure by another vocabulary (for example, if I use a vocabulary for holiday types - family, group, singles, couples etc - how do I ensure that this vocabulary doesn't take the place of the location vocabulary?).


texts:
Views are often used to modify entities (for example tasks and their status or priorities) and when a field is changed using an ajax button, a page or view refresh is required to update the rest (like row visibilithy, color, or other dependent fields).
Page or views refresh is not userfriendly, it creates a distracting interruption while the attention is drawn away from the field in question. Ideally only the row should be refreshed.

Is row refresh possible and if yes, how?


texts:
For the last months (without any significant change except modules and drupal core upgrades) I've been noticing that the First time to byte decreased from a not bad value (less than 300ms) to more than 2 - 3 seconds and I don't know why.

http://www.webpagetest.org/result/140518_61_6VV/1/details/

So I just moved from a shared hosting to a VPS but the First Time to Byte didn't change at all and I'm quite frustrated, could someone help me out please?

I'm using Boost, advagg, cache expiration and views content cache. Also I'm using Cloudflare as CDN but it didn't improve the performance either :(

I tried to analyze what's going on with the google developer tools (see attached image) but I cannot get enough information to figure out why so long waiting time.

Any idea?

Thanks in advance!


texts: Workbench moderation repeats "Save and " in the button labels

texts: My workbench moderation label is, for example, Save as draft, but the button says Save and Save as Draft.  How can I get rid of that Save and , which is repeated for every button?


texts: Why JQuery 2.x was removed since jquery_update-7.x-3.0-alpha2?

texts:
I noticed Version 2.1 of JQuery was removed from JQuery Update module since 7.x-3.0-alpha2.
Is there any particular reason for that I should be aware of?


texts: Disable the Fivestar widget after the first vote

texts:
Possible Duplicate:
  How to limit a user to one vote when using Fivestar?

I am a newbie to drupal. I am using Drupal 7, fivestar, userpoints and voting rules modules in my intranet site. I created new rules by using the Rules module to award points to the content author based on the rating (no. of stars etc.) provided by the logged in users. This is working fine.

But the problem is, whenever the logged in user clicked the fivestar widget, an event fires and the content author is getting points based on the rules defined. To resolve this, I want to disable the fivestar widget after the logged in user clicks the fivestar widget once.
How can this be done?

I am using the following modules:

Fivestar 7.x-2.0-alpha2
Voting API 7.x-2.6
Userpoints 7.x-1.0
Voting Rules 7.x-1.0-alpha1
Rules 7.x-2.1


texts: I'm adding an event list to a website and I want to limit what anonymous users see based on a field value, a checkbox "Private event". If the checkbox is marked then only a subset of the fields for the given event are shown. Furthermore, after a year of the event I want all fields to become visible to anonymous users. I took a look at the Access Control module but couldn't find a way to have this conditional type of access to fields. Is there another module that I could use?


texts: Show content with a date after the current one on a view

texts:
I'm creating a calendar of events with Drupal 7 using views. At the moment the elements are shown in order of the date of each one (I have a date field where I put the date of the event). Now I need that when the date is passed, it does not appear anymore.

For example, if I have an event that was held yesterday, today it would not have to appear in the view.

Thank you!


texts: How to anonymize IP logging by google analytics?

texts:
I'm trying to achieve the implementation of:

gtag('config', 'UA-xxxxxxx-x');

to

gtag('config', 'UA-xxxxxxx-x', { 'anonymize_ip': true });

How to do this in D7?

I tried to add it to advance options in the google. Looked in some technical documents in ga but do not see how to fill in this field in drupal.
Any suggestion?


texts: How to increase default Drupal minimum cache lifetime options to a custom value?

texts:
Currently the max page cache age is 1 day. I would like to icnrease to 1 year. How can I do that?

These settings are located at
/admin/config/development/performance

"Minimum cache lifetime"
"Expiration of cached pages"

Boost had a patch http://drupal.org/node/326683, wonder if this somehow could be applied for the core cache.


texts: What is the difference between renderPlain and renderRoot?

texts:
I added a login form to a node with following code :

function my_theme_preprocess_node(&$variables) {
  $node = $variables['node'];
  $variables['login_form'] = FALSE;
  $variables['username'] = FALSE;
  if(Drupal::currentUser()->isAnonymous()) {
    $form = Drupal::formBuilder()->getForm(\Drupal\user\Form\UserLoginForm::class);
    $variables['login_form'] = Drupal::service('renderer')->renderPlain($form); // renderRoot
  } else {
    $variables['username'] = Drupal::currentUser()->getDisplayName();
  }
}

If I change the line

$variables['login_form'] = Drupal::service('renderer')->renderPlain($form);

to

$variables['login_form'] = Drupal::service('renderer')->renderRoot($form);

I can't see any difference. Both seem to work either.

I read the docs, the latter mostly checks

  Whether we're currently in a ::renderRoot() call.

but it is not very explicit about why /when this check is useful and so when to use the former or latter function ?


texts: Problem trying to create a boolean view filter

texts:
Drupal 7.22
Views 7.x-3.7

Hi,
I have two similar content types and have added a boolean field to both (x for one and y for the other).
I want to create a view that displays any of the two types if x or y is true.

If I add the first filter criteria: Content: x (= Yes), I see a result in the preview pane.
If I remove the first filter criteria and add the second filter criteria: Content: y (= Yes), I see a result in the preview pane.

So both work on their own.
If I try to 'or' them I get neither?

I have tried this in various ways (one filter group or two separate groups).
I have also tried simplifying this by changing the fields to text but the or is still not working?

Please can anyone help or point me in the right direction?

Thanks!
a.


texts: Disable menu cache for hook_menu() implementation

texts:
There is a way to disable the menu cache ?

Context

Drupal 7

I have a custom module that implements hook_menu(). The link is showing up only if a view have results. It's working.

The problem is that I have to clear the drupal cache each time the view changes the number of results because the condition is not triggered anymore.

function gal_custom_menu() {

  $items['exhibitions'] = array(
    'title' => t('Current exhibition'),
    'page callback' => 'gal_exhibition_callback',
    'access arguments' => array('access content'),
  );

  return $items;
}

function gal_exhibition_callback() {

  $x = views_get_view_result('exhibition', 'page');

  if(count($x)) {
  $path = drupal_get_path_alias('node/' . $x[0]->nid);
  drupal_goto($path);
  } else {
  return FALSE;
  }

}

Do you have any idea how can I disable the menu cache ? Or is it the Views cache ?

Thanks


texts:
My admin toolbar doesn't showing up. $page_top in html.tpl.php doesn't have any value.

Why doesn't $page_top have any value? How do I fix this?


texts:
I would like to translate some jquery .change functionality to use #states in the form api.

var radio1 = jQuery('input:radio[name=radio_1]');
var radio2 = jQuery('input:radio[name=radio_2]');

radio1.change(function() {
if (radio1.filter(':checked').val() == 0) {
  radio2[1].checked = true;
}
else {
  radio2[0].checked = true;
}
});

radio2.change(function() {
if (radio2.filter(':checked').val() == 0) {
  radio1[1].checked = true;
}
else {
  radio1[0].checked = true;
}
});

Logic:
If radio1 value 0 is selected then radio2 value 1 will be selected.
If radio1 value 1 is selected then radio2 value 0 will be selected.
if radio2 value 0 is selected then radio1 value 1 will be selected.
if radio2 value 1 is selected then radio1 value 0 will be selected.

Looking at form_example_states_form() shows that the syntax is:

'#states' => array(
  'action_to_take_on_this_form_element' => array(
    'jquery_selector_for_another_element' => array(
      'condition_type' => value,
    ),
  ),
),

What's missing for me is "action_to_take_on_this_form_element". I don't know how to select value 0 or 1 of the radio button; all I have in terms of viable options is checked/unchecked (see drupal_process_states() for a list).

What I currently have

'#states' => array(
  'checked' => array(
    ':input[name="radio_2"]' => array(
      'value' => 0,
    ),
  ),
  'unchecked' => array(
    ':input[name="radio_2"]' => array(
      'value' => 1,
    ),
  ),
),

and this doesn't seem to work. I need something like checked[0] in order to select the value 0 radio button.

Edit: Here is the working code. Would like to not use inline js.

function your_form(&$form, $form_state) {
  $form['radios1'] = array(
    '#type' => 'radios',
    '#title' => 'Radios 1',
    '#options' => array(
      0 => 'zero',
      1 => 'one',
    ),
    '#default_value' => 0,
  );

  $form['radios2'] = array(
    '#type' => 'radios',
    '#title' => 'Radios 2',
    '#options' => array(
      0 => 'zero',
      1 => 'one',
    ),
    '#default_value' => 1,
  );

  $form['#attached']['js'][] = array(
    'data' => "var radio1 = jQuery('input:radio[name=radios1]');
var radio2 = jQuery('input:radio[name=radios2]');

radio1.change(function() {
if (radio1.filter(':checked').val() == 0) {
  radio2[1].checked = true;
}
else {
  radio2[0].checked = true;
}
});

radio2.change(function() {
if (radio2.filter(':checked').val() == 0) {
  radio1[1].checked = true;
}
else {
  radio1[0].checked = true;
}
});",
    'type' => 'inline',
  );

  return $form;
}

Demo video: https://www.youtube.com/watch?v=lXfMFaTTVes


texts: What are the consequences of not having an .htaccess file?

texts:
If I have an .htaccess file installed then I get HTTP 500 errors but if I rename it then I can get farther into the site - although not down to the nodes.

I'm unsure whether to pursue the problem with the .htaccess file there, or not.  System works locally, I am trying to install it on my ISP.


texts: Drupal 7 Views, Nested User > Content views filter by exposed date

texts:
I have a nested View. The outer view is a list of users, and that view has a field which includes a content View of everything that user has created. I have chosen to expose the date of that inner view in the hopes I can have an exposed filter on the outer view to control them. Ideally, I'd choose a month and year in the main view and see how much content, if any, each user has created in the last month.

Since the outer view is not a content view, I can't choose a date filter and hook that into the inner view fields. And I need to show all users regardless of whether or not they have content, so I can't go to a Content > Content nested view. Is there a date filter that's independent of content type that I could choose to inherit the exposed filter from the inner view, or that I could use to send a contextual filter to the inner view?


texts: How to condition SelectQuery by field value?

texts:
I have a view that receives taxonomy terms. Via pre execute hook, I want to only get terms the terms that have the current user referenced (in their field). I know it works via views itself, but there is more to it. I have to do it programmatically.

function tk_access_views_pre_execute(&$view) {
  if ('myview' == $view->name) {
    global $user;

    if (in_array('extern', $user->roles)) {
      $query = $view->build_info['query'];
      // debug($query->conditions());
      // $query->condition('field_referenced_user', $user->uid);
      $query->join(
        'field_data_field_referenced_user',
        'referenced_user'
        // 'field_data_field_referenced_user.field_referenced_user_target_id = '
      );
      $query->condition('referenced_user.field_referenced_user_target_id', $user->uid);
      $view->build_info['query'] = $query;
    }
    // debug(array_keys($view->build_info));
  }
}

But it doesnt work, unfortunately. What am I doing wrong?

Edit

If I add a contextual filter inside the view, I can debug the final sql statement:

SELECT
  taxonomy_term_data.name AS taxonomy_term_data_name,
  taxonomy_term_data.vid AS taxonomy_term_data_vid,
  taxonomy_term_data.tid AS tid,
  taxonomy_vocabulary.machine_name AS taxonomy_vocabulary_machine_name,
  'taxonomy_term' AS field_data_field_customer_taxonomy_term_entity_type,
  'myview:entityreference_1' AS view_name

FROM
  {taxonomy_term_data} taxonomy_term_data
LEFT JOIN
  {taxonomy_vocabulary} taxonomy_vocabulary ON taxonomy_term_data.vid = taxonomy_vocabulary.vid
INNER JOIN
  {field_data_field_projectstatus} field_data_field_projectstatus ON taxonomy_term_data.tid = field_data_field_projectstatus.entity_id
    AND (field_data_field_projectstatus.entity_type = :views_join_condition_0
    AND field_data_field_projectstatus.deleted = :views_join_condition_1)
LEFT JOIN
  {field_data_field_referenced_user} field_data_field_referenced_user ON taxonomy_term_data.tid = field_data_field_referenced_user.entity_id
  AND (field_data_field_referenced_user.entity_type = :views_join_condition_2
  AND field_data_field_referenced_user.deleted = :views_join_condition_3)

WHERE
  (((field_data_field_referenced_user.field_referenced_user_target_id = :field_data_field_referenced_user_field_referenced_user_target_id )
   )
  AND(( (taxonomy_vocabulary.machine_name IN (:db_condition_placeholder_4)) AND (field_data_field_projectstatus.field_projectstatus_value IN (:db_condition_placeholder_5, :db_condition_placeholder_6)) )))

ORDER BY taxonomy_term_data_name ASC

I still dont know how to get the additional conditions via SelectQuery object.


texts:
I'm setting up a site with cartaro and I've installed the openlayers editor module but it doesn't seem to be working.  I manually downloaded the ole js library as described in the installation instructions for the module, and I can access sites/all/libraries/ole/ole.min.js from my browser but it doesn't seem to be loaded when I open a page.  There are no errors showing up anywhere (i.e. no JS errors and nothing in the Drupal logs), although on a previous test site I got the following error when opening the configuration page:

  Notice: Undefined index: version in ole_requirements() (line 22 of /var/lib/openshift/528c88a2e0b8cd4d7d0000a4/app-root/runtime/repo/php/sites/all/modules/ole/ole.install)

As far as I can tell everything is set up correctly, i.e. I have installed and activated openlayers, openlayers-editor, libraries, so I have no idea what else to check.


texts: How to check term ID present in database table before updating

texts:
I need to increment a counter on every taxonomy page load. I am adding the code in taxonomy-term.tpl.php file in my theme. I need to add a new entry if the term is not present and need to increment the 'totalview' if its already present. Here is my code, can any one help me to add the condition.

db_insert('custom_file_download_count')
->fields(array(
  'totalview' => 1,
  'tid' => arg(2),
  'timestamp' => REQUEST_TIME,
  'uid' => $GLOBALS['user']->uid,
))

db_update('custom_file_download_count')
->fields(array(
  'totalview' => 1,
  'tid' => arg(2),
  'timestamp' => REQUEST_TIME,
  'uid' => $GLOBALS['user']->uid,
))
->expression('totalview', 'totalview + 1')
->execute();


texts: Is there a way to prevent a user from seeing a field on their user profile page?

texts:
I'm looking to create a 'Last Updated' field in a user's profile. I was then going to create a rule that filled that field with the current date everytime the user's profile was edited. I want the information for admin purposes and don't want the user to see this info.

Is this possible? I'd prefer not to use a module.

EDIT: I would be fine with the field being on the user-edit page instead (but still hidden) if that's easier.


texts: Import the content of a HTML page with XPath HTML Parser

texts:
I would like to import a specific item from an HTML page, and I want to get the "Uptime" column.

I installed XPath HTML Parser and configured it; when I run it on a node, I put these details:

  XPath HTML parser Settings:
  Context: //*[@class='DataGrid']//tr[@class='Odd']

I've created an simple content type with title and body, and put the following on the mapping settings:

  xpathparser:0 TARGET => Body

When import it always says, "No new nodes."

What is happening? How can I import it?

I tried using a Firefox add-on to generate the XPath, but when I paste it on the body or the context field, it is not accepted.


texts: How to add admin pages to Panopoly Pages

texts:
I use Panopoly and added admin/content to the page manager and added two variants. My question is, why doesn't the page show under admin/panopoly/pages ?

Which is the concept of the "Panopoly Pages"? I understand that not all pages, which are added to the Page Manager are Panopoly Pages. How is it determined which pages are listed under admin/panopoly/pages?


texts: Province/State list does not update when Country changes when set to "Dropdown" (Location Module)

texts:
The Location module is exhibiting a weird bug. When setting a location (Country & Province/State), if I use autocomplete for the Province field, it will only suggest provinces in the selected country.

However, when I change it to a Dropdown, the Province/State field does not change, despite the AJAX refresh clearly working (the Province/State field fades in and out, so the AJAX callback is clearly working).

I've used the Webkit Inspector to check the page and there's no JS errors and there is an AJAX callback (however, since I don't have a base reference from a functional site, I'm not sure what data payload I should be expecting to see in the callback).

EDIT: I figured out a solution, but Drupal Answers won't let me answer my own question for another 6 hours. For the sake of anyone else who may be running into the same issue, I've uploaded the code + explanation in a pastie.

EDIT: Nevermind, that didn't entirely work... Will update once I find a working solution.


texts: How to wrap a contact form with another block?

texts:
Is there a method to wrap a contact form with another block and make them together a new block or something?

I want to put some information next to the contact form and put them together in a container. Furthermore I want to place other blocks above and under it, so I prefer not to edit in the region twig file.

Note: I want to have some text next to my contact form. So it doesn't neccesary have to be a block, but that was the first that came up to me.


texts: How to set all subusers created by a user, or their role, to expire on a specific date

texts:
I need to create licensing functionality for a website. Part is done: via the subuser module, I can set up a licensing admin who can create a certain number of subusers that function as licenses based on role perms. So far so good. The admin's role can be set to expire through ubercart.

Here's the difficulty. I need the subusers to either lose their role or be deleted when the licensing admin's role ends. I had thought the Role Expire module (www.drupal.org/project/role_expire) would solve this problem, but it sets expiration based on duration, and I need all the subusers to expire on one specific date, no matter when they were created.

I've considered Rules, along with possibly setting a field on the licensing admin, using a view, somehow using the relation created by the subuser module, but I don't see how to get that to work.


texts: What do I do after I merge feature files with a remote server?

texts:
I'm having real trouble getting my head around the Features module. Would someone be able to help me understand it a little better? Perhaps describe it in laymans terms?

Here's the scenario I am working on right now:

I've made a change to some mini-panel and want to move those changes to a remote server with Features.

I create that feature and add the mini-panel and download the files. This part seems fine - I can even view my changes in the file's code. I then merge these files onto my remote server.

It's here I get a bit stuck. Now what do I do?

When I find my Feature in /admin/structure/features it's overridden. What do I do next to update my mini-panel on the remote server?


texts: Selecting the right pattern for adding in robots.txt

texts:
I've some views with exposed filters but I find that Googlebot is indexing them. In short I don't want any of those Views content by generated exposed filters to be seen by Google.

This page has listed more about it.

I want a pattern which should work for almost all views by restricting access to content generated by changing exposed filters.

Will this cause any issues?:

Disallow:/*&sort_order=*

Assuming we always specify sort order in Views. Is there any other module(s) which may generate url containing this parameter?


texts: Is it possible to get the field value of user reference autocomplete from username?

texts:
I am able to find the username. From the username I need to fill the user reference field.

Is there a way to get the user reference field value from username?

Example:

I have username: abc
I need Reference field value: Abc(201)

user_load_by_name('admin')

stdClass Object
(
    [uid] => 1
    [name] => admin
    [pass] => $S$DYk/jJiQjg07cciSAeU2EeP3XVMm/WhWHG19rA1iQf/FIqdOmY5p
    [mail] => test@gmail.com
    [theme] =>
    [signature] =>
    [signature_format] =>
    [created] => 1469189190
    [access] => 1511853833
    [login] => 1511853621
    [status] => 1
    [timezone] => Asia/Kolkata
    [language] =>
    [picture] =>
    [init] => test@gmail.com
    [data] =>
    [uuid] => 77ef7473-31cd-432e-ace6-26f1b075abb5
    [roles] => Array
        (
            [2] => authenticated user
            [3] => administrator
        )

    [rdf_mapping] => Array
        (
            [rdftype] => Array
                (
                    [0] => sioc:UserAccount
                )

            [name] => Array
                (
                    [predicates] => Array
                        (
                            [0] => foaf:name
                        )

                )

            [homepage] => Array
                (
                    [predicates] => Array
                        (
                            [0] => foaf:page
                        )

                    [type] => rel
                )

        )

)


texts: How can I expose Drupal data to external applications?

texts: How can I expose data from my Drupal site via web services to external applications such as iPhone or Android?


texts: How to restrict access to specific php file to only athenticated users

texts:
I manually made a php file that has the ability to connect to the database and create table entries, it works fine, but now the problem is that if I leave it there, anyone will be able to access it to create entries.
So I want to restrict the access to that file to only authenticated users, I think this may be posible using the .htaccess file, but I don't know how just yet.


texts: After doing a file_save_upload() how do you resize the images?

texts: I created a custom form in Drupal 7 with the ability to upload an image by using file_save_upload(). The image file has been uploaded and a fid has been assigned to it. How do I render this image into the different image styles I have setup?


texts: Is it possible to invoke cron within a hook or route class?

texts:
I'm using the Deploy suite, which requires cron to be run after a deployment is created. However, when I try to execute \Drupal\Core\Cron::run(); from hook_entity_create() or from a route Class, it doesn't work. It dies after hitting $this->accountSwitcher->switchTo(new AnonymousUserSession());, throwing the error Using $this when not in object context in Drupal\Core\Cron::run().

Is this just simply not possible? Is there a way around these errors?


texts:
For security purposes, I need to add a form_token to the login form. However, when (in hook_form_alter) I use the same code Drupal uses in form.inc for other forms, the validation fails because the token calculated during validation is different from the one calculated originally.

The code I'm using is:

if (!isset($form['#token'])) {
  $form['#token'] = $form_id;
  $form['form_token'] = array(
    '#id' => drupal_html_id('edit-' . $form_id . '-form-token'),
    '#type' => 'token',
    '#default_value' => drupal_get_token($form['#token']),
    // Form processing and validation requires this value, so ensure the
    // submitted form value appears literally, regardless of custom #tree
    // and #parents being set elsewhere.
    '#parents' => array('form_token'),
  );
}

I'm calling the form with drupal_render(drupal_get_form('user_login')). I'm aware that Drupal is not using the form_token on the login page because it is often cached, but I have disabled the cache for that page in hook_init with:

$GLOBALS['conf']['cache'] = FALSE

How can I add and validate a form_token in the login form? I'm using Drupal 7.

Some extra info as to why I need this. The request to secure login forms against CSRF came up during a security scan and although I do not agree with the explanation for the request (easier to setup a brute force attack, despite auto blocking logins in such cases), there is a good explanation on stackoverflow as to why this still can be a good idea: Do login forms need tokens against CSRF attacks?


texts:
In my site, I get the following error:

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cambodia_ohchrProduction.ohchr_cache_block' doesn't exist: TRUNCATE {cache_block} ; Array ( ) in cache_clear_all() (line 167 of /home/cambodiaohchr/public_html/includes/cache.inc).

How can I fix problem?


texts: Is it possible to set up multisite with drush including folder creation and database setup?


texts: Creating custom form at registration process for unknown number of nodes

texts:
I have a project where I want to add one OR more "nodes" or content types at registration time. For example, I enter my name and email adress, and then I can add one or more trip (example) I made, and then, later, the content of the site itself will be modified by this information. For example, the main menu could display a tab for each trip (trip1, trip2, etc.).

Any idea where I should start?


texts:
I am working with Drupal 7. When I use the following code, nothing shows up in the form; when I change managed_file with file, everything is fine.

$form['mfile'] = array (
  '#type' => 'managed_file',
  '#title' => t('File to upload'),
  '#size' => 22,'#upload_location' => 'public://vm-files',
);

Do you know why this happens?


texts: Get rid of default block style for drupal menu block module

texts:
After lots of trying, i finally managed to find out how to make my menus active in drupal 7, using the drupal menu block module.

There is one nasty thing which i can't find just a simple solution for, a default block style is still surrounding my menu, and i need to get rid of that.

I tried to override the blocks using:

menu-block-wrapper--[menu name].tpl.php

Problem is, it changes only everything within the block.

I can't add any pictures yet, but i asked the same question on stackoverflow.com, so there you will find the example of what i mean with a gray area around my menu block.

Anyone any idea's and suggestions on how to solve this? I know there is something i can do with the theme hooks, but i really got no clue on how to use it to get rid of the gray area...