texts: want to create custom rule for like post or comment?

texts: I want to write a code for custom rule.I want to that when some one post a comment then one can able to like his/her post or comment i.e a single click on the Like will 'like' pieces of content and a message is send to that user who posted that comment . Is it possible with rules ??


texts: Is it possible to modify help text on a vocabulary page?

texts:
I am using a custom way of managing relations between terms in a particular vocabulary so I want to disable (or at least hide) the built-in functionality allowing terms to be placed in a hierarchy.

I have managed this to some extent with CSS (managed by the module that also does the custom relations). I have removed the "Relations" section from the taxonomy term edit form and I have removed the handles from the vocabulary list so that you cannot move the terms around and place them in a hierarchy that way. But I cannot see how to get rid of, or alter, the help text which says "You can reorganize the terms in Topic using their drag-and-drop handles, and group terms under a parent term by sliding them under and to the right of the parent.".

The problem is that there are no containers around this to identify which vocabulary is being adminstered, or indeed that it is on a taxonomy vocabulary list page at all. I have read the Drupal 8 docs on attaching libraries and they all say that targeting pages by URL is deprecated.

I suspect hook_form_alter would not work either as it is outside of the form tags.

Is there any way to do this?


texts: How to remove nodes with the same title from views listing?

texts:
Just this, how to remove nodes with the same tilte from views listing?

These nodes are NOT duplicated node, they only have the same title.


texts: Rules component parameter form: choose node from drop down list

texts:
I create new rules component with parameter of type Node. In the form it provides the textfield input to enter the Node ID.

Is there any way to make a drop down nodes list instead to choose one?

Is there any way to put a view in that form to choose parameters via VBO?


texts:
My default download method is public, but I need save some file on private folder, I am doing this:

//...
$file = file_save_data($handle, 'private://example.zip', FILE_EXISTS_REPLACE);
//...

Now when I try show to download it:

//...
$file = file_load($file_fid);
$url = file_create_url($file->uri);

$output['download'] = [
  '#type' => 'markup',
  '#markup' => l(t('Download'), $url),
];

return $output;
//...

If I do click on the url, I get:

  Access denied. You are not authorized to access this page.

I am superadmin (uid = 1). How I can management those files for me and for others users?


texts: Is it possible to have a function call within one module which calls a function of a different module even if that function has not been defined as  a hook?


texts: Difference between upgrade and migration

texts: What is the difference between upgrade and migration in Drupal?


texts:
I haven't been able to find a way to change the display of a price from 1.23 USD to $1.23.
How do I change the currency display from USD to $?


texts: D7 + Views 3 - How to reproduce a teaser with fields in Views

texts:
I need to build a "News" block on a website that shows teasers of certain categories.

BUT I cannot use teaser views because I don't want the styles that are in a teaser view. This rules out the viewsnodefield module and teaser option available in the first page of view creation.

My question is: how to reproduce a teaser using fields? How do I get the teaser content? How can I rewrite the link by surrounding the url link field?

Thank you for your thoughts


texts:
I am using Drupal 8, and I am wondering how I can clear more caches than the button in admin/config/development/performance does.

I have had trouble with installing Drush, so I am looking for any alternative solutions.


texts: Can someone explain how Text Formats work with CKEditor profiles? Very confused

texts:
sorry if this is a silly question, but I'm stuck.  I'm trying to figure out the relationship between profiles configured in CKEditor and those configured in Config>Text Formats.

Some context:  In CK editor (Config > CKEditor), I set up three text editor formats:
- "Admin": Full editor for admin
- "Editor": Filtered-but-robust text editor for editors and bloggers
- "User": Filtered-but-VERY-simple text editor for everyone else.

In CKEditor, I don't see a way to assign these profile to different roles.

When I head over to Config > Text Formats, I DO see the ability to assign them to roles, and some configuration options.

Can someone explain the relationship (if any) or what I am missing?

Thanks in advance!


texts: Make a directory and link it in a node at node creation

texts:
I’m developing a site in Drupal 7 where users view a calendar of events as well as photos taken at those events.

I’ve already created an Event content type, generated several Event nodes, and put those nodes together in a Calendar view.

What I want to do now is add a ‘Photos’ link to Event nodes. Clicking on this link should open a gallery of photos for the given event. For example, imagine a user is viewing an Event node titled ‘Pool Party @ Jan’s House’. The user clicks on the node’s ‘Photos’ link and then sees a photo gallery also titled ‘Pool Party @ Jan’s House’ that displays all and only photos taken at that event.

How do I get the following two actions to happen (automatically) when an Event node is created?

Make a directory that will contain photos for the event. (These
photos will be uploaded later by users who attend the event.)
Include a ‘Photos’ link in the newly created Event node that opens a page display of the directory's files. (See the example I give above.)

I’ve been trying to figure this out using the Media, Rules, and Views modules, but I’m not making much progress.

Thanks in advance for your help.


texts: I can't log in into a MAMP multi-installation

texts:
I know this is probably something super simple, but it's one of those days...

I have MAMP set up on my computer so that I can have several local Drupal installs. I have one in a folder called d7 and another in d6. But I cannot log into either one for anything. I checked in the apache log and it says:

File does not exist: /Applications/MAMP/htdocs/sites/default

Which is the wrong directory to check. It should be checking /Applications/MAMP/htdocs/d7/sites/default. Is this why I can't login? What should I change in .htaccess and/or httpd.conf?

EDIT My added vhosts is:

<VirtualHost *:8888>
   ServerAdmin webmaster@d7.example.com
   DocumentRoot "/Applications/MAMP/htdocs/d7"
   ServerName d7.example.com
   ErrorLog "logs/d7.example.com-error_log"
   CustomLog "logs/d7.example.com-access_log" common
</VirtualHost>

Also added the port under NameVirtualHost. I have changed the base path in Drupal's htaccess and the server never hits the right file. There's nothing there where it's looking. It needs to look inside d7 instead of htdocs.

EDIT 2

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /d7


texts: Is it possible to redirect users when page caching is enabled?

texts:
I use simple redirect user inside template.php with the following code:

if ( isset($_GET['abc']) && $_GET['abc'] == 1 ) {
  drupal_goto('mypage');
}

Is it possible to redirect to the page even with caching turned on? It seems that if the page that I want to redirect from is already cached, the template.php file does not fire.


texts:
Hi sorry if this is a simple question, but I could not figure it out on here

My question is about function scope, my code is as follows:

(function ($, Drupal){
  Drupal.behaviors.map = {
     attach: function (context, settings){
        var map;
        function initMap() {
           map = new google.maps.Map($('#map'), {
              center: {lat: -34.397, lng: 150.644},
              zoom: 8
           });
        }
      }
   };
 })(jQuery, Drupal);

In my theme.libraries.yml I have:

 https://maps.googleapis.com/maps/api/blah&callback=initMap: {type: external, attributes: {async: true}}

But on my console I get:

initMap is not a function

So my question is how to allow callbacks to reference to my function initMap?
It works if I do the less optimal way $(document).ready...


texts:
I am porting an existing custom form that takes optional arguments from the URL to preload some fields. I can not use the ?q= method because I must maintain backwards compatibility. For example, both of these URLs are valid:

shop/barn
shop/barn/small/white/red/double/tin

The problem I am running into is how to setup this with Page Manager to accept an optional argument. If I set up my url to be:

shop/barn/%settings

and map %settings to a string, I can get it load the optional arguments! But ... shop/barn does not work. The only way I've figured out to resolve this so far is to create two pages with the exact same panel setup. I would really like to condense this down to one.

I have a feeling the answer lies in something to do with making a custom ctools arguments plugin as the author posted for Panel Pages and Taxonomy Term Arguments. I have tried modifying line 48 in the simplecontext_arg.inc in the ctools_plugin_example module with the following to accomplish this:

if (empty($arg)) {
  $arg[0] = '123';
  return ctools_context_create('simplecontext', $arg);
}

Unfortunately, this displays a blank panel when I visit ctools_plugin_example unlike visiting ctools_plugin_example\123.

This is being implemented on a Drupal Commerce site, so in a perfect world I would also like my panel pages to override the node/%node path with the optional argument so that I can more easily and consistently change the path of my product displays in the future instead of having to manually maintain a bunch of URLs.

I am also open to suggesting something other than Panel Pages, such as overriding the node--barn.tpl.php files.


texts: How to set user search and filter preference on account registration

texts:
I'm bulding a dating site, and I want users to have default search and filtering capabilities.

The field in question is gender.

I want users to be able to choose default search parameter to male or female. So when they access the view, it will only show them males or females, depending on their choice at registration and user account profile settings.

I'm pretty sure core functionality can do something like that, but I can't figure out what kind of settings to use...

I'm attaching the image to demonstrate what I am trying to acheive with an example from another website, the fields "I am a man" >> "I want to find a woman"


texts:
I find myself wanting to control whether a menu item is shown on certain pages, much like how I can control how blocks are only visible on certain pages.

I cloned the menu using the Menu clone module, but have already experience maintenance issues and can only see it becoming more of a problem when the site goes live...

Is there a clever way of controlling menu item visibility?


texts: Views - Wrapper Fields in DIV after ROW class


texts:
I'm setting up a Drupal API, using jsonapi. In the frontend application, we would like to get all content, regardless of content type, with one request. I came across this issue that adresses exactly that and a module has been worked on: JSON:API Cross Bundles
I have already installed the module, but I cannot seem to find how to use it. I assumed that I would just be able to request /jsonapi/node to get a response with all my nodes, but that doesn't seem to be how it works. Has anyone actually used this module and can explain  to me how to use it ?


texts: Adding a link to download the original image to a view

texts:
I would like to add at the end of the description a link like saying "Download HiRes Image" at the end of the caption of the image in this view, but I don't know how. I did try with the module DownloadFile but there is no documentation about it.

http://www.nellens.com/home/photos-full/segunda-serie


texts:
I created a new content type (Image), which has an image upload field set. Now I can upload images and they are now nodes. But what do I need to do to add them to other existing content types?

My guess was to turn the image content type into a block. Is this correct?


texts: How to register Field Handler class with Migrate module

texts:
I'm trying to use the migrate module to import some video fields. I'm assuming that I'll need to write an extension to the MigrateFileFieldHandler. I set up a shell class based on what I saw in the MigrateImageFieldHandler (which is a subclass of MigrateFileFieldHandler), however my class doesn't seem to get loaded.

