texts: Multiple points openlayers geojson display only the last of it

texts:
I made a module retrieving data with geodata. The import feature allows to create a file in geojson. So, i'd like to display the points and the data without using Views, only openlayers module.
I saw the layer example provided with the module : Example GeoJSON, "Picture This", displaying a marker with the given raw geojson data provided.
In the Layer section, I tried to use the URL field instead of the raw data field to provide a link to my datafile, but when i use it on a map, only the last point is displayed.

I saw that in the example :

  {
    "type": "Feature",
    "properties": {
      "name": "Picture This",
      "description": "Outside of the North Carolina Museum of Art."
    },
    "geometry": {
      "type": "Point",
      "coordinates": [
        -78.702798,
        35.809411
      ]
    },
    "crs": {
      "type": "name",
      "properties": {
          "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
      }
    }
  }

but the "regular"geojson is a collection of such features :

{ "type": "FeatureCollection", "features": [
      {
        "type": "Feature",
        "properties": {"name": "point1", "description": "desc of 1"},
        "geometry": {"type": "Point", "coordinates": [-78, 35]
        }
      },
      {
        "type": "Feature",
        "properties": {"name": "point2", "description": "desc of 2"},
        "geometry": {"type": "Point", "coordinates": [-79, 34]
        }
      }
]}

So, since i have more than 1 point i used the second version, and i only get the last point showing when i use this overlay on a map.

Is there something special to do to display several point or shapes (from a layer) using that technique : i'd like to avoid using Views or any other plugins for this.

I've read https://www.drupal.org/node/1481374 and other generic openlayer Drupal 7 tutorials, but i haven't found any help for this kind of problem.
Thanks in advance


texts:
I'm using Drupal 7 and trying to include the Featured Content block between the write up and the comments, i.e. I want it inside a node.

I tried the method explained here, but am not getting the block appear.

This is the code I've used in my node.tpl.php

$block = module_invoke('featured_content', 'block_view', '1');
print render($block);

The featured content block's URL contains this:

admin/structure/block/manage/featured_content/1/configure

Any suggestions? What could I be missing out?


texts: Custom Node Template not inheriting page.tpl.php

texts:
In my theme, I have page.tpl.php and page--node--1.tpl.php.

When page--node--1.tpl.php is rendered, everything in page.tpl.php is lost. I only want page--code--1.tpl.php to replace the $content line in page.tpl.php and inherit everything else in page.tpl.php.

How can I do this? Do I need to first create a template for the content type?

Below is what I have in my template.php

if (strtolower($vars['template_files'][0]) == "page-search") {
    $vars["template_files"] = array();
    $vars["template_files"][] = 'page-search';
} else {
    if ($vars["template_files"][2] != 'page-node-edit') {
        if (isset($vars['node']) && ($vars['node']->type == "mytheme_page" || $vars['node']->type == "person" || $vars['node']->type == "blank_page")) {
            if ($vars["template_files"][2] == "page-front") {
                $vars["template_files"] = array();
                $vars["template_files"][] = 'page-home-mytheme';
            } else {
                $vars["template_files"] = array();
                if ($vars['node']->type == "blank_page") {
                    $vars["template_files"][] = 'page-blank';
                } else {
                    //print "made it here";exit;
                    $vars["template_files"][] = 'page-mytheme';
                }
            }
        } elseif ($alias == "sitemap") {
            $vars["template_files"] = array();
            $vars["template_files"][] = 'page-blank';
        }
    }
}


texts: SSL Issues with Mixed Content and Firefox

texts:
my question is about SSL with Drupal. I've uploaded my certs to my server and got everything installed and working correctly. I've set the base_url to be my https://site domain and also put the following at the top of my htaccess file:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]

Everything seems good on all my site pages on IE and Chrome. But Firefox keeps giving me a mixed content warning:

Firefox is blocking content on this page.
Some unencyrypted elements on this page have been blocked.

Why would it still be saying this if I have a properly working SSL cert (which I do) and it covers my entire site? Is there a way to get rid of it?

Thanks!


texts: extra 'field_' prepended to fieldnames in views $rows (Drupal 7)

texts: I created a field "myfield".  I then created a Drupal 7 view and selected the field 'field_myfield'.  (As expected the system prepended 'field_' to my fieldname.)  When I call dsm ($rows) to look at the row data that gets passed to my custom template, I see that the field is now called 'field_field_myfield'.  Why is a second 'field_' prepended to the fieldname?  Should I assume all fieldnames in $rows will have 'field_field_' prepended?


texts:
How to list all available entity types in Drupal using drush?

Related:

How to get list of all node types?


texts: Why is a page generated by views listening to block.tpl?

texts:
I'm working on some custom templates for a page created by Views and I'm struggling to understand why it's using block.tpl (which I thought was used for blocks). Basically I'm trying to get rid of all the extra divs created for just this one particular page, and until I remove the div class content I can't get the desired style I'm looking for.

I did something similar for a block generated by views and used the template name block--view-name.tpl and got the desired effect. I ended up copying that same template file and just called it block.tpl and got the deserved effect on this Views page.

Now I'm left scratching my head as to why this Views page is listening to block.tpl when it's not a block. Also, seeing as it apparently wants a block template to do what I want, I'm trying to figure out the template naming but none of the usual tools are helping (theme developer module, the theme information under the advanced tab when editing the view).

Does anyone know why a page generated by views would be listening to block.tpl? If it helps the view content on the page is being wrapped by the following div:


texts: How to show link upload option on statuses updates form which converts to embedded content?

texts:
I am using Statuses (Social Microblog) module to allow users to post status updates like other social networks. To enable users to upload photos and videos, there is a module called Facebook-style Micropublisher, which allows users to upload links, photos, videos and documents. The problem with this is that all photos and videos will be saved on my server and for a community site, it is an expensive thing.

To counter that, I installed the great oEmbed module. When the oEmbed input filter is turned on in any of the text formats, It allows users to share a url of the video or photo and it embeds it into the statuses update a user shares. The oEmbed filter is working perfectly, but when a user shares a url of a video or photo with text before or after the url, the content is not embedded and it simply shows a link in the status update.

Now there are few ideas I have in my mind, but I do not know whether those ideas are possible or not. I guess it's a challenge.

Here are the ideas:

IDEA 1. The Facebook style micro publisher (fbsmp) module allows to attach a link with the status update. It is designed to work as I want, it is not working as it should. If you install and see this module, i think you will get the idea of how it works.

I have read some where that the statuses module's api is flexible and customizations can be done. I am using the dev version of the statuses and flag 2.

Important note: It is not necessary that the answer is restricted to my ideas. Anything which solves my problem will do.


texts:
My sys admin hasn't made any changes to dir permissions, but lately whenever I run DRUSH UP I get the following error:

  [error] Unable to download drupal-7.43.tar.gz to /srv/www/htdocs from
  https://ftp.drupal.org/files/projects/drupal-7.43.tar.gz Updating
  project drupal failed.

I'm running Drupal 7.41 with MySQL 5.5.31 and PHP 5.3.17.
Clearing my caches, running "drush rf" followed by "drush up drupal" doesn't work either.
Does anyone know what might cause this?


texts:
There are some related questions but they  are not very new, and  I'm not sure if I get it right. My question seems quite elementary.

Am I wrong in assuming the following basic fact? In the standard default installation of Drupal 7, all articles show a "read more" link, even if there is actually no more text to show. And there is no simple way of changing that stupid behaviour.

Please, tell me that I'm wrong.


texts: PHP code to display block based on list (text) field

texts:
Drupal 7. I'm trying to display a block using the "Pages on which this PHP code returns TRUE" feature. The field is a single value list (text) named field_display_block so all I want to do is determine if field_display_block is set to "1".

I'm sure there are a couple of ways to do this. Any help on this would be greatly appreciated.

Thanks

Les Z


texts: How to make a display mode of the current user on the home page?

texts:
I have a site built with Drupal 8 and the Twig Tweak module. I want to make the current user's frontpage_tasks display mode on my home page. How to do this ?
I can make a user's frontpage_tasks display mode by manually entering their ID :
page--front.html.twig :
{{ drupal_entity('user', 51, 'frontpage_tasks') }}
{{ drupal_entity('commerce_store', ???, 'frontpage_tasks') }}
{{ drupal_entity('group', ???, 'frontpage_tasks') }}

For stores, I want to display all stores that the current user owns.
For groups, I want to display all groups whose current user is the creator.
What I want to do is render the current user account, stores and groups with frontpage_tasks view mode.


texts: How can we make edit Body input area larger?

texts:
The Body field of the content on our website is generally quite large -- multiple pages.  When Editing in Drupal 8, the Input Area is quite small -- 98 characters wide by 9 lines.  The first thing we do is drag the bottom right of the Input Area and increase the size to 30-40 lines.  This makes editing much easier.
Is there a way to make the Body Input Area size 30 lines long for our website?  This would eliminate one step on every Edit!


texts: Profile image goes over the text on advance forum in drupal 7

texts:
I'm fairly new to Drupal and I'm testing out Advanced Forum module on my site.

The problem I'm facing is that when photo which is uploaded is bigger than user info layout, then it goes over the text. Is there any way to force image to stretch and fit into the user info block?

I tried changing css, but I'm not really sure which one to change and in what manner. I'm using silver bells...

Can anyone guide me through this?

Thanks in advance!


texts:
How to add Cancel button to Batch operation?
Is this even possible?


texts: How to restrict who can VIEW content of selected content types using Organic groups?

texts: Using Organic groups 7x-2.7, how can I restrict which users are able to view certain content types?


texts: Export all translatable string/content/fields/interface to a csv file or alternative

texts:
I know there is node contents and fields that need translation, interface element translations, views title/footer translations etc

Is there an export for all these that can ideally later be imported or at least an easy workflow for a translator ?


texts: Published content is not visible to anonymous user

texts:
I have installed the Workbench module (version 7.x-1.2) on my 7.38 Drupal install.

