texts:
I'm trying to install drupal console with Drupal 9.0.5, so I ran this command:
composer require drupal/console:~1.0

However when I try run the drupal command with any arguments I get this error:
root@6dc17ce2d4bf:/opt/drupal# drupal --version
TypeError: Argument 2 passed to Drupal\Console\Command\Test\RunCommand::__construct() must be an instance of Drupal\simpletest\TestDiscovery, null given in /opt/drupal/vendor/drupal/console/src/Command/Test/RunCommand.php on line 58 #0 [internal function]: Drupal\Console\Command\Test\RunCommand->__construct('/opt/drupal/web', NULL, Object(Drupal\Core\Extension\ModuleHandler), Object(Drupal\Core\Datetime\DateFormatter))
#1 /opt/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(1144): ReflectionClass->newInstanceArgs(Array)
#2 /opt/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(618): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'console.test_ru...')
#3 /opt/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(558): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('console.test_ru...', 1)
#4 /opt/drupal/vendor/drupal/console-core/src/Application.php(468): Symfony\Component\DependencyInjection\ContainerBuilder->get('console.test_ru...')
#5 /opt/drupal/vendor/drupal/console-core/src/Application.php(214): Drupal\Console\Core\Application->registerCommands()
#6 /opt/drupal/vendor/drupal/console-core/src/Application.php(119): Drupal\Console\Core\Application->loadCommands()
#7 /opt/drupal/vendor/drupal/console/src/Application.php(64): Drupal\Console\Core\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /opt/drupal/vendor/symfony/console/Application.php(147): Drupal\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /opt/drupal/vendor/drupal/console/bin/drupal.php(89): Symfony\Component\Console\Application->run()
#10 /opt/drupal/vendor/drupal/console/bin/drupal(4): require('/opt/drupal/ven...')
#11 {main}
TypeError: Argument 2 passed to Drupal\Console\Command\Test\RunCommand::__construct() must be an instance of Drupal\simpletest\TestDiscovery, null given in Drupal\Console\Command\Test\RunCommand->__construct() (line 58 of /opt/drupal/vendor/drupal/console/src/Command/Test/RunCommand.php).

I don't really understand this error. Any ideas what might cause this?


texts:
I am looking at my Drupal 7 database, and I think that I see the following pattern:

Fields that are defined programmatically are stored in tables named field_data_fieldname
Fields that are defined via the UI are named field_data_field_fieldname.

I don't find this convention documented anywhere. Did I take it right?


texts:
I just installed rapidssl certificate and I want to serve my cart pages using https protocol.
I put all files inside apache2/ssl folder, edited default-ssl inside apache2/sites-available. The certificate is installed, but after visiting https://www.mysite.com or any link using https protocol, the browser gives me either the "It works page" or a not found page. It is probably due to path pointing to default directory.

I am assuming that I if put the correct path in the default-ssl file it should work. However, I read that having both http and https pages serving the same content is not good for SEO.

What would be the correct way of enabling cart* pages to automatically use https protocol?


texts: The Drupal 6 version of jQuery is too old (1.26). Could I delete, and replace it with a newer version?


texts: Styling Superfish menu with Zen and Sass

texts:
Can anyone advise on the best way to style your superfish menu when using latest version of zen and sass?
I am currently styling my responsive theme using the sass files which regenerate the css, which is going great, but superfish comes with its own set of css files which are located sites/all/libraries/superfish/style/css.

I ideally want to use sass to style it from my sass folder (under theme root) so its all consistent, so I dont have to keep changing into the supefish folder changing css directly.

Any ideas?


texts: why some PDOException errors are displayed in details on users screen and some other not

texts:
A user reported to me seeing the following error on his screen:

The watchdog entry for this error looks like this:

PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: INSERT INTO (.............)

I would like this kind of errors not to be displayed in detail on user screens.

However, I am not able to replicate this problem of displaying error in detail on the screen. During my tests, SQL errors are NOT displayed in detail at all. So, even if I apply a solution (like setting display_errors to FALSE in settings.php) I won't be able to test it, because I can't replicate this particular scenario which causes errors to be displayed on screen with details.

As part of the testing, I've made a deliberate mistake (in table name) in a database query in mymodule_node_view to test how such error will be visible on user screen. The problem is that in both cases, whether display_errors is turned "on" or "off" (checked on Site Status report: http://example.com/admin/reports/status/php), the result is identical. On user screen the error is displayed as:

It's not displaying any details, although  in the watchdog log, it is similarly also a PDOException:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydb.nodeaa' doesn't exist: SELECT (..............)

So, I don't understand. Why is Drupal displaying details of some PDOExceptions on user screen and not displaying details of some other PDOExceptions? How to effectively check whether a setting (e.g. display_errors set to "off") will fix the problem for all sorts of PDOException?


texts: Language Block customization: I need to display either English link or the other language link (not both)

texts:
I have a bilingual project and the language is being switched from the language block. It actually displays now: English and Spanish.

I need to have just one language link displayed: English when on Spanish language and Spanish when English.

Thank you!


texts:
I created a new index and I've created a view with it but it only has the options to show as Search Results & Fields. Is there something that has to be done when configuring the index to get Rendered Entity to show up on views?

It does show up with the Default Content Index made with the module but whenever I make a new index and create a view with it isn't an option.

Pictures:
What appears when creating a view with the default index(1) vs an index that I created(2).


texts: How to set the access of a menu page for all?

texts:
function onthisdate_menu() {
  $items = array();

  $items['blog'] = array(
    'title' => 'blogs',
    'description' => 'Listing of blogs.',
    'access arguments' => array('access content'),
    'type' => MENU_SUGGESTED_ITEM,
  );

  return $items;
}

what access I need to set to let all the users see the page?, because I am looking that page as admin and I get an message "access denied"


texts:
I have create 2 angular app into drupal 7 like

"example.com"
"example.com/app1"
"example.com/app2"

example.com is my main site. So, when I set html5 pushstate enable for removing hash in angular apps, I got nobase error from angularjs. Coz,

<base href="">

require for enable angularjs html5 pushstate.

My question is, since i have multiple angualr app in this drupal site, how can i dynamically add conditional base url for "/app1" and "app2" ?

anybody can help me?
Waiting for response. Thanx.


texts: Domain Access force node redirect to proper domain

texts:
Using Domain Access with Drupal 6, I am encountering an issue in the following scenario:

I set up a node published to a sub site, say:

subsite.com/node-x

If I browse to:

mainsite.com/node-x

I would like it to redirect to:

subsite.com/node-x

However, it just renders the content on the main site domain (which the search engines would pick up as duplicate content).

Any idea how I can configure the sites to redirect to the site on which the node is published? I attempted to use Global Redirect to redirect from the main site to the full url  on the sub site but Drupal told me that I was redirecting something to itself. Are web server redirects my only option?


texts: Programmically add Product to Product Display (Profile)

texts:
I am trying to use a rule to add a product to a profile.  Also, I am using an autocomplete entity reference widget for the product reference field.

Currently I can see the product being added but not saved/updated.

If I dpm() the profile at the end of the function I can see that the product is being added correctly, but when I review the profile it is not there.

Here is the rule I have created:

function mymodule_add_product_rule ($account,$sku){
  $uid = $account->uid;
  $product = commerce_product_load_by_sku($sku);
  $product_id = (string)$product->product_id;
  $profile = profile2_load_by_user($account, 'profile_machine_name');
  $wrapper = entity_metadata_wrapper('profile2', $profile);
  $wrapper->field_product->set($product_id);
  //dpm($profile);
}


texts: What can cause programatically created pages to occasionally disappear, but always come back when update.php is run

texts:
I have a page, very basic it's just some HTML and some Anchor tags, it works fine except occasionally and without consistency it just disappears and I instead get a 404, nothing fixes this no matter how many refreshes, flushing caches etc, but as soon as I run update.php the page returns again until it next decides to go on a journey.

Has anyone seen this behaviour before? What are the likely culprits? I've read about empty module files causing similar inconsistencies and odd EOF elements but I've checked and double checked all my custom modules for these issues and nothings come up.

$items['management'] = array(
'title'            => '',
'page callback'    => '_xxx_management',
'type'             => MENU_CALLBACK,
'access arguments' => array('fusi booking manager'),
);

This $items array is in a seperate menu.inc that's included in my main module as its rather large. Within the hook_menu function. It ends with return $items; as you'd expect

function _xxx_management()
{
        $html = '

        Content
        Properties
        Availability
        Bookings
        Email

        Current Occupants
        Pricing
        Reports
        Settings

';

       return $html;
}

Thanks, Daniel


texts:
I have data in custom response headers that I need to read. I have looked in the Drupal API guide and there is a reference to Response::$headers, but I'm not sure how to exactly use this to read header data.

Edit - to further elaborate what I am trying to accomplish:

I have a form in a custom module that redirects some data in the headers to another page. Here is the code for that:

$response = new RedirectResponse('/path/destination', 302, array(
            "username" => "value"
          ));
$response->send();

The redirect is made successfully and the values that I'm pushing to the headers (illustrated by "username" above) are successfully transferred onto the response headers - I can see that with the browser inspector.

What I am now trying to do is read the values of those custom headers, i.e. "username", as a means of pre-populating the username field on my destination page (/path/destination).

As suggested in the answers, I have also done the following:

$response = new ResponseHeaderBag();
$response::get("username");

I also tried:

$response = new ResponseHeaderBag();
$response->get("username", $default = null, $first = true);

Even though I have both these inclusions on the top of my file:

use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

I get the following error:

Fatal error: Call to undefined method Drupal\module_name\Form\MyClass::all() in ../vendor/symfony/http-foundation/HeaderBag.php on line 113


texts: Can we create a feature for the changes in webform by using feature module?

texts: I am unable to create a feature for the changes in webform on development site to be used on production site by using feature module.Is it possible ?


texts:
I am embedding a view as such:

