texts: Calling HttpRequest with Drush produce PHP fatal error

texts:
I created a drush command which call a function which send emails.
When I'm calling this method with the devel help module, the function is called correctly and my emails are sent. But when I tried to call it from a drush command I have this error below :

  Drush command terminated abnormally due to an unrecoverable error.
  [error] Error: Class 'HttpRequest' not found

Here is how I instanciate my HttpRequest class :

// Configuration client Http
$clientHttp = new HttpRequest($url, HttpRequest::METH_POST);

I am working on my local environment with WAMP (PHP 5.2.11).

I will be very happy if you can give me some advice, thanks !


texts: Example of how to configure contextual filters with taxonomy using php arguments to display a view of commerce products?

texts:
Currently I am trying to configure view to display a grid of commerce products that matches a specific taxonomy term. This term is a term reference field in the product display. I also have a view reference field in the product display. Right now I am trying to pass that taxonomy term into the referenced view as an argument.

I am having the issue of grabbing the 2nd argument path in views. I'm using the PHP option of the context filter.

As you can see from the sql statement it selects only the 1st argument, its suppose to select the 2nd one as seen in the contextual filter options. I'm not sure if its a bug in itself or i have something wrong with my code.

screenshot of view: http://prntscr.com/18qy2f

screenshot of contextual: http://prntscr.com/18rn4v

when it is working it should look like this: http://prntscr.com/18rs0i

In this scenario, i made the first argument as 3ds, which gives me the output i want. But on the top scenario where I want the 2nd argument, it still grabs only the 1st argument.

This is what it should look when it works. It takes the 1st argument. http://img844.imageshack.us/img844/4830/lgt7424d.png

it also seems that the TITLE doesnt recognize  %2 or %3. see here: http://prntscr.com/18rx3i


texts: Quick Uninstall/Reinstall of a Custom Module

texts:
I'm working on creating a module and I'm slowly getting familiar with the Field API and what all settings work on various fields and what don't. While I'm doing this, it seems that the only way to update a custom content type is to disable the module, uninstall it, then re-enable it.

Is there an easy way to do this? Right now, it's a somewhat laborious process that requires a handful of clicks to do the same thing over and over. I'm looking for a script or module to handling this very quickly with (ideally) a single click.


texts: Drupal Solr not working with numerical search terms

texts:
So this is quite a strange one:

I have a site hooked up to a Solr instance through Search API. All seems to work fine, apart from a few edge-case issues surrounding searching for content containing numerical characters.

For example, if I have a piece of content called 'Adam ist 23' (I changed 'is' for 'ist' to get around stopwords being ignored), here are the search terms and results:

Search: Adam ist 23
Result: No results found

Search: Adam ist
Result: Adam ist 23

Search: Adam ist 2
Result: Adam ist 23

Search: Adam ist 3
Result: Adam ist 23

Search: Adam ist 2 3
Result: Adam ist 23

It seems to only affect search results where my search terms match the entire numerical value found within the title (or any indexed field, for that matter).

I found a thread on here with a recommendation to make a change to the following line in config.xml, however it did not fix my issue:

I'm at a loss to what's going on here, so any help would be appreciated!

Thanks in advance.


texts: How to display upvoted posts by user in a view?

texts:
I want to display nodes upvoted by user in userprofile page in a view. I have number up/down rate widget with nodes, and user can take back votes by clicking on vote arrows.

I tried this:

Relationship:

node:votes
node: vote results

Contexual Filters

votes:user = -node-votes(user)

Filter criteria

(Vote results) Vote results: Value (> 0)

Problem

first problem is, whenever a user take an upvote back, and upvote again on same node, it duplicates on view result.

second problem = absolute value of vote result in field criteria is greater than 0. and this also brings downvoted posts on this view.


texts:
Is it possible to create a site that has multiple languages available to the user?

Preferably as similarly as possible to asp.net using .resx files (see here http://support.microsoft.com/kb/917414)

Is there any modules you have used that can provide this sort of functionality?

Thanks


texts: How to access the value of a referenced node's field to use it as a Rules action?

texts:
I have a content type A that has a node reference to type B.  Type B has an email address field that I would like to use in a Rules Action.  How do I get the value of a referenced node's fields?

Note: After much searching, I tried the steps Link suggested in Rules: Do action on the field of referenced node, but after adding the Entity has Field condition on my node reference field, there are not any replacement patterns like node:node_reference:field_email, just the normal node:field_email.


texts: How i could save a block that i had called it before with block_load?

texts: I call a block via a block_load function and i do some changes. What i want to save this block with my changes..


texts: What function/method can I use to redirect users to a different page?

texts:
In Drupal 7, I use the following code.

function my_goto($path) {
  drupal_goto($path, array(), 301);
}

What code should I use in Drupal 8?


texts: Is menu_set_active_trail the way to go if I need to change user/* page titles?

texts:
I've had the pleasure of spending a bit of time trying to change the page titles (the one you get via drupal_get_title()) of user, user/register and user/password. It appears that this is doable in a not so consistent manner by either :

Invoke drupal_set_title from e.g. hook_form_user_register_form_alter, but as this form may be added to any other page which already has a title I assume this may come with undesired side effects.
...or change $vars['title'] in a preprocess function, but this doesn't really change the page title. It just changes the $title variable which is injected into the template. Other modules (e.g. metatag) would still use the default title.
...or use hook_menu_alter to set do $items['user']['title callback'] = 'user_title';, and from there set the page title via function user_title. It seems, however, that this does not work as long as there is a menu item in some menu that links to user. In that case, the user page will be given the title of the menu item of the most preferred menu :

menu.inc:

    // Try to retrieve a menu link corresponding to the current path. If more
    // than one exists, the link from the most preferred menu is returned.
    $preferred_link = menu_link_get_preferred();
    $current_item = menu_get_item();

...or use hook_init to invoke menu_set_active_trail from there. This ensures that the active trail is set, and thus that's the trail which will be used unless other modules explicitly invoke menu_set_active_trail_again. The drawback with this one is that some modules (e.g. the user module) will invoke menu_set_active_item and menu_execute_active_handler again - and thus setting a custom page title in this case fails.

Number 1 and 2 is either flawed or has side effects. While 3 seemed to be the way to go it appears that any menu item which links to the current path will override any title which otherwise would be set by the title callback. Number 4 works most of the time, but not when you go to user as a logged in user.

So, I've now implemented hook_menu_site_status to (1) check which path the user is attempting to access and (2) from there invoke menu_set_active_trail with a custom trail so that I override any trail generated by Drupal based on existing menu items (#3 above). This works even if a module calls menu_execute_active_handler again.

Now, although this works, it feels a bit "brute force"-ish. Is this really the way to change a page title when a menu item links to the same page and thus apparently has the last word on what a page title should be?. It feels very convoluted.


texts: AJAX HTTP error occurred while updgrading Drupal to version 7

texts:
I upgrade my Drupal 6 to Drupal 7.
At the last step, I opy all the Drupal 7 files into my main directory.
While I run update.php, at the run update step.
The following error appear.

  An unrecoverable error has occurred. You can find the error message
  below. It is advised to copy it to the clipboard for reference. Please
  continue to the error page

  An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging
  information follows. Path:
  http:// site.com/update.php?op=selection&token=y5Ljf9tW9wL5n0yanpS-ezpQTQb5JJ1wZhLfqRnjShs&id=34&op=do
  StatusText: Internal Server Error ResponseText:


texts: Error during entup when removing a field added in entity_base_field_info

texts:
I am removing a field that was added using hook_base_field_info:

/**
 * Implements hook_entity_base_field_info().
 */
function MYMODULE_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = array();

  if ($entity_type->id() === 'node') {
    $field_definitions['some_field'] = \Drupal\Core\Field\BaseFieldDefinition::create('datetime')
      ->setLabel(t('some  field'))
      ->setDescription(t('description'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE)
      ->setSetting('datetime_type', 'date')
      ->setDisplayOptions('view', [
        'label' => 'inline',
        'type' => 'datetime_default',
        'weight' => 1,
        'settings' => [
          'format_type' => 'html_date',
          'timezone_override' => '',
        ],
      ])
      ->setDisplayConfigurable('view', TRUE)
      ->setDisplayOptions('form', array(
        'type' => 'datetime_default',
        'weight' => 10,
      ))
      ->setDisplayConfigurable('form', TRUE);

    return $fields;
  }
}

I removed the code and ran drush entup I get the following error repeatedly:

drush entup -y
The following updates are pending:

node entity type :
Some Field field needs to be uninstalled.

// Do you wish to run all pending updates?: yes.

 [error]  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '22906-42845-1-0-de' for key 'PRIMARY': INSERT INTO {field_deleted_revision_01c8f04bcd} (bundle, entity_id, revision_id, langcode, some_field_value, deleted, delta) SELECT base_table.type AS bundle, entity_table.nid AS entity_id, entity_table.vid AS revision_id, entity_table.langcode AS langcode, entity_table.compliance_approval_date AS some_field_value, :deleted AS deleted, :delta AS delta
FROM
{node_field_revision} entity_table
INNER JOIN {node_field_data} base_table ON entity_table.nid = base_table.nid
WHERE entity_table.some_field IS NOT NULL FOR UPDATE; Array
(
    [:deleted] => 1
    [:delta] => 0
)

Any idea why this is caused and how one might go about fixing it?


texts: Records with identical uid and timestamp in node_revision

texts: I'm investigating an issue on a D7 site where a handful of node revisions have apparently gone missing. The issue was discovered on 3/5, and I just noticed in my node_revision table that several records were created on 3/4 with the same uid and the same timestamp (1362422613). How is this possible? Might it indicate a MySQL problem?


texts:
Does anyone know if there is a project going on to add Pinterest to Lightbox or Colorbox?

I've been searching for some way of integrating quick share on Pinterest from my website and can't find any modules that work well. Pin It doesn't even work as far as I can tell and Service Links is difficult to figure out.

Plus the solution for Pinning isn't really the same user experience as tweeting a page or sharing on FB. An overlay on an image in lightbox or colorbox would be huge.

I'm just looking for some decent Pinterest solution for Drupal and am surprised I can't find anything.


texts: Send email after term is selected in checkbox in a node form with rules

texts:
I have created a node form which has taxonomy vocabulary Application Status with three terms  represented as check boxes

Approve Masters
Approve Honours
Rejected

What I am trying to achieve is when you select one of the terms a unique rule for each term sends an email for the term that has been selected in the check box.
I have tried numerous setups but cannot get it to work properly. My current approach is

Event:

After updating existing content of type Online Application Form

After saving a new field collection item

Conditions :

Entity is new

Actions:

Send HTML e-mail

If anybody can give me some good advice on how to achieve this I would be most grateful.


texts:
I would like to display a multi value media field and its file type and size in a content type and display it in a table layout. I thought using a view would be the best way to pull the media file type and file size and any references it has using views relations.

The view uses Relations to get the media type and size and uses a Contextual filter - Content ID from URL. Now I am printing the display in a node template like this using Twig tweak.

{{ drupal_view('materials', 'block_1') }}

The table and media values display fine when published on route entity.node.canonical.

But the media values do not display on other routes and tabs like /latest routename entity.node.latest_version and /full routename entity.node.preview. The table markup displays but not the media values inside. I have tried printing the view using the drupal_block method and had the same results.


texts: Views Contextual Filters with Wildcards URLs

texts:
I have a view with two page displays.  The first page uses a contextual filter for the UID, which is provided with a default value for the user that is currently logged in to the site.  One of the fields displays an order ID, and I have a second Global: Custom Text field which displays a link that appends the order ID to last path component of the URL.

The second page display uses a wildcard within the path of page settings, that matches the scheme of the link generated in the first page display.  When the argument is provided in the preview everything works as expected, however when the URL is accessed via browsing I only see a blank page.

Does anyone have any ideas of why this may be happening or have additional information regarding using path wildcard and contextual filters.  Thanks in advance for any possible advice or tips.


texts: During form validation, can you "stash" a form for an end user while they fill out a different form?

texts:
Core of the question

I have a form that might throw a validation error based on the values in other entities on the site.  If a user fills out an entity form and hits submit, they will see validation errors that tell them another entity is in conflict.

I would like to provide the user with an option to update the other entity on the site to clear up the validation issue.  The problem with that, however, is that the user would have to navigate away from the form throwing the validation errors, and they'd then lose their input.

I would like to fix this up without using Ajax, because I think that Ajax will complicate the UI and I'd like to keep javascript out of the equation for now.

Is there a standard non-hackish way to use $form and $form_state in a way that will allow me to just grab the user input and stash it into the SESSION or something so once the user fills out a secondary form, they go back to the original form and their originally input values are still there?

The desired user experience

{Entity A} exists with field data on the site that will cause a
validation error on {New Entity B} add form.
User enters field input into {New Entity B} add form, and hits submit.
My custom {New Entity B} form validation callback checks {Entity A} and
discovers a problem that requires {Entity A} to be edited before
{New Entity B} can be saved.
User does ??? and {New Entity B} $form and {New Entity B} $form_state are "saved
for later" while user goes to {Entity A} edit form.
User updates and saves {Entity A} and is redirected back to {New Entity B} add form.
{New Entity B} add form has the same input values the user already entered, because they were retrieved from a "stashed" {New Entity B} $form and {New Entity B} $form_state.

Is this possible?  How?

Edit

Caveat about uncertainty of form fields

The exact fields on the entity form are unknown.  I want to apply this logic to numerous entity forms, which means I don't know which fields are there in my validation callbacks.  This is why I'm looking to stash $form and $form_state in their entirety.  I don't want to get involved with individual field values.


texts: Can't update migrated taxonomy terms because of langcode

texts:
We have a site that we migrated from Drupal 6 to Drupal 8.  If we try to update (Just edit and save) one of the terms that were migrated over, we get an error "The value you selected is not a valid choice.". If we add a new term we get no errors.

I tracked it down to the langcode field but not sure how to fix. This is somehow added automatically in Drupal.  One thing that I did notice is that in the taxonomy_term_data table, the langcode was blank for the ones that were migrated but the new ones have en.  I updated all to en but the problem remains.


texts: Create a View of Group Posts Who's Group has a Specific Tax Term?

texts:
Hi i hope someone can help me get my head about this. I dont know if im just having a blonde moment though.

I have tax terms added to my 'groups' (blog, betting, diary etc) I was wanting to create a view showing just posts in Groups that have the term 'blog' attached to the Group. The posts in Groups tagged with 'blog' do not have the term 'blog' in the posts so thus they will not show in any views i create. I hope im making sense here as i think im just confusing the issue.

I think i would need some sort of Relationship to create the View Ill try explain again. I only have one Group content type 'Groups'. Each group has a term (blog, betting etc) I want to...bah im just saying the same thing again arent i?...How can i show just my 'Group Posts' whos parent Group is tagged with 'betting' in a view?


texts: How to get "Add another item" option for fields based on taxonomy terms

texts: The goal is to allow an autocomplete field that uses taxonomy terms, and which allows multiple entries from the same taxonomy list – for example a list of names & contact info for a field that allows "add all that apply." This works for a text field configured for autocomplete and "unlimited" values. It also works when the source is the User list. However with taxonomy term lists, the "unlimited values" choice does not produce the usual "add another item" option. Is there a way to resolve this?   (We want to be able to draw from a taxonomy list, to avoid inconsistencies in how a user might enter names and contact info.)


texts: Watermarking an image that is not in the Drupal filesystem using image_style

texts:
I get an image through the ImageMagick PHP extension because I don't want to start the PHP exec() function. This works.

But I'm not managing to create a watermarked image using image_style because this image is not in the Drupal file system.

How can I do this?


texts: How to create a contextual filter to be used as the first character for a field?

texts:
I create a view listing a field called authors the page path miSite.com/authors

Then if I load this page I get the results:

Bach
Vivaldi
Vaccaro
Babbitt

This view page has the path: miSite.com/authors

I need to create a contextual filter to filter the result for the first character of the author field. I should work in this way:

1) If I load:

