texts: Formatting elements without formatting similar elements throughout entire site

texts:
So I've been fiddling around with elements, or blocks around my site.

I find the element or item I want to change my right clicking it in my browser and clicking "Inspect Element". Then, I find where the CSS file is and head to that directory in my FTP client. When I find the class or styling section, I copy that to my theme's global.css file.

However, when I edit some class/header/basically anything, any other object in my site that uses the same titled class is affected.

If my descriptions aren't very clear, here's my attempt at clarification. So let's say www.example.org/home has a H1 class that I'd like to center to the left. But there's an element over at www.example.org/aboutus that also uses the H1 class style. If I copy and edit the H1 class into my global.css file, both of those elements are affected, when I only want the one at www.example.org/home to be changed.

Is there a way to go around this? Should I try renaming the class that the element in www.exmaple.org/home so that it doesn't end up using the same class as everything else?


texts: Drupal form #ajax callback and javascript toggleClass on radio buttons - reduced functionality

texts:
we're using drupal and I have setup an ajax callback on a form item. The form item is a radio button with two options on/off. also attached to the radio button is some js to toggle a class. The class will toggle correctly as long as the callback is commented out

Here is a paste of my code:

// Making a call to web service and getting value to determine class

<?php
if (($user_alert['endDate'] == $today) || ($user_alert['endDate'] > $today) ) {

$activeFlagClass = $user_alert['activeFlag'];
$active_flag_class = get_active_flag_class($activeFlagClass);

$alerts[] = array(
  'activFlag' => $user_alert['activeFlag'],
  'activeFlagClass' => $active_flag_class,
  'adhMedicationAlertId' => $user_alert['adhMedicationAlertId'],
  );
}

// This is the theme template where I am printing the class and calling a form

<?php foreach($alerts as $key=>$value): ?>

      <div class="list-alerts-item <?php print $value['activeFlagClass']; ?>">

        <?php
        $active = $value['activeFlag'];
        $alertId = $value['adhMedicationAlertId'];
        $alertsActiveFlag = drupal_get_form('innovicares_alerts_active_flag_form', $active, $alertId);
        print drupal_render($alertsActiveFlag);
        ?>

<?php endforeach ?>

// This the form with attached js for toggleClass and attached #ajax callback

<?php
function innovicares_alerts_active_flag_form($form, &$form_state, $active, $alertId) {
   // Init variables
  $active_flag = '';
  $alert_id = '';

  // Let's define the default value for $active
  if ($active == 'true') {
    $active_flag = 1;
  }

  if ($active == 'false') {
    $active_flag = 0;
  }

  // Toggles alert form based on $active
  $form['#attached']['js'] = array(
    drupal_get_path('module', 'innovicares_alerts') . '/js/alerts.js',
  );

  // krumo($active_flag);

  $form['alert']['active_flag'] = array(
    '#type' => 'radios',
    '#attributes' => array(
      'class' => array(
        'alert-active-flag-radio'
        ),
      ),
    // Get default from callback
    '#default_value' => $active_flag,
    '#options' => array(
      1 => t('ON'),
      0 => t('OFF')
      ),
    '#ajax' => array(
      'callback' => 'set_active_flag',
      'event' => 'click',
      'progress' => array('type' => 'none'),
      ),
  );

  // Let's define the alert id
  $alert_id = $alertId;

  $form['alert']['alert_id'] = array(
    '#type' => 'hidden',
    '#default_value' => $alert_id,
  );

  // Return the form
  return $form;
}

// This is the #ajax callback

function set_active_flag($form, &$form_state) {
  // Init variables
  $current_active_flag ='';
  $active_flag = '';

  $alertId = $form_state['values']['alert_id'];

  $current_active_flag = $form_state['values']['active_flag'];

  if ($current_active_flag == 1) {
    $active_flag = deactivate_active_flag($alertId);
    krumo($active_flag);
  }

  elseif ($current_active_flag == 0) {
    $active_flag = activate_active_flag($alertId);
    // krumo($active_flag['data']['activeFlag']);
    // This is coming back as false

    // $_SERVER['PHP_SELF'];

    return $active_flag;

  }
}


texts: Filling compound field programatically fails with EntityMetadataWrapperException

texts:
I followed the instruction in the post from here to create a compound field and it work like a charm. Now I am trying to fill each of the 3 "columns" that make the compound field programmatically and I can figure it out how.

I am using the entity API to create the node see the code below:

$node = entity_create('node', array('type' => 'MY-CONTENT-TYPE'));
$entity = entity_metadata_wrapper('node',  $node);

$data = array('column_1'=>'value 1', 'column_2'=>'value 2', 'column_3'=>'value 3');

$entity->field_custom_compound_field = $data;

$entity->save();

But it does not work. What am I missing?

Note: I keep getting the error:

  EntityMetadataWrapperException: Unknown data property field_custom_compound_field.


texts: Display related nodes with taxonomy hierarchy in a View

texts:
MY taxonomy is set up like:

* Parent term
    * Child term

I have a content type with a term reference so they can select the term it is associated with.

And I need a view that displays a result like:

* Parent term
    * Child term
        - Related node
        - Related node
        - Related node
* Parent term
    * Child term
        - Related node

Is this possible with drupal 7 Views 3?
I am able to relate nodes with only one level of taxonomy hierarchy, but not two. Every example I have come accross does not display related nodes with children terms, only with parent terms.
Any help would be appreicated!


texts:
I have two Content Types (Country, City).
I want to display full contents of City in Country, so I did like this:
- create a field in World Content type
- set this field as entity reference (City).

Drupal print the two City contents in World successfully but I want put the city content in horizontal tabs.

I tried the module references_tabs, but it can put only one field reference at time.

How can I do so?

Thanks


texts: Drupal 7 skip node in hook after node save

texts:
In my custom module I am creating a node using node_save. I have also implemented hook_node_update to catch a user updated node. But every time I call node_save, it also calls my hook. Is there a way I can tell that this update was called using my node_save.
In Drupal 6, I used to add something like $node->skip_it = TRUE in before node_save, and this was available in the update hook. But not any more. Any pointers.


texts: RSS Feed does not validate using Views RSS module

texts:
Drupal version: 7.14

Views RSS version: 7.x-2.0-rc3

I am trying to validate an RSS feed in feedburner for a drupal blog. When I try to validate de xml file at feedvalidator.org I get this error

line 3, column 0: XML parsing error: <unknown>:3:0: XML or text declaration not at start of entity

The xml file is well written (I compared it against another one which validated) and the error I found is that that xml file generated by Views RSS puts three blank lines at the beginning and therefore I think the file does not validate.

I've looked for answers in the oficial Views RSS module issue track but unsuccessfully. I've also created many feed views using Views RSS module, but all of them provide the same error at feedvalidator.org.

I'd like to correct this through the source code of the module, but I do not know where to start or which file I should edit to correct that mistake, just if only through code I could solve this validation.


texts: User organic groups for paid elearning courses?

texts:
I don't know very much about the Organic Groups module.

I have a client that is interested in a course learning system and have that content restricted by groups. Each paid user would checkout and purchase this course.

Would organic groups be good for this particular feature?


texts:
I have several Drupal sites hosted on my shared hosting server. Each site has a dev, test and production instances, with separate Docroots and Apache Vhosts and separate mysql db instances. Not using features module.

Production db has real live data in it. dev and test dbs have dummy data. But as per the development workflow, if a new module has to be installed the developers do it in dev and test instances. That creates a new table and some records in the dev/test db instances.

Now that if they want to have the same module installed in the production site, I want them to able to run an operation via web which takes that particular table/data to the production instance from dev/test.

To explain bit more: This is what I need.

A ==> Test Site

B ==> Production Site ==> Real Data

A new module is installed in A. This creates a table and some records in A. We should be able to take that particular table/data from A and import into B keeping all the B's data consistent. And we dont really know what table is created in A. This is all done by the developers.

In a nut shell. B = (A U B) i.e. B should become A Union B

I tried mysqldiff but that works only for schema but not data.

Ideas please.


texts: Value from ajaxified form field not passed to ajax callback

texts:
This is a continuation of this issue, where I couldn't get the ajax to fire on an entity reference field in a node edit form. With the following code, I'm able to get the ajax to fire.

/**
 * Implementation of hook_form_FORM_ID_alter()
 */
