texts:
I was hoping you could help me with this problem on my website.

I have a views page "News" for a long time now. (q?=news)
I also have 2 blocks that I want to show on that page. On the configurations I set: All pages except those listed - and I listed all the pages i don't want the block to show (So I didn't write the News page).

Thing is, this was working fine and suddendly the blocks stopped showing on that specific page, and I have no idea why.

Any thoughts?

Thank you in advance!

P.S. I can't just try the "Only the listed pages" option because there are too many pages involved.


texts: I want rules to create a new entity on a timed schedule in the middle of the night, when no when is on the .  My question is what do I use for "The author of the node"?


texts: optimal way to remove unwanted js and css files from page

texts:
I use drupal 6 and ubercart2. Loading of cart and checkout page takes a while so I am thinking about removing any js and css files which are not used on specific pages.
What would be the ideal way to do it? I know about js agregation but want to try the first approach.
Thank you very much.


texts:
What is the best way to arbitrary order nodequeues in a view?

Drupal 6.26
Nodequeue 2.11
Views 2.16


texts: Formatting my Link field with multiple values

texts:
I believe I have a way to do this, but as I'm learning I want to make sure I'm not doing it horribly wrong or reinventing a wheel that already exists (the module search on the Drupal site leaves a lot to be desired).

I've got a Link field with multiple values (just URLs). When this field is being rendered, I would like to sort of preprocess each of the URLs. If it's a youtube or vimeo link, I'd like to change it so that a video embed is rendered instead. If it's a link to an audio file (with certain extensions) then I want to render an html5 audio tag.  Else, I just want to render the link normally.

It looks like I could override mytheme_field__links__mycontenttype() (although I'm not exactly sure how to implement that method just yet, any examples are welcome).

It also looks like I could create a template in my theme named field--links--mycontenttype.tpl.php

Is this the right way to go?

Is one better than the other?

Do you have any links to a good example of how to implement/override these?

Thanks!


texts:
I'm using marinelli theme and the rotating images. Now, I'm looking to add usemap to some of the images, as the images are rotating images and are not within a specific node. Moreover, I'm adding the banners through admin->apperance->settings->marinelli->banner management. So, I couldn't add the usemap html tag within the body or some-other place as within blocks/nodes. I tried various ways to add but couldn't get any idea.

I have found some module jQuery Map Hilight, where i can add features to the usemap not really adding usemap to an image.

Is there any way to add usemap tag? Is there any way like adding some code in page.tpl.php?


texts: How get commerce order total(excl vat, exlusive dicount), vat price, discount price, order total(incl vat and discount) in rules?

texts:
I am creating a rule on event "When checkout process is completed".
I want to send an email to the user when order completes.
In the email I want to send the following information

Order total price Exclusive discount and VAT
VAT price
Discount price
Order total Inclusive discount and VAT

But I don't see any token for these values. Only for the order total inclusive vat is available.

How will I display these values?


texts: Drupal behind a SSL offloading reverse proxy -- is this config correct?

texts:
We are transitioning an existing drupal installation to run as a SSL-only site behind a SSL offloading proxy. Drupal itself has no SSL and is running on port 80 on apache.

We've got what we think is a pretty successful configuration:

On the nginx end of the world it looks like:

server {
    listen              80;
    server_name         staging.example.com;
    return              301 https://staging.example.com$request_uri;
}

server {
    listen                  443 ssl;
    server_name             staging.example.com;
    ssl_certificate         $chained_cert_path
    ssl_certificate_key     $private_key_path;

    location / {
        proxy_pass          http://$backend_ip;
        proxy_set_header    Host $host;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto $scheme;
        proxy_set_header    X-Forwarded-By $server_addr:$server_port;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_redirect      http:// https://;
    }
}

And in the drupal site's config we are running:

// reverse proxy settings and such
$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array($proxy_ip);
$base_url = 'https://staging.example.com';

As I said this seems to be passing all tests, but my spidey sense is saying this was too easy and there is a fugly problem waiting somewhere in some part of drupal we don't understand well enough -- manually paving $base_url just isn't sitting right with me. Are there landmines here?


texts: How to show message to user when page is in a filtered state?

texts:
I have a view with a few exposed filters and it uses ajax. It is set to remember their last selection. Is there any way to ensure that the user is aware the the view still has applied filters? (i.e. Some users may not be ware that the list is still filtered and they need to hit the reset button).

Edit

To further clarify:

The issue is that if the user is not aware that the list is in a filtered state that they should reset it before starting another drill down

Basically I need it to say "Hey you! this list is in a filtered state. You need to hit the reset button before doing another search!"


texts: Twitter sign in module session token values lost in twitter/oauth path in HTTPS - Invalid Twitter OAuth request

texts:
The twitter sign in module works on my local and staging server on HTTP fine. But when I install the same module in production mode which is https://example.com, it stops working. The error says "Invalid Twitter OAuth request". I debugged the code a little bit, and I could understand that the session variables stored in token before redirecting to twitter are lost when control is redirected to my site in twitter/oauth path.

/**
 * Submit handler for Twitter signin.
 */
function twitter_signin_redirect() {
  module_load_include('inc', 'twitter');
  $key = variable_get('twitter_consumer_key', '');
  $secret = variable_get('twitter_consumer_secret', '');
  $twitter = new Twitter($key, $secret);
  $token = $twitter->get_request_token();
  $_SESSION['twitter_oauth']['token'] = $token;
  $_SESSION['twitter_oauth']['destination'] = $_SERVER['HTTP_REFERER'];
  $_SESSION['twitter_oauth']['signin'] = TRUE;
  watchdog("twitter_sign_in", "Session Values Set => ". print_r($_SESSION, 1));
  drupal_goto($twitter->get_authenticate_url($token));
}

And on the validate function in twitter.pages.inc, the session values are clearly lost. I used watchdog entries on both functions. Its working fine in my local and staging server.

/**
 * Validate results from Twitter OAuth return request.
 */
function twitter_oauth_callback_form_validate($form, &$form_state) {
  global $twitter_token;
  $key = variable_get('twitter_consumer_key', '');
  $secret = variable_get('twitter_consumer_secret', '');
  watchdog("twitter_sign_in", "Session Values Set => ". print_r($_SESSION, 1));

if (isset($_SESSION['twitter_oauth'])) {
    $form_state['twitter_oauth'] = $_SESSION['twitter_oauth'];
    unset($_SESSION['twitter_oauth']);
  }
  else {
    form_set_error('oauth_token', 'Invalid Twitter OAuth request');
  }

Any help appreciated. Thanks.


texts:
I would like to filter views block content by taxonomy. I have multiple content types on same block, and only one of them has taxonomy. The goal is to output all the nodes from content types with no taxonomy, and from certain term if content type has taxonomy.

Shorter: If content type has taxonomy, filter by it.

And not to be too simple: taxonomy is hierarchical and I would like to it work so, that nodes in child taxonomy would also appear when filtering by parent.

I could of course filter all the other terms out, but the thing is that client can add terms by himself. Therefore limiting the terms out manually is not the best solution.

I am using Drupal 7.22 and Views 3.7.


texts:
I've only so far added 5 or so nodes to my site. I've noticed that not all nodes are coming up in the search results. What I mean is searching for their title doesn't find them :S
It works for some but not others. Why would this be the case>


texts:
I have a multilingual site. English and Dutch are the languages. I need to display date format in Dutch, ie  I need to display a timestamp in Dutch(nl), as 16 oktober 2017. Tried the below code and format_date(), but didn't do the trick.

$date = $node->getCreatedTime();
\Drupal::service('date.formatter')->format($date, 'custom', 'd F Y', $timezone = NULL, $langcode = 'nl'); //not working for me

format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = 'nl');

Above code returned date in "en" language. Am I missing something here.. Thanks..


texts:
I want my view to use Omega's grid system, but could not find a way to do it.

There is this thread http://drupal.org/node/1491678 that suggests using "Views Column Class" module. Is that the best way to do it or I am missing something?


texts: how to create views with month and day in contextual filter

texts:
Let suppose I have  actor content type, it has a birthday field (it is date ),
I want get all actor that has equal month and day of birth,I want to create a views with
birthsearch/%/%  path, and then I want pass  month and day to it ,
as exapmle birthsearch/02/25 , it should return all actor that birthday is 25 feb,I think contextual filter is good idea to achieve this but, by default drupal Granularity of date field  is

it is means I can restrict it to year and month, but I cant restrict it to day and month,

my question is how can I have views with month and day in contextual filter (passed to it by page Url)?


texts: Is it possible to make site_email an i18n variable?

texts:
We have multilingual site pointing to 2 domain according to site language.

  www.example.com (Swedish)

  www.other.com (English)

Now when some user post content from Swedish domain we want to send notification of content submission to user from info@example.com and if from English domain then from info@other.com

Is that possible ?

I have attempted like below in custom module whose weight is 1000:

function custom_overrides_init() {

  global $language;

  if($language->language == "sv"){
    variable_set('site_mail', "info@example.com");
  }else if($language->language == "en"){
    variable_set('site_mail', "info@other.com");
  }
}

When I see in maillog it shows correct from email addresse but its not working and use same email address which is set on site configuration.

i18n_variable also does not provide site_email as variable.

Please suggest !


texts: Can I force cron to process all of my queued tasks?

texts:
My D7 module uses hook_cron to mirror a big external datasource locally. For each new or updated row, $queue->createItem() schedules a task requiring several external API round trips to build the locally mirrored row.

I might queue 750 tasks but Drupal only runs 50 on a cron. How do I make all queued tasks run on each cron?

Please note:

There are no errors reported in /var/log/apache2/error.log
The latest message in admin/reports/dblog reports "Cron run completed." (looks successful)


texts:
Is there anyway for me to create a Drupal view from two sql queries and have two separate outputs. Here is the two SQL queries I want to create a view from:

SELECT f.delta      AS field_data_field_session_start_date_delta
     , f.entity_id  AS date_id_date_filter
     , f.delta      AS date_delta_date_filter
     , n.title      AS node_title
     , n.nid        AS nid
     , n.language   AS node_language
     , f.field_session_start_date_value AS field_data_field_session_start_date_field_session_start_date
     , f.field_session_start_date_value2 AS field_data_field_session_start_date_field_session_start_date2
     , 'node'       AS field_data_field_session_start_date_node_entity_type
  FROM node n
  JOIN field_data_field_session_start_date f
    ON f.entity_id = n.nid
   AND f.entity_type = 'node'
   AND f.deleted = '0'
   AND f.field_session_start_date_value >= NOW()
WHERE n.status = '1'
ORDER
    BY f.field_session_start_date_value ASC
LIMIT 3 OFFSET 0

SELECT f.delta      AS field_data_field_session_start_date_delta
     , f.entity_id  AS date_id_date_filter
     , f.delta      AS date_delta_date_filter
     , n.title      AS node_title
     , n.nid        AS nid
     , n.language   AS node_language
     , f.field_session_start_date_value AS field_data_field_session_start_date_field_session_start_date
     , f.field_session_start_date_value2 AS field_data_field_session_start_date_field_session_start_date2
     , 'node'       AS field_data_field_session_start_date_node_entity_type
  FROM node n
  JOIN field_data_field_session_start_date f
    ON f.entity_id = n.nid
   AND f.entity_type = 'node'
   AND f.deleted = '0'
   AND f.field_session_start_date_value <= NOW()
   AND f.field_session_start_date_value2 > NOW()
WHERE n.status = '1'
ORDER
    BY f.field_session_start_date_value ASC
LIMIT 3 OFFSET 0


texts: Move images from a image field to another field

texts:
Some months ago I developed a D8 based website for a customer with an image field with multiple values, displayed as a Bootstrap Basic Image Gallery.
Now, my customer has changed his mind so now he wants to set the possibility to insert either an image or a video, so I decided to use Paragraphs to let him choose if he wants an Image or an embed Video.
The problem is that the customer has over 1000 nodes with an average of 3-4 images per node, so if I change the field to a Paragraph one, the images previously saved in the Image field are not moving to the Paragraph field.
Is there a way to "migrate" the images from an Image field to a Paragraph referenced Image field?
P.S: As you may understand, re-uploading the images again might be, if I can say, a PITA


texts:
What is the purpose of sites.php and how does it relate to settings.php?

I have done a lot of web searches and looked at the comments in these files, but cannot find a simple explanation.


texts:
I want to add a banned words list to the site. and if a user used one of the banned word in node form (title and body), comment form (title and body), user username in the registration form, then the user should get an error message that you are using a banned word in your {field-name}.

And the form should not be submitted if the banned words are present.

How can I do this?

I have checked some modules like wordfilter but it does not provide the functionality for usernames and also it replaces the strings not giving the error message.


texts: User may edit their webform submissions, but only while in draft

texts:
I don't want users to be able to edit their webform submissions after they have been submitted (in this case it's an application form that needs to be reviewed).

