texts: How can I redirect user, while showing them a status message?

texts:
I'm working on a custom module, in which I want to redirect users, while showing them a status message. What I've tried so far only works for authenticated users but I want to redirect anonymous users. I've tried the below solutions so far. What else can I do?
\Drupal::messenger()->addStatus($config->get('mymessage');
$redirect = new \Symfony\Component\HttpFoundation\RedirectResponse($login->toString());
$redirect->send();

$request = \Drupal::request();
$session = $request->getSession();
$session->set('msg', $config->get('girisyapmesaji'));
$session->save();
\Drupal::messenger()->addStatus($session->get('msg'));
$redirect = new RedirectResponse($login->toString());
$redirect->send();


texts: Fatal error: Unsupported operand types in common.inc on line 2287 when registering new user

texts:
I am receiving this error message when registering as a new user on a site-in-progress:

  Fatal error: Unsupported operand types in common.inc on line 2287

The actual line 2287 is:

  $query += $options['query'];

Here is the surrounding code:

// Without Clean URLs.
  else {
    $path = $prefix . $path;
    $query = array();
if (!empty($path)) {
  $query['q'] = $path;
}
if ($options['query']) {
  // We do not use array_merge() here to prevent overriding $path via query
  // parameters.
  $query += $options['query'];
}
$query = $query ? ('?' . drupal_http_build_query($query)) : '';
$script = isset($options['script']) ? $options['script'] : '';
return $base . $script . $query . $options['fragment'];
  }
}

I use LoginToboggan, not sure if that has anything to do with this issue. Does anyone have any ideas on what might cause this issue and how it can be fixed?

Thanks!


texts: hook_preprocess_page: "node_load() + node_page_view()" versus "%node + node_page_view()"

texts:
A basic node (nid "123") exists and a module registered two paths using hook_menu:

first/%node
second

Both page callbacks use node_page_view($node) to display a fullpage view of the node,  except the second callback additionally uses node_load(123) to get a reference to $node.

Therefore http://localhost/first/123 and http://localhost/second look the same as far as the user is concerned.

However hook_preprocess_page receives the node variable only with the first path, therefore Drupal obviously does something beyond node_load when it sees a %node wildcard, any idea what it is so that hook_preprocess_page receives the reference to $node in both cases ? (because handling everything internally in the second path produces much more friendly urls than redirecting to the first path from the second).

Example:

<?php

/**
 * Implementation of hook_preprocess_page().
 */
function mymodule_preprocess_page(&$vars){
    if (@isset($vars['node'])) echo '
[mymodule.module] Node is defined
';
    else echo '
[mymodule.module] Node is NOT defined
';
}

/**
 * Implementation of hook_menu().
 */
function mymodule_menu(){
    return array(
        'first/%node' => array(
            'title' => 'First callback',
            'page callback' => 'mymodule_page_first',
            'page arguments' => array(1),
            'access callback' => TRUE,
        ),
        'second' => array(
            'title' => 'Second callback',
            'page callback' => 'mymodule_page_second',
            'access callback' => TRUE,
        ),
    );
}

/**
 * Page callback for url "http://localhost/first/123".
 */
function mymodule_page_first($node){
    echo '
[mymodule.module] Function mymodule_page_first

';
    var_dump($node);
    echo '
';

    return node_page_view($node);
}

/**
 * Page callback for url "http://localhost/second".
 */
function mymodule_page_second(){
    $node = node_load(123); //the ID of an existing node

    echo '
[mymodule.module] Function mymodule_page_second

';
    var_dump($node);
    echo '
';

    return node_page_view($node);
}

(Source of file mymodule.module)

My best/only hope so far is to dig in the source of node_page_view and all functions it consequently triggers until I find what happens between the moment node_page_view is called and the moment the module_invoke_all which triggers the hook is called.


texts: I currently have both a Drupal and a WordPress site. Is there a module that can display the latest posts from my WordPress site, or will I need to write my own?


texts:
I would like build out page content using entity references. The problem is I would like to reference multiple types of entities (nodes and terms) plus content that is not an entity (views.)

I've explored this and what I have now is a field for both Node Reference and Term Reference and another with a View Reference which is not a very user-centric. Is there a more succinct way to achieve this?


texts: How can I register an already uploaded unmanaged file as managed file?

texts:
I am stuck in a point that should be easy but I couldn't figure it out.

To make a long story short; I uploaded manually some images to the public directory and now I want to register them as managed files but I am stuck for some time where I couldn't figure out how to do it.

I tried using system_retrieve_file but it seems to accept only URLs not local paths public:// as it uses cURL to get the file

Also, I tried using file_save_data with no luck as well for the same mentioned points.

Any ideas?


texts: Form with Multiple fields in table format

texts:
I have a requirement to design this type of form for a custom content type. This is one part in a large form.

At first what I did is made a Field Group called Income Information

Inside the Field Group I made new fields:

Age as textfield Integer
Sex as select list
Description as Long text
Family Income as Field Collection

Family Income field collection field would have a collection of fields like Family Member, Income, Savings and Loan.

My question is here how to present this part Family Member, Income, Savings, Loan in a table format as the picture below.

In Family Member: Father, Mother, Spouse are just listed by default. If users want to add some other then there is textbox for that, but the total family member will not increase from 5, that means no add more field button there.


texts: Custom grouping by taxonomy term in view

texts:
I made a view with taxonomy and nodes, groupped like this:

term 1
    subterm 1
        row
        row
term 2
    subterm 1
        row
        row
term 3
    subterm 1
        row
        row
    subterm 2
        row
        row
term 4
    subterm 1
        row
        row

But I need grouping by term like this:

term 1
    row
    row
term 2
    row
    row
term 3
    subterm 1
        row
        row
    subterm 2
        row
        row
term 4
    row
term 5
    row
    etc.

please any ideas, i wasted a lot of time to find the hook and tpl.php for this (tpl. or hooks - ?)


texts: How to configure "authorizenet" module in Drupal 7?

texts:
I'm trying to configure "authorizenet" module for my site.

Following is my requirement and the approach I've taken:

  A site visitor should be able to fill out a form (node create form).
  Once site visitor has filled out all the necessary information
  Then Site visitor should be redirected to authorize.net payment gateway
  where they'll be paying some amount and would be redirected back to my site.

I've used "authorizenet" module and "pay" for above but haven't been able to configure it to match my requirements.

Please note I want to configure this for one content type only.

Can you guys please help me with above?

Thanks.


texts:
Are masked inputs supported in custom composites?

I've tried the following and it doesn't break but it also doesn't mask.

$elements['job_details']['job_phone'] = [
  '#type' => 'textfield',
  '#input_mask' => '(999) 999-9999',
  '#title' => t('Company Phone Number')
];


texts: Cannot figure out what's wrong with my schema

texts:
It keep saying

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

Here is my Schema:

function artx_partner_schema() {
  $schema = array();

  $schema['artx_partner'] = array(
    'description' => 'The base table for artx_partner.',
    'fields' => array(
      'partner_id' => array(
        'description' => 'The primary identifier for a partnership.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'User identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => 'Node identifier.',
        'type' => 'int',
        'not null' => FALSE,
      ),
      'product_id' => array(
        'description' => 'Identifier for a product.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'reqtime' => array(
        'description' => 'time stamp of the request',
        'type' => 'datetime:normal',
        'mysql_type' => 'datetime',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'restime' => array(
        'description' => 'time stamp of the response to request',
        'type' => 'datetime:normal',
        'mysql_type' => 'datetime',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'status' => array(
        'description' => 'the status of the request, pending(0)/AC(1)/Rej(2)',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array('partner_id'),
    'unique keys' => array('unique' => array('uid', 'nid', 'product_id')),
    'foreign keys' => array(
      'owner' => array(
        'table' => 'users',
        'columns' => array('uid' => 'uid'),
      ),
      'product_display' => array(
        'table' => 'node',
        'columns' => array('nid' => 'nid'),
      ),
      'product' => array(
        'table' => 'commerce_product',
        'columns' => array('product_id' => 'product_id'),
      ),
    ),
  );

  return $schema;
}


texts: Manage Display Field Label not changing: inline does not work

texts:
I have the same problem as question 212176 and discovered it has to do with CSS.
I have 2 (local) sites both with module ds enabled. I configured in both a field where I want the label and the value in one line: inline

With the classy-theme, this works fine.
With the IceMagic theme it does not.

I have "inspect element"-screenshots of both. As there is no float:left with IceMagic, I believe this is the reason the label stays above.

Where and how to fix this?


texts: In simple words please, what is the "Rendered file" image-format?

texts:
I've tried to Google the term "Rendered file" "Drupal" to have some clear data about this image-format and what makes it even possible for choosing (I guess, a module I installed for another purpose that does it), but that data I found wasn't clear and didactic enough for me.

My only aim is to use Drupals image API with the monumental module Insert. The display should be "Hidden" for the field (so it would not be duplicated when the image is inserted to the CKeditor). But I ask to know anyway, and that people to come will have a better clearer answer for what is the "Rendered file" format.

Please give the shortest, clearest definition you can, for this term, and in the end, some words about it's connection to the Views module. Thx,


texts: Can I use another entity in the route to provide an entity to an entity form?

texts:
I am working on a custom content entity that I want to 'link' to a user by adding it as a tab to the user profile. Each user can have one such entity.

My route is defined as follows:

entity.my_entity.edit_form:
  path: '/user/{user}/my_entity'
  defaults:
    _entity_form: my_entity.edit
    _title: 'Edit entity'
  requirements:
    _entity_access: my_entity.update
  options:
    user: \d+

And the tab (module.links.task.yml):

entity.my_entity.edit_form:
  route_name: entity.my_entity.edit_form
  base_route: entity.user.canonical
  title: Entity

Though this works and the tabs show up, they result in a fatal error (cannot return getValue() on null from the getters) presumably because the form does not have an assigned entity.

If I change the route path to /user/{user}/my_entity/{my_entity}, the form works, but I cannot create a tab as the last value is unknown to the routing system.

Can I use the provided user entity instead from the route instead and during the building of the entity form retrieve (and set) the entity I need?


texts:
By default the navigation in books is collapsed:

Fruits
Vegetables

Is there any way to make them expanded, so that the entire tree would be visible?

Fruits

Apples
Bananas

Vegetables

Tomatoes
Cucumbers
Carrots

Thank you!


texts: How to safely remove drush via pear and then install via composer?

texts:
I have drush 5 installed on my VPS running CentOS 6. Drush was installed using PEAR.
Can I just remove the drush directory and the simlinks and then install drush 7 using composer?

I have been searching for a way to uninstall drush, but all I get are tutorials to install it.


texts: Print the current source node of the comment

texts:
I wold like to have some clues to search.
Out of the box Drupal let you see the original article or page when you write a comment and click "preview". I search everywhere and I haven't a clue about how to fix the problem when I make a custom tpl for the coment-form.tpl.php I lost the part where I see the original source of the subject I'm posting. I just see the comment form. I think is not comment.tpl or comment-wrapper.tpl I also make a custom module but no luck.


texts: Fixed width for columns in grid view (Views)

texts:
I have a block(page same problem) on www.bluraykopen.nl with a grid view with 3 columns. As you can see the 3 products are next to each other on the left side.

I can not get them to use the full with of the block, so that each column has a fixed width like 33%.

I have searched for an answer the whole day, and tried some CSS adjustments, but can't get anything to work.

Hope you can help.


texts: Use the trans tag in Twig without escaping HTML

texts:
I would like to use variables containing HTML inside a trans tag in my Twig template. (The variables contain the start and the end of a link which appears at different positions in the sentence for different languages.)

There is some documentation about "Drupal 8 Twig Templates and Translations" which explains that for variables inside the trans tag there is a |placeholder-filter and a |raw-filter (for older versions: |passthrough).

I see no difference in the output using these filters.
Here is my template:

{% set string = '&amp;' %}

  {% trans %}
    Escaped: {{ string }}
  {% endtrans %}

  {% trans %}
    Pass-through: {{ string|raw }}
  {% endtrans %}

  {% trans %}
    Placeholder: {{ string|placeholder }}
  {% endtrans %}

And here ist the output:

Escaped: &amp;
Pass-through: &amp;
Placeholder: &amp;

Is there any filter that will switch off escaping?


texts: How to create a menu child of an other menu?

texts:
How can I create a menu child of an other menu.
Drupal menu are links to pages or an other content type.
I want a main menu that can expand sub menus by clicking on a menu item.
So, there is a module that can create menu children of a menu?


texts: theming field collection in node add form

texts:
I have themed node/add form of a special content type using the following instruction:

https://www.drupal.org/node/1092122

and I have changed this form to a table.

Now I'm struggling with a field collection with unlimited number of item.
As I have hidden the default form of displaying node/add form when I click on 'add another item' of the field collection, nothing happens.

What I want is to show the next form of the field collection as the next row of the table ready for the user to fill it out.

Any help would be appreciated.
thanks in Advanced.


texts:
I have the following file.

  modules/custom/test_module/config/install/test_module.settings.yml

test_module.settings:
    message: 'Hello'
    langcode: 'en'

But I am not able to get the following value.

$config = \Drupal::config('test_module.settings');
print $config->get('message');

I have referred this link.

UPDATE:

Removing test_module.settings: line solved the issue.


texts: How do I customise individual menu links?

texts:
I have a menu created through admin/structure/menu.

On some of the menus, I would like to place a var after the title.

I have tried placing the following in my theme template, but nothing happens.

 function mytheme_menu_link(array $variables) {
   print_r($variables['element']);
 }

How could I just place the content of a PHP variable after the menu link title?


texts:
I'm trying to add more elements to the exposed views filter form but am running into an odd problem that is confusing the heck out of me.

I'm using a hook_form_alter call in a custom module to add new select drop downs.  This works great, except that they get rendered out as part of the submit element.

function my_module_form_alter(&$form, &$form_state, $form_id) {
  $form['test'] = array(
    '#type' => 'select',
    '#title' => 'New Filter',
    '#options' => array('value 1', 'value 2')
  );
}

Rendered it looks like this:

       Approval Status

          <select name="node_status" class="form-select" id="edit-node-status"><option value="All" selected="selected">&lt;Any&gt;</option><option value="0">queued</option><option value="1">approved</option><option value="2">denied</option></select>

    <input type="submit" id="edit-submit-wpg-content-bulk-admin" value="Apply" class="form-submit">

      New Filter:
      <select name="test" class="form-select" id="edit-test"><option value="0">value 1</option><option value="1">value 2</option></select>

Does anyone know what I'm missing here?  Why would the newly added 'test' element be rendered inside the submit element wrapper?


texts: contact page with some texts, a form & google map

texts:
I would like to have contact page which displays information about address, phone, email and some texts. + a contact form + a Google map showing location.
Please let me know how the above is achieved. Thanks


texts: db_query complete Content Type with all fields automatically

texts:
Can I do this automatically in my module without hard coding the list of content type fields:

$query = db_select('node', 'n');
$query->join(ALL FIELDS OF THIS CONTENT TYPE, FIELD ALIASES, ONs);
$query->fields('n', array('nid', 'title'))
    ->condition('n.status', 1)
    ->condition('n.type', 'airports_fs');
$query->addField(NODE.VALUES,  THESE CONTENT TYPE FIELDS);
    ->condition(EACH FIELD.deleted)
    ->condition(EACH FIELD.entity_type, 'node')
$query->addExpression(MY OWN CUSTOM EXPRESSION);
$result = $query->execute();

I'm open to any syntax - db_select, db_query, extenders, ? - as long as it's dynamic.


texts: How do I programmatically add text to a page?

texts:
I am starting to write my first drupal module, but I need help on how to add content / text / data to the screen? I was able to add tabs and a url with hook menu, but I am unsure of how one goes about adding data you want to put there. If I wanted to say "hello world", what function / hook do I use to do that?

function sky_view_menu(){
    $items = [];
    $items['admin/skyview'] = array(
        'title' => 'Skyview Settings',
        'type' => MENU_NORMAL_ITEM,
        'access callback' => TRUE,
    );
    $items['admin/skyview/tab1'] = array(
        'title' => 'Skyview',
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'access callback' => TRUE,
        'weight' => 0,
    );
    $items['admin/skyview/tab2'] = array(
        'title' => 'test1',
        'type' => MENU_LOCAL_TASK,
        'access callback' => TRUE,
        'weight' => 1,
    );
    $items['admin/skyview/tab3'] = array(
        'title' => 'test2',
        'type' => MENU_LOCAL_TASK,
        'access callback' => TRUE,
        'weight' => 2,
    );
    return $items;
}


texts: How to troubleshoot my VBO operation which freezes at 50% every time?

texts:
I have written custom code that creates a new action for Views Bulk Operations (VBO). I am trying to run the action and it gets stuck at "Prepared 46748 out of 46766".  If I run the same action with 25 or 100 records it works perfectly.

Code has been changed but not that directly impacts this process. I do not know what code causes the regression and too many changes have been made to go back one commit at a time.

There is nothing Watchdog related to this process.

A little more on the custom action. The custom action adds the nid for each node to a queue to be processed fully over many cron jobs. I think the issue stems from the fact that every time a node is prepared by VBO it does a node save but I do not know what is happening to be sure.

I am looking for advice on how to troubleshoot this scenario and find a solution.


texts:
Trying to send an attachment with a webform, but it isn't working.

I have MIME Mail installed, I have webform, I have attached a file to the node, and I have selected under the webform settings "include attachments".

However, when I have the webform send to my email, no attachment comes.

Why would this be?


texts: db_update without table prefix on custom table

texts:
I installed Drupal with table prefixes in the database. I have my own tables in the same database which I am trying to update. I am getting an error because Drupal is automatically adding the prefix "drupal_" to the table I specified.

$key_cached_update = db_update('my_table')
  ->fields(array('key_cached' => $apikeyinfo->result->key['expires'],))
  ->condition('keyid', $row->keyid, '>=')
  ->execute();

  Base table or view not found: 1146 Table 'drupal_my_table' doesn't exist

I don't have problems with db_query to read the database.


texts: Add bootstrap icons next to fields in node page

texts:
In my views I can do this easily using the rewrite results and writing this line

  [field_business_phone]

How can I do the same with the node page. It doesn't necessarily have to be a rewrite method but I am looking for an easy method of doing this. The end result I am looking for is something like this.


texts: Update the core and move current site in a sub-directory to the top level

texts:
My main Drupal site is 8.6 but it is in a sub-directory. I want to update the core (to 8.9) and move the site up to the top level (public_html) overwriting an old site (in 6.1!) I no longer need.

Firstly, I will  of course  backup the database in phpMyAdmin.

I am not sure of the next steps.

My guess would be :

delete everything under public_html except the sub-directory
copy all files in the sub-directory up one level (to be under public_html)
delete everything (including the now empty sub-directory)  under public_html except the sites, modules and themes folders
unpack the Drupal  tar and copy core and vendor folders to public_html
run update.php etc.
settings.php in sites/default should be preserved
copy in the provided .htaccess

Will this work? Have I missed anything?
All help appreciated,
thanks,
Rob


texts: Send email when entity field value is changed

texts:
I have used Rules module for notification when node is created, edited or deleted.

My site is in three languages and I use Entity Translation for translating node's field.

Now I want notification when node's or entity field is changed/updated. Can I achieve it with Rules module?


texts:
I know you can translate a views title pretty easy as answered here: How do I translate a view page title?

Unfortunately I can't find a way to translate exposed filters buttons and labels properly. Using Drupal's User interface translation does never index those strings. Is there any known way (other than preprocessing the view to display translatable markup programmatically)?


texts: Rendering Content Multiple Times in a Node

texts:
I'm starting to dig deeper into themeing and I'm thinking maybe I'm misunderstanding something.

Basically I want to break apart the way the content is laid out in my node--example.tlp.php file.

I've started doing that with some simple render statements like  print render($content['group_factory_images']);

I started running into trouble when I wanted to pull the label off of the normally rendered flow and place them somewhere else with something like print render($content['group_factory_images']['label');

This wasn't working so I started to try and pull other items in, to see if it was a syntax issue or something else.

I came away with 2 questions: What is the right syntax to get labels rendered in a node?

And then; Can you only render a piece on content once? For example could I do something like rendering the body twice in the same node? (not that I would want to, but it illustrates the point I think:

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

// other items rendered

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


texts:
What I am looking for it's pretty straightforward. A view in which the most viewed taxonomy terms will be displayed in an ascending order.

To my disappointment the internet is full of articles on how to show taxonomy terms that are ordered on how many times are used in the nodes...so this makes it harder to pinpoint the solution.

Is there a module for this? Or any other solution?

Thanks

Edit: My taxonomy terms are displayed with the default views page
 ex. term/123. So maybe this is something that has to do with the times the view/page of view is displayed?


texts: Drupal 7 Views Exposed Combine contains any word filter case sensitivity

texts:
There is a problem with case sensitivity, using the combined filter in Views.
I find a solution for the operator "contains" at drupal.org using LOWER

But I use the operator "contains any word." Can anyone help correct change code from views/handlers/views_handler_filter_combine.inc

(need to LOWER search query and the fields in which there is a search)

function op_word($field) {
$where = $this->operator == 'word' ? db_or() : db_and();

// Don't filter on empty strings.
if (empty($this->value)) {
  return;
}

preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
  $phrase = FALSE;
  // Strip off phrase quotes.
  if ($match[2]{0} == '"') {
    $match[2] = substr($match[2], 1, -1);
    $phrase = TRUE;
  }
  $words = trim($match[2], ',?!();:-');
  $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
  $placeholder = $this->placeholder();
  foreach ($words as $word) {
    $where->where($field . " LIKE $placeholder", array($placeholder => '%' . db_like(trim($word, " ,!?")) . '%'));

}

}

if (!$where) {
  return;
}

// Previously this was a call_user_func_array() but that's unnecessary
// as views will unpack an array that is a single arg.
$this->query->add_where($this->options['group'], $where);
  }

I tried to do this myself, but my PHP knowledges is not good.
Thanks!


texts: What's the minimum amount of code needed to have a field show up in Manage Fields?

texts:
I tried copying the functions from the field module in example modules to get a field to show up in Manage Fields without necessarily any functionality

Looking at the answer to this question, only field_create_field() and hook_field_info() should do the trick but I never got that working with the following code:

function entityreference_add_new_field_info() {
  return array(
       'entityreference_add_link' => array(
          'label' => t('Entityreference link'),
          'description' => t('Entityreference link'),
          'default_widget' => 'entityreference_link_widget',
          'default_formatter' => 'entityreference_link_formatter',
      ),
    );
  field_create_field('entityreference_add_link');
}

Putting field_create_field() outside of hook_field_info() returns 'call to undefined function' error.

Update: Here's one thing I've tried without success:

function entityreference_add_new_field_info() {
  return array(
       'entityreference_add_link' => array(
          'label' => t('Entityreference link'),
          'description' => t('Entityreference link'),
          'default_widget' => 'entityreference_link_widget',
          'default_formatter' => 'entityreference_link_formatter',
      ),
    );
    field_create_field('entityreference_add_link');

$instance = array(
    'field_name' => 'entityrefernce_add_link',
    'entity_type' => 'node',
    'label' => 'The Link',
    'bundle' => 'node',
  );

field_create_instance($instance);

}
enter code here


texts: View Render output in bootstrap tab style

texts:
I have an Unformatted list style view with 2 grouping:

Grouping field Nr.1: Allestimento.
Grouping field Nr.2: Descrizione

(allestimento and descrizione fields are excluded from display.)

Now I want alter the output of the tpl files to render the 2 groupin like bootstrap tabs (group n1) and nested pils (group n2).
http://getbootstrap.com/javascript/#tabs

But i have no idea how can i do this... I made this by jquery but something the page not render this so I prefare do it by php...
I hope you can help me.

Thanks


texts:
When I click on a 4th level link of a Menu block, the 3rd level disappear.
This is the menu:

Services

Accommodation

Building A

Apartment 1

Apartment 2

I have 3 blocks to show this menu:

1st level block (Starting level 1st, max depth 1): is ok
2nd level block (Starting level 2nd, max depth 1): is ok
3rd level+ block (Starting level 3rd, max depth 9): it's not ok

When I click on a third level link (Building A) the 3rd block shows:

Accommodation

Building A

Apartment 1

Apartment 2

but when I click on any 4th level links (i.e. Apartment 1), the 2nd level link disappears and it shows:

Building A

Apartment 1

Apartment 2

I need to see the third level links even if I click on the 4th+ levels. What I need is this:

Accommodation

Building A

Apartment 1

Apartment 2

Thank you.


texts:
How do I go about overriding the default template for content of the blog page (the index page that shows the blog teasers)?

Also I would like the original template code for this content so that I can rewrite my content effectively, is the .tpl.php somewhere within drupal core, that I could copy out into my theme?

Thanks for your time!


texts:
Added a paragraph to drupal8 via jsonapi and want this paragraph to be in an articles body. I thought it is as easy as

    "relationships": {
        "field_body": {
            "data": [
                {
                    "type": "paragraph--text",
                    "id": "b0247bf8-a3c0-4a45-8e05-4f4901011000"
                }
            ]
        }
    }
},

but the article is created and the field_body result is empty. It works already with other entities just fine. And the jsonapi gives me the paragraph /jsonapi/paragraph/text ...What is the problem, am I missing something?


texts: How to use 'use-ajax' class with pages created by controller?

texts:
I'm trying to use 'use-ajax' class to load a page inside a modal box.

My Page is dynamically created using node id pass on my page controller

My link looks like this

Any idea on how can I achieve my goal?


texts: How to add a cck email field as default value in webform

texts:
I have a content profile type with a cck email field (this is not the user email and so is not the author's email field). I would like guests to be able to send a contact form (webform) to the email address in the cck mail field.

I have the field displayed via views in a panel so I can change the link to output the url to include the email address and use %get in the webform but that is obviously not the way to go as it exposes the email address.

So can it be done using %post or php in the webform?

Using D6 & webform 3

Many thanks


texts: It's true that policy file in drush prevents sql-sync from local to prod?

texts:
I know in the policies file in drush there was/is a way to prevent sql-sync'ing from local to prod.

Is this still true? If so how do you go about this?


texts: EntityQuery, query by referenced entity value,

texts:
I am getting an empty array when I query by the value of a referenced field.

I have the following:

$result = \Drupal::entityQuery('node')
  ->condition('type', 'custom')
  ->condition('status', 1)
  ->condition('field_category.entity:taxonomy_term.name', 'somevalue', '=')
  // ->condition('field_category.%delta', 'somevalue');
  ->execute();

Using ->condition('field_category.%delta', 'somevalue'); returns way too many results (nids) than expected.

using ->condition('field_category.entity:taxonomy_term', 'somevalue', '='): returns an empty array.

Am I using an incorrect syntax to query by a related field?


texts: How to add a description to an image field?

texts:
I have a content type which has a field of the image field type.

When editing this field I see that I can:

Enable Alt field

and also can:

Enable Title field

Is there any way to Add a Description field to be shown under each image.


texts: I have large gaps in NIDs on my site. Should I clean it up?

texts:
So, since I have a little extra time on my hands I’m doing some delayed maintenance on my personal site.  You know, removing modules I don’t need anymore, cleaning up taxonomy, etc, etc.  There is technical debt on this site because well... you know what they say about cobbler’s children and shoes.  When I decide it’s time I’ll be move the site to D9, I want to make the transition smooth.  The site has been around a while.  It was originally a Drupal 4.7 site which has been upgraded to 5, 6, 7 is currently a D8 site.

So enough preamble, back in the site’s Drupal 5 days I had 4 Drupal sites  that I merged into this site.  Since there wasn’t a MigrateAPI 12 years ago, I renumbered the NIDs inside the source sites and then copied the database records into the target site.  In case I needed to debug things, I left gaps between each of the site’s modes (I added 2000 to the NIDs from siteA, 4000 to the NIDs from siteB, etc) so I could easily tell where the nodes came from.

This is worked and the merged site has been chugging along for over a decade.  I’ve come o a point where the system has ~4,000 nodes but the highest NID is approaching 11,000.  I don’t see any risk here, I’ve worked on much larger sites.  I’m in no danger of exceeding the max number of NIDs anytime soon.

My question is, Is there any benefit to compressing the NIDs (probably by migration to fresh Drupal installation)?  I don’t see one, but I might be missing something that someone else can see.

Thanks.


texts: Custom fivestar widget does not display custom icons

texts:
I am struggling to get my custom widget for the Fivestar module to work. The only time when I can see my new star icons is when I change the options in manage display for the field in content type. Otherwise, the default stars are shown (in the dimension that I state in the css).

I created the widget following the tutorial number 17. I kept the same names, just changed the size of the stars. Here is my code for the .module:

function my_stars_fivestar_widgets() {
  // Letting Fivestar know about my custom stars.
  $widgets = array(
    drupal_get_path('module', 'my_stars') . '/my_stars.css' => 'my_stars',
   );
 return $widgets;
}

And here is the css:

/* Static View-only Star Version */
.fivestar-my_stars div.fivestar-widget-static .star {
  width: 28px;
  height: 28px;
  background-image: url(my_stars.png) no-repeat 0 0;
}
.fivestar-my_stars div.fivestar-widget-static .star span.on {
  background-image: url(my_stars.png) no-repeat 0 -56px;
}

.fivestar-my_stars div.fivestar-widget-static .star span.off {
  background-image: url(my_stars.png) no-repeat 0 0;
}

/* Javascript Star Version */
.fivestar-my_stars div.fivestar-widget .cancel,
.fivestar-my_stars div.fivestar-widget .star {
  width: 28px;
  height: 28px;
}
.fivestar-my_stars div.fivestar-widget .cancel,
.fivestar-my_stars div.fivestar-widget .cancel a {
  background: url(cancel.png) no-repeat 0 0;
}

.fivestar-my_stars div.fivestar-widget .star,
.fivestar-my_stars div.fivestar-widget .star a {
  background: url(my_stars.png) no-repeat 0 0;
}

.fivestar-my_stars div.fivestar-widget div.on a {
   background-position: 0 -28px;
}
.fivestar-my_stars div.fivestar-widget div.hover a,
.fivestar-my_stars div.rating div a:hover {
 background-position: 0 -56px;
}

I am using Drupal 7.38, fivestar 7.x-2.1, Voting API 7.x-2.12, and Halfstar 7.x-1.1 is installed but deactivated at the moment.


texts:
I need to create users in code specifying password, email and other fields' values.

How can I achieve this?


texts: Multiple sites and performance in Drupal 7

texts:
I help manage a cluster of sites related to course curriculum. Each site is a separate Drupal 7 install with its own theming, modules, user list, content types, entity structure, and codebase - all of them identical (not shared, but replicated across all the sites). They all run on the same server as different Drupal instances. I'm not a huge fan of managing each individual site and its modules, libraries and theming, but this is the setup as I inherited it.

Now we are looking at adding a few sites to the cluster. This is an opportunity to organize differently, and I haven't found any adequate data on which method is better. These are my three choices as I see them.

Multiple Drupal instances (the way we have it now).

Advantages:

If code for one instance gets broken, the others will continue to run.
Opportunity for separate userlists, taxonomies, etc. (Right now we are not leveraging this, but I suppose we might in the future.)

Disadvantages:

Every upgrade has to be tested and implemented on all sites individually.
Performance hit from running all those instances (cron runs, session variables, caches, etc.)

One Drupal instance running Multisite.

Advantages:

One codebase means one set of modules to maintain.
One Drupal instance would smooth out the performance issues (maybe?)

Disadvantages:

Each site still has its own database, requiring separate userlists, taxonomies, etc.

One Drupal instance with all the content in one place. (This is the way I'd really like to go.)

Advantages:

Much, much easier to maintain.
Performance savings? (This is what I really want to quantify somehow)
Only one site to upgrade when we finally go to D8...

Disadvantages:

Lose flexibility among sites' user lists and access levels. (I can get some of this back using taxonomy terms, but for now it's immaterial.)
Lose flexibility with content types and structure. (The sites are very nearly identical as it is, and the differences can be smoothed out in development.)
If one site gets broken, they're all broken. (Already true to an extent because all the sites are on one server.)
Performance hit from all that content being in one database?

What I'm wondering is, what are the performance savings for each option over #1 (the status quo)? Quantitative data is great, but even an explanation of where the savings come from would go a long way.


texts:
I am using the Aqcuia Dev Desktop where near to the local code label is written the following link: ( C:\Users\Wessam\DrupalSites\devdesktop\drupal-7.34 )
lets say that i want to move my drupal localhost site files & folders to another folder so it will be under the following link: ( C:\Users\Wessam\AllSites\CompanyName ) so the link near to the local code label should be changed also...
How to do the mentioned above?


texts:
I want a role to have access to

add and view terms to any vocabulary,
the overview admin/structure/taxonomy/foo_vocabulary for sorting the terms by draging

but deny the access to edit the vocabulary or its fields. its like administer-taxonomy permission without the option to edit a vocabulary. TAC wont help.


texts: I want to put a hook to a form on one specific form that I created. Based on Node ID.  The code i currently have is .


texts: Display content type in a tab of user profile

texts:
I have created content type "Bloggers", with few fields -

first name
last name
picture

Now i want to add this content type to user profile, so only admin can change information about user. I want to see a tab called Blogger Bio near VIEW, EDIT etc...
Basically i want to add (content type)Bloggers information to each user with a certain role and see this information in a tab in user profile and also edit this information.


texts: Add target="_blank" to menu item of type MENU_LOCAL_ACTION

texts:
How can I add a target="_blank" property to a menu item of type MENU_LOCAL_ACTION ? I cannot do 'options' on MENU_LOCAL_TASK, MENU_DEFAULT_LOCAL_TASK, and MENU_LOCAL_ACTION items.
I tried with jQuery

(function($) {
    $(document).ready(function() {
        $('.page-admin-commerce-reports-incomplete-payments .action_links li a[href]').attr({
            target: "_blank",
            title: "Opens in a new window"
        })
    });
}(jQuery));

But it didn't work.
Thanks!


texts: Drupal 7 Ajax GET - Error 400 (Hook_menu)

texts:
I am trying to send an array back to Drupal to save in a database table. I'm getting an error 400 though when inspecting in the console and the url seems correct:

  GET http://localhost/audiophreak/callback/%?[1,2,3,4,5,6,45,46,47] 400
  (Bad Request)

Here is my hook_menu:

/**
* Implementation of hook_menu().
*/
function my_db_module_menu() {
  $items['callback/%?'] = array(
    'title' => 'My callback',
    'description' => 'Desc',
    'page callback' => 'mymodule_getinfo',
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
    'page arguments' => array(1),
  );
  return $items;
}

Here is my callback:

/**
 * My callback
 */
function mymodule_getinfo($data) {

echo drupal_json_decode($data);

  // //Parse the data and input it into the database
  // $result = db_insert('my_db')
  // ->fields(array(
    // 'nid' => $data->node,
    // 'uid' => $data->user,
    // 'progress' => $data->progress,
  // ))
  // ->execute();
}

And here is my AJAX

//Data
    var post = plnzVideoTracker.progress

    //Begin Ajax
    $.ajax({
          url: '/audiophreak/callback/%',
          contentType: "application/json; charset=utf-8",
          type: 'GET',
          dataType: 'json',
          data: JSON.stringify(post),
          success: function(data) {
            if(data == "success")
            {
            $('.status').attr("innerHTML","Name submitted successfully!");
            }
            else
            {
              $('.status').attr("innerHTML","Name submit failed!");
            }
            },
            beforeSend: function() {
              $(document).ready(function () {
              $('.status').attr("innerHTML","Loading....");
            });
            },
            'error': function(data) {
              $(document).ready(function () {
              $('.status').attr("innerHTML","ERROR OCCURRED!");
            });
          }
     });

plnzVideoTracker.progress is an array inside of an object literal if that has anything to do with it?


texts: Force users to always log in and show no content

texts:
I am using Drupal 7.31 and I installed the MD Alpine theme. I have a site which loads a video on the front page. I want to hide this front page. When users come to my site, I want they are redirected to the login form.

I tried changing the home page to /user and that was a huge mistake. I did manage to undo this. I also went into the permissions and removed any permission for the anonymous user, including the permission to view published content.

I know I have seen this question before, and it seems like there might be a module that can fix that. I am willing to make some configuration change.


texts: It is correct to change unit_price of commerce_order_item programmatically under several conditions?

texts:
I am developing a module that allows you to select additional options for a product that is not a product or a purchase entity. It's like commerce_option but for D8.

My inspirations come from Product Attributes shipped with Drupal Commerce. So I have mostly the same two entity types:

Product Option (config entity type) - bundle.
Product Option Value (content entity type) - the actual option with price field.

The options can be attached to commerce_order_item types as entity references. Then add to cart form display them as options to select.

The confusion comes at the part when these options come to commerce_order_item and actual order.

At the current moment, I've created a new field type with three properties: option (textfield), option value (textfield), price (commerce_price). This field automatically filled when commerce_order_item added to the cart.

Next, the most obscure part. What's the correct way to handle those additional and their prices?

I see several ways:

(current implementation) My current field type + commerce_order_item adjustments. The problem here I see, there is a bit mess with cart and other stuff. I need manually use getAdjustedUnitPrice() to get real product price. It can be affected by tax and other stuff, so this becomes a mess in the future. Plus, in this way I don't see the proper way to add a discount for this line item. Since the promotion applies to unit_price or total_price, but this amounts in adjustments. It can be solved, but may be tricky.
My current field type + override of unit_price. In this way the discount and tax problem disappear. But rises another problem. The manager, when editing order item, must take product options into account when editing it, since their price will be already included.

Maybe you can advise another approach? I also think about special commerce_order_item type + entity_reference (much complicated I think). But here all the problems of the first approach raise again.

Is it good to edit unit_price directly on order_item save\update? Or it is not expected behavior, when some event will change order_item price by adding the amounts? Also, how this must work on second and so on saves? E.g. order_item price $10, and selected option $5. When order_items saved, the current_price will become $15. When some changes are made, how to detect those options already included? The way I see, recalculate the new unit_price by grabbing the price from purchased_entity. But what if this price was manually overridden by the manager from $10, to $8? The only solution I see now, is to store price before it affected by options in the data field. Is this also correct or I miss something?

The reason because I create special field to store values is almost the same as order_item existence. The option prices can be changed, or even deleted, so order_item doesn't know anything about it and store the raw results values.


texts: To extend the highlighted region to the sidebar second region

texts:
my current account page looks like:

What I would like to do is to extend the highlighted region so it stretches to take the full width(highlighted + sidebar second), and having blocks in the sidebar second region appear below it, like so:

Please suggest any ways I can achieve this.

Config: Drupal 7 with Bartik theme.

Thanks.


texts: Snippet to show the error messages on the comment form

texts:
Every form I try to modify with a module loses the ability to display errors during submission. I searched for an option to fix that, and the solution I found was a snippet which uses form_get_error() to show the error messages. I added the snippet in a template  file for each form.

Now I need a snippet to use in a template file for the comment form. Which snippet should I use?


texts:
Im currently developing a module that must have a capability to browse/select and upload an image to the server.

function myid_user_page_form(){

    $form = array();

    $form['id']['myphoto'] = array(
        '#type' => 'item',
        '#markup' => '
'
    );

    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Save',
        '#attributes' => array(
            'id' => 'myid_save',
        ),
        '#submit' => array('formsave_action'),
    );
    return $form;
}

function formsave_action($form,&$form_state) {

}

How will I upload an image(#img_myphoto) to my server?


texts: How to import css javascript & HTML into block?

texts:
Is there anyway to import my css and javascript external files into HTML block?
I really try to make css and js inline with HTML but Drupal stripe the tags, thus i try syntax highlighter and cpn but nothing changed.


texts: drupal 7 date field stores todays date even when user hasnt entered a value

texts:
I don't want it to! :-)

I'm using custom forms implementing a date field, then saving values manually to a node later. I could add an extra step preventing the value from being saved to the node, but I won't have the necessary info available to calculate whether to do this if it's an 'edit'.

Any ideas? I just dont want to save a value if the users doesnt enter anything. Seem's simple enough to me... :-S


texts: Where are .po translations supposed to go?

texts:
I have .po file with translation and I have it in modulename/translation/xy.po

When I installed profile in XY language the file was not loaded.
I did a little digging and found that \FileTranslation::getTranslationFilesPattern looks for drupal-8.xy.po pattern so I renamed the file, reinstalled my profile but the language still was not picked up. The interface translation was downloaded just fine though. If I manually import the file it works. So it looks to me like the directory for translations has changed maybe?

I have checked the installer and it looks like Drupal only looks into the site's files/translations directory. So how are modules supposed to ship with translations?

So it looks like the translations ARE being imported just fine(entries are present in the locales_source table), but for some reason not everything is displayed translated.

Ok, so I came to a conclusion that my translation file is not imported at all. The reason for incomplete translation is because it comes from downloaded Drupal localization and not my file. I am looking at installer and there is nothing that would suggest po files discovery mechanism in any way, only the drupal core(or any po file) in the files/translations directory(which is where the drupal translation is downloaded into).


texts: $node variable for categories (taxonomy) url?

texts:
I have this structure in a node-- template so I have access to the node properties:

<a href="#" title="<?php print $category ?>"><?php print $category ?>

I also can

dpm($node);

Can someone tell me what is the variable that prints category url? Categories are listes as /category/category_name in address bar.

Thanks


texts:
I am a newbie to Drupal, and have used CakePHP and Codeigniter frameworks earlier. In Codeigniter, a URL such as /users/show/1 would be interpreted as it invoking the show() method of the Users class, passing 1 as user ID. Can we interpret a Drupal URL in this way?

If we have a URL similar to /admin/xyz?u=1, where in the admin module can I find this?

Also, I know Drupal uses a good bit of path alias. Would that affect this in a big way?


texts: Where can I add core  elements with Views RSS

texts:
I'm trying to set up a podcast feed with Views RSS. I think I've succesfully set up the module and the core <channel> elements.

I am now trying to set up the core <item> elements, as explained here. However, I have no idea if I'm looking in the correct place.

I go to admin/structure/views/view/gentle_podcast/edit/feed_1 and under Format I see:

Format: RSS Feed | Settings
Display: Fields | Settings

(I'm translating from Dutch, so labels may be off). When I click the Settings next to Display, I get a popup where I can set Title, Link, Description, Creator, Publication date and Guid.

How can I set all the other items that the documentation mentions?

Does it check the fields I've added to the view? Because I've added a field that has the URL of my podcast file (an mp3), but I don't see anywhere to set the <enclosure> item.

You can see the current result of my view here (as feed) and here (as page).


texts: drush: How to upgrade to a stable module release instead of dev?

texts:
When I use
drush pm-update
it takes always the latest which is usually a dev release. How do I force it to update to the next stable release?


texts: How to deal with Bubbleable Metadata when there's no rendering context and no render array

texts:
Since Drupal 8.0.0-beta12 "all rendering must happen in a render context", as stated by this change record.

This is to avoid bubbleable metadata lost. So far, so good.

Let's say I'm implementing a Commerce payment notification. The important part is a server calls a Drupal URL to notify something. The controller, as far as I know, doesn't need any rendering context because the answer is simple (almost just a status response). Good.

Let's say I want to send an email on this event. I create an EventSubscriber that subscribes to the payment event that happens on this callback. I hook on the event, gather the email data, and call the send function. During sending, Drupal renders the content (is an HTML email!) and I got the error: since there's no rendering context Drupal throws an exception. The point the error is triggered is when Token::replace() is called:

$body = $this->token->replace($this->getBody(), $this->getTokenData());

How to fix this?

Option 1:
Use the BubbleableMetadata $bubbleable_metadata fourth param of Token::replace(). This param docs states:

  An object to which static::generate() and the hooks and functions that
  it invokes will add their required bubbleable metadata.

  To ensure that the metadata associated with the token replacements
  gets attached to the same render array that contains the
  token-replaced text, callers of this method are encouraged to pass in
  a BubbleableMetadata object and apply it to the corresponding render
  array.

But because $body is just a plain string I guess the bubbleable metadata is lost, so what's the point of caring?

Option 2:
Follow the change record suggestion and use RenderContext::executeInRenderContext(). In that case I'd wrap the whole process:

$renderer = \Drupal::service('renderer');
$context = new RenderContext();
$that = $this;
$response = $renderer->executeInRenderContext($context, function() use ($that, $recipient) {
  $that->mailer->send($recipient);
  });

Again, I'm discarding the cacheable metadata.

I guess discarding that cacheable data is ok because the email is totally uncacheable, the whole body and its parts (because the replaced strings with tokens have URLs that would change on every email).

Are both approaches ok? Is one better than the other? Is there a third approach more suitable for this problem? I guess the problem can be summarized as how to deal with Bubbleable Metadata when there's no rendering context and no render array.


texts: Views: How to display the title and breadcrumb from taxonomy terms in URL?

texts:
I have a Page display in a View. The page url is taxonomy/term/xx and I am trying to display the term as the page title and the breadcrumb.

I have tried to set the term as an argument Content: Has taxonomy term ID with the following settings, I checked Set the breadcrumb for the term parents but it did not work. Can someone help?


texts: Custom image style used on image upload causing errors

texts:
The site is running in a Windows Server environment.

I have a custom content type, which has a single "image" field.

I have created a image style, called "slider" with the dimensions 800x480

Images uploaded have some issues:

The original file names are kept but all uploads stored in the same folder. Ideally these names would be timestamped or hashed to prevent duplicate collisions
The file dimensions do not seem to be applied in resizing the image, does this only apply if the uploaded image is larger? Do I add a "scale" filter if I want to enlarge the image to fit the dimensions?
Uploaded images go to:

http://www.mydomain.local/sites/default/files/park/pics/BHP_beach.jpg (this exists)

but the preview:
    http://www.mydomain.local/sites/default/files/styles/slider_desktop/public/park/pics/BHP_beachjpg?itok=lR2G_oG3 (this does not exist)

This latter path is not valid, rather there is no image by this name in this directory??? Why are no files being written here? I just noticed another error which is probably related to the last point I make:

  Warning: imagejpeg() [function.imagejpeg]: Unable to open
  'public://styles/slider_desktop/public/park/pics/BHP_beach.jpg' for
  writing: Invalid argument in image_gd_save() (line 270 of
  C:\mywebsite\modules\system\image.gd.inc).

How do I enable public:// stream wrappers???

Lots of questions I know...but all related to the same thing I think.


texts: Add random element to files in private so they can't be guessed

texts:
I want to add a random element to files in the /private/ directory so filenames cannot be guessed. In other words, when a file is uploaded by the admin I want the URL to download the file to be:

/system/files/RANDOM/original_filename.pdf

This is because users need access to all of the content type that contains the file, but only have access to a file associated if there is an entity reference link to their user profile on the node.

Or is there a better way to do this?


texts: How do I reference an image from text/description field?

texts:
In some cases, I am entering some text and an img src tag in descriptions and text fields on my content pages rather than use an image field, for example the Header field on a view.

I cannot work out the location to use. I thought images/imagefilename.jpg would do the job, but alas no. I also want to avoid the old http://hostname.com/images/imagefilename.jpg for vairous reasons.

My images are in themes/mytheme/images.


texts: Image getting delete away by the cronjob later in drupal 7 using theme settings

texts:
i`m using system theme settings alter to add 4 images for theme, images are getting deleted /swept away by the cronjob later .trying using  FILE_STATUS_PERMANENT images are not getting set as permanent

   function themeA_form_system_theme_settings_alter(&$form, &$form_state) {

  $form['themeA_settings']['header-page']['header_background_file'] = array(
    '#type' => 'managed_file',
    '#title' => t('Header Background'),
    '#required' => FALSE,
    '#upload_location' => file_default_scheme() . '://themebackrounds/',
    '#default_value' => theme_get_setting('header_background_file'),
    '#upload_validators' => array(
        'file_validate_extensions' => array('gif png jpg jpeg'),
    ),
  '#submit' => array('themeA_submit_handler'),
  );

  $form['themeA_settings']['block1']['block1_file'] = array(
    '#type' => 'managed_file',
    '#title' => t('block1 image'),
    '#required' => FALSE,
    '#upload_location' => file_default_scheme() . '://themebackrounds/',
    '#default_value' => theme_get_setting('block1_file'),
    '#upload_validators' => array(
        'file_validate_extensions' => array('gif png jpg jpeg'),
    ),
  '#submit' => array('themeA_submit_handler'),
  );

 $form['themeA_settings']['block2']['block2_file'] = array(
    '#type' => 'managed_file',
    '#title' => t('block2 image'),
    '#required' => FALSE,
    '#upload_location' => file_default_scheme() . '://themebackrounds/',
    '#default_value' => theme_get_setting('block2_file'),
    '#upload_validators' => array(
        'file_validate_extensions' => array('gif png jpg jpeg'),
    ),
'#submit' => array('themeA_submit_handler'),
);

$form['themeA_settings']['footer']['background_file'] = array(
    '#type' => 'managed_file',
    '#title' => t('Footer Background'),
    '#required' => FALSE,
    '#upload_location' => file_default_scheme() . '://themebackrounds/',
    '#default_value' => theme_get_setting('background_file'),
    '#upload_validators' => array(
        'file_validate_extensions' => array('gif png jpg jpeg'),
    ),
 '#submit' => array('themeA_submit_handler'),
  );

  }
   function themeA_submit_handler($form, &$form_state) {
        // Load the file via file.fid.
     if (isset($form_state ['values']['header_background_file'])) {
     $file = file_load($form_state['values']['header_background_file']);
          }
     if (isset($form_state ['values']['block1_file'])) {
       $file = file_load($form_state['values']['block1_file']);
           }
       if (isset($form_state ['values']['block2_file'])) {
          $file = file_load($form_state['values']['block2_file']);
        }
      if (isset($form_state ['values']['background_file'])) {
       $file = file_load($form_state['values']['background_file']);
     }
           // Change status to permanent.
           $file->status = FILE_STATUS_PERMANENT;
          // Save.
        file_save($file);
          // Record that the module (in this example, user module) is using the file.
        file_usage_add($file, 'user', 'user', $account->uid);
     }


texts: I can do loads of user-related stuff with Drush, but I can't see how to create new user roles. Is it possible to do this with Drush?


texts: Drupal 7, Custom Content Type... Does an addon that does this exist?

texts:
I rebuilding my companies intranet... we have what's called a portal. Within the portal is pages. Each portal page is either HTML, a PDF or a Video.

Right now... I'm planning on creating 3 seperate content types. One with Text, one with a custom PDF Object for loading in browser and one for a video. So content types like:

PAGE content Type
* Title
* Image (Icon for content flagged News)
* Text with Teaser

PDF content Type
* Title
* Image (Icon for content flagged News)
* PDF Object (loads PDF in browser)

VIDEO content Type
* Title
* Image (Icon for content flagged News)
* Video Field

FILEVIEWER content Type
* Title
* Image (Icon for content flagged News)
* FileViewer Viewer

Notice... a lot of duplication.

What I'd like to do, and tell me if I'm stupid... is I'd like to have a drop down selector that shows the content type selected, while hiding the rest.

COMBINED CONTENT TYPE
* Title
* Image
* Select List (Three, or more, choices: Text, PDF, Document, Video)
* Text w Teaser
* Video Field
* PDF Field
* Fileviewer Field

It will display the selected content type and hide the others when displayed on the actual node/block. This particular case is simply "Select One type", so I'm not worried about selecting combinations (ie: Text + Video)

I'd just much rather baby one content type... than 3+ content types with near identical layouts.

Question updated. Basically... it's my desire to have one content type instead of 4 (and possibly more). I'm not afraid to make my own custom module, although it would be a learning curve.


texts: Overlap menu does not highlight when I choose link from dropdown

texts:
-Home
-Wood
-Oferta
---Cennik
---Towar
-Contact

I've got a problem for two days. When I choose 'Oferta' from my menu, field 'Cennik' in my dropdown has a red highlight when clicked (because I made it red with @component-active-bg:red; in variables.less) but field 'Oferta' hasn't got a highlight when dropdown is gone. How to make "Oferta" and other menu links with dropdowns become red when dropdown link is chosen?
It is easier to find the parent menu, and i dont know, why it is not red by default like all other menus without dropdown.
I want to make it with LESS css if possible.

I am working with Drupal 7 and Bootstrap 3 sub-theme on LESS files.


texts: Showing icons to represent content types

texts:
Is there a simple way to have the site display a content type icon just before the "Submitted by..." function? I know I can do this conditionally in node.tpl.php like

if ($type==blog_post) echo '<img src=blog_post.png />';

etc. But this seems cumbersome. I have seen this done as part of Drupal Commons and others. Is there a module that can handle this or any other systematic changes to how the metadata is displayed?


texts: Can't acces field collection with $content

texts:
I try to render a field collection in my node--1.tpl.php template with print render($content['field_image_teaser']) with no succes. I followed the example at http://drupal.org/node/1155752

The strange thing is, when I do a print of $content width var_dump () my field is listed:

var_dump ($content);
//...
["field_image_teaser"]=>
      array(1) {
        ["und"]=>
        array(2) {
          [0]=>
          array(1) {
            ["value"]=>
            string(1) "1"
          }
          [1]=>
          array(1) {
            ["value"]=>
            string(1) "2"
          }
        }
      }
//...

but when I do a print of $content ['field_image_teaser'] the var_dump print out a NULL.

Edite:
I'm using the current recommended version 7.x-1.0-beta4.

With the answer of Neograph734 I spot that the the dump of the field "field_image_teaser" cames not direct form "field_image_teaser". It cames from the $node Object (which is referred in every field), but I can't render that value. There is no output with: print render($node->field_image_teaser);

So is there a way to get the field collection in a renderable form to use the regular template system, or is something else wrong?


texts:
I have manually removed all aggregated css and js files from sites/default/files.

I would like Drupal to regenerate these, but it does not. Drupal is still looking for the old files, the ones I have deleted.

Clearing the cache does nothing.

How do I force Drupal to recognize that the files are missing and need to be recreated?


texts: How do I display a custom field from taxonomy term in user list in rewritten field

texts:
I'm trying to display a list of taxonomy custom field terms next to a user's name. Though when I use a custom function to get the custom field (abbreviation) and then use it in a rewrite it still displays the original term list.

The taxonomy field is field_awards, the custom field attached to field_awards is field_abbreviation.

This is my custom function to display the abbreviation instead of the full term:

function ppw_views_view_field__field_awards($vars) {
    $row = $vars['row'];

    $abbr = array();
    foreach ($row->field_field_awards as $record) {
        $abbr[] = $record['raw']['taxonomy_term']->field_abbreviation['und'][0]['safe_value'];

    }

    return (count($abbr) > 0) ? ", " . implode(", ", $abbr) : "";
}

In this screenshot my theme shows the output of the function (it is excluded from display), the user's name with the awards field is rewritten into the output.

I've also tried to implement a custom field format in my theme:

function ppw_field_formatter_info() {
  return array(
    'ppw_term_reference_plain_abbreviation' => array(
      'label' => t('Plain text Abbreviation'),
      'field types' => array('taxonomy_term_reference'),
    ),
  );
}

function ppw_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  // Terms whose tid is 'autocreate' do not exist
  // yet and $item['taxonomy_term'] is not set. Theme such terms as
  // just their name.

  switch ($display['type']) {
    case 'ppw_term_reference_plain_abbreviation':
      foreach ($items as $delta => $item) {
        $name = $item['taxonomy_term']->field_abbreviation['und'][0]['safe_value'];
        $element[$delta] = array(
          '#markup' => check_plain($name),
        );
      }
      break;
  }

  return $element;
}

How do I get the abbreviations next to the name? I've been unable to find what function to implement or what theme file to add to get this to work.


texts: Prevent access to or redirect /user page

texts:
I'm looking to redirect or prevent access for authenticated users to the /user page. The reason being that it serves no purpose being there so would like to either remove or redirect it.

The best I've managed so far is to redirect the user on login so they don't get dropped on the /user page straight after logging in which works great but I'd like to prevent all access to it. The code I've used for the redirect is below:

function mymodule_user_login($account) {
  // Redirect users on login
  $link = Link::createFromRoute(
    "Admin",
    "admin.home"
  )->getUrl()->toString();

  $homeResponse = new RedirectResponse("{$link}");
  $homeResponse->send();

  return;
}

Just a note for anyone potentially using the above code - it only works in a .module file, not a .theme file which took me a while to work out.


texts: Having trouble getting mega menu to work responsively

texts:
I'm using Drupal 7 and bootrap theme, but I've tried other themes as well and I can't get it to work responsively.

What it does is drop down, but it doesn't scroll, having a hard time to troubleshoot with Chrome dev tool because of media queries.

Any idea what is causing this? Megamenu is supposed to be responsive out of the box?

URL is :

http://www.dev.wearelao.com


texts: Creating nodes and interacting with drupal from the command line

texts:
I have a requirement where I will have to insert content (nodes) from the command line.
I know that drupal bootstraping is needed to acces the environment, and this can be done using PHP.

Is there any tool that can create/modify/read content from the command line ? Are there any other programming language binds (besides PHP) ? What are the options ?


texts: Performance Implications when Views JOIN added twice?

texts:
I have a view with a flag (relationship, only show flagged nodes). I have modified it a few times and now I see in the query output that views has the join added twice:

INNER JOIN {flag_content} flag_content_node ON node.nid = flag_content_node.content_id AND flag_content_node.fid = '9'
LEFT JOIN {flag_content} flag_content ON node.nid = flag_content.content_id AND flag_content.fid = '9'

Is there a performance hit for the extra LEFT JOIN?


texts: How to move the content of 'Node content' display (Views) to the end of a view?

texts:
I installed the Answers module and I am trying to edit the question_answer view. Basically I would like the answers (which are generated by the 'node content' display) to appear below the question. This is done by default by the module: See Picture.

The problem is that I would like to move 'Post an Answer' link before the list of answers. Now it works as follows
- Question Header
---List of Answers
---- Question Footer

and I would like to change it to
- Question Header
---- Question Footer (or just the entire Question node)
----List of Answers.

I know that's because the display is "Node Content", but I don't know how to do it properly. I've tried with Attachement, Blocks and no success. You can find the screenshot of the view settings here (Default view has the same values as Node Content Display)  Any advice greatly appreciated.


texts: succesfully changed order regions in info file, but rendered html stays untouched

texts:
Layout-wise I want 3 columns in this order: sidebar first - content - sidebar right. Since the region order in d7 is content - sidebar first - sidebar second I wanted to change that order in html.

If I remember well, all that's needed to change the order of the regions, is to do that in the .info file.

So I simply just put the content region between sidebar first and sidebar second so the info file has the following in it:

regions[header] = Header
regions[highlighted] = Highlighted
regions[help] = Help
regions[sidebar_first] = Left sidebar
regions[content] = Content
regions[sidebar_second] = Right sidebar
regions[footer] = Footer

When I go to structure -> blocks The result that I'm seeings is what I was aiming for; the content region is being replaced. Yet, when I go and check the HTML,The order remains content - sidebar first - sidebar second.

Goes without saying I cleared caches often.


texts: Why do classes sometimes not get loaded when running .install?

texts:
How do I get them to load consistently?

I have a class

files[] = includes/YogaHiveBooking.php

The .install file grabs some constants from it.

$schema[YogaHiveBooking::BOOKING_TABLE] = array(

Sometimes it doesn't work

drush dis -y yhivebook // fine

Uninstall

 drush pm-uninstall -y yhivebook
 The following modules will be uninstalled: yhivebook
 Do you really want to continue? (y/n): y
 PHP Fatal error:  Class 'YogaHiveBooking' not found in

I think global variables are fine - defined in the .module file. e.g.

variable_del(YHIVEBOOK_ADMIN_EMAIL_VAR);

I am using Drupal 7.


texts: Seat reservations for (recurring) events on given days

texts:
I would like to let my users reserve seats (or a whole table) for events, and pay for the reservation via PayPal.

Different performances/shows would be advertised, users could choose which tables or seats they would like to reserve. A theater OR bar, restaurant, etc. would have "fix" seats and tables, so they would not change (or just rarely); events can be repetitive/recurring (e.g. concerts) - in some cases, locations can remain the same too, so only the date changes (e.g. a concert played in Example Bar 3 times a month); but one event can be played in other locations too.

I tried on Drupal.org first, but I got no answer; any help would be appreciated.

If there's no way to "bind" it to Ubercart, I'd solve it in another way (PayPal IPN), but I have to do it ASAP.

P.S.: I've already tried MERCI, Simple Reservation, Hotel Booking System for Ubercart and Reservation modules (the latter seemed OK from the picture), but unfortunately I couldn't figure out how to do something similar to  what I need - BUT THIS MEANS NOTHING, maybe I just overlooked some opportunities!!!

If you say I can solve it with one of these modules, please help! Even if you have a totally different suggestion! Thanks!

UPDATE:

In the meantime I found this very interesting article: Ubercart Event Registration
Let me quote from it:

  at the moment, the de facto Ubercart method for doing online event
  registration is with a module called UC Node Checkout. It's perfect
  for a one-and-done event registration site, but for a site that is
  hosting several events simultaneously and on an ongoing basis, it's
  awkward. This is due to the fact that it maps a content type to a
  product SKU - so for each event you'd need to create a new content
  type. Not really very good long-term, particularly when the site
  administrator is not overly familiar with Drupal or Ubercart.

  So, an alternative solution was devised using the Webforms module. The
  webform stores the registrant's organization's information - and also
  asks the registrant how many tickets to the event they want, which is
  the use case the client specified. The webform, after processing the
  form, adds the event 'tickets' to the cart. This is done with the
  'Webform advanced settings' field in the webform configuration, under
  'Additional Processing'.

Good to know. This means the article I found earlier doesn't describe what I need.

Another quote from uc_event_registration's readme:

  UC Node Checkout

  This is the approach that has been used alot for Drupal conferences
  and demo'd at drupalcons.  The huge problem here is twofold:  First,
  registrations are nodes.  That means we have to build views to create
  registration lists and that seems like unnecessary overhead when
  Webform is so much lighter weight.  Second, and most importantly, you
  need a new content type for EVERY event.  No thanks.  On sites that
  are doing dozens of events per year, this would mean, eventually, a
  huge amount of content types.  That's bad.

Here's another one related to Webforms: Drupal Webforms With Dynamic Select Boxes Tutorial
This seems very promising, maybe this could be the way one could solve what Andy suggested.
I'm still interested in suggestions for practical solutions - maybe this way!


texts:
I want to create a custom context. However I can't seem to get it working. I have seen the following from api.text.

Adding a condition or reaction plugin
 Both context conditions and reactions utilize the CTools plugins API.
 In order to add a new condition or reaction for your module, follow these steps:
1. Implement hook_context_plugins() to define your plugins, classes, and class   hierarchy.

function mymodule_context_plugins() {
  $plugins = array();
  $plugins['mymodule_context_condition_bar'] = array(
    'handler' => array(
      'path' => drupal_get_path('module', 'mymodule') .'/plugins',
      'file' => 'mymodule_context_condition_bar.inc',
      'class' => 'mymodule_context_condition_bar',
      'parent' => 'context_condition',
     ),
  );
  return $plugins;
}

Implement
hook_context_registry() to define your conditions and/or reactions and map them to plugins.

function mymodule_context_registry() {
  return array(
     'conditions' => array(
       'bar' => array(
          'title' => t('Name of condition "bar"'),
          'plugin' => 'mymodule_context_condition_bar',
        ),
     ),
  );
}

Write your condition or reaction plugin class. It's best to look at oneof the included plugins as a starting point.

Add in a Drupal integration point for your plugin. A node page condition plugin, for example, may be invoked from hook_nodeapi().

I have also found the following http://treehouseagency.com/blog/neil-hastings/2010/04/14/joy-extending-context.

However when I go to /admin/build/context/add I do not see my condition listed in the Condition drop down.

I have tried drush cc all

Can anyone point out anything I can read and/or a working code sample.

In the end I want to fire a condition on hook_nodapi when the node is views and a certain type. I was going to pass the $node to the execute($value) and then do the remaining checks.


texts: How do I add my new Paragraph type to a content type?

texts:
I've made a new Paragraph type and it appears as an option in the Basic Page content type, but I'd also like it to appear in another content type.

Would anyone know where I set this?


texts:
Flag Module is a very effective module for tagging entities which -  apparently - only handles two status: "flagged" and "unflagged", while  I need now to know if an entity was even been flagged before. So, 3 status:

"never flagged"
"flagged"
"unflagged"

Which solution have we today in order to see if an entity has ever been flagged?


texts:
I have a content type with a Link field which allows an Unlimited number of values. However, it appears there is no way to Remove values like there is on an Image field with multiple values.

With an Image field, there are Remove buttons next to each item so that I can remove them:

Any idea why the Link field doesn't have a Remove button? I'm logged in as user #1 (an administrator) and just to be sure I've double checked that I have all permissions and such.

Any ideas?


texts: How to remove old revisions product? I have a lot of old revisions of products. They must be removed. How?


texts: How to style map popup from GMap module?

texts:
Does anyone know where I can find, or does anyone have, a solid explanation of how to style the popup that GMap provides when you click on a map marker? I've seen it done on other sites using the GMap module, but I can not for the life of me figure out how to style it myself.

I've done some searching around and found infobubble.js, apparently code made by Google to help with the styling, however I can't figure out how to apply it to Drupal or how to use it.

Any help would be appreciated, I'm at my wits end with this one.

This is Drupal 7 by the way, and the newest version of the GMap module.


texts:
In a view such as what you find at /admin/content
The is a form on the view to delete, publish etc. Is it possible to Ajaxify so that the form will submit and the view will refresh.


texts:
I'm using FacetAPI-SearchAPI and I notice that, on every view based on search api in the breadcrumb there is the "all items" link and, when I add a facet to the search, the facet value is added to the breadcrumb.

Is there a way to remove "all items" and other facets elements from the breadcrumb?


texts:
I just enable SSL certificate for my domain.
I added that in my .htaccess file:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^domainname\.com*
RewriteRule ^(.*)$ https://www.domainname.com/$1 [L,R=301]

And:

# HSTS.
<IfModule mod_headers.c>
  Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
</IfModule>

# Cookie secure.
<IfModule mod_headers.c>
  Header set Set-Cookie HttpOnly;Secure
</IfModule>

And I changed the line in my settings.php file:

$base_url = 'https://www.domainename.com';

And :

$conf['https'] = FALSE;

All my https site displays well with the little green padlock, but the following errors appear in the dashboard drupal :

The Piwik module displays the following error:

  Message d'erreur The validation of
  "https://analytics.s1biose.com/piwik.php" failed with error "Error opening socket ssl://analytics.s1biose.com:443"
  (HTTP code 0).


texts: Contact message entitytype missing "id" parameter after 8.7.6 update

texts:
I am updating site from 8.7.1 to 8.7.6, and I'm getting strange error:

  Error: Call to a member function getType() on null in
  Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->getDedicatedTableSchema()
  (line 2213 of
  core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php)

Site seems to be working and the messages do get delivered. But when I go to admin/reports/status I get that error.

I have debugged this and it seems that there is id key missing from Message class definition.

This is based on the fact that $entity_type->getKey('id'); returns false on the contact_message entity type.

And when I debug EntityType::getKeys(), indeed there is no id key in the entity definition.

Also the id key is present in SqlContentEntityStorageSchema::fieldStorageDefinitions and when I manually include that id field definition I get rid of that error and status page works normally.

if (is_null($id_definition)) {
  $id_definition = $this->fieldStorageDefinitions['id'];
}

Of course this is not an solution, but perhaps someone can give me some pointers as to how to fix this. The production site is still in the latest 8.6.x release, and updating directly from that to current release gives me this error as well. Status page works normally in production, although it gives The Message ID field needs to be updated message.

There is no entity updates pending in the production environment, no matter how many times I run entity updates, the error message is still in the status page.

I tried sorting this out in update hook, in similar way that we've been updating our own custom entities since 8.7 update:

$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('id', 'contact_message');
$entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);

This gives no errors, but messages still appear to be broken.

Apparently the message id has been broken for some time, but we haven't noticed any issues before this one.

Any and all help is appreciated.


texts:
I use the theme "Bootstrap".

When I display a node, there is no breadcrumb. My nodes are related to taxonomy terms.

On the screenshots :

  Boutique / Les chocolats BIO

The second screenshot should be :

  Boutique / Les chocolats BIO / Tablette de chocolat noir artisanale
  BIO aux épices tchaï

"Boutique" is the vocabulary of taxonomy and "Les chocolats BIO" is the terms of taxonomy.

How to display the breadcrumb on the nodes without using any additional modules ?


texts: Filter nodes by currently logged-in user

texts: I want a view which shows nodes authored by the currently logged-in user. I can't figure out how to do this in Drupal 7.


texts: field output dependend on mime type of another field

texts:
I have a node type with 2 fields: preview_image and file (multivalue).

I can upload image and video files.

For the output I need the following:

The preview_image should only be displayed when the first file of the file field (multivalue) has a specific mime type (in my case any video mime type).

Is there a solution for that?

UPDATE:

Now we have a change in field structure. We use 2 mime types, images and videos. But for the images we need a cropping function. And we need an easy possibility to arrange the files within node editor.

Now we would like to create 2 new node types - for example 'image' and 'video'. In both node types we create the file fields - in 'image' with the cropping function.

In the main node type we now create 2 fields as entity references to get the files.

Now we need a solution to display the preview image only when the referenced node is of type 'video'.

Show preview image:

media element (referencing field)

entity of type 'video' (referenced entity)
entity of type 'image' (referenced entity)
entity of type 'image' (referenced entity)
entity of type 'video' (referenced entity)

Don't show preview image

entity of type 'image' (referenced entity)
entity of type 'image' (referenced entity)
entity of type 'video' (referenced entity)
entity of type 'image' (referenced entity)


texts:
I am trying to clean up the node pages and am finding very few options under the Manage Display tab. Do I have to dig in to the code and css to get some more control or is there a module that allows for greater customization in this area?

I am thinking about options similar to what Views allows.

Adding relationships to pull in related content. e.x. author name from profile instead of using username.
A specific example: One content type has a photo and alot of text, and I want the text to wrap around the photo.


texts: Export custom module strings for translation

texts: I've developed some custom modules for a client and implemented the $this->t() method to enable translations on static strings, like table headers. Is there a way to export only the translatable strings from my custom module into a .po file that I can handoff to someone for translation? I ideally want to export each modules translations separately so each module can be self contained.


texts: How can I store an uploaded file in custom module folder itself in Drupal8?

texts:
I am having one requirement to upload a file and store it in that module folder itself. I am just wondering how to do that. I have created a custom module with File type form element in that as below.

$form['BUCKAROO_CERTIFICATE'] = [
    '#type' => 'managed_file',
    '#title' => $this->t('Certificate'),
    '#upload_validators'  => [
                'file_validate_extensions' => array('pem'),
                ],
      '#description' => $this->t('Your Certificate (.pem file)').': '.\Drupal::state()->get('BUCKAROO_CERTIFICATE_NAME'),
      '#default_value' => $config->get('BUCKAROO_CERTIFICATE'),
      '#upload_location' => 'public://myfile/',
];

Here,I am giving #upload_location as public://myfile. this is working fine by uploading a file in sites/default/files/myfile folder. How can I upload to a custom module folder. Please suggest some alternatives.


texts: Permission option for unblock the selected users not listed

texts: I have created a user & assingned it role 'superuser'.I want to give only two permissions to superuser, block the selected user account & unblock the selected user account.I have given 'block selected user' permission from admin->people->permission but the option for 'unblock the selected user account' permission is not listed in admin->people->permission.How can i give this permission to superuser?


texts: Use Color Field Value in Views Field Template File

texts:
I have two fields in my view:

field_background_colour and field_heading

The are both being pulled from nodes and displayed in a rotating hero banner. Each node has a different colour and different heading.

The field_background_colour is defined by the color field module and therefore can be any colour they select.

I need to add the value of the background colour in hex (e.g. #000000) to the html output of field_heading.

[field_heading]

I tried using some html and replacement patterns in the rewrite of the field but it seems that gets stripped out by views. It seems to me that I need to use the field's template file to get what I want.


texts: How to remove a term programmatically from entity reference field using entity browser on translation form?

texts:
I have a content type "Articles", this is a multi-language site, by default the content is created in English, and then translated into Spanish. On new article in English, I set a title and a term for the "Category terms" field, this field is an "Entity Reference", and I'm using "Entity Browser" to show terms from a view (they are a lot of terms), when I create a translation from English to Spanish I need to remove any term related to "Category terms" field. I have tried a couple of ways, but this is not working for this field.

Here is the hook code that I'm using.

<?php

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Form state object double check.
  if (is_object($form_state) && method_exists($form_state, 'getStorage')) {

    $form_storage = $form_state->getStorage();

    // Temporal condition to avoid unexpected results while developing
    if ($form_id == 'node_articles_form') {

      // Check if form is a translation.
      if (isset($form_storage['content_translation'])) {

        // Hard coded test to override title - This works.
        $form['title']['widget'][0]['value']['#default_value'] = 'Forced title text translation';

        // Hard coded test to override Meta Search Terms - This doesn't work. Is not applyed
        $form['field_category_terms']['widget']['entity_browser']['#default_value'] = [];

        // Removing completely the field - This is not a solution, only for test.
        // unset($form['field_category_terms']);

        // Removing data from "Callback Object"
        $build_info = $form_state->getBuildInfo();
        // Getting the entity
        $entity = $build_info['callback_object']->getEntity();
        // Removing terms from entity
        $entity->field_category_terms = [];
        // Setting the entity
        $build_info['callback_object']->setEntity($entity);
        // setting a modified callback object to the $form_state
        $form_state->setBuildInfo($build_info);

        // Removing target_id default value.
        unset($form['field_category_terms']['widget']['target_id']['#default_value']);
      }
    }
  }
}


texts: Canonical URL for Front Page - without path

texts:
I've been looking for a solution to the Front Page URL issue that meets the following criteria.

Allows me to keep the Canonical and Description Tags from Meta Tags Quick on Views sub-pages.
Allows web client users to change the meta description on the front page through the Meta Tags module.

I use both the Meta Tags and Meta Tags Quick modules for views tagging and automation on standard nodes. Unfortunately I haven't been able to set the /welcome page canonical URL to a forced "http://www.website.com/". I continue to get "http://www.website.com/welcome" for the front page.

I've tried removing the path alias. I've tried setting path specific meta tags with the 'quick' module. I've input the details into the standard Meta Tags module under global front page.

Maybe there is some combination that I'm missing. Any ideas?

Additional: I've been using the Redirect Module on the site - if that matters.

Solution: Alright - after extensive poking around the issue was that I added Canonical URLs as a [current-page:url:absolute] to the GLOBAL settings rather than the Content.

This meant that the GLOBAL Front Page override was overridden by the other elements.

Worked for me, for now. Apparently I can't post the solution that I found with my team because I'm a new user. I don't plan to come back this week and will forget to publish a fix if I don't put it here. Get used to it.


texts: Limit the number of web form entries, based on a field, to a set number

texts:
I'm building a competition engine, the organisers are allowing users to submit 3 entries from the same email address. I can see that WebForms allows you to set fields to be unique, or set a number of form submissions allowed based on a cookie or IP. Sadly not on a per field basis.

Is there a simple way to do this? I've looked at the "webform_submission_user_limit_check" function which runs very logically, but I'm unsure about the best way of hooking into the function / replacing it.

Many thanks,

Dave.


texts: How do I show in the home page the facets shown in the product page?

texts:
I'm working on the http://drupal.org/project/commerce_kickstart distribution.

You can see that the products pages shows the search facets: http://demo.commerceguys.com/ck/products

How do I do to show these facets in the First Sidebar of the front page?

If this can't be done, then I think theres a main part missing in this distribution.

Imho the facets search in the products page are great but users are very used to see a main navigation in the left side of the home page, like: http://www.amazon.com/ , http://store.apple.com/us

How can I get this feature? Maybe there is module for this?

I've found this one http://drupal.org/project/commerce_catalog but it seems to be the placeholder for a project...


texts: How to create a multi step form that can be saved/edited by multiple users?

texts:
I need some tips on how to implement a form with these specifications:

Multi steps. for example the user completes section 1 then clicks next to go to section 2 and so on (can be tabs or anything similar).
It can be saved, so users can come back to continue also multiple users can edit
Some users can add a new form to the site (with a different title for a new set of users)
Users should have different permission levels to interact with these forms (creator, editor or view only).

I've been looking at webform. But it doesn't seem to offer what I need. Because it doesn't use native Drupal fields. I need a form that stores data in Drupal standard format. This allows me to expand my form's capabilities (For example using views).
Are there any combination of modules that can be helpful here?


texts: I'm trying to find out how I can use drupal_is_front in order to remove the content_side DIV and rename the content_main DIV (for use with responsive design)


texts: Link existing social media accounts to drupal account

texts:
Both upon registration and/or user editing later on, how could one give the user the ability to link his acccount with a plethora of social networks such as Facebook, LinkedIn, Skype, Google+, Twitter, etc?

I am not looking for an oAuth solution to (just) log in or register with one of the afforementioned accounts instead of a standart drupal one, I am looking for a way to give the user the ability to log in and/or register with either one of those accounts.

Is that technically possible? If yes, is there a one-in-all solution modulewise?

EDIT: to give some extra clarity, the ability to link your social networks' account(s) is a requirement upon registration too. Something like a "field-like" behaviour that will somehow store the connection with the social network account. Kinda blunt but you get the idea.


texts: Is this normal to have Drupal Commerce stuck in PENDING status after a completed paypal payment?

texts:
I'm testing out drupal commance and setup a paypal sandbox seller/buyer account. When I complete a payment with the test accounts, the status of the order says "PENDING" is this what its suppose to do after a successful payment?

I would imagine it would say PAID. I see there are other order status options such as checkout complete. Shouldn't it say that instead of Pending?


texts: Form alter + Unlimited Values + Entity Reference Field

texts:
There are two fields, News Type (Selectbox),  News (Reference Entities, Unlimited option, autocomplete)
When user select a news type, options of News fields needs to revised.
Example: Selecting World needs to display the News related to World.
I have added the ajax callback to get the revised data
I received the options
But when i submit the form or click on add more it says "This entity (node: 6) cannot be referenced. "

function featured_news_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
  $form['field_featured_news']['#prefix'] = '
';
  $form['field_featured_news']['#suffix'] = '
';

  $form['field_news_type']['widget']['#ajax'] = [
    'callback' => 'updateNews',
    'disable-refocus' => FALSE,
    'event' => 'change',
    'wrapper' => 'news-wrapper',
    'progress' => [
      'type' => 'throbber',
      'message' => t('Loading...'),
    ],
  ];

  if (!empty($values) && !empty($values['field_news_type'])) {
    $type = $form_state->getValue('field_news_type')[0]['value'];
    foreach ($form_state->getValue('field_featured_news') as $key => $value) {
      $form['field_featured_news']['widget'][$key]['target_id']['#selection_settings']['view']['arguments'][0] = $type;
    }
  }
}

function updateNews(&$form, FormStateInterface $form_state) {
  return $form['field_featured_news'];
}


texts:
What is the purpose of hook_menu(), if I can create menus from the administration pages?

function onthisdate_menu() {
  $items = array();

  $items['blog'] = array(
    'title' => 'blogs',
    'description' => 'Listing of blogs.',
    'page callback' => 'blog_page',
    'access arguments' => array('access content'),
    'type' => MENU_SUGGESTED_ITEM,
  );
  $items['blog/feed'] = array(
    'title' => 'RSS feed',
    'page callback' => 'blog_feed',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

so now where do I see the result of this function in the admin panel or in the site where the module is rendering?


texts: Returning the userId from an external script

texts:
I have a very simple external php script which will not return the userId. The script is posted below:

<?php
include_once "/includes/bootstrap.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
$userId = $user->uid;
echo $userId;
?>

This script returns an empty string, and I cannot figure out why. Any help would be appreciated.

Note: I have checked to make sure bootstrap.inc is located in the correct directory. I've made sure the directory is accessible. This should be an easy process, but for some reason I just can't return the userId of the currently logged in user..