function mymodule_form_blog_node_form_alter(&$form, &$form_state, $form_id) {
  $form['field_video_reference']['#ajax'] = array(
    'callback' => 'mymodule_video_ajax_callback',
    'wrapper' => 'my-path-div',
  );

  $form['my_path'] = array(
    '#markup' => t('My path'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#weight' => 6,
  );

  if (!empty($form_state['values']['field_video_reference']['und'][0]['target_id'])) {
    $form['my_path']['#markup'] = 'Token path: http://www.mysite.org/node/' . $form_state['node']->field_video_reference['und'][0]['target_id'];
  }
}

function mymodule_video_ajax_callback($form, $form_state) {
  return $form['my_path'];
}

The problem is that the value from field_video_reference isn't being passed to the if statement in the form builder or my callback, so the value from that field isn't displayed in the my_path field when the value is first selected on the node create form (it works fine if the node has already been saved and there is a value in field_video_reference when I edit the node). I'm following examples from the "Drupal 7 Module Development" book as well as from the Examples module, so I can't see what I'm missing.

Thanks.


texts: Possible to set user privileges on part of the text?

texts:
In my node I have embeded a view using php snippet in body field. When regular user edits it I don't want him to accidently delete the snippet, is there a way to hide or lock that part of the text from that user so no matter what he does the snippet will remain there? Should I add a custom field just for it or are there a better options?
Also note, that the snipped could be placed in the middle of the body field content.

Thanks!


texts: How to set product price with rules on checkout

texts:
I want to set the product price for a special SKU in checkout.
Because i calculate the price based on the cart value this is needed.

I tried all rules but none is changing the price, how can this be done?


texts:
I have got the following error:

  SQLSTATE[28000] [1045] Access denied for user '**'@'localhost' (using password: YES) in lock_may_be_available() (line 165 of /home/*/public_html/**.com/includes/lock.inc)

Thinking of solving that error, I have changed the settings.php file www/mysite/sites/default folder.

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'ThemeTesterDB',
      'username' => 'root',
      'password' => '********',
      'host' => 'my host ip',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => 'theme_',
    ),
  ),
);

The site is still not working.


texts: How to hide/show view based on field's value?

texts:
Problem: I have a user directory that anyone can access, with pages for each user. However, there is a view (that's a block) with personal info that I only want shown to the user who's page it is, or users with an admin role. They are not the authors of the page. I know how to fix the admin role issue, and how to get the username using php, but not how to get the field containing the username of the person who owns the page. I can't use Views PHP, just Views. Thanks!

EDIT: I tried doing something where in the view's header I had

if ($current_user == "[field_user_name]") { ?>

Then in the footer of the view:

<?php } ?>

But that hasn't worked.


texts: Multisite Drupal 7 sharing same code base

texts:
I have existing Drupal 7 site and I want to create a sub-domain using the multisite feature of drupal.

I followed all the steps required for drupal multisite as below.

Suppose my existing site url is www.abc.com and I want to make a sub-domain as www.jobs.abc.com

Steps I followed.

Under sites folder I created a new folder jobs.abc.com and copied the default.settings.php file renamed it as settings.php

sites/jobs.abc.com/settings.php

2.My existing domain settings.php file is under default folder sites/default/settings.php

3.I Renamed the example.sites.php to sites.php and added the following two lines.

$sites['www.abc.com'] = 'default';
$sites['www.jobs.abc.com'] = 'jobs.abc.com';

Finally I installed the Multisite wizard module http://ftp.drupal.org/files/projects/multisite_wizard-7.x-1.3.tar.gz

I configured the module it is showing me the message

"Hint: the folders names should be the same as values of domain-folder array in the site.php file
Folders to be created: default,job.abc.com" please find the screenshot.

I have already created these folders there. I am not sure why its showing this message again.


texts: how to get the absolute path for files based on fid

texts: How can i get the absolute path for a file based on the fid? Sorry if this is a repeat, I did a search but was unable to find the answer.


texts:
I'm working on a drupal 7 site and my client would like to have a certain view export as a CSV once a day into a folder. My initial thought was to tie this functionality to our cron schedule, but I'm running into a wall. How can I add functionality to cron? And more specifically, how could I get a specific view to export as a CSV during cron?

Thanks!


texts: Getting a translated URL in a Node TWIG template

texts:
I was referring to this documentation, but am unsure if what I'm trying to do is possible: https://www.drupal.org/docs/8/theming/twig/functions-in-twig-templates#path

In the section, it refers to this on building a URL:

{# Link to node page. #}
{{ 'View node page'|t }}

This returns a TRULY relative URL, in the sense that if I'm on an English node, the URL is translated to english.  If on a Spanish page, the URL is translated.  The thing is, I'm trying to create a link in the nodes to the OTHER language, so I need to be able to create unique links for each language in the opposing language's TWIG.

Anyone know of a way to get this URL in a language-dependant manner?


texts: How to create basic Organic Groups functionality with flags and references?

texts:
I've used Organic Groups for the past 6 months and found it to complex for my simple use case. Creating even basic views to show users of a group or content of a group turns quickly into "rocket since".

The module comes with a ton of extra functionality that I didn't need, like access control.

Plus I couldn't migrate my group content and group membership and when I manually inserted into the tables it wouldn't work reliably.

Below is my solution to create basic OG features with flag and reference modules. My requirements were:

users can create groups
users can join groups (and leave them) without approvals or permissions
users can add other nodes to show up as group content
use views to display group content and group membership

Please post your comments or alternative solutions.

Btw, Clive encouraged me on meta to post this how-to. Thanks, Clive!


texts: How can I override a link in the language menu?

texts:
I'm using the i18n module and Views. I have a separate view for each language and the language menu obviously doesn't line up for each of those views. I want to be able to adjust the links for the language menu when I'm on each of those view pages so they map to the corresponding view in the other language?

Where/how would I adjust those links? Would it be something in the template.php file for the theme or should I do it in a custom module?


texts: Any reason why a theme preprocess_field function would not be called by a view?

texts:
On my site I use Views and Display Suite, sometimes together, sometimes separately.

In on of my Display Suite layouts, I have a certain field displayed and the field itself is modified by a function

theme_preprocess_field(&$variables)

Using Display Suite, it works fine. Now on another page on my site, I am trying to display the same field using a Views page view. The field is specified in the view, but the preprocess function is not being called.

Do you think it has to do with the fact that I have this in a custom module file:

/**
* Implements hook_views_api().
*
* Enabling using templates inside module
*/
function mycustom_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'NAME'),
    'template path' => drupal_get_path('module', 'NAME'),
  );
}

I am trying to avoid putting any custom files in my theme folder because it doesn't make sense (what if I want to change themes?). So I need a way for all my custom stuff to work as a module.

Thanks


texts: How can create a template for user login form?

texts:
how can I create twig template for user login form page: /user/login
Is there any Twig Template naming suggestion for that?
thank's for any help.


texts: vbo action without selecting row (in other mean all rows)

texts:
Is there any option available to apply bulk operation on all rows of views result, which means no need of selecting any rows?

A good example is in GMail's Delete all spam messages now which deletes all rows (spam mails) without complaining about row selection.


texts: How do I disable the default node creation form for a particular node type?

texts:
I have a node type recipe, which should only ever be created via a custom route that causes it to be linked to a parent food type, ie. if the user visits node/add/recipe/1 they will see a recipe creation form that is linked to node 1 of type food.
Now I want to disable the /node/add/recipe route and prevent the recipe node from appearing on node/add. What's the best way to do this?
Note that this is not just a permissions issue - with my module it simply doesn't make sense for a recipe type to be created without a food that is linked to it, so visiting the node/add/recipe page simply doesn't make sense, even for an administrator.


texts: Customize "view modes" and "form modes" based on role

texts:
Drupal 8 has extended the View Modes concept to Form modes

Is it possible to assign a role to both "View Modes" and "Form Modes"?
How does one assign a mode both view mode or form mode to be shown at a particular place ? Say I wish to Full content view mode shown at certain page and Teaser view mode show in a block at another location. Similarly I want form mode A show during create and form B during edit.

For example there is a content type with following Fields

Title : displayed publicly, editable by author
Body : displayed publicly, editable by author
Project code : Not displayed publicly, displayed and editable by author
System code : only visible/editable by admin

Essentially this could be an interesting and performant way to implement field permissions. The field permissions module has no port for Drupal 8 yet.


texts: Views AJAX pager not working, though AJAX is enabled

texts:
I have a view of 6 news items on my front page. These get rendered in teaser mode. I enabled a pager of 6 items, and also enabled AJAX as you can see in the settings below. AJAX is enabled in the Drupal modules, I am not blocking Javascript and the ajax.js file is loaded fine when I inspect my site. I have checked the console for errors, but no errors were shown. I tried to disable semantic views, but to no avail.

The view export can be found here, and the site can be found here. This is just a test environment: some other pages may not work.

A bigger image can be found here


texts: Get the body of content referenced in an Entity Reference field in node

texts: I have a content type "event" which contains an entity reference to another content type "speaker". The speaker content type contains image and body fields. If I select a speaker for my event, I am only able to output a link to the speaker within the event node page. Is there a way I can output the image and body fields within the referenced speaker content in the event node page?


texts: How to create nodes automatically using title, fields, etc from some other nodes?

texts:
I want to generate nodes for a content type using fields of some other content types. For example I have three content types A,B,C. All three content types have some common fields as well like Title, Category and Date. I want to create another content type D to hold only those common fields.

Now here I want to generate content automatically for content Type D. I'm looking for a technique in which I can define that, "fetch data" from these common fields of A,B C content types to fill fields of content type D and generate nodes automatically for content type D.

Any suggestions about how to get this to work?


texts: Error Passing Extra Parameter to Custom Form

texts:
I have a simple custom form that works until I try to add a custom parameter for my module called "forms_admin".

These are the contents of my forms_admin.routing.yml

forms_admin.settings:
  path: 'admin/config/system/forms/{arg1}'
  defaults:
    _form: '\Drupal\forms_admin\Form\FormSettings'
    _title: 'Forms Settings'
  requirements:
    _permission: 'access content'

This is a relevant part of my FormSettings.php file (Currently do not have any custom Validation or Submit actions)

public function buildForm(array $form, FormStateInterface $form_state, $arg1 = NULL) {
    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#required' => TRUE,
    );

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

return $form;
}

And my third file is: forms_admin.links.menu.yml

forms_admin.config:
  title: Forms
  route_name: forms_admin.settings
  parent: system.admin_config_system
  description: 'Forms settings'
  weight: 0

The moment that I add {arg1} to my forms_admin.routing.yml and , $arg1 = NULL to my FormSettings.php file, I am unable to acces the website.

I receive a white page with the error that states:

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

After removing arg1 from my two files and going to the Recent Log messages, this is the error I receive:

  Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("arg1") to generate a URL for route "forms_admin.settings". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 182 of /var/www/test_site/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php).

I have tried changing arg1 to other names, not making $arg1 = NULL, etc. and I receive an error every time.

What am I missing?


texts: How can I ensure a referenced entity is cached separately per paragraph?

texts:
I have a situation where two Paragraphs on single page may potentially reference the same entity.

The affected paragraphs have a field to change their colour, and this colour value is passed down to the referenced entity (via hook_preprocess_[entity-type]) for use in its template.

Node

field_paragraph

Paragraph1

field_colour
field_entity_reference (references entity:1234)

Paragraph2

field_colour
field_entity_reference (references entity:1234)

When I update Paragraph 1 to change its colour, this is currently affecting the colour of Paragraph 2 (because the entity is cached, including the colour value that is preprocessed into it).

I have tried adding a cacheable dependency (in hook_preprocess_[entity-type]) to transfer the cache tags for the paragraph to the entity, so that when the paragraph is updated, it invalidates the cache for the entity it is referencing:

$renderer = \Drupal::service('renderer');
$renderer->addCacheableDependency($variables, $referring_entity);

I have also tried replacing $variables in the above with $variables['elements'] and $variables['content'], but either way this does not seem to work as I expected.