The trouble is, they also need to be able to partially complete and return to it. If they've saved a draft, to continue, they have to access:

/webform/{webform}/submissions/{webform_submission}/edit

and with 'Update own webform submissions' disallowed (which you can do per webform, remember) that route is blocked.

I can't see anything obvious in the options for drafts (Settings > Submissions) yet I can't be the first person to have needed this…

Solution I've come up with so far:

enabling edit/update access for all users
adding a RouteSubscriber for entity.webform.user.submission.edit
loading the submission there, using ->isDraft() to check its status
denying access for false, depending on role/ownership

Any better ideas?

(NB: this doesn't involve anonymous users - they have to be registered and logged in.)


texts: Beginner Drush question. Can't get Drush to do anything!

texts:
I can't get Drush to do much.  I can connect to my site by typing cd and then dragging my files to the terminal window in OSX using Acquia DevDesktop. My overall goal is to create a sub theme of Omega.

When I type drush omega-wizard I get:

  The drush command 'omega-wizard' could not be found.  Run drush cache-clear drush to clear the commandfile cache if you have installed new extensions. [error]

  Drush was not able to start (bootstrap) the Drupal database.         [error]

  Hint: This may occur when Drush is trying to:

  bootstrap a site that has not been installed or does not have a
  configured database. In this case you can select another site with a
  working database setup by specifying the URI to use with the --uri
  parameter on the command line. See drush topic docs-aliases for
  details.
  connect the database through a socket. The socket file may be
  wrong or the php-cli may have no access to it in a jailed shell. See
  http://drupal.org/node/1428638 for details.

I think this means that I haven't shown Drush where the settings file is.  For the life of me, I'm not able to do that.  Normally, I would do something like:

cd sites/nameofsite.localhost

or

cd site/nameoffolder.localhost

I've tried every iteration of this command: with the localhost, without the localhost, different folder names, etc.  I always get "No such file or directory".  Can anyone tell me what I'm doing wrong?  What does Drush need me to tell it?

Thanks so much in advance,

Jason


texts:
i know how to theme pager on the whole site with a theme_pager().
But how to theme a certain pager in a view block?
By default pager shows ← 1, 2, 3, 4, 5, 6, 7, 8, 9...100 →

I need ← 1, 2, 3, 4, 5...100 →

How is that possible to theme pager just in one block not whole site?


texts: Error message for duplicate email for user registration

texts:
On my site, users sign up by submitting their email and name to a user registration form. They will get an email with a link that will allow them to complete the rest of the sign up process, like setting a password. The issue I am having is that when a new user signs up, two messages pop-up. The first message says that a link has been sent to their email with further instructions, which is what I want. However, The second message, which is hidden behind the first, says the email address is already taken. Once a user closes the first message they will see the second message. The second error message is misleading and I would like only the first error message to display when users sign up.
 if($path == '/user/login') {
    /***** user sign-up ******/
    $entity = \Drupal::entityManager()->getStorage('user')->create(array());

    $formObject = \Drupal::entityManager()->getFormObject('user', 'register')->setEntity($entity);

    $form = \Drupal::formBuilder()->getForm($formObject);
    $variables['register_form'] = $form;
}

The code above is how I am getting the registration form to display on page--user--login.html.twig (by calling register_form in the twig template). This is in the .theme file in the mytheme_preprocess hook.
The login/signup page path is /user/login. (so both the user registration form and user login form is on this page. Both have submit buttons)


texts: Drupal 7 - FAPI - Multistep form - with add another option

texts:
I'm creating a multistep form in Drupal 7 - FAPI.

In the main hook_form() the redirection to the different steps are handeled.

function hook_form($form, &$form_state) {
    if (empty($form_state['storage']['step'])) {
        $form_state['storage']['step'] = 0;
    }

    switch($form_state['storage']['step']) {
        case 0:
          $form=  _step_0($form, $form_state);
        break;
        case 1:
          $form =  _step_1($form, $form_state);
        break;
        case 2:
          $form =  _step_2($form, $form_state);
        break;
        case 3:
          $form =  _step_3($form, $form_state);
        break;
        case 99:
          $form =  _step_end($form, $form_state);
        break;
    }
    return $form;
}

function _step_2($form, &$form_state) {
    ....
    $form['Name'] = array(
        '#title' => t('Name'),
        '#type' => 'textfield',
        '#required' => TRUE,
        '#maxlength' => 80,
        '#size' => 80,
    );

        $form['Street'] = array(
        '#title' => t('Street'),
        '#type' => 'textfield',
        '#required' => TRUE,
        '#maxlength' => 80,
        '#size' => 80,
    );

    ......

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

    $form['add'] = array(
            '#type' => 'submit',
            '#value' => 'Collega toevoegen',
        );
}

In step 2 I have an optional button 'Add onther' which saves the form_values into storage and reloads the same form (step 2). But when it reloads this form for the seconds time. the previous form values are being represented as default form values and not a blank (new) form, which is wanted.

function inschrijven_form_submit($form, &$form_state) {
    switch ($form_state['storage']['step']) {

        case 0:
          switch($form_state['values']['op']) {
            case 'Next' :
              ....
              $form_state['storage']['step'] = 1;
            break;
          }
        break;

        case 1:
          switch($form_state['values']['op']) {
            case 'Next' :
              ....
              $form_state['storage']['step'] = 2;
            break;
          }
        break;

        case 2:
            switch($form_state['values']['op']) {
                case 'Next' :
                    ....
                    $form_state['storage']['step'] = 3;
                break;

                case 'Add another' :
                    $form_state['rebuild'] = TRUE;
                    ....
                    $form_state['storage']['step'] = 2;
                    return;
                break;

        .....

    }
}

I've try to clear the form_state['values'] manually after each submit but with no success. Who can this multistep with add another functionality be achieved?


texts: How do I access the Drupal class from a standalone PHP file?

texts: How do I use the \Drupal class in an standalone PHP file?


texts: How to re position the breadcrumb on the product detail page?

texts: I am a bit confused, I was wondering how do you re position the breadcrumb to the top of the page. Please see image example below. When I see the default layout of Drupal Commerce Kickstart, the breadcrumb is located on the top of the product. I even replaced the css with the default css and there was no changes.


texts: How to output the Panel node's template name in the Body class list

texts: Is there a way to access a Panel's template name to output in the body of the page?


texts: Drupal Commerce - How do i specify a user name for new account other than the email address on an anonymous order?

texts:
Ok so here's the use case:

Our site also includes phpBB forums, which of course display the user name in posts... most people don't like their email address being displayed, for obvious reasons.

Orders placed by anonymous users automatically generates an account with the username the same as the email address. I want to keep the auto account creation, but have the user enter a UserID when they enter their billing info.

So i've created a field on the billing profile (field_account_name is the machine name). How do i reference that field in the entity creation rule? I looked at this topic:
http://www.drupalcommerce.org/questions/5370/how-do-i-base-new-account-u...
but that doesn't show me how to reference a field i've created, only ones that already exist in the commerce-order entity.

This might be a stupid question, but i'm still relatively new to drupal... any help would be HUGELY appreciated.

I also posted this on the Commerce site, but it doesn't look like that gets tons of answers.


texts: Display a block based on the term reference field of the current node

texts:
What I'm trying trying to do sounds fairly simple, but I can't get my head around it.

I'm having 2 taxonomy vocabularies: machinery and batteries (both created with NAT for all that matters), and 2 content types which are named the same.

Both the content types provide the ability to check related items (a regular term reference field). For the machinery node the user can check which batteries are suitable, and for the battery node the user can check which machines use this battery.

Basicly what I'm trying to is: if you're on a page about a specific machine, it should show the batteries that are related to it, be it as teasers (or fields) in a block. And vice versa: when you're on a page about a specific battery, it would show all the machines in which it fits.

I've been boggling around with relationships and contextual filters, but it just wouldn't work out so far (spent a couple of hours here). Does anyone have an idea how to sort this out please?


texts: How to delete content of sheetnode spreadsheet field?

texts:
I am using the Sheetnode spreadsheet module to upload data. I am looking for ideas on how to clear the contents of the spreadsheet each time the form is loaded.

I have tried setting form state using all the following ways:

hottopicsresearchsheet_form_hottopics_node_form_alter() {
  $node = $form_state['node'];
  $node_wrapper = entity_metadata_wrapper('node', $node);
  unset($node->field_spreadsheet[$node->language][0]);
  $form['#node']->field_spreadsheet[$node->language][0]['value'] = "";
  $node_wrapper->field_spreadsheet->set(NULL);
}

function hottopicsresearchsheet_field_widget_sheetfield_spreadsheet_form_alter(&$element, &$form_state, $context) {
  $element['#entity']->field_spreadsheet['und']['0']['value'] = "";
  $form_state['field']['field_spreadsheet'] = array('name' => '', 'value' => '');
}


texts: Copy installed modules and configuration to new installation

texts:
I have a Drupal 8 application with mysql as database. I installed bunch of third part modules such as domain, search_api, pdf etc... Most I installed using composer and a very few using "Install module".
Configured few content types, created few views, pages, configured apache solr for search indexing...

Now I have requirement to set up everything in a higher environment using oracle as database. I was able to setup a blank drupal 8 application with oracle database.

Question: Installing all the modules in new installation ?
My thoughts -> Edit the composer.json to add modules and run composer update and  manually install rest of the modules or Is there a better way to import all the installed modules to new app.

Question: Configuration migrate ? I was thinking of using configuration > development > Configuration synchronization to export and import all the configurations.

Question: Data migrate ? I used migration module to import content and upload files. If everything works till here, data migration is the last priority. Good to have. I have one custom module too created for migration purposes. I used this migration module to migrate csv data to druapl8-mysql application. If everything works, I want to migrate the same csv content to drupal8-oracle application.

This exercise will help us to migrate and duplicate setup to test environments too. Please suggest an ideal process for the migration.


texts: I want to avoid the URL pointing to a node on my site contains the "node" part (e.g. http://example.com/node/1). Is it possible?


texts:
Please how can I embed a view in a node template like node--blog--full.html.twig.

I have configured an about-the-author views to be embedded in full mode of blog content type using views-embed-view(), but it doesn't work. I have enabled the "Allow embedded displays" from views settings and followed a few tips online, but none seems to work.

Is there a better way to embed views in D8 node template?
How can I use views-embed-view correctly in D8?

Many thanks


texts: Responsive CSS in Bootstrap theme (more specifically "Tweme")

texts:
I am running the Bootstrap theme "Tweme" (however, this question will most likely apply to all Bootstrap themes) and would like to add responsive CSS. Adding commands like

@media (min-width: 1200px) {
  body {
    background: rgb(0,0,0);
  }
}

to my style.css does not have any effect. What is the best way to add responsive CSS to Drupal themes that are built on the Bootstrap library?


texts:
I'm in a custom tpl.php file. I'm also highly confused!

This line renders nothing...

render($content['field_subtitle']['0']['#markup']);

This line drops the subtitle as expected but in the Devel_Themer formatting.

kpr($content['field_subtitle']['0']['#markup']);

I'm trying to custom-theme a content type in a custom node.tpl.php file. Everything should work as expected... but, of course... it's not. Any ideas?


texts:
I know this generally has been asked a few times before. I've gone through all those questions and answers multiple times and tried several suggested solutions. So I try to ask this again with my specific parameters to see if anyone can come up with a better solution for me.

So in my website the visitor gets to pick a region, the choice will be stored in a session.

To store and switch the session and cookie I have a controller in a custom module with a route that looks like this;

MyModule.region:
  path: 'setregion/{id}'
  defaults:
    _controller: '\Drupal\MyModule\Controller\RegionController::setRegion'
    _title: 'Set region'
  requirements:
    _permission: 'access content'
  options:
    no_cache: 'TRUE'

The setRegion method looks like this;

public function setRegion($id) {
    $session = \Drupal::service('user.private_tempstore')->get('MyModule');
    $session->set('active_region', $id);

    return $this->redirect('<front>')->send();
}

Then I need to display this Session on my theme's page template. I took some inspiration from this answer: https://drupal.stackexchange.com/a/208231/90074
and made a twig extension to display the session. This is how it looks;

class SessionTwigExtension extends \Twig_Extension {

  public function getName() {
    return 'session_var';
  }

  public function getFunctions() {
    return array(
      new \Twig_SimpleFunction('session_var',
        array($this, 'session_var'),
        array('is_safe' => array('html')
      )),
    );
  }

  public function session_var($key) {
    $session = \Drupal::service('user.private_tempstore')->get('MyModule');
    return $session->get($key);
  }

}

Lastly in my page.html.twig I print out the session like this;

{{ session_var('active_region') }}

All this seems to work fine on my development platform while I'm logged in to the administration and the cache is turned off. Once I log out and cache is running again it stops working. So where have I gone wrong? Somewhere it has to run some cached version of that session value.

Note: I've also tried to use symfony Session object and the $_SESSION array instead of the drupal service. Also tried to display the session with {{ app.session.get('active_region') }}

Edit: Adjusted the code and deleted everything that had to do with the cookie. My problem is with the session not the cookie.


texts:
I want set the default frontpage of both my local and production site site.

In my local environment I created a content it has node id (/node/20) and it has URL alias of /homepage.
In the Basic site settings I set my default frontpage to /homepage

In the production environment I also create a content it has node id (/node/33) and it has URL alias of /homepage.
In the Basic site settings I set my default frontpage to /homepage.

Whenever I deploy something to the production environment, I export the configuration of my local environment (in the Drupal CMS) and I will import to the production environment.
But whenever I import my configuration to the production my default frontpage is setting my homepage to /node/33, why is drupal doing this? I specifically set the default page to /homepage.

I'm using drupal 8 by the way.


texts: How do I execute a function every 3 months?

texts:
What's the proper way to execute a function every 3 months? Watchdog variables don't seem to be available after a certain time. I could create another table to insert the execute function date to compare, but it doesn't seem to be the best approach.

The functionality of such functions are:

Send an eMail
Tag an inactive user


texts: How to print "node title" in comment.html.twig template?

texts:
i am styling my comments in comment.html.twig template and need to show "node title" of the node to which the comments belong.
I've tried a number of options, and the only one that works relatively is below:
function enar_preprocess_comment(&$variables){
   $node = \Drupal::request()->attributes->get('node');
   $variables['nodetitle'] = $node->getTitle();
}

However, if I click "reply" in the comments, I get this error.
Error: Call to a member function getTitle() on null in mytheme_preprocess_comment()

My question is, how to print "node title" in comment.html.twig template?


texts: views - get teasers of "related nodes" referenced in entity fields on current node

texts:
I have a content type 'Article' which has a custom field of 'related articles'. This field uses the Entity Reference module and allows an admin to specify up to 4 related articles (nodes) to be shown on that page.

I'm trying to create a view block to display the teasers of those related articles on the page.

I'm struggling to set-up the view.

So far I've got it as:

The plan is that this view will be attached to an existing view which just shows the latest articles.

The view at the moment doesn't seem to be referencing the entity field (Related Articles) or showing those items...

Probably missing something obvious but would appreciate any pointers.


texts: How to access/print fields in non-Drupal php files?

texts:
I'm using Drupal's php filter to add php code in node body of some of my nodes. Among other things, I'm also including a php file. That php file is doing some non-Drupal work and it is included in those nodes properly. However, I can't print Drupal's fields in that file.

Here is an example of php code in node's body field:

<?php

some work is happening here

include 'non-drupal.php'; // include non-drupal php file

some work is happening here

?>

Here is an example of non-drupal.php:

<?php

echo date('h:i:s'); // This works

print $title; // This doesn't work

?>

When I open that node, I can see the time, but there's no node title displayed.

Is it possible to print node fields from "external" php files?

EDIT (code added from dropbucket) I have tried with adding this code from Dropbucket, but it's not working either):

<?php

echo date('h:i:s'); // This works

function get_node_title($nid) {
return db_query('SELECT title FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
} // This doesn't work (There is no output, but no errors displayed either)

?>


texts: Migration multibyte images file name issue

texts:
I have a Drupal website that I transferred it from host A to host B. I have some images uploaded with its Arabic file name, it works fine on host A, but after zipping Drupal files into a zip archieve, sending it to host B, extracting it there and finally run my website there, I found that the file names have been corrupted. the following screen shot demonstrates the issue:

What's the cause of this issue? How could I keep correct multiple byte file names correctly during zipping and unzipping?

By the way, the two hosts are Linux.


texts: How do you customize the title of an RSS feed created by Views RSS?

texts:
I have an RSS feed for each user provided by the Views RSS module. The view uses

  users/$uid/feed

as the display path. The feed is titled "All articles by 34 on example.com". The "34" is the userid being viewed. I want the title to be "All articles by username on example.com". I can't set this to use a variable/data in the views title field, which does change the RSS title.

I can't use hook_preprocess_html() or _page(), as these  are not called for feeds
I don't see a hook in the Views RSS module, but I may have missed something
I don't want to do this in the theme templates for display, as this feels like the wrong place to put the logic

How do I change this? Is there another preprocess function I can use?


texts: I have setup flags so a user can report another user as abusive/offensive. I need a way to manage to flags. I would like to be able the view all the users that have been flagged and and remove the flags. I have tried to do this with views but I could not find a way to remove the flag.


texts: How to create a query about users in a Drupal Commons group including their location (State)?

texts:
I need to create a MySQL query that will allow me to view the users in a specific Drupal Commons group and include their USA State location. I would like to be able to export this to a CSV file.

Any help with this would be appreciated.


texts:
I'm pretty new to Drupal, I installed Drupal Commons in order to build a website where users can register and create a custom profile. Users will be split in categories.

I'm not entirely sure Drupal Commons is the best choice for me.

Anyways, now I find myself in the following situation:
- I cannot find a way to change the Commons Origins default theme, let alone find a place where I can acquire such themes.


texts:
I'm trying to create a custom query access handler for one of our custom entities, and I must be missing something or have the wrong concept of how this is all supposed to work.

Currently I have this in my entity definition file.

"query_access" = "Drupal\fs_report_entity\Entity\Access\ReportQueryAccessHandler"

Which I assumed would call that query access handler anytime I do a \Drupal::entityQuery call for entities of that type, but nothing happens.

I even put a logger in the constructor of that access handler and it never fires.

I'm having a hell of a time finding any documentation on how to actually use this feature. Any help would be greatly appreciated.


texts: how to filter by YEAR of a date (not the published date) in a view

texts: I can add a contextual filter for the YEAR of the published or created date, but not for another date .  How can I create an exposed filter by this other date?


texts: How to migrate from DotnetNuke to Drupal?

texts:
Currently we have DotNetNuke (= DNN) websites. We are planning to move the DNN websites into the Drupal platform.

My questions: how do I migrate the DNN content and users tables into the Drupal Mysql tables?

I have tried with Drupal Migrating Handbooks, but no luck.


texts:
I ma quite new to drupal . I've tried to install commerce 2.x on debian 10. However, php-mysqlnd is only a virtual package referring to php-mysql. there is no real mysqlnd and commerce gets stuck with this dependency.

Does that mean I cannot rund commerce 2.x on debian 10?


texts: Add stock field to product display containing multiple SKUs

texts:
I've been trying forever to create a stock field for a product display that contains multiple product skus. I want to do this so that when each variation is purchased, it is subtracted from the total number of items in stock. Commerce Stock seems to let you track stock for individual skus, but not for one product with multiple skus. For example, I have a total of 100 shirts, but 10 shirts are pink, 10 are red, 10 are blue (hence, the different SKUs). That said, when 2 blue shirts have been purchased, I want the stock to drop from 100 to 98 on the product display. Out of the box, this isn't possible.

I tried using the answer in Synchronize commerce stock for product variations, but I'm unable to achieve the same result. I created a master stock text field on the product display, but I can't seem to set rules to subtract from the new field. Does anyone have clear instructions for doing this via rules?

In short: I am looking for a simple way to synchronize all product variant's stock in a single product display.

** UPDATE

I have SUCCESSFULLY obtained the nid of a product display, and then, fetched Product Display by that nid with the below rule settings. That said, when I try and add an action to set data for my custom stock field (product_stock) located on my content type Product Display, rules can't seem to find it? How is this happening?

FETCH ENTITY BY ID SCREEN

THE SELECTORS I DO GET WHEN I DO FETCH ENTITY BY PROPERTY:


texts:
function formexample_nameform(){

$form['user_name'] = array(
'#title' => t('your name'),
'#type' => 'textfield',
'#description' => t('Please enter your name.'),
);

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

return $form;
}

if i add this:

'#name' => 'new name attribute',

it looks like this:

function formexample_nameform(){

$form['user_name'] = array(
'#title' => t('your name'),
'#name' => 'new name attribute',
'#type' => 'textfield',
'#description' => t('Please enter your name.'),
);

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

return $form;
}

and it does not validate any more, it always let the inputs pass through.

my validate function:

function formexample_nameform_validate($form, &$form_state){
if ($form_state['values']['user_name'] == 'King Kong') {
    form_set_error('user_name',
    t('King Kong is not allowed')
    );
}
}

question: what has the name attribute with validation to do?!


texts: Best way to show another site's page via Drupal?

texts:
I have a somewhat odd request and, while I hate asking vague questions, I just don't know where to start with this one.

I am developing a website (Drupal 6) for a user that also has a seperate website with some very particular server side apps that allow their staff to do data entry.

The request is that they would like to show a certain data entry form from within the new site. The data entry form can span several pages but once done shows a very definitive End of Form marker. I am thinking that to simply show the form can be done using iFrames, perhaps. But this requested level of integration of having the current site recognize the end of form marker puzzles me.

Any advice on how to:

Show the data entry form from the other site.
Have Drupal recognize the "End of Form" marker (just some text that says Done, basically) would be very much appreciated.

Googling things like "Drupal show another page" and such doesn't yield much.


texts: Pager doesn't work in views block if views php field is used

texts:
I have a views block that shows nodes in some conditions. The views has pager and normally it works but if I use Global: PHP field the pager doesn't work and it only show the first page.

The Global: PHP field is as below:

Value Code: emtpy
Output Code:

->

<?php if ($row->type == 'book') { ?>

<?php }
elseif ($row->type == 'article') {
?>

<?php }
elseif ($row->type == 'thesis') {
?>

<?php } ?>

UPDATE:

I'm listing the nodes in this views block. There are 3 different content types and what I want to do with this PHP field is to print an icon according to content type. The code checks the content type with if ($row->type == ...).

(End of update.)

The PHP field works correctly and gives what I want but I wonder if I do something wrong in the PHP structure.

Do you have any idea what can cause this problem?


texts: Display comments from other nodes with a reference

texts:
Here's a doozy.

I have a certain content type where nodes of this ct serve as a sort of portal for other nodes. The other nodes (which are all different content types themselves) have entity reference fields, linked too this portal-node.

I need a view that displays the latest -comments- of the nodes linked too the portal node which the user is currently viewing.


texts: How to log user in to multiple drupal sites?

texts:
I have multiple drupal sites on the same server (VPS). Thise sites has separated d7 core and db. All sites has own domains: domain1.com, domain2.com, domain3.com..

When user logs in to one site I need him to log also in to the another site.
This should be done in single sign on so user does not have to log first to one site and then to another.

How to automatically log user in to the both/multiple sites?


texts: Change field input type on node edit form

texts:
I'm looking to change the input field widget on my form, but still accept the same value at the end of it.

I have an integer field, and I only want them to be able to select certain integers which are relative to another field in the system. Normally I would just make an integer list field, and change the safe value to the words I want them to pick. eg:

1 | Red
2 | Blue
3 | Green

However the list is constantly growing so I couldn't manually set it. I've also tried using an Entity Reference field with an Entity Reference view for the values, but I've found that it creates an error when used in conjunction with a Field Collection field in the same node form, so I'm running out of ideas.

I've written some code to give me an array of the values, keyed by the integer number I want on a per node basis which is working, but what I want is to change the input widget from a textfield to a dropdown of my allowed values, but still accept the integer key value when it's submitted.


texts: console.log() renders elements as "D.fn.D.init"

texts:
I have a strongly ingrained habit of using console.log() to pinpoint where an element is on the page. Usually if you had a page like this

hello Drupal.stackxchange.com This is my first question!

goodbye

and then you ran a jQuery function like this

console.log($('div'));

your console would spit out this

[▶
…
, ▶
goodbye
]

which works just as good as the element inspector. Hovering your mouse over one of these will make the actual element on the page be highlighted in yellow with a helpful tooltip. It's one of my favorite ways to work with markup, however the jQuery that comes with Drupal makes it impossible by spitting out the following alternative.

[▶D.fn.D.init, ▶D.fn.D.init]

which does NOT work with the highlighting feature because it's not the actual element being passed to the console, nor is it very descriptive visually.

Why?


texts: Migration yaml - A colon cannot be used in an unquoted mapping value

texts:
I think I might be losing myself here. I am getting an invalid YAML error on a very simple migration file that really should be working fine. Would someone mind taking a look and letting me know if they can see something obvious that I am missing? Error code is:
A colon cannot be used in an unquoted mapping value at line 14 (near "  method: row").

YAML file is:
id: data
label: 'Data'
source:
  plugin: data
  key: migrate
process:
  name: data
    -
      plugin: existing_term
      vocabulary: data_source
      source: data
    -
      plugin: skip_on_empty
      method: row
destination:
  plugin: 'entity:taxonomy_term'
  default_bundle: data_source

Migration runs without error if I remove process plugins underneath name. Same error occurs if I get rid of the second process plugin (so with no piping). Basically, if I add anything that is indented more than 1 level, this error throws. I am sure that indention is '2 spaces', and this structure has worked in the past. This is on a vanilla drupal 9 install done with composer.


texts: How to restrict creation of content based on unique field values?

texts:
I'm not entirely sure how to title this question.  I want to restrict the creation of a particular content type to one entry per user per the value of a particular field.  So essentially what I'm saying is you should be unable to create a second piece of content of a particular type if the value of a particular field is identical to the value of the same field but in another piece of content created by the same user.

Is there anyway to accomplish this?


texts: When I have an entity reference field with an autocomplete widget, is there a way to add a field to the info that appears in the autocomplete choices? Seems like the default field is Title, but this in my case might be ambiguous.


texts: import local drupal site with database already exist

texts:
i create a local website in my laptop and now i want to work on the project from an other laptop, after installing the module backup and migrate and active it , i download the public files settings and default database, after that in aquia dev desktop i choose import local drupal site then i choose the folder (public files downloaded) as my local code base folder and for database i choose start with Mysqldatabase dump file, at the end, after i click on the link: my local site, it shows me this :

Not Found

The requested URL / was not found on this server.


texts:
I'd like to have a custom twig template for custom block plugins from my custom module.

My custom block HeaderText contains

public function build() {
    return array(
        '#title' => 'Test',
        '#color' => $this->configuration['color'],
        );
}

It is located in myplugin/src/Plugin/Block/HeaderText.php

I have a template block--HeaderText.html.twig located in myplugin/templates which only contains test code

{{ title }}

{{ color }}

However the template isn't used. Following a guide I also added the following to myplugin/myplugin.module

function myplugin_theme($existing, $type, $theme, $path){
    return array('myplugin' =>
        array(
            'variables' => array(
                'title' => 'Default title',
                'color' => null
                ),
                'template' => 'block--HeaderText'
            )
        );
}

Which did not work either. And even if the previous code did work, I have multiple plugins within that module and that code seems to apply to every block which I don't want to do. I'd like each block to have a unique template.


texts: Show oldest to newest of a date range field

texts:
I am trying to figure a way to show the oldest to the newest of a date range field that is attached to a taxonomy.

For example: Tax1 (1900-1920), Tax2 (1913-1950), Tax3 (1970-1980)

So how shall I printed like this: (1900-1980)?


texts: How do you automate text file upload daily to a Drupal Page?

texts: Im trying to create a plugin, possibly through IFTTT, where i can forward an e-mail with a text attachement that will replace a current file on a Drupal page.  Has anyone had any success in automating this process?  Bascially we're getting a text file sent to us daily that we would otherwise have to manually upload to the page.


texts: Editing a user profile locks my user search reults to that username

texts:
Note, I did not dev this site I am onsite for a couple of days to help with debugging.

Clients site has a View for searching users. After I click Edit the user profile shows, if I save or cancel this edit the search results are locked on that user. Clearing the search field, typing a different user name or refreshing the page doesn't help. The only way to get fresh search results is to click on the Users button again.

Any guidance in this is appreciated. Let me know if you need more info.

Thanks!


texts: Way to prevent drush from eating custom profiles when updating core?

texts:
I use drush make with a stub .make file to download a custom profile via git.

that profile has all of the modules I want all of my sites to start out with.

If I then go into that site, and run "drush up drupal", it will update core, and remove my custom profile.

This is not good, since all of the modules I downloaded with my install profile's make file get stuck into the profiles/myprofile/modules folder. This basically removes all of my installed contrib modules, and drush doesn't give me a way to put them any where else, so basically, I can't update core with drush.


texts: Is it possible to add help text to addressfield module fields?

texts: I would like to add some help info to address field fields from Address Field Module (http://drupal.org/project/addressfield). Is that possible, or do I have to use Javascript?


texts: Custom field for Search API with multi values

texts:
I'm using latest version of SearchAPI (1.18) and SearchAPI Solr (4.1.10).
I've a custom field that I want to have multiple values (I use it for faceted search with Facets module). In the previous version of SearchAPI the second example worked.
If I use this code, SearchAPI save "Array" as value:
<?php

namespace Drupal\archivio_utils\Plugin\search_api\processor;

use Drupal\search_api\Datasource\DatasourceInterface;
use Drupal\search_api\Item\ItemInterface;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\search_api\Processor\ProcessorProperty;

/**
 *
 * @SearchApiProcessor(
 *   id = "periodo",
 *   label = @Translation("Periodo"),
 *   description = @Translation("Periodo"),
 *   stages = {
 *     "add_properties" = 0,
 *   },
 *   locked = true,
 *   hidden = false,
 * )
 */
class Periodo extends ProcessorPluginBase {

  /**
   * {@inheritdoc}
   */
  public function getPropertyDefinitions(DatasourceInterface $datasource = NULL) {
    $properties = [];

    if (!$datasource) {
      $definition = [
        'label' => $this->t('Periodo'),
        'description' => $this->t('Periodo'),
        'type' => 'string',
        'processor_id' => $this->getPluginId(),
      ];
      $properties['search_api_persona_periodo'] = new ProcessorProperty($definition);
    }

    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public function addFieldValues(ItemInterface $item) {
    $entity = $item->getOriginalObject()->getValue();
    /* @var \Drupal\node\Entity\Node $entity */
    /* @var \Drupal\node\Entity\Node $carriera */
    if ($entity->bundle() == 'persona') {
      $fields = $this->getFieldsHelper()
        ->filterForPropertyPath($item->getFields(), NULL, 'search_api_persona_periodo');
      foreach ($fields as $field) {
        if (!$field->getDatasourceId()) {
          $values[] = 'test1';
          $values[] = 'test2';
          $field->addValue($values);
        }
      }
    }
  }
}

If I replace code where I wrote values with this:
$values[] = 'test1';
$values[] = 'test2';
foreach ($values as $value) {
   $field->addValue($value);
}

I obtain this error:

[error]  Drupal\search_api_solr\SearchApiSolrException while indexing
item entity:node/10008:it: Solr endpoint http://solr:8983/ bad request
(400). ERROR: [doc=3igm00-archivio_indice-entity:node/10008:it]
multiple values encountered for non multiValued field
ss_persona_periodo: [test1, test1] in
Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase->handleHttpException() (line 1016 of
/var/www/html/web/modules/contrib/search_api_solr/src/SolrConnector/SolrConnectorPluginBase.php).

How can I add multiple values to this custom field?


texts: Custom form set error for user login validate

texts:
I have used a custom validate function.

function user_information_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login' || 'user_login_block') {
    array_unshift($form['#validate'],'user_information_user_login_form_validate');
  }
}

function user_information_user_login_form_validate(&$form, &$form_state) {
  // print_r($form_state);
  form_set_error('name', t('Password invalid'));
}

But I am unable to log in to the site any more.


texts: Updating my very first install of Drupal

texts: I'm getting emails to update my very first install. How should I go about updating? Should I download the file and drag and drop using Filezilla, or should I use command prompt on my server? http://drupal.org/project/drush/


texts:
When trying to set up a migration, I can't seem to register new Migrations. When running drush migrate-status, I only see my User migration, even after a drush migrate-register.

My migrate.inc looks like this:

function module_migrate_api() {
    $api = array(
        'api' => 2,
        'migrations' => array(
            'User' => array(
                'class_name' => 'UserMigration'
            ),
            'News' => array(
                'class_name' => 'NewsMigration'
            ),
            'Activity' => array(
                'class_name' => 'ActivityMigration'
            )
        )
    );

    return $api;
}

And my module.inc file contains classes for each of these Migrations, based off of the UserMigration I wrote first (example given is UserMigration, which works, and NewsMigration, which does not work):

class UserMigration extends TestMigration {
    public function __construct($arguments) {
        parent::__construct($arguments);

        $this->description = t('Migrates users');

        $query = Database::getConnection('default', 'original')
            ->select('users')
            ->fields('users', array(
                'user_id',
                'username',
                'firstname',
                'lastname'
            ));
        $this->source = new MigrateSourceSQL($query);

        $options = array();
        $this->destination = new MigrateDestinationUser($options);

        $this->map = new MigrateSQLMap($this->machineName, array(
            'user_id' => array(
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'description' => t('Source ID')
            )
        ), MigrateDestinationNode::getKeySchema());
    }

class NewsMigration extends TestMigration {
    public function __construct($arguments) {
        parent::__construct($arguments);

        $this->description = t('Migrates news');

        $query = Database::getConnection('default', 'original')
            ->select('news')
            ->fields('news', array(
                'news_id',
                'user_id',
                'title',
                'text'
            ));
        $this->source = new MigrateSourceSQL($query);

        $options = array();
        $this->destination = new MigrateDestinationNode('news');

        $this->map = new MigrateSQLMap($this->machineName, array(
            'news_id' => array(
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'description' => t('Source ID')
            )
        ), MigrateDestinationNode::getKeySchema());

        /* $this->addFieldMapping('target', 'source'); */
    }
}

So far, I haven't added fieldmappings, since I want to set up everything that should be migrated first, to get a complete view of the work that's left.

When running drush migrate-register, I'm getting the following output:

All statically defined migrations have been (re)registered.                                                                                [success]

And a drush migrate-status gives me the following:

 Group: Test  Total  Imported  Unprocessed  Status  Last imported
 User         55     0         55           Idle    2015-12-03 13:40:30

So as you can see, no errors, not even when running with -v. But only User is recognized. Both classes are in the same file. Am I missing something simple?


texts:
I want to extend the basic views_view_table and add optional classes from a plugin form. I'm creating a new plugin. I'd prefer not to duplicate the views-view-table.tpl.php file nor template_preprocess_views_view_table().

I've started like this.

'views_my_table' => array(
    'title' => t('My Table'),
    'help' => t('My table options.'),
    'path' => $path . '/plugins',
    'parent' => 'default',
    'handler' => 'ViewsMyTablePluginStyle',
    'uses row plugin' => FALSE,
    'uses options' => TRUE,
    'uses grouping' => TRUE,
    'type' => 'normal',
    'theme' => 'views_view_table',

  ),

Then, I extended the table class.

class ViewsMyTablePluginStyle extends views_plugin_style_table {

/**
 * Set default options.
 */
function option_definition() {
  $options = parent::option_definition();
  $options['table_options'] = array('default' => '');
  return $options;
}

/**
 * Provide a form for setting options.
 */
function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

    $form['hover'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hover styling'),
    '#required' => FALSE,
    '#default_value' => $this->options['table_options'],
    '#description' => t('Adds the hover class to table to enable hover styling.'),
  );

}

This gives me a blank table rendered from the template, but the preprocess function either it isn't firing or it isn't getting the right data.

Maybe I need to implement the table plugin with more options, then tack on the classes based on those settings.

How do I correctly extend the table plugin?


texts: Switch to Drupal Mobile Theme Programatically

texts:
I found the following code on http://detectmobilebrowsers.com/ and would like to use it to programatically switch from my default theme to a mobile theme that I will also have active.

<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) {
    //Change Drupal theme to a custom mobile theme
} else {
    //Continue assigning the default theme
}
?>

Where should I place this code so it will transparently use the correct theme? I don't want to use another module or a sub domain for the mobile site. I just want to use a different theme for users accessing my site from their mobile phones. Thanks!


texts:
I am adding 2 columns to an existing table using hook_update_N function as below:
function cca_update_8904(&$sandbox){

   $connection = \Drupal::database();
      $schema = $connection->schema();
      $spec = array(
        'type' => 'integer',
        'description' => "criteriaflag",
        'length' => 20,
        'not null' => FALSE,
        'default' => 0,
      );

      $schema->addField('cca_program', 'criteriaflag', $spec);
    //
      $spec = array(
        'type' => 'text',
        'description' => "criteriaflagcode",
        'length' => 20,
        'not null' => FALSE,
      );

      $schema->addField('cca_program', 'criteriaflagcode', $spec);

    \Drupal::entityDefinitionUpdateManager()->applyUpdates();

    }

When I run update.php I get to see the below error:
Failed: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL DEFAULT 0 COMMENT 'criteriaflag'' at line 1: ALTER TABLE {program} ADD `criteriaflag` NULL DEFAULT 0 COMMENT 'criteriaflag'; Array ( ) in cca_update_8904() (line 702 of /vagrant/web/modules/cca/cca.install).

Any help on how this can be fixed?


texts: How to get Views Bulk Operations to work when showing a view programmatically?

texts:
I have shown a view programmatically using the code:

  $view = views_get_view('my_view');
  $view->set_display('panel_pane_2');
  $view->set_arguments( array('node', '241+254') );
  $view->pre_execute();
  $view->execute();
  print $view->render();

The view shows up and the VBO form shows up too. However, the VBO actions do nothing. They simply redirect to the home page. The action functions don't even get called.

Is there something extra needed in the code above or is this a bug in VBO?

Extra info (just in case): the code above is entered in a Panels pane through Page Manager.


texts:
I am looking for a contact form module for different users logged in to the website.

E.g.,

1) a website that has different authors

2) the user clicks on the author's page there is a contact form for that specific author on their page

Any suggestions?


texts: File in /sites/default/files/ gives 404 error

texts:
my page is trying to load this file /sites/default/files/languages/it_Et3NQJm4afZYHEnSM9oq5ylZkAw2ExqC8PQtEYrxXDU.js but it gives 404 error.
This error is spamming my log page with errors messages. If i check the ftp the file is there but if i try to load it from the url it gives 404 error. Is it a permission issue? How can i fix? Thanks


texts: Advantages of running cron via drush rather than via curl?

texts:
Are there any major advantages of triggering Drupal's cron tasks via Drush rather than via a curl call to the site? The main thing I can think of is that no web server process would be needed, when using drush. Are there other benefits?

Thanks!


texts:
I have Profile2 module installed and Solr search module.
Is there a way to search for users by e-mail with Drupal Solr ?


texts: I want to give the reset password link a different class so I can style it. How can I do this in drupal 7? my layout here http://www.lusciousanime.com/


texts: How to force a dev release of my module?

texts: Whenever I go to create a release for my contrib module, it gives me one option - 6.x-1.x (6.x-1.x-dev) - but if I select that it says "The version you have selected (6.x-1.x-dev) is already in use by another release." IIRC dev releases are packaged automatically every twelve hours, so why is this option even appearing? And it seems like dev releases aren't being packaged automatically for my module ...


texts:
I am using Drupal 8. By retrieving an entity by Entity Query I am getting an array. How can I fetch directly the TID?

Right now I am doing the following:

  public function getCommuneTidByPostalCode(int $postalCode) {
    $commune = \Drupal::entityQuery('taxonomy_term')
      ->condition('field_zipcode', $postalCode)
      ->condition('vid', 'commune')
      ->execute();

    if (!empty($commune)) {
      return intval(key($commune));
    }
  }

Can I drop somehow this part?:

if (!empty($commune)) {
  return intval(key($commune));
}


texts: Can I post a blog entry in a user's name?

texts:
I just found a new user has posted a dozen or so "blog entries" which were actually all posted as comments to a single forum question

I have explained to the user who will - hopefully - "add content" / "type = blog" in future.

Ideally, I would like to somehow edit those user comments and change them into user blog posts. Can I do that?

If not, I can copy /paste them; but can I create a new blog post entry in the user's name? And can I change its time-stamp to agree with the original?


texts:
I created a content type Carousel.
I created a region Huge.

On the front page, I want the content type to be placed in the region Huge.

Current process:

Create content
Specify publish to front page.

Even though I specify this:

render($page['carousel']).

All of the content is being loaded in:

render($page['content']).

What is the drupal way of doing this on the front page?

The use case is for marketing to create new Carousel content type >> publish to front page >> the HUGE region is updated with new content.

This should be different than regular blog's posts that appear on the front page.

Thanks for any help!
noah


texts: Filter on a single field from a field combination in a View

texts:
I'm working on a Drupal 7 site that shows the projects done by the researchers in an organization. The Projects content type has a field collection of researcher first, researcher last and role. The role is important because some researchers are the primary researcher and others take a more supporting role. These are not roles in the sense of Drupal user roles, but roles that are internal to the organization. Roles are a taxonomy with a term reference in the field collection.

There are two filters needed:
1. A filter by last name no matter what the role
2. A filter by last name where the role is primary researcher

I found this resource, which got me started: http://drupalcampnj2014.drupalcamp.org/sites/default/files/slides/working_with_field_collections_0.pdf

I have set the view to Aggregation On and I have created a relationship with the Field Combination. But I still see no way to filter on a specific field.


texts:
I've got a migration set up whose source was apparently filled out using MS Word. The JSON source for the migration looks like this in places:

{
    "field_courses": "
Courses Taught (selected)
\r\n...
"
}

When the migration completes and I open the resulting node, the field is rendered like this:

The field in question is allowed to use everything from Plain Text all the way to Full HTML. When I save the node manually, not making any changes, all the nonsense is stripped out and I'm left with relatively sane HTML when I check out the source of that field.

I thought maybe it would be as simple as loading the entity by its pathauto alias (eg. /people/[person_id]) and running $entity->save() on it as soon as it's been imported, but that's not removing the formatting. Any way that I can get it to display correctly without requiring a content manager to manually save 500+ nodes?


texts: Strange error updating PHP code in a node

texts:
I have a 'Basic Page' node that contains PHP code which returns the following error, when I edit and save it:

  Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.

I believe it is not the real error; if I edit anything but the code, I don't get any error.

What I do is changing <?php if (user_is_logged_in()): ?> to <?php if (user_is_logged_in() && (inarray('approved user', $GLOBALS['user']->roles)))): ?>.

I'm pretty positive the code is right; the PHP filter is enabled, and the administrator user is the only user who can use it. I'm not really sure what else could be the issue.


texts: Display edit link for a node in a view when user has permission

texts:
I have a view displaying fields from one node.

Is it possible to display a link for a user to edit the node if they are logged in and have the appropriate permission to edit?  Something similar to the tabs with edit displayed for a regular themed node would be nice.


texts: Adding stylesheets for an internal page only

texts:
I am trying to add a CSS file to a specific internal basic page in Drupal 7 with no success.
After enabling the clean URL paths and add a path for my internal basic page I am able to capture the path using $path=drupal_get_path_alias();.

After that, I am trying to put condition statements so when a specific path is loaded a specific CSS file is loaded. I have this piece of code in ninesixty_preprocess_page(&$vars, $hook) in the template.php file.

if($path == 'about/advantages') {
  drupal_add_css(drupal_get_path('theme', 'ninesixty') . "/page-about.css");
}

I have tested the IF-statement by echoing the $path variable with total success. The page-about.css file does not load at all, though.

Please note that I am using Drupal with WAMP server, and the page-about.css file is located under drupal/sites/all/themes/ninesixty/styles/framework.


texts: Does apache solr module supports the indexing of fields attached to custom entities?


texts: Set Default Value of User Entity Reference to logged in user

texts: I have a Drupal 8 installation that has a user reference field and I would like the currently logged in user to be the default value for the field. I believe in Drupal 7 I would've used the [current-user:name] Token for this. That functionality didn't seem to show up when I installed Token for D8.


texts: How do I filter down on multiple taxonomies?

texts:
I'm trying to create a simple classifieds area e.g. think of Craiglist.

I have 2 taxonomies; Region and (Ad) Category.

Everything is fairly easy when using just the Category in the following way:

Marketplace (views page)

Cars (5)
Clothes (10)
Electronics (14)
etc.

Category (views taxonomy page)

Cars
Listing of 5 nodes belonging to this category

Now, I want to bring along the Region but I am stuck on how to make it work with the listings I have. The user should be able to choose the Region before coming into the Marketplace or when on the Marketplace page. The number of items in each category would reflect on the chosen Region and consequently the Category pages would list only nodes that are in that Region.

What I've tried is to use the Views exposed filters and it works fine on some parts. The real problem is how to make it all flow from the beginning so that the Region information carries across the steps?


texts: how to get the translated taxonomy term programmatically?

texts:
I have tried this

$term = taxonomy_term_load($tid);

and this:

$term = i18n_taxonomy_localize_terms(taxonomy_term_load($tid));

Both return the default language (English) term

I am using D7.


texts:
I've set up a custom login page witht the difference that that one should redirect the user to another page.

I use the default drupal login form so I dont really now how to fix the form alter for my custom form without it to change the default login form too.

What could I do to fix this?

My code:

function mymodule_cv_login() {
    // Print the user login form
    $form = drupal_get_form('user_login');

    $form['redirect'] = 'cv';

    return $form;
}

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'user_login') {
        $path = 'profil';
        $form['#action'] = url($_GET['q'], array('query' => array('destination' => $path)));
    }
}