miSite.com/authors/b

I get the results:

Bach
Babbitt

2) If I load:

miSite.com/authors/v

I get the results:

Vivaldi
Vaccaro


texts:
How can I add classes to a form option tag without JS?  At the moment in Form API I can pass a keyed array like this

array(
  '0' => 'option 0',
  '1' => 'option 1',
)

and I'll get html like this

<option value="0">option 0</option>
<option value="1">option 1</option>

Is there a way to do something like this:

array(
  array(
    'value' => 0,
    'text' => 'option 0',
    'class' => 'bob 0',
  ),
  array(
    'value' => 1,
    'text' => 'option 1',
    'class' => 'bob 1',
  ),
)

and then get this

<option value="0" class="bob 0">option 0</option>
<option value="1" class="bob 1">option 1</option>


texts: Adding metadata to nodes for SOLR search

texts:
We have a website using SOLR search and we've run across an issue. For example, we have a page called "Organizational Chart" but if someone searches for "org chart" it will not appear in search results.

Is there a way to add aliases or metadata to nodes so that we can add "might be searched by" data or extra information that may enhance search visibility?

Would simply adding a cck field accomplish something like this? Taxonomy doesn't really apply because these are not categories and would be different across each node.


texts: How should I display fields for a content type?

texts:
I have a complex content type with several user-defined fields. In Drupal 6, I used Contemplate to display the fields in an HTML table. I've just upgraded to Drupal 7 and I'm wondering how to best achieve this now. The Contemplate project seems to suggest that Drupal 7's field display features are the way to go. But how do I create and populate an HTML table with a node's fields in Drupal 7? Do I extend/override a theme?

Update: To clarify, let's say I have several nodes with the same content type history. How do I display each of these nodes in the same specific way, including some of the user-defined fields I've attached to that content type. In addition, I use the pathauto module to give each of these nodes a path like history/<year>.


texts:
We are using the ECK module where we have created component eck_highlight (machine name). How would we be able to modify the variable array using a preprocess hook?

Eck_highlight component has this field:

Field Reference to content types: basic, article, and event

Goal:

Call the preprocess to store 'info' array to vars (i.e. vars['info']). The info variable will be passed into the Twig template so we can use to output information.

mymodule_preprocess_eck_highlight(&$vars) {
    $vars['info'] += [
       'id' => 'some-id',
       'height' => 'some-height',
       'width' => 'some-width',
       'src' => 'src1'
    ];
}

We have tried to do the following but cannot alter the variables.

mymodule_preprocess_eck_highlight(&$vars)
mytheme_preprocess_eck_highlight(&$vars)


texts: Notify a user if a node has a comment or status updated

texts:
I'm trying to build a simple ticketing system with Drupal 8.6. I'm able to create a content type for these tickets and the comments will be the responses to the ticket. Also I have a status field for open, pending, and closed. I want to be able to email all the users on the ticket if the node is updated or commented on. And I have another user reference field for "assigned ticket to".

What modules would I need that work with 8.6 to get this kind of funtionality? I prefer no modules, but I'm not sure if core itself supports this type of thing.


texts: Will "features" be overwritten when there is a distribution update?

texts:
Example scenario:

I create a site using commerce_kickstart 7x-2.0.
I modify some of the "Features"(ex. commerce_kickstart_user, commerce_kickstart_taxonomy) that are prepackaged with the distribution.

Question:

Will these "Features" be overwritten when an update comes, ex.
commerce_kickstart 7x-2.1 (Not really sure if there is such as a
thing as a distro update. Tried to google, went to issue queues,
IRCs to no avail)
If the answer to #1 is yes,how do you maintain your configurations to the "features" when an update comes? Should they be renamed and moved to "/sites/all/modules/my_features"?


texts: Gmap view: how to only show certain nodes from a list?

texts:
I have a Gmap view that maps markers for all the nodes of a certain content type. Now what I am trying to do is filter the markers by node id. Specifically, I have a list of node id’s that can be different for each user, and I want the map to ONLY show markers for those id’s. Is this possible?

One way to do this would be to use Javascript to remove certain markers from the map after they are already loaded.

Or, perhaps there is a way to create my own custom filter in PHP by hacking the module? If so, where in the module files can I edit the code that creates the array of markers for the map?

(As a further note, i’m fetching the list of node id’s to display on the map from a Parse database object for each user. For example, if Parse returns node id’s 68,70, and 91, how do I map only those nodes?)

Thanks,


texts: I have a view that I have attached a data export view to. I want to change the default orange icon that shows XLS at the bottom of the view, to another button with text "Download View". How can I achieve this?


texts:
I have the following menus

about us
    company
    menu 2
our work
    menu 1
    menu 2