Any advice appreciated.


texts:
I'm manually printing my node fields on its template (node--TYPE.tpl.php). Something like:

<?php print $year; ?>

And my hook_preprocess_node() looks something like:

function MY_MODULE_preprocess_node(&$vars) {
    switch ($vars['type']) {
        case "my_type":
           if (isset($vars["field_year"]["und"][0])) {
              $vars["year"] = $vars["field_year"]["und"][0]["value"];
          }
        break;
    }
}

The output is fine to all fields; however, when I view the node as administrator, no output is printed. I listed all the variables from the hook to see what was happening with the following code.

function MY_MODULE_preprocess_node(&$vars) {
    var_dump($vars);
    ....
}

I'm getting all fields without the "UND" value, $vars["field_year"][0]["value"] instead of $vars["field_year"]["und"][0]["value"].

Do you have any clue why this happens?


texts: Convert "long text" field to "long text with summary"

texts:
On my site I've many nodes with a "long text field".
Is there a way to change, also programmatically, this field to a "Long text with summary" field?


texts: How to add Replace (mysql) function in view query condition field

texts:
I am using EntityReference Autocomplete with filter by entity reference view. And I want to ignore space in search filed.

For example, column username in DB has value first name it should popup when user types first or firstname. To achieve this I wrote hook_views_query_alter to change the condition, I would like to pass the condition as REPLACE(username, ' ', '') LIKE '%firstname%'.

Even if I set field value in condition to REPLACE(username, ' ', '') its getting changed to REPLACEusername. Even I tried running the query separately, like below in node,

$query = db_select('node', 'n')
              ->fields('n', array('title'))
              ->condition('type', 'article', '=')
              ->condition('REPLACE(n.title, \' \', \'\')', $category, 'LIKE')

When I output query prints like below,

    SELECT n.title AS title FROM {node} n WHERE (type = 'article') AND (REPLACEn.title LIKE '%articleone%' ESCAPE '\\')

How can I set it correctly? Is there any other way to do?


texts:
I would like to sell subscriptions on a site and have the person logged in automatically.

I have setup the contribution page and it works fine. The person at the end of the process doesn't get a drupal account or become logged in. We created a custom module to create the person's account at the end of the process. We haven't found a way to log them in though.

Ideally the person can register/pay/be logged in as one step. We are afraid that if we get them to register a drupal account, confirm the account and then pay the membership we will lose a lot of people as it is 'too complicated'.


texts: Pass contrib module tokens to custom event in rules

texts:
I am creating a custom rules event using hook_rules_event_info. This custom event is extending the features of the Stripe Subscription contrib module. The custom rules event is working fine so far.

Stripe Subscription creates several tokens for use within the module using hook_tokens. Is it possible for me to pass the tokens available in the module onto the custom rule event I have created so I can use them in the actions?

The event rule I have created looks like this:

function stripe_subscription_rules_event_info() {
  return array(
    'stripe_subscription_event' => array(
      'label' => t('A user subscribed'),
      'module' => 'stripe_subscription',
      'group' => 'Stripe Subscription',
      'variables' => array(
        'acting_user' => array('type' => 'user', 'label' => t('The user who is subscribing.')),
        'plan' => array('type' => 'text', 'label' => t('The purchased plan.')),
        'subscription_action' => array('type' => 'text', 'label' => t('The subscription acton')),
      ),
    ),
  );
}


texts: How to create a parent content type which consists of other child content types?

texts:
I want to create custom content type (parent) which consists of other custom content types (children). Is this feasible in Drupal 8? Or I should do it programmatically?

Example: I want to have custom content type called Task, and another custom content type called Subtask. When a user creates a task, the user has to complete some fields (id, name), and should then create some Subtasks which are children of this Task. For the subtask some fields are to be completed also. In the end, each task will have some data such as:

name = "task_one".
description = "this task should do ..".
subtasks = {"subtask_one","subtask_two"}.


texts: How to pass variable of paragraphs type to another preprocess function

texts:
I want to override the fontawesomeicons.html.twig (Fontawesome Module). But I only want to do this for "my-very-special-paragraphs-type" and not in general. I think it is a good idea to declare a variable of "my-very-special-paragraphs-type" in a preprocess function and use the variable in the twig-file.

function mytheme_preprocess() {
  $var = my-very-special-paragraphs-type
}

the fontawesomeicons.html.twig:

{% if var == 'my-very-special-paragraphs-type' %}

    {{ icons }}

{% else %}

   {% if layers == '1' %}
      {{ icons }}
   {% else %}
      {{ icons }}
   {% endif %}

{% endif %}

But I do not know how to do this. Can anybody help?

This is the hook of fontawesome module:


texts: multiple (two at least) user registration forms

texts:
I have built a registration form with a few custom fields, works fine. Now I need to another registration form, but with a dozen or so more fields. Both need to force drupal into its user registration/validation process.

it has to be done this way, I cannot just redirect a user to register first then fill out a survey.

Alex


texts:
First post here! ;) I'm not getting any help from the Drupal forums on this, maybe someone can help me out...Does anyone know of a module that I can use so that an Author can allow access to a user requesting access to the Author's node.
The setup would be like this:
1. An Author would create a private node, but viewable in teaser form.
2. Any Authenticated user could then request access to the node/full view.
3. The Author would then have a queue, say in their own user environment, where he/she could approve or deny access to the node/full view for the requesting user.
Thank you very much!


texts: Can't filter Calendar according to event date instead of date added