texts:
Rues and VBO are not working as expected to delete nodes. Can someone tell me what I'm missing? Thank you.

What I have:

A View with VBO field which successfully selects all nodes of a certain type based on how long ago they were created. (The Preview shows all the desired nodes.)
A Rules Action set which:

A. Load a list of entity objects from a VBO View. Obviously the chosen View is the View from step 1 above.

B. Loop through the list of entity objects.

C. Deletes each list item using "Delete entity".

A Rule which runs on cron and has for its only action the above Action Set (and no conditions).

However, it's not working. I run cron via drush and none of the nodes are deleted.

I have cleared all caches, recreated each part of the process from scratch (i.e. not cloning anything)... but it's still not working.

I have also created a Page display in the View (because the Rules Action set uses the Master display) and I can successfully manually delete the nodes with VBO - it's just not working when used in a Rule/Action Set.

However, the site is already deleting User entities with an identical Views/VBO/Rules/Cron setup.

Has anyone come across this or have any idea what might be wrong? Thanks.


texts:
I'm trying to use tokens in the Linked Field module to link a field in one content type to another content type. I'm also using Pathauto.
So I want to link a field in URL /type/subtype/pagetitle to destination URL /type/subtype.
I've tried [current-page:url:args:first]/[current-page:url:args:second] but the second token doesn't work and the resulting URL is just /type.
I've tried using the [node:field_nameofsubtype] token but that results in /type/Sub Type instead of the /type/subtype generated by my Pathauto.
Surely it isn't that hard to use tokens to just move one step up the URL tree but I can't find it. What am I doing wrong?


