texts: How Do I Change My Drupal Admin Password From a Drupal Test Install on My Local Machine

texts:
I am a complete Drupal beginner. My Drupal site is hosted with a provider. I have these questions and would really appreciate your insight.

1) I want to be able to change the front end log in pass from cPanel in the event I get locked out. My hosting company has provided me with (a) a lengthy way to do it and (b) a short way to do it.

(a)

Set up up SSH access
From Mod Security
Add and whitelist my current IP address
Manage SSH Keys
Generate New Key
Find the Key under Public Keys section
Manage
Authorize
SSH Access screen
Manage SSH Keys again and under Private Key View/Download
Then "convert "id_dsa" key to PPK format"
Enter password and download key
Download/install PuTTY
In PuTTY go to connection, SSH, Auth and browse for coverted key file just downloaded.
Click Session and under Port enter 2222
Enter host name and Open to connect
Answer yes to all security prompts
When prompted to Login As, enter my cPanel username and for the password use the one I set for the SSH key.
Once connected via SSH enter "cd public_html" and go to Drupal root
Then enter ""php core/scripts/password-hash.sh 'NEWPASSWORD'"
Copy the text after where it says "hash"
Return to cPanel, open phpMyAdmin, click on database, look for "users_field_data table"
Find the account with the name "Admin"
Click Edit and replace the text in the pass field by pasting in the hashcode I generated.
Lastly, go to the table in the database named "flood" and delete any rows with my IP address.
Then they say "You may want to enter your IP at the top, under Filter rows.
Do the same for the cache_entity table.

(b)
    Go to your cPanel -> Databases box -> phpMyAdmin.
    Select the database which Drupal uses from the drop-down menu on the left.
    Select the right tab that says: (SQL)
    Click the SQL tab. (I tick SQL and a text field pops up with: "Run SQL query/queries on database" (database name)
    In the SQL text field page type the following text:

update users set pass=md5(’NEW PASS’) where uid = 1;

Where NEWPASS is your desired new administrative password.

Then click on the GO button and if no errors present, the Drupal password should have been changed.

(a) is very difficult.

(b) is easier but I'm not confident that (b) is correct. Is it?

(c) I want to download/install a test Drupal to my local machine and try these tasks before I attempt them on my live site.

(d) Can I test these tasks on a my local machine with Drupal installed as a test version?

(e) Of the three installers at https://bit.ly/2QeuFLd which one do you suggest for a beginner?

Thank you for your advice.


texts: Override responsive-image-formatter for given image field of a content type

texts:
I would like to override the responsive-image-formatter.html.twig template.

I copied it into themes/custom/mytheme/templates/field folder and renamed it to responsive-image-formatter--node--gallery--field-picture.html.twig as I wanted to override it only for the field-picture image field of the gallery content type.

I followed this way, because this is how I could overwrite the image-formatter.html.twig template. I thought the behavior is same.

I cleaned the cache, but it doesn't work. The system still uses the core template instead.

Any idea or hints?


texts: Grouping Taxonomy terms by their parents

texts:
I have a Taxonomy Vocabulary for all types of cars. It has the following hierarchy:

Main Brand 1
- Sub0
- Sub1
- Sub3
Main Brand 2
- Sub1
- Sub2

and so on...

I want to have a webpage that displays the sub items when the main brand is selected.

Also, is there a way when assigning a specific value for the main brand field in my content type, for another field to appear populated by the sub brands of the main field?


texts: Views - Filtering view results by current user profile field

texts:
I have been trying to do this last couple of days but no luck.

Every user have a custom field (favorite_car) which is taxonomy and there is different terms ('Audi','Bmw' etc).

I have also content type 'Cars' which had also a custom field (favorite_car).

I need to display only the results, that user have selected.
If user have a custom field selected to 'Bmw', view need to return only nodes which have a favorite_car field set to 'Bmw'.

I think that there is a way to do this in drupal 7. Every kind of help is welcome.


texts: Can I use hook_uc_add_to_cart to ask for a yes/no confirmation before adding to cart?

texts:
For certain products in my ubercart catalog, I need to show a legal disclaimer before actually adding them to the cart.
I was thinking to use hook_uc_add_to_cart for this, because it allows me to return a message in the result array :

http://api.ubercart.me/api/drupal/ubercart!uc_cart!uc_cart.api.php/function/hook_uc_add_to_cart/7

I could return a html enriched message holding the anchor to the final cart addition, in case the legal notice is read and confirmed.

For example : How do I translate this submit input form to a query string like alternative ?

<input class="node-add-to-cart form-submit" type="submit" id="edit-submit-144" name="op" value="Add to cart">

As an alternative I could ask the 'shopper' to hit this submit a second time as confirmation.

Then: To bypass the hook a second time, I could add a confirmed Boolean into the $data array which is returning into this hook as 3th parameter.

If I add this Boolean into the $data as a new key->value pair, will it be available again in the next submission ?


texts: Why does composer not work with core composer.json file when adding new libraries?


texts: How to add canonical links on ALL URL's?

texts:
What is the best way to get canonical links on ALL URL's in D7?

I see nodes already have relative canonicals but I have a site with a lot of non node URL's that also need canonicals.

I added code to my html.tpl.php to add a canonical on any page but now I get double ups on node based pages.

Thanks for anyone taking a look at this.

UPDATE:
I used a theme_html_head_alter() hook to remove the node canonicals.
Then I added new canonicals into the html.tpl.php so every page has them and there is only one on the node pages.


texts: How can I add an extra button & submit handler to an exposed view form?

texts:
I would like to add a second button to an exposed view form.

I am able to get the button to display, but not to have it call the button submit handler. Instead, it behaves just like the standard search button that views provides automatically.

How can I have my second button call a separate handler?

Below is what I've tried to do.

(FWIW, my specific goal is to let the user use the exposed view form to search for an existing node, then if he doesn't find it, to go ahead and post a new node. So, I want a button that will call an action to post a new node.)

function my_module_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'views_exposed_form':
      if ($form['#id'] = 'views-exposed-form-my-module-page-1') {
        // Add a button
        $form['my_button']['#type'] = 'button';
        $form['my_button']['#value'] = t('My Extra Button');
        $form['my_button']['#submit'] = array('my_module_button_handler');
      }
      break;
  }
}

function my_module_button_handler($form, &$form_state) {
  // do something here
}


texts: Site shows themeless and blockless front page

texts:
I've installed a brand new Drupal 8 site (http://www.edcint.co.nz/tmp/drupal8_problem_new.PNG) with next to no configuration, default theme etc. I then ran Drupal Update against a Drupal 7 site (http://www.edcint.co.nz/tmp/drupal8_problem_existing.PNG). The content/users all came across but the front page shows without any theme or blocks, only the 3 articles/pages marked as "published to the front page" appear.

I've migrated another more simple Drupal 7 site to Drupal 8 and this did not happen.

Have I hit some limitation of the Upgrade module?
How can I make the theme and blocks reappear on the front page?


texts: How to display a form in modal dialog on page load?

texts:
This is on Drupal 8.6, PHP 7.2, Theme is based on Bootstrap.

The scenario is, I want to display a dialog box with a subscription form in the home page. The dialog box will be loaded automatically when page load, not by click any link.
I see there are lot of examples there in the net, but all related to by clicking a link, modal will display. But I want to load it without any click.