news
contact
jobs

I like to insert an extra li between each top level menus (about us, our work, news, contact, jobs) to make them look like "about us   |   our work   |   news   | contact   |   jobs "

I looked at template.php and I have themename_menu_link, but I don't know how to compare the variable to check if it is a top level menu or not.


texts: Views - PHP error: Allow memory size exhausted

texts:
I'm suddenly experiencing the infamous "PHP Fatal Error: Allowed memory size of XYZ bytes exhausted" (Drupal 7.38)
This happened while trying to save changes to a view: I simply wanted to modify the field display order, nothing more, nothing less.

So, at the moment I can't see my website, even as an anonymous user, and even pages that aren't related to the view. Moreover, I can't access the admin panel.

I know this problem is usually related to module activation or other major changes, but in this case it is only a "minor change", related to an already existing view, a very simple one (and I have others - more complex), so even if I could increase the PHP memory limit, I think this would be only a workaround and not a "real" solution.


texts: I want to duplicate all content into a new enabled language

texts:
I have 5000+ articles that so far were in one language; I want to make a new language available, but it would be very useful to at least create the content by copying the current one with images and texts, then just pasting my translations.

It saves me weeks of work for not having to recreate every node and uploading videos and images.

How can I loop through all nodes of a type in PHP, and to create its translation?
What I want to do is something similar to this pseudo-code:

for ($allnodes as $node) {
   $translated_node = create_node_in_language($node, $lang);
   copy_all_content_from_node($node, $transated_node);
}

I don't know how to use the drupal API to accomplish this, but I'm sure it is possible.

The one issue that can occur is the mandatory fields that have to be filled upon saving a new translation, and which needs to be copied from the original node.


texts: Know if node is in view, edit, delete, etc. in page.tpl

texts:
I need to verify, in page.tpl file, if page is currently showing a node for viewing, editing, or deleting purposes.

I found I can write arg(2)=="edit" to verify if it is in "edit mode", but how to do for delete (arg(2) is empty such as for view).

What is the correct way to get this information?

Thank you


texts: Taxonomy Terms mapping Many to one mapping | Complex

texts:
I have a typical / complex task and need help. this is with related to taxonomy terms and creating many to many kind of relations but without duplicating the terms, please see this excel sheet for sample data

http://demo.bodhtree.com/category-sub-category-mapping.xlsx

any guidance from community is highly appreciated.


texts: Default date field values like "today +10 hours 30 minutes"

texts:
I have a date_field Date (ISO format) as a Pop-up calendar. I would like to have it as a default value: today 10:30
In php the

strtotime("today +10 hours 30 minutes")

serves me well. Also

strtotime("today 10:30 am")

If I put it in the "Relative default value" field, the time gets not parsed. It is always the current time.

strtotime("noon")

or

strtotime("midnight")

has the same effect. Bug? How to get the default date to "today 10:30 am"?


texts:
I want to manage sticky content on front page of website.

I have made five content sticky on top for front page but my query its show by default according to publish date order but I want to fix the order of that sticky content.

Any suggestion or solution about how to do so?


texts: How to prevent Rules scheduled within a month may have an offset that is off by 1 or 2 days?

texts:
I have been using Rules to send out emails to users based on their user role. Based on the role, they should get emails at different times based on an event.

Whenever a rule is triggered in a month with more or less than 30 days however, the offset doesn't seem to work and my scheduled events are one day off. In the case of February (with 28 days), it's even two days off.

I'm assuming this is because after 30 days it calculates it as a month? I'm at a loss as to how to fix this.

These schedules are tied to certain events and should always be triggered a certain number of days after the event start date.


texts: How to create a dropdown list with node ids?

texts:
I need to create a dropdown list box which contains the list of node ids of a specific content type. Then after selecting the node id in the dropdown i need the content of the node to be displayed below the dropdown.

Iam new to drupal. Is there any way to create the dropdown list box with the features...?


texts:
I've setup two MySQL servers with Master/Slave replication for the drupal database and I've confirmed the databases are in sync and replicating.

I am now trying to point drupal to both databases basically for failover/redundancy purposes. That is if I need to reboot our primary database server I don't want our site to go down. (Going read-only is acceptable during failure scenarios)

Based on the following article. I've modified settings.php as follows:

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'sdrupal',
  'username' => 'drupal',
  'password' => 'topsecret',
  'host' => 'masterdb.ptp.local',
);
$databases['default']['slave'][] = array(
  'driver' => 'mysql',
  'database' => 'sdrupal',
  'username' => 'drupal',
  'password' => 'topsecret',
  'host' => 'slavedb.ptp.local',
);

The configuration is fine until I shutdown the master (service mysqld stop) - when I do that my site pukes:

  PDOException: SQLSTATE[HY000] [2013] Lost connection to MySQL server
  at 'reading initial communication packet', system error: 111
  in drupal_is_denied() (line 1895 of /www/includes/bootstrap.inc).
  Additional

  PDOException: SQLSTATE[HY000] [2013] Lost connection to MySQL server
  at 'reading initial communication packet', system error: 111
  in dblog_watchdog() (line 141 of /www/modules/dblog/dblog.module).

Whats the trick to make this work?


texts: How can I access webform submission values from webform-confirmation.html.twig

texts:
I have a webform with Inline confirmation, AJAX enabled and saving of submissions disabled.

Is it possible to access the submitted values from the webform-confirmation.html.twig template?

I know that I can do this by adding token values to the Confirmation message in the WebForm UI. But I prefer to solve this by modifying the template.

My motivation for doing this is that I need to add a javascript snippet after the user has submitted the form. And I want to do it at the template level because I have a larger number of forms where I need to add the javascript snippet.

Cheers

Stian


texts: Which cache bin to clear after changing services

texts: I made some changes to own services and now I get an error about invalid arguments. When I clear all caches everything works fine. I don't want to clear all caches in my production environment. Which cache bin (and how) do I need to clear? I use drupal console. I tried 'drupal cache:rebuild container' but I get a message 'Cache container is invalid'.


texts: How to open accordion when setting error?

texts:
I have custom validation on an element using ['#element_validate'].

But the element is within an accordion item within an accordion and the error doesn't signal to the parent elements to open up when the form is reloaded with the errors.

Is there a way to signal to an elements groups to open up when doing $form_state->setError($element) on an element?


texts:
I experience some difficulties with formalizing a question for Google, so I'm going to post it here and request real human help=)

Are there any systems (modules or smth similar) in Drupal that monitor user activity and detect possible malicious actions? And react automatically?

For example, in some form, a dummy user tries a certain kind of SQL injection. Typing something like " or 1=1 -- or similar. This is obvious that this sort of data cannot be entered be accident. Drupal then detects this:"Ahah, this is going to be something like an SQL injection", then blocks the user IP for a month, for example, and logs all information about this event. Or sends an email to admin: "User @@ possibly tried to carry SQL injection while entering @@ form while doing @@ (situation description goes there) and was blocked for a month. See log at @@"

As I understand Drupal is pretty secure but it's secure in a passive way. I want to get it not only waiting for an attack and process it but also response to this attack. Or at least notify administrator of something anusual and therefore dangerous.

I hope you will understand what I want to get (not necessarily exactly what I mentioned) and extend the scope from my possibly idiotic imaginations to what is really used today.


texts: How do I pass multiple values to the command line?

texts:
My module will be run from the command line.  The Drush command would be something like this:

drush create-denver-type --name="some title" --title="some title" --options="apple" --userid="myid"

--options can have one option or five. I'm using a switch statement and only passing one value through --options. What do I need to do to pass two or three values to --options, for example --options="apple, pear, orange"?

Basing on the values passed in --options, different functions will be called.

When gathering multiple values, how do I pass them to my function, and call the correct functions based on the value passed in --options?


texts: How to display a node page in ctools modal?

texts:
Is there any way to display a node page in the ctools modal.

I have searched for a contrib module but did not find one.

I know the following code will display the content in ctools modal, but can't figure out how to use it for a node.

ctools_include('ajax');
ctools_include('modal');
$popup_content = 'some content;
$output = array();
$output[] = ctools_modal_command_display(t('Confirmation'), $popup_content);
print ajax_render($output);
drupal_exit();

As I have a view displaying nodes with read more link. When I click on the readmore, that node should display in ctools modal.

I know I can figure out a solution for this problem is to create a path like article/% and in the callback I will load the node and will use the above code to display the node content.

But I'm looking for a clean solution, where the readmore should link to node/[nid] in actual but with node alias. and the node page appears in ctools modal.


texts: Filter for landscape format images in views

texts: I am working with Views 3 and Drupal 7 and created a view to display a list of images from a given content type in a slideshow. For layout reasons, images in portrait format don't work. Is there any way to filter for "width > height"?


texts: how to optimize setting theme suggestion for different languages?

texts:
I've been trying to look for a way on how to optimize theme suggestions for different languages. The code below is a snippet of what I have been working on.

One is for english and one is for Spanish. Is there a way I can minimize this into a single code instead of breaking it down for multiple languages?

// Template based on current url
// News Press Room

if ($current_url == '/iom/news-press-room') {
    $suggestions[] = 'page__news_press_room';
}

// News Press Room(Spanish)

if ($current_url == '/iom/es/news-press-room') {
    $suggestions[] = 'page__news_press_room';
}


texts:
I've created a landing page/portal content type and created a series of views for it. However I have run into a problem, i'm not sure how to pass arguments from the urls to the block views on these portal pages.

Basically, if a user goes to http://mysite.com/portal/action I want action which is a taxonomy term to be used as an argument for the block views on the page. Any ideas?

EDIT:
To help clarify I am trying to create a page which pulls in information from other parts of my site based on a taxonomy term, so for example http://mysite.com/portal/action would go to a page which contains blocks displaying things like latest news posts in the action catgeory etc.

So far I have created a content type called portal that lets the author set the topic of a portal and then a series of text boxes to add some custom content to the page.

I then set up a view with a series of displays which creates the blocks that pull in information from other parts of the site such as news, and also turned the custom fields made during the creation of the content type as blocks on that page.

My issue is setting up the arguments within this view so that it changes based on the url. So if i created a horror portal page at mysite.com/portal/horror the content would be those items tagged with the horror taxonomy term.

Hope this makes sense?

Edit 2 Solved:
Thanks everyone for your help. I ended up adding the following code to the provide default field

    if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
if ($node) {
return $node->title;
}
}