Everything is working fine as far as an original author changing the status of a page from "Draft" to "Needs Review" and the page then showing up in an approved users workbench to review.

The problem is that if the reviewer finds an issue and then changes the status from "Needs Review" back to "Draft" with some notes and sends it back to the original author, the page DOES NOT show up in the original authors workbench. It actually completely disappears from the original author and doesn't show anywhere. The reviewer can see it in THEIR Drafts tab, but that's it.

This obviously isn't right. Has anyone else seen this or have a fix for it?

Second one is when the reviewer moderate state from needs review to published then content is not shown to anonymous user.


texts: Can I only traverse a DatabaseConnection object once?

texts:
I have a database query result, and I want to go through the records twice. However, the second time I go through it, nothing happens. It seems you can only iterate through this object once?

My code looks like this:

$query = db_select( ... );
$result = $query->execute();
if ( $result->rowCount() > 0 ) {
  foreach ( $result as $record ) {
    ... processing happens here
  }
}

// now loop through again, to mark records as processed, upon success.
foreach ( $result as $record ) {
  ... additional processing here
}

And the additional processing doesn't happen.

As a work around, I added $records = $result->fetchAllKeyed(); before the initial processing, and then the result object had no records!

I found nothing in the documentation about resetting the object or anything.

Is this how the object works? Can I reset the iterator again, or must I fetch the keys initially to have an array that I can iterate over many times?


texts: Tagging of multiple content items at once

texts:
I'm very new to Drupal, so please be gentle.

My company is in the process of setting up Drupal as a learning portal, which will have various content types (videos, pdfs, blogs, basic pages) that we will tag for ease of searching and offer 'suggested learning materials'.

While we will try to get our taxonomy defined perfectly up front, we know we'll miss something.

I came across two related questions here, but neither are exactly what I am asking

Add a field to multiple content types at once?
is there a way to change multiple tags at once?

I'll certainly use these questions and answers in the future, but for now my question is:

if we add a new term (rather than change one), is there a way to select multiple content items and add the new terms to the selection in a single action, rather than have to go to each content item individually and add the new tag?


texts: How to get all terms with services module?

texts:
I am working on an app (react native) and when i make a request to get the taxonomy terms i don't get all the terms

This is the url i used to get the terms:

http://example.io/api/taxonomy_term?parameters[vid]=2&pagesize=1000

But when I go to the url from my browser i get the full list of terms!

Here is my fetch code:

fetch('http://dev-fnyan.pantheonsite.io/api/taxonomy_term?parameters[vid]=3&pagesize=500').then((response) => response.json()).then((response) => {
    let data=[]
    response.map(i =>{
      data.push({label:i.name, value:i.tid, parent:i.parent})
    })
    this.setState({
      categories: data
    })
  }).done();

Can anyone suggest where is the problem?


texts: Additional old_XXXXXXtaxonomy_term__field_XXX Tables after upgrading

texts:
After Upgrading from Drupal 8.6 to 8.7 I have tons of new (garbage?) tables in the database. The naming schema for the tables is old_XXXXXXtaxonomy_term__field_XXX

Is there a drush command to remove them or can i just drop dem directly?

I tried drush eval "field_purge_batch(5000)" and drush entity-updates without success.


texts: How do I expose the fields value while filtering on a Combine fields filter?

texts: I have view with multiple fields, where I have added a combine fields filter, which is working fine. I want to extend this and add option to choose fields for which fields user want to search for.


texts: How does the views page style options work?

texts:
I have recently discovered the power of Views. I am using the Unformatted list Format and an Entity Reference bringing two content types that I created (myprojects and mytasks) together such that if there are any tasks associated with a given project they are listed below the related project. This works pretty well.

I know very little about HTML and really don't want to have to get into it. I want a simple indentation on each output task row displayed so that the report is easier to read. It would also be nice if it was double spaced.

The theme I'm using in my site is Outreach. What happens is each project is h3 and each row is inside div and underlined with a smaller font.

This list of projects and tasks becomes an agenda for meetings when copied into Word.

How can I use Settings for Unformatted list and/or Settings for Fields in the view to indent the rows of tasks?


texts: How to add custom theme for Add a Product page

texts:
I'm new to Drupal Commerce.

I have created new product type and added custom fields everything and it's working fine.

I want to theme the Add a Product (form page). Please suggest me how to do that.

Thanks,
Selva


texts: Use Webform for multiple possible inputs

texts:
I want to create a webform that will replace a excisting excell file
(visitors download a excell file, fill it in and send it back to the company).
Under here a simplified example of the excell file...

As you can see above the visitor can fill in one line or more lines...

I could make a webform for entering one-line (one product), not so difficult.

But the client should be able to fill in more than one demand (if he wants).
So after putting in one demand, there should be a possibility, to say/click add one more...

Don't know if this possible with only "webform" module, or is there a other module for this.

Any tips, links, video's ,  comments are welcome!

K.


texts: Does poll not allow multiple anonymous votes?

texts:
We're having a problem with the core poll module on drupal 7. We have a poll that we want anonymous users to be able to vote on. There is currently one anonymous vote, and now anonymous viewers only see the result (we've tried looking at it from outside our network).

We've checked the perms, and anonymous can vote and view results ( but not change vote). We've cleared the cache.

How does Poll work on D7 with regards to the anonymous user?


texts: What does typical beginning mark in *.tpl.php files mean?

texts:
I'm looking into template files for theming purposes, and often at the beginning of the file there is a // $Id$ mark.

Could you explain me what it mean, and what the purpose of it is?


texts:
I'm getting this error on the Status report page.

Advice on resolving this?


texts: Remove the 'read more' and 'Add new comment' links on the home page

texts: How do you remove or modify the list of links shown after the content?


texts:
I'm attempting to render a webform inside a block plugin. I'm able to successfully retrieve the webform using the following code

$webform = \Drupal::entityTypeManager()->getStorage('webform')->load('my_webform');

However I'd like to render this form. I've attempted using

return $webform;

But I receive the error

  Recoverable fatal error: Argument 1 passed to
  Drupal\Core\Render\Element::isEmpty() must be of the type array,
  object given

I'm assuming this is because $webform isn't formatted as a proper render array, but I'm not sure how to do this. I've been searching for clues inside the code of the original webform module, but I haven't been able to find anything.

How would I programmatically render a webform? And/or is there a way to find in the code of a module or entity the way to render that entity?