I partially successful by using BootstrapDialog, but ajax is not working on form submit button. What I did, I attach a js file in the front page, with the code below. It shows the Modal Dialog box, and I tuned a page--newsletter--subscribe.html.twig, its working But submit button not working not ajax is working.

    BootstrapDialog.show({
    title: 'Subscribe To Newsletter',
    message: jQuery('

').load('/newsletter/subscribe'),
    closable: false,
    draggable: true,
    closeByBackdrop: false,
    closeByKeyboard: false,
    buttons: [{
        label: 'Close',
        action: function(dialogRef){
            dialogRef.close();
        }
    }]
});

I saw there is an example in code node.preview.js file like this:

          var $previewDialog = $('
' + Drupal.theme('nodePreviewModal') + '
').appendTo('body');
      Drupal.dialog($previewDialog, {
        title: Drupal.t('Leave preview?'),
        buttons: [{
          text: Drupal.t('Cancel'),
          click: function click() {
            $(this).dialog('close');
          }
        }, {
          text: Drupal.t('Leave preview'),
          click: function click() {
            window.top.location.href = event.target.href;
          }
        }]
      }).showModal();

But I never able to make it working in my custom module.

If some one can help on this, will be really great!

Update:
I just tried to put a link manually in the template and tried to open the dialog, but it gives me some error:

Show Dialog

The error is as follows:

dialog.js?v=8.6.4:35 Uncaught TypeError: $element.dialog is not a function
at openDialog (dialog.js?v=8.6.4:35)
at Object.dialog.showModal (dialog.js?v=8.6.4:52)
at Drupal.AjaxCommands.openDialog (dialog.ajax.js?v=8.6.4:96)
at Drupal.Ajax.success (ajax.js?pkvhqx:155)
at Object.success (ajax.js?v=8.6.4:234)
at i (jquery.min.js?v=3.2.1:2)
at Object.fireWith [as resolveWith] (jquery.min.js?v=3.2.1:2)
at A (jquery.min.js?v=3.2.1:4)
at XMLHttpRequest.<anonymous> (jquery.min.js?v=3.2.1:4)

It seems some of the library is not loaded. Here is my global attachement:

  dependencies:
- core/jquery
- core/jquery.ui
- core/drupal.ajax
- core/drupal
- core/drupalSettings
- core/drupal.dialog
- core/drupal.dialog.ajax
- core/jquery.form
- core/jquery.once
- core/modernizr


texts: Embedded video thumb has been displayed on all overlay windows

texts:
I have been created a block to display YouTube videos on my website ,When ever i tried to open admin windows that video thumbnail has been displaying on every overlay windows how can i disable that any suggestions ?

Screenshot :


texts: Adding an OR condition to an existing query

texts:
I want to be able to search additional user fields instead of just the standard username. For instance, I would like users to be able to search an attached field with the users' Real Name. The user search query can be found in user_search_execute(). I figured I would use hook_query_alter() to alter the database query generated by this function.

The problem I am running into is that if I add anything like this:

$arguments = $query->getArguments();
$query->condition('n.field_name_value',$arguments[':db_condition_placeholder_0'], 'LIKE');
$query->leftJoin('field_data_field_name', 'n', 'users.uid = n.entity_id');

Then drupal adds a "AND" to the list of conditions (instead of an OR).

I have even tried adding something like this:

$arguments = $query->getArguments();
$query->condition(db_or()->
  condition('n.field_name_value',$arguments[':db_condition_placeholder_0'], 'LIKE'));
$query->leftJoin('field_data_field_name', 'n', 'users.uid = n.entity_id');

However, this produces the same results.

thanks!


texts:
I need to manage different fields for different roles in a content type. If users enter a value for that field, administrator users can see it but not edit that field; on the same content type, when administrator users fill a field, users can see it but not edit it.

I have used the Field Permission module for this.

How can I show all the fields to any user, but control the edit part for different roles?


texts: how to replace file with an empty file of the same name?

texts:
My Set-Up:

When a user uploads a file, it first gets uploaded to a folder on my local server, and then gets moved to an amazon s3 server for storage.  Currently, when the file is moved to s3, the local file gets deleted.

What I would like to do:

Rather than delete the local file, I would like to replace the local file with a 0-byte file.  Reason:  so that if another user uploads a file with the same name, the system will know it needs to rename the second file.

My Question:

How can I replace a file ("myvideo.flv") with an empty file of the same name, so that "myvideo.flv" now contains 0 bytes?


texts: Show menu items with limit access to anonymous users

texts:
I have a website that uses Private module in order set the access to the content, and of course some of my pages have menu items. Now if I set a page to be private, only users with proper permission could see that, which is great and what I wanted.

But I am having a bit of issue with the menu items, they disappear if the content assigned to them are not public (ie the page assigned to them is Private), this is OK but I would like to be able to still show those items in the navigation, so if user clicks on them, it will take them to the login page asking them to enter their details in order to see that particular page.

So basically I would like to change the behavior of the menu items the way that they will always be visible to anonymous and registered members of the website but when you click on them, you will be either able to see the page (if you are logged in) or be redirected to the login page (if anonymous)

I found this solution which is not the best one for me since I have many pages like that so I am looking for a better approach. I have even tried Menu item visibility module but that didn't help either!

How do I achieve this please?

Luca


texts: FedEx Address Validation module setup help

texts:
I am trying to force accurate city, state and zip code entries when a user inputs their address. the Address Field module by default doesn't require any accuracy. For example i can type "fake city" and it will accept that.

I found the FedEx Address Validation module, but as stated on the module page there is no user interface for connecting your FedEx credentials.

Does anyone know where to add my credentials?

  This module has no User Interface, so you must set the following variables:
  fedex_address_validation_environment - must be either "test" or "live".

Live credentials are made up of the following 4 values:

fedex_address_validation_live_key
fedex_address_validation_live_password
fedex_address_validation_live_account
fedex_address_validation_live_meter

Test credentials are made up of the following 4 values:

fedex_address_validation_live_key
fedex_address_validation_live_password
fedex_address_validation_live_account
fedex_address_validation_live_meter

I tried adding to settings.php

$conf['fedex_address_validation_environment'] = 'test';
$conf['fedex_address_validation_live_key'] = 'LIVE KEY';
$conf['fedex_address_validation_live_password'] = 'FEDEX PASSWORD';
$conf['fedex_address_validation_live_account'] = 'ACCOUNT NUMBER';
$conf['fedex_address_validation_live_meter'] = 'METER NUMBER';

with no change. status still "Not configured for test"


texts: AJAX on multiple views pagers fails to work

texts:
I have a situation that not all of my AJAX enabled pagers are working.

I have several blocks on a page where each block is a view with a pager.
Each pager has a unique ID.
I use Context to determine which blocks to show on the page.
Some blocks will consistently work, but other ignore AJAX and instead go for a full page refresh.
And most importantly, it only fails for anonymous users. It works consistently when I am logged in as an administrator.

How can I ensure that the AJAX pager will work consistently?


texts: Drupal7 | Time shows differently in Frontend and Backend

texts:
The front end time shows as 3 hours behind the backend time of the same page.
The correct time is the one on the backend.
I set the time-zone correctly for the user and also
the time show correctly in the "Administration » Configuration » Regional and language » date and Time"

Here is the time that the page shows on the Backend (the correct time):

And here is the time showing on the front-end (3 hours behind)

And here is the code that I am using in the page template file:

`<?php print "Last Updated: " . format_date($node->changed, $type = 'medium'); ?>`

I am developing this Website locally on my machine (localhost).
Any Ideas to get the time correct on the front end?
Thanks.


texts: In Views, how can I display an edit link if a node relationship exists, otherwise display an add link?

texts: I have a view of assignments, and want students to be able to post their work from that node. If they already have a work node, I want to display an edit link. Otherwise, I want to display an add link. In a previous version of this view, I used a Views PHP field that queried the DB for a work node matching the assignment, but I am rewriting the view because of a bug and I wanted to revisit this because it seemed a but ugly. Can anyone think of a better way?


texts:
I am actualy working on drupal multisite environment and I am stuck within a alias suffix problem.

I made a setup like this in my sites.php file for the multisite alias names.

$sites['example.example.de'] = 'example.example.de';
$sites['tp-ref.example.example.de.vwp'] = 'example.example.de';
$sites['tp-tst.example.example.de.vwp'] = 'example.example.de';
$sites['tp-dev.example.example.de.vwp'] = 'example.example.de';
$sites['tp-local.example.example.de.vwp'] = 'example.example.de';

My VHost Config file is the following.

<VirtualHost *:80>
  DocumentRoot "C:/seu/xampp/htdocs/iptp"
  ServerName example.example.de
  ServerAlias tp-ref.example.example.de/vwp tp-tst.example.example.de/vwp tp-dev.example.example.de/vwp tp-local.example.example.de/vwp
</VirtualHost>

The host file contains the following lines.

127.0.0.1 example.example.de
127.0.0.1 tp-ref.example.example.de
127.0.0.1 tp-tst.example.example.de
127.0.0.1 tp-dev.example.example.de
127.0.0.1 tp-local.example.example.de

The URL example.example.de works without any problems; when I am trying to open one of the other URLs, I could open the page, but Drupal seems to have a problem with the path.
For example, if I want to open the URL "tp-ref.example.example.de/vwp", Drupal trys to load all CSS and JavaScript files from tp-ref.example.example.de, but it should load it from tp-ref.example.example.de/vwp.

I think this is a base path problem. Does Anyone have an idea about how fix this?

The comment shown in the sites.php is the following one. I used it to edit the sites.php file.

/*
 * URL: http://dev.drupal.org
 * $sites['dev.drupal.org'] = 'example.com';
 *
 * URL: http://localhost/example
 * $sites['localhost.example'] = 'example.com';
 *
 * URL: http://localhost:8080/example
 * $sites['8080.localhost.example'] = 'example.com';
 *
 * URL: http://www.drupal.org:8080/mysite/test/
 * $sites['8080.www.drupal.org.mysite.test'] = 'example.com';
 */


texts: How to display content type name on related image?

texts:
I have create one content type[article] with two by default field i.e. title and body.
In body summary part we have contain one image on left side and description on right side.

I want display the content type name on that image which is show in summary part.
Please help


texts: Importing non-unique terms with Feeds Importer

texts:
I'm trying to import a large chunk of data to our site using Feeds Importer. However, I've come to a small problem when trying to map a piece of our data to a collection of taxonomy terms.

The problem is as follows:

We have a vocabulary called Categories with two levels. Every parent term has a list of child terms.
In some of our terms, both the parent and the child have the same name, e.g.:

parent; child
Cozinhas; Cozinhas

This is absolutely necessary as we need both the main category and the sub category to be listed and presented in this fashion.

With Feeds Importer we simply import all the main (parent) categories once and the every sub (child) categories related to it (e.g.: "Casas de Banho" -> "Banheiras"). However, in this case, it simply maps the term to the parent and lists it twice. We are using Hierarchical Select to save the terms, so we use Tamper to explode the terms we've imported and send it to the correct field.

I've tried importing the alias of the sub-category term ("Cozinhas-0") and the unique ID to map it correctly but it simply doesn't work that way, it seems it has to be the term name.

Is there any way to map this correctly?

tl;dr:

We need to import several values, with Feeds Importer, into a single Hierarchical Select field and we need them to be unique, in order to map same-name taxonomy terms to their correct ID. Is there a way to do this?


texts: How to create anchor link to another page

texts:
I want to set an anchor link on a page to an anchor on a different page. I have been able to do this using CKEditor, specifying the target anchor and then specifying an href for the link in CKEditor to, for example, /training/classes/#puppy-training.

This works, but the resulting URL obviously includes the #,  instead of /training/classes/puppy-training. Is there any way to remove the # mark from the URL?

This is using nodes built with custom content types in Drupal 7. I've also noticed the Links module, and wonder if it might be of any any help setting up anchors?

I'm also wondering how to approach this if I was using Views.


texts: How do users can login automatically through URL when they click on the link received in Email

texts: In Drupal 7, I am sending E-mail to each user with some content. Here I need to send link to automatically login through URL means when they click on the link they should redirect to the site and submit the form. This form should submitted by only authenticated users. How to generate those Unique URLs. Is there any module for this or give me any ideas please.


texts: How to disable Create new revision option in a node programmatically

texts:
I am trying to disable the 'Create new revision option' in each existing nodes programmatically.
I tried with below codes but it was not working.

$results = db_select('node', 'n')
->fields('n', array('nid','vid'))
->execute();
foreach ($results as $result) {
$node = node_load($result->nid);
// Disabling the Create new revision option
$node->revision = FALSE;
node_save($node);
}

Can anyone help me on this? Thanks.


texts: Whats the difference between a 'page', a 'panel', and a 'handler'?

texts:
I am porting a site over and looking through the code, and in a module there are folders for pages, handlers, and plugins/layouts (containing panels layouts) . The pages and handler folders contain .inc files. They are exports of pages and panels etc. However, what is the definitive difference between a handler, panel, and page?
Thanks


texts: So what happend to pear.drush.org I havent been able to access that page and drushs puppet module relies on it. Is the site down?


texts: How to exclude a cache table from memcache?

texts:
I have created a one custom table for storing the data, based on cache rules i have created a table.

Installed and enabled Memcache module in site.

Configured memcache in settings.php

  $conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
  $conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc';
  $conf['memcache_stampede_protection'] = TRUE;
  $conf['cache_default_class'] = 'MemCacheDrupal';

  // The 'cache_form' bin must be assigned to non-volatile storage.
  $conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
  // Don't bootstrap the database when serving pages from the cache.
  $conf['page_cache_without_database'] = TRUE;
  $conf['page_cache_invoke_hooks'] = FALSE;
  $conf['cache_thrive_tips'] = 'DrupalDatabaseCache';
  $conf['memcache_servers'] = array('localhost:11212' => 'default');

When i configure memcache in my site, at that time onwards my custom table(cache_abc) not storing any values.

How can i exclude only this table from memcache?


texts: Drupal form elements in html table, label (title) rendering

texts:
How to place title/label in other cell of the html  table

I have:

function hook_theme() {
  return array(
    'hook_form_table' => array(
      // The renderable element is the form.
      'render element' => 'form',
    ),
  );
}

function hook_form_table_form($form = array(), &$form_state) {

    $form['#theme']= 'hook_form_table';
    $selected_two="";
    $options_second=array("a");
    $form['carmodel'] = array('#type' => 'select',
        '#options' => $options_second,
        '#default_value' => $selected_two,
        '#required' => TRUE, '#title' => t('Car model:'),
        '#validated' => true,
        '#prefix' => '
',
        '#suffix' => '
',
    );

    $options_euro=array("Euro 3,4","Euro 5" );

    $form['euro'] = array('#type' => 'select',
        '#options' => $options_euro,
        '#default_value' => $selected_two,
        '#required' => TRUE,
         '#title' => t('Euro type:'),
        '#validated' => true,
     );

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

  return $form;
}

function theme_hook_form_table(&$variables) {
    $form = $variables['form'];
    $content = '
' . t('Please enter your information below') . '
';
    $content.="
";
    $content.="
";
    $content.="";
    $content.=$form['carmodel']['#title'];
    $form['carmodel']["#type"]="";

    $content.="	";
    $content.="";
    $form['carmodel']['#title']="";
    $form['carmodel']['#required']="";
    $content .= drupal_render($form['carmodel']);
    $content.="	";
    $content.="";
     $content.="hire want euro type  with * and label and all";
    $content.="	";
    $content.="";

    $content .= drupal_render($form['euro']);
    $content.="	";
    $content.="
";
    $content.="
";
  return $content;
}

This give me a table but labels is on top:

How to render label to put it like this:


texts: How do I add CacheableMetadata to an array I'm returning in a rest resource?

texts:
I'm getting the following error, which I've seen in several other questions, but as yet I haven't been able to make any of the example solutions work:

  LogicException: "The controller result claims to be providing relevant
  cache metadata, but leaked metadata was detected. Please ensure you
  are not rendering content too early.

Most of the other questions seem to revolve around somebody trying to return a node object, or a URL object, which needs to be added to the response as a cacheable dependency. In my case, I'm just extracting some data from fields and building a simple array with it. But it appears that as soon as I execute a query, the problem rears its head, even if I don't actually use any data from the query:

/**
 * Provides a resource for listing available foo data
 *
 * @RestResource(
 *   id = "foos",
 *   label = @Translation("Foos list"),
 *   uri_paths = {
 *     "canonical" = "/api/v1/foos",
 *   }
 * )
 */
class FooListResource extends ResourceBase {

  /**
   * Responds to resource GET requests.
   * @return \Drupal\rest\ResourceResponse
   */
  public function get() {
    $data = [
      'data' => $this->get_valid_years(),
      '#cache' => [
        'contexts' => [
          'url',
        ],
      ],
    ];
    $response = new ResourceResponse($data);
    $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
    return $response;
  }

  /**
   * Get the nodes and list years
   */
  private function get_valid_years() {
    $years = ['2018', '2019'];
    $query = \Drupal::entityQuery('node')
      ->condition('status', 1)
      ->condition('type', 'foo_type');
    $nids = $query->execute();
    return $years;
  }

}

I've also tried this with CacheableJsonResponse, with no better luck. I feel I'm missing something incredibly obvious here. Can anyone enlighten me?


texts: Conference registration form/site with limited places available

texts:
I have to build a little conference-site with a registration-form.

The conference is 1 day and has different sessions in the morning and different sessions in the afternoon. Those sessions have limited spaces available.

Users should be able to register for the conference by the registration-form and if there are no more spaces available for a specific session, they should get a message that this is no longer available, so that they have to choose another session.

What is the best solution for this, knowing that my client wants 1 registration form for the entire day. Otherwise I was considering entity_registration. With the "1 registration form" in mind, I was considering to use webform and webform_validation or webform_rules, but there is no standard solution for the limited spaces available.

Is there a good solution for this problem?

Can someone help me?


texts: Assign all permissions to a user programatically

texts: Is there a way to assign all the permissions to an authenticated user through code, I want to do it in unit tests.


texts: Render Panels Overridden user profile template

texts:
I have overridden the user profile template using Panels module and want to render this overridden user profile in one of my custom module.

Actually I wanted to show "About Author", tab besides the "View" tab of article, which when clicked, will show overridden user profile.

For that I have created menu entry as follows:

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

    $items['node/%node/author'] = array(
        'title' => 'About Author',
        'page callback' => 'get_node_author',
        'page arguments' => array(1),
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
    );

    return $items;
}

My function is as follows:

function get_node_author($node = NULL) {
    $account = user_load($node->uid);
    $account_view = user_view($account);
    return drupal_render($account_view);
}

But it is loading user profile in normal format and not the one which is customized using panels.

Any suggestion how can I achieve this?


texts: How to fix - PDOException: SQLSTATE[42S22]

texts:
I cannot seem to get rid of this error after numerous updates, anyone got any ideas/advice how to fix it as my Admin Modules doesn't want to load at all. I'm running D7.26 on this project.
Thanks.

Reports as:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'has_children' in 'field list': UPDATE {menu_links} SET
  menu_name=:db_update_placeholder_0, plid=:db_update_placeholder_1,
  link_path=:db_update_placeholder_2,
  router_path=:db_update_placeholder_3, hidden=:db_update_placeholder_4,
  external=:db_update_placeholder_5,
  has_children=:db_update_placeholder_6,
  expanded=:db_update_placeholder_7, weight=:db_update_placeholder_8,
  depth=:db_update_placeholder_9, p1=:db_update_placeholder_10,
  p2=:db_update_placeholder_11, p3=:db_update_placeholder_12,
  p4=:db_update_placeholder_13, p5=:db_update_placeholder_14,
  p6=:db_update_placeholder_15, p7=:db_update_placeholder_16,
  p8=:db_update_placeholder_17, p9=:db_update_placeholder_18,
  module=:db_update_placeholder_19,
  link_title=:db_update_placeholder_20,
  options=:db_update_placeholder_21,
  customized=:db_update_placeholder_22 WHERE (mlid =
  :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] =>
  navigation [:db_update_placeholder_1] => 0 [:db_update_placeholder_2]
  => catalog [:db_update_placeholder_3] => catalog [:db_update_placeholder_4] => 1 [:db_update_placeholder_5] => 0
  [:db_update_placeholder_6] => [:db_update_placeholder_7] => 0
  [:db_update_placeholder_8] => 0 [:db_update_placeholder_9] => 1
  [:db_update_placeholder_10] => 420 [:db_update_placeholder_11] => 0
  [:db_update_placeholder_12] => 0 [:db_update_placeholder_13] => 0
  [:db_update_placeholder_14] => 0 [:db_update_placeholder_15] => 0
  [:db_update_placeholder_16] => 0 [:db_update_placeholder_17] => 0
  [:db_update_placeholder_18] => 0 [:db_update_placeholder_19] => system
  [:db_update_placeholder_20] => Catalog [:db_update_placeholder_21] =>
  a:0:{} [:db_update_placeholder_22] => 0 [:db_condition_placeholder_0]
  => 420 ) in menu_link_save() (line 3208 of /var/www/sitename/includes/menu.inc).