texts: How do I access a multistep form using the URL?

texts:
I followed the Examples for developers to create a 5-step form. I want to access the third and fourth step using the URL, so I tried test/page_num/2, but it seems it doesn't work.

Is there any way to access the form for a specific step?


texts:
I'm using Drupal 7, and I have a content type called Book, which consists of a picture and a title. I'm using Views (grid format) to display Books on a page, and it's working great. The only problem is that the titles always sit directly under the picture, which looks bad if the pictures are of different heights. Is there a way to horizontally align all fields within a grid?

This is what I currently have:

_____   _____   _____
|    |  |    |  |    |
|    |  |    |  |    |
|____|  |    |  |____|
title   |____|  title
        title

And this is what I want:

_____   _____   _____
|    |  |    |  |    |
|    |  |    |  |    |
|____|  |    |  |____|
        |____|
title   title   title

I've managed to achieve this by overriding views-view-grid.tpl.php (and adding a new row to the table for each field), but was wondering if there was a better way?

Update: I'm not interested in solutions that involve changing the layout / picture sizes. This is the second time a designer has given me a PSD that leaves me facing this issue, so I'd really like to find a good solution to this exact problem!


texts: drupal_render() and formBuilder's getForm

texts:
What exactly is the best way to accomplish this? I can pass the $form object returned from getForm to drupal_render() and get the correct themed output fragment but the API docs say this function will be deprecated in D9 and to use the renderer service instead.

When I use:

\Drupal::service('renderer')->render($form)

I get

  You have requested a non-existent service "renderer". Did you mean one of these: "render_html_renderer", "html_fragment_renderer",
  "html_page_renderer"?

When I use:

\Drupal::service('render_html_renderer')->render($form)

I get a valid object with a protected content() method, which contains the string, but I can't seem to find any valid public functions to access this.

I can normally use the route builder to point to a form controller that I've created but, in this instance, I just want to pull an existing form, get the HTML content, and display it - hopefully as a variable in a preprocess function. I don't necessarily want to create a block, since I probably won't be reusing it.

What is the best way to do this? Keep using drupal_render() until D9? Can somebody point me in the right direction?


texts:
I'm creating a custom menu in the administration for my module with multiple elements. This works fine by defining the forms, routes and menu links.

How can I create a page like /admin/config for my custom menu? Is it created somehow automatically or do I really need to create a custom page that lists all submenu items in a custom controller?


texts: Can I downgrade to drush 5.x using homebrew?

texts:
I used brew install drush which installed the latest stable version (6.1), when I need the 5.x branch.

This GitHub issue indicates a drush 5.x package was made available for homebrew, but I'm unsure how to install it.


texts: Why do I get "Theme hook ... not found" after renaming?

texts:
I have a module to create and handle surveys. I made a theme originally for it called "survey" and everything worked fine. I am now trying to rename the theme/template to "questionList", but am getting "Theme hook questionList not found" in the logs.

My working code with the theme name "survey" is shown below.

survey.module

 /**
 * Implements hook_theme().
 */
function survey_theme($existing, $type, $theme, $path)
{
    $variables = array(
        'survey' => array(
            'variables' => array(
                'questions'    => NULL,
            ),
        ),
    );
    return $variables;
}

RadioQuestionController.php

    public function getAllQuestions()
    {
        $element['#questions'] = array(1,2,3,4,5);

        $element['#title'] = 'Radio Questions';
        $element['#theme'] = 'survey';
        return $element;
    }

survey.html.twig