My guess is that I need to register my Field Handler somewhere, somehow, but I can't find any instructions or examples anywhere. I know that I register Migrations in the hook_migrate_api but I can't find how or where I need to register Field Handlers.


texts: Bypass drupal theme with hook_menu() function?

texts:
I have a page within Drupal administration where I want to bypass all of the normal Drupal theming and calculations to only show the HTML that's returned by the function. Is this possible?

 $items['admin/special_blank_page'] = array(
    'title' => 'PDF',
    'page callback' => 'special_blank_page',
    'type' => MENU_LOCAL_TASK,
  );

//...

  function special_blank_page(){
      $html ='Only show this HTML';
      return $html;
  }


texts: Change the name of uploaded file based on content type and entity id

texts:
Consider this pattern :

  [content type]-[entity ID].[file:ffp-extension-original]

is there any hook so I can change the uploaded file name based on content type and node ID in drupal 8?

PS:

I used File(field) paths module but I couldn't find proper tokens to get it work right


texts: How to override Page Title of View using Contextual Filter

texts:
I have a view that uses a contextual filter for part of the URL. For example: www.example.com/categories/%/all

I have successfully replaced the % with the name of the taxonomy term from a specific category (for example, www.example.com/categories/shirts/all), but I cannot get the Title Override options to work.

Here's how I have things set up...

Contextual Filter - Indexed Content: Clothing Categories
When the filter value is NOT in the URL -  Display empty text
Override title - %1
Specify validation criteria: Validator: Taxonomy Term
Filter value type - Term Name Converted to Term ID
Transform dashes in URL to spaces in term name filter values  (checked)

When I preview the View result by typing the contextual filter "shirts", it does display the shirts and it does display the title "Shirts". However, on the live page, the View's title is displayed instead ("Category View"). I have tried deleting the View's title, but that just causes the front-end page to display no title.

Any idea on how I can get this to work, or any other methods to make it work?

Thanks!


texts: How can I filter a view by Content Type -or- Taxonomy Term and have both sets of items show?

texts:
I have a basic view that works great. It shows a list of nodes that are filtered by content type.

To that list of allowed content types, I want to add a taxonomy term. That is, the view should show anything that is a certain special content type, but ALSO include any node that has a certain special taxonomy term, no matter what the content type is.

The view that already works fine has its filter setup this way:

FILTER CRITERIA:

Content:  Content type (is one of: Blog, IM, PI)

Easy, no problem. To add the taxonomy term, I set it up this way:

FILTER CRITERIA

    Content:  Content type (is one of: Blog, IM, PI)  OR
    Content: Has taxonomy term (= News Release) | Settings

Here's where it went all wrong on me. As soon as I added the taxonomy term filter, the items that should be there by Content Type completely disappeared. Only items with the taxonomy term show up in the view now. If I remove the taxonomy term filter, then items in the Content type pop back in again. It's like the taxonomy filter suppresses the content type filter in some way.

I tried:

using Content: Resource Type (= News Release) | Settings which was an alternate way of listing the taxonomy, "Resource Type" being the vocabulary
using AND instead of OR but, as you would expect, that returned no results at all because I do not have any of the special three content types that are also labeled as the special taxonomy "News Item". They are separate use cases.
using filter groups, listing the content type, an OR, and a content type AND taxonomy:

Content:  Content type (is one of: Blog, IM, PI)
OR
Content: Content type (= Article) AND
Content: Has taxonomy term (= News Release) | Settings

To be clear, either the node is a special content type OR the node is a regular content type with a special taxonomy term. Never both. Both types of nodes should appear side-by-side in this view.

Am I not allowed to make a view that shows stuff filtered by taxonomy alongside stuff filtered by content type at the same time? Can anyone suggest something for me to try?


texts: An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows

texts:
I'm getting this AJAX error when I try Add content in Panel and see AJAX errors
 I have test at localhost the not errors but when I uploaded to hosting is have this problems.

I don't know why

My modules using:
Panels Bootstrap Layouts 7.x-3.0+12-dev, Panels 7.x-3.5, Nodejs integration 7.x-1.9, Chat Room 7.x-2, Views Bootstrap 7.x-3.1
Bootstrap version   jQuery 1.7.2, jQuery Update jQuery 1.7.2 (configure) and jQuery UI 1.10.2

Im check my status is
HTTP request status Fails
Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services. If you are certain that Drupal can access web pages but you are still seeing this message, you may add $conf['drupal_http_request_fails'] = FALSE; to the bottom of your settings.php file.

Thanks for any helps


texts:
I'm trying to build this:

Adopt NAME-OF-PET

the code I'm using:

$adopt_me_link_male = l(t("Adopt !name",
 array('!name' => $node->field_pet_name['und'][0]['safe_value']), array('context' => 'Male pet name')), 'node/163', array('query' => array('edit[submitted][nameofthepet_webform_fieldset][webform_nume_animal_comp]=' => $node->field_pet_name['und'][0]['safe_value'])), array('attributes' => array('class' => array('btn', 'btn-primary', 'btn-xs'),),) );

The above code generates the link but I have two problems:

the link looks like this:

Adopt NAME-OF-PET
there's no css class applied to the anchor

Why the classes are not applied and the link looks so messy?

Thank you!


texts:
I would like to write an interactive Drush script that potentially makes a change to all pages of a website.  Let's say we would would like to change "Foo" to "Baz" on each page.  We want to review each changed page before it is saved.  The code would look something like this:

foreach(website as node) {
  if node->body->value contains "Foo" {
    change "Foo" to "Baz" and display the changed version of body for the user
    Prompt User: Commit change? Yes or No
    if "Yes", save the node
    }
}

It appears Drush is buffering output so that I can not interact with the user in this way.  Is this possible?


texts: Show content of custom content type in a block based on taxonomy term

texts:
In D8 I have created two custom content types:

Store
Store products

It's not an e-commerce, I just need two custom types to show all the stores on one of the subpages and the products that each store has.

Because there are 24 stores, I would hate to create 24 custom types of a store products, so I also added a taxonomy term field to a Store product.

Now, I would want to show the Store products in a Block, depending on the taxonomy term.

For example:
I created Store A, which has products A1, A2, A3. If I go to the page of Store A, there should be a block that shows those products.

If I would go to Store B, the same block would show products of Store B.

I tried following this answer and added a contextual filter, but no luck so far:
Display content based on URL

What I did:

Created a View Block for Store Products
Added a contextual filter to the block (Has taxonomry term -> taxonomy term ID from URL)
Also added another contextual filter node:id
Added the block under blocks to render on the page Store


texts: Combine two or more filter criteria in views

texts:
I want to combine two or more filter criteria to a dropdown in views filter criteria. so that i can select a filter criteria in the dropdown box and can search with a string in a text box. so that the result will be similar to the string from the filter criteria which is selected from the dropdown listbox(combination of filter criterias).

Is there any way to combine the filter criteria as dropdown...?


texts: Workflow assign user to handle node in given state

texts:
I am using Workflow module to implement moderation policy in one of my project. It is working fine.
But I want is when a user changes workflow state of user, he must be able to select a given user also from given user group, who will be responsible to manage the node in that state.

So, ideally it would be drop-down of user, form where admin can select user to whom the the node be assigned.

I searched a lot, but didn't find any solution yet. Is there any way to achieve this.

-- Many thanks for your time.


texts:
I created 2 rules with the same action, which sends Drupal logs to the site. One is Content is created with the After saving new content (rules_entity_insert:node) event; the other one is Content is updated with the After updating content (rules_entity_update:node) event. Also, they use the same Condition: Node is of type condition.

I am using a REST request to create/edit a node. However, when I do a POST, I am getting 2 logs in the site, which means that both rules are being triggered. PATCHing a node is working fine: A single log is created.

Am I missing something?

I am using the Rules module 8.x-3.0-alpha3. The action is programatically created.


texts:
mvf field is not working with view dependant filter.

I created a mvf field .

I want its view filter with view dependent filter module .

Its filter is working fine when the field is not in dependant list .
But when i inclued it with Dependent filter its not hiding.


texts: mytheme_links__system_main_menu($variables) function not being called

texts:
I have created a custom template and i don not want the default menu structure of drupal 7.So I thought of creating a custom structure for this.In my custom theme page.tpl page i have called the
the following theme function.

<?php  print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu'))); ?>

I have created a new custom template.php file in the same theme directory where the page.tpl.php resides and defined the following function

function mytheme_links__system_main_menu($variables) {
  $html = "
\n";
  $html .= "
\n";

  foreach ($variables['links'] as $link) {
    $html .= "
".l($link['title'], $link['path'], $link)."
";
  }

  $html .= "
\n";
  $html .= "
\n";

  return $html;
}

but tthis function that is being included in the tempkate.php file does not seem to be called for some reason.Could someone please help me as o why the mytheme_links__system_main_menu is not called.Thanks in advance..


texts: Restws module exposing custom module content

texts:
I'm using RESTws module and access content via /node/id.json. I've written a custom module and use the "hook_entity_property_info" which exposes these fields:

{
  "entity_id": 6655,
  "cloudinary": {
    "publicID": "sdfg334fsdsdfv",
    "title": "test title",
    "caption": "test caption",
    "url": "http://res.cloudinary.com/cloudname/image/upload/asdfd",
    "credit": "© test",
    "keywords": "",
    "description": "sdfgdfsg",
    "primaryImage": "0"
    "width": "300"
    "height": "100"
    "ratio": "1.6"
    "crop": "{'height':100,'width':100,'ratio':1.6}"
  }
}

This works for a node (I can see all my fields). When I use a field collection the module field is completely missing:

{
    "field_answer_v": "test test test",
    "field_correct_v": false,
    "field_feedback_v": null,
    "item_id": "345",
    "revision_id": "345",
    "field_name": "field_answer_fc",
    "url": "http://url/cms/field-collection/field-answer-fc/13085",
    "host_entity":
    {
        "uri": "http://url/cms/node/3067",
        "id": "3067",
        "resource": "node"
    }
}

When I use "hook_field_collection_item_load", and print the value out in PHP, the module field is there!