texts: How to change the alias for the core forum landing page for drupal 6?

texts:
Core forums sets the landings page to /forum. I need this changed to /some-other-name.the forum posts can be changed using pathauto, but I need to change the alias for the top-level forum landing page. I have tried playing with url aliases but can't find anything to solve my purpose.
I googled and found this exctly same question on drupal stackexchange, but I need to do it for drupal-6. Please help.
 Edit: im also using advanced-forum module


texts:
I have installed some analytics module for my drupal sites. Because it's on company's internal network, I couldn't use it. Now I have the tables created by the module sitting in my database (after I just forcefully removed the module folder from drupal installation).

Is there a way to clean unused tables in Drupal 7?

Note: I tried Schema, but it doesn't seem doing anything but displaying tables are in use and not used


texts: I am unable to show the access denied message of the premium content module. How can I do this?

texts:
I have 3 view modes (teaser, presentation and full view mode). I have created a node--content-type.tpl.php and created the code for each view mode using a conditional statement

if($teaser) {}
else if($node->type == 'tu_mooc' && $view_mode == 'presentation') {}
else {}

I have linked the 3 view modes. So I can go from the teaser to the presentation and from the presentation to the full view mode.

I have downloaded the premium content module so that access to the full view mode is limited to authenticated users. I made a small change in premium.module so that anonymous users have access to both the teaser view mode and the presentation view mode. The problem I have is that when I try to access the full view mode (as an anonymous user) I don't get the access denied message. Instead I get the code that appears within the teaser view mode. i.e. In node/1 I get the teaser of node1 instead of getting the access denied message.