texts:
Hi I'm trying to figure out this issue as well. i have calendar that only shows the dates the event has been posted, not the actual start date for which I created the field.
I can't seem to filter dates according to their start day. When I try to filter it, it's not giving me the date field option. :( Can someone direct me toward good tutorial or help me set it up. Thank you in advance.


texts: Share single CUSTOM function across multiple themes

texts:
I have some repetitive code that I'd like to share across two separate themes. Is there a best practice for something like this?

I know I can simply create an include file in the sites directory and do it that way I just wasn't sure if there was another way to do it that would be cleaner?

Thanks in advance!!


texts: How do I add special characters in the dialog in CKeditor and WYSISYG?

texts:
I am using CKEditor 3.6.3 along with WYSIWYG for filtered HTML, and I am using the default special characters plugin that is already available.
I want to modify the pop-up dialog that opens up and add certain other special characters like alpha, beta, gamma, etc, but I do not seem to get it working in filtered HTML inline. If I change the plugin.js file to add these special characters, I cannot see them getting updated in the pop-up.

Can anyone advise on what I should do? My SQL server supports UTF-8 unicode, and so does the browser.


texts:
I am new to Drupal and have been working with Webform module to generate a custom form. One of the requirements for the form is to show a table where a user can add upload documents like this:

I created a new webform and started adding fields. As I added the 'table' field, it had option to set table Header (th) but not rows (td). I am not very familiar with the idea of hooks. Can someone please tell me how I can add rows? And if it is not possible to be done via the UI, then in what files the code must be added?

I am using Drupal 8.


texts:
I'm using the following function to render a image field in a template, this works great but I would also like to add a custom alt attribute to the image:

function <module>_render_field($node, $field_name, $delta = 0, $display = array()) {
   $field = field_get_items('node', $node, $field_name);
   $field = field_view_value('node', $node, $field_name, $field[$delta], $display);
   return render($field);
}

<module>_render_field($node, 'field_image', 0, array(
  'type' => 'image',
  'settings' => array(
     'image_style' => 'object_380x250',
     'image_link' => 'content',
   ),
));

I was trying to add the alt attribute to the image by changing the above code to:

<module>_render_field($node, 'field_image', 0, array(
  'type' => 'image',
  'settings' => array(
     'image_style' => 'object_380x250',
     'image_link' => 'content',
   ),
      'attributes' => array(
         'alt' => 'alternate'
      )
));

The above didn't worked but I managed to add the attribute by changing the module code to:

function <module>_render_field($node, $field_name, $delta = 0, $display = array()) {
   $field = field_get_items('node', $node, $field_name);
   $field = field_view_value('node', $node, $field_name, $field[$delta], $display);
   // add alt attribute
   $field['#item']['alt'] = 'alternate';
   return render($field);
}

I'm hoping there is a nicer way to achive this.


texts: "A fatal error occurred: Serialization of 'Closure' is not allowed"

texts:
I'm implementing a form using the Drupal form and AJAX. I've done this many times before, but now I stumble upon a problem I never seen before.

My AJAX event is called when the value of a textfield is changed.

'#ajax' => array(
   'callback' => array($this, 'ajaxRenderSheets'),
   'event' => 'change',
),

In my callback I refresh the form:

  public function ajaxRenderSheets(array &$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();
    $response->addCommand(new ReplaceCommand('#wrapper', $form['sheets-wrapper']));

    return $response;
  }

Then in my form, I check if the value of a field is filled out; if so, I execute a request to google sheets API (this form state value is filled out after the ajax request. So when the texfield above is filled out, this code gets executed).

  if ($spreadsheet_id = $form_state->getValue('spreadsheet')) {
    $spreadsheet_info = $this->googleManager->getSpreadsheet($spreadsheet_id);
  }

When that request is executed I get the error:

  A fatal error occurred: Serialization of 'Closure' is not allowed

Is this a Drupal core issue, or is this related to my code?


texts: Difference between DRUPAL_CACHE_PER_PAGE and DRUPAL_NO_CACHE

texts:
What is the difference between DRUPAL_CACHE_PER_PAGE and DRUPAL_NO_CACHE?

I'm developing a module that will generate 2 blocks for menu and it's sub-menu in different blocks and can't decide between those two options for the blocks.

links:
https://api.drupal.org/api/drupal/includes%21common.inc/constant/DRUPAL_NO_CACHE/7
https://api.drupal.org/api/drupal/includes%21common.inc/constant/DRUPAL_CACHE_PER_PAGE/7


texts: Update a field based on value of another field in node edit form

texts:
In the node add/edit form, I have a node reference field. When users select a node, I want to update another field with value of a field of selected node.

What's the best and easiest way to do this?

I want to load the value in the edit form, using AJAX or AHAH, so that the users can see it, and edit if necessary, not just updating the field after form is created.


texts: Open Menu Link In New Browser Tab/Window

texts:
I am having a problem with opening a menu link defined in a module.links.menu.yml in a new browser tab or window. Code for the link:

mymodule.mm_google:
  url: 'https://google.com/'
  parent: mymodule.admin_mm.external_index
  description: 'Search Engine'
  title: 'Google'
  options:
    attributes:
      target: _blank

I am working with Drupal core 8.2.4 8.2.5 and the link currently works except for opening a new browser tab or window.

Update:
The links are opening in a new tab/window when rendered by the Toolbar/Admin Toolbar modules but not when rendered and displayed by  admin overview controller \Drupal\system\Controller\SystemController::overview. The controller will also not render included classes for the anchor element.


texts: I need to set up a forum kind of discussion board for each group that is created. Can anyone help me with this.


texts: What happened to the "menupath" token in the URL aliases for Drupal 7?

texts: Again, am I blind? If my "Widgets" page is under "Products," I want the auto-alias to be /products/widgets. I can't seem to find that in Drupal 7.


texts: What date format is this? Or is it even a date?

texts:
I'm working with a Drupal 8.3.6 setup done by someone else and I have a date format that doesn't make sense to me. I'm interacting with it thru MySQL Workbench.
The best I can tell,
1499287512 = Wed, 07/05/2017 - 23:02
and
1501079338 = Tue, 08/22/2017 - 06:25
BUT there's no guarantee of that.
In any event, 1499287512 and 1501079338 appear to be in a date placeholder; numbers like it appear in users_field_data.fields, created, changed, access, login.


texts: Importing node_revisions records from version 5 to version 6

texts:
Probably a dumb question, but could I simply export an SQL file from the database of a Drupal 5 site and import it into a Drupal 6 database in the same table provided I used the same CCK fields for both? I've tried to migrate content in so many different ways and pretty much everything has failed so far... importing csv through the feeds module was my greatest hope and was made to look so easy but I keep getting an HTTP error.

Also is node_revisions the table that contains all of the stories? I tried exporting nodes, but it didn't seem to contain the body field.


texts: Using multisite for a ReSTful API and Auth Strategy

texts:
My Situation

I have a small app with a public interface. I'm interested in making an API for this to be used in a mobile environment and even eventually as a public API. I want to keep it simple with the priority on aspects like security and performance.

My Plan

Why Drupal? Well, I know Drupal and I can envision a setup where I have 2 sites. www.mygui.com (default) and api.mygui.com (API). All database structure is determined by the work done in the default site. Using the Drupal Services Module (and only a few other necessary core modules) on the API site I plan to allow authenticated updates to the database by way of JSON and the drupal_internal_api.

My Problem

I already have a prototype (not in drupal) that uses tokens. I'm new to services and don't really know all its limits and capabilities yet. This looks promising but still in the pipeline: Drupal Services Auth Token Module. I would like advice or resources regarding a good authentication strategy. For example, which is best? Keep the user base the same with assigned "API Uer" roles or have a completely separate user base specifically for the API site? Keeping in mind that an API username is a long term setup where the username/password or token should not change until the API user is ready with a new app release? Can I have a nice GUI for users to manage their API site credentials on the default site?


texts: combining two taxonomy fields into one exposed filter dropdown

texts:
I have created two taxonomy fields (home team and away team) with a content type.

I have created a views to display the list content of content type. In view, I have added taxonomy filter for home team and away team which is showing two taxonomy filter in the views page.

I would like to combine both taxonomy filter into single exposed filter.


texts: global webform submissions admin page per user

texts:
I have a site where users fill diferent webforms and they can visit formX/submissions to view/edit their own submissions for every particular webform.
Now I need to give users something like a submissions administration page, where they can have a global view of their submissions to all webforms and be able to edit which one they choose.
is it possible to build this global submissions page with webform?


texts: Difference between calling a service method in drupal 8

texts:
I want to know what difference does it make when i call a service this way :

$service = \Drupal::service('myservice.method');
$service->methodNameInService();

or this way (Dependency Injecton)

 public function __construct(MyService $myService) {
+    $this->myService = $myService;
   }

public function test() {
    // Call function from service
    $this->myService->methodNameInService();

}

Is this better for performance or is it just only the right way and has it zero effect on performance or something else?


texts: Javascript file is being included but console.log wont work

texts:
So I THINK I have configured my javascript right in that i want to inlude two files. leaflet.js and mappingsource.js and currently on the page source there exists this:

Whih both have settings? for the files that i want however the file mapping source looks like this

$( document ).ready(function() {
    console.log( "ready!" );
});

window.onload = "test()";

function test() {
    console.log('123');
}
console.log('test');
var map = L.map('map', {
    center: [51.505, -0.09],
    zoom: 13
});

Which should be console logging SOMETHING surely? Is there something I'm missing?
Additional files look like this
helloworld.libraries.yml
helloworld:
  version: 1.x
  js:
    js/leaflet.js: {}
    js/mappingsource.js: {}

<?php

/**
 * @file
 * Contains helloworld.module.
 */

helloworld.module
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function helloworld_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the helloworld module.
    case 'help.page.helloworld':
      $output = '';
      $output .= '
' . t('About') . '
';
      $output .= '
' . t('Hello World example module') . '
';
      return $output;

    default:
  }
}

function helloworld_page_attachments(array &$attachments) {

  // Unconditionally attach an asset to the page.
  $attachments['#attached']['library'][] = 'helloworld/leaflet';
    $attachments['#attached']['library'][] = 'helloworld/mappingsource';

}

/**
 * Implements hook_theme().
 */
function helloworld_theme() {
  return [
    'helloworld' => [
      'render element' => 'children',
    ],
  ];
}


texts: How do I display fields in my product type in a product display?

texts:
I have the unique parameters for my product.  Sometimes I want to display some parameters, and sometimes I don't.  So, I defined them in my product type.

My question is how do I display these fields for a product display?  I don't want to create a duplicate when the values are already defined in the product type.


texts: Drupal menu management seems lacking compared to WordPress: Am I missing anything?

texts:
I'm trying to understand how to best add content links to menus. As far as I can tell, there are two limited ways:

In the content edit screen, click the "Provide a menu link" checkbox. Shortcoming: This will only add links to the main menu- you can't target other menus from the content edit interface?
In the menu edit screens, you can add links. Shortcoming:  You have to spell out the paths. Seems like it would be a lot easier if there was a content finder on this screen so that you could easily select the content, a la WordPress and every other CMS.

I'm coming from WordPress, which has a basic but robust menu management system. Is Drupal just lagging in this regard? Are there better ways of handling menu links?


texts: Views entity reference based on passed in value

texts:
I have a set of taxonomies that are related to a role- each member of the role gets their own set of values, plus a default value that is common to everyone. For example:
uid | tid | taxname
20 | 200 | name1
20 | 201 | name2
20 | 202 | name3
21 | 203 | name4
22 | 204 | name5
0  | 205 | default
So users 21 & 22 each have 1 term plus the default term, user 20 has 3 terms plus the default term.

I am trying to figure out how to setup an entity reference View that would display the terms available to each user. I know how to setup the entity reference View based on the uid as a contextual filter, but can't figure out how to bring in the default value as well.


texts: How can I include php file in my module without using composer?

texts:
I want include PHP file in drupal 8 module.
What is the best way for it ?


texts:
This form creates dynamic fields. I am trying to build a submit handler for each of the dynamic field values.  So for each of the $form['items_fieldset'][$i]['serial'], (amount, and description) I could have many fields.  How would I pass those to my database?

Here's what I have thusfar:

Form excerpt:

$form['#tree'] = TRUE;

$form['items_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Shippment Inventory Items:'),
'#prefix' => '
',
'#suffix' => '
',
);

 if (empty($form_state['num_items'])) {
$form_state['num_items'] = 1;
}

 for ($i = 0; $i < $form_state['num_items']; $i++) {

$form['items_fieldset'][$i] = array(
'#prefix' => '
',
'#suffix' => '
'
);

$form['items_fieldset'][$i]['amount'] = array(
  '#type' => 'textfield',
  '#size' => 30,
  '#title' => t('Amount:'),
  '#required' => FALSE,
  '#prefix' => '
',
  '#suffix' => '
',
);

$form['items_fieldset'][$i]['description'] = array(
  '#type' => 'textfield',
  '#size' => 50,
  '#title' => t('Description:'),
  '#required' => FALSE,
  '#prefix' => '
',
  '#suffix' => '
',
);

$form['items_fieldset'][$i]['serial'] = array(
  '#type' => 'textfield',
  '#size' => 30,
  '#title' => t('Serial Number:'),
  '#required' => FALSE,
  '#prefix' => '
',
  '#suffix' => '

',
);
}

$form['items_fieldset']['add_items'] = array(
'#type' => 'submit',
'#value' => t('Add more'),
'#submit' => array('_nnreport_shipping_new_add_one'),
'#ajax' => array(
    'callback' => '_nnreport_shipping_new_callback',
    'wrapper' => 'items-fieldset-wrapper',
    ),
);

Handler to pass to database (not including all the static form values):

 function _nnreport_shipping_new_submit($form, &$form_state) {
    $submission = new stdClass();
    //This doesnt work, but I think it's kinda what I'm after...??
     for ($i = 0; $i < $form_state['num_items']; $i++) {
          $submission=>amount.$i = $form_state['values']['$i']['amount'];

          };
          _nnreport_shipping_new_update($submission); }

After that I submit the values of $submission to the database, like this:

function _nnreport_shipping_new_update(&$submission){

     db_insert('nnj_shipment')
        ->fields(array(
            'hotshotId' => $submission->carrier,
            'driver' => $submission->driver,
            'driverPhone' => $submission->driverPhone,
             //lots more of those...
              ))
             ->execute();

I've unsuccessfully tried a few variations to get the dynamic fields into the object...I would be very grateful for someone to point me in the correct direction.


texts: How do you add a fieldset to a content type in Drupal 7 to group fields? I don't see this option anymore. I just want to group related fields on a form together. Will that also trigger vertical tabs instead of let fields just float around in the open?


texts: Multigroup (CCK3) / FlexiField-like solution for compound fields?

texts:
I've used FlexiField in the past to do multiply occurring series of field groups; now, working on a Drupal 7 project, I'm setting up a "Resume" content type and need a way to set up repetitive entries for education/work experience.

IE: for "Education", I need the ability to dynamically add new rows comprised of a combination of dates and places for each institution studied at.

What is the best way to accomplish CCK3 multigroup/FlexiField-like functionality in Drupal 7?

Thanks!


texts:
how can I get total price of all orders which owned by a single user? I want to assign different type of discounts by finding about total amount of their orders.
I'm using

  hook_rules_action_info

.
should I use commerce_order_load_multiple() ?


texts: View exposed filter block no alter form with ajax

texts:
I am trying to filter out the no results items in my exposed filters. (I know i can use selective filters, but in this case i can't use them).

So i alter the filters with form_alter, check which options that hasn't got any results and unset those options.

It work's on first page load, but when my view is updated with ajax, the form alter isn't called. This only happens when the exposed filters are displayed as block. If the filters are inside the view, the form alter is called every time the view is updated by ajax.

Any suggestions to fix this? Add a class and work with a custom drupal behaviour javascript function to update this block?


texts:
I tried to get the string messages and create a condition based on the string, but I don't know how to pull the string value.

This is an example of message.


texts:
I created my custom content type and add field called 'Image' of type Image and set the content manager can set multiple images into it. Now this field is rendered as such html

Image:&nbsp;

I cannot find where are the template(s) which render this piece of html. I'd like to override it to render list of links, similar to

Image:&nbsp;

img1.jpg

img2.jpg


texts:
I have used featured to create  a yml file for views and other configurations.  When I import my yml file all that is created is a content type that has a title.  Is there a way to import the fields with the content type?

uuid: 1bd0f08e-cf80-4fc3-8707-7a9d19c404da
langcode: en
status: true
dependencies:
  module:
    - menu_ui
third_party_settings:
  menu_ui:
    available_menus:
      - main
    parent: 'main:'
name: Podcast
type: podcast
description: 'Allows Drupal to play an audio file.  The Embed Podcast field should contain the name of the Podcast exactly as it is uploaded to Drupal.'
help: ''
new_revision: false
preview_mode: 1
display_submitted: true

this is my file and there is nothing about the fields in a content type


texts: Delay ajax from firing immediately (AJAX links api)

texts:
Problem

I'm trying to add a bunch of CSS3 page transitions to my site. To do this, I'm loading the pages with AJAX using the AJAX Links API module, but I want to delay the AJAX call to allow for the animations.

However the ajax click handler seems to come straight from jquery.min.js, rather than module as I expected so I can't work out how to delay it. Does anyone know how to delay the ajax link click handler? (i.e. wrap it in a setTimeout.)

Details

I can prevent normal link clicks with:

  Drupal.behaviors.dsmooth_state = {
    attach: function (context, settings) {
      $('a.notajax').click(function (e) {
        e.preventDefault();                   // prevent default anchor behavior
        var goTo = this.getAttribute("href"); // store anchor href

        // funky animations go here.

        setTimeout(function(){
             window.location = goTo;
        },800);
      });
    }
  };

However the Drupal AJAX framework, uses a separate click handler for AJAX which is obviously not effected by this.

The AJAX Links API module defines the following click handler, however wrapping it in a setTimeout does nothing. I'm presuming that somehow this click handler sets the other one? I'm not really sure.

var ajaxLoading = false;
  Drupal.behaviors.ajaxLinksApi = {
    attach: function () {
      var trigger = Drupal.settings.ajax_links_api.trigger,
        negativeTrigger = Drupal.settings.ajax_links_api.negative_triggers;

      // match the elements from the positive selector
      var $elements = $(trigger);

      // remove elements if the negative trigger is specified
      if (negativeTrigger) {
        $elements = $elements.not(negativeTrigger);
      }

      // add the click handler
      $elements.click(function(e) {
        e.preventDefault();
        var selector;
        if(!ajaxLoading) {
          ajaxLoading = true;
          var url = $(this).attr("href");
          var id = $(this).attr("rel");
          if(id) {
            selector = $(this).attr("rel");
          } else {
            selector = Drupal.settings.ajax_links_api.selector;
          }
          ajaxBefore(selector);
          ajaxLink(selector, url);
        }
      });
    }
  };

//EDIT removed chrome information. I think I misunderstood what Chrome was putting out. It seems to list all event listeners as coming from jquery.min.js


texts: Properly building array and using with drupal_json_encode()?

texts:
I am trying to pass data from my database to a javascript variable, however I'm not sure if I'm correctly using drupal_json_encode(), or correctly building my 2D array.

When I check my console, the javascript variable only displays [], so the data is not being passed.

I know this isn't the very best way of doing this, but I am only trying to make a functioning prototype, and not a finished product

Here is a portion of my php code that is making the sql query, as well as the 2D array, and is located in my page--front.tpl.php:

<?php
$server = 'db.*****';$user = '*****';$database = '*****';$password = '*****';
$db = mysqli_connect($server, $user, $password, $database);

  if (isset($_GET['routeselected']))
  {
  $result = mysqli_query($db, "SELECT * FROM STOP INNER JOIN RouteStop ON Stop.Stop_ID = RouteStop.Stop_ID WHERE RouteStop.Route_ID = " . (int)$_GET['routeselected'] . " AND RouteStop.Company_ID = " . (int)$_GET['companyselected']);
  $items = array();
  while (($row = mysqli_fetch_array($result))){
      $markers[$row['title']] = array($row['Stop_ID']);
      $markers[$row['lat']] = array($row['Latitude']);
      $markers[$row['lng']] = array($row['Longitude']);
      $markers[$row['description']] = array($row['StopName']);
      }
    drupal_json_encode($markers);
    drupal_add_js(array('markers' => drupal_json_encode($markers)), 'setting');
  }
  ?>
];

and here is my google map javascript that is in my js folder and is being implemented to the front page via drupal_add_js:

var map = null;
var infowindow = new google.maps.InfoWindow();
var markers = [Drupal.settings.markers];

window.onload = function () {

var mapOptions = {
    center: new google.maps.LatLng(
        parseFloat(markers[0].lat),
        parseFloat(markers[0].lng)),
    zoom: 13,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
var path = new google.maps.MVCArray();
var service = new google.maps.DirectionsService();
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var poly = new google.maps.Polyline({map: map, strokeColor: '#F3443C'});

var lat_lng = new Array();
           for (i = 0; i < markers.length; i++) {
           var data = markers[i]
           var myLatlng = new google.maps.LatLng(data.lat, data.lng);
           lat_lng.push(myLatlng);
           var marker = new google.maps.Marker({
               position: myLatlng,
               map: map,
               title: data.title
           });
           (function (marker, data) {
               google.maps.event.addListener(marker, "click", function (e) {
                   infoWindow.setContent(data.description);
                   infoWindow.open(map, marker);
               });
           })(marker, data);
       }
for (var i = 0; i < markers.length; i++) {
    if ((i + 1) < markers.length) {
        var src = new google.maps.LatLng(parseFloat(markers[i].lat),
                                         parseFloat(markers[i].lng));
        var des = new google.maps.LatLng(parseFloat(markers[i+1].lat),
                                         parseFloat(markers[i+1].lng));
        service.route({
            origin: src,
            destination: des,
            travelMode: google.maps.DirectionsTravelMode.DRIVING
        }, function (result, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                for (var i = 0, len = result.routes[0].overview_path.length; i < len; i++) {
                    path.push(result.routes[0].overview_path[i]);
                }
                poly.setPath(path);
            }
        });
    }
}
}

Does anyone possibly know a solution to my issue? Thank you for all and any help!


texts: URL with "en" for english language does not work

texts:
I did implement the multilingual. I have successfully translated the content and interface in multiple languages. But when I try to use "/en" in URL for the English language which is the default. It does not work and shows me "404 Page" for default language only.

Can anyone please help me to fix it?

Thanks


texts: Separate panels variants for 'edit' & 'add' nodes of same type

texts:
[D7/Panels 3]

I have two different panels layouts - one for editing, the other for adding nodes of the same content type ("Contact Details").

A panel page for overriding 'edit' pages exists in Panels (in code), which I have activated. I've made a variant which works for 'edit' pages, but it is also overriding the 'add' page with the same layout.

I've added a context of 'Node add form' with 'Contact Details' as the 'Node type'. Also added a selection rule:

Node: type / Node add form is type "Contact Details"

Both forms still appear in the same panel layout (the one for 'edit' pages).

Help much appreciated :)


texts: Create a field with options are a combination of taxonomy terms, and content types linked to those taxonomy terms, for which the content type is used

texts:
This is a decoupled drupal 8 back end with an angular front end connected over jsonapi and other custom restful inputs.

We have a coupon content type in out Drupal csm.  It is exactly what it sounds like, a coupon.

We have a content type "products" and you can assign a coupon to that product when creating or editing said product.

We have a taxonomy term list of product categories and sub categories.

Category A
    Sub Category 1
    Sub Category 2
Category B
    Sub Category 3
    Sub Category 4
    Sub Category 5

An admin can go into a taxonomy term, and add a coupon to an individual taxonomy term, or to a product content type.

This is where it gets crazy.

We have a listing of coupons, on that list we want to give the admin the ability to display a "featured product" and ideally, in the CMS they have a field where the only options are either a taxonomy term or a product content type that said coupon has been applied to.

Product A (Product)                  # (content-type)
Product F (Product)                  # (content-type)
Category B (Category)                # (product taxonomy parent (weight 0) term)
subCategory 1 (Sub Category)         # (product taxonomy sub parent (weight 1) term)

only products ( a content type ) or taxonomy terms with this coupon are shown.

We will then need to build a link pointing to the correct front end page.  The category list, the sub category list, or the actual product.

Thoughts on how to achieve this with no custom code?  If the only way to do this is with custom code, what's the best way to approach the task?

Thanks a million and 1.

[EDIT to change output options.]


texts: Drupal 8 REST - How to export Drupal 8 Main navigation menu with REST service (JSON)

