texts:
I am using Drupal 8 to build a little complex website. Here is an example of what the content is like:

Content Types: Books, Chapters, Paragraphs
For instance a book content type would contain fields to hold author, cover pic, etc. then the chapter will have a link to the related book, and paragraphs will have links to its related chapter and an ordering number.

Now I'd like to have the website to have pages as following:

/books - will show all books by cover photo with links to go to the contents
/books/<book-name> - will show info about a specific book with list of chapters each with a link to go to the content of that chapter
/books/<book-name>/<chapter-number> - Will show all paragraphs in that chapter

My question is can this be achieved just by the view module that is installed with d8 vanilla?
Can I achieve all of this with one view? If multiple views are needed, can they all use the same path structure (/books is common in that case)?


texts: running "drush @remote status" gives "bash: drush: command not found"

texts:
I tried to follow solution here: Why does drush say "command not found" when I try to execute remote commands?

But it did not work for me, the url /usr/local/zend/bin does not exists in my hosting provider.

I can't run any remote command from my local, I dould test the connection doing

drush @remote ssh

and it correctly connects through ssh, so the problem is not in the connection. Please help me with this =( Thanks


texts: How to add a contact link next to the 'submitted by' user info?

texts: I would like to customize the 'submitted by user' section of certain contact types and add a 'contact author' link.


texts: Can't get Corresponding node references to work

texts:
I installed the 'Corresponding node references' module to avoid double editing between nodes that should point to each other (by means of node reference fields). I have followed the instructions to first create nodes with node reference fields and manually editing these fields so that node A point to node B. Then  I checked the box in the modules settings page on admin/config, that indeed showed this correspondance.
But I still have to double edit nodes of these same types. The "other" node is not automatically updated with a reference...
Any suggestions? The site is Drupal 7.42.


texts: Zen theme: understanding the zen grids design in _responsive.scss?

texts:
Below is some of the code from _responsive.scss from the latest release of the Zen theme. It controls the layout of the page. Does anyone know what I have marked 'FROM HERE' to 'TO HERE' is for? I was following the Zen grids method fine until I came across this section of Sass. It doesn't appear in the five column layout, just the three column layout. Thanks

/**
* The layout when there are two sidebars.
*/
.two-sidebars {
  /* Span 2 columns, starting in 2nd column from left. */
  #content {
    @include zen-grid-item(2, 2);
  }

  /* Span 1 column, starting in 1st column from left. */
  .region-sidebar-first {
    @include zen-grid-item(1, 1);
  }

  /* Start a new row and span all 3 columns. */
  .region-sidebar-second {
    @include zen-grid-item(3, 1);

    --- FROM HERE ---

    @include zen-nested-container(); // Since we're making every block in this region be      a grid item.
    @include zen-clear();

    /* Apply the shared properties of grid items in a single, efficient ruleset. */
    .block {
      @include zen-grid-item-base();
    }
    /* Span 1 column, starting in the 1st column from left. */
    .block:nth-child(3n+1) {
      @include zen-grid-item(1, 1);
      @include zen-clear();
    }
    /* Span 1 column, starting in the 2nd column from left. */
    .block:nth-child(3n+2) {
      @include zen-grid-item(1, 2);
    }
    /* Span 1 column, starting in the 3rd column from left. */
    .block:nth-child(3n) {
      @include zen-grid-item(1, 3);
    }

    --- TO HERE ---

  }

}


texts: Strip HTML from trimmed body before it is trimmed

texts:
Teaser display has been set to display "summary or trimmed" at 200 characters but the auto generated trimmed body comes through with image tags, links and all.

I have tried the following in THEME_preprocess_node, but it results in a short trimmed version as it counts the html as characters -> trims to 200 -> removes tags:

if(isset($variables['content']['body'][0]['#markup']) && $variables['teaser']) {
    $variables['content']['body'][0]['#markup'] = strip_tags($variables['content']['body'][0]['#markup'], '<p> <br>');
}

This seems like surprising behavior, is trimmed not normally clean? PS this should ideally not be done in the template file.


texts:
I am trying to make the summary field on the body field have a limit of 40 words.
I have searched on the net so far, and I haven't found any solution.

Do you have any idea on the best approach for this?
The website is live and already has content with summaries, so I can't use a new field to do this.
am working with drupal 7


texts: Collapsible text in Drupal 7 - tried several guides, need for dummies version

texts:
Running Drupal 7.39 and CorporateClean theme and Ctools module installed.

I want to be able to have sections of collapsable text.