texts: Migration taking increasingly long periods of time

texts:
I have a migration and I've noticed that the code, through each batch operation, seems to process less and less items.

For example, the first few cycles, it'll say, "processed 600", and 600 or around there will be processed. However about 5-10 cycles in, and it will still say "processed 600", and it actually processes perhaps 100 or 200. This eventually stops the migration from happening, as it essentially grinds to a halt.

It was completing on my local machine and not the stage environment, which I initially thought to be due to some sort of environmental condition. Now I think that the cycles on my local were just large enough to allow everything to process before it grinded to a halt.

I'm not sure what is causing this, and if it's in this migration, or the migration that this migration is extending. I'll include the former, and if anyone needs the latter, let me know.

Note, there may be occasional instances where the words Company or Type are capitalized when they should not be - I just did a quick find/replace for sensitive data.

class CompanyTypeUserDataMigration extends CompanyCertBaseMigration {

public function __construct($arguments) {
    parent::__construct($arguments);

    $this->machineName = "CompanyTypeUserData";
    $this->systemOfRecord = Migration::DESTINATION;
    $this->group = MigrateGroup::getInstance("Company");
    $query = Database::getConnection('default', 'Type')
        ->select('Type')
        ->fields('Type', array('Name', 'Username', 'Address', 'City', 'State', 'Zipcode', 'Country', 'Phone', 'Notes', 'Email'));
    $query->addExpression('`Company Name`', 'Company');
    $query->addExpression('`Supervisor Email`', "supervisor_email");
    $query->addExpression('`Declined Recert Renewal`', "declined_recert");
    $query->isNotNull('Username');
    $this->source = new MigrateSourceSQL($query, array('status' => 'Status calculated based on various fields'));
    $this->destination = new MigrateDestinationUser();
    $this->map = new MigrateSQLMap($this->machineName, array(
            'Username' => array('type' => 'varchar',
                'length' => 50,
                'unsigned' => FALSE,
                'not null' => FALSE,
            ),
            'Email' => array('type' => 'varchar',
                'length' => 50,
                'not null' => FALSE,
            )
        ), MigrateDestinationUser::getKeySchema()
    );

    $this->addFieldMapping('name', 'Username');
    $this->addFieldMapping('field_company', 'Company');
    $this->addFieldMapping('field_supervisor_email', 'supervisor_email');
    $this->addFieldMapping('field_notes', 'Notes');
    $this->addFieldMapping('field_status', 'status');
    $this->addFieldMapping('field_full_name', 'Name');
    $this->addFieldMapping('uid', 'user_id');
}

public function prepareRow($row) {
    // Always include this fragment at the beginning of every prepareRow()
    // implementation, so parent classes can ignore rows.
    if (parent::prepareRow($row) === FALSE) {
        return FALSE;
    }
    if (empty($row->Username)) {
        return FALSE;
    }

    $uid = $this->find_user_id($row);
    if($uid === FALSE){
        return false;
    } else {
        $row->user_id = $uid;
        $user = user_load($uid);
        if(isset($user->name)){
            $row->Username = $user->name; //so we don't try to overwrite username permutations
        }
    }
}

}