texts:
I have tried to GET main menu with rest path "/entity/menu/{menu}" but all I get in response JSON is a menu properties as uuid,language,id... without menu structure (links...).

{
  "uuid": "93d5d0a9-a962-4448-af01-c38aa3ebda22"
  "langcode": "en"
  "status": true
  "dependencies": [0]
  "_core": {
    "default_config_hash": "Q2Ra3jfoIVk0f3SjxJX61byRQFVBAbpzYDQOiY-kno8"
  }
  "id": "main"
  "label": "Main navigation"
  "description": "Site section links"
  "locked": true
}

I have also tried to GET menu through block (main menu is also a block) with "/entity/block/{block}" but without luck.

Fatal error:  Call to a member function access() on null in    C:\Apache\work\test\core\modules\rest\src\Plugin\rest\resource\EntityResource.php on line 52

Is it possible to GET whole main menu with it's sub-menus in JSON format?

Thanks in advance.
Danijel


texts: How to enable field_ui "Manage display" for a custom entity?

texts:
I have written a module that creates a custom Content Entity that has a number of fields including an entity_reference field with a "file" target type. The field_ui module adds location task tabs, alongside my entity settings page, for editing field properties (good!). However, clicking on the field_ui "Manage display" tab for my custom Entity settings crashes Drupal (and not in my code). Has anyone else seen this problem? What "file" plugin is it referring to? This happens in multiple versions of Drupal (8.0.6, 8.1.1, 8.1.7):

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

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "file" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 57 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('file')
Drupal\Core\Field\FormatterPluginManager->createInstance('file', Array)
Drupal\Core\Plugin\DefaultLazyPluginCollection->initializePlugin('file')
Drupal\Component\Plugin\LazyPluginCollection->get('file')
Drupal\Component\Plugin\LazyPluginCollection->getIterator()
Drupal\Core\Plugin\DefaultLazyPluginCollection->getConfiguration()
Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object, 1)
Drupal\Core\Entity\EntityDisplayBase->preSave(Object)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object)
Drupal\Core\Entity\EntityStorageBase->save(Object)
Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object)
Drupal\Core\Entity\Entity->save()
Drupal\Core\Config\Entity\ConfigEntityBase->save()
Drupal\field_ui\Form\EntityDisplayFormBase->buildFieldRow(Object, Array, Object)
Drupal\field_ui\Form\EntityViewDisplayEditForm->buildFieldRow(Object, Array, Object)
Drupal\field_ui\Form\EntityDisplayFormBase->form(Array, Object)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array)
Drupal\Core\Form\FormBuilder->retrieveForm('entity_view_display_edit_form', Object)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}()
call_user_func_array(Object, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)


texts:
We are having an issue where the "Show as expanded" checkbox is false whenever a new link is generated regardless of menu link weight.

Using the Superfish module we are displaying the menu block and tried to the following below to see if we can have the menu links expanded by default. However, during testing this is failing. We are using the latest Bootstrap theme as our base theme.

Test case:

1) Create a menu link for custom-menu
2) Navigate to admin page to view all the menu links
3) Click on edit on the menu link item
4) The Show as Expanded is disabled

Code (only hook in my .module file):

function mymodule_menu_link_alter(&$item, $menu) {
  if($item['menu'] == 'custom-menu')
  {
    $item['expanded'] = 1;
  }
}


texts: How to export field's default image in Features

texts: I have Image field type and provide Default Image. This default image doesn't seem to be exported by Features. Is there another module that need to be added so the image also exported? Or are there another way or alternative to achieve this?


texts: My local site directs to install.php after update from production site af drush sync

texts:
Just set up drush for a site, database and site root set up in MAMP. I've updated the local directory using these drush commands:

drush rsync @alias.production @alias.local
drush sql-sync @alias.production @alias.local

The terminal doesn't display any errors and I can see in my local phpmyadmin + in the site folder that both files and database entries are synced. Still the local URL directs me to /install.php (also after running drush cc all)

I've done this several times before without difficulties. Any ideas how I should debug this behaviour to find my error?


texts: Make variables outside of node available to pathauto

texts:
I'm trying to port a website over to Drupal 7. The structure consists of locations which have an entity reference to a region which has an entity reference to a country:

  location<-region<-country<-continent

This all seems to work OK. A location node doesn't directly know what country it is in, but it does know what region it's in.

The problem is I want to use the old URL structure:

  /continent/country/region/location

So far I can get it to work for /region/location (as region is referenced from location) but then I get stuck.

What I'm wondering is there any way to pull these other fields (country / continent) into the node and make them available to pathauto?

If it helps it doesn't really matter what the continent and country are as region & location provide enough info. So a wildcard would be fine.

So, firstly, is this possible with this structure. And if so, how?

Any help greatly appreciated.


texts: Why my theme suddenly gone blue after an update?

texts: After updating the Bartik 960 template on Drupal the homepage highlight each of the blocks on the page in blue. It looks like it's gone into a debugging mode, but I'm not sure how to fix it.


texts:
I have been trying to use the following php condition to achieve a specific rule required for my project, but I keep failing to match the condition, please help.

<?php
$sql = "SELECT `mid` FROM `managed_staff_points` WHERE `uid` = '[userpoints-transaction:user:uid]'  ";
$result = db_query($sql);
if ($result == '[site:current-user:uid]') {
    return TRUE;
else
    return FALSE;
}
?>


texts: What is the right way to force a session start?

texts:
I'm currently porting SimpleFBConnect module to Drupal 8. This module uses Facebook PHP SDK which expects that we have established a session before the user is redirected to Facebook for authentication.

By reading SessionManager API, I assumed that SessionManager::start would start the session. However, this does not seem to be the case. The same thing applies to SessionManager::save (description says that this function will "Force the session to be saved and closed.").

The only way how I was able to force a session start was to call SessionManager::regenerate.

Is this the correct way to force session start in Drupal 8?

Debug code, which will show that SessionManager::start will not start the session.

class TestController extends ControllerBase {
  public function test() {
    $session_manager = Drupal::service('session_manager');
    $session_manager->start();

    if ($session_manager->isStarted()) {
      $msg = 'Sesssion started';
    }
    else {
      $msg = 'Sesssion not started';
    }

    return array(
      '#markup' => $msg
    );
  }
}


texts: Drupal absolutely refuses to serve gzip css and js files, however they are produced just fine. What could be causing this?

texts:
What I have tried so far:

All variations of modifications and additions to .htaccess gzip relevant sections near the bottom.
The Advanced CSS/JS Aggregation module, and all suggested configurations provided in its readme, which either had no effect or (in the case of the "best pagescore configuration) caused the site to never load until I manually disabled the module.
All combinations of the above two I can conceive of.
Disabled all possible competing modules, including adaptive images, boost and core caching of all kinds besides core aggregation required by the Advanced module.
Threw some junk text into the mod-headers section to confirm it is active and received a 500 error. Repeat result for all relevant apache modules.

The aggregation works fine - whatever configuration I use, save the one that killed the site, successfully produces the aggregate files AND their counterpart gz files and places both in the correct folder under default/files. But come time a page is requested, the server refuses to serve the gz files - it will only serve the full files irrespective of the client's request for compressed files. Could this be a server thing despite the relevant Apache modules otherwise being active? What else is there to try? Could it be on the theme layer or something?


texts: how to display sub menu under the respective main menu

texts:
I want to display main menu in custom menu block and display all sub menu below the main menu block on clicking the respective main menu. Iam able to display main menu but not able to display respective sub menus below the clicked main menu. Please help

I would like to give a reference if my reqiurement is not clear. The submenu created in the site http://stmarksumc.com/node/159 is what I am looking for.Can anyone please   suggest me any solution to the issue Drupal 7?

Thanks for your help.


texts: Why won't Comment Notify replace the unsubscribe token in notification emails?

texts:
In short: when the Comment Notify module (under Drupal 7) sends a notification email to anyone subscribed to comments on an article on my site, it refuses to replace the token for the unsubscribe URL. Instead, it just appears in the email as [comment-subscribed:unsubscribe-url].

This is a known bug for previous versions of Comment Notify, but I upgraded it weeks ago (and was sure to run update.php. I'm now running v7.x-1.2 (I've also tried the dev version). Drupal itself is not at the latest version, but unless I know it's a bug in core, I really don't want to go through the pain of upgrading just yet.

I have cleared the cache, run cron and truncated the cache_form table. I have checked that the variable table entry for Comment Notify uses the correct token. And yet, it still refuses to perform the token replacement for that token alone.

The template for the one of the Comment Notify emails is simply:

There's a new comment on "[comment:node:title]":

Author: [comment:author]

[comment:body]

--
You can view the comment at [comment:url]
Stop receiving notifications for this post at [comment-subscribed:unsubscribe-url]

[site:name]
[site:url]

What else can I try to get this working, or to debug the problem further?


texts: Possible to use drush to list overrides for all features?

texts:
I believe that drush features-diff will list the overrides for a specific feature and that drush features-list will list all features. Is it possible to list all of the overrides for all features, perhaps by piping the results of drush fl to drush fd?

If so, how would one pick up the second field from drush fl to pipe to drush fd? Or, is there a better way to do this?


texts:
Migrated a Drupal 8 site to another server running apache2 PHP 5.5.9 (should be supported). Apache returns 500 when index.php requested, but no errors are logged anywhere. I tested by forcing an intentional PHP error in index.php and the log contains PHP errors.

I also excluded database connection problems. Taking settings.php out redirects me correctly to /core/install.php and no error is thrown.


texts: Node body not preserving HTML formatting?

texts:
The body area of my node is set to WYSIWYG. When I enter in HTML formatting (using the WYSIWYG buttons), it doesn't make it to the content type template:

print $node->content['body']['#value'];

Why doesn't the HTML come through? How can I print the node body to the page and preserve the HTML formatting? What am I doing wrong here?

Thanks!


texts: Is it possible to programmatically pass parameters to a block?


texts: I have a field of date-time type. I added this field into a view and formatted the date-time field to show only year. When I switch 'aggregation' on in Views and try to group this field it didn't work as i expect and show all the dates again. I saw the Vies-query and there wasn't any preformatting. It was grouping by dis field only. I want the modify the query to get this fields formatted as i need(years only). Any advices would be appreciated. Thanks in advance!


texts: Adding #ajax to checkboxes and getting selected values in callback

texts:
I've been trying to use #ajax callbacks on a form. I've got this working with radio buttons, so when I've debugged the form I get the value associated with the radio button as '#value' under 'triggering_element' in $form_state; what I'm struggling with is doing the same thing with a group of checkboxes. The first checkbox checked seems to work correctly, and I can see the correct value, but if I click a second checkbox, the value doesn't come through correctly (triggering element is the field that was returned in the previous #ajax callback for some reason??) and '#value' is a string and not an array as I would have expected. Also $form_state['#values'] doesn't contain the previously selected checkbox or the current checkbox.

How do you correctly add #ajax to an element  of type 'checkboxes' and how is it possible to get the value of all checked checkboxes when the ajax callback is fired?


texts: How to override nid filter to accept multiple values on views

texts:
I have read a dozen of open tickets on this issue, but none of them explains how to solve this.
Lets say I have a raw array of nids and wanting to override the query in a hook for the nid filter.
The nid filter allows only 1 value or some of the operators given in the image below.

There isnt an operator "is one of" as in the taxonomy reference filter. So how could this be overriden and allow multiple values for the nids?
Is this possible perhaps within the hook_views_query_alter()?


texts: hook_entity_bundle_field_info_alter() only validates article bundle

texts:
I used hook_entity_bundle_field_info_alter to validate fields in node as below:

function my_module_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
  if ($entity_type->id() == 'node' && !empty($fields['title'])) {
    $fields['title']->addConstraint('UniqueField', []);
  }
}