"field_cloudinary": {
    "und":[ {
                "publicID":"asdfasdf",
                "title":"test",
                "caption":"",
                "url":"http:\/\/url\/image\/upload\/asdfds.jpg",
                "credit":"\u00a9 ",
                "keywords":"",
                "description":"test",
                "primaryImage":"0",
                "height":"1355",
                "width":"2048",
                "ratio":"0.661621",
                "crop":""
        } ]
},

The data is there but why is it not appearing in the restws module? Is there some other hook I need to use? This is causing some major headaches :-p


texts: Changing column names for CSV export in Webform results download page

texts:
This should be very basic. Unfortunately I couldn't find any page that provides specific instructions on how to do this. If anyone can point me in the right direction, much obliged.
Basically I just need to automatically rearrange and change the names of a few columns when I go to the submissions results download page in Webforms. That way, when I export in CSV, I get the column names I want instead of the ones I created in the actual webform.
I'm aware you can do this via a view, but I would like more specific instructions... Anyone know of any guide that can point me in a right direction?
Thanks.


texts: How to display page loading time in drupal 7 for each page

texts: I want to display page loading time in every page in the footer. I can do this through some custom php script but want to know that is there any drupal way to achieve this


texts:
I have an interesting problem where the comment body does not appear with the comment. The field wrapping is in the HTML but the content portion is always blank.

This problem occurs regardless of the theme, eg. the same result with Bartik.

The database entry for a comment is:

+-------+--------------+--------------------------------------+----------+
| cid   | comment_type | uuid                                 | langcode |
+-------+--------------+--------------------------------------+----------+
| 35044 |              | b6328985-9e15-46e4-a55d-8285e530ee55 | en       |
+-------+--------------+--------------------------------------+----------+

and the body:

+---------+---------+-----------+-------------+----------+-------+--------------------+---------------------+
| bundle  | deleted | entity_id | revision_id | langcode | delta | comment_body_value | comment_body_format |
+---------+---------+-----------+-------------+----------+-------+--------------------+---------------------+
| comment |       0 |     35044 |       35044 | en       |     0 |
Test text

 | basic_html          |
+---------+---------+-----------+-------------+----------+-------+--------------------+---------------------+

The comment displays on the node view as:

j ayen green

Mon, 05/20/2019 - 14:39

Test

And displays on the comment edit form as:

Edit comment Test
Open Primary tabs configuration options
View comment Edit(active tab) Delete Likes
Subject
Test

The comment field on the content type entry is:

Comments    field_comments  Comments

The Manage Display entry for Comments is:

FIELD     LABEL     FORMAT

Comment   Hidden    Default

The field on the comment type is:

LABEL   MACHINE NAME    FIELD TYPE
Comment comment_body    Text (formatted, long)

And the HTML is:

      j ayen green

      Mon, 05/20/2019 - 14:39

      Permalink

Test


texts: How to restrict access to the site during development?

texts:
I am creating a new Drupal 7 based site.

The development will be on a server that is publicly accessible. I am working in a multi-site environment.

I would like to totally block access to the site to anyone & anything but authorized users. Including access to the site name, theme, etc...

I used Secure Site for similar tasks before. It did http-level authentication and returned 403 when authentication failed. It doesn't have a D7 version.

What would be the easiest way to do this?


texts:
Using Views, I was able to apply CSS elements to content fields, but after applying Organic Group module and assigning each content to each group, I don't know how to take control of these content. The contents looks fine in the front page but inside the group's page it is a bit messy.

So is there's any way to fix that?


texts: Is possible to update a project that has been installed from the archive file?

texts:
I'm very new to composer, I've only used it to install the occasional necessary library for our D8 projects. At each Drupal update I normally run

drush up drupal

Which (among other things) replaces the vendor folder and composer.json, so on sites with library dependencies, I need to re-run

composer require [library]

Aware of the touted benefits of Composer as a dependency manager, I want to use composer to maintain our Drupal projects. However I've run into issues, namely that

composer update

or
    composer update drupal/core --with-dependencies
both give me "Nothing to install or update". After some reading, I found this resource https://github.com/drupal-composer/drupal-project. With this unzip, if I run

composer install

I get the correct latest version of Drupal installed in ./web. But when I use the yaml from the template composer.json file in my own composer.json file I still get "Nothing to install or update".

My folder structure is identical to the .zip distribution, so /core and /vendor and /sites etc are all in the same folder, so I have obviously adjusted the composer.json file according. But it doesn't matter what I do, I just get
"Nothing to install or update"
"Nothing to install or update"
"Nothing to install or update"

So, I'm beginning to think that composer update with or without dependencies REQUIRES YOU TO HAVE INSTALL THE DRUPAL 8 PROJECT WITH COMPOSER TO BEGIN WITH.

Is that right? If so, then I can move on.
If not then I need to know what I'm doing wrong. Right now it's not a big deal and I can manage the update process, but it seems each new project requires more and more non-core libraries, so I know composer will save me a lot of time in the future.

TL;DR - Can someone give me a kickstart to configuring my EXISTING, WORKING PRODUCTION SITES so I can use composer to update them, the usual ReadMe's don't seem to work properly with sites that weren't also installed with composer.


texts: How to create a view displaying fields only from block it was created in (Custom Blocks Types + Paragraphs)

texts:
So I'm trying to create a view on a slideshow content type. I want to create multiple slideshows. However, whenever I create a slideshow, I want to run a slideshow that only displays the slides from the paragraphs I created in that specific node.

NOTE: I don't want to add filters that only show from that specific node ID. I want something that works exactly how field collection views worked in Drupal 7.

Anyone know of any solutions?

[Update]

So while I started to go into this, I decided to change route of what I wanted to do. Learning more about how Drupal 8 works, I decided to change from making a slideshow content type to creating a new block type for slideshows. Inside the new block type I am using paragraphs for the slide information.

What I want to do is create a display view for the slides in each block type created (slideshow).

In my views settings I created a context filter by Paragraph ID. It's almost where I want it to be however, my view is only displaying the first item of the paragraph (the first slide fields). Its not until I put, (display all fields inline) does it show my slides. However, this doesn't help me with using flexslider or slideshow. I need them to be separate to have the slideshow work properly.

When I go to my fields tab and I look at my Slides (Paragraph). Under "Multiple Field Settings" it has the checkbock "Display all values in the same row".

I obviously want this unchecked because I need them to be in different rows for the slideshow to cycle though. If I leave it unchecked it only shows the first item in the paragraph.

Lastly, under the checkbox it says "If not checked, each value in this field will create a new row. If using group by, please make sure to group by "Entity ID" for this setting to have any effect."

However, it's not doing that, it just shows the first item and that's it. I'm not using grouped by so the last part shouldn't matter...at least I think it shouldn't.

"Help me, I'm poor"


texts: How is webform node type is defined in webform module?

texts:
Reading the webform module code I could not figure out how webform content type is defined. I only found this piece of code:

function webform_node_type($op, $info) {
  $webform_types = webform_variable_get('webform_node_types');
  $affected_type = isset($info->old_type) ? $info->old_type : $info->type;
  $key = array_search($affected_type, $webform_types);
  if ($key !== FALSE) {
    if ($op == 'update') {
      $webform_types[$key] = $info->type;
    }
    if ($op == 'delete') {
      unset($webform_types[$key]);
    }
    variable_set('webform_node_types', $webform_types);
  }
}

In variable table of drupal database I found the following webform_node_types variable: a:1:{i:0;s:7:"webform";}. When applying variable_get to this variable I recieve an array of 1 element with value - 'webform'.
Please help me understand how webform node type actually is defined and how it works?
Thanks


texts: How to add variables to Drupal.settings using form#attached?

texts:
I found this example: http://deeson-online.co.uk/labs/how-use-formattached-javascript-setting-drupal-7-form-api

I tried:

   $form['#attached']['js'][] = array(
            'data' => array(
                'my_module' => array(
                    'xx_code' => 'dsadsad',
                    'xx_key' => 'sadasd',
                ),
            ),
            'type' => 'setting',
        );

but with no luck, Drupal.settings.my_module is undefined


texts: I'm completely new to Drupal. I've installed Gist Input Filter. In blog, when I write [gist:6351376], as said in the project page, it just shows as it is. Please help.


texts:
I have noticed that PHP 5.2 is officially recommended for Drupal 5 and 6. But as the 'System Requirement' page needs update, I am wondering what would be the anticipated problems using Drupal 5.3.

I have been using PHP 5.3.2 + FPM on a Drupal 6.22 site, and have some JavaScript issues with the Voting UP/Down and Poll modules. Is it possible that I can resolve these by downgrading PHP to 5.2?


texts: How does the view filter: Search: Search Terms works? Can I improve it?

texts:
I have a View with and Exposed Filter: Search: Search Terms to filter the view result based in the keywords entered in this filter.

I works, but not as I expected.

Lets say I have a node with the title "The car, a good transport". Then:

if I enter the keyword: car the node is shown
if I enter the keywords: car a good the node is not shown
if I enter the keywords: good car  the node is not shown

Is this behaviour right? I need the node to be shown in all these situations

UPDATE: I see that there is already an open issue about this: http://drupal.org/node/1615438


texts: Form textfield on-click remove default values

texts: My objective is to automatically remove the default values within the form textfields upon either being selected/clicked on. Not really sure how to at the moment. Any suggestions?


texts: cannot login after theme change or backup/restore

texts:
I am using Drupal 7, with VMware 5.0.1 build-894247 with Ubuntu 12.10. 2GB ram, 20GB disk, 32 bit VM, hosted by Windows 7 Enterprise.

I am developing on a team with SVN (subversion) as the source control. All of this works fine on everyone else's (on my team) local dev environment and on our staging/prod servers.

I set up a shared folder from my C: drive on Windows called Sites (C:\Sites), and it appeared as /mnt/hgfs/Sites on Linux.

My dev folder is under that, so /mnt/hgfs/Sites/test.dev

I configured Apache sites-available to point to this new path, and enabled it. I setup the mysql database fresh, and ran through the default install of Drupal. No problems so far. At this point I can log in and out without issue.