texts: How to override system_time_zones in Drupal 7

texts:
How can I override the system_time_zones() function without hacking the Drupal 7 core?

I would like to modify how the dropdown list is presented, but cannot seem to get at it with hook_form_alter().

My end goal here is to reformat the timezone dropdown list to include only the location and offset by removing the date/time from the <select> lists <options> text.

For example,

'Pacific/Honolulu: Friday, June 1, 2012 - 6:43pm -1000' would change to
'Pacific/Honolulu: -1000'

This would be a simple edit to system_time_zones() in system.module, but hacking core is not an option for me.

If I were to hack core, this is what I would like to do.

Before Edits (for reference):

function system_time_zones($blank = NULL) {
  $zonelist = timezone_identifiers_list();
  $zones = $blank ? array('' => t('- None selected -')) : array();
  foreach ($zonelist as $zone) {
    // Because many time zones exist in PHP only for backward compatibility
    // reasons and should not be used, the list is filtered by a regular
    // expression.
    if (preg_match ('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
      $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace ('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone)));
    }
  }
  // Sort the translated time zones alphabetically.
  asort ($zones);
  return $zones;
}

After Edits (Changes are to $zones[$zone] in @zone string):

function system_time_zones($blank = NULL) {
  $zonelist = timezone_identifiers_list();
  $zones = $blank ? array('' => t('- None selected -')) : array();
  foreach ($zonelist as $zone) {
    // Because many time zones exist in PHP only for backward compatibility
    // reasons and should not be used, the list is filtered by a regular
    // expression.
    if (preg_match ('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
      $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace ('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', ' O', $zone)));
    }
  }
  // Sort the translated time zones alphabetically.
  asort ($zones);
  return $zones;
}

How can I accomplish this without messing with core?


texts: How to programmatically create forums and containers (not forum topics)?

texts:
I need to create containers and forums using rules.

If I use the action "Create new entity" -> "Taxonomy term" I got that by default the new term created is treated as a forum, not a container. How can I either convert it to be a container or, using a custom PHP script, create directly a container ?

I tought it was some variable of the term to make the difference, but if I use Devel over both containers or forums they looks the same.

I found http://www.unibia.com/unibianet/drupal/how-create-drupal-forums-and-containers-programmatically but it refers to D6, and in D7 I don't know what to pass as $form and $form_state to the forum_form_container() function.


texts:
I'm running a local dev Drupal 8 install in Docker using the Docker4Drupal project. I tried to run drush up to update my core from Drupal 8.2.4 to Drupal 8.2.6 and got the following errors:

rmdir(/var/www/html/aadlorg/drupal-8.2.6/core/lib): Directory not empty filesystem.inc:150                [warning]
Destination directory /var/www/html/aadlorg/drupal-8.2.6 already exists.                                    [error]
Updating project drupal failed. Attempting to roll back to previously installed version.                    [error]
rmdir(/var/www/html/aadlorg/drupal-8.2.6/core/modules): Directory not empty filesystem.inc:150            [warning]
Destination directory /var/www/html/aadlorg/drupal-8.2.6 already exists.                                    [error]
Unable to move /home/www-data/drush-backups/drupal/20170303142739/drupal to                                 [error]
/var/www/html/aadlorg/drupal-8.2.6.
Could not restore backup and rollback from failed upgrade. You will need to resolve manually.               [error]
Backups were restored successfully.                                                                            [ok]
Backups were restored successfully.                                                                            [ok]
require_once(/var/www/html/aadlorg/core/includes/errors.inc): failed to open stream: No such file or      [warning]
directory bootstrap.inc:562
[03-Mar-2017 14:32:40 UTC] PHP Fatal error:  require_once(): Failed opening required '/var/www/html/aadlorg/core/includes/errors.inc' (include_path='.:') in /var/www/html/aadlorg/core/includes/bootstrap.inc on line 562
Fatal error: require_once(): Failed opening required '/var/www/html/aadlorg/core/includes/errors.inc' (include_path='.:') in /var/www/html/aadlorg/core/includes/bootstrap.inc on line 562
Drush command terminated abnormally due to an unrecoverable error.                                          [error]
Error: require_once(): Failed opening required '/var/www/html/aadlorg/core/includes/errors.inc'
(include_path='.:') in /var/www/html/aadlorg/core/includes/bootstrap.inc, line 562

Now my Drupal install is totally broken:

Warning: require_once(autoload.php): failed to open stream: No such file or directory in /var/www/html/aadlorg/index.php on line 14

Fatal error: require_once(): Failed opening required 'autoload.php' (include_path='.:') in /var/www/html/aadlorg/index.php on line 14

I'm logged into the container as the www-data user and all the directories are owned by that user. So did I do something wrong? Should I try to run drush as root? Just not use drush to update core?


texts:
Now I'm having like

1|City name
2|Another city name
3|Little town name

in values field when creating content type field

How can I wrap some of them in a group that will appear as “optgroup” in html generated?


texts:
I want to write the logs for users info, page navigation in drupal 7.
For example: from the time the user log in what actions he has performed, pages visited

Is there any module available? Please help.


texts: Appending a hidden input value to a textarea value?

texts:
So basically what I need to do is append a hidden input value to the text-area without overriding the original texarea value on submit. What am I doing wrong? This is in the template.tpl file.

function hook_form_alter(&$form, &$form_state, $form_id) {
     if($form_id){
         $sCampaign = $form['submitted']['campaignstring']['#value'];//hidden value
         $sComments = $form['submitted']['Comments']['#value'];//comments textarea
         $sComments = $sCampaign."-".$sComments; // Appending them.

    }

}

I also tried:

function hook_form_alter(&$form, &$form_state, $form_id) {
         if($form_id){
             $form['#submit'][] = 'submit_string';
           }
    }

function submit_string($form, &$form_state){
    $sCampaign = $form['submitted']['campaignstring']['#value'];
    $sComments = $form['submitted']['Comments']['#value'];
    $sComments = $sCampaign."-".$sComments;

}

Newer try:

function THEME_form_alter(&$form, &$form_state, $form_id) {
//Appending Campaign String to comments
$form['submitted']['Comments']['#value'] = array('#value' => $form['submitted']['Comments']['#default_value'] .'/'. $form['submitted']['campaignstring']['#value'],
                );
}

function submitHandler($form, &$form_state){
    $campaingString = $form_state['values']['campaignstring'];
    $comments = $form_state['values']['Comments'];
    $comments = $comments."/////".$campaingString;

    drupal_set_message('Submitted');
    drupal_set_message($form_state['values']);
}


texts:
Looking at the documentation for the Drupal 8 html.html.twig template file, I notice node_type is listed between the available variables for that template file.
Contrary to the other variables available to that template file, thought, node_type is not set from template_preprocess_html() nor _template_preprocess_default_variables(), which are the functions I expect to set the documented variables for that template file.

What function or method initializes node_type to the bundle of the currently viewed node for html.html.twig?


texts: Add Comment after every 200 words of a node

texts:
I am creating a creative writing feedback site and would like the option for feedback to be given after every 200 words of the body of one particular node type I'm calling chapter. The writer would post an entire chapter, but then when a user wants to give feedback the node would display like this:

The first 200 words of this chapter would go here

-Add Comment

The second 200 words of this chapter would go here

-Add Comment

The third 200 words of this chapter would go here

-Add Comment

And so on and so forth. I've found the pagination module that will break up the node body into specific length sections, each with comment form, but I want to be able to display multiple 200-word sections on each page.

Any idea on how I might accomplish this function?


texts: "Non-existed service" errors after clearing the cache

texts:
After clearing the cache in Drupal 8 (via the UI) I got "The website encountered an unexpected error. Please try again later." error. It happened for the first time. I haven't introduced any heavy changes to the site, basically only created a field and some features (via the Features module).

I've found this error in the logs:

  Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "password_migrate". in /.../app/vendor/symfony/dependency-injection/ContainerBuilder.php on line 800

To fix this was trying different things: clearing cache tables directly in the DB, trying drush rebuild (rebuild wasn't successful since it yelds the same error). After some time the error is different (and I don't know why):

  Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service "ctools.paramconverter.tempstore" has  a dependency on a non-existent service "user.shared_tempstore". in /.../app/vendor/symfony/dependency-injection/  Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php on line 58

I can temporarily get the site back to life by loading {cache_container} table from the old backup. But the site breaks again after clearing the cache and the first error reapers in logs.

The site is basically broken. How can I restore it? How is the {cache_container} populated, so I can reverse the process and restore what's missing based on the cache? Thanks!


texts: Remove menu item in template.php drupal 7

texts:
After quite a bit of googling I'm asking here which theme_* function I use to remove a menu item.

I already use theme_menu_link to alter 2 of the menu items in this menu but I want this one to dissapear completely.

Wasn't there a field I could add to the array that would hide it or am I thinking of something else?


texts:
I'm having a developer work on a site for me.  I'm being told that each user must have a unique username.  That makes sense.  I'm also told that they all need to have a unique password.  This doesn't make sense and is causing problems for me client.
Shouldn't a unique combination of username and password be what's required?
Can anyone help direct me to a solution?


texts: How do I check a form is a node type form?

texts:
I am writing a custom module and I want to add some condition in hook_form_alter() to check the form is a node type form.

Is there any function to check whether a form is for a node?


texts: How is it possible for CSS code to be in a false directory but still be used?

texts:
I am trying to mimic a theme from another website. I pulled the code / database down and now I have a local copy.

The sub-theme this guy is using is fine and correct, all is in order.

/var/www/sandbox/sites/all/themes/erc_generic/css/

However, when I go to look at where he put his CSS code, its in this directory:

/var/www/sandbox/sites/default/files/css/

This is no-where near in the sub-theme that is being used by Drupal.

He has about 30-40 CSS files in that folder and they don't have normal names either.. here is a example of one:

css_0_-tDmvAnmauKU86ANuyPJMDjn5wjUx4qFEEbOhbr7g.css

Also for whatever reason, maybe for extraction purposes, each CSS file he has, he has them individually zipped up.

I am trying to mimic the theme and I thought just copying and pasting the sub-theme settings would do, but when I right-click on the site to look for what CSS properties are being used.. they are linked to these files instead.

How does one even DO this? I can't find how he can link CSS files to a theme thats not even located in the sub-theme folder.


texts: Add custom tag in RSS XML header Drupal 7

texts:
I'm using Views to generate a custom RSS feed. I need to add an extra tag in the header. I tried different setting in Header section of the Feed Display, but nothing gets displayed in the feed.

Could anyone explain what's the best way to do it


texts: Drupal SA-CORE-2014-005 - How to tell if my server / sites were compromised?

texts:
I just updated all my sites using the patch method of resolving the Drupal SA-CORE-2014-005 exploit. I just read reports that just yesterday there is someone from a Russian IP infiltrating drupal sites.

https://www.drupal.org/SA-CORE-2014-005

My main concerns are now:

How do I tell if my sites have been comprised?
What should I search for in my apache access logs to detect if my site was a victim or not?
So far what are these hackers doing to comprised sites?


texts: Deleted nodes appears in Views VBO list with their pathauto links

texts:
Deleted nodes appears in Views VBO lists with their pathauto links.

I have custom VBO view which I use to delete filtered nodes. After processing I get this message i.e. 'Skipped Delete node on node id 251'. It's probably because the node doesn't exist, but in the views list it's still listed and has its original title and path to it and when clicked it gives page not found.


texts: using EntityFieldQuery to find a custom taxonomy field

texts:
I have the following query which works:

$query = "SELECT field_code_description_value FROM {field_data_field_code_description} WHERE bundle = :vocabulary AND entity_id in (SELECT entity_id FROM {taxonomy_term_data} WHERE name = :name)";
  $results = db_query($query, array(':name' => $fund_code, ':vocabulary'=>'fund_code'));
  $terms = $results->fetchObject();

I'm trying to convert this into using EntityFieldQuery, as it seems to be the best way to go (and I need some practice), but I couldn't get it right. This is what I tried:

$query = new EntityFieldQuery();
    $query
      ->entityCondition('entity_type','taxonomy_term')
      ->entityCondition('bundle','fund_code')
      ->fieldCondition('taxonomy_term_data','field_code_description', $fund_code, '=')
      //->propertyCondition('vid', $fundCodeTaxonomy->vid);

    $results = $query->execute();
    foreach($results['taxonomy_term'] as $tid) {
      $term = taxonomy_term_load($tid);
      dpm($term);
    }

How do I properly use EntityFieldQuery here?


texts:
I have a view with multiple taxonomy filters.  I need to have it set up so that when a certain term is chosen I need certain nodes to show up on top. Because of this I can't just simply use Sticky!

I'm thinking I will need to write something custom or perhaps use in addition to EntityQueue.


texts:
when a create a news content (exple article) I got this error:

Notice: Undefined index: und in include() (line 4 of /var/www/vhosts/elantechnology-bf.com/wapoparc/sites/all/themes/goodnex/templates/node/node--view--popular-posts--block.tpl.php).
Notice: Undefined index: und in include() (line 4 of /var/www/vhosts/elantechnology-bf.com/wapoparc/sites/all/themes/goodnex/templates/node/node--view--popular-posts--block.tpl.php).

I need your help to fix this


texts: AJAX form - replacing #default_value not working

texts:
I have an AJAX form. I want to update the text of a textfield when a button is triggered. But this does not work. My form is below:

<?php
function my_form($form, &$form_state) {
  $form['ask_first_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Ask me my first name'),
    '#default_value' => 'I LOVE chickens',
    '#prefix' => '
',
    '#suffix' => '
',
  );
  $form['update'] = array(
    '#type' => 'button',
    '#value' => t('Update'),
    '#ajax' => array(
      'callback' => 'ajax_example_autotextfields_callback',
      'wrapper' => 'textfields',
      'effect' => 'fade',
    ),
  );

  // shouldn't this update the default value when the button is pressed??
  if (isset($form_state['values'])) {
    $form['ask_first_name']['#default_value'] = 'I HATE chickens';
  }

  return $form;
}
?>