The validation I wrote in UniqueFieldConstraintValidator Plugin works for "article" bundle but not for any other bundles. What am I doing wrong?


texts:
I have a json file like this
{
  "online": false,
  "key": "123",
  "Product": {
    "name": "product name",
    "Id": 12,
  },
}

I have my json migration file
source:
  plugin: url
  data_fetcher_plugin: file
  data_parser_plugin: json
  urls:
    - 'json_path/data.json'
  item_selector: /Product
  fields:
    - name: keyword
      label: 'Keyword'
      selector: name
  ids:
    product_key:
      type: string
  constants:
    vocabulary: tag
process:
  vid: constants/vocabulary
  name: keyword
destination:
  plugin: entity:taxonomy_term

but I am getting the following error.
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

It means the xpath is not correct.
I have tried with the item_selector: $ and for the keyword selector selector: Product.name but then I am getting this error.
Passed variable is not an array or object

I have tried with item_selector: 0 and item_selector: / but nothing worked.
However when I use the following json.
{
  "online": false,
  "key": "123",
  "Product": [
    {
      "name": "product name",
      "Id": 12,
    }
  ],
}

Notice the [] brackets.
What is the issue? How can I make it work without the [] brackets because I don't have any control on the json to change it.


texts:
I have a content type (Staff Member) with many fields, such as portrait, name, and bio. The name and bio fields are grouped together under the field group _text_fields_.

I have created a view for this content type.

The view renders each content node like this.

John Doe

John Doe has been with us for 800 years.

However, I want grouped fields to be grouped like this.

John Doe

John Doe has been with us for 800 years.

I've tried writing a views-view--staff-members.tpl.php template file, but it receives all of the .views-row items as a HTML string.

How might I accomplish this?


texts: How to override field collection field title?

texts:
I have created field using field collection. I need to override field title and and incremented by 1 every field title. For this I am using this code. But its not working for me.