function theme_module_name_element($element) {
  $view = views_get_view('view_name');
  $view->set_use_ajax(TRUE);
  $output = $view->render();
  return $output;
}

The view is displayed then by the filefield sources module but when you try to search it won't use ajax. I'm assuming this has something to do with the js not being loaded but I just can't figure out how to get this going!

Any ideas?

Edit: This might be related to this: http://drupal.org/node/386388

Edit 2: The pager works and when it has been used the search works...

Edit 3: When the pager is pressed (and everything works fine) there is html added to the form so it goes from:

(Edit 3 update: If I had to guess I would say "Drupal.behaviors.ViewsAjaxView" from ajaxViews.js isn't being executed when the filefield_sources source is being chosen.)

                Search

                            <input type="text" maxlength="128" name="image-title" id="edit-image-title" size="30" value="" class="form-text">

                    <input type="submit" id="edit-submit-Filefield-Sources-Imagebrowser" value="Apply" class="form-submit">

to:

    <form action="/" accept-charset="UTF-8" method="get" id="views-exposed-form-Filefield-Sources-Imagebrowser-default" class="views-processed">

                    Search

                                <input type="text" maxlength="128" name="image-title" id="edit-image-title" size="30" value="arnar" class="form-text">

                        <input type="submit" id="edit-submit-Filefield-Sources-Imagebrowser" value="Apply" class="form-submit">

        <input type="hidden" name="view_name" value="Filefield_Sources_Imagebrowser">
        <input type="hidden" name="view_display_id" value="default">
        <input type="hidden" name="view_args" value="">
        <input type="hidden" name="view_path" value="node/add/dagskrafaerslur">
        <input type="hidden" name="view_base_path" value="null">
        <input type="hidden" name="view_dom_id" value="655136b3027e2ef4608dfbaa7605db4c">
        <input type="hidden" name="pager_element" value="0">
    </form>

(Notice the addition of the form tag and input elements.)


texts: Removing the unwanted character from date field

texts:
I am generating the auto label by using the tokens for some field like date of birth and the gender of a person in auto label tab. but after saving the node the date of birth is generating in following format, 2015-08-11 00:00:00 Male,
i have chosen the created date format in the manage fields for the DOB field but still its displaying along with 00:00:00, i want to take off this all zeros. please help me on this.


texts:
I'm trying to use mytheme_preprocess_html() to load a different html.html.twig file based on certain conditions (GET variables in URL).

In D7 I've done the this with:

if (isset($_GET['response_type']) && $_GET['response_type'] == 'embed') {
    $variables['template_file'] = 'raw';
}

Where variables['template_file'] = 'raw'; set the name of the tpl file to load (raw.tpl.php). It works fine.

Now I need to do the same thing in D8, but I can't find the way.
I tried:

function mytheme_preprocess_html(&$variables) {
    if (isset($_GET['response_partial']) && $_GET['response_partial'] == 'header') {
        $variables['html']['#theme'] = 'raw';
    }
}

But it doesn't work.

Edit

I know how to set different template for page.html.twig, but I can't figure out how to do the same for the file html.html.twig

The function

function mytheme_theme_suggestions_page_alter(array &$suggestions, array $variables) {
    $suggestions[] = 'html__raw';
    $suggestions[] = 'page__header'; }

Works properly for the page template but not for the html.


texts: How to get Drupal 8 View to Accept Parameter as argument?

texts:
I created a view that shows a bunch of cars. I allow you to filter by brand using an exposed block. If you filter, it results in a path like this:

/?brand=Volkswagen

I want brand to have the path:

/Volkswagen

instead.

How would one do this with Views? Or is this something that should rather be attempted with rewrite rules in htaccess?


texts: Dynamic form building - cleanest way to substitute tags with form elements?

texts:
I have a string with tags, and form elements with elements corresponding to that tags:

$line = "This module contains [quantity] items of type [type]."
$elements = array(
  'quantity' => array (
    '#type' => 'textfield',
    //other settings
  ),
  'type' =>  array (
    '#type' => 'select',
    //other settings
  ),
}

Now, I have:

I want to generate:

What's the most standard Drupal way to do this? Elements and string will be taken from database. I assume it should happen in hook_theme, but how to pass all values to it?


texts: Apache Solr own grouping in autocomplete

texts:
The apache solr autocomplete module don't work for me.
I try to achive a relative complex autocomplete,
my target is to achive this on the autocomplete:

Search for "searchword":
-Facet for type/bundle
-Facets based on the results
Show all results for "searchword"

As example:
Search for "test":
Download (176)
Systems (100)
News (20)
Services (5)
Systems
System 1
System n
Services
Service 1
Service n
Show all results for "test"

Any suggestions how I could get this?

Edit: I use apache solr search for this so no search api hook here
(miss some functions in the search api based)


texts:
I am setting up a multi-blog site in Drupal. I'm currently learning Drupal and I'm a beginner. I am setting up Organic groups, to make blogs for groups. I have added CKEditor to get RTE in the text fields for the blog entries. I have also added IMCE to be able to upload images in the RTE.

Now my question is. How can I give each user an individual folder for uploading files? I don't want the users to access the full upload root.


texts: Improve performance by using drush functions instead of Drupal module functions

texts:
I am trying to improve the import performance of a drupal website we are working on.  The site makes use of the queue api to import individual items.  Currently this process is very slow.  I have hear it mentioned that one way of improving performance is to process items using drush rather than having Drupal do it directly.

What our site does is read the contents of a text file and then add each item to a queue for processing.  The queue worker function just takes the information, performs some processing logic and then saves it as a node.

From what I understand we would want to move this queue worker function out of the current Drupal module and into drush.

I have been searching for general background information on how to do this or some introductory tutorials, but have not been able to find anything about using drush to improve performance of resource intensive tasks.  I am a little surprised that there is so little information on this given that it is supposed to improve Drupal performance.


texts: drupal 7 xpath feeds stand alone form, how do I set author of node?

texts:
I am using drupal 7, xpath feeds to import movie information from IMDB. Users are allowed to import movie information. To make this happen I am allowing users to use the stand alone form within feeds, however the author of the newly created feed is set to anonymous (or any other user that I set on the backend). How can I configure feeds in such a way that the user who submits the import is set as the author of the node that will be created?

I tried to change the settings
Basic Settings -> Attach to -> IMDB Content type

But using that will create two nodes .. one that retreived the IMDB information and the node that has been created..

Does anyone know how to do what I want?

Thanks in advance.


texts: How to assign a dynamically updating date to a user based on a related field on their profile

texts:
I have a site where Users who can expect a delivery to their address every week depending on their delivery route. I also have a Content Type of "Delivery Route" and a Content Type of "Delivery" with a Date field and an entity reference field that adds related delivery routes for each delivery. With this I have a couple issues:

1: How to automatically assign a user a delivery route based on the ZIP code of their delivery address entered upon registration (Using the Address Field module).

2: How to display the next upcoming delivery date for a particular user on their profile based on deliveries collected for their delivery route.


texts:
I am using drupal 8. I want to add tokens to the paragraph image field widget as data-attribute, but it doesn't work. What can be caused by this problem? Is it need some modules? Here screenshot:

Thanks!


texts:
I intend to use Drupal for a news portal. We have a strong system which is exposed as REST based services in J2EE. Does Drupal have a capability to consume already developed REST services as a template while authoring a web content and executing the same REST call and replacing the appropriate place holders on publishing ?

What are the modules I would require to develop the same?

E,g,

Use case 1 : let's say I want to publish the recent export stats of a region and list out outputs from a set of manufacturing companies, I should be able pull the company names (available as a REST service ) and continue authoring.

Use case 2: Manufacturing company details page. (Details are available as REST api)

Use case 3: On Clicking on a manufacturing company detail page. I should be able to post back the visits count against the company to an external analytic tool

Use case 4: Use multiple REST services in a page and authoring a content.

I reiterate, in no case I need Drupal to produce REST services, only consume REST services


texts: Can I panelize a field collection entity?

texts:
I have made a fieldable panel pane that uses a field collection to collect one or many pieces of content. I have included in the content a link to itself so that I can open the new content in it's "page".

What I need now is to be able to apply a panels template to that piece of content. I can use panelizer to apply templates to entities but it seems that field collections do not exist for it.

Is there a way to panelize a field collection entity or another away to approach my problem?


texts:
According to the documentation for drush (version 5.9) it has a built in alias called @self.

When I attempt to use the @self alias in a command such as:

drush site-alias @self

Nothing is returned. However, using aliases I've defined in my aliases.drushrc.php the commands work as expected.

Does anyone have any ideas as to what might be going on?


texts:
Very new to Drupal and Commerce 2.x. I'm use to working with WooCommerce on Wordpress.

I have a list of equipment products and product attributes created. Each equipment category has different specification so I created different product variation type so I can add in the different attributes.

Under product types > manage display, the variation format is set to "add to cart form".

My question is how do I style the variation so that it displays as a table? display:table and display:flex doesn't seem to work with the fieldgroups.

Here is what it looks like now:

I want the above information to look like this:

Eventually I will be changing out the add to cart button to a request a quote so I wasn't sure if i needed to keep the variation format as an add to cart form or not. Unless there is a way for me to add the button in the template itself?


texts: Filter views on Current user OR Administrator

texts:
I have a total of 770 users, 760 with the custom role of "certified provider", 10 with the role of "certified administrator".

Using views, and relationships I am able to allow the certified provider to each see only their own created nodes. But I need the "certified administrator" to see ALL nodes from ALL providers.
I have a relationship of Content:Author, and filter of User:Current.
I have read everything I can get my hands on to figure out what to do  and where to go next.

Have tried to follow https://stackoverflow.com/questions/20840490/drupal7-filter-view-based-on-current-users-roles
But haven't been able to get the filter values to work.

Any help would be greatly appreciated.


texts: Make a carousel of every node associated with a term in a particular vocabulary

texts:
I have a vocabulary with a lot of terms in it, I want to show list of each term's nodes as a carousel using views.

I rather using OwlCarousel module to achieve this.

Can you guide me how to configure the views to achieve this?


texts: How to sort an exposed filter alphabetically?

texts:
I've done quite a bit of digging, and I can't figure out how to do this in Drupal 8. I have a view with an exposed filter, but the filter's options aren't displaying alphabetically.
I'm going down the path of using a hook_form_alter, but as for figuring out how to sort the filter options, I'm at a loss.
Any pointers? Thanks.


texts: How to make a image url active in Views Table

texts: I've got a table with a column for images. The field display is link (see screenshot). For some reason it doesn't display as an active link. Any ideas on how to accomplish that?


texts:
We're running the core Poll module on our site, and we'd like to change the default messages that it generates. I'm meaning stuff like Your vote could not be recorded because you did not select any of the choices.

I looked at the poll content type, but there weren't any settings for it there. It's apparently not listed under modules, because it's core, I suppose.

How can I change these messages from their defaults?


texts: Update the price of a line item after shipping method is selected

texts:
I looked everywhere and couldn't find the appropriate and clear explanation of how to change the price of a line item.
I have a line item called "fee", the fee changes based on the date and zipcode. I have a function that returns the correct fee based on the parameters.
Now what hook do I call to update the "fee" line item?
This is what I found

function ck_custom_commerce_cart_order_refresh($order_wrapper)
{
$fee = _ck_custom_delivery_fee($order);//this function returns an integer

foreach ($order_wrapper->commerce_line_items as $line_item_wrapper)
{
    if($line_item_wrapper->type->value()=="fee")
    {
        //I would like to update the fee
    }
}
}

Please what is the right of way of accomplishing this?
FYI: I'm using the commerce fees module if that helps.


texts: Reference to an Image of a different content type

texts:
here is my question:

I have two content types, Events and City.
The goal here is to "connect" content of type "Events" with a city, so that, when i publish content of type "City", to include the logo (image field) of the referenced city.
What i have done till now:
I have used the field reference module,
creating a "field_reference" field on Content Type "Events". At its configuration, i chose the desired "logo_field" from the "City" content Type, but only the name of the city logo appears, and not the logo itself (on node page).
The same appears when i want to use this field in a view.

Any ideas?


texts: How to load a menu item and its children menu items?

texts:
I have the menu item id. I want to display that menu item with its children.

Suppose for example I have menu item test and it has two children menu items. So I want to load them and display it as

test
  test1
  test2

I tried to load the menu item with the following code.

$menu_content = current(\Drupal::entityManager()->getStorage('menu_link_content')->loadByProperties(array('id' => 1)));

But I am unable to get the children from the variable. Can someone help me here?


texts: insert fields for the links in my content type

texts:
Good morning,
I have to put in my content type of fields to collect a variable number of links (www.example.com). how can I do to allow insertion of variable numbers of fields and how do I then access them with php?


texts: Getting all the values from a entity reference field (Drupal 8)

texts:
I'm trying to figure how I can get all the values inside an entity reference field

As shown in this image, I have an entity field called Target Participants(field_program_participants) with multiple values.

I have tried to output the values using node.field_program_participants.entity.label, but it only outputs one value.

How can I output all the values inside the field


texts: Reset/Delete the value of a field with node_save()

texts:
I have a content type with a field_FOO of type text. I have a procedure that check which nodes have this field_FOO without value ($node->field_FOO == array() ), extract 1 at random, make some operations, set a value for this field (field_FOO[LANGUAGE_NONE][0]['value'] = 'bar') and save the node.

Now for 10.000+ nodes I need to delete this value but I don't want to do a node_load, empty field_FOO, node_save because for every node_save Drupal change the changed date associated with that nodes.

So, how can I "delete" the value of a field without use node_save()? If I delete the entry from field_data_field_FOO table I risk a site down ?

In the field_data_field_FOO table there is a "deleted" column. If I set it to 1, at the next hook_cron() that fields are deleted without a site down ?

Thanks.


texts:
after form submit in a page its return some value,I want to prnt this value in a block .how can I do this?
and I want the form and the block are in the same page.


texts: How to filter users based on address location?

texts:
I have a content type "job". There is a field "location" which contains the zip code of area. Now i want to filter users based on distance from job's zip code. Each user also have a zip code.
I already have a view which is filtering users on different criteria. Is there any way to achieve this in view?

EDIT
here is what exactly i needed.
adding a job should have a field to add the zip code of the location of the job. This should change the way the users are filtered for the job as the customer should be able to filter the users using radius selector for 1 km, 5km, 10km, less than 50 km.
Thanks


texts: How to create a suggested articles block that uses taxonomy?

texts:
I've been trying to create a view that uses taxonomy to generate suggested articles to users.

I wanted these articles generated according to their relation with the taxonomy term of the current article the user is reading.

How can I make this work?


texts:
I'm not sure why this is difficult for me to get.  It seems like it should be simple.  I have a content type A and content type B.  Content type B has an entity reference field to content type A.  Content type B has an image field.

I want to display a view of type A, with all the images of a type B that reference it.

I've looked everywhere and it isn't making sense.  Can someone please point me in the right direction?

EDITED:  I figure it may help if I give a concept of what I'm trying to do. I have programs that I want to display.  For each program I have, one or more sponsors donate to the program.  When I display my view, I not only want to display my program content (content A), but also the logos of all the sponsors that donate to the program (content type B).  Right now, for each logo, I get a duplicate fields for my programs (content A).


texts:
I'm creating an RSS feed of a basic Blog using Views. This is being picked up by Facebook's Graffitti module. Everything works fine here, except that the image isn't being added to the RSS feed... I've incuded a screenshot of my views settings... I'm using a Style of RSS Feed and Row Style: Node (this is the only type allowed).

How can I get a link to the image into feed?!

screenshot


texts: specific htaccess in some sites on multisite

texts:
i have several drupal sites running as multisite (same core + modules code), just moving to shared hosting

Some sites should be kept password protected. (AuthType Basic)

Is there a way to tell in .htaccess in drupal root that for certain HOSTNAME's
the password section should apply or at least a new .htaccess (in site subfolder) shall override
 .


texts:
I have read a great deal and trying to learn how to get data into a table in the db. I have the below code to test entering just the first name of someone and I am getting an error. I have tried to follow the examples.module but I am missing something. I would appreciate a nudge in the right direction...

function ghost_form_form_submit($form, &$form_state) {
$entity_id = db_insert('field_data_field_first_name') // database table name
  ->fields(array(
    'field_first_name_value' => $form_state['values']['field_first_name_value'],
  ))
  ->execute();

drupal_set_message(t('Your form entry has been added'));
}

Here is the complete form code...
https://gist.github.com/anonymous/f6d8dc19a3eed0f56d59

The only error I get in watchdog is the $entity_id. However I am not sure what I am missing.
Thanks


texts: twig if Term ID is something, then do something

texts:
I have a taxonomy called Fish and 2 terms in it. Bass and Gold. I have a term reference field on a Page node, and its a select list. The editor can select either Bass or Gold. And I want display something depending on what the user selects. I cannot get it to work. This is what I have tried. Below the Bass tid is '1'.

{% if node.field_term_reference.value == '1' %}

The value is Bass

{% else %}

The value is Gold

{% endif %}

Below I am outputting the string value bass.

{% if node.field_term_reference[0]['#title'] == "bass" %}

The value is Bass

{% else %}

The value is Gold

{% endif %}

Both of these return "The value is Gold"
I tried this also

{% if node.field_term_reference.label == "bass" %}

The value is Bass

{% else %}

The value is Gold

{% endif %}

What if you want to add multiple terms and use AND OR "bass" and "finch".

{% if node.field_term_reference.entity.label == "bass" and or "finch" %}

How would it be written?


texts: Views relationship outputting duplicate nodes?

texts:
I have a view of Planet content types. These Planets have a node reference field for Trade Routes to reference other Planets. I'm attempting to output both the current Planet's x/y coordinates, as well as the x/y coordinates of the Planets it references in it's Trade Routes field.

Setting up the fields with each Planet outputting its own x/y and the x/y fields again but using the Trade Route relationship this time results in each Planet being returned as a row once per Trade Route it is storing, instead of returning an array of x/y like I would expect.

What am I doing wrong here?


texts: How to add jQuery code only to the node add/edit page?

texts:
I'd like to execute some jQuery code on a particular element in the node add/edit page of a particular content type. Currently I do that by putting

$(document).ready(function() {
    if (window.location.href.indexOf("node/add/CONTENT_TYPE") > -1) {
        ACTION;
    }
});

in the theme's .js file. It works, but I think the approach is probably not appropriate, as the test unnecessarily runs everywhere.

Could you please suggest an appropriate way?


texts: Pathauto tokens for taxonomy terms except root

texts:
Thanks to pathauto and tokens it is very easy to generate URLs with [node:field_product_category:entity:parents:join-path]/[node:field_product_category:entity]/[node:title] \o/

But … I would like to start at the 2nd level, so is it possible to exclude the root level from [node:field_product_category:entity:parents:join-path]?

Example

What I have got: http://www.example.com/redundant_root_category/category_from_level_2/category_from_level_3/super_product

What I want: http://www.example.com/category_from_level_2/category_from_level_3/super_product


texts: How can I make a node link to another node

texts:
According to this site http://asblab.mie.utoronto.ca/news, you can see how
Home>>News just below the menu. If I could add in this node http://asblab.mie.utoronto.ca/node/12525

such that Rise of the robots page would have

Home>>News>>Rise of the robots . How do I link them together?

Thank you guys, this forum has been helping me alot. If my question doesnt make sense, please inform me so I can try my best to edit and make the question better.


texts: create multilingual node programmatically

texts:
i'm trying to create a multilingual node using a php script.

I'm doing this:

 $node = new stdClass();
 $node->title = "Test ".mktime();
 $node->type = "job";
 $node->language = 'de'; // Or e.g. 'en' if locale is enabled
 $node->uid = $user->uid;
 $node->status = 1; //(1 or 0): published or not
 $node->promote = 0; //(1 or 0): promoted to front page
 $node->comment = 1; //2 = comments on, 1 = comments off
 $node->path = array('alias' => 'das-ist-ein-test-'.mktime());
 $node->body[$node->language][0]['value']   = "Body Body Body";
 $node->body[$node->language] = text_summary("Body Body Body");
 $node->body[$node->language]  = 'filtered_html';
 node_save($node);

As long as i set $node->language to 'und' everything is working fine.
But as soon as I set the language to 'de' or 'en' (both languages are activated in my Drupal installation) the body text doesn't get saved.

So my question is: can anybody provide me with a working example of how to store a multlingual node (de,en) into Drupal using program code.

Thank you


texts: Images are not showing on localhost. What settings do I need to change?

texts:
My images are not showing. I have looked this question up but all of the solutions I found were over a year old and my settings.php file does not have a $base_url setting.

If you try to view an image with the browser, you can see it at localhost/mysite/sites/default/files/image.jpg, but Drupal is pointing to
localhost/sites/default/files/image.jpg and the subdirectory is being left out.

How do I fix this?

I am using Drupal 8 on LAMP on Ubuntu 16.04.


texts: Drupal EU Cookie Compliance module conflict with theme JQuery

texts:
When I first installed the module, it'd only appear in admin pages.

After some investigation, I discovered the cause was some sort of conflict with my themes jquery: jquery-1.11.2.min.js.

If I disable it, the module works. If I enable it, the module doesn't work in non-admin pages.

The error message I'm getting is

TypeError: $.cookie is not a function

I think the module is using a older version of jquery, and that API has since been deprecated in newer version. I can't update the the modules jquery without modifying the module itself, nor can I downgrade my theme's jquery.

How do I have the module strictly use its own jquery and not use my theme's (if that's the cause of the problem)?