{#
/**
 * @file
 * Default theme implementation to print list of questions.
 *
 * Available variables:
 *   - questions
 *
 * @ingroup themeable
 */
#}

Test

The above works fine and prints "Test" to the specified path in my .routing.yml file. However the following does not work.

survey.module

 /**
 * Implements hook_theme().
 */
function questionList_theme($existing, $type, $theme, $path)
{
    $variables = array(
        'questionList' => array(
            'variables' => array(
                'questions'    => NULL,
            ),
        ),
    );
    return $variables;
}

RadioQuestionController.php

    public function getAllQuestions()
    {
        $element['#questions'] = array(1,2,3,4,5);

        $element['#title'] = 'Radio Questions';
        $element['#theme'] = 'questionList';
        return $element;
    }

questionList.html.twig

{#
/**
 * @file
 * Default theme implementation to print list of questions.
 *
 * Available variables:
 *   - questions
 *
 * @ingroup themeable
 */
#}

Test

Is there something that I am missing that I need to change other than what is changed in the above code? Or is there something else going on?


texts: How do I add content type in taxonomy settings?

texts:
In Drupal 6, taxonomy can be added content type.

How do I add content type in taxonomy settings in Drupal 8?

Below is Drupal 6:

Below is Drupal 8:


texts: Entity Reference | View - Display content based on a entity reference field's value that is randomized?

texts:
We are using Entity Reference.

We have a content type "Dog", and a content type "Breed".
In the Dog content type, there is an entity reference field to Breed

We want to have a View that displays pictures and names dogs of a random Breed. If the page is refreshed, it should select a new random breed by which to filter the Dogs displayed.
We are displaying Dogs by Breed no problem, but getting it to load (and refresh) with a Random breed (and populating the Dogs accordingly) is the challenge we cannot yet solve.

I have a feeling we need to use a PHP Contextual Filter to handle this, but not sure what the approach is to make it work properly. Does anyone have any insight here??


texts: Views infinite scrolling loads multiple times

texts:
I'm building a view programmatically, and this is the page info configuration i have to do:

$view->query->pager->total_items = $count;
$view->query->pager->current_page = isset( $params[ 'page' ] ) ? $params[ 'page' ] : 0;
$view->current_page =isset( $params[ 'page' ] ) ? $params[ 'page' ] : 0;

$view->query->pager->options[ 'total_pages' ] = ceil( $count / 8 );
$view->total_rows = ceil( $count / 4 );

$view->items_per_page = $view->query->pager->options[ 'items_per_page' ];
$view->query->pager->update_page_info();

The problem is i had to add an infinite scrolling to the view so i used views infinite scroll module, but it's not likeing the way i'm making these settings.

If i say the current page is 0 then the first page is loaded twice and at the end it's not loading all the data.

Could someone point me to the right direction to adjust these settings? Or any idea on what i could do to make this work? It would be much appreciated.


texts: drupal_get_path() not working in subdirectories of my site

texts:
So I'm using drupal_get_path() within a block to reference an image in my themes//images directory.

And this works. At the root and all first level pages. example.com, example.com/about, etc.

However, if I am on a page such as example.com/about/csa:

Instead of continuing to output the filepath as /sites/all/... it outputs the file as //sites/all/...

This only happens when I'm in a subdirectory of the site.

Does anyone know why this might happen?

EDIT:

<?php $src = drupal_get_path('theme', $GLOBALS['theme']) . '/images/carrots.png';
echo '<img src=' . $src . ' alt="carrot background image" >'
?>


texts:
I'm using Drupal 7 with views 3.

I am listing the fee of students in a view developed using views 3. How can I show the total of fee for all records displayed at bottom as Total Fee. I tried Views_calc module, but this module is with some errors and notices.

Thanks in advance for your help.


texts: how to get email of welcome messge with drupal 7?

texts:
After creating new account with Drupal 7 I am getting the message.

  Thank you for applying for an account. Your account is currently
  pending approval by the site administrator.In the meantime, a welcome
  message with further instructions has been sent to your e-mail
  address.

But when I check my email account I am not getting that welcome email.


texts: what POST values are required to update nodes containing CCK Date fields via cURL?

texts:
In brief:

I am tasked with maintaining a Drupal based site but can only access it via the web.

I have several hundred nodes that are incorrectly formatted/missing content
I wrote a class to simplify batch create and update activity via cURL and can successfully update moderately complex content types
I cannot update nodes that have date fields and recurrence, when I try, the return is the form you'd find at /node/$id/edit with the fields populated with the same values I tried submitting and with this error:

An illegal choice has been detected. Please contact the site administrator.
An illegal choice has been detected. Please contact the site administrator.
The UNTIL value is required for repeating dates.

I also cannot create a new node of any type that has a date field.

I am assuming the problem has something to do with the date fields. Pages, which do not have a date field, update without complaint.

The default values I'm submitting, in addition to taxonomy, cck text fields, the standard title and body, and identical start and end month/day/year values and are:

"field_date[rrule][FREQ]" => "NONE",
"field_date[rrule][UNTIL][tz]" => 'America/New_York',
"field_date[rrule][UNTIL][all_day]" => 1,
"field_date[rrule][UNTIL][granularity]" => 'a:3:{i:0;s:4:"year";i:1;s:5:"month";i:2;s:3:"day";}',
"field_date[rrule][exceptions][EXDATE][0][tz]" => 'America/New_York',
"field_date[rrule][exceptions][EXDATE][0][all_day]" => 1,
"field_date[rrule][exceptions][EXDATE][0][granularity]" => 'a:3:{i:0;s:4:"year";i:1;s:5:"month";i:2;s:3:"day";}',
"field_date[rrule][additions][RDATE][0][tz]" => 'America/New_York',
"field_date[rrule][additions][RDATE][0][granularity]" =>'a:3:{i:0;s:4:"year";i:1;s:5:"month";i:2;s:3:"day";}'

All of which were found in the POST values sent when manually saving one of these nodes both with and without changes.

I've been banging my head against the wall on this one for a couple of days now. Can anyone tell me what I'm doing wrong?

Thank you.


texts: Contextual filter with group ID and group name

texts:
I have a page view which is currently using a group id as a contextual filter. This is working. However, I am trying to achieve a 'friendly url', so the url should contain the group name, rather than the group id.

For example:

[Current] /b/%groupId/test - contextual filter using group id
[Ideal] /b/%groupName/test - contextual filter using group name

Alternatively, if this is not possible, then I would like to know if its possible to include the group name - as well as the group id, in a similar way to how Stackoverflow.com urls work, where there is an id, and human-friendly/seo url that contains the subject of the post. In this case, the group name can be ignored by drupal as it is only needed for SEO - and not for routing.


texts: How to use owl carousel in custom module?

texts:
I am trying to call Owl Carousel from a custom module, but despite the short description of how to do that on https://www.drupal.org/node/2412689, can't figure out.

I could use Views, but then I need to call either list of nodes or node fields, but in this case, I have several items which need to be rotated in a variable. I could put them into array if the implementation requires it.

So basically my question is:

Given a list of items in a variable (or array) how can I rotate them using the Owl Carousel module?


texts:
In mytheme.theme file I have:

function mytheme_preprocess_page(&$variables) {
      $variables['logopath'] = '/' . drupal_get_path('theme','mytheme') . '/logo.png';
}

In my menu--main.html.twig I have:

<img class="img-responsive" src="{{ logopath }}" />

But it's not printing my logo? The src is still empty?


texts: Meta tags on taxonomy term pages not showing(using views 3)

texts: I have installed Meta tags module, configured it, working well, but on taxonomy term pages: meta description, and meta keywords not showing. I am using Views to override taxonomy term pages. I tried to set some random words for test purproses(not even tokens), but it's still not working. Anyone encountered this problem?


texts: Conditions for using mail.css with drupal_mail()

texts:
Problem

I'm trying to style an email sent with drupal_mail. Sometimes it works, other times it doesn't and I can't work out why.

I'm running mail system, SMTP and mimemail:

Mail system sets up: SMTP for sending and mimemail for styling.

In the mimemail options include stylesheets is disabled because it's found mail.css in my theme. Mime mail CSS compressor is enabled because people use hotmail and gmail.

Condition 1

User uses form to send email, this works as expected I receive a styled email in gmail.

$message = drupal_mail('module_1', 'notify', $email, language_default(), $params);

function module_1_mail($key, &$message, $params) {
    $title = check_plain($_SESSION['title']);
    $message['headers']['MIME-Version'] = '1.0';
    $message['headers']['Content-Type'] = 'multipart/mixed; text/html; charset=UTF-8; format=flowed;';
    $message['subject'] = t('Email subject plus ').$title;

    $message['body'][] = "Body text goes here";
    $message['params']['attachments'] = $params;
  }

Condition 2

The user uses another form which schedules a rule action which sends an email some time later. This doesn't receive any styling despite seeming identical for all intents and purposes.

$message = drupal_mail('rules_module', 'notify', $user->mail, language_default(), $params);

function rules_module_mail($key, &$message, $params) {
    $message['headers']['MIME-Version'] = '1.0';
    $message['headers']['Content-Type'] = 'multipart/mixed; text/html; charset=UTF-8; format=flowed;';

    $message['subject'] = t('Here is a (@location)', array('@location' => $params['location']));
    $message['body'][] = 'This is some body text';
  }

Could rules somehow affect the calling of a stylesheet? Am I missing something obvious?


texts: How do I programmatically render a view with contextual filters?

texts:
How do I programmatically render a view with contextual filters in Drupal 8?

In Drupal 7, I generally use the following code.

$view = views_get_view('test_view'); //test_view is the view machine name
$view->set_display("block"); //block is the view display name
$view->set_arguments($tid); //$tid is the argument to pass
$view->pre_execute();
$view->execute();
$content = $view->render();

Is there any alternative way to achieve this in Drupal 8?


texts: Cloudflare country code for language negotiation

texts:
Cloudflare.com provides CF_IPCountry http header.
This can be retrieved in php with

$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];

as they say. It'll return XX if the country cannot be determined.

How can this header be used to negotiate language?
(I want to use it so that if users come for example from France, then to be redirected t www.site.com/fr/ homepage, and if they come for any other country in the world go to www.site.com/en/ homepage?)

My research:
There are 2 modules for Drupal 7, but I don't think they can do what I want.

One module is http://drupal.org/project/ip2locale, which is dev version and not updated for a year, and the other is http://drupal.org/project/smart_ip, which says it breaks caching because it adds session variable.
They both don't use cloudflare as source of ip.

Is there any php snippet that I can add somewhere, so that $_SERVER["HTTP_CF_IPCOUNTRY"] takes me to the locale I want?

If you ask me why I want to use cloudflare header, I suppose that maybe it's faster to determine country and more updated with ips, than other free solutions.

Thanks


texts:
Im in drupal 7, i need to make a select with many options, depends of the option taken, in a textarea will be loaded several values in a string.

After hours of test i come here for help.

Im working on a basic page:

function ajax_load_all_admins($form, &$form_state) {
    $form = array();
    $form['changethis'] = array(
        '#type' => 'select',
        '#options' => array(
            '' => '',
            '1' => 'Cargar todos los admins'
        ),
        '#ajax' => array(
            'event' => 'change',
            'callback' => 'ajax_load_all_admins_callback',
            'wrapper' => 'listaCorreos-div'
        )
    );

    $form['listaCorreos'] = array(
        '#type' => 'textarea',
        '#prefix' => '
',
        '#suffix' => '
'
    );

    if (!empty($form_state['values']['changethis'])) {
        $payments_list = db_query('QUERY WORKING WELL');

        $value = '';
        foreach ($payments_list as $payment) {
            $value .= $payment->admin . ',';
        }
        trim($value, ',');
        $form['listaCorreos']['#default_value'] = $value;
    }

    return $form;
}

function ajax_load_all_admins_callback($form, $form_state) {
    return $form['listaCorreos'];
}

$form = drupal_get_form('ajax_load_all_admins');
print drupal_render($form);

The Ajax call is working but i only recibe:

0: {command:settings, settings:{basePath:/, pathPrefix:,…}, merge:true}

No other one position.

I think it can be for the drupal_render, but dont know why?

Thanks in advice.


texts: how to extend ctools functions in my own js file?

texts:
I am trying to extend the ctools model functions in my JavaScript file but not getting the exact way.

In ctool model.js contains modalContentClose = function(){close(); return false;}; which I want to override in my JavaScript file to add more functionality.

I have tried to use the following code, but it doesn't work.

function extends modalContentClose() {
  // Some alert here.
}


texts: Empty field collection in hook_node_presave with entity_metadata_wrapper

texts:
I have a node with a field type field_collection which has 2 items:

$node->field_field_collection['und'] = array(
  0 => array('value' => 1),
  1 => array('value' => 2),
);

on the save node drupal fire hook_node_presave:

/**
 * Implementation of hook_node_presave.
 */
function mymodule_node_presave($node) {
  $ewrapper = entity_metadata_wrapper('node', $node);
  $wrapper_counter = 0;
  $node_counter = 0;
  foreach ($ewrapper->field_field_collection->getIterator() as $delta => $fc_wrapper) {
    $wrapper_counter++;
  }
  foreach ($node->field_field_collection['und'] as $key => $value) {
    $node_counter++;
  }
}

after runing code

$wrapper_counter = 0;
$node_counter = 2;

what am I doing wrong?
I want to walk the field collection using entity_metadata_wrapper.

Drupal: 7.34
Entity API: 7.x-1.5
Field collection: 7.x-1.0-beta8


texts:
I've a custom callback with a form which works well in last chrome and last FF.

$form['foo']['bar'] = array(
  '#type' => 'submit',
  '#value' => t(''),
  '#attributes' => ['class' => array('search-api glyphicon glyphicon-refresh btn-primary')],
  '#ajax' => [
    'callback' => '::fetchApiData',
    'event' => 'click',
    'effect' => 'none',
    'progress' => [
      'type' => 'throbber',
      'message' => NULL,
    ],
  ],
);

However, my customer has a old version of firefox, the esr 45.9.0 version, and when we click on the button that trigger the callback, we have an alert error.

  An error occurred while attempting to process
  /declaration?ajax_form=1&_wrapper_format=drupal_ajax: invalid regular
  expression flag a

Does anybody know how to debug this?


texts:
When reading the documentation for the Drupal class, I notice the following sentence:

  This class exists only to support legacy code that cannot be dependency injected. If your code needs it, consider refactoring it to be object oriented, if possible. When this is not possible, for instance in the case of hook implementations, and your code is more than a few non-reusable lines, it is recommended to instantiate an object implementing the actual logic.

The example code that uses a service in a hook implementation, is the following one.

 // The preferred way: dependency injected code.
  function hook_do_stuff() {
    // Or, even better, rely on the service container to avoid hard coding a
    // specific interface implementation, so that the actual logic can be
    // swapped. This might not always make sense, but in general it is a good
    // practice.
    Drupal::service('stuff.doing')->doStuff();
  }

  interface StuffDoingInterface {
    public function doStuff();
  }

  class StuffDoingClass implements StuffDoingInterface {
    protected $lockBackend;

    public function __construct(LockBackendInterface $lockBackend) {
      $this->lockBackend = $lockBackend;
    }

    public function doStuff() {
      $lock = $this->lockBackend->acquire('stuff_lock');
      // ...
    }
  }

The code is still using the Drupal class.

Should my code use the Drupal class? Are there any methods of that class I should avoid using in Drupal 8 code written from scratch?


texts: How can I transfer votes to nodes selected from an entity reference list?

texts:
I create a form where users can submit their opinion and votes about nodes that they select from an entity referenced list.
How can I assign the votes to the entities that apoear on this list?

eg.
"Review" content type are completed by auth users.
In "review" form there are 2 fields "class" and "teacher" where the user can select from an list of nodes "class" and "teacher" content types. After the user select the "class" and "teacher" then must vote (voteapi & rate) and complete an opinion (textarea) about the nodes he selects.


texts:
I need to add a single span inside of the list items of a views pager. This needs to be there even when the list item doesnt contain a link (when you are on the current pager's page).

I cant see any tpl files for doing this (my preferred method as im more of a themer.)

Ive looked for a theme override and ive found the following. The problem is that I cant figure where I would add the span.

function theme_views_mini_pager($vars) {
  global $pager_page_array, $pager_total;

  $tags = $vars['tags'];
  $element = $vars['element'];
  $parameters = $vars['parameters'];

  // current is the page we are currently paged to
  $pager_current = $pager_page_array[$element] + 1;
  // max is the maximum page number
  $pager_max = $pager_total[$element];
  // End of marker calculations.

  if ($pager_total[$element] > 1) {

    $li_previous = theme('pager_previous',
      array(
        'text' => (isset($tags[1]) ? $tags[1] : t('‹‹')),
        'element' => $element,
        'interval' => 1,
        'parameters' => $parameters,
      )
    );
    if (empty($li_previous)) {
      $li_previous = "&nbsp;";
    }

    $li_next = theme('pager_next',
      array(
        'text' => (isset($tags[3]) ? $tags[3] : t('››')),
        'element' => $element,
        'interval' => 1,
        'parameters' => $parameters,
      )
    );

    if (empty($li_next)) {
      $li_next = "&nbsp;";
    }

    $items[] = array(
      'class' => array('pager-previous'),
      'data' => $li_previous,
    );

    $items[] = array(
      'class' => array('pager-current'),
      'data' => t('@current of @max', array('@current' => $pager_current, '@max' => $pager_max)),
    );

    $items[] = array(
      'class' => array('pager-next'),
      'data' => $li_next,
    );
    return theme('item_list',
      array(
        'items' => $items,
        'title' => NULL,
        'type' => 'ul',
        'attributes' => array('class' => array('pager')),
      )
    );
  }
}


texts: Multilanguage setup breaking View results layouts

texts:
Background:

We're trying to setup multilanguage options on our site (to allow English/Welsh options). We're using the Internationalization module primarily, with the language detection set to URL.

The problem:

The static content pages work fine, but when a page containing views is translated it seems to break the order and div styling of the Views results.

Any ideas what might be causing this (e.g. have I missed a setting in the Block/View somewhere to apply a div style to the translated version of the page)?

E.g. see below - in pic 2, the results are wrongly shown single column rather than in a 4 column grid, and are displayed before the rest of the main content rather than after):

Comparison of default (www.../resources) and translated (www.../cy/resources) page layouts


texts: How to get contextual filter in hook_views_query_alter or hook_views_pre_execute?

texts: I want to alter contextual filter before executing the sql query of views. Is there any way to get current contextual filter in hook_views_query_alter or hook_views_pre_execute? Or which is the better hook to alter contextual filter for views?


texts: Better Exposed Filters Secondary Options Hierarchy

texts:
I can't find where to set the hierarchy for filters under "Secondary Exposed Form Options". I can do it without ticking the "Secondary Form" box, but after setting it it seems to get overridden.

Right now this is what I have:

Despite my fields being ordered like this;

Content: Has taxonomy term (exposed) | Settings
Content: Author uid (exposed)
Content: Post date (exposed)

Can anyone help me out with getting this ordered properly?


texts:
What is the best approach of having a single language non-English site? I am thinking of performance mostly.

I dont want prefix or suffix in urls. I dont preferably want entity language (Language neutral possible in D?)

Adding a second language, deleting English? Will this have implications?


texts: Autocomplete Widget for Hierarchical Taxonomy

texts: I would like to be able to use a widget along the lines of active tags autocomplete that would allow me to maintain a taxonomy hierarchy. I need to be able to select multiple terms, including multiple children for one parent. Any recommendations?


texts: "Authored by" field to be automatically filled

texts:
On every creation of a node or edit of a node I need the "Authored by" field to be automatically populated with the username of anyone saving changes.

any ideas how I can do that?

Thanks.


texts:
Is there a module that take a custom menu and show it like Admin menu?

I want to create my custom menu and then display it like admin menu (only for some roles).

I've tried some modules but:

Admin menu does not allow to select which menu should be displayed, and however I want to display default menu for Administrator and a custom menu for "editors" and other custom roles
Superfish or Nice menus does not allow to place the menu in top of page, like Admin menu does

Another solution could be a module that place a block in top of page, fixed, so I could use a "simple" superfish menu, but I have not find something like this.

The main question is that I can't use the "default" management menu, but a custom menu.


texts: Check content type of node in preprocess hook

texts:
I have a series of variables I want to make available on twig templates for specific content templates.

In MYTHEME.theme I have:

function MYTHEME_preprocess_node(&$variables) {

  if (isset($variables['node'])) {

    $mycustomblock = \Drupal::service('plugin.manager.block')
      ->createInstance('myblock', []);

    $variables['mycustomblock'] = $mycustomblock->build();

    $headertext = \Drupal::service('plugin.manager.block')
      ->createInstance('headertext',
        [
          'text-align-submit'  => 'right',
          'uppercase-submit'   => TRUE,
          'header_size'        => 'h4',
          'header-size-submit' => 'h4',
          'grid-size-submit'   => 6,
          'header-title'       => 'This is a test',
        ]
      );

    $variables['headertext'] = $headertext->build();
  }
}

This allows me to use {{ headertext }} and {{ mycustomblock }} in content type templates like node--contenttype1.html.twig and node--contenttype2.html.twig. But I'd rather not build the 'headertext' and 'mycustomblock' variables for every single node type when I only need each one for one content type. It'd be nice to have a switch or if statement that checks which content type it is before generating a variable with a block.

Is there a way that I can check the content type of the node?

I've tried

$type = $variables['node']->type;

But that did not work.


texts: How to programatically change image style of images gathered by view?

texts:
I have a view that collect fields of some content type and one of those fields is image field. I can set image style for that image from view editing page and that image in every row will have that same image style.

Now I need to set different image style for some rows. I.e. first row image should have style "ep1", second "ep2" and third and fourth "ep3".

What I tried so far is pre-processing image field like this:

function hook_preprocess_views_view_field(&$variables)
{
  $view = $variables['view'];
  $field = $variables['field'];

  switch ($view->id()){
    case 'view_id':
      switch($field->field) {
        case 'image_id':
          $rowIndex = $variables["field"]->view->row_index;

          $variables['field']->options["settings"]["image_style"] = 'thumbnail';
          break;
      }
      break;
  }
}

This way I can collect row number, but setting this "thumbnail" style is not working. On front-end I'm still getting image style set from view.

Then I tried preprocessing image formatter like this:

function cr_common_preprocess_image_formatter(&$variables) {
  if ($variables['image']['#style_name'] === 'style_to_change') {
    $variables['image']['#style_name'] = 'thumbnail';
  }
}

And this way style really is changed, but I don't' have info on current view row so it can be used only for setting random image styles or something.


texts: Change Standard Title for Adding Content Into Something New? Also Redirect to the Page You Were On?

texts:
What I have right now is an obituary page, with a listing of obituaries. Clicking on one of those listings takes you to that person's obituary page. There are links on that page for visitors to send their condolences to or make a memorial donation. The links look similar to http://shawnjacksonfuneralhome.simalam.ca/node/add/condolences?field_obit=131 and http://shawnjacksonfuneralhome.simalam.ca/node/add/memorial-donations?field_obit_donation=131. The text after the question mark is there to prepopulate a select list of entity references on the next page.

There are 2 things we are trying to do here. First, we want to change the title from the standard "Create Condolences/Memorial Donations" to something like "Send Condolences to the family of X" where X is the name of the deceased person. I've tried using the drupal set message function to find the value selected in the list.

drupal_set_message("Obit Name:" . print_r($node->field_obit, TRUE) . '');

According to those results, the value of the prepopulated select list should be like this:

$obit_name = $node->field_obit['und'][0]['entity']['title'];

However, it doesn't display anything (either with echo, print, or print render()).

The second thing we are trying to do is after the visitor submits their condolence/donation, we want them to be redirected back to the obituary page they were just on, along with a message thanking them for their actions. I've tried using the Rules Module to redirect and display a message, but it won't do both for some reason. It will not redirect to the previous page, either.


texts: Drupal 7 custom module menu hook is not working

texts:
I have created D7 module called 'mymodule' and enabled it from module list page.
But the menu created inside the mymodule_menu() is not being called, instead redirects to 404 page.

Below is the mymodule.info file

name = my custom module
description = My module testing
version = 7.x
package = Custom Modules
core=7.x

Below is the mymodule.module file

<?php
echo 'Module is called';

function mymodule_menu() {

    $items['mydesk'] =  array(
      'title' => 'My Desk' ,
      'page callback' => 'show_mydesk',
      'access arguments' => TRUE,
    );
    return $items;
}

function show_mydesk() {
    echo 'show_mydesk';
}

Note: the echo 'Module is called' text is printing after enabled the module.
Any help to find out where I have missed something.

Thanks
Govind


texts: How can I add pager to the comments of advanced forum in drupal 7?

texts:
I use the drupal 7 core forum with advanced forum module.

This works perfectly except the forum topic page show only post comments what number is defined on the content type, and no pager on the comments, therefore the users can't jump to the next few comments.

My question: how can I add pager (first, prev, next, last, etc.) to the advanced forum post comments?

I didn't found any solution until yet.


texts: Hide node title on front page using template.php not css

texts:
I'm building a drupal 7 bootstrap sub theme and want to hide the title of the nodes if there on the home page. I don't want to use css as its only hiding it I want to have the titles not render at all.

i have tried hook_preprocess_page() but didnt work:

function mytheme_preprocess_page(&$vars) {
    if ($vars['is_front']) {
        $vars['title'] = '';
    }
}


texts: Custom actions not appearing in the Trigger/Action settings page

texts:
I am developing a custom module which defines custom Triggers and Custom actions.
When I add or change an action, this action doesn't inmediatelly appear in the select list of the Triggers admin page.

I refresh, flush all caches and even activate/desactivate the Trigger Unlock module (which seems to work), but now when I create a new custom action, I go nuts to make it appear.

You can appreciate in the image and code what I am talking about (notice the Description has not changed after update).

/**
 * Implementation of hook_action_info().
 */
function commercegate_action_info() {
    return array(
        'commercegate_show_message' => array(
            'description' => t('Show message 1.'),
            'type' => 'commercegate',
            'configurable' => false,
            'hooks' => array(
                'commercegate' => array('callback_sale','callback_cargeback'),
            )
        ),
        'commercegate_show_message2' => array(
            'description' => t('Show message 2.'),
            'type' => 'commercegate',
            'configurable' => false,
            'hooks' => array(
                'commercegate' => array('callback_sale','callback_cargeback'),
            )
        ),
    );
}

Anyone familiar with this problem? Thankyou


texts:
In my webform page I have two select options components:

Item number:
20 | 20 ,
35 | 35 ,
40 | 40

Price List:
100 | 100 ,
200 | 200 ,
300 | 300

I need these two select options components synchronized. If one selects Item number (35) the price list also moves to (200).

Is there any module available to do that, or how can I get the synchronization of the two select options.


texts: Can alias be set for same language but different domains?

texts:
I have a site in Drupal 7, with Domain Access and i18n modules. I use PathAuto. I can create custom links, and link to a node nid with different languages, but I am not able to create different links for different domains? Is there some module or way of achieving this? For example, for one and only node->nid = 5:

www.example.com/es/alias-1

would be equivalent to www.example.com/node/5

www.example.com/en/alias-2

would be equivalent to www.example.com/node/5

and I now need

www.example2.com/en/alias-3

to be equivalent to www.example2.com/node/5  (notice change of domain).

The system says that the URL already exists (alias-2 is using node->nid = 5 and language = 'en', so cannot repeat it, and, in any case, I cannot indicate a domain, anyway).


texts: Trying to using Rules to create page redirects to external links per node, but it's not working

texts:
I like using Rules and am trying to create a page redirect, for a certain content type i’ve created. So instead of the user viewing the node, they get redirected to an external website. the site address get’s input via a simple text field in the content type i’ve created. i’ve tried different setting for this field, plain text, full html.

In the action part of the Rule i’v set as System/Page Redirect and the value as [node:field_ext_link_text]. But it’s doing something to the URL (decoding or encoding??) and instead say going to www.somewebsite.com, i get a page not found that reads

"/%3Cp%3E%3Ca%20href%3D%22http%3A//www.somewebsite.com%22%3Ewww.somewebsite.com%3C/a%3E%3C/p%3E%0A" could not be found.

i really don’t understand what it’s doing to this URL.

i also installed the link module and tried using a field type link but got similar results. i've also tried ommitting http://,

i also tried using Rabbit Hole module to accomplish the same thing, but got similar results.

Any help would be greatly appreciated. … have spent way to much time on this…(!)


texts: CSS Files served from https Domain instead of CDN domain

texts:
I setup a Drupal site on two domains (www.example.com and blog.example.com); I am using the Domain module.

I also setup a fake cdn.example.com domain on the same DOCUMENT_ROOT folder; I am using the CDN module for this.

I setup boost for static page cache with aggregation and minimalization of CSS and JavaScript files.

At first, everything was right and the files were served correctly from cdn.example.com. After some time (I don't know how long), something changed. The boost cache files referring to the CSS and JavaScript files are served not via http://cdn.example.com, but https:/blog.example.org (note the https instead of http). Since my blog.example.org does not have a SSL certificate, the files won't get requested and my style is broken.
When I flush the cache, everything works again.

I updated the modules and Drupal core to the latest stable production versions.

Why do I have this behavior?


texts: How to return number of text field inputs filled in, on focus change using ajax?

texts:
I am struggling to find a solution to the following, using drupal 7 and hook_form_alter.

Within my form I have a group of text inputs, the number of which can be altered by the user in 5s. i.e. there can be 5, 10, 15 ... n*5 inputs. Not all of these are required to be filled and I would like to count how many have been used and return this to the user as they are filling the form in. This eventually will be used in a drop down, however that will have to wait for another question. For now I am just looking to return the number.

The inputs are built in a function that uses an array in the $form_state for both number and value for each of the textfields.

I thought that by implementing ajax on each of the fields I could then count and return an array pair to be stored with the initial array (differentiated from the others as a string key and not integer), by updating the $form_state, and this could then be used to dynamically update the select options or in this case an html element with the number. The form state is being altered in the callback but is not then altering the $form_state which the inputs are being built from.

Any suggestions on how I could get this to work, or other solutions greatly appreciated.

Code to build textfields where $item is array of specified within $form_state

foreach ($item as $ikey => $value) {
            $form[$section][$area][$areacont][$areabox][$ikey] = array(
              '#type' => 'textfield',
              '#size' => 20,
              '#default_value' => $value,
              '#ajax' => array(
                    'callback' => 'bform_commands_count_callback',
                    'wrapper' =>  $section . '-' . $area,
                    'progress' => array('type' => 'none'),
                    ),
            );
            }

Callback

function bform_commands_count_callback ($form, &$form_state){
$trigger = $form_state['triggering_element']['#array_parents'];
$section = $trigger[0];
$type = strstr($section, 'section', TRUE);
    $area = $trigger[1];
$ins = $section . '-' . $area . '-ins';
    $values = $form_state['input'];
    $numfilled = count(array_filter($values[$ins]));

$form_state['ins'][$type][$ins] = array('numfilled' => $numfilled) + $values[$ins];
$form_state['rebuild'] = TRUE;
return $form[$section][$area];
}


texts: Issue with Views Contextual Filter using Taxonomy Term Name

texts:
I've run into an issue with views using contextual filters that feels like a bug but usually when I encounter what appears to be a bug it's because I'm doing something wrong so I wanted to see what people here think. My issue is the contextual filter on a taxonomy term name doesn't seem to work when there is another vocabulary in the system that has a couple identical term names. Let me explain further.

I have two different content types (content type A and B) and each is set up with its own taxonomy vocabulary (vocabulary A for content type A and vocabulary B for content type B). Then I've created a view for each content type (view A for content type A and view B for content type B). For each view I'd like to filter its respective content types by taxonomy term name. I've created contextual filters by bringing in the field taxonomy associated with content type and selecting the contextual filter "Name". This works just fine when until the second vocabulary is created in the system.

Now vocabulary A and B have a couple overlapping term names and when I use any of the overlapping term names in the contextual filter nothing is displayed in the view. The contextual filter works if a use any of the other non-overlapping term names. If I delete or rename one of the overlapping term names then it will suddenly work just fine. Also, when I setup the first content type with its vocabulary and view before I'd created the second content type, vocabulary and view it too worked just fine. It's only the presence of another vocabulary that might have a couple identical term names to I have an issue where the contextual filter no longer works.

    Vocab A
--------------
    cars
    trucks
    planes

    Vocab B
---------------
    bicycles
    motorcycles
    cars

"cars" in this example would be what I mean by overlapping vocabulary term names. They aren't the same terms, different term ids they just have the same label.

I'm using Drupal 8.6.13.

Has anyone encountered this issue? Is it me or is it Drupal?

Thanks!


texts: Second parameter in menu url (hook_menu) not working

texts:
I have a problem in my hook_menu() function. When I try to catch a second parameter (%foo) in a url, fails.

My urls:

 $items['node/%webform_menu/webform-factors'] = array(
    'title' => 'Factors',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('forms_grade_factors_create_factor'),
    'access callback' => 'user_access',
    'access arguments' => array('access administration pages'),
    'weight' => 5,
    'type' => MENU_LOCAL_TASK,
  );

  $items['node/%webform_menu/webform-factors/factors'] = array(
    'title' => 'Factors',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('forms_grade_factors_create_factor'),
    'access callback' => 'user_access',
    'access arguments' => array('access administration pages'),
    'weight' => 1,
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );

  $items['node/%webform_menu/webform-factors/ranges'] = array(
    'title' => 'Ranges',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('forms_grade_factors_create_range'),
    'access callback' => 'user_access',
    'access arguments' => array('access administration pages'),
    'weight' => 2,
    'type' => MENU_LOCAL_TASK,
  );

  $items['node/%webform_menu/webform-factors/delete/%webform_component/factor'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array('forms_grade_factors_delete', 1),
    'access callback' => 'user_access',
    'access arguments' => array('access administration pages'),
    'type' => MENU_LOCAL_TASK,
  );

When I typed in the browser a url, for example, http://drupal.dev/node/12/webform-factors/factors/1/delete, doesn't call forms_grade_factors_delete function. Instead, it's redirected to the default local task ('node/%webform_menu/webform-factors/factors').

'node/%webform_menu/webform-factors/delete' works fine. However, when I put another parameter, it fails (like 'node/%webform_menu/webform-factors/delete/%webform_component').

Another thing I don't know if it is correct is that (as you can see in the picture below), the tab without title (it corresponds to 'node/%webform_menu/webform-factors/delete/%webform_component/factor'), has within the url the string %webform_component.

Thanks for your help! :)


texts: How do I get rid of the "Review payment" form after PayPal Express checkout?

texts:
Can I somehow disable "Review payment" site after paying with "Express Checkout" method on PayPal?

Why is it even needed? Why do we assume that our customers who pay via PayPal "Express Checkout" do have a company? (There is the field "Company".)

Here's a screenshot:


texts: How to alter the value used to sort a view?

texts:
I have properties that have a rental price. The rental price is a field collection with a value (price) and period (per month, per week). You can sort the properties by price (low to high, or high to low) using an exposed filter. The problem is that if someone enters 2000 per month it is being registered as more expensive than a property that is 600 per week (2400 per month). So I want to divide the monthly values by 4 in order to have equal calculation.

What hook do I need to use in order to process the value field just before it is used to sort the properties?


texts:
In Drupal 8, the theme folder for contributed themes seemed to have moved.

Where do themes go in drupal 8?


texts: Why does Drupal display node titles at the page level instead of the node level?

texts: I'm doing some work with 'Extra Fields' and keep tripping up on the fact that Drupal tends to display the title of a node at the page level when viewing the full node page. It seems to be that it makes more sense to always display the title at the node level. Is there a reason I'm not seeing that makes it better to display it at the page level instead?


texts: Catch the English name of a translated taxonomy term (token)

texts:
I'm building up a multilingual website (Drupal 7) with Locale and Content translation modules enabled for nodes. The node category is managed thru a content_area field (taxonomy term thru Entity Reference module), which is translated with Entity Translation and Title modules in order to have a translated path in URL (using Pathauto module). Everything goes as expected, the content_area is translated in URL, in the breadcrumb and in the tags area.

As each node manages more images, shared among languages, we've built a file folders structure which comply with paths (not equal but similar) in order to keep a clean images structure, using File (Field) Paths module.
Problems arise: if the content_area field (taxonomy term) is untranslated (i.e. English), we have only one folder for images of all languages (as expected), but if we translate the content_area field we get a translated folder keeping images, as we do not want.

When setting up File (Field) Paths for images field in File path, we expected to find a token related to the untranslated/translated [node:field_content_area:name], with no luck. Even [node:source:field_content_area] cannot work and do not work, as we cannot know if the editor building up the node content will begin ('source') from English or from another language.

I hope I have been clear, it is my first post.
Thanks in advance


texts: how can I remove registered .tpl.php file?

texts:
When I remove html.tpl.php file, I get this error:

Warning: include(/home/xxxx/public_html/sites/all/themes/cgame/html.tpl.php) [function.include]: failed to open stream: No such file or directory in theme_render_template() (line 1413 of /home/xxxx/public_html/includes/theme.inc).
Warning: include() [function.include]: Failed opening '/home/xxxx/public_html/sites/all/themes/cgame/html.tpl.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in theme_render_template() (line 1413 of /home/xxxx/public_html/includes/theme.inc).

How can I remove this file to force drupal use core html.tpl.php file?


texts: How do I retrieve node data for a referenced node in a template file?

texts:
I have two content types, Event and Gallery. Each Event has a node-reference field to a gallery. I am now trying to style the gallery node page from inside the template file. I need to have a way of creating a link which links back to its parent, the Event.

How can I find this information?


texts:
I have a custom module and in its controller i am using 'namespace + classname' format to included QRCode library (which is in root/vendor/).

I have used composer to install library

Now I am trying to use this library in custom controller

namespace Drupal\product_display\Controller;
use Endroid\QrCode\QrCode;

But I am getting 'class not found error'

Error: Class 'Endroid\QrCode\QrCode' not found

Class doesn't autoload.


texts: Show/hide menu link based on changing custom $tempStore value

texts:
I'd like to show/hide a main-menu link based on a $tempStore variable the user can set and modify during their session, i.e.

user sets $tempStore['vlaue'] = 0; --> menu link is hidden
user sets $tempStore['value'] = 1; --> menu link is shown.

The menu link is provided by a view (page). What I started to do is to implement my own custom RouteSubscriber which adds a custom access check  (which is defined as a service in mymodule.service.yml) to the view. The custom access check in myCustomAccessCheck.php basically does the following

   ...
   $value = $tempstore->get('value');
   return AccessResultAllowed::allowedIf($value == 1);
   ...

Apparently Drupal by default hides all menu links that the user does not have access to, so this approach should work (which it actually does!). However, caching is a problem, i.e. when the user changes the value, the link is shown/hidden only after a cache-rebuild.

Now my question:

Is there a better/more elegant approach to do this? (I could not find any)
If not, can I use some hook to add my custom cache tag to the menu-link? (the view itself already has this cache tag, but the provided menu link does not respond to it)
Is it "better" to make a view-block instead of view-page, using a hook to add the custom cache tag to the block and add the block to the menu via *.links.menu.yml to have more control over the behavior?


texts: menu_tree_all_data() returns empty arrays for custom menus

texts:
This works.

$tree = menu_tree_all_data('main-menu');

This doesn't work.

$tree = menu_tree_all_data('menu-health-center');

Why doesn't menu_tree_all_data() work for custom menus?


texts: How do I set allowed extensions for a managed_file form field?

texts: Not having any luck find this in Drupal documentation or developer examples.  I need to set a managed_file form field to only allow zip files in a Drupal 7 custom module.


texts: How do I programmatically disable a form?

texts:
I want disable the user register form depending some conditions. The user go to the "/user/register" page, and he must see 'Registration is disable because ...'.

From my "form_user_register_form_alter" hook, I don't find anywhere how can I disable all the form programmatically (I mean removing all fields form). I think I can unset all form elements, but I feel that is an ugly way.

Is there a method (from the FormStateInterface class) or a Drupal function (for the form variable) to properly disable the form?

This is my most recent tentative.

function mycustommodule_limit_form_user_register_form_alter(&$form, FormStateInterface $form_state){
  if (...) {
    $form['#access'] = FALSE; // Drupal 7 (ugly?) way
    drupal_set_message('This form is disable because...');
  }
}

When I go to the /user/register form, the form is disable ! but I get this error.

  Notice: Undefined index: #markup in Drupal\Core\Render\RenderCache->getCacheableRenderArray() (line 323 of core/lib/Drupal/Core/Render/RenderCache.php).

I would like to hide/remove Create new account too.


texts:
I am having a big problem with a newly created Drupal 8 site for a theater.

After going live we discovered that the cache_render table grown extremely big, and extremely fast. After one weekend, it was already over 30 GB which makes a backup of the database impossible.

After some analysis and google search, I have stumbled upon cache_render database table growing in size. They say it is wise to use a caching service such as Memcache but honestly, that does not really solve the problem at all.

I have set the Cache maximum age to 1 hour and the cache_render page STILL sets the expiration date to infinity! Why?

What causes Drupal to fill up the database this much?

System information

Drupal version: 8.1.0

Modules in use:

List item
color_field 8.x-2.0-rc1
contact_block 8.x-1.1
contact_storage 8.x-1.0-beta4
ds 8.x-2.3
embed 8.x-1.0-rc2
entity_embed 8.x-1.0-alpha1
entity_reference_revisions 8.x-1.0-rc6
field_group 8.x-1.0-rc4
file_entity 8.x-2.x-dev (2016-Apr-13)Aktuell  Ok
Google Analytics 8.x-2.0
google_map_field 8.x-1.1
imagemagick 8.x-1.0-alpha2
layout_plugin 8.x-1.0-alpha22
mailchimp 8.x-1.1
menu_link_attributes 8.x-1.0-beta1+5-dev (2016-Feb-23)
metatag 8.x-1.0-beta8
paragraphs 8.x-1.0-rc4
smtp 8.x-1.0-alpha0
token 8.x-1.0-alpha2
weight 8.x-3.0
yoast_seo 8.x-1.0-alpha2+2-dev (2016-Mai-20)


texts: Why is my View empty if the taxonomy term of a field on an entity is not set (i.e. 0)

texts:
I am using ECK in Drupal 7 and I have an entity that has a property called "your_country".

The behavior is "term_reference" (using the eckextend module)
The type is "integer",
the widget type is "select list",
the vocabulary is "countries", and
the "Required property" is unticked (i.e. not required)

The database shows that this is an INT(11) not NULL and default value is "0"

It all works well with page manager but not so much with Views.
I created a view pane and added a relationship "your_country" because I need to fetch the "taxonomy term name" via that relationship. If I don't have that relationship, I can't show the term name.
It works but if that property was left 'empty' (the database shows "0"), then the view renders empty.
Why is that and how can I overcome that?


texts: I'm on D7. I have a content type that I would like users to add comments to WHILE they create it. Basically the content type is a "how to" topic and the comments will be used as different steps to do whatever. Thanks for any suggestions.


texts: S3fs redirect aggregated file to s3 failed

texts:
I follow the s3fs's readme to redirect aggregated files.
It didn't work.
Got 403 error in the nginx access log.
Here is my nginx conf.

location ~* ^/(s3fs-css|s3fs-js)/(.*) {
  set $s3 '*.s3.amazonaws.com/s3fs-public';
  set $url_full  $2;

  resolver               172.16.0.23 valid=300s;
  resolver_timeout       10s;
  proxy_pass             http://$s3/$url_full;

}

if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}