When I press the 'update' button I'm expecting the field text to change, but it doesn't. If I use #value instead of #default_value it works, but I know I shouldn't use that because I still want the user to be able to change it again.

<?php
// using #value works - but should I use that?
$form['ask_first_name']['#value'] = 'I HATE chickens';
?>

What is the recommended Drupal way to change the field value after AJAX is triggered?

NOTE: This answer solved the problem in my case, but as mentioned in the comments there is not access to the values in $form_state['values'] after submit. However, I'm storing the data in $form_state['storage'] so I can still access the data, though I'll probably implement ctools object cache in the end.


texts: Add a view with a contextual filter not on a node/taxonomy page

texts:
Druapl 7 - I have a taxonomy vocabulary called ‘Destinations’ and an entity created called “accommodation”. The accommodation entity contains names of individual accommodations, to simplify, let’s use hotels. So:

Entity type: accommodation

Hotel X - San Diego
Hotel Y - Barcelona
Hotel Z - Rome

What I want to do is create pages that show which accommodation is available in which city. So I need to create a page for each:

/san-diego/accommodation
/barcelona/accommodation
/rome/accommodation

I can do this by adding a custom page:

/admin/structure/pages/add

I have created a view but can’t quite get my head around how to use contextual filters and relationship to show only the hotels available at each accommodation page.

How will Drupal “know” that this page should show hotels in San Diego:

/san-diego/accommodation

I understand contextual filters and relationships and use them all the time, but can’t figure out how to do this in the case.

What is the best way to create these pages and add the view?


texts: Hide authoring information programmatically in a content type

texts: How do I programmatically hide the Authored by part in a content type using hooks?


texts: Panelizer settings page not found for OG group node

texts:
I have a site with several content types, all of which are OG content except one type, Group, which is a group.

I also have Panelizer and Panels Everywhere enabled. When I go to edit the default Panelizer settings for each content type, I have no problem doing so, except when the node type is Group. I can turn on Panelizer for Groups but then when I go to set the default settings for individual view modes, I get a "page not found" error.

I've cleared caches, rebuilt the registry, and even reinstalled Drupal, to no avail.


texts: Drupal taxonomy module -- too limited in the identification of Tid based on URL?

texts:
I have installed Path Breadcrumb module. It works well for simple settings, but when I try to make something more complex, I am at a lost. I have configured a path of this kind: node/125/%brand/%model

It works correctly for simple cases. But when either the term brand or model contains spaces (%20/), dashes or special characters, it does not work at all. That is because I use Term name for identification of the taxonomy term. If I use Nid, it does not work, as the URL is of the kind: node/125/FabCar/ModelA and not node/125/20/56, for example.

I was suggested some time ago to use Path Alias, and convert a URL of the kind node/125/20/56 in node/125/FabCar/ModelA, but there are thousands of data, they are updated weekly and even daily, and maintaining all the paths is crazy, so I generate the URLs dinamically, showing 404 if the query in the database yields no results.

All this could be solved if I could look for a taxonomy term by another field, let's say "description", and there I could write the URL-friendly path of the taxonomy. In that way node/125/FabCar/ModelA could be unambigously identified. The name of the term could be Fabricated Car Ltd., and the "description" or another field "FabCar", and I could use this field for the URL path.

How can I circumvent this limitation?


texts: Create additional menu page for node that can be accessed by the nodes' alias with /page?

texts:
I created a block using hook_block_view() and hook_block_info(), then set-up the page with hook_menu() using page arguments but this seems to only work for node/id/page?

This is what I have right now:

$items['node/%node/text'] = array(
    'page callback' = 'my_module_function',
    'page arguments' = 'array(1)',
);

I need it to work for the nodes alias which might be article/node title/ or journal/node title/ - they are for two different content types. Going to just article/ or just journal/ shows a View page that displays all the articles or everything from the journal.

Currently whenever I try to go to:

  article/node title/page

the article/ Panel page is loaded. However disabling the panel for article/ then going to article/node title/page causes a Page not found error, so it seems it's something to do with my hook_menu() not registering the URL aliases of the nodes?

As node/node id/page works perfectly fine.

Edit: unsure how to reopen, see comments


texts: How to get CCK optionsfield value, if I have the key for that value?

texts:
I have a CCK select list where I defined key|value pairs.

When I execute a node_load for that node, I only get the key (in my case an integer) stored in Drupal.

How can I get the value of that key easily? Is there a Drupal function?

something like, cck_value('field_name',$key) ?


texts: When should I use the private file system instead of public file system?

texts:
I try to build a social network on Drupal 8 currently.

And now I have to decide, which files (e.g. user pictures, uploaded user files) should be handled as private files and which as public files.

As far as I know, the public file dir listing is deactivated by Drupal generated .htaccess and it returns a 403 server error. The file is only accessible if you know the exact URL.

The private file system sometimes is buggy (e.g. default user pictures) and doesn't it bloat the database with aliases?
If I want to grab e.g. a picture from the site which is saved in private file system, but shown as content of a view or a node field, I can simply right click on it, and despite private file structure I can save it locally.
So, back to question, when does it make sense to use private file system?


texts: Change language programmatically after login

texts:
I have a multilingual site and I want to change the language programmatically after user login to his own language to see all the content in his language.

How can I do this?


texts: Is there a module for limiting CCK select list options per role?

texts:
I notice we can define a custom php list for options widget in CCK.

Would love to limit allowed values per role?

What would be the easiest way?

Such a solution could replace a lot of other modules, like Workflow etc...


texts:
I'm looking at putting together a Drupal 7 installation for a community website. One of the features of the website will actually be in specific user profiles, which will double as "About" pages in a catalogue of team members. Anyway, the site is currently designed in such a way that a user has a detailed photo on their page. I'm looking at one of two different options, and would like some input as to how best to carry out this task.

After a user uploads a profile picture (with the ImageStyle profile_picture) , have the system create a duplicate photo for the forum avatar based on what was just uploaded, only resize and crop the photo to be 200x200 pixels, and have the duplicate be named under the image style forum_avatar.
Provide an additional upload form for avatars in the user configuration settings with Drupal 7.

Obviously, the first one would take a little bit of doing, but I'm really curious: what would be the best way to carry out one of these two processes?


texts: Database object syntax for where conditions giving error

texts:
I am trying to convert the following SQL query in calls to the database API.

SELECT p.id, p.message,t.posted, p.posted AS reply_date,p.poster_id,t.id,t.subject, t.forum_id FROM punbb.punbb_posts AS p JOIN punbb.punbb_topics AS t ON p.topic_id = t.id WHERE p.id = t.first_post_id;

What I get is the following code.

$query = db_select('punbb_posts', 'p')
  ->fields('p', array('id', 'message', 'posted', 'poster_id'));
$query->join('punbb_topics', 't', 'p.topic_id = t.id');
$query->addField('t', 'posted');
$query->addField('t', 'id');
$query->addField('t', 'subject');
$query->addField('t', 'forum_id');
$query->addField('t', 'first_post_id');
$query->condition('t.first_post_id','p.id');