texts: In order to fight spammers, I'd like to limit the number of threads and posts that authenticated users can create per hour. What is the easiest way to do so?


texts: Allow Role to change only Moderation State of Content Type without possibility to edit content fields

texts:
The system we are building has a role Publisher.
It's task is to change  Moderation State of a content (news content_type) without having a possibility to edit an actual content.

In short, the user in role Publisher sees all News created by other users and only has permission to change its state.

In short, how do I allow a user in a role to edit only 1 field and block the rest?


texts: Issue using Exposed filters along with contextual filters in views

texts:
I have a view page listing my stories/articles. I have a contextual filter based on the field Country which is a taxonomy term reference field. I have defined the path of the page as article-search/% to accommodate the contextual filter value.

I have an exposed filter on the field article-category which is also of type taxonomy term reference. I use better exposed filters to display the exposed filter values as links.

The contextual filter works fine and I configured the url to display taxonomy name instead of term id. This part works fine but when I click on any of the links in the exposed filter the taxonomy term name for the contextual filter value changes to %25 instead of the taxonomy name and the contextual filter fails. It works fine if I use the default dropdown option for the exposed filter instead of better exposed forms.

Any idea if there is an issue with better exposed filters when used along with contextual filters?


texts:
I am running a setup on Ubuntu and WSL (Windows Subsystem for Linux) with Nginx and PHP7.4.