Do I need to include some code like <?php print $denied_message; ?> into the node--content-type.tpl.php? or what do I need to do?

Thanks in advance.


texts:
I'm working on a paragraph type that will need to display on a very limited number of pages but has some specific functionality where the preprocess function will need to run each time.

In my preprocess function, I've tried various iterations of the following:

$variables['elements']['#cache']['max-age'] = '0';
$variables['elements']['#cache']['contexts'][] = 'url.path';
$variables['elements']['#cache']['contexts'][] = 'url.query_args:r';
$variables['elements']['#cache'] = ['tags' => ['my_paragraph']];
Cache::invalidateTags(['my_paragraph']);
\Drupal::service('page_cache_kill_switch')->trigger();

However, the preprocess function runs once after a cache clear and then doesn't run again.

What am I doing incorrectly here? How can I get this to run each time?


texts: Drupal 7 site crashed after enabling module - No DB backup. What do?

texts:
I enabled the blog module on a website, after that the site crashed.
The error is the same on everypage:

  Catchable fatal error: Argument 2 passed to
  entity_views_field_definition() must be an array, null given, called
  in
  /homez.653/xxxxxxxxx/www/sites/all/modules/entity/views/entity.views.inc
  on line 152 and defined in
  /homez.653/xxxxxxxxx/www/sites/all/modules/entity/views/entity.views.inc
  on line 175