The code generates the following SQL query.

    SELECT p.id AS id, p.message AS message, p.posted AS posted, p.poster_id AS poster_id, t.posted AS t_posted, t.id AS t_id, t.subject AS subject, t.forum_id AS forum_id, t.first_post_id AS first_post_id
FROM
{punbb_posts} p
INNER JOIN {punbb_topics} t ON p.topic_id = t.id
WHERE  (t.first_post_id = :db_condition_placeholder_0)

Why can't I get "PID"?


texts: Drupal 8 Blog Autoposting To Facebook, Twitter, LinkedIn etc

texts:
I'm deciding what technology to use to build a social website. One of the features I'd like is autoposting to Facebook, Twitter, Linkedin, Youtube etc from a blog.

Joomla has a component called easyblog - http://stackideas.com/easyblog. I was wondering if there is anything similar for Drupal?

Normally I build basic websites with Joomla and more complicated things with Drupal 7 but with 8 out would ideally like to have used that.

Kind regards and many thanks for your time it is appreciated.


texts:
I want to add the banner image from the Admin page. The banner is slider. The slider contains text, Read more link and Images.

These three options user have to add from the admin page. The slider appears only in the home page.

Is there any plugin or Content type is advisable.


texts: When would tags be stripped out of a template?

texts:
I've got a custom module in Drupal 8 that's putting out an XML feed. The structure of each item in the template that makes the feed looks like this:

<item>
<title><[[CDATA[{{ node.title|raw }}]]></title>
<category>{{ node.terms }}</category>
<description><[[CDATA[{{ node.body }}]]></description>
</item>

When I look at the feed, I see the CDATA enclosure on the title, but I don't see it on the description, just the text contents of the body.

Somehow, the site is searching for feeds that use the word "description", and then stripping the tags out of them, at the twig template level.

This is all very confusing for me, as this worked properly a week or two ago, and now CDATA has mysteriously vanished from all the feeds.

Here's been my debugging process so far:
 1. Turned on Twig Debug mode, saw the correct template was loading, saw there was no field level template overriding the description portion. Also, in twig debug mode, the CDATA enclosure does appear normally, and vanishes again when I turn off debug mode.
 2. If I change the enclosure name from description to "descriptiona" suddenly, the CDATA enclosure appears as normal
 3. I made sure to clear the cache after each test and change.
 4. Breaking the CDATA code by removing the closing > causes the rest of the characters in the CDATA enclosure to appear normally.
 5. Adding  to the front and  to the back of the line in the feed template causes the  and  to also disappear along with the CDATA parts, which shows that I'm seeing an across the board twig-level strip tags effect of some kind.
 6. I changed the theme of the site to see if a theme function was causing it, but I saw no change on the feeds.
 7. I noticed it's not only the "description" enclosure that's flagged but also "media:description". Other variants of description seem unaffected.
 8. I tried moving the CDATA code from the template into the data where I build the node.body string, but regardless the CATA portion was removed from the code on output.
 9. I put a second CDATA wrapper around the first, this just resulted in an error.
 10. I swapped the data part, so I had node.title output twice, just in case it was a content error. No effect other than now I had the title showing twice, once with CDATA in it's own correct title enclosure and one incorrect without CDATA in the description enclosure.

I'm a bit at my wits end with this. Any thoughts on how or where Drupal would even be re-writing portions of a Twig Template? I've looked through my custom modules over and over, and all I see is the manipulation of data. Nothing template overriding that I can tell. Definitely nothing that's targeting the word "description".


texts: How to add phone number field with extension to webform component

texts:
Theme:
Bootstrap subtheme
Modules:
https://www.drupal.org/project/webform_bt_layout,
https://www.drupal.org/project/webform,
https://www.drupal.org/project/phone,
https://www.drupal.org/project/webform_phone.
Steps:
Enter 'Phone No' in component field.
Selected 'Phone Number' as   field type.
Clicked 'Add'
Country was selected as 'US/Canada' (I am accepting only US/Canada 10 digits)
Separator field has dash(-)
Problem:
When I visit my form, I see a one field which allows to enter more than 10 digits.
How can I make sure I can enter 10 digits numbers (separated with dashes) with upto 4 digits extension?


texts: How to redirect a user to the current page?

texts:
How can I redirect user to the current page using Drupal\Core\Link?

I am creating a breadcrumb where I want to redirect user to the current page


texts: Can Rules create a node reference that is empty except for a title?

texts: Is it possible to automatically create a reference node or entity with Rules? The idea is to have a node with information and an image Gallery reference. If the image gallery is clicked on the node view then it just shows the images with a link back to the original node. This way the original node can have one author while several different users can add photos. There isn't a need to populate the gallery on the original node creation since it will be an obvious second step view the node to add images or wait till later. I just think that it would make sense to have it available from the beginning even when empty.


texts: How to restrict access to a non-drupal url on a site's domain?

texts: So, I've just run into this issue with a drupal 7 site that I am maintaining. Access to the mailing list URL www.XXXmysite.com/mailman/listinfo is accessible to the general public. Is there someway of restricting access to this URL through drupal's permissions? This isn't obvious how to do because the mailman program isn't a part of drupal, I'm not sure where the program actually runs from, but the url is mapped from the site's domain.


texts:
I am having difficulty creating a rule to completely remove items from a Shopping cart.
I have tried Before adding a product to the cart

{ "rules_prevent_salon_professional_xover" : {
    "LABEL" : "Prevent Salon professional xover",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "-18",
    "OWNER" : "rules",
    "TAGS" : [ "staffmy" ],
    "REQUIRES" : [ "rules", "commerce_order", "commerce_cart" ],
    "ON" : { "commerce_cart_product_prepare" : [] },
    "IF" : [
      { "data_is" : {
          "data" : [ "commerce-product" ],
          "op" : "IN",
          "value" : { "value" : [ "97", "98", "99", "100" ] }
        }
      },
      { "AND" : [] },
      { "data_is" : { "data" : [ "site:current-user:roles:5" ], "value" : "5" } },
      { "AND" : [
          { "NOT data_is" : { "data" : [ "site:current-user:roles:0" ], "value" : "1" } },
          { "OR" : [] },
          { "NOT data_is" : { "data" : [ "site:current-user:roles:4" ], "value" : "4" } }
        ]
      }
    ],
    "DO" : [
      { "commerce_order_update_state" : { "commerce_order" : [ "commerce_order" ], "order_state" : "canceled" } }
    ]
  }
}

as well as After adding a product to the cart

{ "rules_prevent_professional_subscription_purchase_cross_over" : {
    "LABEL" : "Prevent Salon professional subscription purchase cross-over",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "-18",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "TAGS" : [ "staffmy" ],
    "REQUIRES" : [ "inline_conditions", "rules", "commerce_order", "commerce_cart" ],
    "ON" : { "commerce_cart_product_add" : [] },
    "IF" : [
      { "commerce_product_contains_products" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "sku" : "salon-owner-monthly , salon-owner-3month , salon-owner-6month, salon-owner-yearly "
        }
      },
      { "AND" : [] },
      { "data_is" : { "data" : [ "site:current-user:roles:5" ], "value" : "5" } },
      { "AND" : [
          { "NOT data_is" : { "data" : [ "site:current-user:roles:0" ], "value" : "1" } },
          { "OR" : [] },
          { "NOT data_is" : { "data" : [ "site:current-user:roles:4" ], "value" : "4" } }
        ]
      }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "commerce-line-item:commerce-unit-price:amount" ] } },
      { "commerce_order_update_state" : { "commerce_order" : [ "commerce_order" ], "order_state" : "canceled" } }
    ]
  }
}

I tried modifying it, by Removing entity - but still have a product in the Shopping cart

{ "rules_prevent_salon_professional_xover" : {
    "LABEL" : "Prevent Salon professional xover",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "-10",
    "OWNER" : "rules",
    "TAGS" : [ "staffmy" ],
    "REQUIRES" : [ "rules", "commerce_order", "commerce_cart" ],
    "ON" : { "commerce_cart_product_prepare" : [], "commerce_cart_product_add" : [] },
    "IF" : [
      { "data_is" : {
          "data" : [ "commerce-product" ],
          "op" : "IN",
          "value" : { "value" : [ "97", "98", "99", "100" ] }
        }
      },
      { "AND" : [] },
      { "data_is" : { "data" : [ "site:current-user:roles:5" ], "value" : "5" } },
      { "AND" : [
          { "NOT data_is" : { "data" : [ "site:current-user:roles:0" ], "value" : "1" } },
          { "OR" : [] },
          { "NOT data_is" : { "data" : [ "site:current-user:roles:4" ], "value" : "4" } }
        ]
      }
    ],
    "DO" : [
      { "commerce_order_update_state" : { "commerce_order" : [ "commerce_order" ], "order_state" : "canceled" } },
      { "entity_delete" : { "data" : [ "site:current-cart-order" ] } }
    ]
  }
}

This Rule does prevent the role from being added to the user, but the product and its normal product price exists in Shopping cart on the Orders page.


texts: How to use entity id for new entity for another field and prevent saving twice?

texts:
I have an entity that has field called 'group'. This field serves as a way to tie multiple entities together(it is like a reference field but not exactly in the way core uses it). Basically the entities in the same group are all variants of each other so they are tightly related. The value is either the ID of the entity or id of entity that the entity is a variant of(so there is always some "root" entity that is a source for the variants).

Anyway, what I am trying to do is to have the value to equal to entity id as default behavior. New entity will get ID only after it is saved into the storage and so in order to get the ID I have to wait for save() method and do the logic AFTER the fact. Currently I am using postSave() method in the entity to manually update the field data table and save the entity id as a value for this field.

It is working just fine but since RC1 the Drupal core has some advanced caching in it I am affraid this can become a problem in the future. So I am wondering how should I approach this but prevent saving the entity twice in a row?


texts: I got problem with entity translation. I have three content types, all of them have the same settings,I can translate two content types, but when I translate third one, it changes content on the original language too. Is this problem with database or what? Thanks for answers


texts: Drupal7+Omega Theme: How to narrow the 20px gutter between columns in 960 grid?

texts: Is it possible to alter the allmighty 20px gutter in 960px grid especially when using with Drupal 7 Omega subtheme?


texts:
What should be the template for my block view if the url is

  block/manage/views/guides-block/configure?destination=node/9

I have tried block--block--9.tpl.php but does not work