Drupal 8 and Drupal 9 fresh installations load every page with no problem, except the page on /admin/modules.

On the error.log file I found this error.

  2020/06/04 17:28:17 [error] 3610#3610: 1 upstream timed out (110: Connection timed out) while reading upstream, client: 127.0.0.1, server: d9.local, request: "GET /admin/modules HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "d9.local:8080", referrer: "http://d9.local:8080/"

The Nginx configuration is the following.

server {
    server_name d9.local;
    root /var/www/d9.local/web; ## <-- Your only path $
    access_log /var/www/d9.local/logs/access.log;
    error_log /var/www/d9.local/logs/error.log;

    listen 8080;
    listen [::]:8080;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Very rarely should these ever be accessed outside of your lan
    location ~* \.(txt|log)$ {
        allow 192.168.0.0/16;
        deny all;
    }

    location ~ \..*/.*\.php$ {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }

    # Block access to "hidden" files and directories whose names begin with a
    # period. This includes directories used by version control systems such
    # as Subversion or Git to store control files.
    location ~ (^|/)\. {
        return 403;
    }

    location / {
        # try_files $uri @rewrite; # For Drupal <= 6
        try_files $uri /index.php?$query_string; # For Drupal >= 7
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    # In Drupal 8, we must also match new paths where the '.php' appears in the middle,
    # such as update.php/selection. The rule we use is strict, and only allows this pattern
    # with the update.php front controller.  This allows legacy path aliases in the form of
    # blog/index.php/legacy-path to continue to route to Drupal nodes. If you do not have
    # any paths like that, then you might prefer to use a laxer rule, such as:
    #   location ~ \.php(/|$) {
    # The laxer rule will continue to work if Drupal uses this new URL pattern with front
    # controllers other than update.php in a future release.
    location ~ '\.php$|^/update.php' {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        include fastcgi_params;
        include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                fastcgi_read_timeout 60;
                fastcgi_keep_conn on;
                fastcgi_buffering off;
    }

    # Fighting with Styles? This little gem is amazing.
    # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
    location ~ ^/sites/.*/files/styles/ { # For Drpal >= 7
        try_files $uri @rewrite;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }
}

Drupal 7 fresh install loads the modules page fine.

Note that page loads if you switch from Nginx to Apache. Do I cross post this to Server Fault? I just don't see it how this can be Nginx fault for not loading one specific page and people at Server Fault might not just get it or work with Drupal, I don't know what other kind of information to provide.

While the page loads, running service php-fpm7.4 restart immediately loads the complete page. I had this issue previously on all pages, which was solved reading the answer for Pages load only when you restart php-fpm, more with .gif images and previews. I am still stuck on the Modules page.


texts: Token replacement pattern for triggered rules on node creation

texts:
I am currently using triggered rules to send notifications whenever a certain node type is created (by anonymous, unauthenticated users). In the email notification sent I would like to include some of the content submitted in the form but I cannot find any of the replacements tokens when editing the ruleset for the event.

Right now, the token replacement patters for Form and for Form State are listed as empty.

How can I get hold of the relevant replacement tokens for the Form content?

Is there any modules that are capable of sending similar notifications (with node/Form content) upon node creation?

I am using Drupal 6.20, Rules 6.x-1.4, Token 6.x-1.15, CCK 6x.2.9


texts: How do I get posts of a content type on node writing

texts:
I have three content types: endorse, deals, and recommends. Recommends has three nodes.

How do I show those three nodes from the recommend content type on the deals content type using a field on the deals content type writing panel?


texts:
I'm building two very big sites using Drupal. Both will have plenty of vocabularies with up to 6-7 levels deep like this:

State->District->City->Area->office name->department

The taxonomy will have multiple parents from across vocabularies.

I'm working on D6 sites and managing taxonomy hierarchy isn't easy and is bit cumbersome with D6.

I want to know if it'd be easier with D7 especially when it comes to managing terms with multiple parents.
Any idea?


texts:
I have two different views that need to be toggled on a node page.  I cannot put these two views together so I have created a form that will basically take the values of the form that I create, and send them as arguments to the view and display the view.  I am attempting to do with this ajax.  It works fine but the problem is the second time I run the form it does not refresh or update that view.

function photoflight_albums() {
    photoflight_gallery_themes();
  $output = render(drupal_get_form('photoflight_gallery_form'));
  $output .= "
";
  $output .= views_embed_view('gallery', 'default');
  $output .= "
";

  return $output;

}

//Grabs the node titles
function photoflight_gallery_themes(){
    $type = "photo_theme";
    $theme_list = array();
    $nodes = node_load_multiple(array(), array('type' => $type));
    foreach($nodes as $themes){
        $theme_list[$themes->title] = $themes->title;
    }
    return $theme_list;
}

//Form calls back to the function above to the gallery-ajax-wrapper div output above
    function photoflight_gallery_form($form, &$form_state){
        $form = array();

  $form['themes'] = array(
    '#type' => 'select',
    '#options' => array(photoflight_gallery_themes()),
    '#ajax' => array(
            'callback' => 'photoflight_simplest_callback',
            'wrapper' => 'gallery-ajax-wrapper',
        ),
  );
  //debug($form);
  return $form;
}

//Ajax callback
function photoflight_simplest_callback($form, $form_state) {
    $view = views_get_view('gallery');
    $args = array( 'title' => $form_state['values']['themes']);
    $view->set_exposed_input($args);
    $output = $view->preview('default', $args);
    return array("#markup" => $output);

}


texts:
So I'm getting a white screen of death on my newly created Drupal 7 site that was working fine until a minute ago. This is only happening on Chrome, the site works fine on IE and FF.

On chrome, the console gives the following error message:

  net::ERR_INCOMPLETE_CHUNKED_ENCODING

What I've done recently that might be causing this error:

I enabled the xmlsitemap module
I enabled clean url's on my site - maybe this is being caused by something wrong in my .htaccess file?

My cPanel Error log reports the following, though I'm not sure these are related issues:

[Thu Sep 24 20:10:33 2015] [error] [client xx.xxx.xx.xx] File does not exist: /home/myuser/public_html/sites/default/files/milla.jpg, referer: http://mydomain.fi/?q=node/7/edit&destination=admin/content

[Thu Sep 24 20:09:04 2015] [error] [client xx.xxx.xx.xx] File does not exist: /home/myuser/public_html/admin, referer: http://mydomain.fi/?q=admin/structure/types/manage/blog-post&destination=admin/config/search/xmlsitemap/settings

[Thu Sep 24 20:00:07 2015] [error] [client xx.xxx.xx.xx] File does not exist: /home/myuser/public_html/admin

[Thu Sep 24 19:59:59 2015] [error] [client xx.xxx.xx.xx] File does not exist: /home/myuser/public_html/admin

[Thu Sep 24 19:59:48 2015] [error] [client xx.xxx.xx.xx] File does not exist: /home/myuser/public_html/admin

First real Drupal project that I'm actually hosting somewhere, and now that I just got it up and running it's all coming crashing down :(


texts: ASAF module redirects comment form to system/ajax#comment-cid after submission

texts:
I use Asaf (ajax submit for any form) module to Ajaxify form submissions in my website. This module works well but in comment form submission, it submits the comment then redirects the page to system/ajax#comment-cid which is a blank white page.

How can I solve this or is there any way out to Ajaxify comment form submission?


texts: Display content with Taxonomy on User and Content matching

texts:
I've got a specific content type.  One field is a term reference field called "blog subject" in which a content author tags the node.

Ok.  Moving on to the end user.  I added the same term reference field to user account settings in which a user can select certain terms that they're interested in.

I would like to create a view in which the contextual filter is the user.  By going to www.whatever.com/blogs/12, I can see content that matches the users selected interests.

Thoughts?


texts:
I programmed a multi-step form using the drupal form API. On the first page is
a user image file upload using the drupal managed field managed_file. When the form is stepped thru to the end and submitted, the already in the single steps validated data will be stored into profile2, by creating a profile2 object with profile_create and set the assign the fields.
This all works without problem. But how can I store the FID of the uploaded file to the profile2 user_image field? A s I saw in mysql, the file FID and the measurements of the image are stored in the field table.

I have this (file_load code snippet is untested) in the form submit step, where the data gets stored into profile2:

$profile = profile_create(array
    'user' => $new_user,
    'type' => 'main'));
$profile->field_firstname['und'][0]['value'] = $user_data_collection['t_1_1'];
// ...
if (isset($user_data_collection['t_1_22'])) {
    $file = file_load($user_data_collection['t_1_22']);
    $file->status = FILE_STATUS_PERMANENT;
    file_save($file);

    $fid = $file->fid;

    // --- how can I store the FID, x and y measurements of the image?
    // ...
}
// ...
profile2_save($profile);

Can somebody give me a hint? I was searching on google but did not find an answer to my question. Thanks in advance!

Update:
This is how I solved it now. Since I work with an "managed_file" Field in the form, and later for displaying the image file via the theme() fct I do not have to care about resizing. This is done due to the image cache / theme fct's with a properly defined image-style.

$profile = profile_create(array(
   'user' => $new_user,
   'type' => 'main'));

//...

if (isset($user_data_collection['t_1_22'])) {
   $file = file_load($user_data_collection['t_1_22']);
   // --- Flag that this file is permanent and should not be deleted.
   $file->status = FILE_STATUS_PERMANENT;
   // --- save file object to the database
   file_save($file);

   // --- get original x/y measurements for this image
   $img_info = image_get_info(drupal_realpath($file->uri));
   // --- store fid. x and y to profile 2
   $profile->field_image_user[
      'und'][0]['fid'] = $file->fid;
   $profile->field_image_user[
      'und'][0]['width'] = $img_info['width'];
   $profile->field_image_user[
      'und'][0]['height'] = $img_info['height'];
}

//...

// --- save profile data
profile2_save($profile);

So all seems to work and have the solution that I needed.


texts: Is there a module to show a quick message to a user or role?

texts:
Is there a module to send a user or users having a role a message like the one that is currently on top of this site (The Drupal Answers 2012 community moderator election is underway — nominations now being accepted.")?

I don't need a message box like the one that Private message module provides, but a quick message.


texts: Ajax wrapper replacement on a field widget form

texts:
I'm having ajax-related problem while building my custom compound field. The problem is similar to this post.

The field widget consist of a textfield (autocomplete) and markup. They are defined like this in the hook_field_widget_form:

   $element['symbol'] = array(
      '#type' => 'textfield',
      '#title' => t('Phrase'),
      '#required' => $delta == 0 && $instance['required'],
      '#default_value' => isset($items[$delta]['symbol']) ? $items[$delta]['symbol'] : NULL,
      '#size' => $settings['size'],
      '#element_validate' => array('_ghs_field_validate'),
      '#autocomplete_path' => 'admin/ghs/get',
    );
    $element['description'] = array(
      '#type' => 'markup',
      '#markup' => '[no phrase selected]',
    );

Of course this is accompanied by hook_menu() for the autocomplete path and a callback function. But this is working fine, so there's no need to paste the code.

The problem I'm having is that I want a front-end callback that would do wrapper replacement of the $element['description'].

I tried to do that following the Ajax Example, replacing #autocomplete_path with:

'#ajax' => array(
  'callback' => 'ajax_example_simplest_callback',
  'wrapper' => 'replace_textfield_div',
),

This is the way that commerce guys used for commerce_line_item (snippet) but I must be doing something wrong when trying to mimic their code.

A plus of the #autocomplete_path way is that it provides a visual signal (a throbber) that it is a lookup field. This may be important for site editors later.

To cut a long story short - is the  replacement doable using the #autocomplete_path property of the element? Is there any extra js code needed to do that?


texts: How do I debug a CKEditor installation on Drupal 7?

texts: I installed the the CKEditor module in Drupal 7.  I've also installed the CKEditor JavaScript library from the website CKEditor. However, no matter what I do, the editor don't show up as it is supposed to.


texts:
I need to add a new feature to my site that allows users to buy a services.

We have 1 service now to be sold, and may extend to have 3 in the future with no attributes nor shipping, just a sales price.
 What should we use to implement this?

Commerce, ubercart or none of them?


texts: Assigning a different set of roles to the same user based on the node being edited

texts:
I am using hook_node_access (https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_access/7.x) to provide some users the ability to edit certain nodes they couldn't otherwise edit based on certain criteria. The solution works but there are two problems

The users are able to edit certain nodes but they should also have a
permission to attach the node to a specified place in the menu
structure
I am using the paragraphs module (https://www.drupal.org/project/paragraphs) so although the users are able to edit the node itself, they are unable to edit the paragraphs the node is holding.

I am thinking about the following solution for the above mentioned problems:

In hook_init check that the current user has a certain uid
Check whether the current user is on a node edit page
Check the node has a specified node id
If the above criteria is met, on the fly assign a special role to the
user
The special role has permission to edit menu and paragraphs
During the first page load when the criteria above is not anymore met, remove the special role

So my question boils down to whether it is acceptable to assign and remove roles on the fly enabling the same user to have different set of roles based on the node the user is editing. Or would this type of approach be problematic?

I know there are a variety of access related modules but none of those has suited the use case I am dealing with so Im looking a code based solution rather than introducing new node access modules.


texts:
I notice here that I can upload a photo from my computer, like this one:

On my drupal site, I can do so as well, as an admininstrator. But for a regular authenticated user, I can't. Here's what regular users gets when they click on the upload media icon. Only access to gallery, not local files. Why?


texts: How to play the video using media module?

texts:
I am using drupal 7 and i am in need of upload a video from our local system as well as from the video. I found the media module and media_youtube module. After installing the module, the url from the youtube is working, but for local machine system video upload in getting downloadable option in the front end and not played.

How to play the video without downloadable option in the same page. Please suggest me some ideas.

Thanks.


texts: Pass parameter to node twig template via url

texts:
The url to display node 100 is <site>/node/100. I want to pass a parameter to this node via the url. For example: <site>/node/100/3.

Question:

What must I do to get Drupal 8 to see /node/100/3 as /node/100 with the parameter 3 instead of just the url /node/100/3 (which fails)?

Efforts:

I've read many posts, but didn't find any that seem to directly address this issue.
I realize this can probably be accomplished via /node/100?param=3. I want to avoid using a query parameter if possible, just for cleanness.
I realize this can probably be accomplished by displaying the node within a view and then using a contextual filter. I want to avoid using a view if possible, again just for cleanness.


texts:
I am using a user flag, Visits, to track each user's visits to other user's profiles.

When a user visits another user's profile, a rule is triggered that automatically flags the visited user on behalf of the visiting user.

Flagging the user on the first visit is no problem.  But on the second visit and thereafter, I want to update the flag that was flagged on the first visit.  To do this, I made the following rule:

Event: User account page is viewed
Condition 1: NOT [account] is [site:current-user]
Condition 2: User is flagged ([account] on behalf of [site:current-user])
Actions-> How do I fetch and update the flag?

This rule is triggered correctly; however, I don't know how to get the previous flag (the flag applied when the user visited the profile for the first time) in order to update it.

My question: how can I fetch the previously applied flag in rules so that I can update the timestamp and re-save it?

What I tried

Flag provides a rules action Fetch user flagged by user, but this does not help because this returns an array of users, not the flagging, which is what I want to update.

I can add the Unflag a node action and then the Flag a node action, but this will destroy my previous flag and replace it with a new one; since I want to track referer information over time, this is not a good solution.

Since I'm using Flag 3.x in which flags are entities, I tried using the Fetch entity by property action in Rules to fetch the flagging, but in this case the only property I can choose to select is the value of the Referer field, which is not helpful.  There seems to be no way to fetch the flag by its endpoints.

Why I'm doing this

This flag has a computed field, Referer, which stores the value of $_SERVER['HTTP_REFERER'] upon flagging.

When a user visits the profile of a user for the second time, I want to update this flag by updating the timestamp of the flagging and adding the new referer information to the flag.


texts: Submitting disabled fields on content entry forms?

texts:
I need to submit content entry forms that have default values set in disabled elements.  However, if I remember correctly, HTTP specifies that fields that are disabled do not have their values sent to the web server (or are dropped by the web server, I can't remember).

Specifically, I have a tag field (term reference) that is a select list, and it defaults to a particular value that is updated twice a year and it cannot be changed by users submitting the form.  I want this field to appear to the user, but at the same time I want it disabled so they can't change it.

How can I submit a disabled field in Drupal 7?


texts: hook_preprocess_node() or hook_node_view() for html altering the field

texts: What's the best way to alter html of an image field? I have imagefield and i want to rewrite it's html from scratch.


texts: What determines which fields are available in the relationship options?

texts:
What determines which fields are available in the views relationship options?

When creating a view, you can use Relationships, choosing from a list of available fields. Are all created fields supposed to be available for relationship in any view? It seems that some fields are available and some are not.

Example: I have Students and School as my Content Types. Students uses a Node Reference to School. When creating a view, I use Relationship, and a bunch of fields are there to choose from. As expected, School is there, because it is referenced in a field. But there are a lot more fields available. Why are those fields available? What criteria do fields fill to be available to use?


texts: OAuth2 Server sending 'null' as the 'sub' parameter instead of User Id

texts:
When using OAuth2 Server module to authorize with users, I am not receiving the correct "sub" parameter in the response from the server. I get all the other fields such as email, email_verified, name, preferred_username, and zoneinfo; just not the sub parameter.
{
  "sub": null,
  "email": "someuser@email.com",
  "email_verified": true,
  "name": "SomeUser",
  "preferred_username": "SomeUser",
  "zoneinfo": "Asia/Dubai"
}

I've tried using hook_oauth2_server_user_claims to alter this parameter like so:
function my_module_oauth_server_user_claims($account, $requested_scopes) {
  $claims = [];

  if (in_array('profile', $requested_scopes)) {
    $claims['sub'] = $account->id();
    $claims['user_id'] = $account->id(); // for debugging purposes
  }

  return $claims;
}

Doing this adds the user_id parameter to the response body, but the 'sub' is still set as 'null', therefore it must get override afterwards.
I double checked the documentation and have all the permissions set, but can't find anything about this particular issue.. Why is `sub' not being populated correctly during this process?


texts:
CSS styles don't load in Internet Explorer (checked on version 9 and 7). They work locally, but not on the remote server. Do you have any idea?

Edit: It seems that compressing CSS inside "configuration >> performance" causes this problem. Is there a way to turn this feature for all browsers except IE?


texts:
In Drupal 8, how can you add new attributes to be rendered into the twig file?

I want to provide a region.html.twig that can be extended for subtheming.

So, I want the default to be:

{%
  set wrapper_classes = [
    'region',
    'region-' ~ region|clean_class,
    'container',
    'container--100',
  ]
%}

{%
  set outer_column_classes = [
    'container__col',
  ]
%}

{%
  set inner_column_classes = [
    'container__inner',
  ]
%}

<div{{ wrapper_attributes.addClass(wrapper_classes) }}>
  <div{{ outer_column_attributes.addClass(outer_column_classes) }}>
    <div{{ inner_column_attributes.addClass(inner_column_classes) }}>
      {% block content %}
        {{ content }}
      {% endblock %}
    </div>
  </div>
</div>

Simply making them arrays or strings as you would in D7 doesn't work - they never reach the twig template.

I noticed that Bartik uses the Attribute class to create new/empty Attributes. Is this kosher to do, exactly?

use Drupal\Core\Template\Attribute;

function mytheme_preprocess_region(&$variables) {
  $variables['wrapper_attributes'] = new Attribute();
  $variables['outer_column_attributes'] = new Attribute();
  $variables['inner_column_attributes'] = new Attribute();
}

When I do that, my new attributes appear and are rendered in the template. Is this even worth doing, or is it a lot more trouble to extend templates and manipulate them?


texts: How to allow visitors add option in poll?

texts:
I would like to have a poll for logged in and anonymous users to vote.
In the poll, users are allowed to add in their own poll option and vote. (Just like how Facebook poll is working previously)

Is there any drupal way which I can do this? Or I need to use some combination of ways to achieve this?


texts: OG "Add people" username predictive searching

texts:
In OG7, I have given one user the role of overseer and that role has the Administer Organic groups permissions enabled so he can administer all Organic Groups on the site.

So, for each group, when my overseer goes to Group -> Add People and he attempts to input the user name, the textfield does not predict/provide suggestions of matching user names. However, this helpful effect does happen for the site administrator.

Can anyone tell me how I can enable this user name prediction effect for my overseer role?


texts:
Question: How do I export/import translation of Custom Menu Items

I have a module that takes all the .po files for custom strings and then uses locale to batch import them. This works great.

I was wanting to translate my custom menu links, but when I search for them in the translate interface (or searching the .po from exporting my translations) I am unable to find any of the menu items.

I've included my admin/config/regional/content-language settings below so you can see that Custom Menu Link (and it's menu link title) is ticked.

I am able to translate the menu items only by going to admin/structure/menu/item/#/edit/translations, but this isn't (seemingly) exportable in either the .po files (via locale export), nor the config management system (via drush cex).

Anyone know how to do this? Thanks in advance.


texts: I need to switch from database logging to syslog

texts:
I'm running a drupal 6 website and I was thinking of speeding it up following these steps:

Completely stop database logging
Enable syslog

How do I configure Drupal to use syslog?
What if I enable just syslog and disable the database log? Do I have to further configure stuff?


texts: Is there any way to add a file field for multiple upload file to a custom form?

texts:
I'd like to add a file upload widget to a custom form, with core file module, as shown in the admin edit node page. I've trying with the 'managed_file' API, but I've only got upload one file. I need multiple files and re-ordening.

Is there a way to use the File module in a custom form, as in the node edit form?


texts: Hook not firing for custom entity -- how to set theme suggestions?

texts:
I have an entity whose machine name is orb_act.  This code is not firing in Drupal 8:

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function mytheme_theme_suggestions_orb_act_alter(array &$suggestions, array $variables) {

  // Add template suggestions based on the current view mode.

  $suggestions[] = 'orb_act';
  $suggestions[] = 'orb_act__' . $variables['elements']['#view_mode'];

}

How do I set my template suggestions?


texts:
I want to add a body class for the content type of each node. Drupal already provides this, but it isn't always consistent between the Node view, the Node/Add view and the Node/Edit view. This makes theming difficult.

Here is my code in template.php

function MYTHEME_preprocess_html(&$variables) {

    // Add Content type name to classes
    $content_type = $variables['page']['content']['system_main']['type']['#value'];
    $content_type_class = 'content-type-'.drupal_html_class($content_type);
    $variables['classes_array'][] = $content_type_class;

}

It works but I get this error message:

  Notice: Undefined index: type in wintheme_preprocess_html()

On Stack Exchange, it says the best approach is to use Isset().

If I do this, the error message goes away, but so does the class.

How can I keep my class working without the error message.


texts: Create a log when user join/abandoned in a og group in Drupal 7

texts:
I'm creating a log with several actions in drupal.

I need register in a custom log when a user requests to join a group. Then I need register that the user has joined in the group or has abandoned this.

Appreciate any guidance to investigate. Thanks :)


texts: Save boolean data types in serialized array

texts:
I'm writing a CRUD front end application that talks to a hand-written Drupal endpoint. The data I'm pulling from the database is serialized in one field, or cell. It comes out as a keyed array.

One of the actions a user can do is to set a value true/false. The problem I'm running into is that when I send that data to the database from Javascript, it's coming in as a string:

 request.post('/my-api/save/' + id )
  .set('Content-Type', 'application/json')
  .send('{"' + prop + '":"' + val + '"}')

And when it's serialized and saved the the database val is written as a string. The problem is when val it is equal to "false." I'm using drupal_write_record to save the array. When this comes back to the front end, it's still a string, which in Javascript gets coerced to true.

What I'm struggling with is how/where to turn that string into a boolean. I'm guessing I should be doing this on the save action, but maybe there's a Drupal specific way to do this.

I'm doing this to the incoming json at the moment, I don't like it but it works for now.

$received_json = file_get_contents("php://input",  TRUE);
$json = drupal_json_decode($received_json);
foreach($json as $key => $val) {
  // Typecast the "false" string
  $json[$key] = $val === 'false' ? (bool) FALSE : $val;
}


texts: How to write EntityQuery so that it checks user's access to nodes?

texts:
How do I write the following Drupal 8 EntityQuery so that it only returns nodes that the current user has access to?

$query = \Drupal::entityQuery('node')
  ->condition('type', 'article');

The above query will return all nodes, even unpublished ones. Depending on how you use the results (like a list of nodes), users could see titles or other information from unpublished nodes.

$query = \Drupal::entityQuery('node')
  ->condition('type', 'article')
  ->condition('status', 1);

When I add the "status" condition, I now get a list of only published nodes. But I would like people with administer nodes permission to see all the nodes.

Basically, is there a way to simulate the "admin or published" filter, like on Views?


texts: settings and switching to external pgsql db

texts:
I am working with Drupal 7.3.4 and attempting to follow the instructions of changing settings.php so that I can switch to a pgsql DB within a module and then switch back to the default mysql after doing a query.

I have set up in the settings.php file with the following format:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => '',
      'username' => '',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
  'custom_db' =>
  array (
    'default' =>
    array (
      'database' => 'custom_db',
      'username' => 'dbuser',
      'password' => 'pass',
      'host' => 'urltoservice',
      'port' => '5432',
      'driver' => 'pgsql',
      'prefix' => '',
    ),
  ),
);

Now I am trying the process of switching to this DB in a module and verifying that the driver is changing.

db_set_active('custom_db');
//Get the currently active DB driver
drupal_set_message(db_driver());
db_set_active();

But, when I print the driver it is not switching to pgsql as expected.  I am pretty sure it is still pointing to the default mysql db.  Any ideas of what I may be doing wrong here would be greatly appreciated.

Thanks,
Derek


texts: Automatic Nodetitles: How to hide "Pattern for the Title" when empty

texts:
I installed Automatic Nodetitles 7.x-1.0 on Drupal 7 for Staff Content Type. Everything seems perfect except the feature "Pattern for the title" for "Automatically generate the title and hide the title field".

The pattern I replaced with "[node:field-firstname] [node:field-middlename] [node:field-lastname], but it displayed the ACTUAL TEXT "[node:field-middlename]" on title when middle name is empty. Is there a setting or solution to hide pattern when empty?


texts: How do I override a default view template from another module?

texts:
Drupal provides hook_theme(). But is there a hook_theme_alter()? I'm looking for something like hook_menu_link_alter(), which overrides hook menu entries, but for the theme. I want to modify a view hook theme entry so I can specify where to look for one of my custom templates. I am not interested in specifying it through the Views interface, since it look for the theme template inside the theme folder, and I want my template in a feature module.

I found hook_theme_registry_alter() and _theme_process_registry(). You can answer which one is the best to use and why.

Which of these keys should I modify in order to make the view pickup the template from the module?

If I put views-data-export-xml-header--richard-feeds-nokia-movies--views-data-export-1 in the feature, the View defaults to pick up views-data-export-xml-header.tpl.php. If I put that template in the theme layer, the view picks it up (even with the registry alter hook in place).


texts: Feeds importer. Only imports a certain amount then stops

texts:
I have been attempting to import 5,000+ pieces of content from a CSV file using the feeds module. I have it set up to import 130 items every cron run and i have cron running every hour.

All is good for the first few hours. I go to sleep and then wake up, and it is no longer running.

I have my cache clearing every 6 hours. is it possible that clearing cache kills the communication with feeds and stops the import record?

Is it a simple setting change within feeds?

I cannot monitor it completely to see when this issue stops exactly since my imports are suppose to be spread over 48 hours on each hour.

Update: If I run cron manually over and over again, it will reach 100%.


texts: SSESS Cookie (Session ID) is being changed when loading images that don't exist

texts:
I have a Drupal 8.6.10 site which has a very confusing logout bug:

I have a page that has various elements on it as images, js, css and so on.
I load that page and everything works fine
I add an image to that page
I load the page again, everything fine, also the image is showing.
I delete the source image and the image style derivatives of that image
I reload the page -> I get logged out!

I can see on the call to the image (which returns a 404 because the image is not existing), the value of the SSESS Session cookie is changed (so the session ID) thus I'm losing the connection to my session and get logged out.

I have already proven that this happens inside the execution of PHP and has nothing to do with varnish (logging at the very end of index.php, before the answer gets sent, shows already the changed session id using session_id() ).

I have a parallel installation which is still on Drupal 8.3.7, and which contains various fixes of this issue: https://www.drupal.org/node/2743931
When I remove the fixes for the issue, the bug does no more appear.

However after the update to 8.6.10, I removed all the fixes because the issue has been fixed in core, and despite the fixes being removed, the logout bug still appears.

How can the session id even be changed? Calling session_start() a second time does not work and session_regenerate_id (the only one in the symfony core) is never called.

Please help me on this one, as I'm currently at the end of my latin. Thanks!


texts:
I need the active page in my menu not to be a link.

So let's say I'm on the services page, I need my menu structure to look like this:

home

services

portfolio

contact

How can I do that?


texts:
I'm getting a list of the following errors in my new drupal website. Any idea where this is coming from and what I need to do to fix it?

The Default path pattern (applies to all content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern for Applications (applies to all Applications content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern for Careers (applies to all Careers content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern for Events (applies to all Events content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern for Executive Team (applies to all Executive Team content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern for News (applies to all News content types with blank patterns below) is using the following invalid tokens: [node:created:custom:Y], [node:created:custom:m], [node:created:custom:d], [node:title].
The Pattern for all Products paths is using the following invalid tokens: [node:title].
The Default path pattern for SlideShow (applies to all SlideShow content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern for Solutions (applies to all Solutions content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern for Test Type (applies to all Test Type content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern for Webform (applies to all Webform content types with blank patterns below) is using the following invalid tokens: [node:title].
The Default path pattern (applies to all vocabularies with blank patterns below) is using the following invalid tokens: [term:vocabulary], [term:name].
The Pattern for user account page paths is using the following invalid tokens: [user:name].


texts: How to correctly install PHPMailer + Messaging on Drupal 6

texts:
I have a Drupal 6 site where I would like to use PHPMailer to send notifications about newly created nodes and such.
When I install PHPMailer 6.x-3.1, it needs Libraries and that phpmailer be placed under sites/libraries.
As I want different notifications for each content type, I installed
Notifications 6.x-4.0-beta7 and Messaging 6.x-4.0-beta8.
What confuses me, is that I have two different places where PHPMailer can be configured, and they can have different settings: http://mysite.com/admin/messaging/settings/method/phpmailer and http://mysite.com/admin/settings/phpmailer.
Can anyone confirm my setup?

BTW: I had some trouble finding out that existing subscriptions had to be replaced with new (or edited in database) to move from notifications to notifications_content. Might be a help for others.


texts:
I am trying to add different html class attributes to images based on what view they are being output with. I have created two image styles using the administrative interface, here are the two machine names.
1. front_page_recent_blogs
2. blog_page_view

I have assigned each of these to the image field in the two different views. I have successfully added classes to the front_page_recent_blogs images using the following code:

function mythemename_image_style($variables) {

  $variables['attributes'] = array(
    'class' => 'img-responsive center-block',
  );

  $variables['path'] = image_style_url('front_page_recent_blogs', $variables['path']);
  return theme('image', $variables);

}

How do I add classes to the blog_page_view image style, and to any future image styles? Calling the function twice breaks the entire site. If there is a better way to add classes to multiple image styles than overriding theme_image_style, please let me know.


texts:
I am hiding a field using hook_form_alter, because I only want to be able to edit this field in views. then, I used the Editable Views Module to display this field. Now, my problem is that when I press the save button, all of my nodes are saved.

Is there any way to only save nodes where this field has been edited?


texts:
I would like to list the values of certain variables using Drush in order to make sure they are in fact the variables that I intend to add to my feature. It seems that some variables are parents which contain multiple children. I use a drush/features/git workflow with a purchased but customized theme and following is my example for clarity.

In my feature myfeature_theme_helper there are two variables that I exported to it: theme__settings and theme_settings. I want to be able to view what values each are storing so I can determine if they should be removed from my helper. One of them contains an active tab, for example, which is not a setting that I want to commit to code.

Thank you!


texts: Can You Use HOOK_node_builder() to Set Custom Node ID?

texts:
Drupal 8.x

How do you set the node id in HOOK_node_builder()? Is it even possible?

There is a similar question here: Specifying a custom node id when creating new content, however it is a different approach or need.

MYMODULE.module:

function MYMODULE_node_builder($entity_type, NodeInterface $node, $form, FormStateInterface $form_state) {

    $node->setTitle('Node Title');

}

I am able to set the title fine. I am hard pressed to find any docs or posts on this hook.


texts: Drush make: simplexml_load_file(): I/O warning : failed to load external entity "" Project.php:74

texts:
I'm facing a very strange issue with Drush wget and OpenSSL on my mac book (MacOSX Sierra).

When I launch drush make site.make command (which should theoretically download the all modules) it fails with the following error:

Failed to get available update data from https://updates.drupal.org/release-history/workbench_og/7.x
simplexml_load_file(): I/O warning : failed to load external entity "" Project.php:74

I tried

wget https://updates.drupal.org/release-history/rate/7.x

and I got the following message:

https://updates.drupal.org/release-history/rate/7.xResolving
updates.drupal.org... 151.101.113.175
Connecting to updates.drupal.org|151.101.113.175|:443... connected.
OpenSSL: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
Unable to establish SSL connection.

Same message with flags:

wget https://updates.drupal.org/release-history/rate/7.x --no-check-certificate

Here I found exactly the problem that I have but, even if reinstalling openssl and upgrading the version (current version is OpenSSL 1.0.2l 25 May 2017) the problem persists.

Did someone has the same kind of issue?
And, in case, how did you handle it?

Thank you in advance!


texts: Preserve views exposed filter options when back button is pressed

texts:
I have an ajax exposed filter in the views. When user select option from filter it loads content. But when I click on item on view and press browser back button, exposed filter resets and default option is selected. Same thing happen when I refresh the page.

Is there any way in view to preserve the last selected option? Same thing happens when I click on page number of views.

Thank you.


texts: How to feature-ize multiple vocabularies applied to multiple content types?

texts:
Each of my content types is being exported into its own feature. I now need to export several vocabularies that are associated with the content.

Some of the vocabularies are applied to multiple content types. What is my best option for exporting those? Can I export a stand-alone feature that contains all the vocabularies that apply to multiple content types? Or should I associate them all with the most common content type? Or do I have to include each vocabulary in each feature individually?


texts: How to add cancel button while clicking the Edit link in View?

texts:
I created a content type and a view; when I click the edit link shown in the view, it redirects to the filled content type page, which contains only the Save, Preview, and  Delete buttons. I need to have a Cancel button too.

How do I add the Cancel button?


texts: View that filters content based on current page

texts:
I'm in the middle of a Drupal 6 to 8 migration and am attempting to recreate a view.  This view would appear on pages of the content type "People" and would show the "Publications" that this person is associated with.  The "Publications" has a field of type "Entity reference" that references each of the "People" titles.

How do I configure the view block to only show Publications that have the entity reference of the current "People" page?  I figure this has something to deal with contextual filters, but I'm a bit lost on how to filter this correctly.

Thank you in advance.


texts:
Problem

I have a form which a user can create data with and some of the fields are date fields which use jQuery datepicker.

The form is long and in order to help the user out, I have a series of help messages which appear when the relevant form input is focused.

When a form element is given focus, the form's ID is grabbed and attached as a class to the help div, which reveals the correct help message.

Example: jsfiddle - caveat in a moment

This works in the jsfiddle, however in Drupal it breaks. On click the calender opens but rather than selecting a link it hits the local hyperlink "#" below it and changes the url to http://mywebsite.com/form/#

The problem appears to be related to how the Drupal date jQuery module deals with Datepicker. I've narrowed it down to something to do with $(this).attr('id'), it doesn't like the that selector but I'm unsure as to why.

Full Script

  Drupal.behaviors.jobhelpAddClass = {
    attach: function (context, settings) {

      var jobHelp = $('#jobhelp').children();

      $('input, select').focus(function() {
        $(jobHelp).attr('id', $(this).attr('id'));
      });
    }
  };

I've tried with document ready instead of Drupal behaviours and it still breaks. I've also tried getting focus to call a function (with the same code), however neither works.


texts: Using drush into remote host is showing me local data

texts:
I have an alias setup for my remote host with the following in the script:

<?php
$aliases['lws'] = array(
    'root' => 'domain.com:/home/user/public_html',
    'uri' => 'domain.com',
    'remote-user' => 'user',
);
?>

But when I drush using (for example): drush @lws status

I get information back about my local machine and not about the remote machine. I know this is the case because my remote machine is Linux and my local machine is windows...and when I run drush from the remote machine itself it shows me different results than what drush on my local machine is giving me. Also the command above run locally shows me all the alias files I have setup on my local machine (for other drupal installs).

Any idea what might be going on here?


texts:
I am using Drupal 7 and I am creating an Omega subtheme.

In my case I want a page without left and right sidebars. But when I inspect the page.tpl.php from alpha theme it contains only code for printing attributes, content and footer regions

Here is my page.tpl.php

print $attributes;
  if (isset($page['header']))

   print render($page['header']);

  endif;

 if (isset($page['content']))

    print render($page['content']);

 endif;

  if (isset($page['footer']))

     print render($page['footer'])

  endif;

In the above snipped I don't find any option to show/hide sidebars as we used to do like in Garland theme.


texts: Field Template Suggestions: Target a particular field type on a content type

texts:
I want to use a field template for all the fields on my "journal_page" content type that use a widget of "long text".
How would I do this?
N.B.  My field is not named "long text". "Long text" is the name of the widget I am using (It is a text field). I want to use the same template file for multiple differently named fields. The only thing they have in common is the widget type.

 Steps I have tried
On Drupal Theming suggestions it says you must use the following format: field--[type|name[--content-type]|content-type].tpl.php, so:

field--field-name--content-type.tpl.php
field--content-type.tpl.php
field--field-name.tpl.php
field--field-type.tpl.php

I tried the following but, none have worked:

field--long-text--journal-page.tpl.php
field--long_text--journal_page.tpl.php


texts: Count results in Views using aggregation

texts: Is it possible to count results (e.g. count the nodes of the content type x) in a view, using aggregation (not programmatically)?


texts:
I'm linking an android app with a drupal 6 server. Basically the app should be able to request information from the server to sync data and other simple functions. JSON is our preferred way of achieving this.

I've installed Service, JSON Server in drupal 6 and activated both node and view services. With views.get i'm able to get a JSON output of the default display from the view listed.

Question(s)

First thing I'd like to achieve is to have the JSON output in a separate file. Completely. Currently the JSON is being shown below the views.get page. I've googled solutions for this but only found for drupal 7.
I'd like the JSON to receive arguments from the android app using POST.

How can I achieve the two above.

Thank you very much.


texts: How to add file extensions to list of acceptable in IMCE

texts:
I am using Ckeditor editor/IMCE file upload.
How do I get to the config settings where I can add more extensions which are accepted?


texts: What is the difference between {{ |t}} and {% trans %}?

texts:
I notice that Drupal 8 support {% trans %} which, according to the Symfony documentation (The i18n Extension), adds gettext support to Twig.

{{ |t }}, as far as I know, is the legacy way to add translatable strings into Drupal templates. According to the documentation, t() translates a string to the current language or a given language.

Both support multi-language website.

What are the differences between those extensions?
When should I use one over the other one?


texts: I'd like to add a second "Save" button that saves the node as usual, but I can use a module to alter the node

texts:
EDIT: Answered below.

Bit of a weird one. I'd like a second Save button that saves a node but that I could target with some php.

Save Save Progress Cancel

My use-case isn't as simple as using Autosave and I don't want to start installing WorkBench or any other module for a small feature.

I could have a taxonomy field above the save where users can choose, but really, I'd prefer a second Save button for UI reasons. I could also use jQuery and have psuedo-buttons that click the appropriate term and then the save button, but I'd rather do it programmatically.

Thanks.


texts: How to handle password field for externally authenticated users (Oauth2)?

texts: I'm working on an Oauth2 authentication implementation where I need to provide content access to external users authenticated against an Oauth2 server which provides me with user info. From my understanding of Drupal's user system, this requires me to create a local user populated with the information provided via the API. I've been looking at the user_external_login_register function and it looks like one of the expected user fields is a password. In my case, since the users are authenticating against an external server, the only validation info I have for them is the auth token, and it would actually defeat the purpose for me to have their password. So, should I provide a dummy password?


texts: How can users share entities if they have a relation?

texts:
Im setting up a pretty complicated website, where users are going to have access to a certain nodes depending on which entities the user of the relation has.

with profile 2, i did add an entity reference field, which displays the nodes im going to grant / restrict permissions on the profile registration.

Its going to be something like this:

Me (admin) is going to create a SUB ADMIN user, i set which nodes is he / she going to be able to access.

The SUB ADMIN user, creates users with the role of normal users. The user itself is going to have less privileges than the SUB ADMIN user, and is going to have the same restrictions on the nodes than the SUB ADMIN user.

... i know its a bit complicated, but i would love to know if there's any way to share the entities of the SUB ADMIN user to the user he creates?.

Using this modules right now:
ENTITIES REFERENCE
PROFILE 2
RELATION
SUB USER

Hope you guys could help me... Thanks in advance!.


texts: How to use Tamil language in my website?

texts:
I have installed the language selection page module. I have Tamil, English language to be chosen by users.

If user chooses English means site will appear in English Language. If user chooses Tamil language means site will appear in Tamil language.

So, how can I install Tamil language in Drupal 7.34?


texts: How to prevent users with negative balance of user points from viewing nodes?

texts:
I have a rule that deducts 1 point from users viewing a node, however the problem is that users with a negative balance can still view a node. So I would want to prevent this.

I'm using Drupal 7 with modules Rules and User Points.

Any suggestions?


texts: Getting information from database and giving it to javascript

texts:
The main thing I want to achieve is that my module makes a google map with markers.

For now im doing this:

drupal_add_js('https://maps.googleapis.com/maps/api/js?key=AIzaSyDcl28Qcn9GTi02rRtQaLgVS4GWZbGcQ8E', 'external');

$locations = db_query('SELECT * FROM {locations}')->execute();

$script = '
';

$html = '

';

return array('#markup' => $script.$html);

As you can see in the third line of code im trying to get information from the database that I have saved. The problem is I dont know how would i get it properly. And then I want to pass it down in the var locations part in the script..

I have tried finding some tutorials where they explain how would this work but most of them is just how to show some posts or somthing like that and that doesnt help me.

Thanks for help already! :)

// EDIT

This is the script that i have now in js file

(function($) {
     Drupal.behaviors.myModule = {
       attach: function(context, settings) {

          function initialize() {

          var mapOptions = {
             center: { lat: 56.9714744, lng: 24.1291624},
             zoom: 9
          };
          var map = new google.maps.Map(document.getElementById('map-canvas'),
        mapOptions);

    var locations = [
                    ['Mājas',56.956344, 24.197409],
                    ['Domina',56.966058, 24.162004]
                    ];

    for (var i = 0; i < locations.length; i++) {

      var loc = new google.maps.LatLng(locations[i][1], locations[i][2]);

      var marker = new google.maps.Marker({
        position: loc,
        map: map,
        title: locations[i][0]
      });
    };

  }

  //google.maps.event.addDomListener(window, 'load', initialize);

}

}
 )(jQuery);

I have the "google.maps.event.addDomListener(window, 'load', initialize);" commented becouse I think i dont need it..? And becouse there is no function initialize anymore? Or should i add that back?

The problem now is that my script seems to be added.. But it doesnt seem to be run becouse the google map dosnt show up..


texts: custom js in bootstrap sub-theme is loaded, works in console, but doesn't actually work in browser

texts:
I have a bootstrap subtheme with scripts[] = script.js in the .info file.  When I go to the site and view html source of the page I can see that drupal is including the file <script src="http://site/path/to/subtheme/script.js?ox2bif"></script> and if I click on that link and I see the expected contents of the file:

jQuery(document).ready(function(){
  jQuery('p').click(function(){alert("hello");});
});

The js works, the  links to the actual file.  What else is there?

If I paste jQuery('p').click(function(){alert("hello");}); into my browser's js console then, obviously, clicking any paragraph opens an alert popup window.  But what am I missing that it's not working in the Drupal theme?

Additional info:

Drupal 7
Bootstrap base theme 7.x-3.15
Using Bootstrap CDN (not the SASS or LESS starterkits) with version 3.3.7
Using jQuery version 2.1

switching to jQuery 2.2 or 3.1 doesn't not help

Currently doing:

function winprevent_custom_page_build(&$page) {
  $themescript = drupal_get_path('theme', 'winprevent') . '/script.js';
  drupal_add_js($themescript, array('group' => JS_LIBRARY, 'weight' => -10));

...in a custom module to load the script from the theme.  Notice the 'group' => JS_LIBRARY; this was necessary to get the file to load before admin_menu module's js.  Disabling admin_menu stops it from breaking.  The presence of admin_menu.js also breaks the animation of Bootstrap's collapse feature.

So scripts[] = script.js actually does work in the theme but only for anonymous users, it breaks for the authenticated users (who all have access to the admin menu).


texts: Create users to post unplublished nodes so admin could approve

texts: How can I create some users in Drupal 6 to post unpublished nodes so that admin could approve those unpublished node?