function previewcustom_form_alter(&$form, &$form_state, $form_id) {
  $x = 1;
  if($form_id =="article_node_form"){

  foreach($form['field_ingredientsf']['und'] as $k => $v) {

    if(is_numeric($k)) {

      $form['field_ingredientsf']['und'][$k]['field_steps']['und'][0]['#title'] = $form['field_ingredientsf']['und'][$k]['field_steps']['und'][0]['value']['#title'].' '.$x;
      $form['field_ingredientsf']['und'][$k]['field_steps']['und']['#title'] = $form['field_ingredientsf']['und'][$k]['field_steps']['und']['#title'].' '.$x;
      $x++;
    }
  }
}

Note I cleared the cache.


texts: How to construct database query with conditions that include 'and' and 'or' clauses?

texts:
I am converting a Drupal 6 module to a Drupal 7 module. I have come across the following database query that I don't know how to convert to the new Drupal 7 format.

$sql = "
  SELECT id
  FROM {room_reservations}
  WHERE (
    (deleted = '%s' AND room = '%s' AND date = '%s' AND time = '%s' AND length > %d)
    OR
    (deleted = '%s' AND room = '%s' AND date = '%s' AND time = '%s' AND length > %d)
    OR
    (deleted = '%s' AND room = '%s' AND date = '%s' AND time = '%s' AND length > %d)
  )
";

Although the where clauses do repeat itself, each substituted value in there is different. My question is how does one construct such a statement in Drupal 7 using the new database API? Can you mix and and or statements?

Thanks.


texts: How to add role selection field to the registration form?

texts:
How can I add the role to registration form that users can choose their role?

I tested the Profile2 module and the Auto Assign Role module but they don't do what I want.

I want to add a CCK field in the admin/configure/account/fields.

Is there any module to add a CCK field to registration form for choosing the role?


texts: How to prevent page refresh after a button click?

texts:
I know this question is already asked, but my problem is different.
I have a code field created with Display Suite, that displays an audio player named AblePlayer, with a playlist of three tracks.
In this field there is a list of buttons that select tracks to play.
The list is created dynamically with foreach, depends on field items.
When button is clicked, AblePlayer selects automatically the track and plays it.

The problem is that drupal refreshes the page and Player stops playing!

I'm using html to create these buttons, don't use arrays.

I tried to create a button that does nothing, to see if the problem is AblePlayer, but drupal refreshes the page also if button is simply a button…

so <button>something</button> does nothing, but drupal refreshes the page!
Help!


texts:
How do I add an extra field with machine name field_caption?

Do I need any module to implement it?

++++++++++++++++++++++++++++++++

My Answer:
Download the following module
https://www.drupal.org/project/image_caption
https://www.drupal.org/project/insert

Insert settings:
Home » Administration » Structure » Content types » Article » Manage fields
Enable insert button

Upload image in node and add caption in text.

The text will become caption.


texts: How can I run Drush 8 and Drush 9 together on same machine to test some module on it?

texts:
As in my earlier environment I was running Drush 6 and Drush 8 together.

I need help with the Drush 8 and Drush 9 installation. Is there any possible way to achieve it?

I tried to do porting command following Porting Commands to Drush 9, without success.

Any help would be appreciated.


texts:
I am trying to print a commentator's avatar picture in the comments.tpl.php

<img src="
        <?php
            if ($picture) {
                print image_style_url('comment_picture', $comment->picture->uri);
                ?>"

which works as desired. However it doesn't post the default_picture if the user does not have a profile picture uploaded.

I've tried using [default_image] but then nothing happens

<img src="
        <?php
            if ($picture) {
                print image_style_url('comment_picture', $comment->picture->uri);
             } else {
                print image_style_url('comment_picture', [default_image]);
            }
                ?>"


texts: One content type doesn't show up for one role on content page

texts:
Weird bug with a relatively complex D7 setup using admin_views: on the admin/content page, nodes of one content type ("event") don't show up at all, but only for a specific role ("editor"), even though this role has full access to this type of nodes (create, edit own/all, delete own/all).

If logged in as admin, the "event" nodes appear on this page as expected.

If logged in as editor, the "event" nodes don't appear at all; but nodes of other types show up just fine. Using the filter Type: Event, gives the "no content available" result.

If I give the editor role the permission "Bypass content access control", then the "event" nodes do appear again on the content page. But this gives the editor access to other types of nodes I don't want him to access...

If I disable the admin_views module, the problem goes away. (Editor is able to see the "Event" nodes on the content page again.) But since it's a rather complex site, the ability to customize the filters and columns on the content page is quite useful, so I don't want to disable this module.

Visiting the edition page for this admin view (admin/structure/views/view/admin_views_node), I don't see anything related to user roles, so I don't understand this behavior. I tried with or without Ajax, but no change.

I also tried to clear all caches and clear views cache.

Any idea what's causing this behavior?

UPDATE

After more tests, it seems that this problem is somehow related to the organic groups module, which is also used on this site.

Some content types are intended (configured) to be part of a group, while other content types (such as "Event") are "group-neutral" (not part of a group; they don't even have the field for that). I have configured the node admin view so that users are able to filter nodes based on the name of the group they belong to (obviously this only applies to content type that can be part of a group, but it's OK). For this purpose, I have added the Entity Reference: Groupe relationship to this view, which then allows to add an exposed filter based on the title of the group.

Removing this relationship solves my problem. But I still don't understand why this happens for one role only.

So in summary: for the "editor" role, the view behaves as if this relationship is required (although it's not the case, I checked in the settings for the relationship), which results in all nodes not part of any group being excluded from the results.

I'll just remove this relationship (and related filter) for now, as I don't really have time to research this further at the moment...


texts:
How can I stop the default output of a Views rendered mini-calendar block?

I am using Views 7.3.7 to output a calendar of nodes according to a date field.

I don't want the links to the node that I get by default. So rather than have links to my nodes, I can just have an NID associated to each entry in a cell?
I need the NIDs so I can do some AJAX work.


texts: Image shows on home page but not other pages

texts:
I've added an image to a block that shows on every page and have the image added manually in the block like so:

<img src="sites/default/files/image-name" />

It shows fine on the home page as intended, but on the interior pages it doesn't show. I inspected element and for most pages it's using the same URL to try and access it.

I cleared cache.

Thoughts on why this might be?


texts: allowed values for node/entity/user reference field

texts:
Can you get allowed values for reference field?

i tried with:

$all_fields_info = field_info_fields();
$allowed_values= list_allowed_values($all_fields_info["field_user_ref"]);

but it is not working ..


texts: Is it possible to define hook functions in template.php instead of the module?

texts:
Theme functions are defined in the template.php but is it possible to define hook functions in there? for example There is a content type called phone-book, its add content form ID is phone-book-node, I want it to redirect to my custom page when it is submitted. so I created this function in the template.php :

function MYTHEME_form_phone_book_node_form_alter(&$form, &$form_state, $form_id) {
$form_state['redirect'] = 'go/some/where';
}

but it doesn't work. I don't know if it is totally impossible to define such hook functions inside template.php or something is wrong with my code.


texts: Drupal 8: Best practice to get nid in form_submit

texts:
I can get nid from within form_submit by using one of those snipet:

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

or

\Drupal::routeMatch()->getParameter('node')->id()

If feel this is a little bit overkilling... what is the best way?


texts: Implement a Facebook login without breaking the privacy

texts:
Like everybody knows Facebook ignores the privacy compleatly.

So I would like to allow users to login via Facebook without breaking their privacy or non Facebook users. Curriently I'm using the modules Fbconnect, OpenID Selector, OpenID Selector for Drupal login and OpenID Selector for Facebook Connect.

I want to allow the users to log in like in stack exchange. This works almost so like expected except the Facebook stuff. The plugin adds to everypage a stupid link to Facebook. So Facebook can spy my users. How can I avoid that?

Is it possible that I download the http://connect.facebook.net/xx_XX/all.js script and put it on my space? Or maybe to proxy the access and cache the file. Does anyone know if some of my ideas are forbidden by Facebook?


texts: Theme a subscriber field in Simplenews issues

texts:
I need to address my subscribers in a more personal way. Thus I added fields for Mr./Mrs., firstname, lastname to the subscription block, and data gets collected nicely.
However, I can't see how to theme these fields in simplenews-newsletter-body.html.twig.
In the header of this template there's an example printing the subscriber's (built-in) mail.
 {{ simplenews_subscriber.getMail  }}

Trying the same as {{ simplenews_subscriber.field_lastname  }} doesn't do anything. I tried a lot of variations to this approach, but to no avail.
What's the secret of getting custom subscriber fields to print with Twig?


texts: How to require one of many modules in your own module?

texts:
Let's say my module needs functionality X. This functionality can be provided by two other modules. For example, front-end with two backends to store data, and at least one backend is needed for frontend to work. Is there a way in Drupal to mark it?

In GNU/Linux and BSD operating systems there usually is a marker like provides, for example Bison provides Yacc, and everything that would need a Yacc can work with only Bison installed. That's about what I'm looking for here.


texts:
I am developing a module which has an admin menu entry in Drupal 7. The issue I am having is that the menu item is not showing up in the admin menu. I have looked at the docs and scoured google for why this might be happening but nothing I try seems to work.

Here is my hook_menu() implementation:

$items['admin/config/people/accomplishments'] = array(
  'title'            => 'Accomplishments',
  'description'      => 'Configure the accomplishments system.',
  'page callback'    => 'drupal_get_form',
  'page arguments'   => array('accomplishments_admin_form'),
  'access arguments' => array('administer site configuration'),
  'file'             => 'accomplishments.admin.inc',
  'type'             => MENU_LOCAL_TASK,
);

I have tried flushing the cache and reinstalling the module but nothing works. I do notice that when I specifically go to the url admin/config/people/accomplishments I get a permission denied error - which doesn't make sense to me as I am logged in as user 1 and I have assigned access privileges to the administrator role.

The module I am developing is creating a new entity so I don't know if this might have a baring on this as I have never created an entity before, but I don't think it should.

Any ideas as to what I am overlooking or what the cause might be? I am going crazy here.


texts: Is there any way of adding the exact same login options of StackExchange websites in a Drupal 7 site?

texts:
I think that the title is pretty descriptive but I would like to be as detailed as possible so let me list all the login options that I would like my drupal site to have available:

Open ID
Stack Exchange
Facebook
Yahoo
Gmail
Wordpress
Blogger
AOL
Google Profile
Verisign (optional)
LiveJournal (optional)
Clickpass (optional)
ClaimID (optional)

So, is there any solution to implement this in a Drupal 7 website?


texts:
Specifically, when an admin goes to the 'People' admin screen, selects some users, then goes to 'Remove a role from the selected users', I want to capture this and apply some other actions.

To give a little bit of insight into what I'm doing: I have another set of tables in the same database belonging to a CRM, and when the user is removed from xyz group, it should toggle the account status in the CRM as well. The action of toggling the status is no problem, I just need to know the best way of going about capturing the role removal. Is there a quick way of doing this, or am I going to need to create a new cancellation method via hook_user_cancel_methods_alter()?


texts: How to check that cron is reindex the complete site?

texts:
I'm using drupal 7 and cannot find a log that the site is reindexed.

Cron is running every 3 hours which I can see in the log. How can I check that the cron is reindex my site as well?


texts: Using "Rabbit Hole nodes" and "Facebook Like Button"

texts:
I am busy developing a Drupal 7 website. All nodes of content type "X" are displayed on my front page as well as on (possibly) multiple taxonomy term pages. But that is it, users are not allowed to access the single node page directly.

I have restricted the user's access to example.com/node/* pages using the plugin "Rabbit Hole nodes", redirecting them to example.com/#node-[node.nid] using the "Token" module.
I have also implemented the "Facebook Like Button" module to provide
a Like button for each node.

Each of these Like buttons are placed inside a generated iframe with following iframe Src.:

//www.facebook.com/plugins/like.php?href=http%3A%2F%example.com%2Fnode%2F1&layout=button_count&show_faces=true&width=450&font=arial&height=80&action=like&colorscheme=dark&locale=de_DE&send=false

Note: Look at the "href" value that is passed along. It uses the exact URL pattern (../node/*) that I am restricting access to.

I asked myself these questions:

Does the Facebook crawler (user agent: facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php) actually have access to this?
Will "Rabbit hole nodes" not break this like functionality?
Where will users from Facebook land when clicking on the Facebook
"like" notification of their friend? I mean, it's restricted..

[Update] How it should actually work:

When accessing the URL example.com/node/1 the following should happen:

Normal User (everyone except Facebook's crawler): Should be redirected to example.com/#node-1.
Facebook's crawler: Should not be redirected, instead it should just stay on the single node page example.com/node/1.

Possible solution:

One solution that I considered implementing is altering "Rabbit Hole nodes" module code and checking for the Facebook crawler user agent like this:

if (in_array($_SERVER['HTTP_USER_AGENT'], array(
  'facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)',
  'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)'
))) {
  // Don't execute Rabbit hole functionality
}
else {
  // Execute Rabbit hole functionality
}

What are your opinions, ideas and solution approaches?


texts: How to render an Image Field as a URL in node.tpl.php

texts:
I have an image field called field_body_image

I want to render it in my tpl.php file with a custom image style. I am using the following code (from this thread) to do this:

<?php $view = field_view_field('node', $node, 'field_body_image', array('settings' => array('image_style' => 'thumbnail')));?>
<?php print render($view); ?>

However, I want to display the URL of the image. How can I do that?

This thread has a solution, but it is for user photos and so you cannot specify a custom field.

Image Url Formatter is a module that can do this, but I would rather achieve it without an extra module.

This page has some advice, but apparently it is not best practice.


texts: How can I display tags below an article inline? I have tried using firebug to no avail. I am using Drupal 7 and the zen sub theme.


texts: How can I get a field value of a node using PHP?

texts:
I have created a field in a Basic Page with the label of User Name and the field name of field_user_name.

How can I get it's value using PHP?


texts: Up to how many nodes Drupal can handle without affecting performance?

texts:
Is there a kind of known number of nodes Drupal can handle without visible performance down?

I suppose the more nodes we have on a site the slower it will load pages. However does it matter if the number of the nodes is like a couple of thousands?


texts:
The RSS Views Feeds are very restricted. I created an RSS Views Feed to display the Message (https://www.drupal.org/project/message).
I want to rewrite the RSS Views Feed and I want to display the RSS Message View mode.
I created a template for my Views :
views-view-row-rss--test.html.twig

I don't know how to make the RSS message display mode in this template.
Here is the RSS template for Messages.
message--mas-create-node--rss.html.twig :
<item>
  <title>{{ drupal_token('message:field_node_reference:entity:title', {message: message}) }}</title>
  <link>{{ drupal_token('message:field_node_reference:entity:url', {message: message}) }}</link>
  <description>{{ drupal_token('message:field_node_reference:entity:content-type', {message: message}) }}</description>
  <pubDate>{{ drupal_token('message:created:since', {message: message}) }}</pubDate>
  <dc:creator>{{ drupal_token('message:author:display-name', {message: message}) }}</dc:creator>
  <enclosure url="{{ drupal_token('message:rss-node-render', {message: message}) }}" length="3180" type="image/jpeg"/>
  <guid isPermaLink="true">{{ drupal_token('message:url:absolute', {message: message}) }}</guid>
</item>

The RSS Feed markup in Views is very bad. It only works on node display modes and does not manage images. It does not allow tokens to be used to rewrite fields.
How to completely rewrite my Views and display the RSS display modes for my Messages ?


texts: Join a user field to a profile2 field in a view

texts:
What I am trying to do is to join fields that are a user type (e.g. image, and username) to Profile2 fields.
In the example I want to join:

teacher name (teacher profile2)
teacher date (teacher profile2)
username (drupal registration)

What I mean by Drupal registration is the fields used to register an account.


texts: How to modify Drupal 8 Views "Rewrite..." field values later in code?

texts:
In a Drupal 8.3 View, I am displaying fields. One of these fields is configured to "rewrite results" so as to "output this field as a custom link" with a custom link path.

I would like to modify these links in code (based on some later logic). However, I cannot find a place to actually modify this value in code. If someone knows how to accomplish this, please let me know. (This was much easier in D7.)

Here's what I've tried thus far.

theme_preprocess_views_view(): I found ...['#view'] -> field['name'] -> options['alter']['path'] in Drupal 8's endless arrays, but changing this value did not affect the output. I could not find my custom link anywhere else in this endless array.
hook_views_post_render(): This supposedly allows one to alter the output string, but doesn't actually give the output as a string (broken documentation).
I can see the output string in a twig template, but cannot easily substitute my link given that PHP doesn't run in twig. This would be a less desirable option in any case.