Problem is that I don't have any backyp of the DB......

Any any idea on what should I do?

Thanks you per advance.


texts: How can I create a Views type page without using Views?

texts:
I have a very intensive project that ultimately (and theoretically) was designed to house 33,600 Views pages. It's a census data project, and one page represents one city in the United States.

The URL structure MANDATORILY must follow this pattern:
example.com/Atlanta-GA or example.com/{cityname}-{state}

Originally, when trying to use Views as the direction, it was easy enough to create a page view with name "atlanta-ga." Then, as each page had attachments and other blocks specific to the data found for that particular location, it showed them on that page accordingly.  This approach worked well until we got to just over 1000 views.  (Of course, all these views are created programmatically from already existing data sets in other databases).

However, Views will not scale this high (because of memory leaks and existing limitations in Views current architecture predominantly.)

So then, how do I recreate this process programmatically without using Views? How can I create a page at the address example.com/{cityname}-{state} with related blocks, attachments, and tabs? How did people do this before Views was ever invented?

Here are a few links if you are interested in some other background questions related to this project and Drupal's ability to scale this high (or Views rather.)

http://groups.drupal.org/node/284998

Here Merlinofchaos, author of Views, states pretty much it's not possible to get views to scale this high. He notes that in many instances all of the views have to be loaded, which, will crash at these numbers.
http://drupal.org/node/1929938