texts: How can I add a content (let's say content of Article type)' to ANY region (not only in content region), or how to add a region to a node view page?


texts: Display content that reference the logged in user using Views

texts:
I have a content type Job with a Entity Reference field. This field (field_data_field_job_applicants) has a target type of User, and maximum number of values set to 10.

What I have got working so far is adding the users (specifically their uid) to this list when they click "Apply Job" on a job page.

What I am trying to do now is: when a job applicant logs in, they will see a collection of jobs they applied for.

More specifically, I want to tell the Views block to only display jobs where [current-user:uid] is referenced by field_data_field_job_applicants.


texts: Ajax on Exposed View Filter with Better Exposed Filter Module

texts:
I have a filter exposed as a block and would like to filter my view via ajax instead of refreshing the page. I installed the Better Exposed Filter module, set the view's Ajax setting to TRUE, and set the style to Better Exposed Filters but the page still refreshes.

According to the Better Exposed Filter's documentation all I need to do is add some javascript but that didn't work.


texts: Can drupal be installed on a subdomain and used on the main domain?

texts:
I was thinking about installing Drupal on admin.myexample.com for clients to access an add and edit news posts & products.

Then just using myexample.com as the main site. Calling the database and entries to their pages with PHP/SQL.

Is this practical?

I've been trying to learn my way around Drupal, I know this wouldn't be a way to learn. I'm much more comfortable writing the pages up myself than manipulating Drupal pages (at this point in time.)


texts:
I have a situation where I need to check the changes (what tables) were done at database level after a particular date as the two databases have to be merged now.
Is there any tool or module in Drupal that can fulfill this requirement.

Scenario: My client has given me the database (code also) of his current site to work on. He also did some changes meanwhile (at database level only maybe content) on his live site.

Now I need to integrate these changes into my database, but he did not record the changes that were done. What would be the best solution?

What I have done: I wrote a query fetching records from node table showing all the changes done after the particular date and manually updated his changes into mine. Am I missing something else?


texts: Basic page still showing in view that filters out basic page content from view

texts:
I made a view that is only supposed to show Album, Mixtape, and Artist content types, but the basic page I made called "About Us" is showing up.  I've tried deleting that content and re-making it and then doing the same with the view but it still shows up!

I'm attaching a couple of pictures to show you what I mean.


texts:
Trying to install Drush using Composer, i get an error concerning consolidation/annotated-command. What does it mean "locked at 2.0.3" and "requires 2.8.1"?

This is the error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1

- Installation request for drush/drush dev-master -> satisfiable by drush/drush[dev-master].
- Conclusion: remove consolidation/annotated-command 2.0.3
- Conclusion: don't install consolidation/annotated-command 2.0.3
- drush/drush dev-master requires consolidation/annotated-command ^2.8.1 -> satisfiable by consolidation/annotated-command[2.8.1, 2.8.2].
- Can only install one of: consolidation/annotated-command[2.8.1, 2.0.3].
- Can only install one of: consolidation/annotated-command[2.8.2, 2.0.3].
- Installation request for consolidation/annotated-command (locked at 2.0.3) -> satisfiable by consolidation/annotated-command[2.0.3].

Installation failed, reverting ./composer.json to its original content.


texts:
I am not sure how to explain this as I have very little experience with Drupal. I built a site with Drupal 7 and now I am trying to recreate it in Drupal 8. I have a problem with the Content area.

I have set up a view that looks like this.

The arrow points to a title name link.

When I click the link, I want to see additional detail not shown in the view. This works. However, there is as an additional view that looks like a “teaser” view that I do not want to be displayed. The area at the top in the rectangle I want and is part of the “Entity View (Content) with a category of Chaos Tools. The bottom part near the x is the teaser part and is a duplicate of the top part I don’t want. How can I remove the bottom part?


texts: How to tag content from external databases?

texts: I have an external database with a couple of hundred rows and columns. Is there a way in which I can tag content while or after I import the database to my drupal 7 website? Is there any module already contributed which could be used for this purpose?


texts: Why might a D7 view sorted using random seed always return the same order?

texts:
I have a View which displays records for places to eat out, with filters available to narrow things down to pubs, cafes, restaurants etc.   It uses Random Seed sorting, with the aim of providing a list of randomly arranged available places to eat.

The seed is set to use the same seed for every user, and reset the seed every hour.  The site is on Drupal 7.

It all looked suitably random, until I realised that whenever I visited the page, the same random takeaway would be in the top spot.

I tried clearing caches, then removing the sort entirely and putting it back (I thought perhaps the scheduled seed clearance was not happening).  The result order changes when I remove the sort criterion and save, but as soon as I put the random seed sort back in place, there is that one takeaway again, back at the top of the list!  And it's always there.  It was there yesterday too.

Any ideas?  Or does Drupal really like fish and chips a LOT?


texts: Embed webform in block and on submit load file from currently displayed node

texts:
I need to create a "Download this whitepaper" functionality similar to this one.

So far this is what I've done:

Created 'whitepaper' content type with file field
Created 'whitepaper' webform (as a block). Contains fields for firstname, last name and email.
Displaying the 'whitepaper' webform block on 'whitepaper' node types.

Here is where I need some guidance.

When I am viewing a node of type 'whitepaper' and want to download the attached file, I fill in the form fields on the block 'whitepaper' web form. When I hit submit, I want to be able to download the file attached to the content type.

How can I achieve this?

Will I be better off writing a custom module instead of a webform form?


texts: How to display the recent user revision in a views block with contextual filters?

texts:
We are having a Setup where we need to be able to display User Revision Fields via Views Blocks. We are using the User Revision Module and even fixed a Bug on the Contextual Filter Plugin of that Module.
Lets say the Url is /user/abc/revision/123 everything with a Contextual Filter for the VID on the Path works fine.
The Problem comes when we want to display the last Revision trough the same View because it has not the Revision Url pattern. it is only user/abc
Do i have to write a custom Contextual Filter which can differentiate the Url ? And what is then used instead of the VID ?


texts: How to keep the same vertical tab open on AJAX call?

texts:
We're using vertical tabs on a configuration form for a ctools content type inside Panels. Inside most of these vertical tabs, there are "Add more" buttons, which use AJAX to add another item to the form. Essentially combine these two examples:

https://api.drupal.org/api/examples/vertical_tabs_example!vertical_tabs_example.module/7

https://api.drupal.org/api/examples/ajax_example!ajax_example_graceful_degradation.inc/function/ajax_example_add_more/7

We set the container around the whole form to reload the entire thing. The problem is that, on reload, the vertical tabs reset. We'd prefer it leave the element that the user currently had open open. Is there a way to do that?


texts:
i already searched all relevant drupal sites - but without success.
I have to create a own template file for the "edit user profile" site of the module Profile2.

As far as i know, i have to hook the new templatefile in the template.php of my theme - but what keywords and syntax do i need to accomplish that?

Every hint would be great!
Thanks.


texts: Error while custom Form creation in drupal8

texts:
I am trying to create a custom form in Drupal-8, by refering online docs. But I am facing one error, not able to find out what is the wrong am doing here, please find below code and error.

Error: Fatal error: Cannot redeclare class Dupal\amazing_forms\Formss\ContributeForm in C:\xampp\htdocs\drupal8\modules\custom\amazing_forms\src\Formss\ContributeForm.php on line 46

Folder structure:

modules->custom->amazing_forms
                   ->amazing_forms.info.yml
                   ->amazing_forms.routing.yml
                   ->src
                       ->Formss
                          ->ContributeForm.php

Code:
amazing_forms.routing.yml

amazing_forms_contribute:
  path: 'amazing_forms/contribute'
  defaults:
    _title: 'Registration Page'
    _form: '\Drupal\amazing_forms\Formss\ContributeForm'
  requirements:
    _permission: 'access content'

ContributeForm.php

<?php
namespace Dupal\amazing_forms\Formss;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class ContributeForm extends FormBase {
  /**
     *{@inheritdoc}
     */

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

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#required' => TRUE,
    );
    $form['video'] = array(
      '#type' => 'textfield',
      '#title' => t('Youtube video'),
    );
    $form['develop'] = array(
      '#type' => 'checkbox',
      '#title' => t('I would like to be involved in developing this material'),
    );
    $form['description'] = array(
      '#type' => 'textarea',
      '#title' => t('Description'),
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
    return $form;
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    foreach ($form_state->getValues() as $key => $value) {
      drupal_set_message($key . ': ' . $value);
    }
  }
}


texts: Remove entities programmatically from view results before pager is generated

texts:
I want to remove certain entities from the view results (Views core module), before the view's pager is generated.

By now I am doing it in hook_views_post_execute(). The problem here is, that the number of results on the view pages is different then. There should be 10 results per page and not 7, 8 or 6 etc.

I do not want to create a views filter, which would require manual interaction from the user inside the views interface in the webbrowser.

I have tried also hook_views_query_alter(). The problem here is, that my module's class methods are processing entity id's (node id's in particular). It might would work with the SQL NOT IN statement, but this is probably a problem for bigger site's and a huge performance impact. Since I need to iterate over all entity id's from the site and check access then.

My questions:

Is there any method inside the Views module, which allows me to
remove the entity id's from the view results or shall I really use
hook_views_query_alter()?
Also - if it comes to the hook_views_X
methods - isn't there any more elegant class method or event? Since
hooks are a mostly deprecated way in Drupal 8.

Thanks for your attention!


texts: How do I act after quantity change in cart?

texts:
I am writing a Commerce submodule that needs to run some code on the line items in an order when the Update Cart or Checkout buttons are clicked in the shopping cart form, but I'm not sure where to put it. More specifically, I need to see if the user updated the quantity of a line item in their cart and then write code that acts on the quantity change (without using Rules).

I am already using hook_form_FORM_ID_alter() to alter the Remove buttons in the shopping cart, I figured I could just add a submit handler in this hook but that doesn't seem to work.

function MYMODULE_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state) {
  $form['#submit'][] = 'MYMODULE_cart_submit';
}

function MYMODULE_cart_submit($form, &$form_state) {
  dsm($form);
}

When I hit either Update Cart or Checkout, dsm doesn't load on the next page. Am I in the right spot?

Thanks! :)


texts: Fivestar appears on content type, but can't vote

texts:
I have problem with Fivestars module, (Drupal7).

It is configured in field and appears on content type page, but cannot vote
(like voting is disabled - when inspecting with firebug, i see no Javascript activity over stars, and no any possible javascript conflict.)

Permissions are set correctly.

What in the world could cause this ?
(it seems more-less like plug-and-play module :D )


texts:
I am using  SMTP module to send mail. Email sends but receives after one day. I am unable to identify what is the issue.

Please suggest me how to resolve this issue?

Thank :)


texts:
I want to create an archive from my news with views and filter it by post date.
How can I do it?
Thank you


texts: Additional field data stored outside of the field storage (in a separate table) doesn't load with the rest of the field

texts:
I've implemented a custom field that needs to store data outside of the Field Storage mechanism and in a custom DB table. (The field structure is enough to require a second table, but not enough to justify creating a new entity type. It's an image field with tooltips that will be later styled with JS.) I've hooked the necessary functions and I can see that the data is getting saved to the table, but the load hook doesn't get called when the edit screen form is built, nor does it's additional content show up in the passed-in $items array.

Since hook_field_widget_form doesn't get the $entity being edited, I can't manually query the auxiliary table for the data. How do I get the data into $items and onto the form so the user can edit again?

(It also doesn't appear to be calling hook_field_load on the node load either, but I haven't started working on the field formatter yet.)


texts: Pages never cached, X-Drupal-Cache always MISS (using apc)

texts:
We run a Drupal 7 site where 99% of the traffic comes from anonymous users. Sometimes the traffic can spike very fast, so caching the barely changing content is essential for the performance. Checking the headers of the returned pages from Drupal, however, we see that all requests have X-Drupal-Cache: MISS set, and all have no-cache set and the expiry date being 1978. This was tested as anonymous user. We use plain APC and no varnish.

We enabled APC and added and configured the drupal apc cache module. On admin/config/development/performance  all checkboxes are activated and minimum cache lifetime and expiry are set to 1 hour. (We actually had to set those settings in settings.php, because the page would not save any changes made).

This is what the settings.php file contains:

$conf['cache_backends'] = array('sites/all/modules/apc/drupal_apc_cache.inc');
$conf['cache_default_class'] = 'DrupalAPCCache';

$conf['page_cache_without_database'] = true;
$conf['page_cache_invoke_hooks'] = false;

$conf['cache'] = 1;
$conf['cache_lifetime'] = 3600;
$conf['page_cache_maximum_age'] = 3600;

Although the APC statistics show that a lot of data is cached (opcode, system and user caches, so drupal seems to be able to put data into the cache), the headers suggest that all requests are misses. This is an example of the headers we see from anonymous requests:

Cache-Control:no-cache, must-revalidate, post-check=0, pre-check=0
Connection:close
Content-Encoding:gzip
Content-Language:nl
Content-Length:8294
Content-Type:text/html; charset=utf-8
Date:Thu, 14 Mar 2013 16:50:41 GMT
ETag:"1363279841"
Expires:Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified:Thu, 14 Mar 2013 16:50:41 +0000
Link:<https://XXXXXX/node/637>; rel="shortlink",<https://XXXXXX/online-therapie>; rel="canonical"
Server:Apache/2
Vary:Accept-Encoding,User-Agent
X-Drupal-Cache:MISS
X-Generator:Drupal 7 (http://drupal.org)
X-Powered-By:PHP/5.3.16

We do not know how to improve this situation, or how to kindly ask drupal to not send the no-cache headers for a clearly anonymous user.

Any help here? Can it be that the clean-urls or any other module is interfering here?

Thanks in advance,
Stefan.


texts: Service API acting strange with Answers module

texts:
I'm currently developing an Android App that uses REST to communicate with drupal

I've setup the Service module and got it working with normal "post" content type nodes

But, if i post a question node from the Answers module, it would not work.
So, I post an JSON string like this:

{"node":
{
   "title":"REST question",
   "type":"question",
   "language":"und",
  "body":[
  {
     "und":{
        "value":"REST content",
        "format":"filtered_html"

     }
  }
]
}
}

Drupal would respond like this:

Request header:

Request Url: http://www.mubie.com/rest_api/node.xml
Request Method: POST
Status Code: 200 //<- the request is valid...
Params: {}

Respond body:

<?xml version="1.0" encoding="utf-8"?>
<result>
    <nid />
    <uri>http://www.myhost.com/?q=rest_api/node/</uri>
</result>

now, normally, if I post something like a blog post, it would return the node(nid) url, but with a question content type, it returns the url that lists all nodes.
Also, the content is not added to drupal

How do i make it post my question content properly and return a node url?


texts: How to troubleshoot subdomain issue on Aegir

texts:
I set up Aegir on a rackspace server. Everything works correctly. I then create a new site and set the url to testname.mydomain.com. After Aegir is don provisioning the site I go to the front page at testname.mydomain.com and see my new site. The front page works fine, but every other page, gets a page not found error, so when I attempt to login I'm unable. How do I go about troubleshooting this issue.

So it turns out this is somehow related to platform, I added another platform based on makefile (for open atrium) and it seems to work correctly, I'm not really sure why this would happen, but I figured I would update incase anyone else is having the seam issues.


texts: can we add two search form in single site?

texts: I have a one search form which is used for all content type but i want another search form which is only for specific content type and show on specific page only. I have install the custom search module but there is no way to show that custom search module in structure block


texts: Display flash, video, photo in slideshow

texts:
I want to build a views slideshow. How can I display several format in this slideshow like flash format, video formats and photos together?

I want to upload a flash file, two photos, and one video to show them in a slideshow. I'm using Drupal 7.14.


texts: Which graphs solution for Drupal 7 can be used to upgrade my Open Flash Chart solution from Drupal 6?

texts:
I have upgraded from Drupal 6 to Drupal 7 and for me, everything is better in Drupal 7 until I hit this problem.

What I'm trying to achieve:

I have to create and show graphs to users depending on whatever the data they have stored on the site, I mean I have collected the data and stored in a Mysql database. I now have to fetch these data from that Mysql database and display it as a neat graph.

In drupal 6, making such dynamic graph is a cake walk..! I used Charts and graphs module with "Open Flash Chart" to create some very interactive and pretty graphs. But it does not has a Drupal 7 version..!

Attempting to use the 'Charts' module fails:

Then I searched for one that could work in D7 and found the charts module. It looked very promising and has a Drupal 7 version too. So I tried to install it, but I can simply not get it to work! I found a patch, but still no luck. Even if I get it to work, it will only work with Google Charts and not with Open Flash Charts or Fusion Charts because it requires those charts to be installed by us and Open Flash Charts or Fusion Charts, do not have a D7 version..!! FYI, the same problem existed in D6: when I installed everything (even Open Flash Chart API), it said "no chart plugin installed". And not even a single line of documentation is provided regarding how to install these plugins and make other charts work. Hence I think its out of the picture.

My Question(s): So what can I do now..?? How can I create graphs..? What can I use..??

Update about this question:

Since I didn't find any graphs module that I could use in my Drupal 7 site, I tried using an external PHP charting library "pChart". I configured everything without getting any errors or warnings, but I only get a bizarre output ...

I have explained everything in detail, along with the code I have used to create the graph in my (new) question What is causing the unusual output when trying to create charts in Drupal 7 using the pChart library? Any help to answer that new question would be greatly appreciated!


texts:
on a Drupal 8 webform, I have a datetime entry which works fine and I can format it in settings. When I create a custom composite with a datetime in it, I don't have the same formatting options as before. For example, I cannot pick a display or submit format for the date.

I could create a module to hook onto the submission and alter it that way or, presumably, I could do this in the email submission with tokens. (I have not tried that yet.) That would only affect the submission and not the display, though.

How do I format the display and submission format of a datetime field in a custom composite?


texts:
I am using the Jssor Slider module. My slider works, but the content type Jssor slider, where text is displayed on images, is not working on Drupal 8.

I want to display content on slideshows like shown on
http://www.jssor.com/demos/content-slider.slider. How can I do this?


texts: Images served from private files dir unprintable in IE11

texts:
IE 7 - 10 have been killed off. Please somebody kill ie11 too.

I have a D7 site that stores images in file fields in private://. IE11 fetches these images appropriately and displays them in normal website use, however when you come to print them, they're not there. Instead you just see a tiny photo icon and "Photo"!

The same image copied somewhere public and referenced there works fine - seems to be something about the way Drupal serves the request for private files.

It works fine in Firefox, Chrome, Edge. Unfortunately I need ie11 to be able to print these images. Has anyone found this to be a problem, and has anyone found a workaround?


texts: Problem with jquery or jquery ui (animating color)

texts:
I have found a jquery code which animates colors. I made a fiddle from it (after minor change), and it's working perfectly on jsfiddle:
http://jsfiddle.net/kFuzp/

Unfortunately, it's not working on my Drupal site. I have JQuery Update module and updated to 1.8, using jQuery CDN. The code (as in jsfiddle) is inserted using drupal_add_js ($script1, 'inline') in mytheme_preprocess_page(). When I debug the code in Chrome, it just runs (I can observe how the color_index changes etc using breakpoints). But the <p> background color is always white.

By the way, when I change the animation property to { opacity: color_index/7 } then the opacity animation is working (slowly) both in jsfiddle and in Drupal.

Why it's not working in Drupal and how to fix it?


texts: How to alter search api autocomplete to exact match?

texts: I have installed search api autocomplete module. I have configured it also but the requirement is to it should search only 'starts with word'. now the result is searching if a word present in mid of a sentence/title. But i need only starts with title/sentence. I checked in backed configuration for the same but for autocomplete i didn't find any such configs. Is there any way to alter the search any out-of-the-box feature available in backend only.


texts:
I have been trying to disable a menu item "standard.front_page" using the following code:

db_query("UPDATE {menu_tree} SET enabled = 0 WHERE id LIKE 'standard.front_page';");
db_query("DELETE FROM {cache_menu};");

It works fine till I do a cache rebuild using drush cr. Once I do a cache rebuild the menu item again comes back.

Can anyone please suggest a good way of doing the above?


texts: Using drupal login system for another platform

texts:
I want to create another site that uses the drupal user login / registration system so that it is integrated with my drupal site. This would allow current users to use this other service without having to register again.
Can someone let me know if this is possible? Sharing login cookie / registration / user validation...etc.

I am using drupal 7.


texts: How to pass views link as a variable to a node?

texts:
I have had a custom tables and I need them to view using Views in Drupal 7 module and it works.

In the Views module we can output fields as a link and redirect to the page what we need and I did this.

My question: when that link is clicked by the user, I need the link name to go to the specific node that I want as variable and being accessed by that node.

Is that possible in Drupal 7?


texts: Is it possible to rewrite the output of this CSV item with Feeds Tamper?

texts:
I have a feed set up to use the HTTP Fetcher with CSV Parser to download my content from a URL using the Feeds module (7.x-2.0-alpha8+84-dev) and Feeds Tamper module (7.x-1.0). I've mapped out my fields appropriately, but I'm having difficultly with the instance.

In my CSV source, there's one field where the information source outputs:
[[u'short', u'introduced', u'Solar Energy and Energy Conservation, Bank Reauthorization Act of 1983'], [u'official', u'introduced', u'A bill to amend the Solar Energy and Energy Conservation Bank Act to authorize appropriations for the provision of financial assistance under such Act through fiscal year 1990, and for other purposes.']]

However, I only really need the official title pulled into my content, which should be "A bill to amend the Solar Energy and Energy Conservation Bank Act to authorize appropriations for the provision of financial assistance under such Act through fiscal year 1990, and for other purposes."

Is it possible to rewrite this with Feeds Tamper, and if so, which plugin would you use/how would you set this up? In this instance, I don't believe explode would work because I do not want both items in my content and I would like the brackets '[]' and such removed. If not possible, how would you suggest accomplishing my goal?

I'm happy to provide more information, and I very much appreciate any assistance. tia

Here's the link to the source location. I've limited the results to 1 as to not overwhelm :)


texts: Whats faster db_query, db_select, or EntityFieldQuery

texts:
So I'm trying to find out what is faster db_query, db_select, or EntityFieldQuery. Currently I'm using EntityFieldQuery. I'm grabbing about 1600 node entries.

I realize this can be taxing on the system so I just want to figure out which is the best option to grab 1600 nodes. Shaving off seconds or even milliseconds would matter a lot with the application I'm building.

Thanks in advance for your answers.


texts:
I want to implement the create content form programmatically. In hook_menu() I have the following code.

$items['create/content/video'] = array(
  'title' => 'Create Video',
  'page callback' => 'create_content_video',
  'access arguments' => array('create video'),
  'type' => MENU_LOCAL_TASK,
  'weight' => 1
);

In hook_init(), I have the following code.

if (arg(0)=='node' && arg(1)=='add') {
  drupal_goto('create/content/'.arg(2));
}

In hook_theme(), I have the following code.

'video_node_form' => array(
  'arguments' => array(
    'form' => NULL,
  ),
  'template' => 'my_theme_video_form',
  'render element' => 'form',
),

In the page callback, I have the following code.

function create_content_video() {
  module_load_include('inc', 'node', 'node.pages');
  return node_add('video');
}