location @rewrite {
  rewrite ^ /index.php last;
}

location ~* files/styles {
        try_files $uri @rewrite;
}

        location / {
                try_files $uri @rewrite;
        }

        location ~ \.(php)$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param REDIRECT_QUERY_STRING "$query_string";
                fastcgi_param  QUERY_STRING     $query_string;
                fastcgi_param  REQUEST_METHOD   $request_method;
                fastcgi_param  CONTENT_TYPE     $content_type;
                fastcgi_param  CONTENT_LENGTH   $content_length;
                include fastcgi_params;
                fastcgi_keep_conn on;
        }

        location ~ /\. {
                deny all;
        }


texts: How to set date display format for jQuery datepicker?

texts: I am using the standard jQuery datepicker in Drupal 7 and I would like to change how it saves and displays dates. Instead of displaying 10/11/2013, I would like it to display as November 10, 2013 for clarity. Is it possible to accomplish this?


texts: Date popup - how to restrict typing into the textfield and return timestamp instead of formated date

texts:
In D7 I'm using date popup form element:

$form['sidebar']['reg_date']['from'] = array(
    '#type' => 'date_popup',
    '#title' => t('From:'),
);

When user click the textfield a popup calendar will appear, but user also can type the date into the textfield. But he can write something invalid like '44444' and this value will be returned in form state values without any form error. It would be useful if this module had an option for restricting typing date by keyboard. Is there any option for this?