I read the following (and some others, which I can't link due to restrictions):
 - How to collapse and uncollapse (toggle) the body field in teaser display?
 - http://timonweb.com/posts/painless-collapsible-divs-in-drupal/

The things I tried do NOT work.

I would appreciate a for dummies version including

which sub-module of CTools I need to enable
if I need to add code, where exactly it needs to go? I know I can't
just paste it willy-nilly.

The old page worked with the following code:

<link type="text/css" rel="stylesheet" media="all" href="/sites/default/files/deflist.css" />

<Title

content

Close

Even if I move the deflist.js and deflist.css into the src path, the old code doesn't work.

For reference, this is the content of deflist.js

$(document).ready(function() {
  $('dl.committee> dd').hide();
  $('dl.committee> dt> a.toggle').click(function() {
    $(this).parent().next().slideToggle('fast');
  });
  $('dl.committee> dd> p.close').click(function() {
    $(this).parent().slideToggle('fast');
  });
});

and this deflist.css

dd img {float:left; margin: 0 10px 10px 0;}
dl.committee dd {height:250px;}
dd p.close {text-align:right; margin-right:20px; font-size:0.85em; cursor:pointer;}
dl {padding:5px 0 0 0; border-bottom:1px solid #E1E1E1;}
dt {padding:0 0 5px 0; border-top:1px solid #E1E1E1;}
dt a {background: url('/sites/all/themes/acquia_marina/images/green-bullet.png') no-repeat left 0.20em;
  padding-left: 1.20em;
  cursor:pointer;}

I'm wondering if the reason would be that the background url above is from the old theme...

I would appreciate any help you can provide.


texts: Adding links to $content['links'] in theme layer

texts:
I know that I can use template_node_view_alter() or template_preprocess_node() in template.php, but the problem is, that some of the information that I can alter there, seems to be processed already. For example:

$variables['content']['links']['node']['#links']['node-readmore']['title']

have some styling informations and a bit of text that is already translated. Is it possible to add a link even before, that structure was constructed? I don't want to overwrite something that was generated by Drupal for specific purpose.


texts: How can I edit the contents of the printable invoice for Ubercart order?

texts:
I need to add some text and a few extra order fields (and user profile fields, if possible) to the printable invoice that is accessed via a link like this: http://mysite.com/admin/store/orders/12345/invoice/print

I used grepWin to find all instances of the phrase "Purchasing Information:" (which is on the invoice), and that phrase was found in two files: uc-packing-slip.tpl.php and uc-order--customer.tpl.php. Unfortunately, changes to those files have no effect on the printable invoice (I tried placing the modified tpl files in my theme's templates/ folder as well as in their original location.

The only way I could get a "reaction" was to change the contents of the file uc_order-invoice-page.tpl.php. However, its contents are merely as follows:

<?php

/**
 * @file
 * Default theme implementation to display a printable Ubercart invoice.
 *
 * @see template_preprocess_uc_order_invoice_page()
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">

<head>
  <?php print $head; ?>
  <title><?php print $head_title; ?></title>
  <style type="text/css">
    .buttons {
      text-align: right;
      margin: 0 1em 1em 0;
    }
  </style>
  <style type="text/css" media="print">
    .buttons {
      display: none;
    }
  </style>
</head>
<body>
  <div class="buttons">
    <input type="button" value="<?php print t('Print invoice'); ?>" onclick="window.print();" />
  </div>

  <?php print $content; ?>
</body>
</html>

I tried adding some of the order fields to that file, replacing <?php print $content; ?>, but it did not work. I suppose if I can find out the source of the "content" that is being "printed", I would be in good shape. Can anyone help?

Thanks!


texts:
I have a view block on my frontpage ('news-block') that displays 3 headings which are links to the 3 latest news articles in my website (content-type = 'news').

How do I display this view block in my Simplenews? Alternative suggestions are welcome. I assume this data will display whatever it is at the time of sending, which is fine.


texts:
I use this code in my form ( buildForm(array $form, FormStateInterface $form_state) ) :

<?php

namespace Drupal\test\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\user\PrivateTempStoreFactory;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\SessionManager;
use Symfony\Component\HttpFoundation\Response;

class TestForm extends FormBase {

    public function getFormId() {
        return 'TESTOLDTONEW';
    }

    public function buildForm(array $form, FormStateInterface $form_state) {
        \Drupal::service('page_cache_kill_switch')->trigger();

    $a['ad_mail'] = [
        '#type' => 'email',
        '#title' => t('Email ID:'),
        '#required' => TRUE,
    ];
    $b['total'] = [
        '#type' => 'hidden',
        '#attributes' => [
            'id' => 'actionsubmitid',
        ],
        '#value' => '0',
    ];
    $c['actions']['submit'] = [
        '#type' => 'submit',
        '#value' => $this->t('Finalize the purchase'),
        '#button_type' => 'primary',
    ];
    $test= [
        '#theme' => 'test',
        '#a' => $a,
        '#b' => $b,
        '#c' => $c,
    ];

    return $test;
    }

    public function validateForm(array &$form, FormStateInterface $form_state) {

    }

    public function submitForm(array &$form, FormStateInterface $form_state) {
        $form_state->setRedirect('test.new');
    }

}

Now I want redirect to a machin name ( for example "test.new" ) that create in routing.yml file . I use $form_state->setRedirect('test.new'); in "submitForm(array &$form, FormStateInterface $form_state)" but not work .

EDITED :

.routing.yml

test.old:
  path: '/test/old'
  defaults:
    _form: '\Drupal\bpay\Form\TestoldForm'
  requirements:
    _permission: 'access content'

test.new:
  path: '/test/new'
  defaults:
    _controller: '\Drupal\bpay\Controller\TestnewController::new'
  requirements:
    _permission: 'access content'


texts: Programmatically disable content translation options in content edit form

texts:
I want to programmatically disable the content translation options located at the bottom of the content edit form (see yellow area in screenshot):

I know that i can disable the revision information options with the following code in a form_alter hook:

$form['revision_information']['#access'] = false; // <--- works

But that doesn't work with the translation options, at least with what I tried:

$form['content_translation']['#access'] = false; // <--- doesn't work

So ideally, how can i disable the whole yellow area?


texts: How can I purge a specific URL from varnish cache without making a curl request?

texts:
I'm programmatically updating images and keeping the same file name. I flush the image styles for the image when I do this, but I'm running into an issue where my image styles aren't being regenerated because the old image style is being loaded from varnish when the attempt to regenerate them is made. I've read (in a couple places, including this related Drupal answer How can I clear the Varnish cache?) that I can clear the cache with a curl request:

curl -X PURGE -H "Host: domain.com" http://127.0.0.1/test.html

How can I use an existing method in the Purge or Acquia Purge modules to clear the cache for a given url, specifically an image style url?

Note: I've seen the purge_queuer_url module, but that is not a viable solution for me.

Update: I don't even think this was happening. I can't reproduce the varnish cache hits at all so I must've been wrong about that. I found a bug elsewhere with the focal_point module that was causing my image styles to not be recreated properly.


texts: Put footer/signature on every blog post?

texts: I'd like to put a canned footer at the bottom of every blog post which has it's own content type.  My blog posts can have comments so I'd like the footer boiler plate to be at the end of the post content but before the "Add new comment" header.  I am NOT talking about a general footer for the entire site.  What's the drupal way to achieve this?


texts:
I'm trying to add 'new' or 'updated' to the links in a Menu, and one of the ways is with AJAX.
But to do that, I need to add AJAX to existing node/page path
following the documentation and various examples,
hook_menu()
successfully adds the scripts and call backs for paths that only exist in the module file

// The page that will run the command.
$items['my-custom-path/trigger-page'] = array(
  'title' => 'AJAX trigger page',
  'page callback' => 'my_ajax_trigger_page',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK,
);

[my_ajax_trigger_page calls add_ajax_js and works with and without clean URLs]

but when I add items for an existing node with a menu path, a page I created, and gave a URL path like 'my-toc-page' does not get registered for the AJAX calls.
nothing happens - the scripts to not load on to the page at all,
and the callbacks silently fail
I have also tried this with a View, with AJAX enabled, but still it does not register

// register script load
$items['test-toc-page'] = array(
  'title' => 'MyTable of Contents',
  'page callback' => 'add_ajax_js',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK,
);

How do you do this on a page that already exists and has content and blocks on it?
No forms, but the links on the page need to be processed.

Using a page template file , I can load the JavaScript files onto an existing page, but the AJAX call backs fail.

Thanks everyone, this is a continuation of my initial question about AJAX on page load.
Existing Page not getting registered by hook_menu to trigger Drupal AJAX on page load


texts:
Writing in to custom.module:

function custom_field($variables) {
  dpm($variables)
}

Returns nothing is it working in a module? And i have devel installed and turned on


texts: How to move comments section out of its parent div

texts:
How can we move or override the placement of the comments in a node. Usually the comment section is placed inside its content div. My aim is to place this comment section out of its parent div which is usually the node content.

        Some Node Contents ...

Add new comment

I have my template overrides

field--comment.html.twig
comment.html.twig
page.html.twig

Inside themes/contrib/mytheme/templates


texts: Displaying parts of main menu in separate blocks

texts:
I need to display my main menu in separate blocks: the first sub-menu in one block, and the following two sub-menus in another block. I'm using Drupal's native menu module and also the nice menus module.

How can I do that?


texts: Need to redirect the homepage to a different url but keep the site live and accessible

texts:
A website built in drupal now client has come back and said the url needs to direct to another address. We want to keep the site up and working for various reasons so how do I go about doing this?

homepage needs to redirect to another site
the existing website homepage needs to be moved to a different page /main or /homepage and accessible only thru the direct link

how do I do this?


texts: Concatenate $base_url and path_to_theme()

texts:
I'm used to write this kind of code in .tpl.php files in order to display images (for instance) :

<?php echo $base_url .'/'. path_to_theme();?>

I wonder if it would be possible to concatenate $base_url and path_to_theme() into one single command/variable ?


texts:
UPDATE: I now see that drupal has a built in setting you can check to add even/odd,first, and last classes to the items in the view. Is there a way I can append another class to the last item using this?

For responsive purposes I was planning on adding the bootstrap .hidden-lg class to the last item in a view. This is in order to display more items when I go from a 3 column to a 2 column view. I did see that there was a style output template for views that iterates through each of the rows (as you can see below) but I wasn't sure how to take advantage of that.

<?php

/**
 * @file
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)): ?>

<?php print $title; ?>

<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>

<?php endforeach; ?>

Unless the only option is to perform some regex on the last item of the foreach statement.

As a heads up, I'm already outputting the content and applying custom classes using a view field output template.


texts: Ecommerce site with square area calculation in price

texts:
I am currently looking to make a shop selling carpets. For this I need to use a system that calculates a price per Square area. I have seen Posts where people are in the same position as I am but had no feedback. Is Magneto the answer or Ubercart Druple 6 or 7. I am a developer with no Drupal experience and I am using this as an introduction to Drupal.

Any advice for the best solution would be much appreciated.


texts: How do I use hook_preprocess_page_title() on a Bootstrap subtheme?

texts:
I've just discovered that Drupal 8 Bootstrap theme doesn't implement all existent hooks.
So, for example, hook_theme_suggestions_page_alter() works, but
hook_theme_suggestions_node_alter() doesn't work.

I'm interested on hook_preprocess_page_title(&$variables) and I wonder if it's possible to incorporate this hook into my custom Bootstrap sub-theme. I have created the page-title.html.twig template and cleared the cache.

I saw https://drupal-bootstrap.org/api/bootstrap/docs!plugins!Preprocess.md/group/plugins_preprocess/8.x-3.x but it seems this is for extending an already existent hook in Bootstrap theme, not for adding a new one.

How do I add hook_preprocess_page_title() in a Bootstrap theme?


texts: What is the need to have the Unicode class?

texts:
Why is it necessary to have the Unicode class?

What does Unicode::strtoupper() or Unicode::strtolower() do that cannot be done just using native the PHP functions strtoupper() or strtolower()?


texts: Change individual file from public to private and vice-versa

texts: Running Drupal 7.  I have two file fields set up: One is public, the other private.  I need to be able to take a file which has been saved as a public file, and switch it to the private file field.  And, vice-versa.  Can someone provide some some advice on this?  Thanks!


texts: Extra fields in 'manage display' for content types

texts:
On my old website, there were extra fields such as 'Author', 'Last modified', 'Tags', 'Post date', 'Read more', 'User picture', and 'Comments' available in the 'manage display' section of content types.

I'd like to have these fields on my new website too, but I really can't remember anymore how they got there. Does anyone perhaps know if they were provided by a certain module?


texts: Taxonomy view representative node contextual filter leads to incorrect results

texts:
I have a view that is outputting incorrectly, perhaps not according to the code, but according to what I need it to do. So, a challenge?

The view lists colors (taxonomy terms from vocabulary 'Color') which have content assigned to them.

View type:      Taxonomy
Format:         Unformatted list
Show:           Fields
Fields:         Taxonomy term: Name
Relationships:  Taxonomy term: Representative node (required)
Filters:        Taxonomy term: Vocabulary (= Color)

The site must display different content depending on which area the user lives in. There is an 'Area' vocabulary, currently with two terms: East (tid = 1) and West (tid = 2).

Because of this, all relevant content types have an "Area" term reference field which can either be set to "East" or "West".

To get this to work, I added a contextual filter for the view.

Type: (Representative node) Content: Has taxonomy term ID.

A fixed value comes from this PHP:

$url = explode('/', $_SERVER['REQUEST_URI']);
$tid = 0;

if($url[1] == 'east') {
  $tid = 1;
} elseif($url[1] == 'west') {
  $tid = 2;
}

return $tid;

Values that don't validate cause the view to be hidden.

The problem: Taxonomy terms with content assigned to 'East' are being hidden from the list. I know that there is content using these 'Color' terms, but they are being excluded.

Here is what I think is happening:

View is executed for path 'domain/east'.
Representative nodes for each 'Color' taxonomy term are selected.
Contextual filter is applied to the representative node for each term - if the single representative node does NOT have the correct value for the URL (eg. 1, 'East' in this case) it is excluded.
Views output displays trimmed results, which are not representative of the actual data.

Does anyone know how I could get it to work properly? I'm hoping to avoid creating views for each area, as later, adding 'North', 'North West', 'South', 'South South East', etc, would get very frustrating. Ideally I'd be able to use a hook.

For example, would I be able to alter the representative node query, to get the contextual filter and change the SQL based on that?

Thanks for reading. :-)


texts: Multiple Registration forms (with unique roles)?

texts:
I have a scenario where I want users to be able to register via the standard registration form and be assigned a role of "tenant". I also need the ability for site administrators to be able to create either "tenant" roles (with unique fields) or "landlord" roles (with their own unique fields and roles).

I've looked at profile2, user role field, and field permissions as possible modules, but I'm unable to see a way of getting this to work. How can I make certain fields required for one role, but hidden for another?


texts: Menu link that uses title from router item's title callback?

texts:
In the user menu, I would like the menu link for the "user" path to use the dynamic link title from the title callback, instead of a custom link title.

I know I could alter this on the theme layer, e.g. with hook_preprocess_menu_link(). But somehow I have the feeling there must be something simpler, that works out of the box..

Any ideas?


texts: Should Text Format: "Full HTML" create a safe value?

texts:
When I am rendering fields I noticed that if the user selects "full html" as the WSYWIG text format on a "long text" field, a safe value is not created.
For example the array would be:

value (String, 14 characters )
test

format (String, 9 characters ) full_html

But if "Filtered HTML" input selected it would be:

value (String, 14 characters )
test

format (String, 9 characters ) full_html
safe_value (String, 4 characters ) test

Settings to Full HTML seem to have no effect.

What controls whether a safe value is created?


texts: How do I make a view page URL be in the destination parameter?

texts:
I have a Views Page and some of the rows contain links.

I want to send the User back to the Views page after clicking the link via the Destination parameter but do not want to hardcode the Views' URL into the link.

Is it possible to use a token in a Views row for the current view URL?


texts: Help with adding different stylesheet to one specific page in Drupal 7 using the template.php

texts:
I am trying to apply a CSS style (games.css) to page--type--games.tpl.php. I am using Drupal 7, and I have created a new content type called "games."

So far, my code works for pulling up the page--type--games.tpl.php, but it has been unsuccessful in applying the CSS stylesheet. This is my current version of the code.

/**
 * Add javascript files for front-page jquery slideshow.
 */
if (drupal_is_front_page()) {
  drupal_add_js(drupal_get_path('theme', 'bluemasters') . '/js/bluemasters.js');
}

function bluemasters_preprocess_page(&$variables, $hook) {
  //some other stuff
  if (isset($variables['node'])) {
    $variables['theme_hook_suggestions'][] = 'page__type__'. $variables['node']->type;
    $variables['theme_hook_suggestions'][] = "page__node__" . $variables['node']->nid;
  }

  if (drupal_get_path_alias("node/{$variables['#node']->nid}") == 'games') {
    drupal_add_css(drupal_get_path('theme', 'bluemasters') . "/games.css");
  }
}


texts: How to use Rules to perform a simple anti-spam validation using specific keywords?

texts:
My site is under repeated attacks by spammers who create accounts manually with nonsense email addresses and "fake" IP addresses (no way to block them).
I came up with the idea of blocking node creation with the Rules module, using data comparison, but it does not work. Here is a summary of the rule I have:

Event : Before saving content
Conditions: text comparison : Parameter: Text: [node:body:value], Matching text: lexapro, etc. [how to make the list of words/expression? One per line?]
Actions : page redirect

Update: starting from the rule in this answer, I created a rule which will redirect to a page and unpublish the node, but only if the words are both in the title and in the body. I've tried to put an OR in the rule, but it didn't work.
{ "rules_simple_antispam" :
  {
    "LABEL" : "Simple antispam",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_presave" : [] },
    "IF" : [
      { "text_matches" : { "text" : [ "node:title" ], "match" : "lexapro" } },
      { "text_matches" : { "text" : [ "node:body:value" ], "match" : "lexapro" } }
    ],
    "DO" : [
      { "redirect" : { "url" : "death-spam" } },
      { "node_unpublish" : { "node" : [ "node" ] } }
    ]
  }
}

What do I need to change in my rule to make it work?
PS: I'm not a coder.


texts: Updating composer autoloader after moving modules

texts:
I have been using composer to install all Drupal modules, when I realized that they had not been installing to modules/contrib. So, I added this into my composer file:
"installer-paths": {
  "modules/contrib/{$name}": ["type:drupal-module"]
}

Then, I moved all modules to /contrib under the modules directory, and rebuilt my cache with drush cr. No errors.
Now I cannot reload the site, I am getting fatal errors about missing modules at their old paths.
How do I clear the autoloader so it gets updated to look in modules/contrib instead of just modules for class files?
Attached picture of the error.
I tried removing the composer.lock file and running composer update - no dice.
Update
Looks like I did everything right, I just needed to reboot the VM to clear the APC cache.
Is there a way I could do that from command line instead of reboot the server?


texts: What causes localized_options on a menu link to be set to (boolean) FALSE?

texts:
I'm having a problem with one of our existing Drupal 6 websites where if you go to Build > Menu > Primary Links it causes 500 error.

The error message is: Fatal error: Unsupported operand types in /var/www/sitename/htdocs/includes/common.inc on line 1632 which is corresponding to the function L which creates links, and particularly the part that says:

// Merge in defaults.
$options += array(
  'attributes' => array(),
  'html' => FALSE,
);

Which basically means, as I understand, $options is set but it's not an array.

So I've further investigated the problem, and dpm'd the menu tree to investigate, and found one link in the tree array to have localized_options set to (boolean) FALSE where all other links had an array as localized_options.

Now I'm wondering where this FALSE could come from, and how to correct it? Obviously I don't want to hack the default menu.module and set a check for boolean, so I'm looking for the proper solution and the origin of the issue.

The link was probably (- because I don't enter the site's content) put in manually through the admin interface, so it's not a custom module hook_menu link or anything. I've tried looking in {menu_links} and {menu_router} tables in MySQL Workbench but I have no idea where the localized_options comes from. It could be on of the serialized data in the table.


texts: Render date field in custom format in tpl file

texts:
In a content type tpl file I can print my date field with the following:

<?php print render($content['my_date_field']); ?>

However I need a custom date format. So instead of something like this:
Sunday, June 9, 2013 - 16:50

I need to print:
June 9th Sunday

I cant change the default date formats site wide or the node's field, I need to just modify how its printed in this instance.


texts: Search result page with tabs and ajax pagination

texts:
I need to create a results search page with those characteristics:

The page will have different tabs (like the bootstrap ones so no page reload), each tab will only shows the relative content type. There needs to be a “all” tab with all the content as well
Each tab needs to have a “load more” button on the bottom for ajax pagination

I can alter the search-results template and having the tabs, but I don’t know how to integrate an ajax pagination on each singular tab by using drupal functions (or using Views Infinite Scroll if it will be a view)

Any hints?


texts:
I've just changed the view of login form to Drupal default view. Now I am not able to log in as administrator.

I have tried to change the password using php .\scripts\password-hash.sh newpwd.  I got an hashed password, I used to update the password stored in the database with a SQL query, but still I am not able to log in. I have also cleared entries from flood table.

Any help will be appreciated.


texts:
I have an image field that is set to link to content. Drupal makes this markup:

Now I need to tweak the markup and add some styling, for example:

I want to add the inline CSS in this way because the page is for emailing.

What would be the best way to do this? I have tried:

Putting the markup into field--myfield.tpl.php and inserting variables, but the $items array doesn't give me clean image file or target URLs.
Using the Custom Formatters module, but it gives me AJAX errors for some reason and not sure it would do the job anyway.
I could use a preprocess function in template.php, but I am hot sure how.


texts: How to show a block on specific pages using the Node ID instead of an URL?

texts:
Using the "Show block on specific pages" on a block configure field, is it possible to use the Node ID in lieui of URL.

I.E.

412 instead of about/contact-us/


texts: Is it possible to assign permission to fields?

texts:
The idea is that one can assign permission to fields just as node types. Evidently this gives great flexibility to webmasters to account for unforeseen requirements.

The advantage seems obvious: one can simply change permission of a particular field instead of defining a new node type and suffer the burden of migrating or re-creating old nodes into new ones. For example one can make an image field only visible to premium members.

I appreciate your hints about this.


texts:
I create a about-us with Basic Page content type, and with path alias aliased it to \about-us( nid = 2),Now in template file I want to get path alias

{{ 'About Us'|t }}

in Drupal 7 I got it with  url("node/2") but what is equivalent in Drupal 8?
what snippet  I have to use to get path alias of nid 2 in template  file ?


texts: Not possible to override js/misc/ajax.js using hook_js_alter in Bootstrap theme

texts:
I am trying to specify another custom ajax.js file in place of js/misc/ajax.js using hook_js_alter(&$variables) but with no success. Upon inspection of the &$variables array, my target file js/misc/ajax.js does not appear there at all and thus it is not possible to override it using HOOK_js_alter(&$variables)

Any idea how to override that file?


texts:
I have written email validation as follow.

if($email != ''){
             if (!ereg("^[_a-zA-Z0-9]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$",$email)) {
               form_set_error($email, t('Please enter a valid Email address.'));
             }
          }

But when i try to register with 'test.byme+1@gmail.com' , Not accepting with '+'. Can any one correct my code..Thanks


texts: Hook_form_FORM_ID_alter to alter views exposed form

texts:
I am attempting to create a function which will alter the exposed form of a view in order to display a certain image instead of the button which says 'Apply'. I have the code below and I could use some help in debunking why it doesn't work.

function ana_zymphonies_form_views-exposed-form-search-content-page-1_alter(&$form, &$form_state, $form_id) {
$form['submit'] = [
'#type' => 'image_button',
'#src' => base_path() . path_to_theme() . '/images/search.png'
];
}


texts:
Ok, DisplaySuite is nice, Views is nice. But, I often find myself doing PHP coding using EFQ to achieve the result I need.

Thing is, dealing with render arrays and field API is a massive pain, especially when so many of the settings can easily be configured using the existing UIs.

So, I'm wondering if there is a module that I've overlooked that would allow me to configure my field settings for entities/nodes, and then just call that field configuration in my code.

Basically DisplaySuite, but for individual fields only.


texts:
I have a content type (a) referenced to another content type (b) by url widget, how can I get the ID of the referenced node (b)?
Thanks.


texts: I need to show users 2 registration forms. 2 different forms with different fields. 1 form for free registration and 1 form with admin approval registration. how can i achieve that?


texts: What is the performance impact of having many modules in D8?

texts:
I like to keep my custom code as separated as possible (in the way it makes sense).
In D7 I know it could be crucial (source) because every module used it's .module file and since module files getting loaded in each request it ended up having heavy page load times.

Since in D8 the .module file is not necessary to have any more, is the situation got better?


texts: Search API module causes server error when saving index fields

texts:
I am very new to Drupal, so please let me know if I'm doing something wrong.

Using the Search API module, I would like to go change some fields of my Node Index. For example, I would like to uncheck the "Title" field so it is no longer indexed for searching. However, the problem arises when I try to save this or any other change to the fields. I get an error page saying "Your browser sent a request that this server rejected, possibly due to security scanner restrictions." and the fields remain unchanged.

Similar posts have given me the sense that the fix may be to uninstall/reinstall the module. But this module is so fundamental to everything I've been doing over the last few days. If I uninstall/reinstall the module, will it erase everything I've done?

Update: I disabled the server and then enabled it and now the index fields are working (yay) but it deleted my search (boo)


texts: Create a term reference with a select list selecting one at a time

texts:
I have a couple term reference fields, one of which allows unlimited values, and one of which allows 4 values.  I'm using Simple Hierarchichal Select as the widget for the unlimited one, and it lets the user select a first value, and then click 'add another item' if they need more.

If I set the other value to a simple hierarchical select widget, it shows 4 rows with no Add another button.  This makes sense, but encourages the wrong behavior for this case -- I'd prefer the user select only one value, but if they need to they can add up to 4.  Having 4 rows from the beginning encourages them to add 4.

I would slightly prefer to use a select list widget for this limited field, but I don't feel confident that users are comfortable with the ctrl-click to select multiple items operation, so I'd prefer a dropdown allowing them to select one at a time, with an add more button.  SHS would be fine too, if I could get it to show the 'add another another item' instead of showing 4 rows from the beginning.

Is either of those operations possible?  Basically I want some kind fo dropdown widget, that allows users to select one value, and require them to click add another item, to add more, up to 4.


texts: Webform required field message on a div instead of input field

texts:
I've created some fancy checkboxes. The original input type checkbox is hidden and replaced with a more designed one . When the required field is not checked and I submit the form there is no javascript message shown because it is hidden.
How can I change this, so the message is shown on the label element.
Below input field is hidden. Click on the  element set the checkbox to checked with javascript.

  I agree
  <input data-webform-required-error="This is a required field" data-drupal-selector="" type="checkbox" id="" name="" value="1" class="form-checkbox required form-control" required="required" aria-required="true">

In hook_form_alter?
If input is of type 'checkbox' and input is required add input is not checked ... add class to ''.
If input is of type 'checkbox' and input is required and input is checked ... remove class from ''.
Something like this?
Need more help for this.


texts:
I'm trying to render a Drupal 8 modal dialog form through JavaScript, so it can appear on multiple pages across my site. In the controller class, I create an AjaxResponse object with an openModalDialogCommand for the modal form. I want to render the modal dialog through JavaScript, so that I can control in which pages it displays.

$(document).ready(function() {
  $('body').append('

');
  console.log(Drupal);
  jQuery('#ao-interstitial-modal').load('/aao_additions/modal_form');
});

This the JavaScript code I write so far, but it renders a textarea in the body tag with the AJAX command object as text inside it.

What do I need to do to render the form as a dialog popup?


texts:
I have a webform, that the user can fill out. After the user clicks on the "submit" button, a new node should be created with the content the user typed in (text, images, ...). The form itself should be multi-step (first page = personal data, second page = content, etc.). I'm not sure if I can use the regular node creation, because I would need to

customize the form
the form should be multi-step

Is this possible?


texts: How to display one image in multiple sizes across the site?

texts:
I would like one image to show in different locations, for example:

Event in the Calendar (Cropped version of the image)
Homepage (if promoted to Front Page - as the full size of the image)

Is this possible using Drupal 7?

Thanks!
Izumi.


texts: How to prevent newline character in textarea

texts:
I'm building a form in a module for Drupal 7 and I want to add a textarea as I would like it to be multiline so that text overflows on the next line, etc. but I don't want users to be able to create a new line if that makes sense. How can I achieve this?

Also, I would like to add a "Select All" button for the textarea and I have followed this article but it doesn't seem to have worked.

I know have the first part of my question solved, but still can't get the "Select All" button working. I have confirmed that the Javascript function does run by adding console.log, but it doesn't do the job. All that happens is the page reloads and no text is selected in the text area.


texts: After moving a module to another folder , i cannot clear reminiscent module paths

texts:
I have moved the contrib module pagerer from

  /sites/my_site/modules

to

  /modules/contrib

It breaks the site as some files are unaccessible

  /platforms/drupal8-development/sites/recherche-dev.univ-amu.fr/modules/pagerer/src/Entity/PagererPreset.php):
  failed to open stream: No such file or directory in require()

i guess i would need to perform a registry rebuild but i don't know how.

drush rr outputs

  The drush command 'rr' could not be found


texts:
Is there a way to render the URL Alias field on the form separately from the print drupal_render_children($form);?

My plan is to render the URL Alias field on top of the form neatly (before the other fields), bcoz right now its in some sort of box like output that is generated by Drupal.

Any help would be greatly appreciated.


texts: Change the code in the module from the front end of drupal

texts: I have created my custom module. Can i edit my module from the from end of drupal rather then going to backend and editing the module. Is there any module for this purpose?


texts: How to disallow selected roles to edit node titles?

texts:
In project I have a content type that the owner only allows to edit some fields. I used the Field Permissions module in order to configure field edit permission and it works fine in fields.

But this module doesn't support permissions for the "TITLE" field. In my project the default users & roles don't have permission to edit title and some fields.

Any recommendations for a solution for this issue?


texts:
I'm new to drupal and I'm trying to create a video contest website. Each contest will have a time limit (Say 1 month). I need the following basic functionality.

Disable upload function after the contest ends.
People can vote during the contest but the total rating should be revealed only after the contest ends.

Is there a module for that purpose ? Or should I create a custom module?

Sorry if this is a silly question. I searched everywhere but couldn't find a solution.

Thanks In Advance.


texts: what are the implications of installing APC on a VPS running multiple Drupal sites?

texts: I have a single VPS running a number of independent Drupal sites. What considerations do I need to make (if any) when installing APC?


texts: I have a content type with fields that I want to customize for my clients to look more professional that it does in the current layout. Is this possible?


texts: Custom Javascript Not Loading On Paginated Pages (Except First Page)

texts:
I am running the following jQuery that affects elements on a page view.

$(document).ready(function($){
    $(".views-field-field-video").click(function() {
        $(this).parent().find("a.cboxElement").click();
    });
});

The code works perfectly, but only on the first page. When I use the pager at the bottom and navigate to any other page, the script does not work. Then, when I navigate back to the first page, the script also fails.

If I reload the page however, it brings me back to the first page and the script works again.

EDIT: The classes I am selecting in the script remains the same on all pages.


texts: User Content with image gallery and text

texts:
i am building a little "show and tell" page, for showing pictures of a room, basically as practice to get into Drupal but the page will be used later.

What i have managed (as it was pretty easy):
1) Generate an custom content type for the room
2) Add fields for the room for the information

But now i got stuck: The users should have the ability to upload multiple pictures within the form (i think pluploads will handle this). The room should then have a gallery for the pictures. How do i add the upload form to the content type and how do i manage to get a gallery in the content type, that shows only the pictures a user added to this post

I tried the media gallery module, but it seems to only have static album pages and can not be embedded in a content type.


texts: How to assign taxonomy menu to a link in main menu?

texts:
I have a side menu, based on taxonomy dictionary with the Taxonomy menu module. But I need to have a duplicate of that menu, that will be a dropdown from one of main menu links. Main menu is manipulated with Superfish module.

I can write a jQuery script, that will manipulate with DOM, but it's crazy

How can I achieve this in right Drupal way?


texts: Use Ajax on Exposed Filter of a View but NOT on the pager of that View

texts:
I'm experimenting with a "page" view, and would like to submit the view's exposed filters via Ajax, but not the same views pager.(I currently have a checkbox "has taxonomy term" filter that has been enhanced by the BEF module.)

Currently if I select "Use Ajax: Yes" in the "Advanced" column of the views settings, both the pager and exposed filter are submitted via Ajax. Is there a way to make it so that only the exposed filter submits via Ajax, and the pager reloads the page with the default "?page=X' GET parameter?

I was thinking I could leave "Use Ajax: No" in the view settings, and then somehow add the ajax functionality to the exposed form, via some hook. (form_alter?) Or maybe add some inline javascript which disables the ajax functionality of the pager? (which isn't even a form.)

Hoping someone could point me in the right path.
(Using Drupal 7 and Views 3)


texts: How to display a view link in another view?

texts:
I’m listing in a view a list of article filtered with taxonomy terms.

The result is like this :

taxonomy term 1
- article A
- article B
- article C

taxonomy term 2
- article D
- article E
- article F

taxonomy term 3
- article G
- article H
- article I

Here is the view configuration :

I’ve also created a view which contains 3 articles and which have the same taxonomy relationship than articles.

I can see this view as a page like this : http://my-site.com/my-view

Here is my view configuration :

I would like to display this view link in the listing :

taxonomy term 1
- article A
- article B
- article C
- link to view A (associated with term 1)

taxonomy term 2
- article D
- article E
- article F
- link to view B (associated with term 2)

taxonomy term 3
- article G
- article H
- article I
- link to view C (associated with term 3)

How can I do that? I can't find a field in view configuration to display this view.


texts: Reuse file uploaded via (File|Image|Whatever)Field in another node

texts: I noticed the existence of this file_usage table in D7's database and I was wondering if it's possible to link in a new node the same file I uploaded using a file field in a previously created node. This seems logical to me, yet I can't seem to find a way to do it.


texts: Show progress of code executed on form submit

texts:
I have a form in my site (custom module) where the user chooses some options and depending on those options, some code is executed.

The code basically executes shell commands on a remote server and at the moment, all the drupal_set_message commands are only shown after all commands are executed.

Is there any way that I can show those messages as soon as each part of the code is executed?

function mymodule_connect() {
    $host = '<my ip address>';
    $username = '<my username>';
    $password = '<my password>';

    $connection = ssh2_connect($host, 22);
    ssh2_auth_password($connection, $username, $password);

    return $connection;
}

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

    $delete_load = $form_state['values']['delete_load'];
    $change_load = $form_state['values']['change_load'];
    $load_number = $form_state['values']['check_load'];

    if($change_load == 1) {
        # DELETE
        # perform some command

        # LOAD
        # perform other command

        drupal_set_message('Deleting. Please wait...', 'error');
        drupal_set_message('Changing load. Please wait...', 'warning');
    } elseif ($delete_load == 1 && $change_load == 0) {
        # DELETE
        drupal_set_message('Deleting. Please wait...', 'error');

        $command = "<some shell script command to send>";

        $connection = mymodule_connect();

        $stream = ssh2_exec($connection, $command);
        stream_set_blocking($stream, true);
        $output = stream_get_contents($stream);
        dpm($output);

        ssh2_exec($connection, 'exit');
        unset($connection);

    } else {
        # do nothing
    }

    # OTHER DIFFERENT SET OF COMMANDS TO SEND
    drupal_set_message('Configuring. Please wait...', 'status');

    $commands = array(
        "<some shell script command to send>",
        "<some shell script command to send>",
        "<some shell script command to send>",
    );

    $connection = mymodule_connect();

    foreach ($commands as $command) {
        $stream = ssh2_exec($connection, $command);
        stream_set_blocking($stream, true);
        $output = stream_get_contents($stream);
        dpm($output);
    };

    ssh2_exec($connection, 'exit');
    unset($connection);

    return t('Success');
}


texts:
one of the web site (in Drupal 7.43) I am looking after (apparently not that well, although updates have always been applied) has been hacked.
There's now extra text in the footer pointing to an Italian escort web site.

The following code is the culprit:

incontri escort milano - ...

(Note that I removed some of the code - that's the 3 dots. And I added dashes to the URL to avoid to point to it).

I don't know what to do to remove it ! :-(
Any help would be appreciated.

Cheers,
L@u


texts: How can I ensure a user field is hidden by default for the logged in user?

texts:
Module X provides a field-definition and attaches it to the user-entity.

Attaching metadata to the user in that way makes for a very convenient way to access it across the site.

However, by default, a logged in user will also be able to both view and edit this data, which is not always desirable.

Is there a way for the same module to ensure that this field is hidden by default?


texts: How to share some content in a multisite?

texts:
I'm working on the Drupal 8 multisite where there is main site and partner sites.

For example partners publish events or news.

I want some content from partner sites to be available on the main site. How can this be done?

What I discovered so far:

sharing db tables seems tricky - there are just to many node tables and their dependencies will likely break.
I could create custom entity but then its not place in "content" (beacause it's not node type) and I will lose nice content handling. but tables are easier to share then.
I could copy the content but then i have copies not the same content (what are possibilities here?)


texts: Is this the right way to do this? Inserting a block into the content body field of a node

texts:
I'm very new to using Drupal 7 and trying to understand the correct way to insert a book navigation menu block into the content field of a node, or any field/block of content into anything for that manner.

Anyways, one solution I have come up with is this:
In field--body.tpl.php

<?php
$block = module_invoke('book', 'block_view');
//render book menu
if($block){
echo'
';
print render($block);
echo'
';
}
?>

I have no idea if this is the proper/orthodox way to do this; I'm pretty sure a better way would be with a pre-process in template.php. Could someone explain/demonstrate how would this get implemented in that way?


texts: logging into development instance of Drupal

texts:
Ive rsynced the directory structure from mywebsite.com to mywebsite.local ( on my LAN)
and copied the DB .
the website mywebsite.local displays the website, but i cant log with the admin user/pw from the production site .
The DB tables look the same to me.  Its a single site and in sites/default/settings.php it points to DB host is 'localhost'
Tailing apache access.log and I can see the .local site is served from localhost

Do I need to change anything else  ?


texts: How do you change the title of a field collection edit form?

texts:
Here is an example edit URL for a field collection I have field-photo-block:

  /field-collection/field-photo-block/65/edit

The title of this page is being set to the title of the field collection. How do I change it to something descriptive?


texts: $pager_total_items giving wrong results count in custom search module

texts:
I am not too sure what happens but in my custom search module, the $GLOBALS['pager_total_items'] count is wrong on the first page.

For example, I search for a term and it will display: Showing 1 - 10 of 77 results and the pager shows 9 pages (when it should show only 8).

Then if I click the pager to go to page 2 (or any other page) the display changes to: Showing 11 - 12 of 12 results and the pager now shows 2 pages (which is right).

In my TEMPLATE_preprocess_search_results function, I use $GLOBALS['pager_total_items'][0] to get the total number of results.

Any idea what could go wrong? Or should I post my complete module code?


texts:
I'm declaring, on my module, a custom theme function:

<?php
function monitor_chart_theme() {
  return array(
    'chart_monitor' => array(
      'template' => 'monitor_chart',
      'variables' => array(
        'container' => null,
        'theme' => null,
        'classes' => null,
        'chart' => null,
      ),
    ),
  );
}
?>

On my tpl I would like to add additional classes that I want to pass when I call the function.
Now I've declared a preprocess functions like this:

<?php
function monitor_chart_preprocess_chart_monitor(&$vars) {
  if ($vars['classes']) {
    foreach ($vars['classes'] as $class) {
      $vars['classes_array'][] = $class;
    }
  }
}
?>

My tpl is this:

<div id="<?php print $container; ?>" class="<?php print $classes; ?>">

If I don't use the preprocess function, "class" attribute of the div has value "chart-monitor", the name of the theme function.

Is there a more elegant way to pass extra variables to my tpl?

Thanks a lot.


texts: Unable to Remove Images with the Media Module

texts:
While working with the Media Module I have noticed that I am unable to remove images/pdfs while under Content >> Media Tab. I first encountered this problem when faced with having to remove duplicate images/pdfs from Drupal. Once removed, the image/pdf still remains with a preview broken icon displaying. On the second attempt in removing the broken image an error message displays. See screen captures below:

System Information:

•   Drupal 7

•   Bartik 7.12


texts:
Hi I am facing a serious problem to list all nodes/subterms under each terms. Let's say I have several terms.

Games
   -> Cricket
   -> Football
   -> Badminton
   -> Tennis
     -> Long Tennis
     -> Table Tennis
   -> Hocky

Here you can see Games is the top most categories and Cricket, Football etc are sub categories. Must note: Tennis has 2 sub categories.

Each last term has some contents. That means Football, Cricket all are have several contents. But Tennis don't have any content. Long Tennis and Table Tennis has contents.

My aim is to show all the 1st level categories (That means Cricket, Football, Badminton, Tennis, Hocky) and then show all content under taxonomy term tree.

Like this below:

Categories:
   -> Cricket
   -> Football
   -> Badminton
   -> Tennis
   -> Hocky

Football:
   How to play Football?
   Football ground measurement.
   What is Football

Badminton:
   How to play Badminton?
   Badminton ground measurement.
   What is Badminton

Tennis:
  Long Tennis:
      How to play Tennis?
      Tennis ground measurement.
      What is Tennis
  Table Tennis:
      How to play Table Tennis?
      Table Tennis ground measurement.
      What is Tennis

Hocky:
   How to play Hocky?
   Hocky ground measurement.
   What is Hocky

I tried with Taxonomy View but no success. Tried to create the taxonomy-term.tpl.php file but I failed to give the display. I have modified the code many times so I can not paste the code here.

I am using Drupal 7 and views 3.

Is there any solution to solve this? Can you suggest me how can I achieve this? I think I am running on some wrong way. Please help me and give some advice to solve the things.

Lots of thanks in advance.


texts: Where is basic documentation for the devel module?

texts: Can someone point me to the basic documentation about how to use the devel module to add and delete nodes, users, etc.? I did not find any links on the project page.


texts:
Is it possible to Insert a view in a content type in drupal 7?
Is so can you help me do that?


texts: How do I know which products have seen other customers when they took a look at the product that I am currently looking?

texts:
I am developing a website with the Drupal Commerce module, and my customer wants me to implement a functionality to allow the purchaser to know which products have seen other purchasers/customers when they saw the same product he is currently watching.

Do you know if any specific module for Drupal Commerce is available, or can I use a combination of modules that have nothing to do with the Drupal Commerce module?


texts: Can blocks created via the admin UI be cached?

texts: I am trying to understand if blocks created using the admin UI can be cached or not? I had a look at the block table in the database and it would appear that the cache value is set to -1 regardless of whether block caching is enabled or not.  So I am assuming that blocks created via the admin UI cannot be cached.  Is that correct?


texts: Fetching user account additional field in views global php

texts:
I want to fetch the additional account field by using global php in Views.
The additional account is shown below:

The code I use in Global PHP output:

<?php
global $user;
$namepsm = strtoupper(str_replace("_"," ",$row->value));
print ($namepsm .  ' ' . $user->field_id_number) ;
?>

I have an error

  Notice: Undefined property: stdClass::$field_id_number in __lambda_func() (line 4

I can use other standard account fields, for example $user->name or $user->$mail.

How can I print the additional account field (field_id_number)?


texts: export views data to text file in the background

texts:
I am using views data export module to generate a text file and that works perfectly. but instead of asking me to save it to my local computer.

What I want to do is save it directly on the server, I would like to run this is the background if possible as large amounts of data take time to generate.
Ideally I would like to run this for each user in the background on cron run so I presume I will need to setup some batch job to run.


texts: How to determine if a View display is being used in a site?

texts:
We have many Views and Views displays. Over 3 years of building the site we have many displays that are not being used. We would like to delete them and clean up the view but are concerned that a display might be used in the site. Is there a way of determining if a views display is being used on the site? I thought of different ways to check this:

A View display that is a Page will have a URL path. Check the path to see if it is working.
A View display that is a block display will be in Managed Blocks. Go to Managed Blocks and see if is placed in any region.
You can look at the view display machine name. And see if there are any twig templates that match that name.
Also do a grep search in our templates for the display machine name to check if it printed in a twig template.


texts: Custom action to create a new entity based on a fields of an existing entity

texts:
There are two entity types on my site: 1) an application for participation (entityform) and 2) a participant profile (node). At first user creates an application for participation. And then site administrator must create somehow a new participant profile and fill its fields from an entityform created by user.

How to create such an action "Create participant profile from application"? The action must be accessible to administrator as a button or a menu tab item on a entityform view page.


texts: node_delete() does not trigger the "deleting content" Rule?

texts:
Due to certain requirements, we are developing a custom module to handle node creation and deletion, using node_save() and node_delete() respectively. However when we add a Rule with the Rules module to perform certain tasks with the events "After saving new content" and "After deleting content", the event "After saving new content" is triggered with node_save() without problem, but the event "After deleting content" is never triggered at all with node_delete(). Anyone has any idea what could be going wrong here?
Thanks.


texts: How to add a condition for an array on an entity query for a config entity?

texts:
I want to execute an entity query on a config entity type. However when I want to add an IN condition on a property which is an array I am getting an error.

For example, I want to retrieve all user roles that have the administer nodes permission:

$query = \Drupal::entityTypeManager()->getStorage('user_role')->getQuery();
$query->condition('permissions', ['administer nodes'], 'IN');
$query->execute();

This gives the following error:

PHP Warning:  mb_strtolower() expects parameter 1 to be string, array given in core/lib/Drupal/Core/Config/Entity/Query/Condition.php on line 166


texts: Help developing a module for managing unzipped files

texts:
I have a content type called resources and one of the fields is a file field where users can upload content such as a pdf, video, docx, swf etc...

What I am trying to do is allow user to upload a zip file and unpack it on the server then let the user select the main file to be displayed.

So for example if someone had a swf file which has videos they can upload the zip then the server will unzip the files and the user can select the swf file as the main file to display.

I have managed to build a module to unzip the file on hook_node_submit, but not sure how to progress this to get the required functionality as explained above.

Does anyone have any suggestions?


texts: I want to import locations from my remote non drupal database. I can't use feed as it does duplication. Is there any custom solution?


texts: Redirect loop after installing SecureLogin module

texts:
I have only just installed the SecureLogin module and after enabling it, I cannot access any user pages or forms that have been configured to enable HTTPS.

I only ever get 310 redirect loop errors.

Edit: I have managed to fix the issue by commenting out the $base_url configuration I had set up in settings.php . Now the site redirects correctly but still shows some unsecured content (styles and scripts from the header mainly).


texts: Data Attribute added to block from Content Type field

texts:
So this is a very complex series of questions. I am brand new to module development (and PHP for that matter).

I have a content type called "Parallax Block" with 4 fields: a title, an image, a selection from a dropdown (Direction) and a body.

My ultimate goal is to have a module set up where every time a content type is generated, it creates a block with the Title and Body fields inside, but with the Direction and Image values placed as data attributes on each of the primary block divs. For example, a block called StackExchange with data-image="/path/whatever/se.png" and data-direction="top-to-bottom".

How can I dynamically create blocks based on the number of a content type, and have new blocks generated every time that a new piece of Parallax Block content is created?

As you can see in my linked module, I have gotten the appropriate nodes and variables from each Parallax Block. I'm trying to figure out how I can loop through and create blocks with dynamic names.

Furthermore, I am having difficulty getting a block template override functional that would be able to print out the appropriate values in the data attribute fields in the template file. How can I get these variables and insert them into each block?

I know that's a lot, so any resources that you can point me to would be a great help.

Here's the module as it currently exists.
https://bitbucket.org/mattcoker/parallax-block/


texts:
The following method not returning any value (true or false).

\Drupal::service('path.matcher')->isFrontPage();

How to check if the page is front or not?


texts: Export views result as json, xml, csv etc?

texts:
In Drupal 7 we had

https://www.drupal.org/project/views_data_export
https://www.drupal.org/project/views_datasource

Can Migrate in Drupal 8 replace these, for example to export view results with Migrate as JSON, CSV, etc?


texts:
How can I prevent a specific node - or a list of specific nodes - being cached server-side in Drupal 8?

I have page that pulls a value out of a $_SESSION variable using a PHP text block, and it is being cached, which is obviously not what I want.


texts:
I found a sandbox module that I want to test.

What should I do to use it on my site?


texts: How to limit the maximum length of the title of a node?

texts:
I have a content type with a title that shouldn't be more then 10 characters long. This title field is read only.

What is the recommended way to limit the length of that title to 10 long?


texts: How to grant userpoints only for modifying nodes last changed at least 20 days ago?

texts:
I am not sure how to go about this. I use the Userpoints module in Drupal 7 to attribute points to users who create nodes ('reviews'). I also want to allow them to gain some points if they supersede or modify an existing node... but only if the previous creation/mod was done over 20 days before.

How can I do this with Rules? Or else, how should I code it manually?


texts: Incorrect unit price and total in line item

texts:
I'm not sure whether this is a bug or not.

As a requirement, my installation has to use Indonesian Rupiah as the default currency. The item in this example is worth Rp. 500.000 (we use period as separator as opposed to comma, and comma is used for decimal mark). As you can see in the attached screenshot, the unit price and the total for the line item are wrong, but the order total has the right number.

I checked other places (such as Drupal Commerce Reports), and I only found the wrong number in the individual order page and the edit page of the said item. I think it adds two extra zeroes for the cents, but the formatting is somehow messed up.

Please let me know if there's a quick patch for this. Thanks.

Screenshot: http://i.imgur.com/p2Wwrfh.png


texts: How to show fields of referenced entity when referencing entity is being loaded?

texts:
I have 2 content types, the first one has an Entity reference fields that references nodes of the second type.

I want to build a view (block) that shows some fields of the second (referenced) node when the visitor loads the node id of the first (referencing) entity.

For some reason I think this may be done really straight forward, but I'm not getting it to work.

A similar question was self-responded for the user who made it, but I dont seem to understand the screenshot he posted. How to use Entity Reference and Views

Another question seems to be answered but It looks to me like it lacks some information, as following that 3 points I cant get my block-view to work. Puilling Information From Referenced Entities to Display/Use In A Custom Content Type?

Any ideas?


texts: how do i alter the file field 'file maximum size upload' value using hook_form_alter in drupal 6?

texts:
In drupal 6 project,I need to alter all file fields 'file maximum size upload' value using hook_form_alter.I have created a custom module and used '#after_build' in hook_form_alter() to alter the default value.

function my_custom_module_form_alter(&$form, &$form_state, $form_id){

if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    // attach our #after_build handler so we can modify cck fields
    $form['#after_build'][] = 'my_custom_module_after_build';
}

}

and the callback function for '#after_build' is

function my_custom_module_after_build($form, &$form_state){
    $fields = filefield_get_field_list($form['type']['#value']);
    if (!empty($fields)) {
        $fields_name = array_keys($fields);
        //dsm($fields_name);
        foreach ($fields_name as $field_name) {
            $value=100;
            $form['#field_info']['$field_name']['widget']['max_filesize_per_file']=$value.'MB';
         }
     }
     return $form;
}

but it doesn't alter the default value.please tell me how can i alter that value?


texts:
I have a web application deployed through Drupal 7.43. I need to modify the has_js cookie that is set by Drupal to make it both Http-only and Secure for a site security review.

What are pros and cons of making the has_js cookie Http-only and Secure?


texts: Drupal 8. Imce module show thumbnails instead of a filename

texts: Is it possibility to show thumbnails instead of a filename in imce file manager? Just not see any options for this..


texts: Creating a loop condition in Rules for Commerce Line items

texts:
Certain products on the site can't be shipped using a certain shipping service as they are classified as dangerous goods.

So I need to be able to loop through all the items in the cart, check to see if the product has is marked as dangerous (field_dangerous_goods on the commerce_product entity), if any of the products in the order are marked as dangerous goods then that shipping service shouldn't be shown to the user.

I've tried with various different rule components to try and create what I need with not even a glimmer of hope.


texts: How do I capture an audit trail of changes made to a view?

texts: What would be the best way for me to log any administrative changes that might have been made on a view? E.g. a new filter added or a field removed. The audit entry should include a user stamp and a time stamp and the change that was made. Doesn't look like any of the conventional options seem to capture this information.


texts: How can I have drupal commerce create a sku and adjust prices on the fly?

texts:
This is something I've done in the past outside of Drupal but I can't seem to figure out how to do this with Drupal Commerce.

I need the ability to do the following:

Allow the user to create parts via category (this could be a taxonomy term with fields like name, image, sku component, description, price markup...)
Allow the user to create a new product and select which parts can be placed on this product.
When the end user is looking at the product page, they will select which parts they want for this product.
When they select their parts the PHP script, on submission, will create a line item with sku comprised of the parts selected and a price made up of the base price of the product + any additional cost per part.

So, for instance, part category A has 5 parts. Standard and 4 upgrades. If the user selects an upgrade from Category A, it will modify the SKU on submission AND update the price based on the markup price of the part's price field.

Anybody following me here? How do I do this? I'll code it myself if I have to, I just need to know where to begin.


texts: How do I display date and time for multiple time zones?

texts: I am webmaster at http://www.archerpoint.com. We would like to display our events in both Eastern and Pacific time. I only know how to control the system time zone or let the user set their own time zone, but I do not know how to display a single time entry as two separate time zones without hacking code or creating and displaying two separate entries, one for each time zone. Is there a simple solution for this?


texts: How to dynamically assign submit hooks to webforms when generating blocks

texts:
in mymodule_block_view I am generating some blocks for my site, depending on configuration data stored in the database. Some of these blocks may have Webform front ends:

$block = module_invoke('webform','block_view','client-block-' . $r['webform_nid']);

At the point above when I fetch the webform, I would then like to attach a custom submit hook to the webform. The submit hook will need access to the values entered into the webform by the user, and also some variables which are available to the block (so would need to be passed through to the webform somehow).

The submit hook needs to be selected dynamically by the block code, it won't be the same every time.

Any help much appreciated.

UPDATE - HOW I EVENTUALLY SOLVED THE ISSUE

As Shawn says in his reply, webform_block_view returns a rendered webform, with no access to $form_state, so there is no way to pass information into the form. Instead, I figured out how to use drupal_build_form from within my module_block_view to generate the webform:

$node = node_load($webform_nid);
$form_state = array();
$form_state['build_info']['args'] = $node;
$form_state['rebuild'] = FALSE;
$form_state['foo']['bar'] = $bas; // block specific info passed into form
$block['content'] = drupal_build_form($webform_name,$form_state);

I then added code into my module_form_alter as per his suggestion, to add the custom submit hook to the form. The submit hook then checks the foo and bar variables passed through from module_block_view and behaves accordingly.

WATCH OUT FOR ...

One thing worth mentioning for anyone reading this page in future, is NOT to use $form['storage'] for storing custom form data when using webforms, as the webform module rather rudely destroys $form['storage']. This took me a long time to discover!

From _webform_client_form_pages_ in webform.module

// Determine what we need to do on the next page.
  if (!empty($form_state['save_draft']) || !$form_state['webform_completed']) {
    // Rebuild the form and display the current (on drafts) or next page.
    $form_state['rebuild'] = TRUE;
  }
  else {
    // Remove the form state storage now that we're done with the pages.
    $form_state['rebuild'] = FALSE;
    unset($form_state['storage']);
  }


texts: Removing user points using rules module?

texts:
I've made a rule to add userpoints by

Add user points rule

Events
1.A node has been flagged, under "MyFlag"

Actions

1.flagged-node:author
 2.Value 1
 3.Point Category General

How do you remove user points using rules?


texts: $page not targetting views block but $is_front is. Need help with trying to solve this in any way

texts:
I wrote this poorly the first time, more succinctly:

I need a custom node.tpl for the same content type in the front page teasers, the node itself, and a views listing of that node in the sidebar on every page. The problem is the front page uses teasers, while the nodes use full view, so I can't edit the markup of the sidebar nodes with just $page or $teaser because they would share the markup with the main content of either page.

The front page uses teasers to display nodes. I want different markup in the sidebar for the "most popular" views block, so I set it to use full view. This works fine on the front page.

The problem is on the individual nodes. I can't target the views block's markup in node.tpl. I made an identical views block with teaser view (because nodes use full view) instead but

<?php if ($page): ?>
<?php if ($view_mode == 'full'): ?>
// Node
<?php endif; ?>
<?php if ($view_mode == 'teaser'): ?>
// Views list
<?php endif; ?>
<?php endif; ?>

doesn't work. The opposite works fine on the front page:

<?php if ($is_front): ?>
<?php if ($view_mode == 'teaser'): ?>
// Node
<?php endif; ?>
<?php if ($view_mode == 'full'): ?>
// Views list
<?php endif; ?>
<?php endif; ?>

I tried <?php if ($page == 1): ?> as well, though I'm not sure if that's used.

Either way, why I can't just use views for everything is because 1. it breaks the AJAX of the rate module. Which is fine in the sidebar, but not on the front page. And 2. I'm using a link from within a field like this:

    <a class="full-link" href="<?php echo $node->field_download_link['und'][0]['value']; ?>">

                <?php print render ($content['field_parent'][0]['#markup']); ?>

                    <?php echo $node->title; ?>

so I can't have all of the "field-" divs, which break the link. If it matters I'm using $block to get the views list, again, to avoid those "field-" divs.

        <?php $block = module_invoke('views', 'block_view', 'sidebar_popular_full_view-block'); ?>
            <?php print render($block['content']); ?>


texts: How do I get 2 separate displays of a view in one page that are displaying contents from two different content types?

texts:
For example, I have a Page view which displays Content Type A Title, Post date and categories. This page will lists out all of the matching contents that this user has published.

Then I created a Block view that displays contents from Content Type B with Title and categories. The similarity between content type A and B is the categories. I want to display the contents of the block under each result in the Page that matches each category chosen for that node.

How would you display this in the view? I have heard of Views Attach or Entity Views Attachment . But the first one is only for D6 while second will probably not work since I'm not using entities ... or am I?

Or can this be done using Panels? How to do this dynamically with the Block view auto populating the Page view with the right amount of results?

I want to be able to display multiple views results for multiple taxonomies in one page. The content types do not have references for each other. But they do share the same taxonomy vocabulary and its terms.

Edit: This is how I want to display the entire page

Page Results Name

Page Result 1: Title    Date Posted     Categories
    Block Result 1 Title     Matching Categories

Page Result 2: Title    Date Posted     Categories
    Block Result 2 Title     Matching Categories

Page Result 3: Title    Date Posted     Categories
    Block Result 3 Title     Matching Categories

...

The Page is populated by Content Type A
The Block is populated by Content Type B

Want Each Block to have 10+ results that matches categories on Content Type A

It's not just placing Block view underneath the Page view. They're embedded together.

Right now, I have the 2 views displaying the correct results separately. But having trouble integrating them together.

Oh and the results for Content Type A should only display contents that the logged in user published. But the Content Type B can be from any author as long as it matches the Categories.


texts: How do I include the result of a token as a parameter for another (custom) token?

texts:
I'm writing a module with custom tokens.

I need a token that generates a hash based on three other tokens: user id, poll id and (poll) option id. The idea is that a user gets links to vote by email and she can vote just by hitting the link, but to authenticate the link I need to generate a unique, checkable hash in it. So I should be able to write a mass mail with tokens that would contain links like

Option text

(I know the tokens are not right, but you get what I mean).

Then I would check if the hash is true for the user, poll and option, and save the vote if true.

The problem is I can't get the token for hash to be computed from the other tokens, I don't know how to go about it. Maybe I don't understand how the 'need-data' field in the hook_token_info function works, or maybe it isn't possible out of the box.

Any ideas?


texts: Now I working on project who need support some external payment systems (not PayPall or Google Chackout). I try search some tutorial/documentation about creation Ubercart payment system, but nothing found. So which way to look or where to start to solve this problem?


texts: Views Search Ignoring Custom Node Access permissions

texts:
I have a hook_node_access function that denies users view access to a page node if the node has a certain tag and they are not an authenticated user.

This is working fine for viewing the page directly but unregistered users can still see the nodes that they should be denied in a views powered search page. When they click through to the page they are denied access.

I was using the taxonomy access control module to do this before and that hid the result from search, I had to disable it because of a conflict with another module.

Is there anything extra I need to do to make views recognise these permissions?

Here's my hook and helper function:

function mymod_page_perms_node_access($node, $op, $account){
  if ($op === 'view' && in_array($node->type, array('page','publication'))){
    $access_level = field_get_items('node', $node, 'field_access_level');
    if (count($access_level)){
      $access_level = $access_level[0]['tid'];

      $accessIDtoRoleID = array(
        '68' => '7',
        '69' => '2');
      if (isset($accessIDtoRoleID[$access_level])){

        global $user;
        $requiredRole = $accessIDtoRoleID[$access_level];
        if (mymod_page_perms_check_allowed_roles_array(array($requiredRole),$user->roles)){
          return NODE_ACCESS_ALLOW;
        } else {
          return NODE_ACCESS_DENY;
        }
      }
    }
  }

  return  NODE_ACCESS_IGNORE;
}

function mymod_page_perms_check_allowed_roles_array($allowedRolesIds,$roles){
  foreach ($roles as $rid => $role){
    if (in_array($rid, $allowedRolesIds)){
      return true;
    }
  }
  return false;
}

thanks


texts: Display all products of a product type in Drupal Commerce

texts:
Right now, I have to add each product one by one. Is there a way to display all the products of a particular product type all at once? Like when using a view to display all the nodes tagged with a certain taxonomy term?
The products have already been created, and just need to be attached to their respective displays.


texts:
In a view I have set up a block to render a Google Maps map, using the Geolocation field module, with some markers from content-type-1. And I have created a geolocation layer to add extra markers from content-type-2 to the map. This all works fine.
But now I want to be able to show either the markers from content-type-1 or the markers from content-type-2. I want the user to be able to decide what to see.
The easiest way would be to use the exposed filter based on content types. But even when I have the inherit exposed filter option turned on in the geolocation layer the output isn't affected by the exposed filter. Creating and exposed filter in the geolocation layer doesn't work because this filter isn't rendered anywhere.
Another option is to hide it using JavaScript something like layername.map(null) should work but I don't have a clue of what the layer name of these layers are.
Is there a way show and hide the output of a geolocation layer view (Geolocation field module)?
Update:
I found out the normal attachment of Views has the same problem as the Geolocation layer view has. I found this thread. And tried to use this patch to change the Layer.php file in the geolocation module but this didn't work.


texts: Inserting search terms into a search input in Drupal 7

texts:
When using Drupal 7, how do I print the current search terms into a search form in a block?

In Drupal 6, I used something like this in my template.php:

$vars['search_keys'] = search_get_keys();

Then, in search-theme-form.tpl.php I had:

<input type="text" value="<?php print $search_keys; ?> name="search_theme_form" id="edit-search-theme-form-1">

But search_get_keys doesn't exist in Drupal 7, so I can't use this method.

Using arg(2) is the only method I've come up with, but that seems a little hacky, because it will break if the URL ever changes.


texts: How to sum value of a field of all entries in a View?

texts:
I have a view that displays nodes. These nodes have a field and I need to sum all values of this field for all entries the view is "displaying"(not only the currently visible entries/current page but all entries that match the current Views filter).

So all I want is to add this information into the Views template file. So I have the view object available. I was trying to get rid of the pager so I could get all results but without any success. I was able to re-run the query and everything I needed beside excluding the pager. Any idea how to do this? I tried to unset the pager, change it to another module('none'), manually set offset, limit and such but still no success.


texts: Referencing logged user and node relations.

texts:
I am trying to solve a problem with no luck:

I have 4 objects in Drupal:

-Company user (role company)
-Mod user (role moderator)
-Node Project
-Node Person (not a user entity)

Company user can add/edit/delete own Project nodes.
Mod user can a/e/d  own Person nodes.

I would love to accomplish next:

Mod can reference (add) Persons to Projects.
Example : Person A, Person B,... (both owned by Mod1 user) can be referenced (added) to Project 1, Project 2, etc. (or unreferenced/removed).

I imagine this as M:N relation, with two extra attributes - status (value 0-5) and author/createdBy (logged Mod1 user) to prevent mod users from editing/viewing others relation entities.

Next level is creating this by Rules module and Rules link module.

Lets have a View with Projects

clicking on a project should display a project page with list of
referenced and unreferenced Persons owned by logged-in Mod user.
Persons list should be clickable (rules link) for adding/removing reference
from actualy displayed project.

I had some progress with field collection module - was able to create relation entities with status, but cannot made it with Rules - dont know how to send two parameters in rule link (project id, person id) and create project page with persons lists (maybe as view blocks with contextual filters?)

Thank for any help, or idea.


texts: Implement parallax effect on Header image from Content type field

texts:
I have a Header image which i can upload per node from my Basic-page Content type. I want to implement this parallax effect, on my Header image section. But I need to add:

.

How do I add data-image-src="/path/to/image.jpg" to the wrapping
? It has to be dynamic and per node you must be able to attach a specific image.


texts: How to use Rules to flag a node on behalf of ALL users who had previously flagged it with a different flag?

texts:
Here's what I'm trying to do:

I have a content type of Question.
Questions have a field that identifies their status as "asked" or "answered".
Questions marked "asked" can be flagged (using Flag Module) as "follow" by users.
When an admin changes the status field of a Question from "asked" to "answered" I would like to flag the Question with an additional flag called "archive" for all the users who "follow" the question.

This is how I set up the rule:

1. Events:
After updating existing content

2. Conditions:
Entity has field (Parameter: Entity: [node], Field: field_question_status)
AND
Data Comparison (Parameter: Data to compare: [node:field-question-status], Data value: Answered

3. Actions:
Fetch users who have flagged a content (Parameter: Flag: Follow, Content: [node]
Provides variables: Users who flagged (users)
LOOP
(Parameter: List: [users]
List item: Current list item (list_item))
ACTION-IN-LOOP
Flag a Content (Parameter: Flag: Archive, Content: [node], User on whose behalf to flag: [users:0], Skip permission check: true)

Here's my problem:

The rule seems to be working for only one user at a time. So if 3 users have "followed" a Question and it is switched to "answered" status only one of the users will have the Question flagged as "archive". I found I can specify an individual user in the ACTION-IN-LOOP (action nested in the loop) by changing the value of "User on whose behalf to flag: [users:0]". If I switch the value to users:1 or users:2 then the rule works for those individual users but not all. The only other option I can think of is to try [users] without any additional chained value, but this gives the error "The data type of the configured argument does not match the parameter's flagging_user requirement." How do I get a rule to flag the node (with "archive) on behalf of ALL users who had previously followed it?


texts: Need help creating a Commerce Order from Commerce Customer shipping profile

texts:
I am looking for a way for our admin users on a Drupal Commerce site to look up customer profiles from previous orders, and upon looking at a specific customer profile, provide a button that allows then to create an order for that customer. This use case is for a call center.

So far, I have tried using Button Field to call a rule component but I have having problems writing the rule.

Looking up previous orders and creating a new order with information for the shipping profile attached would also be a viable alternative.

Any suggestions regarding approach or use of modules would be welcome.

Thanks!


texts:
We are running a multisite Drupal 8 installation in Acquia Cloud platform, which uses AWS.

The site structure looks like this:

/html [main D8 installation]
/html/sites/site1 [D8 multisite]
/html/sites/site2 [D8 multisite]
/html/sites/site3 [D8 multisite]
/html/sites/siteN [D8 multisite]

Is there a way to limit how much data a single site in Drupal 8 can store in its public files directory?

Any help would be much appreciated!


texts: Show list of taxonomy terms, with node's current terms given a class

texts:
My goal is simple: to display a list of taxonomy terms (alphabetically), with the terms on the current node being highlighted by a current css class. I've tried using views of taxonomy term, but I can only get either the full list or the terms on the node to display, and I want something of a mashup.

So for the visual thinkers I want an output of this:

< ul >
    < li class="current" >Blue< /li >
    < li >Red< /li >
    < li class="current" >Rouge< /li >
    < li >Yellow< /li >
< /ul >

I feel like I'm about to have a very "duh!" moment, so please, enlighten me. Seems like this should be simple to do in Views, yet I can't seem to get it and will resort to doing it in the template.php file if I can't find an answer. Thanks for any help.


texts: How to stop the jquery element being added on ajax requests

texts:
I've added a toggle for my superfish menu, it works fine but for every ajax load or colorbox trigger the span is created multiple times. How to fix it???

(function ($){
Drupal.behaviors.customjs  = {
attach: function (context, settings) {
$(document).ready(function(){

$("#superfish-1").before("Menu");
$('#superfish-1').toggle();
 });


texts: To Connect to MYSQL - How to access database array in setting.php

texts:
I need to connect to my database in php file in drupal 7. Each time I move from local server to development server, I have to change my db and host. I have seen setting.php file which have array of database.

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'my_db',
      'username' => 'root',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

How do I aceess this database array in drupal 7 to use it connecting to database

$con = mysqli_connect('localhost','root','','my_db');

Thanks for Help


texts: How can I reliably login by username in hook_form_user_login_form_alter for SSO?

texts:
I'm integrating SSO for one of my Drupal 8 websites.
We have on-premise SSO and getting user details and respective user roles from SSO response.
When I try below code, sometimes it works. Sometimes it is not working, as I couldn't navigate to pages after login.
Response from SSO:

user name, email, roles (Approved roles for this user).

After login, I am able to see admin menu but the login form is still displayed which should not be there for authenticated users.
Main issues:

Not able to navigate to pages as it redirects with anonymous session.
The user login form still displays even though I logged in as admin.

// Used below code in "hook_form_user_login_form_alter"
$user = user_load_by_name($username);
user_login_finalize($user);

$front_page = Url::fromRoute('<front>')->toString();
$response = new RedirectResponse($front_page);
$response->send();


texts: Lightweight way to check to see if another user has a role

texts:
There are lots of examples of seeing if the current user has a particular role. I need lightweight function to see if another user has a particular role.

For comments, I want to highlight comments from users who have a particular role, "Guest Blogger". Using hook_preprocess_comment(&$variables) I can load up each user using:

$user_fields = user_load($variables['comment']->uid);

But this seems rather heavy. All I need to do is see if the user has a role, not load up the entire user object.

Can someone help me out with a function or a query where I pass in the uid and the function/query passes back an array of roles?


texts: Parsing value of a field from content to a webform field

texts: I have a content type named apartments. When i view a content of content type apartments i will give a button for requesting a quote. When clicked on that button it takes to a webform and by default a field value should be filled by that contents title. Please let me know the process of parsing a fields value to a webform field.


texts:
we have an application which was built with drupal connecting to a mysql db. upon go-live we found that the production db is a clustered one and requires us to change our db tables to NDB cluster engines.

Is drupal capable of working with clustered db's and how do we do this?


texts: Views Group by date plus showing newest node

texts:
I have a view of photo nodes uploaded by users and want to group them by post date and user.
That part is pretty straightforward once you patch views. Just set sort by "post date" with "day" granularity and add a username field to group by user and day.

I use "count distinct" for nid to show the number of photos by user. I even used "format plural", "no results behavior" and "rewrite output" to only show a link to more photos if there are more than 1 photos per user. So far so good ...

The challenge I'm having is when I try to show a photo and title. When I add the "title" field with "group results" it's now showing each photo instead of grouping. If I use "max" or "min" it will only show 1 photo per user but now the photo won't match the title.

So, how can I show a photo and matching title for photos grouped by day and user?  At this point it doesn't matter much if the photo is the oldest or newest for that user and day.

thanks!


texts:
This question about podcasting in Drupal 7 recommends the Views RSS iTunes elements module, which hasn't had any commits on the Drupal 8 dev branch since 2014. (tutorial for D7)

The iTunes RSS tag documentation shows that the tags are not very complex, and indeed the iTunes elements module (D7) documentation shows that there are only about a dozen tags that need to be set up for an iTunes-compatible podcast.

So my question is, do any of the additional features of D8 compared to D7 provide a way to configure this with just the modules in core, or am I going to have to code something to generate an RSS feed that meets the iTunes podcasting requirements?

I was hoping to be able to use something like a Views theming template to just rewrite all the tags in the template and publish the feed that way.


texts:
I use Drupal 7 and the Webform module.

How can I know if a form is submitted or not? I need this to show either error messages or success message after form submission in form page.

I prefer not to write a module because I think it is unnecessary to write a module for a very small task.

Some more info to further explain my question:

I already know about the setting for Webform per form. This setting is located "Content > Webforms(tab) > Edit(your form) > Webform(tab) > Form settings" (where you can add the confirmation message or redirect to a Custom URL).
Actually I render my webform in my node--contact.tpl.php and I use the Webform Validation module for my form validations. And with the form_get_errors function I get errors and loop through them and show them. And if submission is successful I show form successful submission message. I just don't know how to detect whether form is submitted or not.


texts:
I'm using the Rate module for voting. When an anonymous user clicks on the voting widget, the user is redirected to a url "user/login-to-rate". I'm also using i18n for localization. The issue with both of these together is that when I'm on a page with the URL "en/my-url" and I click on the voting widget, I'm redirected to "de/user/login-to-rate" where "de" is my default language. Ideally the user should be going to "en/user/login-to-rate" i.e. user selected language should be respected.

Going into details, I find that the rate module calls url() using the following code:

print url('user/login-to-rate', array('query' => $query, 'absolute' => TRUE));

There is no language paramater that is passed, which means the default site language gets selected.

Am I missing something here in the configuration? Has anyone faced a similar problem and can help?


texts: Drush command to show installed modules but not being used?

texts:
In the process of developing a site I inevitably install modules thinking they are the ones I want but they are not. I am looking for drush command to find these modules to disable them and reduce my resource overhead. Can anyone point me in the right direction?

maybe something like [drush resource cleaner];


texts: Cannot delete / re-install sharethis module

texts:
I upgraded my Drupal to the latest version. I also did this with the modules. When I was doing this I got an error for the "sharethis" module. I got a message that told me to upgrade that module myself, so I uploaded the new module files.

But the module isn't working anymore, and when I look at the module-list I cannot find "sharethis".

This is what I see:
ShareThis Block   7.x-2.2   This module creates a custom block for the ShareThis widget.
Vereist: Sharethis (MISSING)

When trying to reinstall the module I get this message:
"Sharethis is aleady installed"

So I can't uninstall/install this module! Also when deleting the directory it gives the same error. (already installed) So I want to delete and re-install a module that's not visible in the module-list.