In the template file, I render form element correctly.
My problem is with the the AJAX uploader in the form. Without, I use the upload button to upload the file, and the node is correctly saved; when I use the AJAX uploader, it returns an error.

  Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'node_form' not found or invalid function name in drupal_retrieve_form() (line 795 of /var/www/mysite/includes/form.inc).
  Notice: Undefined index: #node in comment_form_node_form_alter() (line 1193 of /var/www/mysite/modules/comment/comment.module).
  Notice: Trying to get property of non-object in comment_form_node_form_alter() (line 1210 of /var/www/mysite/modules/comment/comment.module).
  Notice: Undefined index: #node in menu_form_node_form_alter() (line 629 of /var/www/mysite/modules/menu/menu.module).
  Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 629 of /var/www/mysite/modules/menu/menu.module).
  Notice: Undefined index: #node in menu_form_node_form_alter() (line 630 of /var/www/mysite/modules/menu/menu.module).
  Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 630 of /var/www/mysite/modules/menu/menu.module).
  Notice: Undefined index: #node in translation_form_node_form_alter() (line 135 of /var/www/mysite/modules/translation/translation.module).
  Notice: Trying to get property of non-object in translation_form_node_form_alter() (line 135 of /var/www/mysite/modules/translation/translation.module).
  Notice: Undefined index: type in xmlsitemap_node_form_node_form_alter() (line 136 of /var/www/mysite/sites/all/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module).
  Notice: Undefined index: nid in xmlsitemap_node_form_node_form_alter() (line 136 of /var/www/mysite/sites/all/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module).
  Notice: Undefined index: field_news_attachment in file_ajax_upload() (line 276 of /var/www/mysite/modules/file/file.module).
  Notice: Undefined index: #suffix in file_ajax_upload() (line 285 of /var/www/mysite/modules/file/file.module).

When I create content without this method, it works fine.
I am using Drupal 7.14.


texts: when calling privatemsg_new in a block, how can I correctly set the internal $destination variable?

texts:
I am calling privatemsg_new in php in a block so that the form to contact the node author is on the same page as the content. here is the code.

$node = menu_get_object();
if ($node->uid != 0) {
module_load_include('pages.inc','privatemsg');
$recipients = $node->uid;
print "
Contact " . $node->name ." about this post.
";
$subject = $node->title ." question.";
print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject));

Normally you access this form from the node page via a link that reads 'send this author a message' and that link loads a 'destination' parameter into the url query so that, when the message is finished, it redirects you back to the node page.

My code for the form in the block works fine except for the redirection back to the page after submission.  The variable that needs to be set is inside the scope of the privatemsg_new function:

http://drupalcontrib.org/api/drupal/contributions!privatemsg!privatemsg.pages.inc/function/privatemsg_new/7

How can I set that variable so that redirection works correctly?

EDIT 8/1/2012
Eugene's answer below was the correct direction and code for this particular problem, but I wanted to update my question with the exact code necessary to achieve a fully functioning 'Contact Author' block.  Simply copy and paste this in for Drupal 7 and it should work great, if you looking for the same solution.

$node = menu_get_object();
if ($node->uid != 0) {
module_load_include('pages.inc','privatemsg');
$recipients = $node->uid;
print "
Contact " . $node->name ." about this post.
";
$subject = $node->title ." question.";
$form = drupal_get_form('privatemsg_new', $recipients, $subject);
// Setup destination parameter to be equal to current page.
$form['#action'] = url('messages/new/'. $node->uid, array ('query' =>    drupal_get_destination()));
  print drupal_render($form);
drupal_set_title($node->title);
}

You have to set the drupal title manually. The reason being that the privatemsg_new function overrides this.


texts:
Is it safe to change the entity bundle (e.g. node type or commerce product type) when updating an entity with Migrate API?

Specific use case:

The site already contains plenty of commerce_product entities with $product->type === 'product', that were imported with something other than Migrate API.

I now want to re-import these entities with Migrate API, updating the existing entities.
Custom MigrateMap to sync by field or property, e.g. SKU

The product type should be changed to something else by the update, let's say $product->type === 'othertype'.

Some of the fields are the same in both bundles. Other fields only exist in one of the bundles. Data from obsolete fields should be discarded / deleted. This includes images from an image field.

So, I wonder if all of this will happen painlessly, or if I need to do something special to make it work.

I will try this anyway and see what happens, but I think it is useful to have this documented here on stackexchange.


texts:
I would like to show an entire book outline as a menu.  Something like this:

Topic 1
  Subtopic
  Suptopic
    Sub Subtopic
Topic 2
  ...

I have installed the Menu Block module but it seems that I can only ever get it to display one level at a time.  Am I using it incorrectly?  Or is this the way it is designed?  I am using the Bootstrap theme.  Could this affect how many levels are displayed?

I have read about using Views.  Should I just try to create and display a custom view?

EDIT: I have found the perfect example of what I am trying to achieve on the Drupal site itself, https://www.drupal.org/documentation/theme.  On the right hand side is a menu with the heading 'Theming Guide'.  This is the menu that I want to achieve.  I suspect that it does not use the Menu Block module....

EDIT 2: Ok, so I just changed the theme and I got the book navigation that I was looking for, out of the box.  So obviously it's the Bootstrap theme that is suppressing the extra levels of book navigation.  Not sure why...


texts:
I added the diff module that keeps all node Revisions (it seems that I can't limit the
number of Revisions to keep).
Is there a code I can use where I can set a limit of the number of Revisions to keep?
If so, where to add it?

Thanks.


texts: How to generate url with language code in drupal7?

texts:
Is there any drupal function to return the url with currently used language.
Like: example.com/en


texts: How to update the language in a existing node entity?

texts:
Using kint($node) gives me some availables methods to use but none seems to be able to set the language of the node

By guessing i found $node->landcode which gives me a method setLangcode($langcode) but it does not work

After loading the $node->langcode->setLangcode('cat'); and $node->save();, the node in the interface still have not updated the language


texts:
I have drupal 8, and I want to create a custom rule action. I have created it in Drupal 7, and it's working fine. I have no idea how to do it in Drupal 8.

Can you please explain which code should I use for Drupal 8?

Drupal 7 Code

function custom_rules_action_info() {
    return array(
        'custom_action1' => array(
            'label' => t('custom_action1'),
            'group' => t('Custom'),
            'parameter' => array(
                'user_id' => array(
                    'type' => 'integer',
                    'label' => t('User ID'),
                    'description' => t('User ID.'),
                ),
            ),
            'provides' => array(
                'return_value' => array(
                    'type' => 'text',
                    'label' => t('User Created with return_value'),
                ),
            ),
        ),
    );
}


texts:
I've been given a Drupal site to put on our server, I've not worked with Drupal before. From my understanding, the database credentials are stored in the settings.php file:

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

I've updated these to use the new server credentials (from foo to bar for the sake of this post). However it's failing to connect, with the error showing that it's still using the old credentials, foo.

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

Error:

PDOException: SQLSTATE[HY000] [1045] Access denied for user 'foo'@'0.0.0.0' (using password: YES) in lock_may_be_available() (line 167 of /home/sites/bar/public_html/includes/lock.inc).

So my question, does Drupal store these credentials anywhere else or cache them?


texts:
While using drupal 7, is it necessary for to wrap pure javascript code with jquery wrapper? (I understand that while working with jquery, I need to wrap my code inside beaviors.)

code

function openWin()
  {
    mycode
  }

od should I wrap it like this

(function () {

function openWin()
  {
mycode
  }

  })();

Or even use behaviors? Thank you.


texts: Best way to break up node edit forms smaller, more manageable forms?

texts:
It's pretty common to end up with massive node edit forms once content types start accumulating fields. Collapsable fieldsets and vertical tabs help the UI, but it can still be overwhelming.

Example: Say I have a local business site, and it involves a content type called 'business' which has lots of fields. One very significant field is the business's location. Rather than having location as just another fieldset in the large node edit screen, I'd like to break out the location-related items (address fields, google map, etc.) into a separate editing screen.

Multi-step forms are not ideal in this case. Is there a straightforward way to break a single node edit form into distinct forms?


texts: Update Two select box when change another select box

texts:
I have drupal form with three select box i want to change select box 2nd and 3rd after change value of 1st select box.

ex:
i have Three select box

1) Cruise line

2) Destination

3) Ship Id

When user select any value of Cruise line then i want to update value of 2) Destination and 3) Ship id

2nd and 3rd select box value are dependent on 1st select box

your answer really appreciated

Thanks in advance


texts: Hide comments on a node type for standard users

texts:
I'm using the 'comment permissions' module to restrict standard 'authenticated' users from commenting on a particular node type. However I do not want them to bee able to see comments on that node either.

I want to use the commenting system as tool for discussing posts internally. So admins can discuss posts by standard users. I DO want standard users to be able to comment on some other node types.

Obviously it is very important that the author never sees these comments. 'Comment permissions' doesn't have a way to handle this part so I have overridden the node.tpl.php file and only show comments if a certain role is present (see below)

My question is; how bullet proof is this method? Can anyone suggest a better way to achieve this? Obviously a change in theme would reveal comments but are there other issues I'm not thinking of?

<?php if ( (in_array('staff', $user->roles)) || (in_array('administrator', $user->roles)) ){ ?>

// show comments

<?php } ?>


texts:
I'm new to Drupal and despite making progress over the last few days I've hit a problem.

I've got two custom content types linked with an entity reference. I'm using the Views module to create a relationship between them and output the results as a block. The block also uses a contextual filter.

All of this is working ok, I add the block to a page and the content is shown exactly as expected, except I don't get the edit/view tabs that I usually see above nodes.

If I navigate to the node by itself via the 'find content' page the edit tabs are there, but once inside the block they're missing.

I found one post mentioning that edit tabs don't appear as standard when contextual filters are used, but the post was three years old, had no solution or discussion, and and nothing to confirm whether it was actually true.

I know I can add an edit link from the Fields menu in Views but it makes the UI look inconsistent.

I'd appreciate if someone could let me know:

What exactly stops them from appearing.
What to read up on to get them working again.

Thanks.


texts: Webform Custom-Field Module and validation