All creative approaches to this problem appreciated.


texts: drupal_view or views_embed_view doesn't show translated content

texts:
I have a block view on a multi-language website. Rendering Language is set to Content language selected for page and the translated content is displayed correctly in the admin page.

I embed this view like {{ drupal_view('ipa_projects_map') }} inside twig but at that page the content in original language is displayed, ignoring the content language selected for page setting.

Any ideas why?

PS: drupal_view is provided by "Twig Tweak" module and utilizes views_embed_view


texts:
On Drupal 7.15, I cannot save reordered draggable items at /admin/config/content/formats.
That is the dialog with all text formats and their options, and dragging them in order force their order of appearace.

I am able to drag items and reorder them, but after saving, items returns in previous order, in spite Drupal says "The text format ordering has been saved."

I do not have clue yet how to troubleshoot this issue, as there is no error anywhere.


texts: Services Views and combine different field values into one?

texts:
I got a site with a profile2 type and a content type that uses the same field containting coordinates (field_coordinates).

I'm using Services Views to show these coordinates in JSON but this is where I ran into some problem. I want only one field set of these coordinates visible, but I have to chose the relationship of the field: either no releatinship shows the node coordinates, or the relationship with the profile shows the profiles coordinates.

There will never be two sets of coordinates per output node (in one case the are requested from the node, and the other case from the profile). The JSON output cant show two fields with the same label so I have to have two different names: one for profile coordinates and one for node coordinates.

The issue is that I want only one coordinate field, and therefore added a global text field, where I put both of the place holders from the other coordinates. But this global text field output wont show in my Services view. Why is that?


texts: How to properly manage field types for a content type created by a module?

texts:
I'm a bit confused about two different errors I get, which seem to contradict each other. I guess I didn't register my field types properly. The first one appears when I try to uninstall my module.
Drupal\Core\Field\FieldException: Attempt to create a field field_example that does not exist on entity type node. in Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (line 312 of core\modules\field\src\Entity\FieldConfig.php).

The second one appears as an error message within the UI when I try to fix it by introducing another module which should only create the field type.
Unable to install Helper, field.field.node.content_type_example.field_example already exists in active configuration.

In general, the module calls an external API and fetches data which is then used to create nodes with several fields. These are defined inside the config/install directory. Furthermore, inside src/Plugin/Field there are FieldType, FieldFormatter and FieldWidget classes, more or less as described here.
I used this module when I tried to fix the first error without a helper module. With its help, I removed the field types created by my module in the first place. Unfortunately, I don't know a lot about drush, which seems to be capable of solving the issue. On the other hand, it would be great if it was possible to "reset" the content type and the field types programmatically whenever the module is installed or uninstalled. So far, I tried the following code, without much luck:
<?php
// mymodule.install file
use \Drupal\field\Entity\FieldStorageConfig;

function mymodule_install() {
  if (FieldStorageConfig::loadByName('node', 'field_example')) {
    FieldStorageConfig::loadByName('node', 'field_example')->delete();
  }
}

Does someone know how I can fix the error and how I should manage these fields in the future? Thanks!


texts: How to send a confirmation reservation email using the Reservations module?

texts:
I'm using the Reservations module to control certain resources.  I'd like to send an email to the user who reserved the resource when it is confirmed.  I also installed the Reservations email module to handle that.  I could not find a token to use to refer to the user in the email body.

Currently, when a user requests a resource, an admin receives an email.  When the admin confirms the resource I'd like to send the user an email confirmation.

Any suggestions about how this can be done with the existing module?