I also have one side question: Is there any option to return unix timestamp value instead of formatted date in form state values? In my case it returns date in format '29.5.2016'.


texts: Drupal 7 - Create a custom template that can be assigned to different pages

texts: I want to have a custom template for pages. WordPress has template selection feature for Pages or Posts. Is that possible for Drupal?


texts:
I have a little issue on drupal 7. I want a little object/field on the userprofile. This object/field shoud show special roles of the user (special = "admin, moderator ...").
And is it possible that this object comes directly after the username ?

(I am very sorry for my bad english. I hope you understand my question)


texts:
Right now I have a custom view template created where I have a left sidebar and a main content area.

In the left sidebar I have taxonomy menu running to show my taxonomy terms.

I then have a custom view in my main content region filtering the nodes related to the taxonomy term. When I click on each term, the whole page has to load. It's just a bit too slow.

I've turned Ajax ON for my view, but it's not working (probably because I am not using it right).

Would using exposed filters be my answer to this? Or is there any way to keep my format and somehow pass the information to the views without having to load the entire page?

An example of a site doing what I would like can be found here.


texts: Render comments in a custom Twig template

texts:
I rewrite the article tpl page--article.html.twig and I want to render the comments and the comments form.

I add the comments in the content type fields and try to render with {{ node.comment | render }}, but it's not work.