texts:
I am currently working on a Webform that is used to enter some rather complex finance information (think tables with sums and other weird checks).

Since the styling has to be rather specific for this form I decided to create a custom Module that provides a new Webform-Component using the Webform Module Hooks.

That means that I created the HTML and WebForm Structure of the form using the _webform_render_component hook by providing a custom #process function that expands the initial component array to include a bunch of textfields and some custom themes.

function _webform_render_ff_promotion($component, $value = NULL, $filter = TRUE) {
  $element = array(
    '#weight' => $component['weight'],
    '#pre_render' => array('webform_ff_promotion_form_prerender'),
    '#webform_component' => $component,
    '#theme' => 'webform_display_ff_promotion_form',
    '#process' => array('webform_process_ff_promotion_form_expand'),
    '#prefix' => '<div>',
    '#suffix' => '</div>',
  );
  return $element;
}

And the custom process expansion:

function webform_process_ff_promotion_form_expand($element) {
  $element['general_group'] = array(
    '#type' => 'fieldset',
    '#theme' => 'ff_general_group_fieldset'
  );
  $element['general_group']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#required' => true
  );
....
}

So far that works well and I have the form set up to look and behave as I need it to (saving etc works). Only problem now is validation - I cannot specify any other validations rather than required through the form_api.

I am trying to do this with the Webform Validation Module following this guide.
This works and I could now write a really huge list of if (is_numeric(...)) checks to see if the user did only enter numeric values to my textfields - but it feels kind of pointless.

So the main question here being - is there a best practice for custom components that rely on standard components internally (The whole custom component consists of just a bunch of '#type' => 'textfield' elements) to validate without writing a completely custom validator for it?

The Webform Validation Module feels like the wrong tool as it allows the validations to be done by the user in the admin. I'd rather just add more attributes like the  '#required' in the FormAPI and have them be checked.

Any help would be greatly appreciated - thanks!

Version Info:

Drupal 7.34
Webform: 7.x-4.6
Webform-Validation: 7.x-1.9


texts: How to delete all revisions of given content type except the current revision?

texts:
I am having a very large website which have around 400000 nodes of story content type. And these nodes have around 2000000 revisions. How can I delete all the revisions except the current revision so i can reduce the size of my database.

I have tried node node revison delete module with no success. Page is getting time out.


texts: How to programmatically create a node on user registration with the user as author?

texts:
I want to create a single node of content type XYZ for each user upon registration.

I tried to use hook_user_insert() (hook_entity_insert()), but this doesn't work because when I set the nid to the uid, the uid is still 0 (anonymous user), and the node needs to be assigned to the newly created account. (NOTE: This was my misunderstanding, see below.)

I want to create the nodes upon account creation because each user should have only one node of this content type.

In Drupal 7, I managed to do this in Rules using a rule set in which I saved the user account and then created the new node.  Since Rules isn't in beta for Drupal 8 yet, I am trying to do this programmatically.

Here is the code I am using:

function MYMODULE_user_insert(Drupal\Core\Entity\EntityInterface $entity) {
  $user = \Drupal::currentUser();
  $profile = Node::create(['type' => 'userprofilenode']);
  $profile->set('uid', $user->id());
  $profile->enforceIsNew();
  $profile->save();

As noted in 4k4's answer, $entity already has a UID.  The problem is that I mistakenly introduced the current user, which is 0 (anonymous).


texts: How to hide the title field in create content (Drupal 6)?

texts:
I have a type of content that I won't use the page title,
I will have to use a taxonomy field (the titles will repeat), because it's a restaurant list with auto-complete.

Can I do it with hooks or something?  I could copy some content from other field into the title if it's gonna be mandatory at submit..right?

How can I do it?


texts: Drupal 7 Commerce - How do you style the Please wait loading message/icon when you select an attribute?

texts: I'm trying to style the please wait loader icon when you select an attribute for a product in drupal 7 commerce. I'm using chrome and i can't figure out a way to right click inspect element fast enough as it loads to fast. Or is there another way to expose this? I just need the HTML and classes associated with it.


texts:
I am trying to migrate data using csv source to Drupal 8 installation using Drush and Drupal Migrate Tools. I am able to execute all the drush commands including the one to check the migration status (drush ms). But while I execute Migrate Import command (drush migrate-import {migrate-id}), I am getting the following error:
PHP Fatal error:  Class 'Drush\Commands\DrushCommands' not found in {SiteName}/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php on line 23
Drush command terminated abnormally due to an unrecoverable error.                                                                         [error]
Error: Class 'Drush\Commands\DrushCommands' not found in
{SiteName}/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php, line 23

What am I doing wrong here?
Drupal Version: 8.9.3
Drush Version: 8.1.17
Migrate Tools: 8.x-4.5


texts: How to add country suffix to the hreflang tags?

texts:
I am working on a multilingual site. In which I am using Alternate hreflang module and everything working as expected.

But it should look like

    <link href="/es" rel="alternate" hreflang="es-ES" />
   <link href="/es" rel="alternate" hreflang="es-MX" />
    <link href="/es" rel="alternate" hreflang="es-AR" />

Means in hreflang need to add country name as suffix like es-ES, es-MX etc.

Tried like below but its not working.


texts: jquery.cookie.js is loaded only for authenticated users, by jQuery update module

texts:
jquery.cookie.js is loaded only for authenticated users and i cannot really figure out why.
The page caching is disabled.

Any thoughts?


texts: Where can I learn the views 3 API? I can use the ui to make views but I would like to create views using the API in my modules. I would settle for the views 2 API at this point. I looked at the docs and did not get very far. Anyone know of a good tutorial?


texts: How do I get a data value after all AJAX calls are complete?

texts:
I'm modifying the content of the modal window that pops up when using Linkit module in a WYSIWYG.

This modal uses AJAX so I have to use Drupal.behaviors for the first time.  My code is structured basically like this:

(function ($) {
  Drupal.behaviors.mymoduleLinkit = {
    attach: function (context, settings) {
      $('#linkit-dashbaord-ajax-wrapper').once('linkitSelects', function() {
        //do cool stuff
      });
    }
  }
})(jQuery)

Now, I need to get the existing value of an input box here, so I simply do this:

var $existingData = $('.form-item-linkit-rel input').val();

Then try to return that value, but it's always undefined. I think it's because this page seems to do a few AJAX calls in a row and I am trying to get the value before it is actually loaded into that field and available.

To ensure that waiting until AJAX is loaded is actually the problem I wrapped my code in a timeout() in order to wait for the loading to finish.  This isn't a good solution, but it confirms everything is working once things are loaded.  It looked like this:

   //wait so data is loaded via ajax
  setTimeout(function() {
    //set our select list to any pre-existing values
    var existingData = $('.form-item-linkit-rel input').val();
    if(existingData != ""){
      var $parts = existingData.split('_');
      $('.form-item-linkit-rel .size-select').val($parts[0]);
      $('.form-item-linkit-rel .type-select').val($parts[1]);
    };
  }, 500);

So the question is:  Instead of using a timeout, how can I fire this code only after the initial ajax calls are done?

You can view the full code here including the timeout stuff but please don't get distracted by all the other stuff going on (or my poor coding)...Everything else in here works and I'm really just concerned with getting the data in the question above.


texts: Prevent trigger of other hook_preprocess_HOOK()

texts:
Is there a way to prevent other preprocess hooks from being triggered?

I have a Drupal 8 hook_preprocess_HOOK() implementation, and I'm doing some alterations. There will be other modules with same hook, and I need the other preprocess hooks not to alter my changes to $variables.

The only options I have are:

Rely on weights system, which still could cause problems
Set a value inside $variables and prevent other modules from doing their thing if the variable is set


texts: Faceted search using fields from a related node, is it possible?

texts:
Drupal 7
Modules:
Facet_api 7.x-1.3
Search_api 7.x-1.6
Relation 7.x-1.0-rc4

My site has two nodes, node one provides a description of various astronomical objects and node two are images and their composition details. I’ve built a many to many relationship between the two nodes and there is a node index (search_api) which contains all fields from the two content types with facets enabled on the primary fields.

I’ve created the faceted search page for the Astronomical objects which works fine and I now want to extend the Astronomical facets to gallery search page (. e.g. Show all images containing an astronomical object of type galaxy) which is where I have become stuck as I can’t see a way to create an index which joins relationships and nodes.

If this approach isn’t possible the only alternative I can think of is building out the relation type with extra fields duplicating the data that I want from either node and building the index on it, which just feels like a hack. Any suggestions?


texts: How do I create a view showing all the commerce store products?

texts:
I am using Drupal 8 Commerce v2.19. I am trying to create a view that shows all the store products. I have created the Search API index of the products, indexed the store field as in this screenshot.

This is the contextual view filter. Nothing happens after placing the block in www.example.com/store page. It displays all the products of the website.


texts: Drupal Commerce: How to make more than 50 types of a product variation?

texts:
So I have an online printing shop, each of my products can have different variations which can adjust the price, such as "Print type", "Coating", "Round corners", "Size" & etc...

As far as I know for being able to make different variations of a product (let's say a business card), I have to add all the different type of variations as a product, then add it to my product display.

It works fine in this way but I have a lot of variations, Imagine if a customer wants a business card with no round corners with the rest as default options (1 product that I have to add), the next customer wants a rounded corner (second product) and the list goes on and in this situation I have to add more than 1000 product which is just a overkill.

I'd like to know if there's a better solution for product-variations and my issue.


texts: What is the purpose of the "Links" field in the "Manage Display" UI?

texts:
In admin/structure/types/manage/my_content_type/display, you can hide/show the fields to display.
There is a Links field that you can also hide/show.

What is the purpose of this field? Nothing is changing in my output when I hide it.


texts: Webform submission value as date field default

texts:
I need to populate a webform date field with the value of another date field.  Here’s the yaml:
copied_birthdate:
  '#type': date
  '#title': 'Birthdate'
  '#help_title': 'Birthdate Format'
  '#help': 'Please enter your birthday in MM/DD/YYYY format.'
  '#date_date_max': '-18 years'
  '#date_date_format': m/d/Y
  '#default_value': '[webform_submission:values:birthdate_primary_contact:html_date]'

If I use that same value [webform_submission:values:birthdate_primary_contact:html_date]   in a text field, it populates just fine, but I can’t get the date to enter in the date field.
So far I’ve tried:
[webform_submission:values:birthdate_primary_contact]
[webform_submission:values:birthdate_primary_contact:html_date]
[webform_submission:values:birthdate_primary_contact:date:html_date]
[webform_submission:values:birthdate_primary_contact:raw]
[webform_submission:values:birthdate_primary_contact:mdY]

Any suggestions?


texts:
I would like to access the title of the node a field belongs to in a field.tpl.php file. My goal is to transform the field into a mailto link that would use the node title as the subject field.
Is it possible to access that information at this point?


texts: Preset settings and lock on a custom field type

texts:
I have created a custom Drupal 8 module which defines a custom field type and the corresponding formatter and widget for that.

This field should be added by the admin to whichever Content Type he wants. The module's code, on specific occasions, will detect if this field type exists on a node and do some extra actions if it does.

Although the admin is responsible to add this custom field type to any CTs he likes, i would like to preset, with code, the internal settings of this field (e.g. make Allowed number of values = unlimited by default) and preferably lock the settings of the field altogether.

Scenario would be that admin adds the field to the desired CT and is allowed to make no changes to the field settings.
This way the field will be securely configured, by the module itself, and the module's code would work as expected at all times without fear or extra checks that specific settings are not changed by the admin.

Is that possible and if yes how could it be implemented?


texts: How to use Form API #attached and module's own scripts with jQuery Multi module?

texts:
I was using jQuery Update module, but it conflicts with Views and feature requests for library version per page or per theme are consistently killed. On the other side, Views maintainers seems to assume that if UI works with distribution's jQuery, it isn't broken. Long story short, I was forced to forget about jQuery Update the way we know it.

Solution I found is jQuery Multi module, as it allows load updated jQuery only, if there is a library that requires it in use on the page. And for things like Chosen (when jQuery Update is hacked out of requirements) it works great. Now, I have problem with javascripts directly attached to forms:

$form['#attached']['js'] = array(
  drupal_get_path('module', 'aat_pc_product') . '/js/tag.js',
  drupal_get_path('module', 'aat_pc_product') . '/js/tabs.js',
  drupal_get_path('module', 'aat_pc_product') . '/js/categories.js',
);

jQuery Multi claims it can be used on any js file, but it's documentation says:

  C) Put the JS anywhere else, like in a custom module, and use hook_jqmulti_files() to load it. No need to use the alias.
  38

  D) Put the JS anywhere, use the provided alias, and don't use the jqmulti hooks or UI. Simply load with drupal_add_js() or something similar. If you're only using this method, make sure to select the 'Load Always' checkbox in the jQuery Multi config.