texts:
If the user didn't buy anything ever, at the first time he gets a 20% tax of total shopping cart amount.
I'm newbie in Drupal and can't understand how to implement it.
Say I'll do checking for first order (I imagine how), but I can't find how to change total cart amount without changing every item price.

I hope you can help me :)


texts:
I have created an entityform "Submit your proposal"(Machine name: submit_your_proposal). I would like to theme this form as per my site theme.

I gogled, but didn't find the exact result.

The form fields are given below (in following order Label, Machine name, Field type, Field widget)

Program name, field_pf_program_name, Text, Text field

Email,  field_pf_email, Text, Text field

Organizers details, field_pf_organizers_details, Field collection, Embedded (Field limit is unlimited which gives "Add another item" button)

Proposed duration, field_pf_proposed_duration, Text, Text field

Possible dates, field_pf_possible_dates, Date, Pop-up calendar

Upload your proposal, field_pf_upload_your_proposal, File, File

Organizers details (MAchine name: field_pf_organizers_details) given above is a "Field collection" which contains following fields,

Name, field_pf_organizers_details_name, Text, Text field

Affiliation, field_pf_organizers_details_affi, Text, Text field

Email, field_pf_organizers_details_em, Text, Text field

Please guide me how to create a custom theme for entityform

Thank you


texts: Getting the taxonomy parent term as Views argument

texts:
I am trying to get a taxonomy parent name with this code; when I put 1 as the argument, I keep getting the ID, but when I try using 2, I get a error. It should wor,k but it keeps throwing the error back at me. I am trying to get the parent name, not the ID.

$view = views_get_current_view();
print $arg0 = $view->args[2];

  Notice: Undefined offset: 2 in __lambda_func() (line 3 of /home/loansdotorg/public_html/modules/views_php/plugins/views/views_php_handler_area.inc(39) : runtime-created function).


texts: Find out if a view returns any results and if it doesn't disable a link to that view

texts:
I have a panels page with two view panes on it. The first view pane lists taxonomy terms. When you click on one of the taxonomy terms the second view pane will display a list of content for that taxonomy term.

Is there any way that if there is no content for one or more of the taxonomy terms then those links can be disabled/hidden from the first view pane?

The second view pane uses the term ID from the links in the first view pane as an argument to filter the content for that term.

I'm not quite sure how to go about doing this. One way I had thought was to use jQuery and Ajax to somehow call a function in Drupal to find out if the view returned any result and then hide the link. But I haven't attempted this before in Drupal.

There is another slight complication in that the panels display are for organic groups and the second view pane only shows content for the taxonomy term clicked on and also content that is associated with that group. So that any function that finds if there are any results would need to pass in both the argument for the term ID and also the ID for the group, which the view was getting from the context.

Any help would be much appreciated, or even an outline of an approach I could take.


texts: Multiple instance of same block and contextual widget

texts:
I print the same menu twice in my region (to handle responsive design).

Here is a part of my region--header.html.twig with my two topnavigation menus:

       {{ topnavigation }}

       {{ topnavigation }}

My problem is the contextual module is not able to show contextual links for these two blocks (it works if I disable one of them).
If I inspect the DOM, they have the same data-contextual-id value so maybe it's a problem for the rendering.


texts:
I am trying to setup twitter module for Drupal 7 on my localhost. I followed the installation instructions as given in Twitter 7.x installation guide. I followed steps until "Add Twitter accounts" when i start getting this error.

Could not obtain a valid token from the Twitter API. Please review the configuration.

The dblog has the following information:

  exception 'TwitterException' with message 'Bad Request' in
  C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.lib.php:142
  Stack trace: #0
  C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.lib.php(101):
  Twitter->request('https://api.twi...') #1
  C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.lib.php(51):
  Twitter->auth_request('https://api.twi...', Array) #2
  C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.pages.inc(336):
  Twitter->get_request_token() #3
  C:\wamp\www\test_twitter\includes\form.inc(1464):
  twitter_auth_account_form_submit(Array, Array) #4
  C:\wamp\www\test_twitter\includes\form.inc(860):
  form_execute_handlers('submit', Array, Array) #5
  C:\wamp\www\test_twitter\includes\form.inc(374):
  drupal_process_form('twitter_auth_ac...', Array, Array) #6
  C:\wamp\www\test_twitter\includes\form.inc(131):
  drupal_build_form('twitter_auth_ac...', Array) #7
  C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.pages.inc(130):
  drupal_get_form('twitter_auth_ac...') #8 [internal function]:
  twitter_user_settings() #9
  C:\wamp\www\test_twitter\includes\menu.inc(517):
  call_user_func_array('twitter_user_se...', Array) #10
  C:\wamp\www\test_twitter\index.php(21): menu_execute_active_handler()

  11 {main}

I also have oauth module installed as given in the requirements.

Additional info:

My machine accesses internet via a proxy server and i do have proxy settings given in settings.php file. Not sure why it should cause problems.
I was able to run twitter API commands using twitteroauth library in a standalone application. It was throwing errors before i gave it the proxy settings for curl.

Can anyone help?


texts: Change toolbar config to latest CKEditor toolbar groups

texts:
There is a ckeditor plugin that I really want to use (Line Height), but after looking at its .js file I can see that it is configured to work with the ckeditor config.toolbarGroups concepts, which configures the toolbar like so:

CKEDITOR.editorConfig = function( config ) {
config.toolbarGroups = [
    { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
    { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
    { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
    { name: 'forms', groups: [ 'forms' ] },
    '/',
    { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
    { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
    { name: 'links', groups: [ 'links' ] },
    { name: 'insert', groups: [ 'insert' ] },
    '/',
    { name: 'styles', groups: [ 'styles' ] },
    { name: 'colors', groups: [ 'colors' ] },
    { name: 'tools', groups: [ 'tools' ] },
    { name: 'others', groups: [ 'others' ] },
    { name: 'about', groups: [ 'about' ] }
];
};

However, I use the ckeditor module, with a drupal 7 codebase, and after I install the plugin and its dependencies, the button for the lineheight plugin doesn't show up when I go to admin/config/content/ckeditor/edit/**{text format}**.

Is there a way to edit the lineheight plugin code so that it works with the ckeditor module?

editor.ui.addRichCombo( comboName, {
        label: editor.lang.lineheight.title,
        title: editor.lang.lineheight.title,
        toolbar: 'styles,' + order,
        allowedContent: style,
        requiredContent: style,
        panel: {
            css: [ CKEDITOR.skin.getPath( 'editor' ) ].concat(   config.contentsCss ),
            multiSelect: false,
            attributes: { 'aria-label': editor.lang.lineheight.title }

Or, is there a way to convert the ckeditor module to from using the method below to using the new method above?

// Toolbar definition for all buttons
Drupal.settings.cke_toolbar_DrupalFull = [
['Source'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker',   'Scayt'],
['Undo','Redo','Find','Replace','-','SelectAll'],
  ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','Iframe'],

'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript','- ','RemoveFormat'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl','-','Language'],
['Link','Unlink','Anchor','Linkit','LinkToNode', 'LinkToMenu'],
'/',
['Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize', 'ShowBlocks'],
['DrupalBreak', 'DrupalPageBreak']


texts: Node paths come through empty unless view result is programmatically changed

texts:
Task: to retrieve a list of nodes in JSON format including their aliases generated by Pathauto module. The configuration of my view is this:

Problem: path fields come empty - they won't include original Drupal path to it nor an alias generated by Pathauto:

The current solution I've got is to programmatically amend view's result in the following way:

function my_custom_views_pre_render(\Drupal\views\ViewExecutable $view) {
foreach($view->result as $value) {
    $url = \Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $value->_entity->get('nid')->value], ['absolute' => false]);
    $url = $url->toString();
    $value->_entity->set('path', $url);
}

}

And that populates the path fields:

I'd like to know if there is a way to avoid the hook and make views return node paths without it, or is it normal Drupal Views behaviour?

P.s.: If I chose "Fields" instead of "Entity" in the Format section in the Views UI, it does return me the correct paths. However I want to get the full entity due to extensive data it consists for later consumption.
Thanks!


texts:
I need to add an ID into a textarea of body field on my custom "node-form.tpl.php". Now this body field will be rendered like this:

<textarea class="text-full form-textarea" id="edit-body-und-0-value" name="body[und][0][value]" cols="60" rows="20"></textarea>

I want to add a ID redHat into the texarea, that output should be:

<textarea class="text-full form-textarea" id="edit-body-und-0-value redHat" name="body[und][0][value]" cols="60" rows="20"></textarea>

To do this i have used hook_form_alter() in my template.php with no luck!

function bartik_form_alter( &$form, &$form_state, $form_id ) {
if($form_id == "article_node_form"){
    $form['body']['und']['0']['value']['#attributes']['#id'][] = 'redHat';
}
}

what i am missing? Thanks


texts:
The Node has attached two terms.

Term::load($node->get('field_posts_category')->target_id); only returns first item. How to get all Taxonomy Term attached to Node?


texts: PHP Fatal error: Call to a member function get_option() views/includes/view.inc on line 2493

texts:
I installed the Carbide Builder Module from SooperThemes and now receive this error when trying to go to any node/add page.

Their support says one of my Views displays has a view with a missing display plugin.

I have a lot of views/displays. How can I find it easiest?

UPDATE: Looks like there are some old Views from a D6 installation uses Feeds.


texts: Error Message: "You must change the sites/all/libraries/mpdf/graph_cache permissions to be writable, as mPDF requires write-access to that directory."

texts:
I'm getting the following error message:

"You must change the sites/all/libraries/mpdf/graph_cache permissions to be writable, as mPDF requires write-access to that directory."

The problem is that it is writable by apache and it has the correct permissions.

drwxr-xr-x.  2 hpadmin apache      22 Jul  2 10:51 graph_cache


texts: How do I send out an email every Monday at 8:00am?

texts: How do I send out an email every Monday at 8:00am using rules?