Is it possible to render it in a custom tpl?


texts:
I am creating a module for Drupal 8, in which I want to upload and extract zip file to a root directory. Inside moduleSettingsForm.php file, I have a function submitForm(array &$form, FormStateInterface $form_state). I am getting all the values of uploaded file but I am unable to extract the content of file.

So is there any way to do this in Drupal 8?


texts:
I am trying to add a Javascript ad code on our Drupal based website through a block and when I do this, the page doesn't display but only ads display. Please see this sample page:
http://circuitdigest.com/forums/circuits-and-projects-help/arduino

I tried adding on different blocks and even added the ad code by directly inserting in the codes but no changes. Other Javascript based ad codes from other ad networks are working fine but only had problem with this one.

Could someone let me know what could be the problem? Here is the ad code.

    <script id="mNCC" language="javascript">
    medianet_width = "600";
    medianet_height = "120";
    medianet_crid = "455208315";
    medianet_versionId = "111299";
    (function() {
    var isSSL = 'https:' == document.location.protocol;
    var mnSrc = (isSSL ? 'https:' : 'http:') + '//contextual.media.net/nmedianet.js?cid=8CUWJ3143' + (isSSL ? '&https=1' : '');
    document.write('<scr' + 'ipt type="text/javascript" id="mNSC" src="' + mnSrc + '"></scr' + 'ipt>');})();
    </script>