Now, I can't do C) as I'm using Form API and I can't do D) as it breaks Views.

Form API for #attached says:

  Description: Allows loading of CSS, Javascript, libraries,

Converting my scripts to a libraries would help, as A) and B) options for jQuery Multi are for libraries, but only examples provided by Form API are for JS and CSS files.

There is one use-case for libraries provided:

$form['#attached']['library'][] = array('system', 'jquery.cookie');

but it's there without description.

I can make my scripts library:

function amymodule_library() {
  $module_path = drupal_get_path('module', 'mymodule');
  $items = array();
  $items['mymodule_form'] = array(
    'title' => t('My Module Form'),
    'version' => '1.0.0',
    'js' => array(
        $module_path . '/js/tag.js' => array(),
        $module_path . '/js/tabs.js' => array(),
        $module_path . '/js/categories.js' => array(),
    ),
    'css' => array(
      $module_path . '/css/mymodule_form.css' => array(),
    ),
  );
  // dpr($items);
  // die();
  return $items;
}

And attach it as a library to a form:

$form['#attached']['library'] = array(
  array('mymodule', 'mymodule_form'),
);

Sadly this does not make it appear on the configuration screen:

I know it's due to the first 2 methods described in documentation:

  A) Put the JS in sites/all/libraries/ and use the UI at admin/config/system/jqmulti to select your library. All the library's JS files will be loaded with the jqmulti jQuery version. There is no need to use the alias in this case. This is ideal if you're using a prepackaged jQuery library or plugin.

  B) Put the JS in sites/all/libraries/ and use hook_jqmulti_libraries() to include the library. No need to use the alias. This is ideal if you're using a prepackaged jQuery library or plugin, and is equivalent to method A.

Of course I cannot put my scripts there, they are built in part of my module.

Now, I'm perfectly open to module hacking, if that's what needed, but if there is a way to "pretend" that my module's library is in the folder jQuery Multi wants it to be, I would be grateful to know it.


texts: how to get the arguments from the URL and store it for further processing in views drupal 7.I am passing a token from a webform to a view through custom redirect URL.Later i need that value for some calculations.I need some help on how to do this.


texts: REST API OAuth Authorization and Authentication

texts:
I am very much confused about the way OAuth authorization and authentication works in Drupal 8/9.
Let me put my points first, please correct me if I am wrong.

Authorization is when an entity proves a right to access.
Authentication is when an entity proves an identity.

I have done the following to implement a REST API which is intended to be consumed by mobile applications (Android and iOS).

Installed and/or enabled modules: Simple OAuth, REST UI, RESTful Web Services, Serialization.
Created a new role for specifying the scope of simple OAuth consumer, and set required permissions.
Created a consumer by adding RSA key pair, password and scope.
Succeeded in getting the response from /oauth/token by submitting a request body containing grant_type, client_id, client_secret, username and password.

The question is, why we need to send the username and password, for getting the access_token, since we are only trying to Authorize the API Request and NOT Authenticate the User?
Also, what should I do to Authorize the API request with OAuth but need to access contents without authentication? Should I create a dummy user and always send this user credentials to get access_token?
It would be very helpful if someone can explain the concept and how should one proceed.
Reference I followed: https://dev.acquia.com/blog/decoupled-drupal-authentication-oauth-20


texts: Enable new modules dependencies on deploy

texts:
How can I automatically enable new dependency added on a custom feature (or standard modules) with drush?

After getting the new code, my deployment script basically run:

drush cc all
drush fra

But I need to visit the admin/structure/features page if I added new dependencies otherwise those modules are not enabled. How can I avoid it? Is there a drush command? I can't use drush en thenewmodule because I want to keep my deployment script generic.


texts: Views programmatically remove node access (tag)

texts:
I'm trying to remove the node access check from a view programmatically.
But i'm not sure where the access tags are added/executed.

function MYMODYLE_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
kint($query);
}

If i print the $query the tags are empty, and i can't really figure out where or when those access tags are added. And how to manipulate them.

Can someone point me in the right direction?

Drupal: 8.3.2


texts: Generating Images from image styles in drupal 7

texts:
I'm just getting accustomed to the changes in drupal 7, I've created a number of nodes that have an image field. The nodes were created as dummy content from the Devel module. I then created a view, added a number of fields, and chose my image style as a formatted for one of the fields. The only thing I can't figure out is how to get Drupal to generate the the images, I tried re-generating the dummy conent, but it still does not create the thumbnails.

Any Ideas?


texts: How to jump to another know page on a button click?

texts:
I need to implement a select list (something like auto-complete in JQuery UI) with a Go button on a mini-panel (or block). I can do this in Javascript. When the user selects a value, a corresponding page (for example: article) URL is computed.

Assuming we know the URL of that page, how do I get Drupal to jump to that page when the user clicks on the Go button? I am no expert in PHP, but could implement some if necessary, or is there a better solution?


texts: Create a node on user account creation. Display link to user on first login

texts:
I need to capture addtional private information about a users company
when they register (one time).

What i am currently doing.

Creating new node on account creation with rules.
Add a view that filters by node author, and display it on the users profile, with a edit link.
The user can then edit the node that he is the author to on his profile page.

This works

I want to display a link or auto redirect to the node once the user has logged in for the first time.

Been busy with this for a long time. Any advice or Pointers.


texts:
I've configured workbench as per tutorial, everything works fine until i've handful of users but when I imported about 7000 users (authors) and when I open Add or Edit content type form for editorial it take more than a minute to load and sometime throws timeout error.

I'm showing Author field (auto-suggest and not dropdown) on content type add / edit form.

pulling out my hair to understand the cause. when I disable workbench email module everything becomes normal, page loads in less than 5 secs.

appreciate any answer or hint to solve this issue. is this due to any mis-configuration of workbench access module?


texts: How to configure or style an Openlayers source?

texts:
I'm just getting started with Drupal Openlayers. I've created a simple map consisting of one views geojson view. What I want to know is how to customize the display of the layer, such as the type of marker for the points, etc. I'm just not sure where these setting are.

Any advice would be appreciated.


texts: adding a field to the form during form_validate