texts: I want to create a content type in which one of the field is a list of all users in drupal.I know I can add a node reference field but that reference is showing only normal node view but not user view.Is there a way to add list of all users in a content type?


texts: View won't render any content/teaser, only shows fields

texts:
I'm having a couple of articles which I want to display in a view. So I've set up a new view and made the following setting there:

Format: Unordered List | [default settings]
Show: Content | Full Content

All other settings remain untouched as default.

In the views-preview it is displayed nicely, but the whole view doesn't show up on the page when browsing to the path.

I've also tried

Show: Content | Teaser
Show: Rendered entity | Full Content

with no luck.

Only if I set the view to

Show: Fields

the view is displayed.

The article node pages are being displayed without a problem.
I'm working with views for years now, and never had such a problem.
Any ideas where the problem is?

Thanks, Marc


texts:
I would like to be able to track how many clicks are done on Google adsense ads from each node of my site.
The purpose of doing so is to be able to do revenue sharing with the authors of each article that will be published.

This module may seem to be useful: http://drupal.org/project/adsense

Except that it says "Click Tracking: tries to track clicks on the displayed ads, usually failing to do so."

Are there any alternatives?

Thanks in advance for your answers.


texts: How to update custom content type fields value in bulk?

texts: Is their any way to provide the bulk edit in the custom content type fields values by csv or in bulk.?


texts:
Noticed the following tag being used on Drupal.org: ciandt-contrib. Either I'm completely missing something but I can't figure out what the ciandtabbreviation stands for. And when it should be used.

Is there perhaps also a list that explains more of those abstract issue tags?


texts: How to use a custom template for a custom view in Drupal 7?

texts:
I'm working with panels and views. I'm trying to understand how to create a  view and also create a custom template for that view. I'm able to create the view through the Drupal admin and also create the demo.tpl.twig template (using twig, rather than php for templating), but not sure how to tell Drupal to use a specific template for my view.

Any and all help is appreciated. Thanks.


texts: How can I add custom classes to each view's generated row?

texts:
Is it possible by using the theme preprocessor add some classes to views generated rows?

For example: based on Drupal site about default theme implementation to display a view of unformatted rows.views-view-unformatted.html.twig:

  Available variables:
  - title: The title of this group of rows. May be empty.
  - rows: A list of the view's row items.
  - attributes: The row's HTML attributes.
  - content: The row's content.
  - view: The view object.
  - default_row_class: A flag indicating whether default classes
     should be used on rows.

I know that it's possible and we can add our desired classes to each row inside the views-view-unformatted.html.twig:

{% if title %}
  <h3>{{ title }}</h3>
{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  <div{{ row.attributes.addClass(row_classes) }}>
    {{ row.content }}
  </div>
{% endfor %}

But I want to understand is it possible to do the same thing for custom views like front-page by use of:function template_preprocess_views_view_unformatted__frontpage in particularor in other template_preprocess_views_view generally?


texts:
After validate with javascript that I'll be able to use the client location:

if (navigator.geolocation) {
...

I need to load the content of a view block with arguments (based in the position coords). I know how to obtain the HTML that I want to put inside the div, so at least I have this part.

I tried to follow the Simple Drupal AJAX load with jQuery and delivery callback article (that is write for Drupal 7 very different from Drupal 8) but I just arrived to load a page in a div (with headers and footer very far from my real objetive).

jQuery('#my-div').load('/admin/help');

Any ideas on how to load content in a div with ajax?


texts: Can't get custom content type page template to load

texts:
I'm running Drupal 7, and working with the Zen theme. I'm pretty sure I created a child-theme of Zen. My file structure looks like sites/all/themes/mytheme, with the original zen being located in sites/all/themes/zen. Not sure if any of that matters.

Anyway, I've created a custom content type and now I'd like to style the page differently (not just the node, but the entire page).

I've copied my page.tpl.php file and renamed it page-mycustomcontenttypename.tpl.php. This file is located in the same directory as my page.tpl.php file, which is sites/all/themes/mytheme/templates.

I then added the following code to template.php, which is in my theme's root folder:

<?php
/**
* Add / modify variables before the page renders.
*/
function phptemplate_preprocess_page(&$vars) {

// custom content type page template
  // Renders a new page template to the list of templates used if it exists
  if (isset($vars['node'])) {
    // This code looks for any page-custom_content_type.tpl.php page
    $vars['template_files'][] = 'page-'. str_replace('_', '-', $vars['node']->type);
  }
}

I then clear my site cache, but the changes I make to the custom template don't show up.

There's about a million places I could make a misstep here, so I'm not sure where to start? Any help is appreciated!


texts: How do I PUT update on a node using services 3

texts:
I have a node with field_order_status field(not required) in list(text) type and radio button widget and I want to update a node(nid:95) but my sample JSON PUT content(application/json) throws Status 406 Error:

{"form_errors":{"field_order_status][und":"An illegal choice has been detected. Please contact the site administrator."}}

my content is:

{
  "field_order_status":{
    "und":[
      {
        "value": "1"
      }
    ]
  }
}

sample url:

http://localhost/caesarschickencms/createorder/node/95

Services 3.4, Drupal 7.22

Notes:
When I tried replacing und with other values like 'en', it accepts but not updates, refer to drupal 7 + services 3 - inserting nodes with select fields

And Devel page vars dump:

What would be missing?


texts: For the purposes of the Cycle plugin I need to render a node without any external buildup, just the $content. Is that possible?


texts:
I would like to open a jquery dialog that asks a question before taking the user to the desired page (ie do some page set-up before they get there). The catch here is that I would like to open the dialog when the user clicks the menu item. I am not sure how to go about this. Could someone point me to some examples where this is done or what I need to do? I am using Drupal 7.

Thanks.


texts:
I am working on an English/Arabic website, the user can switch between the two languages using the language switch block, I wanted to translate the email sent to the user after registration. So after some digging, I figured out I could do this using the account setting (translate tab), I added the Arabic translation of the email; then, after testing, I found out that the registration email is still sent in English.

Shouldn't a user registered in the Arabic language get an Arabic registration email?

I also found out that the user's preferred language is English, even after registering in the Arabic language.

These are my language detection settings.


texts:
I need your help for the following things:

1.i have a content type called "discussion-topics",Discussion-board is the view  created for this Content type.I want to show   create new content link in the view list page .

It is a discussion board page and an authenticated user can only create the new entry to this board.

Do we have any option to show create new link in View settings ?Please reply me.

thanks in advance.


texts: How to hide user picture based on the value of a field in their profile

texts:
This last bug is the only thing between be and launching this site.  Please help!

I have a field called publish photo? that is a checkbox in the user's profile.  For users with this box unchecked, I would like to hide the user picture for users that are not logged in. I would like it to be hidden everywhere, in a display suite view and in the views view.  I had the following in my template.php, which I could have sworn was working, back before I added on display suite, but it seems not to be working now.

function MYMODULE_preprocess_user_picture(&$variables) {
    if ((!isset($variables['account']->field_user_publish_photo) || $variables['account']->field_user_publish_photo[LANGUAGE_NONE][0]['value'] == '0') && $variables['logged_in'] != 1) { // hide user photo when Publish photo is turned off
        $variables['user_picture'] = '';
    }
}

What is the proper way to do this?


texts: How to create a view displaying a list of users who have logged-in user's preferences

texts:
How does one create a view that filters users so as to display those with preferences of the logged-in user (the one viewing them)? I'm using Drupal 7.34, Views 3.

E.g. A user selects a preference on sign up, such as "i'm interested in a man". How do you create a view that will show this user a list of users who selected "I'm a man" on their own signups. Think of it as matchmaking.

I came across this discussion but didnt figure out this comment. All the articles out there don't seem to address this clearly.

I'm certain there is a contextual filter move I'm missing. Please help.


texts: How do you allow users to create own menus?

texts:
The idea is that a user should be able to create a menu to structure his uploaded content. How would you go about making this possible without giving the user access to edit other users menus?

Cheers,


texts: Using Drupal to authenticate user on a remote web site

texts:
I have a custom php web site on which I need to authenticate users based on their credentials in a Drupal site.  I am not very experienced with Drupal but am (mostly) finding my way.  It is a Drupal 7 site.

I have found that I need the Services, Rest Server and Libraries module and they are all installed.  I am using this tutorial for setting up Drupal:
https://www.drupal.org/node/2424977

and this code for my remote site:
Using drupal login system for another platform

I am stuck on the tutorial where I am trying to get a user token from the Drupal site.  I have set up an endpoint ("rest", and when I go to it in a browser I get:
"Services Endpoint "remotetest" has been setup successfully."
However in the Firefox RESTClient when I try to post to https://sub.domain.org/rest/user/login.json I get:

Status Code: 404 Not found : Could not find resource user.
Cache-Control: no-cache, must-revalidate
Connection: Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Wed, 08 Nov 2017 18:55:24 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.18 (Ubuntu)
X-Content-Type-Options: nosniff

I have tried a few things like enabling Drupal permissions for the Services module for anonymous users (all items except manage Services) but don't know what else to do. I have also tried the login directly (why would I need a token?) but I get an error "The requested URL returned error: 404 Not found : Could not find resource user." It seems like steps are missing in the tutorial.

Suggestions?


texts:
I'm building a TV listing and I'm using quicktabs module with tabs:

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Every tab shows a node that have a TV listing.

Is it possible these tabs to be shown by date/day?

Example: today is Monday, so when a user enters the page for TV schedule the active tab will be Monday.

I've inspected the tab links and I find out that every tab has additional link to the main URL.

Example: The first tab (in mine case - Monday) has /program?qt-quicktabs_tv_schedule=0#qt-quicktabs_tv_schedule

The second tab (in my case - Tuesday) has /program?qt-quicktabs_tv_schedule=1#qt-quicktabs_tv_schedule

etc.

EDIT:

I've tried this code:

(function($){

$(document).ready(function(){
var d = new Date();
var n = d.getDay();
$(".quicktabs-tabs li").removeClass('active');
$('#quicktabs-tab-quicktabs_tv_schedule-0' + n).parent().addClass('active');

});
})(jQuery);

The removing active class is working, but the days changing based on

var d = new Date();
var n = d.getDay();

it's not working. Maybe I'm missing something...

EDIT 2:

Here's what I've tried:

     (function($){

        $(document).ready(function(){
        var d = new Date();
        var n = d.getDay()-1;
        if ( n == -1) {
        n = 6;
        };

        $(".quicktabs-tabs li").removeClass('active');
        $('#quicktabs-tab-quicktabs_tv_schedule' + n).parent().addClass('active');
        $('.quicktabs-tabpage').addClass('quicktabs-hide');
        $('#quicktabs-tab-page-id-' + n).removeClass('quicktabs-hide');

        });

})(jQuery);

With this code it simply hides the default tab.


texts:
I can't figure out what I am doing wrong, as my block isn't showing up with the content from the taxonomy.
I am trying to create a block that shows the content based on the taxonomy; I made a path on the taxonomy, and the main content shows up, but when I try to add a block using Views, it never shows.

This is the settings page for the taxonomy.

This is the view I am using with the argument.

Edit: I fixed the issue; all I had to do was create a new content and it worked. I guess my only question now is how to keep the block on the front page after adding the filter.


texts: How to check if entity's property has a value

texts:
How can I check if entity's property has a value? I don't think this is the "drupal way" to check it like this

$page_optimization->title->value() !== ''

Is there any method, something like $page_optimization->title->hasValue() etc.


texts: Unable to save storage class for styled images

texts: I'm unable to save the storage class for the selected image style (Storage API). I'm getting timed out from the server. I'm not sure what it is trying to do. Any help is really appreciated. Thanks.


texts: how to create two or more view with in a single view

texts: I want to create a view which outputs as page . Within that view ,i need to create two or more views they will react based on the arguments to their parent view


texts: How to display the user registration or profile field on the search page?

texts: How can I render/display user profile or registration field on search result page (user search)?


texts: change image size in media file selector of media module

texts:
how can I change the size of the image that show in media file selector popup in media module
, I don't know which image style this module use, and how can I change the image style which is currently used or active.


texts: Populate $form_state['values'] with defaults from drupal_get_form()

texts: I'm looking to resave a form's defaults values. In core the test module uses drupalPost() to test the form so I'm thinking this will be custom code.


texts: Missing the message status when saving Node

texts:
Of the handful of content types on our site, some of them don't display the message status (ex. Article Test has been created) when the node is saved.

Where can I investigate the cause?


texts:
if this is my function:

<?php
//dsm($query);

function customstatsB_menu() {
  $items['customstatsB'] = array(
    'title' => 'Maestros Inactivos + email',
    'page callback' => 'customstatsB_all',
    'access arguments' => array('access customstatsB content'),
    'type' => MENU_CALLBACK
  );
  return $items;
}
/**
* Valid permissions for this module
* @return array An array of valid permissions for the customstats module
 * No repetir permisos, este es únicamente un modulo, y cada query NO necesita permisos. PERMISOS A NIVEL MODULE x ROL.
 */

function customstatsB_perm() {
  return array('access customstatsB content');
} // function customstats_perm()

//return array('access customstats content', 'administer customstats');

function customstatsB_all() {

/**
 * MAESTROS INACTIVOS
 */

$query = "
SELECT name, status, rid, mail
FROM users
JOIN users_roles ON users.uid = users_roles.uid
WHERE mail NOT LIKE '%@hotmail.com'
AND users_roles.rid =6
AND users.status =0
";

  // get the links (no range limit here)
  $queryResult =  db_query($query);
  while ($links = db_fetch_object($queryResult)) {
    //$page_content .= l($links->name, 'node/'.$links->mail) . '
';
    $page_content .=
    l($links->name, 'mailto:'.$links->mail) . '
';
  }

  // check to see if there was any content before
  // returning the page
  if ($page_content == '') {
    // let the user know there is no content to show
    $page_content = "No existe información para mostrar.";
  }

  return $page_content;
}

return array('access customstatsB content', 'administer customstatsB');

/**
 * Email configs
 */

function customstatsB_mail($key, &$message, $params)
  {
     $params = array(
        'subject' => t('SQL Results Tester'),
        'body' => t("Body of the email goes here"),
      );

      drupal_mail("customstatsB", "customstatsB_normal_mail", "my@mail.net", language_default(), $params, "admin@mysite.com");
      drupal_mail("customstatsB", "customstatsB_html_mail", "my@mail.net", language_default(), $params, "admin@mysite.com");
  }
      $language = $message['language'];
      switch ($key)
      {
           case 'customstats_normal_mail':
              $message['subject'] = t($params['subject'], $var, $language->language);
              $message['body'][] = $params['body'];
              break;
          case 'customstats_html_mail':

              $message['subject'] = t($params['subject'], $var, $language->language);

               $body = "

HTML Email Sample with Drupal

                  {$params['body']}
                  ";
              $message['body'][] = $body;
              $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
              break;
      }
  }

and I am using hook_mail and drupal_mail to send an email, how should I insert the query results into the body of the mail?

Also, I have created pagecallbacks customstats1 to customstats15 via hook_menu and I need to send indivual mails when users visit each page independently. I have read a few tutorials but I haven't been able to do this.

Thanks in advance for your help.


texts: using $_POST values in form alter to add validation

texts:
it's not the first time that i get into trouble using $_post in a node form alter, this time i'd like some assistance.

basically, i need to pass some parameters to a form (and i should not pass the appended to the url, as query parameters). but $_POST values don't work as expected (they work until reaching validation phase).

So.. in a page i pass as hidden value

<form method="post" action="/node/add/">
    <input type="hidden" name="mydesideredParameter" value="itsValue">
</form>

In the form_alter function of this form, at the very beginning, i try to assign this value to $form_state (and it works, I watchdog it later and it's correct)

if (array_key_exists('mydesideredParameter', $_POST)) {
    $form_state['mydesiredConsequence'] = 'dance';
}

Later, inside form_alter, at the very end, i state:

if ($form_state['mydesiredConsequence'] === 'dance'){
    $form['#validate'][] = 'myDancingFunction';
};

No complains happen on form building, but when trying to submit the form, the validation funcion doesn't get called and php complains about index that doesn't exist no more

Notice: Undefined index mydesiredConsequence

Nothing similar happens when i use this step and the values are in the url(via drupal_query_parameters) , but trying to make this work in $_POST seems a bit awkward. (i obviusly can imagine that the second form-rebuilding ignores $_POST, as it was a former request; but that should be the intended purpose of assigning the value to $form_state).


texts: Export a specific non-default database using drush sql-dump

texts:
My Drupal 7 site connects to multiple databases using a $databases array like this:

$databases = [
  'default' => [
    'default' => [
      'database' => 'examplecom',
      'username' => 'example',
      'password' => 'sostrongpassword',
      'host' => '',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ],
  ],
  'nondefault' => [
    'default' => [
      'database' => 'notdefaultdb',
      'username' => 'notdefaultuser',
      'password' => 'notdefaultpass',
      'host' => '',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ],
  ],
];

Ideally I want to be able to do something like drush --database-key=nondefault sql-dump > myfile.sql but I don't see a way in drush to do that. Is it possible?

I tried creating a custom script to do this like:

drush_sql_bootstrap_further();
db_set_active('nondefault');
$sql = drush_sql_get_class();
return $sql->connect(FALSE);

And then calling that script with drush scr foo.php but the sql connect (or any other command) seem to work against the default database.


texts:
I have a lot of trouble with the WSOD and have looked around quite few posts; like WSOD with Devel module and How to see the error messages when I get the white screen of death? as well as https://www.drupal.org/node/1692262

After reading the posts the best thing to do was to uninstall the the devel module, once i did that the WSOD is gone, but what if you need the devel module?

I'm struggling to get the errors up and work out where i have gone wrong. Doesn't Krumo need devel?


texts: I am wondering what is the best way to preserve viewing certain url patterns in forum posts only for authenticated users? So that guests can see something like "please log in to view the link", as per most stand-alone forums?


texts: Is site safe after a failed module installation?

texts:
I was working on a site this morning, and I enabled a whole bunch of modules at the same time.  One of the modules threw a PDO exception during the process.

What state is the site in at this point?  Assuming the site still loads after the error, is it safe to use, or should I restore from a backup?

For the sake of this question, I am not concerned about the actual error or the module that threw the error (I would report this in the issue queue).  I am concerned about the general state of the site, and what may have happened to the installations of the other modules.

To make this more concrete, let's say I tried to enable ModuleA, ModuleB, ModuleC, and ModuleD.  After I clicked SUBMIT on the module page, ModuleC threw an uncaught PDO Exception and I didn't get the normal module enabled message.  Now, lets say that I can live without ModuleC on the site.  What can be said about the state of hpw the installation went for ModuleA, ModuleB, and ModuleD, and also dor Drupal in general?


texts: How to get the node id the comment is attached to in hook_comment_insert?

texts:
How can I get the node id the comment is attached to in hook_comment_insert?

I tried the following code:

function mymodule_comment_insert(Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity->bundle() == 'comment_custom' && $entity->get('entity_type')->value == 'node') {

    // Below returns empty, because "$entity->get('entity_id')->value" is empty.
    $node = Node::load($entity->get('entity_id')->value);

    // No luck with this one too.
    $node = \Drupal::routeMatch()->getParameter('node');

  }
}


texts: How to call a function in a form from another form?

texts:
I have 2 forms: distribution_inscription_table_form and distribution_inscription_for_user_form in the same custom module (amap).

namespace Drupal\amap\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class DistributionInscriptionTableForm extends FormBase {
  public function getFormId() {
    return 'distribution_inscription_table_form';
  }
  public function buildForm(array $form, FormStateInterface $form_state) {
    some code...
    $rows = $this->_listEnrolments();
    some code...
    return $form;
  }
  public function _listEnrolments() {
    some code...
    return $rows;
  }
  public function validateForm(array &$form, FormStateInterface $form_state) {
    some code...
  }
  public function submitForm(array &$form, FormStateInterface $form_state) {
    some code...
  }
}

namespace Drupal\amap\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class DistributionInscriptionForUserForm extends FormBase {
  public function getFormId() {
    return 'distribution_inscription_for_user_form';
  }
  public function buildForm(array $form, FormStateInterface $form_state) {

    $rows = ????_listEnrolments(); <--------
    return $form;
  }
}

As they share a significant part of code; I put this code in a public function _listEnrolments located in the first form.
How can I call this function from the other form?


texts:
I have file tpl in drupal 7 like this:

<div class="<?php print $classes; ?>" <?php { print $attributes; } ?>>
    <?php
    $content_section = '
';
    foreach($columns as $key => $column) {
      $content_section .= render($column);
    }
    $content_section .='
';
    if(isset($customHTML)){
      $customHTML = str_replace('[content]', $content_section, $customHTML);
      print $customHTML;
    }
    else {
      print $content_section;
    }?>

I want convert two twig template. But i have problem with function render() and str_replace(). I know in twig have function replace. But don't know how to convert to twig.