When I make a change like importing a theme and setting the theme, then log out, I can no longer log in. The login screen will not even tell me why I am not being logged in (normally there is an error message... it is as if someone disabled java-script or something). If I blow away the database and recreate it, start over with the default install, it works again. My real goal is to enable a backup and restore that to the new site, but that changes the theme and more, and has the same problem (although the theme does change and content is there when I do this... just can't log in)

another kicker, if I move the files back to /var/www/ and re-point apache, it works again.
UPDATE: It turns out this problem does not have to do with VMware, as it is now failing in the exact same manner while in /var/www.

I have checked permissions and even set everything to completely unrestricted access (chmod 777 -R).

Any ideas why?
This seems very reminiscent of this other post too...

UPDATE: after hours of diagnosis, discovering drush, and playing with variables, my buddy  noticed this: If we switch the theme back to Bartik, and login from  login, it will fail without even showing an error message. BUT, if we just go to the home page, there is a login block on the left, and if we login there, it works! The top nav bar comes back and everything. Log out and try again from http://sitename/users, and it fails again. He thinks it may be a modules or theme-based permissions issue.


texts: EntityQuery PHP issue when assigning the query to a variable

texts:
I am very confused about this behavior of EntityQuery, or maybe I am just missing something basic about PHP.
Here is the query I am working with:
$entity_query_points1 = \Drupal::entityQuery($entity_type_id)
  ->condition($entity_type->getKey('bundle'), $entity_type_bundle)
  ->condition($entity_type->getKey('uid'), $uid)
  ->condition('field_int_points', 1, '=');
return $entity_query_points1;

This is fine.
But if this query returns no results, I wanted to immediately execute another query.  So I made a switch statement and wrote code like this:
$entity_query_points1 = \Drupal::entityQuery($entity_type_id)
  ->condition($entity_type->getKey('bundle'), $entity_type_bundle)
  ->condition($entity_type->getKey('uid'), $uid)
  ->condition('field_int_points', 1, '=');
$entity_query = $entity_query_points1;
$count = $entity_query->count()->execute();
if ($count >= 1) {
  return $entity_query_points1;
}

This fails with a WSOD (I am using this code with the JSON:API Resources module):
TypeError: Argument 2 passed to Drupal\jsonapi_resources\Resource\EntityQueryResourceBase::loadResourceObjectsByEntityIds() must be of the type array, string given, called in /app/web/modules/contrib/jsonapi_resources/src/Resource/EntityQueryResourceBase.php on line 97 in Drupal\jsonapi_resources\Resource\EntityQueryResourceBase->loadResourceObjectsByEntityIds() (line 125 of modules/contrib/jsonapi_resources/src/Resource/EntityQueryResourceBase.php).

If I use the following code, it works (query resolved correctly, no WSOD):
$entity_query_points1 = \Drupal::entityQuery($entity_type_id)
  ->condition($entity_type->getKey('bundle'), $entity_type_bundle)
  ->condition($entity_type->getKey('uid'), $uid)
  ->condition('field_int_points', 1, '=');
$entity_query = $entity_query_points1;
$count = $entity_query->count()->execute();
if ($count >= 1) {
  $entity_query_score1 = \Drupal::entityQuery($entity_type_id)
    ->condition($entity_type->getKey('bundle'), $entity_type_bundle)
    ->condition($entity_type->getKey('uid'), $uid)
    ->condition('field_int_points', 1, '=');
  return $entity_query_points1;
}

But... why?  I executed the count on $entity_query, but I have to redefine $entity_query_score1 to return the query as expected.  I know having to redefine the query means I have screwed up somehow, but I don't know what my mistake is.


texts: setHandler into views_pre_render OR count results in views_pre_render

texts:
I have a view that needs to have a custom views footer only if it get results. Otherwise the view needs to not be displayed

I can set up a view footer by using $view->setHandler with hook_views_pre_render and I can count results with hook_views_pre_render

How can I achieve both with a single function? Using $view->setHandler with hook_views_pre_render does not attach the footer


texts:
I am trying to modify a form with a hook_form_FORM_ID_alter within a module though it doesn t seem to have any effect at all when called from within my module.

My code looks like something like this:

function fb_reg_form_user_register_form_alter(&$form, &$form_state, $form_id ){
    $form['field_lang_list']['#prefix'] = '
';
    $form['field_lang_list']['#suffix'] = '
';

   $fbu = fb_facebook_user();
   if ($fbu || is_numeric($fbu)){
   $fb_account = fb_api($fbu);

   krumo($fb_account);
   $form['account']['mail']['#prefix']= '<fb:profile-pic uid="'.$fbu.'" linked="false"></fb:profile-pic>';
    $form['account']['mail']['#default_value'] = $fb_account['email'];
    $form['account']['name']['#default_value'] = $fb_account['name'];
    //$form['account']['name']['#default_value'] = $fb_account['name'];
   }
}

The thing i don't understand is that this works as expected when the hook is called from within the template.php but when in the module it self i can't seem to get it work.

Would anyone have any idea on what s going on?

EDIT: Could this have something to do module weight ?

Many thanks,


texts: Creating commerce users programmatically

texts:
I need to import customer data from CSV files with billing and shipping data using Drupal 8.8 and Commerce 2.
I want to create the customer with its address data programmatically, but i do not know how to create billing and shipping.

I create the user as:

 $lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
 $user = \Drupal\user\Entity\User::create();
 $user->setPassword('password');
 $user->enforceIsNew();
 $email="xyz@email.com";
 $user->setEmail($email);
 $user->setUsername($email);
 $user->set("init", $email);
 $user->set("langcode", $lang);
 $user->set("preferred_langcode", $lang);
 $user->set("preferred_admin_langcode", $lang);
 $user->activate();
 // Save user account.
 $user->save();

How do i create its billing and shipping data?


texts: How to perform views date calculations using global math?

texts:
Is it possible to calculate date in Views like to calculate two cell using global math for this case?

Example:

Nick's birth of date was 20/10/2005
Only 20 years old can join the club
So before 31/10/2025 Nick cannot join the club,
its mean Nick needs to wait for 10 years 10 days (date 31/10/2025) to join the club.

Can anyone assist me to solve this?


texts: Using rules to get the user's group audience nid

texts: Is there a way where you can use rules to grab the currently logged in user's group audience nid?


texts: Send "Views PDF Display" generated PDF by mail as attachment

texts:
TLDR: How to send Module "Views PDF Display" generated PDF by mail as attachment without another deprecated module ?

I have a Drupal site with the Views PDF Display module on it.

I can generate a custom PDF for my order, and all is nice, except for one things. I need to send those PDF one by one by mail as attached file for the past year of commands, and i looked around for a while without seeing an answer.

I found that one the module page, they talk about two modules that does that, but the fact that both modules are 7 years old and thus not covered by security policy is a 'no'

Other idea to generate all PDF from the last year is just not possible as it will be too much PDF for the server to handle

Do you have any idea for me to retrieve those PDF from the views and to send them by mail as an attachment ?


texts: Embed Google Earth Flyover using KML or route

texts:
Geofield, Openlayers with KML layers all great and am really loving how well this is all put together on Drupal.

Question: on the site http://www.mapmyfitness.com they are using a Google Earth plugin to display a Fly-over of the route. Is there a Drupal module that implements this at all?


texts: How to ajaxify webform submit in Drupal 7?

texts:
I have tried to alter the webform rendering using hook_form_alter() and hook_node_view() in a custom module so I could add '#ajax' somewhere.

Has anybody already had some experience working with webform and ajax on D6 or D7 ?
I guess the logic would be the same for D6 and D7 then just the implementation changes.


texts:
I am developing new website in D7 and I have installed bootstrap theme on the of it.

So, now I want to create home page/front page for my website and for that I have created a basic page, but I am not able to add CSS and JS in that basic page.

What approach should I use to create a front page in Drupal 7?


texts: How are entities and libraries for the Apache Solr server organized?

texts:
I'm trying to understand some basics about Apache Solr server, and particularly how its entities and libraries are organized.

I've tried to read the documentation but it is hard to understand it without good knowledge of the Java language.

My goal is to integrate Solr with Drupal 7's Search API location module. I have already got working and configured Solr server but it also requires Solr to be extended with Lucene localation library, and this is actually the part that I don't clearly understand.

There is a version of Solr with an already compiled location library, but it means that the existing one should be deleted. What I was thinking about: is it possible to just copy the apachesolr/solr (with geo library) directory from that version into existing Solr server as new instance?

Any explanations about this?


texts: Is there a way to hide the price on a product using Drupal Commerce?

texts:
Basically I want to create a commerce site, load all the products but not give a price yet, for competitive reasons.

Instead of displaying 0 I want to:

Change the price to - "Call for price"
Hide add to cart button

At a later stage when I give the item a price it should:

Display the price
Display add to cart button

I know this is possible in Magento but would rather try using Drupal Commerce.
Any tutorials or links will be appreciated.


texts: Prevent URL encoding of custom query parameters passed to FormState::setRedirectUrl()

texts:
Upon submission of a custom-coded form, I'm redirecting to a URL that includes query parameters. How can I prevent Drupal from URL-encoding those parameters?

Example:

$params = [
  'something' => '1,2,3',
  'something_else' => '4,5,6',
];
$url = Url::fromRoute('<current>', $params);
$form_state->setRedirectUrl($url);

Results in the URL below:

http://example.com/page?something=1%2C2%2C3&something_else=4%2C5%2C6

But I'd like:

http://example.com/page?something=1,2,3&something_else=4,5,6


texts: In Taxonomy View, how do I get the count of relationships associated with that term

texts:
In a View based on a Taxonomy Term, is there a field which shows a count of how many relationships that tag has?

I'm pulling a list of Academic Years in this situation. If there is no Nodes tagged with these years, I'd like to omit them from the list.


texts:
I created an entityform and a view which displays all previous submissions in a table format. On each row of this table I have a link to view a specific submission which target to a page with this kind of url /?q=entityform/submissionID.

I would like to customise the display of this link and retrieve user information and incorporate a private msg form to reply to the submitter. Lets say that my list of previous submissions were products. I would like that the current logged in user could contact the seller on that page (by private msg)
Is that possible?

thanks in advance for any help that will be provided


texts: Drupal update to specific version (not dev) with git

texts:
I have a Drupal folder made with command:

git clone --branch 7.x https://git.drupalcode.org/project/drupal.git

Now I want to update it to the actual version (7.67). When I run

git pull origin 7.x

or

git pull origin 7.67

Every time I get the 7.68-dev version, not 7.67. What am I doing wrong?
I know how to get the specific version with composer, but in this situation I need to get it with git pull command.


texts: Is it possible to add a taxonomy term to a file that it is uploaded to the site? If not I imagine that I would need to create a content type to encapsulate the file and tag that.


texts: Want parent MENU_LOCAL_TASK tab to show when on a child page

texts:
I have a set of local task menu items defined in my module. This includes the following items:

control => MENU_NORMAL_ITEM
control/jobs => MENU_DEFAULT_LOCAL_TASK
control/jobs/% => MENU_???
control/download => MENU_LOCAL_TASK
control/settings => MENU_LOCAL_TASK

The three menu items (jobs, download and settings), display as tabs, as I want. When someone clicks through to see a particular job, I want this to show as having the jobs tab selected.

If I add MENU_LOCAL_TASK to "control/jobs/%," the tabs show up, but I get notice errors (because Drupal is trying to define a link to % and can't know that).
If I don't, the specific job page does not have any tabs at the top.

Have I misunderstood anything? Can I achieve this in another way?


texts: What is the correct order of disabling the default contact form on Drupal?

texts:
Drupal comes with a default contact form on each site we install. And while we already have the webforms and recaptcha module installed, some of our site owners still use the default contact form found in
/admin/structure/contact.
I need to remove them because when they are enabled, the site is prone to spam attacks. I've had a few instances where some of the sites had form submissions with PDF file uploads of inappropriate content. So you see how this is a security risk for our organization.
I removed that contact form in my local site by disabling the following modules in this order:

contact form
contact storage
contact

But I need to do this for all our sites now, so I wrote the following in my hook_update_n() function:
function my_profile_update_8011() {
    $config = \Drupal::configFactory();
    $moduleHandler = \Drupal::service('module_handler');

    if($moduleHandler->moduleExists('lightning_contact_form')) {
        Drupal::service('module_installer')->uninstall(['lightning_contact_form']);
    }
    if($moduleHandler->moduleExists('contact_storage')) {
        Drupal::service('module_installer')->uninstall(['contact_storage']);
    }
    if($moduleHandler->moduleExists('contact')) {
        Drupal::service('module_installer')->uninstall(['contact']);
    }

}

When I deployed this update to our dev environment, it would work on most of the sites, but fail on the rest. They all have this same error message:
The error output from the server was: >  [notice] Update started: my_profile_update_8011
>  [error]  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause': SELECT 1 AS expression
> FROM
> {contact_message} t
> WHERE id IS NOT NULL
> LIMIT 1 OFFSET 0; Array
> (
> )
>
>  [error]  Update failed: my_profile_update_8011
 [error]  Update aborted by: my_profile_update_8011
 [error]  Finished performing updates.

All our sites share the same codebase, so I don't know where my update hook went wrong.
Is there a better way of disabling these modules?
thanks,
Kevin


texts: How to remove the create prefix text when adding new content?

texts:
Tried a couple of attempts and no luck with function framework_preprocess

function framework_preprocess_ask_a_question(&$vars, $hook) {
  if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'ask_a_question') {
      $variables['title'] = 'Ask a new question';
   }
}

Content type is called "Ask a Question" want to change the title from "Create Ask a Question" to "Ask a new question" (removing the create text set by default)


texts:
I created a view (from Views module) where I display my content in a table.
The table contains about 22 columns:

The table continue to the right of the screen (see screenshot above).
How to fix that? (fit it to view boundaries or make the view area wider)


texts: How can we define twig template based on checkout flow in Commerce 2.x?

texts:
I am using Drupal Commerce 2.x. I try to build different twig templates based on the checkout flow.

So, I use hook_theme_suggestions_HOOK_alter to register other theme suggestions. However, I can't find any useful variable which we can use in the function.

The following code is what I tried now.

Please give me some advice.

Thanks a lot.

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function bootstrap_sass_theme_suggestions_commerce_checkout_form_alter(array &$suggestions, array $variables) {
    if( $variables['form']['#id']=="commerce-checkout-flow-multistep-default" ){
    //add theme suggestions.
    $suggestions[]='my_new_checkout_template';
    }
}


texts: How can I let a plugin depend on another module?

texts:
Is it possible to let a plugin depend on a module (other than the declaring one)?
Use case: I want to create a field widget plugin that should depend on the 'date_all_day' contrib module, but I don't want the entire declaring module depend on this.
Is it possible to declare this in the annotation?
E.g.
/**
 * @FieldWidget(
 *   id = "my_daterange",
 *   label = @Translation("Date and time range + All day"),
 *   field_types = {"daterange"},
 *   dependencies = {"date_all_day"}
 * )
 */
class MyPlugin {...}

The plugin should only become available if both the declaring module and the dependency module are enabled.


texts:
I am using Commerce Kickstart, and I want to use as order ID any desire number, where by default the first order ID is 1.

How can I achieve this?


texts: Drupal 7's States API: Why won't this code work?

texts:
Scratching my head on this.  Trying to get a few fields in a node edit form to be visible only when a select element's value is 'sponsor':

function iv_persona_helper_form_persona_node_form_alter(&$form, $form_state) {
  $lang = $form['field_persona_type']['#language'];

  $sponsored_control_states = array(
    'visible' => array(
      ':input[name="field_persona_type['. $lang .']"]' => array('value', 'sponsor'),
    ),
  );

  $form['field_sponsored_url']['#states'] = $sponsored_control_states;
  $form['field_sponsored_text']['#states'] = $sponsored_control_states;
  $form['field_sponsored_description']['#states'] = $sponsored_control_states;

  $form['#validate'][] = 'iv_persona_helper_form_persona_node_form_validate';
}

I know the form_alter is being invoked, but those fields visibility is not at all changed.


texts: Image field: How to directly upload an image to get a preview, after choosing a file

texts:
Possible Duplicate:
  How can I automatically upload images on file selection rather than pressing the upload button?

I'm trying to change the default behavior of Drupal when adding an image through image field on a content type.

When you choose an image to assign to a node, it's not directly uploaded. You also need to click "upload" to display the preview of your image, and this is not really user friendly.

How can I change this (programmatically) to make Drupal start uploading directly the image after choosing the file.

Thank you for help


texts:
need a bit of help please, when i write my query like this it works fine

    $query = db_query('select * from form_submissions where address in (select address from form_submissions group by address having count(address) > 1 ');
    $submissions = $query->execute();

but when i write it with drupal it should work like this? but it dont

    $query = db_select('form_submissions', 'sfs')->fields('sfs', array());
    $subquery = db_select('form_submissions', '')->fields('address', array())->groupBy('address')->having('count(address) > 1');
    $query->condition('address', $subquery, 'in');

    $submissions = $query->execute();

can someone see what im doing wrong?


texts: How to show data from external api to theme template?

texts:
I am totally new to Drupal. I have given one assignment to build Drupal site which shows courses from our company site. I am totally stuck in one point. I need to show data from our api into theme template.

Can you please guide me on this? If you have any example, please share with me. I will dig into it and I will try to solve my problem.


texts: How do I set a url query parameter node/{node}/edit for a specific content type?

texts:
I'm trying to add a taxonomy term from the node in question as a url parameter, but am struggling to figure out how to do it without just going through the site and modifying all of the links that point to it.

So currently the path looks like this

node/{node}/edit?destination=/plan

I'd like to modify if to look like this for a specific content type.

node/{node}/edit?destination=/plan&year={field_plan_year}

Should this be done in the routes file? Can it be done in hook_form_alter? Does anyone have any suggestions as to where I might look for an example of this? Can this be done with something like Pathauto?

The reason behind my need for this is to filter a view (that is shown via the form template). The node edit screen shares a matching programmatically generated taxonomy term (in this case "year"). We need to be able to contextually filter the view based on the value of the term from within the node.


texts: Custom block that's always the first thing in a region?

texts:
I'm trying to create a region for my Drupal 7 theme that will be clickable drop-down to allow the user to log in/out, access their profile page and a few of other things. The best analogy I can come up with is that I'm trying to create something similar to the sort of drop-down that you see on sites like Twitter. (It's not exactly the same as what I'm trying to build, but close enough to demonstrate my point.)

Now, neither styling the region nor implementing a show/hide behavior in jQuery is difficult. The key here is to add a bit of custom HTML to the region that will wrap outside the blocks, but inside the region itself.

The output should look something like this:

Click here

        < blocks go here >

It's also important to make sure users can't move or delete this special stuff, so I think this should probably go in template.php, but since I'm a Drupal theming newbie, I'm not sure.

Anyone have an idea how to do this?


texts: What hook function (is _form_alter correct?) do I use to alter the input submitted by the user into a views exposed filter form?

texts:
I'm developing a views exposed filter form for searching for items in given geographic locations.

I want to restrict this to a particular country so that cities with the same name in other countries aren't shown in the View results. For example only London, UK not London, Ontario; Portsmouth UK not Portsmouth New Hampshire, USA.

(Note please don't close this topic as being too local - my question would apply to anyone who wants to do this whatever country they are in.)

The simplest approach I want to consider is suffix the user input with the country. For my example this would be Newcastle becomes Newcastle, UK.  Given that the site is focused on users in particular country, for user experience (UX) usability reasons I do not want the user to have to enter the country name at the end.

I had tried to add a function to do the suffixing by adding it as a callback in the form[#submit] array in _form_alter and implement the function in my custom module. But this did not alter my submitted input as required. Here is my code snippets:

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

// keep the standard handler
$temp = $form['#submit'][0];

// put my handler in first
$form['#submit'][0] = '_mymodule_custom_handler_submit';

// restore the standard handler to appear in the array after mine
$form['#submit'][2] = $temp;
}

function _mymodule_custom_handler_submit(&$form, &$form_state) {
    $form['field_geofield_distance']['origin']['#value'] .= ", UK";
}

When I try this I find (using  dpm ) that the submitted input is not altered before it gets sent to the View for it to create the results - so I deduce that this code is not running before that, but instead after that.

Can you advise on what I might be doing wrong here?

Also, in the $form['#submit'] array, are the callback functions "chained" together - i.e. in that the first function in the array gets called, it modifies the form submitted input and this is then passed to the next callback. If this were the case I would have expected my code to work.

Is _form_alter the right hook to use for this problem?

Update

Now using debugger (Komodo IDE) connected to my Vagrant VM-based local development environment that's running the site to investigate a solution:

Thanks.

Update 2:

I don't think this form handler approach is going to work, the screenshot below shows a callstack - see bottom right, showing that the views execute display function (presumably the view itself) runs before my code to modify the input


texts: Selectively purging views from varnish cache

texts:
We are trying to optimize our site's performance with Varnish together with the Cache Expiration module to selectively purge only the updated content from varnish.

However, one problem has come up, since we are listing content with Views, the expire module has no way of knowing which pages the updated content is listed on, and can't purge these at the same time the node url gets purged.

I guess we could purge all content from Varnish at regular intervals using cron, but that would also remove lots of perfectly valid content from the cache.  Has anyone manage to solve this in a nice way?


texts: How to display 'Terms and conditions' before starting a download, possibly using Rules?

texts:
We have a page displaying various download options. When the user clicks one of the options we would like to display a terms and condition page and then take the user further to the actual download page.

There is only one terms and conditions but multiple download pages.

I looked at the Legal module. But this seems to be for users who register and users don't need to register for download.

I also looked at Rules module. But this is for recurring events. But it is not a recurring event but an on click event.

Has anybody got an idea which strategy would be helpful here?

Note: terms and conditions are the same for every option.


texts: How can I gracefully interrupt an AJAX callback?

texts:
I have a form element that triggers an AJAX callback call when it looses focus.  This callback can take a few seconds, which generally is not an issue.

If a user submits the form before the AJAX callback completes, the following error is displayed:

Here is the exact error message displayed to the end user:

  An AJAX HTTP request terminated abnormally.Debugging information
  follows.Path: /system/ajaxStatusText: ResponseText: ReadyState: 4

How can I gracefully terminate an AJAX callback from completing when passing control to a submit handler?

This is the relevant code from the module.

function a_custom_form($form, &$form_state) {
  $form['email'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
    '#type' => 'textfield',
    '#title' => t('Customer Email Address'),
    '#required' => TRUE,
    '#ajax' => array(
      'callback' => '_user_email_ajax',
      'wrapper' => 'cust-email',
      'effect' => 'fade',
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit Request'),
  );

  return $form;
}

function _user_email_ajax($form, &$form_state) {
  $commands = array();
  // Doing time intensive stuff here...
  drupal_set_message(t('Some Message'), 'error');
  $commands[] = ajax_command_replace('#email-warning-message', '
'. theme('status_messages') . '
');

  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );

}

I have tried the solution given for Prevent "AJAX HTTP request terminated" error on early form submit, but this seems to prevent the submit button from functioning, rather than interrupting the AJAX callback.


texts:
The Drupal 6 website I am working on is giving me some problems with the sidebars.

Here, my 'general info' sidebar is incorrectly showing 'home' sidebar info.

To the right is my 'divisions' sidebar which displays correctly [except for the >> next to probate, can't seem to find a fix for that issue]

I've tried to go through general info and compare the node hierarchy with that of divisions, making sure the settings are similar. I did not seem to find anything that would fix the issue for me.

Also if anyone could help me with why the ">>" 's show up seemingly randomly ( see 'Human Resources', 'Juvenile Delinquency Court', and 'Records management') These nodes do not have children.

First sidebar issue
Second sidebar issue


texts: SMS Framework - Multiple destination numbers

texts:
I'm using SMS Framework module to send sms from Drupal site; Clickatell is setted as my default gateway. Using Rules module I'm able to notify users via sms when new node is created, but i can only setup one destination number.
Is there anyway to setup mutiple destination number?

A screenshoot of my rule configuration below:


texts: How to know current active installation profile like standard/minimal etc. on existing drupal site?

texts:
I have installed minimal installation profile. Is there any entry in database where profile name is mentioned, current active profile.

I wanna get the profile name which is get installed in existing site.


texts:
How do I save the format used for a node body?

I am using the following code, but it doesn't work.

$article = Node::create(array('type' => 'article'));
$article->setTitle($node->title);
$article->set('body', "My body...");
$article->setPublished(TRUE);
$article->body->format = 'full_html';
$article->save();

How can I achieve this?

EDIT:

Fixed:

Right code:

$article = Node::create(array('type' => 'article'));
$article->setTitle($node->title);
$article->body->value = $node->body;
$article->body->format = 'full_html';
$article->setPublished(TRUE);
$article->save();


texts: How to install patched Paypal module in Drupal Commerce?

texts:
I am not an expert of Drupal, but I am trying to configure a site with Drupal Commerce, and in particular, the PayPal module.

I need the following two patches:
https://www.drupal.org/node/2415489
https://www.drupal.org/node/2415501
that, if I understood correctly they are not merged into the paypal module yet.

So, what I did is to manually download the PayPal module, manually apply the patches (unfortunately they conflict each other, so I applied one with the patch command and the other by manually diff the files) and I tar.gz everything.

The resultant module is here: https://dl.dropboxusercontent.com/u/7968745/commerce_paypal-7.x.2.3.tar.gz

Now, if I try to install this module I get the following error:

Unable to create directory 'temporary://update-extraction-bde81194/.'

But if I try to install any other module, it works.

BTW: I don't know if this is relevant or not. Before installing my custom-made module, I disabled and uninstalled the PayPal module, but if now I look for the modules in my Drupal installation I still find the PayPal module (but disabled)


texts: Need to change User Pages Title and Breadcrumb in drupal 7?

texts:
I want to change Title and breadcrumb for user pages to username to My Account.
I don't want to user drupal_set_title or drupal_set_breadcrumb bcoz its in lots of pages

I saw below code in user core module

  $items['user/%user'] = array(
        'title' => 'My account',
        'title callback' => 'user_page_title',
        'title arguments' => array(1),
        'page callback' => 'user_view_page',
        'page arguments' => array(1),
        'access callback' => 'user_view_access',
        'access arguments' => array(1),
        // By assigning a different menu name, this item (and all registered child
        // paths) are no longer considered as children of 'user'. When accessing the
        // user account pages, the preferred menu link that is used to build the
        // active trail (breadcrumb) will be found in this menu (unless there is
        // more specific link), so the link to 'user' will not be in the breadcrumb.
        'menu_name' => 'navigation',
      );

/**
 * Menu item title callback - use the user name.
 */
function user_page_title($account) {
  return is_object($account) ? format_username($account) : '';
}

User menu is calling title callback function and set the user name in that callback function. So i have tried hook_menu_alter to change title callback of user menu but it is not working

My Code

function health_portal_menu_alter(&$items) {
  $items['user/%user']['title callback'] = 'health_portal_user_menu_title';
}

function health_portal_user_menu_title() {
  return 'Test';
}

Anybody tell me what is wrong with this code and what i do?

Thanks


texts: Use patch for .htaccess only on remote site

texts:
Following this post I'm working on a way to patch my .htaccess file so my changes don't get overwritten by a drupal update.
But my .htaccess files most of the times are in my .gitignore because the extra code I add to the .htaccess file is only needed on my remote site. On my local site I need the default .htaccess file. How can I solve this?


texts: Caching a variable for a fixed amount of time

texts:
So I'm at odds with Twitter API which only allows 15 requests per 15 minutes (of course this encourages and promotes good behaviour by not allowing repeated request for the same data).

My task is simply to get the latest tweets for a Drupal based homepage which is easy enough but my question is as follows: is there a native function within the Drupal API to store an array or variable (...my twitter JSON request) for a fixed amount of time?

I recently implemented Twitter caching for a Wordpress site and it was super simple using Wordpress Transients API, see the example here: http://www.codeforest.net/wordpress-transients-api-caching-benchmarks

Is there an alike function in Drupal?


texts: Services Module Unable To Update User Fields

texts:
I am using the Services module configured with a REST endpoint. I can update all other fields on the user account but when I attempt to update the mail field (user e-mail field) it doesn't appear to change.

I think this has to do with the "current_pass" field. Am I supposed to validate the password somehow?

I am testing this but any "hey, silly guy, did you try this?" would be helpful.


texts: How do I uninstall Drush 9 and install Drush 8?

texts:
I take it I can't manage Drupal 7 sites with drush 9 so I'm trying to install Drush 8. But first I have to remove 9.
I tried composer global remove drush/drush but it gives errors:

  drush is not required in your composer.json and has not been removed
      Package "drush" listed for update is not installed. Ignoring.
      Loading composer repositories with package information
      Updating dependencies (including require-dev)
      Nothing to install or update
      Generating autoload files

I know it is installed because drush -version lists 9.7.1


texts: How to create a view that lists one post per user

texts:
For a blog homepage I am trying to output a view that lists a single post for each user on the site. It needs to be sorted by date, so the latest post is shown at the top.

I'm trying the 'view inside a view' method here http://groups.drupal.org/node/11746 but thinking there must be a better solution out there.


texts: Error after transfering process to a new host

texts:
I transfered my website to a new host and I am seeing this error:

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146
  Table 'teise1_katalogas.system' doesn't exist: SELECT name, filename
  FROM {system} WHERE status = 1 AND bootstrap = 1 AND type = 'module'
  ORDER BY weight ASC, name ASC; Array ( ) in system_list() (line 136 of
  /home1/teise1/public_html/imoniukatalogai.lt/includes/module.inc).

Anybody who knows how to resolve this error?


texts: What mapping solution do people use that has a proximity filter?

texts:
For D6 I used gmap, which allowed me to easily create map-based views and include proximity filters and sorts. With D7 I've been tempted to move to OpenLayers - I like the idea of learning one powerful mapping tool that can be used to solve more problems than presumably gmap could. However I can't for the life of me find anything that looks close to stable for proximity filters and sorts. I find this a bit surprising - does anyone know of anything I've missed? The best lead I've found so far is this sandbox project, but I haven't given it a go yet.

So can anyone recommend a way, with or without OpenLayers, to have Views-based mapping and proximity filters on D7?


texts: Rules Conditions being evaluated after schedule time elapsed?

texts:
Backstory:  I have a content type that will send an email after a period of time if a boolean is true.  From the creation of a node to the time the email will be sent, the boolean could change at any time.

My Problem:  I would like a clean way to have the conditions of a rules (see if the boolean is true) to be evaluated before going about executing an action set.  Through my testing, I cant get the Rule to be properly check the boolean when a node is both created and updated.

Optimally, I would like the conditions to be evaluated after the elapsed time of the Rules scheduler rather than upon initially after being created or updated.

Clarification Edit:  Make a Rule that will execute sending an email after a given set of time that is set by the user upon node creation.  The single condition of sending the email is if a boolean is true.  The boolean could be modified on node creation or through a node update.  So the Rule can not be activated based on one of those.  No Sssweat was able to show me how to move an evaluation from a standard Rule to the component allowing it to only be evaluated when the standard Rule scheduled the component.  So the Rule is set up to be triggered on node creation with only a given time frame field as its condition.  Depending on which time frame field was selected, the Rules Scheduler will start.  During this period the boolean to be evaluated could be shifted from true to false many times.  So only be the end of the scheduled time should the boolean even become relevant.  The component side of the rules looks at the boolean to see if it should send the email or not.  If true > send email. If false > do nothing.

Some more clarifications:

The user has a field to choose the time frame for resolving the node.
If a node is updated, the countdown should not be reset.  One email should be evaluated to be sent at the end of the given time frame.
If the boolean has been changed to false, the email should not be sent and no further action is needed.


texts: How to set images path on libraries JS file in Drupal 8?

texts:
I would like your kind help to point the correct path of images from JS.
I'm trying to change a DIV background using CSS and JS. Quite simple, right?
Well, not for me in Drupal 8.

My div loads the background defined in the CSS (my_module.libraries.yml)
The JS also works for changing positions of the layers (or DIVs, sorry, I'm from the Netscape times, old school).
But it doesn't work for setting the background because cannot find the images.
That means that there is no problems regarding routing neither configuration of the module.

So, the question is: How can I set the path for the CSS images in the JS libraries?

Here goes some codes:

My_module.libraries.yml

box-simulador:
  version: 1.x
  css:
    theme:
      css/box-simulador.css: {}
  js:
    js/box-simulador.js: {}

Excert from the CSS file

#SimHolder {
    background: url(img/pillow.png) left top no-repeat; /* << WORKS FINE! */

Excert from the JS file

function setTowel() {
 document.getElementById('SimHolder').style.backgroundImage='url(img/towel.png)'; // DOESNT WORK :(
 document.getElementById('textHolder').style.top='30%'; // IT WORKS!

I'm sure the answer would be quite simple ;)
Thanks in advance!


texts: Show block only on node view page, not in node create or edit form

texts:
How can I configure block visibility to show only in node view pages? (not in node edit and create pages)

What should I insert in "Show block on specific pages" > "Only the listed pages"? current config is:

video
node/*


texts:
I'd like to create a form with Drupal that all users can access, but every time I try to access the form without being logged in, I get this error:

Access denied

You are not authorized to access this page.

How can I allow all users to access the form?


texts: What is the order of execution and redering of hooks and page components?

texts:
In order to have a better understanding of what Drupal does, I need to find out what the order of execution of hooks and page components is.

A page layout in Drupal consists of HTML, regions, nodes, blocks, Views and ... . Every one of these components have lots of preprocess or process functions,  like hook_preprocess_node. There are also template functions, theme functions and ... that are run to build the page array.

To avoid my question to be too broad, let's only talk about the hook and preprocess functions not the core functions.

Thanks.


texts: How can menu title be included in breadcrumbs?

texts: I have menu block  with title 'Content'. It has several links. Breadcrumbs are made throw template.php by splitting url. Is it possible to include menu name before last link (which is content title) in breadcrumbs? I need to make it for all custom menu block links.


texts: How to prevent installation to run from UI?

texts:
I have an installation profile that will be installed purely via Drush/CLI. So I need to prevent anyone to run the installation from web interface.

What would be the best approach?


texts: How do I use .htaccess to trigger mod_rewrites before D7's Clean URLs take over?

texts:
I am migrating from olddjango.com to newdrupal.com, and need a way to alter the URLs from the old style into the a format we've chosen for the new Drupal application.

In addition to rewriting them, I want the final "corrective" rule to redirect, to register the 301.  The structure of the URL has a marker that I'm using as a RewriteCond, it is the last thing I change before the redirect (so the URI won't get rewritten unless it is from the old site).

I've written a small number of mod rewrite rules, which work well enough in http://htaccess.madewithlove.be/

If I put them in my /etc/httpd/conf/httpd.conf they work smashingly... but that isn't a viable option. (it theoretically COULD be... but only as a last resort)

However, when I put them in /.htaccess, they do absolutely nothing...

I put them at the top of the file, before anything else, I put them at the bottom... and in the middle.  I tried with and without "RewriteBase /"...

I'm obviously missing something, or the nature of D7 disallows pre-empting the machinations of Clean URL.  I've found at least one person saying it was possible, but no one saying there were any special tricks involved, or actual documentation... so I'm just trying to get an answer committed to the interwebs one way or the other.

This is the final rule of my section of rewrites:

RewriteCond %{REQUEST_URI} ^/?gbnk/?.* [NC]
  RewriteRule ^/?gbnk/?(.*) $1 [NC,R=301,L]


texts: content access + menu block => not shown all links in menu block

texts:
I have menu block and content access modules in my website, and I have some content types restricted and is working well. The problem is when a node is restricted, the link isn't shown and I want to show that link.

To show the links in menu block is important for me, because the user will know that there is content there and to access he has to acquire a membership.

I have tried the always shown module, but it only works in other menus (the normal drupal menu, TB megamenu ans superfish menu), I mean that in those menus it shows the hidden links, but it doens't work in menu block.

I need menu block, because I handle a principal menu, and menu block is my secondary menu, it shows after the 4th level.

How can I show all links in menu block module? (https://www.drupal.org/project/menu_block)

Thank you so much for all your answers, I really want to finish that page and for that I need all the help you can give it to me because I couldn't do by myself.


texts: Display Suite label below field, instead of above or inline

texts: Pretty straightforward question. Is there a way to get the label for a field to appear below the field? The only options within display suite are inline and above.


texts:
I just can't get my head around the following problem.

I have two content types. One is ISSUE the other one is ARTICLE.
I use the Node Reference module to link and ARTICLE to an ISSUE.
Then I am using Free Pager module to have a pager on every page to click to the next and previous node.

The pager works but for all ARTICLES of all ISSUES. Now I want it to work for only the ARTICLES in the same ISSUE as the current node.

I tried to get this to work with the normal Views filter and the Contextual filter but for some reason it doesn't work. Does anyone have a solution for this? Or another option with other modules that do the trick?

Thanks in advance
Joost


texts:
I am completely new to Drupal 7. I have made slider from the views slideshow .As I am making my site multilingual, I have set my slider in basic page and made it the front page.

But my question is that, right now it is having only the static data below the slider.But Is there any way to post recent articles in place of that static data ?

Thanks in advance for help.


texts: How to get the managed_file progress bar working in a custom theme?

texts:
I'm trying to get the managed_file progress bar working in a custom theme.  Right now, when I start an upload, the empty progress bar widget appears in the form, but it doesn't visually update while the file is being uploaded. If I switch my site from my own theme to Bartik, the bar works properly, so it's evidently a theming problem.  (This also confirms that I've got all the uploadprogress stuff properly installed.)

I've found theme_progress_bar, and tried adding it to my theme's template.php file, renaming it to MYTHEME_progress_bar, but it didn't work.  Any advice on how to get it to work?  Thanks!


texts: I can login to /admin/structure/menu and create a new menu. How can my module create a custom menu like that?


texts: For example, with example.com/en/apple/12/article/11/23, in hook_init() arg(0) returns "apple," as I expect; in hook_boot() it returns en which is language prefix of English.


texts: Dynamically fetch feeds and html content from other website and show

texts: Is there any module that pulls data from external feed or html link and displays in drupal. It should not create any corresponding nodes in drupal. It should just go and scrape data or feed and display in a page or block.


texts: How to programmatically get node ID in custom Rules Action

texts: Need to create a custom Rules Action. How do I pragmatically get the node ID for an action such as when a node is saved?


texts: Assigning roles and permissions Drupal 7

texts:
I have a hierarchy of roles which are Admin -> shop_admin -> food_manager / drink_manager / supplies_manager

So the Admin can edit the permissions of all the roles. Is there a way to allow the shop_admin to edit the permissions of drink_manager, food_manager and supplies_manager?

So basically my question is - Is there a way to give a user permission to manage other roles and permissions?


texts:
How To Add PHP code to the body of a Drupal 7 Block

I just want to make a button on block body. Is that possible?

this link will explain what i want to do [add button]: http://drupal.org/node/1046700

  This article is for Drupal 7 developers who have tried to put PHP code
  in the body of a Custom Block, but can't get it to run.


texts: How to Display Custom Token in Rules UI Data Selector?

texts:
We use Rules and its submodule, Rules UI to manage our Rules. We have recently created some custom tokens, which are under the 'node' type. I have tested to make sure that these tokens 1) get the proper value and 2) are present among the Drupal tokens (by viewing them at /admin/help/tokens).

We would now like to use these tokens, both present under 'node'. However, they refuse to show up in the Rules UI. I have tried to add a condition to the Rule that 'Entity has field' of the custom token(s), but they do not appear there.

How can I make a custom token appear in Rules (UI), when it already exists in Drupal's token system?

Update:

The Token is an email address. It appears the token will appear in the field where I can select an email to be sent. However I would really like it to be available in the 'Entity has field' and/or the 'Data is empty' selectors, so I can choose whether or not to send the email based on whether the token has an email address associated with it.

Any ideas for getting it to appear in either of these locations ('Entity has field' or 'Data is empty')?


texts: adding id attribute when linking stylesheet from themeName.info

texts:
I am working on drupal theme. In past, i linked stylesheets via the themeName.info file as follows:

stylesheets[all][] = css/thickbox/thickbox.css
stylesheets[all][] = css/custom.css

However, this time i need the particular css file link, so it has an ID attribute set as following:

<link rel='stylesheet' id='jquery-colorbox-css'  href='/assets/css/colorbox.css' type='text/css' media='all' />

How would i link the style sheet from the themeName.info file, so that it has ID set to 'jquery-colorbox-css' along the extra attribute 'media' included as well. Thank you a lot


texts: A view of full nodes with comments that are a content type

texts:
I have split up this question into other questions previously trying to join them up to create my final solution. However the combination of what I am trying is causing problems.

I need a comment field to be able to use a CCK field. To do this I am using the nodecomment module as it allows you to use a content type for comment (http://drupal.stackexchange.com/questions/3202/creating-threaded-nodes). I will call this type CustomComment.

I have a custom node type, NodeType. This uses CustomComment for it's comments.

I need to create a view of NodeType. Which prints the full node (not fields). I also need to print the Comments as full nodes as well. Can anyone give any additional pointers. Part of me is thinking It might be better for me code this myself.


texts:
Background:
Im working in Drupal 8 and I have a paragraph type that contains a title and an image and I am trying to pass it through the preprocessor hook so I can set it inside a html template. For testing purposes all I have on my template is div that calls the image variable. Im more worried about the pre_processor than I am the html
Code:
function theme_preprocess_node(&$variables) {
  if ($variables['node']->getType() == 'landing_page') {
    $paragraphs = $variables['node']->field_section->getValue();
    $section = [];
    foreach ($paragraphs as $key => $paragraph) {
      $p = Paragraph::load($paragraph['target_id']);

      echo "<pre>".print_r($p,TRUE)."</pre>";

      switch ($p->getType()) {
        case 'tabbed_body':
          foreach ($p->field_body_tab_content->getValue() as $tab) {
            $t = Paragraph::load($tab['target_id']);
            $title = $t->field_body_tab_title->getValue();
            $content = $t->field_tab_content->getValue();
            $image = $t->field_body_image->getValue();
            $section[$key]['tabbed_body'][] = [
              'title' => $title[0]['value'],
              'content' => $content[0]['value'],
              'image' => $image[0],
            ];
          }
          break;
      }
    }
    $variables['sections'] = $section;
   }
}

Image Settings:


texts: How to disable a form button in DrupalGap after it is clicked?

texts:
I am experimenting with the Stripe Cordova plugin that seems to provide for an easy addition of Stripe payments to a Phonegap app.

I have created a form with the necessary fields (name, amount, CC numer, CVC, expiration month and year). It is of course important to prevent double clicking/double charging.

What is the most reliable way to disable the submit button immediately after it is clicked and prevent double charges?

Scenario 1:

/**
 * Define the form's submit function.
*/
function stripe_payment_form_submit(form, form_state) {
  try {
    var points = form_state.values['points'];
    var number = form_state.values['number'];
    var exp_month = form_state.values['exp_month'];
    var exp_year = form_state.values['exp_year'];
    var cvc = form_state.values['cvc'];
    var fullname = form_state.values['name'];
    chargeCard(points, number, exp_month, exp_year, cvc, fullname);
}
  catch (error) { console.log('stripe_payment_form_submit - ' + error); }
}

function chargeCard(points, number, exp_month, exp_year, cvc, fullname){
  stripe.charges.create({
  amount : points,
  currency : 'usd',
  card : {
    number : number,
    exp_month : exp_month,
    exp_year : exp_year,
    cvc : cvc,
    name : fullname
    },
   description : "Stripe Test Trasnfer"
},
  function(result){
    // asynchronously called
  });

}

Scenario 2:

/**
 * Define the form's submit function.
*/
function stripe_payment_form_submit(form, form_state) {
 try {
   stripe.charges.create({
   amount : form_state.values['points'],
   currency : 'usd',
  card : {
   number : form_state.values['number'],
   exp_month : form_state.values['exp_month'],
   exp_year : form_state.values['exp_year'],
   cvc : form_state.values['cvc'],
   name : form_state.values['name']
  },
  description : "Stripe Test Trasnfer"
 },
 function(result){
  // asynchronously called
 });
   }
  catch (error) { console.log('stripe_payment_form_submit - ' + error);   }
 }


texts: How to alter each article's comment setting by PHPMyAdmin

texts: After I updated my site, I found out that all the node comments are set to "disabled."   I then went to the specific content type setting page, and changed the default comment setting to read/write, but the nodes of that content type are still disabled. If I change the comment settings for each node, that would be a too cumbersome work. Is there a way to change each node comment setting using a SQL command?


texts: Updating to PHP 5.4 breaks Drupal 7.25 with Strict warning: Declaration on bootstrap.inc

texts:
I tried updating to PHP 5.4, but got a few errors. These aren't critical errors right? seems like its only warnings.

I'm using Drupal 7.20 What do the following errors mean exactly? And how can they be resolved? Can I just upgrade my Drupal 7 to the latest 7.31 as of 2014-09-24 to fix these issues?

Strict warning: Declaration of Messaging_User_Destination::validate_address() should be compatible with Messaging_Destination::validate_address($address, $type = NULL) in _registry_check_code() (line 3080 of /home/xxx/public_html/includes/bootstrap.inc).

Strict warning: Declaration of Messaging_User_Destination::format_address() should be compatible with Messaging_Destination::format_address($address, $format = MESSAGING_FORMAT_PLAIN, $type = NULL) in _registry_check_code() (line 3080 of /home/xxx/public_html/includes/bootstrap.inc).

Strict warning: Declaration of Messaging_Mail_Address::validate_address() should be compatible with Messaging_Destination::validate_address($address, $type = NULL) in require_once() (line 208 of /home/xxx/public_html/sites/all/modules/messaging/messaging_mail/messaging_mail.inc).


texts: Where do I check whether the logged-in user is administrator, moderator, or just an authenticated user?

texts:
I have two separate login pages for users and administrators: /users/login and backend/login.
I have created a new function in my custom theme.
  function customtheme_theme() {
    $items = array();
    $items['user_login'] = array(
      'render element' => 'form',
      'path' => drupal_get_path('theme', 'customtheme') . '/templates/user',
      'template' => 'user-login',
    );

    $items['user_pass'] = array(
      'render element' => 'form',
      'path' => drupal_get_path('theme', 'customtheme') . '/templates/user',
      'template' => 'user-pass',
    );

    return $items;
  }

In /sites/all/themes/customtheme/templates/user, I created 2 files, user-login.tpl.php and user-pass.tpl.php. In user-login.tpl.php, I put the following code.
<?php $login_form = drupal_get_form("user_login"); ?>

<?php print $messages; ?>

<input autocomplete="off" type="text"
value="<?php echo $login_form['name']['#value']; ?>"
id="<?php echo $login_form['name']['#id']; ?>"
name="<?php echo $login_form['name']['#name']; ?>"
placeholder="Enter your username" required=""
oninvalid="this.setCustomValidity('Username id is required')"
oninput="setCustomValidity('')"/>

// password field..
// actions ..

So, I used the same setup for the admin login as well.
I created a new template at /sites/all/themes/customtheme/templates/page/page--backend.tpl.php. In that page, I just rendered the user_login form.
$elements = drupal_get_form("user_login");
$form = drupal_render($elements);
echo ($form);

Now, both pages are working fine, but I need to show some message saying you are not allowed here if normal users logged in through the backend form.
I am not able to figure out at which place/file/path I need to check for the user role and display the message (push to $messages).


texts: Modify content before sending to browser

texts:
I want to modify all the <a href src of the Drupal content before it's sent to the browser. So far I have tried the following.

public function onKernelResponse(FilterResponseEvent $event) : void
    {
        $request = $this->container->get('request_stack')->getCurrentRequest();
        $response = $event->getResponse();
        // Replacement for link headers for domains for Chinese vs. Other Languages.
        $headers = $response->headers;
        $links = $headers->get('link','',false);
        $links = str_replace($this->domain_patterns, $this->domain_replacements, $links);
        $headers->remove('link');
        $headers->set('link',$links, false);
        // Replacement for h2->h1 when neccesary and domains for Chinese vs. other languages in content.
        echo $html = $response->getContent();

But I don't get anything to be return in $html.


texts: How to pass computed data from Theme preprocess functions to Twig templates?

texts:
My general problem is this: I need to compute some data from PHP, usually using Drupal APIs, then pass computed values to a Twig template (in order to showing it).

For example: I have a template named node--dog.html.twig and inside this template I need to show the total count of Dogs I have inside the website. To do this I will compute from PHP the total count, using the Drupal::entityQuery API. But then I have to pass this computed value to the Twig template.

I tried to use a theme's preprocess function inside the file <my_theme>.theme:

function customtheme_preprocess_node__dog(&$variables) {
  //
}

From here I'm able to do all PHP computations, but I couldn't find any documentation explaining how to pass data to Twig views. Can I use the $variables object? Is there any drawbacks? Is there a better approach?


texts: Make canonical URL in document HEAD absolute

texts:
I have a requirement to use absolute URLs for the canonical URL element generated by Drupal 8.

hook_page_attachments_alter doesn't seem to have access the HTML element. Is there any other way I can access it?


texts: Does you know how the CCK Private Fields module works? Any API?

texts:
Do you know how the CCK Private Fields module works?
What I'm interested in is having a user who can switch all their content profile fields to private.

Is there an API that I can call to switch all the user's content profile fields to private?
Is there any better way to have a user opt-out and become basically an invisible user?
The definition I'm getting for opt-out is to never display the user in any search, browse or page.


texts:
I am looking for a way to allow one type of users to create a second type of users.

Can anyone advise me on how to do this?

I am using the profile module but creating a profile does not create a corresponding user who owns the profile.


texts: Installed a module, broke my site. And now I have no way to turn it off

texts:
I'm still wrapping my head around Drupal 8 and installing modules during my learning process. Now I installed this module: https://github.com/iwhitcomb/foobar and it totally broke my site:

In Drupal 7 I used to be able to just goto the terminal and do a drush sqlc and manually update the modules table in the database to disable it. But in Drupal 8 there is no modules table for me to make edits.

How do I disable this new module I installed via the drush command line? (drush pm-uninstall doesn't work as it throws the same error in the shell)


texts: How to validate allowed file types in custom module

texts:
I want to validate a field with accepted file type as PDF, XLS, JPEG, JPG, GIF, ZIP, RAR and PNG.

I'm getting file types as PDF, XLS etc. here is part of my code.

if ($fi_name!='') {

  if ($p_filefilename[1] != 'pdf'
    ||$p_filefilename[1] != 'xls'
    ||$p_filefilename[1] != 'jpeg'
    ||$p_filefilename[1] != 'jpg'
    ||$p_filefilename[1] != 'zip'
    ||$p_filefilename[1] != 'rar'
    ||$p_filefilename[1] != 'png') {

    $form_state->setErrorByName('document', $this->t('Please upload document  in pdf, xls, jpeg, jpg, gif, zip, rar and png file.'));
  }
}

Even when I'm uploading PDF files it's going to error part and showing my message as "Please upload document  in pdf, xls, jpeg, jpg, gif, zip, rar and png file."

What am I doing wrong?