texts:
I am working on a node form in which my users can add sport-teams (which I'll handle through a taxonomy) that are related to the node (say it's a blog-entry about your local rugby-team and you want to relate it to the team's taxonomy entry). To each team entry, I also have a db-table with a corresponding zip-code of the teams headquarter (say your local rugby team comes from cardiff).

Now the users can also add teams, that are currently not in the taxonomy list (through the use of taxonomy-autocomplete (i.e. tagging)). When that happens, during form_validate, I fire a form_set_error() and ask the user to type in the City the team is coming from.

In effect, I want to add a field to the form during form_validate. But how do I do that?

I tried, to no avail, adding the following to the $form variable in the form_validate function:

$form['field_new_team_location'][$i] = array(
'#type' => 'textfield',
'#title' => t('new team location'),
'#default_value' => $node->title,
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#description' => t('description')
);

EDIT Alas, although Charlie S' answer helped me to put up a field during validation (read: the html gets displayed; I can write in them), but it seems I cannot access it in a follow-up validation. In fact, when I hit save again, neither $form nor $form_state have the newly created fields in them! Any help accessing my fields is much appreciated!

2nd EDIT With what Charlie S said, it works. One thing that holding me up was that the form only gets rebuilt when no error messages are being cast. In other words, every required field has to be supplied before the form gets rebuilt and the user is able to input something in the new fields.


texts: "Process 'Apache web server' failed to start. Port 8083 didn't open"

texts:
I'm trying to install Acquia Deve Desktop 2 for my windows 10 PC. When it's finished installing and I run the program, an error pop up message shows up saying Process 'Apache web server' failed to start. Port 8083 didn't open.

I should point out that I do have XAMPP installed in my PC, but I also read in the documentation that even if you have XAMPP installed, it won't interfere.
What am I doing wrong here?
I just want my Drupal websites to load faster because on XAMPP they're pretty slow.


texts:
I want to change the contents of a status message, it is being brought in via the commerce module (commerce_cart.rules.inc).

The error message I want to change is:

/**
* Rules action: displays a the default translatable Add to Cart message.
*/
function commerce_cart_rules_add_to_cart_message($product) {
  drupal_set_message(t('%title added to your cart.', array('%title' => $product->title, '!cart-url' => url('cart'))));
}

I don't want to apply a patch to commerce just to change a status message so does anyone know of any alternate solutions?

Thanks


texts: Use data from one textfield to populate other textfields in drupal 7 form

texts:
I am new to drupal. I have a drupal form having fields Customer Name, Address and Phone. Is it possible to populate Name and Address Field automatically from database when the phone number is entered?

I am using Drupal 7.

Please help me and treat me as a beginner. Thank you...


texts: duplicate search field appearing with just one block

texts:
There's suddenly two search fields appearing on my dev site. I'm afraid I'm not sure what the last change was before this.

There's just one standard Drupal search block configured

here's the html from chrome's inspector

Configure block

  <form action="/" method="post" id="search-block-form" accept-charset="UTF-8">

Search form

  Search
 <input title="Enter the terms you wish to search for." type="text" id="edit-search-block-form--2" name="search_block_form" value="" size="15" maxlength="128" class="form-text">

<input type="submit" id="edit-submit--6" name="op" value="Search" class="form-submit">
<input type="hidden" name="form_build_id" value="form-siNBZmrvpwkL6N9gfwu4Li2LBMPzp0TVxw81H7C4H2U">
<input type="hidden" name="form_token" value="nxWBZ6gSMs4INvrbfpGyfd4DTr2QhLdfSrjuYA5PSC0">
<input type="hidden" name="form_id" value="search_block_form">

</form>


texts: Maintaining libraries on a live site without Composer

texts:
I notice this question has been asked several times on here - and each time the answers always seem to involve using Composer one way or another! :-)

I get that one can get around shared hosting constraints by using Composer in their local dev environment and then uploading the lot, but what about maintaining libraries without Composer at all. Is it even possible?

I recall in D7 it was possible to manually download and maintain libraries in a nominated folder location. Is this still possible in D8?


texts: How can I hide a page for a specific language?

texts:
I think I may be missing something obvious here. I need to completely hide a specific page for a specific language. Blocks have a language visibility setting put pages and menus do not have anything similar and I haven't found a module for this functionality.

What is the best method for removing/hiding a page if a specific language is selected on a site? For example, About Us page shows for all languages except for German.


texts: Error: OAUTH2 SERVER LIBRARY Unavailable

texts:
I have a website in drupal version 8.3.3 and since I installed oauth2 server module, I get the below error in Admin -> Reports -> Status Report

The OAuth2 server library is required for the OAuth2 module to function. Download the library using composer, downoad it from GitHub or use composer manager.

So I have added OAuth2 server library by running the below command

$ git clone --branch master https://github.com/bshaffer/oauth2-server-php.git

This command executed successfully and also the files are created in libraries directory. But still I get the same error

Note: I followed the instruction from https://www.drupal.org/node/1938218


texts: Create image style options, when user is uploading an image

texts: Is there any way to provide image style options, when user is uploading any image and can select any style from the drop down?


texts: How to unset the title of a custom form field

texts:
I'm trying to unset the label of a custom form called email. In which the value is in the #title key.

I've tried {{ value|without('title', 'description', 'email.#title') }}

But it is not working


texts: List all available items with Apache Solr if the search keyword is empty

texts: I have created 2 search pages with Apache Solr module one with content type filter and another for search in taxonomy terms. By default if the keyword string is empty the search pages don't return any results. How can I list all available items with certain content type or with taxonomy term in this case? Thanks


texts: Creating nodes with Views Bulk Operations

texts: This seems like it would be a common application but not sure if it is doable.  I have a view (d7, views3) that is displaying fields in views bulk operation format from a content type (call it general).  For each row the user selects, I want to create a node of a separate content type (call it userspecific) made up of the user id and some of the fields from the general content type.  Is this something that is possible using VBO ??


texts: 240sec Registering New Account with Services

texts:
I am working with a fresh copy of Services 7.x-3.4 / user resource enabled.

A POST to api/user/register is made with Content-Type header application/json and body:

{
   "name": "ffftest",
   "pass": "123",
   "mail": "afsdf@awdfasd.com"
}

The Drupal user is created immediately, but the HTTP request takes about 240sec to respond. When that finally happens, the response is good: status 200 with the uid/uri.

How do I find out what's going on with the HTTP response and get Services to respond immediately?

(Possibly related to the new CSRF token https://drupal.org/node/2013781#comment-7508325)


texts: Handle database connection exception via custom handler

texts:
I want to catch the database connection exceptions with a custom handler. I have already built an handler which is overriding the default logger factory, but now I want to use that custom handler to log database exceptions, without hacking the core.

I can see the connection driver uses the following code in open().

try {
  $pdo = new \PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
}
catch (\PDOException $e) {
  if ($e->getCode() == static::DATABASE_NOT_FOUND) {
    throw new DatabaseNotFoundException($e->getMessage(), $e->getCode(), $e);
  }
  if ($e->getCode() == static::ACCESS_DENIED) {
    throw new DatabaseAccessDeniedException($e->getMessage(), $e->getCode(), $e);
  }
  throw $e;
}

I am not sure how I can catch the exception and log it using the handler. How can I achieve this?


texts: As documented here, it seems the Economist is using Drupal for most of it's site.  I am just curious if anyone has information on the number of servers and their config.  Any idea?


texts: Set up Node content 'localization' / site wide region filter - similar to languages idea

texts:
What is a good approach re structure and modules to be able to render site content based on a location drop down? It is not an option to display all the content via views.

I'm aware of Views Global Filter. This is be good, but it doesn't work against nodes for one. Therefor only addresses some of the site content.

In principle the user would select from a dropdown a location (custom, based on municipalities). This would then dictate the content presented to that user.

From the admin side, the menus stays the same. One could then create different 'versions' of the same page, each flagged for a specific locality. If the locality doesn't have a corresponding node version, the 'default' node version would be displayed.

Ultimately, I would like to be able to use one dropdown (session stored) that will affect the node content displayed, other views used on different pages and search results.

The translate module is very close, but I don't need the translate functionality, but the rest. Where a few objects are associated to the same url, but rendered depending on the filter.

  Example
  Something like this (-no it's not a multi-council site, just the concept here):

id    page     name               zone
--    ----     ----               ----
1      1       Local Council      East
2      1       Local Council      West
3      1       Local Council      North
4      2       Building permits   East
5      2       Building permits   West
6      3       Pet Registration   East
etc...

  main-menu:
  Home | Local Council | Building | Pets

Therefor, the first page version will be the 'default' and any subsequent ones are then flagged for a zone. If a zone does not have a node with their flag, the default is displayed.

Location offers an option to get a location associated to the node, but how do I track the different 'versions' of the same page to same menu item then? And how do I stop search from giving me every version as a result?

I can see various bits that is getting close, but if some could explain the puzzle pieces please.


texts: Accessing element in REST export view json response

texts:
I have an API created from a REST export view, now im trying to do some behat test, but im getting some strange/different result when accessing an element in the json formatted response.

Using this method to evaluate if the expression is valid/invalid:

public function evaluate(Json $json, $expression)
{
    if ($this->evaluationMode === 'javascript') {
        $expression = str_replace('->', '.', $expression);
    }
    try {
        return $json->read($expression, $this->propertyAccessor);
    } catch (\Exception $e) {
        throw new \Exception(sprintf('Failed to evaluate expression "%s"', $expression), 0, $e);
    }
}

This is the output of a regular node/content when I access node/1/?_format=json and I was able to get the nid value by typing nid[0].value. This is enclosed in a curly braces and I believe its an object.

{
    "nid": [
        {
            "value": 1
        }
    ],
    ...
}

However, in my REST export view(path = api/custom/1?_format=json) json formatted response of a custom content type that I noticed, is enclosed in [], I get this result:

[
    {
        "user_id": "test",
        "title": "title"
    },
    ...
]

But I am not able to access either of the fields, tried user_id or title.

Other examples that is valid and invalid:

VALID by accessing data.type, displays article

{
    "data": {
        "type": "article",
        "id": "123",
    ...
    }
}

INVALID expression, tried id[0].value or id.value

[
    {
        "id": [
            {
                "value": 398
            }
        ],
    ...
    }
]

Parent issue


texts:
I'm using Drupal 7 with Webform and Content Access contrib modules.

I wrote a little snippet that displays all items for a given menu, and greys out the ones that the user doesn't have access to, while the accessible ones are links.

I get the access control information with

menu_link_load(menu_load_links(menu_my_menu)[mlid])[access]

...if that helps at all. It returns 1 if access should be granted, and NULL if not.

The problem I'm encountering is that, while this code works swimmingly for normal nodes, webforms seem to return a 1 for access even when the logged-in user does not have permission to submit that form. So the link shows up, and then it takes the user to a page that says "You do not have permission to view this form."

What function do I call to find out whether a webform of a certain path (or title or whatever I can find out from menu_link_load) should be visible to the user?