texts: Installing and loading google client php api

texts:
I am developing a php module that uses the Google Client class from the google client php api. I have downloaded and unzipped the latest google client php api at sites/all/libraries, and put my module at sites/all/modules. The code loading the library is this:

if (($library = libraries_load("google-api-php-client")) && !empty($library['loaded'])) {
    print "success";
}

$client = new Google_Client();

However, I am getting "Class 'Google_Client' not found" when I try to access it. Also, the print is not showing, as if the library never loads. However when I use libraries_get_path() I do receive the correct path: sites/all/libraries/google-api-php-client

I have tried the checks here but they all fail. I am using the Libraries API 7.x-2.1 and drupal 7.22

My hook_libraries_info() implementation:

function hook_libraries_info() {
    $libraries['google-api-php-client'] = array(
        'name' => 'Google API PHP Client',
        'vendor url' => 'https://code.google.com/p/google-api-php-client/',
        'download url' => 'https://code.google.com/p/google-api-php-client/downloads/list',
        'version arguments' => array(
            'file' => 'README',
            'pattern' => '/Version (\d+)/',
            'lines' => 5,
        ),
        'files' => array(
            'php' => array(
                'Google_Client.php',
                'config.php',
            ),
        ),
        'integration files' => array(
            'calendarVis' => array(
                'php' => array(
                    'Google_Client.php',
                    'config.php',
                ),
            ),
        ),
    );
    return $libraries;
}

Other than that, I have tried creating an .info file, which worked on my initial wampserver setup, but I cannot make it work anywhere else. Here is the .info file:

name = calendarVis
description = Google Calendar Visualization for P-space
core = 7.x

dependencies[] = libraries

Also, after accessing the page that uses the module and returning to administrator menus, I am getting this error message:

"Warning: Invalid argument supplied for foreach() in libraries_invoke() (line 161 of drupal-7.22/sites/all/modules/libraries/libraries.module).
Notice: Undefined index: installed in libraries_load() (line 621 of drupal-7.22/sites/all/modules/libraries/libraries.module)."


texts: How to change the order of fields in field account in the user profile form?

texts:
In the user detail screen (user_profile_form) there is a field: account.

In this field there a different form fields. How to change the order of these form fields? I would like to group the fields current password, new password and confirmation password together.

I did by form_alter ...

if($form_id == "user_profile_form") {
   dpm($form)
}

But then? I do not see any key or weight in this array..


texts: Which version of Drush should I install?

texts:
Drush 6 works great of corse on a Drupal 6 website, but will I have all of the Drush 6 features when working on a Drupal 7 website? Should I use Drush 7 when working on a drupal 7 website?

I found this post that says you can switch between the two version easily, is this correct?

switch to drush6 command:
composer global require drush/drush:6.*

switch to drush7 command:
composer global require drush/drush:dev-master


texts: How do I create a view with some customization?

texts:
I like to create a view to display properties information as shown below.

View

View page

7676 - SQFT

7    - BR

I created a view and added the fields based on my design. I made progress, but I am not able to create the second column of data (SQFT, BR).

How do I add the second column in this view?


texts: Anonymous users unable to download purchase

texts:
I've set up a Drupal Commerce store (on localhost) for a book shop. One of the requirements is that people can buy ebooks without creating an account.

It all works fine if I buy a book as the administrator; at the end of the checkout process I can download the book. However, when I buy a book as an anonymous user I'm shown the 'Download now' link in plain text.

I'm using a content type named 'Books' with a field named 'Ebooks'. The latter uses the 'File' field type. The rest of my set-up is as follows:

Commerce File 7.x-2.0-beta2:

Product types: Books
Download limits: 5

Commerce License 7.x-1.2

Product types: Books
Line item types: Product

Permissions for anonymous users:

Checkout, Access checkout
Commerce licenses, View own licenses
Order, View own orders of any type

Rules:

Create a new account for an anonymous order: inactive
Assign an anonymous order to a pre-existing user: inactive
Activates licenses of an order: Completing the checkout process >
Activates all licenses of the provided order
Update the order status on checkout completion: Completing the
checkout process > Update the order state (to 'Pending')

At first I though the issue was that the order status is changed to 'Pending' once the checkout process has completed. However, changing this made no difference.

I then found that giving anonymous users permission to 'bypass license control' does instantly resolve the issue. However, that permission setting comes with a "give to trusted roles only; this permission has security implications".

So... something is not quite right in my set-up. It seems that anonymous users aren't given a license allowing them to download their purchase. I've run out of ideas though. What have I done wrong?


texts:
I haven't got around to sending user emails yet.

I wonder if we are able to send HTML emails by default from the Emails section (admin/config/people/accounts), or if we need to use modules for this.


texts:
I have a content type of blog that I created a view for and added a display of that view. I created a view block and have it displaying on the front page in the main content block. I decided that I would rather display the blog posts as a teaser instead of the full text but I can't seem to get it to work.

I set up the content type as a teaser under manage display. Should I be able to select the blog teaser as a content type separate from the default blog display under filter criteria in views? Essentially how do I go about setting the content type blog, within my views block to display teasers instead of the full content?


texts: Add items to batch queue operations on the fly

texts:
I have some code which generates a batch with a single operation; to go off to an API and get some data. This data could be any number of items.

I would like to be able to populate the rest of the batch's operations during the first operation.

I have tried this, but it doesn't seem to work...

Batch initialisation (drush command callback):

function example_drush_sync_entries() {
  $batch = array(
    'operations' => array(
      array('_example_fetch_data', array())
    ),
    'finished' => '_example_batch_finished',
    'title' => t('Processing'),
    'progress_message' => '',
    'error_message' => t('The update has encountered an error.'),
  );

  batch_set($batch);
  $batch = &batch_get();
  $batch['progressive'] = FALSE;

  drush_backend_batch_process();
}

function _example_fetch_data(&$context) {
  $response = drupal_http_request('http://blah.com/data');
  $data = $response->data;
  $data = drupal_json_decode($data);

  $batch = &batch_get();
  $batch_set = &$batch['sets'][$batch['current_set']];
  foreach ($data as $entry) {
    $batch_set['operations'][] = array('_example_process_entry', array($entry));
  }
  print_r($batch);

  _batch_populate_queue($batch, $batch['current_set']);
}

function _example_process_entry($entry, &$context) {
  print_r(func_get_args());
}

I can see $batch has a load of new operations in it, however _example_process_entry never seems to fire.

Is it possible to dynamically add items to the batch queue while its processing?


texts:
I've been stuck on this problem for a while now. I am trying to get the results to display from the api if there are no entries in the db that match the id thats being called from the api and then store those results into the db if there is a Id that matches then pull the results from the db and display them instead of displaying the results from the db.

I keep running into this error which is causing the page to go blank when being displayed PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column '29f1fc0bbd3dfe65a9e0ba6e044fb8e3398967a3' in 'where clause': SELECT * FROM {places} Where {ID} = 29f1fc0bbd3dfe65a9e0ba6e044fb8e3398967a3; I guess its because it cant find the id in the db, but it should still show the results from the api.

My logic makes sense im not sure what I am missing, Any suggestions?

       $listings_key = 'xxxxxxx';
            $xml = file_get_contents('https://maps.googleapis.com/maps/api/place/textsearch/xml?query=loans+near+'.$city_name.'&sensor=true&type=bank&key='.$listings_key.'');
            $listings_request = simplexml_load_string($xml);

            $loans_places = '';
            $loans_places .= '
';

            foreach($listings_request->result as $pre_list){
                $xml2 = file_get_contents('https://maps.googleapis.com/maps/api/place/details/xml?reference='.$pre_list->reference[0].'&sensor=true&key='.$listings_key.'');
                $xml2 = simplexml_load_string($xml2);
                $l_ID = reset($xml2->result->id[0]);

                $dbresult = db_query("SELECT * FROM {places} Where {ID} = ".$l_ID."");

                foreach($dbresult as $db_inlist){

                    dpr($db_inlist);

                    $places = array(
                        'Name'      => $xml2->result->name[0],
                        'Address'   => $xml2->result->adr_address[0],
                        'Phone'     => $xml2->result->formatted_phone_number[0],
                        'Website'   => $xml2->result->website[0],
                        'Ref_ID'    => $xml2->result->reference[0],
                        'ID'        => $xml2->result->id[0],
                        'City'      => ucwords(arg(2)),
                        'State'     => arg(1)
                    );

                    if($l_ID != $db_inlist->ID){
                        $loans_places .= '
';
                        $loans_places .= ''.$xml2->result->name[0].'
';
                        $loans_places .= $xml2->result->adr_address[0].'
';
                        $loans_places .= (isset($xml2->result->formatted_phone_number[0]) ? $xml2->result->formatted_phone_number[0].'
' : '');
                        $loans_places .= (isset($xml2->result->website[0]) ? l('website', $xml2->result->website[0]).'
' : '');
                        $loans_places .= '
';

                        //execute store into db function
                        $nid = db_insert('places')->fields($places)->execute();

                    }else{
                        $loans_places .= '
';
                        $loans_places .= ''.$db_inlist->Name.'
';
                        $loans_places .= $db_inlist->Address.'
';
                        $loans_places .= (isset($db_inlist->Phone) ? $db_inlist->Phone.'
' : '');
                        $loans_places .= (isset($db_inlist->Website) ? l('website', $db_inlist->Website).'
' : '');
                        $loans_places .= '
';
                }
            }
        }

    $loans_places .= '
';

return $loans_places;


texts: How to embed username and password in a URL?

texts:
We have a form that users need to fill out, but it is accessible only to authenticated users. We want to send a mass email to all users with an username and a password embedded in an URL, so that users can just click on that URL and log in to Drupal. The username and password will be common for all users.

Is it possible to log in to Drupal through this way?


texts:
I'm theming a Drupal 8 Views page. I created the twig template file and can output the 2 exposed filters with the code below. The problem is that nothing happens when I click Apply on the exposed filters. It's probably missing some attribute, but I can't figure out how to do it.
Has anyone done this?

{% if exposed %}
  <div class="view-filters form-group">
    {{ exposed.field_category_target_id }}
    {{ exposed.field_address_locality }}
    {{ exposed.actions }}
  </div>
{% endif %}

Here are the printout of the exposed variable


texts: How to get the number of pages in a view template?

texts:
I'm trying to get the number of total "pager" pages with a view by using the views-mini-pager.html.twig. Here is my code so far...

{% if items.previous or items.next %}

            {% if items.previous %}
                {% if items.current %}
                    {% trans %}
                    Page {{ items.current }}
                    {% endtrans %}
                {% endif %}
                    ←{{ items.previous.text|default('‹‹'|t) }}
            {% endif %}
            {% if items.next %}
                {% if items.current %}
                    {% if items.previous %}
                    {% else %}
                        {% trans %}
                        Page {{ items.current }}
                        {% endtrans %}
                    {% endif %}
                {% endif %}
                {{ items.next.text|default('››'|t) }}→
            {% endif %}

{% endif %}

I want to have something like this

And currently, I can only get the current number page which ends up like this ...

I have searched for the variables inside of views-mini-pager.html.twig and I have not found the number of pages.

My question is...

How can I get the number of pages total? So I can display it at views-mini-pager.html.twig

For instance, if I view is divided into three pages I want to display "Page 1 of 3"


texts:
How can I pass arguments to drupal_get_form() in Drupal 7?

function new_menu_callback() {
  $vars = some_example_function(); // returns: array(1 => 'one', 2 => 'two');
  $output = $vars[2];
  $output .= drupal_render(drupal_get_form('new_form'));
}

function new_form($form, &$form_state) {
  // How can I access $vars[1] from new_menu_callback() here?
}


texts: Get view via php based on page number and 1 argument (uid)

texts:
I have a view that it has an contextual filter based on "uid".
Now I need to get it via PHP and I can use views_embed_view(). But I need to get only page FOO or page BAR and views_embed_view() accepts only "arguments/contextual filter".

Which is the correct way to call views FOO, for display BAR, using argument "uid = X" and get only "page = Z"

Thanks.

M.


texts: How do I set up both a landing page and front page?

texts:
Here's the behavior I'm trying to achieve.

If a user types in our domain name www.mysite.com, I want them to go to one page, describing our site.  It can be called www.mysite.com/landing.

But if they hit the logo or the home button anywhere in the site, I want them to go a different page, the one defined in Configuration->Site Information.  It is called www.mysite.com/phront.

Ideas?


texts: How to populate select field from View result like in

texts:
In a custom content entity, I have defined this field

$fields['from_seliste_id'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Offreur'))
  ->setDescription(t('Le SÉListe qui a rendu le service (qui reçoit les graines)'))
  ->setSetting('target_type', 'person')
  ->setSetting('handler', 'views')
  ->setSetting('handler_settings', [
    'view' => [
      'view_name' => 'sel_selistes',
      'display_name' => 'entity_reference_1',
    ],
  ])
  ->setDisplayOptions('view', array(
    'weight' => $weight,
  ))
  ->setDisplayOptions('form', array(
    'weight' => $weight,
    'type' => 'options_select',
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE)
  ->setRequired(TRUE);

In the corresponding form, the field appears as wanted as a dropdown list populated with the result of the View sel_selistes:

I'd like to create another form with the same functionality.
How should I code the field in the form?

$form['mySelectField'] = array(
  '#type' => 'select',
  '#options' => [], <-- ??????
  '#title' => $this
    ->t('whatever'),
);


texts: I have a listing view with filters and a button to export the results to a CSV file. How can I send the view's arguments to my export callback after a user applies some filters?


texts:
I have views with three fields (Title, Image, Price). I want to send this view as email to registered user. I am using Mime mail to send email.

Email works fine but images are not displaying in email. Thanks.


texts:
is it possible to use multiple templates select for a content type. I am thinking of having a select_list which will be shown while adding the content and you can choose how your page will look like, based on existing template files.

thanks


texts: User points download per node instead of per file

texts: The userpoints download module works great for people to buy credits for file downloads.  I have three CCK fields in a content type, but I would like to remove a single user point no matter how many of them are downloaded from a single node. Any ideas?


texts:
Is there any way I can show/hide entire column in Views Table?

Exclude from Display completely excludes the column which is not possible to show again, so, I am using Views Dynamic Fields Module to exclude the column initially and showing it when the filter is checked. Like in the picture, the initial view when Column is hidden using Views Dynamic Fields module.

When the Nick Name checkbox is checked the column is shown like:

However, I want to hide the Name Column entirely when Nick Name is shown.

I initially tried it with jQuery like:

// Hide the Name Column when Nick Name is shown
$('#edit-dyfield-field-girls-nickname').change(function() { // id of checkbox
                if ($('#edit-dyfield-field-girls-nickname').is(':checked')) {
                    $('.views-field-title').hide(); // Title points to Name field so all the th td have this class in Name
                }
            });

But it hides both Name and Nick Name for a while, and shows both fields again.

Any solution Drupal based or some tricks with jQuery/JavaScript would be fine, thank you.


texts: Addition to an integer field with a form

texts: I have a bundle of image nodes of the same content type that I create in my custom form. Each image node has a field that contains a unique reference number to that node. Currently it is up to the user to add +1 to the previous image node saved and type that in the form for the next reference number. How can I add +1 to the last saved field and use the result to populate the saved field displayed on the saved node? More advanced: If I use an AJAX form that allows users to add more fields to add more pictures on the image creation form, how could I save the images with consecutive IDs?


texts: Update button for each line item in cart (drupal 7 commerce)

texts: The update cart button in drupal commerce updates all quantities at once. Since on my site there will be very lengthy lists of line items in the cart, I would like to have an update cart button for each line item (see screenshot, red column). How can that be done?


texts:
So its Christmas eve and this is really dampening the Christmas spirit.

I need to be able to customise the submissions results page table to show the county taxonomy for the submission user.
I have never really done anything with SQL before but I can get all the information I need by running the below select query in phpMyAdmin:

SELECT `sid`, `nid`, `serial`, `uid`, `is_draft`, `submitted`, `remote_addr`,
field_data_field_counrty.field_counrty_tid as CountryID ,

(select name from taxonomy_term_data where taxonomy_term_data.tid=field_data_field_counrty.field_counrty_tid) as Country

FROM `webform_submissions`

inner join field_data_field_counrty  on webform_submissions.uid =field_data_field_counrty.entity_id

And i know that the below code is where it generates the submissions table in webform.submissions.inc:

// Build the list of submissions and load their basic information.
$pager_query = db_select('webform_submissions', 'ws')
// Ensure only one row per submission is returned. Could be more than one if
// sorting on a column that uses multiple rows for its data.
->distinct()
->addTag('webform_get_submissions_sids')
->fields('ws', array('sid', 'nid', 'serial', 'submitted', 'remote_addr', 'uid', 'Country', 'is_draft'));
foreach ($filters as $column => $value) {
$pager_query->condition($column, $value);
}

// Join to the users table to include user name in results.
$pager_query->leftJoin('users', 'u', 'u.uid = ws.uid');
$pager_query->fields('u', array('name'));
if (isset($filters['u.uid']) && $filters['u.uid'] === 0) {
if (!empty($_SESSION['webform_submission'])) {
  $anonymous_sids = array_keys($_SESSION['webform_submission']);
  $pager_query->condition('sid', $anonymous_sids, 'IN');
}
else {
  $pager_query->condition('sid', 0);
}
}

But i have no idea what to do from there.
If anyone could offer any advice, tips or anything, I would really appreciate the help.

Happy holidays everyone!!


texts: How to change page.html.twig depending on the content type I am viewing in Drupal 8?

texts:
I was wondering how I would change page.html.twig depending on the content type of the node I am viewing?

For example I would like the title to be shown on pages with the article content type but be hidden on the site page content type.


texts: Creating a source for content to be consumed by Feeds?

texts:
I'm creating a site that is to serve as a source for nodes for several 'client' sites. The plan is to have the client sites use Feeds to get the new and updated nodes from the source site. However I'm not sure how to have the source site actually make those nodes available in a format where feeds can get a hold of them.

These nodes have node references, fields, field collections, and also file and image fields, so all that data needs to go over to the client sites.

Is there a "go-to" module for this, or will I have to write my own functionality?


texts: How to map term name via XPath node feed using xpathparser into Term reference field?

texts:
I have an xml feed to import to and mapped to a content type. However, there are fields that are referenced to taxonomy. The fields that are not referenced seems to be working fine and are getting picked up. But those that are referenced to a taxonomy vocabulary are not.

How can I import data from xml from say:

<properties>
  <item>
    <refid>1234</refid>
    <propertytype>Apartment</propertytype>
    <!-- ... -->
  </item>
</properties>

I want to be able to import propertytype to this content type as 'Apartment' as referenced to a taxonomy vocabulary - Property Types:

Property Types (Taxonomy Vocab)
Apartment
Townhouse
Villa
etc...

I've learned that taxonomy referenced fields stores data to a separate table in the database. Does this mean I have to manually do insert query to these tables separately? Or is has anyone encountered the same predicament?


texts: CKeditor has empty node body for some nodes

texts:
On Drupal 7.52 and ckeditor module 1.17 (library version 4.6.1) and this is driving me insane. Here's a list of things I've noticed and tried:

Seems to primarily happen with unpublished nodes but not all unpublished nodes seem to have it. I have been testing using account 1 which has all privileges so I doubt it's permission related.
If I refresh the page, I can see the node body show up where ckeditor would be for half a second. When ckeditor loads it's gone though.
Checking the page source I can in fact find the textarea with the entire node body, so it is being sent to the browser.
No errors at all on the browser's console.
Can get in both Chrome and Firefox.
Disabling ckeditor makes the node body viewable again, re-enabling brings me back to the same problems.
Typing something on the empty ckeditor field, going to plain text mode and I can see the HTML, then going back to rich text mode and it's all gone again! This behavior happens when creating new nodes as well, but not with already published nodes that show the node body from the beginning. This also produces no console errors!
Updated ckeditor from 4.5.9 to 4.6.1.

Anyone have any ideas as to things I can test to pinpoint this problem?


texts:
Hello Drupal Stack Exchange crowd.  I am working on building a view for a content type that has several fields and an image. I am using an "Unformulated list"

Using Drupal 7 core and the most recent update of views.

My goal is to align the field image to the right so the text is right next to it.

I have put the text field and image "Inline" in field settings and "remove HTML" formatting and changed the text to "Plain Text". This places the text starting at the bottom right corner of the image but I'm wanting the text to align starting at the top right. I have tried rewriting the field to do this but have had no luck.

It seems like something like this would be very simple without .css (since I'm not the best at it).

My Questions are:

If I use .css, what style sheet should I insert the code into (Views, Theme, ??)?
Is there a way to get around using a .css to accomplish what I want to do?

Thank you in advance for your time.
WO

Addition info 10/22/15 - in response to argiepiano: I already use and love display suite and have never noticed the "Display Suite" option in Views. THANK YOU. I have gone through the first 5 videos but:  I still have trouble getting text/images to align correctly in Display Suite (css), do you mayhap know of any good videos or articles on that?

Thanks Again,
WO


texts:
I tried the module LoginToboggan to log in entering the email and not the username (that I use as Facebook ID). The problem is that the module allows to log in with either the email or the username.

How can I log in with just the email?


texts: ckeditor or drupal keeps adding closing source tag /> at the end of  tag. Using Video Plugin for ckeditor

texts:
I am using the ckeditor for drupal and the video plugin for it to embed video's to site. I have tried to edit the Video plugin javascript file like below so it will spit out something like this <source scr="" type=""> but have had no luck.

innerHtml = '<cke:source src="'+video.src+'" type="'+video.type+'">';

However once I go to click okay ckeditor or drupal adds a closing slash at the end of the source tag to make it look like this:

<source scr="" type="" />

I have turned off "Correct faulty and chopped off HTML" and it still adds it at the end.

Even when viewing source view of the content editor there is /> present.

Is it ckeditor or drupal adding this at the end of source tags and how can I remove it?

Using CKEditor 7.x-1.16
Video Plugin for ckeditor


texts: How to validate file using hook_file_validate?

texts:
I want to validate my file, I'm using

  hook_file_validate

function test_file_validate($file) {
  $errors = array();

  if (empty($file->filename)) {
    $errors[] = t("The file's name is empty. Please give a name to the file.");
  }
  if (retstrlen($file->filename) > 255) {
    $errors[] = t("The file's name exceeds the 255 characters limit. Please rename the file and try again.");
  }
  return $errors;
}

But, when I am going to print_r($file) I am not getting any values, please let know how to use this function


texts:
I would like to create modals for special offers and promotions. I know how to open them either using drupal.dialog or OpenModalDialogCommand. This works fine.

But what is the best place to put the content for the modal? I started adding it in the JS with .appendTo('body'). This works, but the modal content is complex and contains a lot of elements. I would like to know wheter there is a better place to put this modal content?


texts:
I have a block view that only displays the taxonomy terms in a vocabulary. However I would like to have a link generated in that block with an "ALL" option. So I created a new taxonomy entry, which is the parent of all other terms.

However if I go to the taxonomy parent, the children aren't shown, only if the nodes are set to the parent value explicitly.

For example:

All (tid=1)
-Shirts (tid=2)
--Small (tid=3)
--Big (tid=4)
-Shoes (tid=5)

So if I were to go to http://mysite.com/taxonomy/term/1 I want it to show all nodes in terms 2 and 5 (would be ideally to have 3 and 4 show up also, but not mandatory).

I am using Drupal 7.x


texts: How to Extract Label of a Field, which is inside FieldCollection?

texts:
I have a field collection with the name 'field_stk_fld1'.

Inside this field collection('field_stk_fld1') there is a field with name 'field_fld_stk_ques1'.

I wanted to extract label of the field ('field_fld_stk_ques1'), Any idea on how to get it?

Note: This field ('field_fld_stk_ques1') is used in multiple places and in each place it has its own label associated.


texts: Trying to update taxonomy menu item with hook_taxonomy_menu_update

texts:
I'm having issues getting this to function to work, if I understand correctly this hook fires after saving or creating a taxonomy term.

I am also unable to use dpm($item) as nothing is rendered

function form_alter_taxonomy_menu_update(&$item) {
    $item['options']['attributes']['class'] = 'myClass';
    return $item;
}

Can anyone spot what I have done wrong


texts:
I am new in Drupal 7. What i am trying to do is to show pop up information windows for the following case:

I have a view with links (internal links to drupal site). I want by clicking on them:

1.To show an information pop-up window with the message "Redirection to the official position..."

This message to be showing for 3 seconds and
The message to disappear after 3 seconds and the redirection to be completed.

How can i show specific pop-up windows by clicking a link and before the redirection takes place?


texts: Module not returning echoing or printing variable

texts:
I'm writing a module to change a user's shopping cart order ID based on a stored value from their profile, which cannot be edited from the users.

In the hook call to commerce_cart_order_id I tried the following code, but it doesn't change the order ID. Printing $orderidentifier with krumo() shows 1; if I change return $orderidentifier; with return 1;  my cart changes just as I'd expect it to.

global $user;
$user_full = user_load($user->uid);
$orderidentifier = $user_full->field_currentcartorder['und'][0]['value'];
return $orderidentifier;

Can anyone tell me what I'm missing?


texts: restrict to subdirectory not work and media module load all images in public://

texts:
I use a media module to select file from library, in field option on my field I specify a custom sub directory(it's name is gift_cards) that  I have been created in public path.    but when the media file selector popup triggered I see all images instead images that on gift_cards.
where is the problem, and how can I restrict my custom field to load only image that are in gift_cards directory?

one suggest is using filedeop module , but I don`t want use this module (this is big module with more feature but my needs is something tiny) , restrict to show only custom sub directory in public://


texts: What am I doing wrong when trying to set the default value for this radio button form element?

texts:
$options = array(
    'yes' => t('Yes'),
    'no' => t('No'),
    'maybe' => t('Maybe'),
  );

  $form['infx2670selig_kangaroo_eating'] = array(
    '#type' => 'radios',
    '#title' => 'Would you eat a kangaroo?',
    '#default_value' => t('No'),
    '#options' => $options,
    '#required' => TRUE,
  );

I don't see what's going wrong. By default, none are selected.


texts:
I need to create custom views field in my module. Basically it should behave like Node edit/delete field. I started with extending views_handler_field class and I can see and add my new field in views admin.

But when I add my new field to view - it don't display any values (empty). I mean - not just my custom field empty, but the whole view. When I remove my custom field - everything is working fine,
My Code:

class views_handler_field_gift_delete extends views_handler_field {

    function render($values) {
        return 'test';
    }
}

What I'm doing wrong?


texts: How to avoid certain variables from being cached?

texts:
I've spent days trying to figure this out and really hope you guys can help me out here.

Let's say, I’ve created a list field on the user entity called field_render_array with the options:

Render array 1
Render array 2

There is a controller called RenderArray which should:

Return render array 0 if field_render_array is not set.
Return render array 1 if field_render_array is equal to render_array_1.
Return render array 2 if field_render_array is equal to
render_array_2.

I’ve been trying to achieve this using a controller like:

<?php

namespace Drupal\example\Controller;

use Drupal\Core\Controller\ControllerBase;

class RenderArrayController extends ControllerBase {

  public function content() {
    $user = \Drupal::currentUser();
    $field_render_array = $user->get(‘field_render_array’)->value;

    if (!isset($field_render_array)) {
      return array(
        ‘#markup' => ‘You haven’t set your preferred render array.',
      );
    }
    else if ($field_render_array == ‘render_array_1’ ) {
      return array(
        ‘#markup' => ‘Your preferred render array is 1',
      );
    }
    else {
      return array(
        ‘#markup' => ‘Your preferred render array is 2’,
      );
    }
  }

}

The problem is that the value of $field_render_array is getting cached. This comes across as a bug for end-users as the render array doesn’t immediately change after changing the value of field_render_array.

Is it possible to somehow avoid certain variables from being cached or is there another solution to achieve the same thing?


texts:
I have a multilingual Drupal 7 site for which I have set up a translated 404-page accessed at mydomain.com/404 and mydomain.com/en/404. In the Drupal settings for 404-page I enter just the path 404.

However, when visiting a non existant URL on the English version, the default language is still being used.

What did I miss?


texts: I have a multi-value field. How can I get the value with highest delta value in Rules? The only idea I have is to create a custom component a loop through all list values in it. Then I could use a auxiliary variable and compare each item with it (so that variable will correspond to highest value). This seems to be rather slow. Is there any better solution?


texts: How do we fetch the list of all content types refererencing a particular taxonomy vocabulary?

texts:
I am trying to delete a taxonomy vocabulary but before doing that, I want to know if there is any content type with a field referencing a taxonomy vocabulary.

My first thought was using a view, but that would only list content. Unless it can display the type and group by the type, it would not be the best solution.


texts: I tried to install memcache module and mongodb in Drupal 6. When I enable memcache, the mongodb will not work.


texts:
I'm search for a few days now. But I cannot find a good auction module for Drupal 7. I have try the module: uc_auction but the highest bid did not save in my shopping card only my sell price. I have no idea of there is an other option for een auction system but I cannot find him.

Who have a suggestion for me? I'm using the module Ubercart for my website now.


texts: Is it possible to get render a field for a paragraphs field in the parent twig template

texts:
My use case requires that I get a fields values in the parent paragraph template file.

So to be more clear I have a paragraph type (wrapper) which itself has a field referencing to another paragraph type (nested).

I am trying to get the values of a field (like title) from the child paragraph (nested one) in the parent twig template.

Hope for some help with this.


texts: How to make product attributes appear as checkbox on the add-to-cart form?

texts:
In Drupal Commerce how to make product attributes appear as checkboxes on the add-to-cart form? I want to see the sum of the prices of all checked products and add them all to the cart, when the add-to-cart submit button is pressed.

I wonder if there is tutorial, or - even better a module - for that?


texts: Set the menu link as disabled by default

texts:
When I create a new node its menu link is enabled by default. I would like to enable it manually only in case if I need.
Is there a way to set the checkbox in menu tree as uncheked by default?


texts: Drupal 2 blocks same form function with different output not working

texts:
I have dynamically created some blocks depending on how many entries I have in the database:

    function my_module_block_info() {
        $result_set = db_select('my_products', 'products')
            ->fields('products', array('pid', 'name'))
            ->execute();

        $blocks = array();

        foreach($result_set as $product) {
            $blocks['my_product_' . $product->pid] = array(
              'info' => ('My Product ' . $product->name)
            );
        }

        return $blocks;
    }

    function my_module_block_view($delta = '') {
        $pieces = explode('_', $delta);
        $pid = $pieces[2];
        $product = db_select('my_products', 'products')
            ->fields('products')
            ->condition('products.pid', $pid, '=')
            ->execute()
            ->fetchObject();

        $block['subject'] = $product->name;
        $block['content'] = my_module_block_content($product);
        return $block;
    }

function my_module_block_content(&$product) {
    $form = drupal_get_form('my_module_block_form', $product);

    $output = '<p>' . $product->price . '</p>';

    $output .= drupal_render($form);

    return $output;
}

function my_module_block_form($form, &$formstate, $product) {
    $form['submit_product] = array(
      '#type' => 'image_button',
      '#button_type' => 'submit',
      '#src' => base_path() . path_to_theme() . '/images/buy.gif',
    );
    $form['product_name'] = array(
      '#type' => 'hidden',
      '#value' => $product->name,
);
    return $form;
}

My problem is that when I have 2 blocks with different products on one page, the submit function for the second block displayed has the value of $form['product_name']['#value'] equal to the first block, which is an entirely different product. What am I doing wrong?


texts: Can I simulate a hook using Devel's PHP execution?

texts:
Let's say, for instance, that I want to quickly view the variables sent to HOOK_preprocess_node(), but I'm too lazy (if I'm just being honest) to edit my template.php file just to do that one check.

Can devel's Execute PHP block allow me to do something like this?

function SOMETHING_preprocess_node(&$vars) {
  dpm($vars);
}

Or is it impossible to use hooks in this context?

To clarify, my somewhat lofty goal is to be able to experiment with virtually any hook function quickly using Devel's PHP execution, and if there's a syntax for doing that. I realize there are some problems with that concept from the get-go, not the least of which is that you need to artificially create a context in which certain hooks will even be called, but I want to see what's available.

EDIT: Tenken's answer got me thinking. I could create a global array called, say, $devel_hooks. In a module, I could populate this variable with the contents of various hooks like so:

$devel_hooks = array();

function devhooks_preprocess_page(&vars) {
  global $devel_hooks;
  $devel_hooks['preprocess_page'] = $vars;
}

The contents of $devel_hooks could then conceivably be accessed at will, BUT there's a problem: Devel's Execute PHP block evaluates its content immediately on form submit and before the page loads again, so I couldn't put, say, dpm($devel_hooks['preprocess_page']); in there and get anything out of it because the page and its hooks haven't been processed yet, so $devel_hooks is completely empty or may even be undefined when that PHP is evaluated.

So maybe I could populate another global array with the information I want to request from $devel_hooks, and have the latest possible page hook (which might be HOOK_page_alter()?) parse that array and run a dpm() on the requested components of $devel_hooks. You would then, obviously, need to execute the PHP on a page that would use the desired hooks, but that's on you. I just haven't quite figured out how to connect those dots.

I could, conceivably, populate the array with strings and map those to array keys, but what if I want to dpm() something deeply nested in one of the hook arrays, like $devel_hooks['preprocess_node]['elements']['body']['#markup'] (just as an example, may not be accurate to what that array would look like)?


texts: How to make a form with latest nodes listing with checkboxes same as in 'admin/content' page?

texts:
I want to create a custom module for newsletter composer in drupal 7.
To create a newsletter I need to show latest 100 nodes in a form with a checkbox and a dropdown (Select box) to select the section user wants to show the node.

In admin/content page same node listing appears. I need a select box within that check box, So need two elements in a row.

Please suggest me how to achieve the node listing table in a form with two fields and a node title in a row.


texts: How to call the implemented hook_profile2_access() function?

texts:
I'm rather inexperienced in module development, sometimes I have really basic issues: I'd like to grant custom access to user profiles. I think I can do it with the implementation of hook_profile2_access() (profile2 and profile2_og_access submodule use such implementations)

I added the mymodule_profile2_access() to my module but I don't know how/when it would be called?


texts: How do I include a Javascript Library from a Twig Extension in Drupal 8?

texts:
I have a custom Twig Extension that needs to add a Javascript library ONLY when the Twig Extension is used.

Here is my modules/custom/MY_MODULE/MY_MODULE.libraries.yml:

my-twig-extension:
  version: VERSION
  js:
    js/myTwigExtension.js: {}
  dependencies:
    - core/jquery

Here is my modules/custom/MY_MODULE/js/myTwigExtension.js (just for testing):

console.log("Hello World!!! at " + Date.now());

In my modules/custom/MY_MODULE/src/TwigExtension.php I define the extension here:

public function getFunctions() {
    return [
        new \Twig_SimpleFunction('MY_MODULE_widget', [$this, 'MY_MODULEWidget']),
    ];
}

and then it's function:

public function MY_MODULEWidget($MY_VARIABLE)
{
    return array(
            '#theme' => 'twig_extension_MY_MODULE_widget',
            '#MY_VARIABLE' => $MY_VARIABLE,
            );
}

The #theme above is correctly loading my file here modules/custom/MY_MODULE/templates/twig_extension_MY_MODULE_widget.html.twig:

Loading Widget...

Attempt 0:

Added the following twig function to modules/custom/MY_MODULE/templates/twig_extension_MY_MODULE_widget.html.twig:

{{ attach_library('MY_MODULE/my-twig-extension') }}

but that did not work.

Attempt 1:

Tried adding the library in the render array:

public function MY_MODULEWidget($MY_VARIABLE)
{
    return array(
            '#theme' => 'twig_extension_MY_MODULE_widget',
            '#MY_VARIABLE' => $MY_VARIABLE,
            '#attached' => array(
                'library' => array(
                    'MY_MODULE/my-twig-extension',
                    ),
                ),
            );
}

but it doesn't look like BlockBase logic is supported here to load the library.

Attempt 2:

I looked at how the Twig function attach_library works and saw how in Drupal\Core\Template\TwigExtension::attachLibrary($library) worked and tried to implement it here like this:

public function MY_MODULEWidget($job_name)
{
    static $doOnce = true;
    if ($doOnce) {
        $doOnce = false;

        /* @var $renderer Drupal\Core\Render\Renderer */
        $renderer = \Drupal::service('renderer');
        $template_attached = ['#attached' => ['library' => ['MY_MODULE/my-twig-extension']]];
        $renderer->render($template_attached);
    }

    return array(
            '#theme' => 'twig_extension_adicio_rated_job_widget',
            '#job_name' => $job_name,
            );
}

... with the idea of including the library the first time the Twig Extension was called.  But no go.

IMPORTANT: yeah I know I can add the following to my module/custom/MY_MODULE/MY_MODULE.info.yml:

libraries:
  - MY_MODULE/my-twig-extension

but I do not want to load this library (very expensive logic), to every page.

Any assistance would be greatly appreciated.  Thank you.


texts: Drupal 7 - When to use template suggestions?

texts:
I always found it difficult to work with template suggestions in Drupal.
I'm trying to override those files (html.tpl.php, page.tpl.php, region.tpl.php) for a given url (mysite.com/user-export). So I found this function:

function MYTHEMENAME_process_page(&$variables) {
if (module_exists('path')) {
    $alias = drupal_get_path_alias(str_replace('/edit', '', $_GET['q']));
    if ($alias != $_GET['q']) {
        $template_filename = 'page';
        foreach (explode('/', $alias) as $path_part) {
            $template_filename = $template_filename . '__' . $path_part;
        }
        $vars['theme_hook_suggestions'][] = $template_filename;
    }
}
}

That seemed to work pretty well, I created a file named page--user-export.tpl.php to override the page.tpl.php file and it worked.
However, at some point I removed that function, and the template overriding was still working!
So I guess in some cases we need to create a function in template.php, and in some other cases, the overriding is done automatically without having to create a function.

So my question is: When to use template suggestions ?

Thanks in advance!


texts: Position Block Below Content but Above Editor

texts:
I have created a block for a horizontal ad. I positioned it in the Content region and as you know I can display it either above the content or below everything. However, I would like it positioned above the editor (or comments area), not above it all.

I have found this pots but I am using an Omega-based theme and I see under the all/themes/omega/templates folder that there are "region.tpl" files so I assume here is where I add it, not in a node.tpl.php file.


texts:
I have the following query, which works.

  $email = db_query('
    Select u.init as email
    FROM user__roles as r
    JOIN users_field_data as u ON r.entity_id = u.uid
    WHERE u.status = 1
      AND r.roles_target_id = :role
  ', array('role' => 'pubblisher'))->fetchAll();

I want to convert it to use EntityFieldQuery, but I didn't find any Join function in the documentation. How do I convert my code to use EntityFieldQuery?


texts: Remove authentication in custom REST API resource

texts:
I have a custom module to create a custom Rest API resource. I want to remove the authentication and make it without required authentication.
In my file custom_moudle/config/install/rest.resource.custom_resource.yml

this is my code

id: custom_resource
plugin_id: custom_resource
granularity: method
configuration:
  GET:
    supported_formats:
      - json
    supported_auth:
      - basic_auth

This is working fine but with authentication. When trying to remove this lines

supported_auth:
  - basic_auth

I got an error. So what is the correct way to remove this authentication?


texts: What stops the import of the rule contained in my custom module?

texts:
I have exported rules from the existing rules and I wanted to import rule using custom module. But when I enable this module. Rules weren't imported in rules list.

I created 3 files:

1) my_module.INFO file:

name = My module example
description = My module for import rules
core = 7.x
package = My module

2) my_module.MODULE file (blank file):

<?php

3) my_module.rules_defaults.INC file:

<?php
     function rules_example_default_rules_configuration() {
      $configs = array();
      $rule = '{ "rules_final_save_pdfs" : {
        "LABEL" : "final save pdfs",
        "PLUGIN" : "reaction rule",
        "ACTIVE" : false,
        "OWNER" : "rules",
        "REQUIRES" : [ "rules", "views_pdf", "entityform" ],
        "ON" : { "entityform_insert" : [] },
        "IF" : [
          { "entity_has_field" : { "entity" : [ "entityform" ], "field" : "field_test_pdf_form" } }
        ],
        "DO" : [
          { "views_pdf_rules_action_save" : {
              "views_pdf" : "test_new_view:pdf_1",
              "path" : "\/workout\/sites\/default\/files\/test_pdfs\/[entityform:field-date]"
            }
          }
        ]
      }
    }';
      $configs['rules_final_save_pdfs'] = rules_import($rule);
      return $configs;
    }
?>

Please let me know if there any changes to do.


texts: I scheduled a big queue with VBO, but I changed my mind. How can I delete it? I don't seem to find any UI/interface to manage queues. Do I have to delete it in the database?


texts:
I am using FileDepot module, and I wanted some help in this. I wanted the authenticated users to create their own folder, and upload their files. They can upload files, but they cannot create their own folder. How do them give them the permission to create their folder?

I found a feature like LOCK. What is this lock feature basically used for?


texts: Taxonomy term deleted but still visible (again)

texts:
I have seen this question, but it seems that the behaviour in my case is even worse.

I have a text field with custom autocomplete which connects to an external service to get terms, and then it creates them if they do not exist in Drupal. Since I am in a early development phase, I am constantly creating and deleting terms. I re-enabled the standard autocomplete widget for a test, and I found that it shows all the terms I had created and deleted! I checked in taxonomy_term_field_data, and of course they are present there.

The terms were created with the following code:

use Drupal\taxonomy\Entity\Term;

[...]

Term::create(array(
  'vid' => 'my_taxonomy',
  'field_codetype' => $codeType,
  'field_mycode' => $myCode,
  'field_codedate' => $codeDate,
  'field_denominazione' => $denominazione,
  'name' => $denominazione,
))->save() ;

and were deleted from the admin interface. Maybe I am missing some mandatory field?


texts: How do I get the taxonomy term ID from its name?

texts:
The only function on the list of taxonomy.module functions that looks like it does what I want appears to be a private function (_taxonomy_get_tid_from_term).

What function am I supposed to use if all I know is the taxonomy term name and I need to find out its ID?


texts: Add Rating Widget to a custom full content layout in drupal 7

texts:
Can anyone know how to add a rate widget to a custom full content layout in drupal 7.

Let say I have a content type article.A have customized the layout with the help of Ds module for the full content.I have added my the field to my choose.Now I need a rating in the full content page with that the user can vote the article whether they like it or not.For that I added a module called Rate widget.With that I try to add a Thumb up/down to the full content page of the article but it is not showing me.Can any one know how to add rate widget to the custom full content.


texts: Add bulk products drupal commerce: Warning: Invalid argument supplied for foreach() en form_type_checkboxes_value() line 2337 form.inc

texts:
I am workin on a commerce site and every product has many attributes and there are many combinations for each display. I am using Commerce Bulk Product Creation so I can add products quicly. The problem is that when I try to add many products in one shoot using this module I have a white screen and The warnng is:
Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value() (lne 2337 de xxx/includes/form.inc).
Any help would be great.


texts: Why is the expire header set to some time in the past ('Sun, 11 Mar 1984 12:00:00 GMT') in Drupal 6/ PressFlow and Drupal 7?

texts:
I have been trying to understand why the expires header is set to the past. I read the comment  In boostrap.inc drupal 6  but I am still a bit confused about it and the relation between expires and vary headers. I looked into this because I am trying to set the expire header in the hope of controlling varnish object cache expiration regardless of TTL. The code reads:

  // HTTP/1.0 proxies do not support the Vary header, so prevent any caching
  // by sending an Expires date in the past. HTTP/1.1 clients ignores the
  // Expires header if a Cache-Control: max-age= directive is specified (see RFC
  // 2616, section 14.9.3).
  $default_headers['Expires'] = 'Sun, 11 Mar 1984 12:00:00 GMT';

Would it affect me if I set the caching headers like expire? I want to do this only for anonymous users.

I posted a varnish question related to this here:
https://stackoverflow.com/questions/19121220/how-to-control-how-long-varnish-expire-a-page-from-the-backend


texts: Drush and mysql database (with MAMP) connection problem

texts:
I have a problem running some drush methods involving database connection.
I run the free version of MAMP.

If I run methods like si or pml I get no problems

But if I run the drush archive-dump method I get this error message:

Database dump failed.

look the capture:


texts: Drush fails with "PHP Fatal error: Call to undefined function decode_entities()"

texts:
My drush installation does not work anymore on an Debian Vserver. I get always the error:

  PHP Fatal error:  Call to undefined function decode_entities()
      in /usr/share/drush/includes/drush.inc on line 1619

I have drush-6.2.0.0 installed there and can't reproduce what caused the error. Any suggestions?


texts: Downloading from private directory corrupting some file types

texts:
We have set up a private file system on a website based on drupal's guidelines. We are using Drupal 8.

We have setup the private file directory outsite of /var/www at /var/privatefiles. When downloading certain types of files - specifically docx - files are being corrupted. pdfs and other common types seem to be working fine.

File upload is working correctly as I am able to scp the files directly from the server and they are intact.

Additionally, on a test server made from a copy of the server we set up the private files inside the siteroot and that works without problem. This solution is not ideal however as we do not want the files to be accessible directly from the web.

I cannot find anything that discusses this issue, surely I am not the first person to set up a private directory this way and have docx files break?

UPDATE:

Further testing indicates that what is occurring is that drupal or php are adding 3 newline 0a characters to the start of every file served from the private file system. It has np effect on some formats but all MS files - docx,xlsx etc - are broken.

How do I fix this?


texts: Expose a view's filters both in a block, and in the actual view

texts:
I made a View, and I exposed the filters in a block; then, in the block's administrative screen, I set this block not to appear in the view that belong. In the actual view I don't want to show this block. Instead, I want the filters to appear in the content as they normally would if I didn't expose them in a block.

If that makes any difference, I am using Drupal 7.


texts:
Can I please get some input on the differences between the two?

I'm building a website where using 'context' is very important. After watching this video series about Page Manager by NodeOne, I feel that Panels 'context' and its ability to securely pass arguments to Views is very important. However, the Context module has a plugin that does a similar type of function called the View Default Argument From Context module.


texts: Can you set the Media module to only show specific images?

texts:
I'm looking to use the media module on a site. Very impressed so far with it but there is one thing I need of it for it to be perfect.

I need it to only show certain images in the library, not every single image that has been uploaded. Is there any way of doing this that any one knows?

Thanks


texts: Field names returned in search snippet. How to hide?

texts:
Field names are being returned in the search snippets on my search results page, like so:

  Academic Culture

  Body Text: The academic culture of your host country may be quite
  different from what you experience here at ...

The bit that reads "Body Text:" is the field name. What's weird is that the field name is only returned when the snippet is at the beginning of the field. So, depending on the search it could return something like this:

  Academic Culture

  ... academic culture of your host country may be quite
  different from what you experience here at ...

Note the absence of "Body Text:".

Is there a way to disable/hide field names in the search snippets?


texts: Specify destination folders outside of Drupal root using Drush Make

texts:
Is there a way to configure Drush Make so that it would build a structure like:

project_root

drupal_core
drupal_contrib

So that next in the build process (that this would form a part of) could symlink the sites/all directory to drupal_contrib

It would be set up this way as I would prefer the build process to allow an upgrade of Drupal core by simply removing sylinks, upgrading, then re-adding symlinks

I'm aware the build process might as well just loop through some drush dl x statements, or that if Drush Make was used the folders could easily be re-jigged afterwards. Just interested if there is a non-hacky way of doing it first.

Thanks!


texts:
I'd like to build a Drupal 7 module that generates a block which contains (along with some static HTML to be used as template for a JavaScript library) a node-specific value to be passed on to a web service. (The web service will return relevant data for the contents of the node.)

How should a block receive node-specific data? Module configuration seems to be global, and blocks cannot be configured individually.

Should I modify the main content-type of the node by adding this "node-specific data" as an extra field even if this value is only used in my module?


texts:
Running Drupal 7, Views 3 and panels 3

Been searching for an answer for this for a few hours now and I can't seem to find one. I am creating a custom user profile page in panels. I created a view to display certain fields from profile2 if that user is of that role. When I test the view at the bottom of the views page by passing it an id it works fine. here are the settings:

Contextual filters:
Node:Nid

Relationships:
Content:Author
(author) User: Profile

Now in panels when I add this view I have the heading Content: Nid with a drop down list in the options. I select the information I want to display and save. Then when I go to the profile page, nothing shows up. I don't think it is passing the nodeid to the view, but I am not sure what I haven't done.


texts: Organic Groups "create post" content link needed with posting content type specific to group

texts:
Organic groups  7.x-2.6
Entity reference prepopulate    7.x-1.5

Hello, I am trying to create custom "create posting" link for my organic groups. Each Organic Group has its own content posting content types, so when a user visits the panel page for that group the add posting link should be specific to that group.

I have 2 groups: Amigo group, and Authenticated group
I read that target bundles are globally defined for Groups Audience, so I read that you have to add an extra group audience to the Posting content type for your group.  You are then supposed to set the target bundle on the 2nd to match the group content type.
My problem is that when I try to set the "Content Create Links" section in my panel it wants to only set one group audience field, and I have 2 created, one for each group's posting content type.

I recorded images of each part of this problem for ease of understanding.

Here is my Amigo group's posting content type called "Amigo Group Post".
Notice the extra Group's Audience field added to the bottom of the content type. Clicking edit on this allows us to change the settings on this field

Clicking on group audience for Amigo Post takes us to that group audiences configuration page.  Here I am choosing to prepopulate the entity reference.

Here is my panel  for the Organic Groups group. Lets go to the Content Create Links setting page.

Here you can set ONE of the 2 posting content types to be the content type used for new group postings, but I need it to just choose the posting content type by the type of Organic Group. I chose one because I could only choose one.

Looking at the Amigo group page we can see that the create post section is not even showing up.

This is the Authenticated group page.  When viewing this page we do see the create post section, because we had to set one field name for the "content create links" section in the Panel.

Does anyone have any idea how to have the panel choose the content creation link type based on the current group?


texts: How to avoid sending 2 emails at the same time?

texts:
I use Drupal 7 and I'm testing a function to automatically send email from a custom module.

I have 3 fields to check, and I have to send mail to a specific address.

I have write simple test code in a custom module:

function test_mail_node_presave($node) {
 if($node->type == 'rso') {
  if ($node->field_a['und'][0]['tid'] == '10'){
   mail('example1@mail.com', 'example2@mail.com', 'example text');
  }
 }
}

It works, but in any verification "field_a" Drupal sends 2 equals email.

Note: I'd also be interested to know about any other technique that can achieve the same result.


texts: Include full term name including "in" "and" etc when used for URL alias

texts:
Im using taxonomy terms to create my URL aliases. At the moment the word "in" is stripped out.

So if the term was "Fun in London"

The URL created would be "fun-london".

How can I include the full path? So I would have "fun-in-london".


texts: Set new theme setting to default on theme update

texts:
Working

We have a custom base theme.
There are custom theme settings with default values.
When the theme is initially installed, the theme settings are correctly set as default. Good.
This custom base theme is now on our many live sites.

Not working

We added a new custom theme setting to the base theme, and set a default value.
When we update the base theme on a site, the new theme setting is there. Good.
However, the default value is not filled in.

Question
How do I set the default value of a new theme setting when the theme is updated?


texts: Error when activating the View Mode Page module

texts:
I am trying to activate the View Mode Page module because I need to use URLs to jump from one view mode to another. From teaser to presentation to full node.
Every time I try to activate the View Mode Page it gives me an error and after that I am unable to view the Manage Display section for any of my content types. It mentions there is an error in the view_mode_page.module (or something similar).
Does anyone know if this module is incompatible with some other modules or what the problem might be?

Thanks in advance.

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drp_obdcbn7hei.view_mode_page' doesn't exist:

SELECT view_mode_page.* FROM {view_mode_page} view_mode_page WHERE (content_type = :db_condition_placeholder_0) AND (view_mode = :db_condition_placeholder_1) ; Array ( [:db_condition_placeholder_0] => tu_mooc [:db_condition_placeholder_1] => default )

  en view_mode_page_get_patterns() (línea 281 de /hermes/waloraweb021/b1678/moo.blasbray/sites/all/modules/view_mode_page/view_mode_page.module).


texts: If I am viewing a users profile page, how do I obtain and display (in a block) their uid? NOTHING to do with the current logged in user. I need to display the users id in a block on their page.


texts: Hello Hiii Again Everyone I Am Creating A drupal website i want to create 2 forum for different topics Mean I want to create a business discussion forum and business ideas forum so in drupal there is only one forum so how can i make 2 different forms in one website


texts: How to get a field with a relationship in a view

texts: I have a design where a car belongs to a brand and let's say a brand belongs to acategory, using entity reference module I was able to display the brand in the car view, but I don't know how to display the category, I tried to set the relationship but it does not seem to work.


texts:
I have the following function that simply grabs nodes:

function getWords() {
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node', '=')
            ->propertyCondition('status', 1, '=')
            ->propertyCondition('type', 'wall_of_words', '=');
    $result = $query->execute();
    return node_load_multiple(array_keys($result['node']));

}

Right now it's working but it's returning everything, is there a way I can return the contents of the body or title field only?


texts:
If you have a paragraph reference field on a node you'll see a form table on node creation or node edit. Is there a way to change the columns of that table? Now you see:

The type of paragraph
The fields that are filled in
Edit button

I want to delete the "type of paragraph" column and add some columns that shows what's filled in in the paragraph form.


texts:
I've got content-type with two fields with real values. Their interior name are field_price1 and field_price2. I created page view includes contents. I've got search. I want to allow user to give some value(s) in search (min and max) to seek contents. I want to display only these contents whose field_price1 OR field_price2 is between min and max filled in by user.

Has someone any ideas?

I tried and I decided to create two filters. First filter (for field_price1) exposed, second (for field_price2) not. So that, in my search I've got two inputs (I chose between operator). I wanted the second filter inherits values from first filter. I coded:

function customSearch_views_pre_execute(&$view) {
  if ($view->name == 'search') {
    $filters = $view->display_handler->get_option('filters');
    $filters['field_price2_value']['value']['min'] = $view->exposed_input['field_price1_value']['min'];
    $filters['field_price2_value']['value']['max'] = $view->exposed_input['field_price1_value']['max'];
    $view->display_handler->override_option('filters', $filters);
  }
}

I place that function in my custom module named customSearch. My view is named search. Unfornately it doesn't work. Second filter doesn't inherit values from first one. I don't know why. Could someone help me, please?


texts: RouteNotFoundException thrown when trying to reroute

texts:
I am converting a Drupal 7 module to Drupal 8. The purpose of this module is to have shorter URLs which can be shared, as an alternative of /node/123 the module should send people typing /n/123 to the same content.

I feel like I am pretty close to competion but there is 1 more issue.
When I try using the 'littlurl' I get this error Symfony\Component\Routing\Exception\RouteNotFoundException: Route "node" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 187 of C:\Users\SAMUEL\Sites\devdesktop\Module3\core\lib\Drupal\Core\Routing\RouteProvider.php).

routing.yml

littlurl.node:
  path: /n/{nodeid}
  defaults:
    _controller: '\Drupal\littlurl\Controller\DefaultController::nodeForward'
  requirements:
    _permission: 'access content'

littlurl.user:
  path: /u/{userid}
  defaults:
    _controller: '\Drupal\littlurl\Controller\DefaultController::userForward'
  requirements:
    _permission: 'access content'

littlurl.taxonomy:
  path: /t/{taxid}
  defaults:
    _controller: '\Drupal\littlurl\Controller\DefaultController::taxonomyForward'
  requirements:
    _permission: 'access content'

controller.php file

<?php /**
 * @file
 * Contains \Drupal\littlurl\Controller\DefaultController.
 */

namespace Drupal\littlurl\Controller;

use Drupal\Core\Controller\ControllerBase;
use \Symfony\Component\HttpFoundation\RedirectResponse;
/*use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;*/

/**
 * Default controller for the littlurl module.
 */
class DefaultController extends ControllerBase {

  public function nodeForward($nodeid) {
    $route_parameters[0] = $nodeid;
    $options['absolute'] = TRUE;
    $url = $this->url("node", $route_parameters, $options);
    $response = new RedirectResponse($url);
    $response->send();
  }

  public function userForward($userid) {
    $route_parameters[0] = $userid;
    $options['absolute'] = TRUE;
    $url = $this->url("user", $route_parameters, $options);
    $response = new RedirectResponse($url);
    $response->send();
  }

  public function taxonomyForward($taxid) {
    $route_parameters[0] = $taxid;
    $options['absolute'] = TRUE;
    $url = $this->url("taxonomy", $route_parameters, $options);
    $response = new RedirectResponse($url);
    $response->send();
  }

}


texts: How to delete configurations when module is uninstalled?

texts:
We have a custom module mymodule that has the following structure. It basically has a configuration object that we are using in a mymodule_preprocess_node() call to do some logic and display certain output.

When the module is uninstalled, we noticed that configuration files are not deleted. How would we delete the configurations on uninstall?

What we were thinking, but not sure if that is correct or if we are missing any steps.

function mymodule_uninstall() {
  \Drupal::configFactory()->getEditable('mymodule.settings')->delete();
}


texts: How to set up permissions for the private files directory?

texts:
I'm trying to set up the private files directory and I'm getting the following error.

  The backup file could not be saved to 'private://backup_migrate/'
  because the directory could not be created or cannot be written to.
  Please make sure your private files directory is writable by the web
  server.

Could someone help correct my misstep? I've scoured scads of pages of documentation, and oddly I don't seem to be able to find a reliable path to a solution. Lots of conflicting info and lots of missing details.

Here's my setup:

bitnami drupal image (centos)
path to Drupal /root/apps/drupal/htdocs
I've connected as root via ssh

Here are the exact steps I've followed, and which best reflect my understanding so far of what I should do:

# cd /root/apps/drupal/ to go to directory that contains the web root directory
# mkdir private-files
# drush dl file_permissions --destination=~/.drush to download the contributed file_permissions utility, which says it handles all necessary permissions changes
# nano sites/default/settings.php to tell Drupal where to find the directory, set $settings['file_private_path'] = '/root/apps/drupal/private-files';
# drush cr to clear Drupal and Drush caches
# drush fp to run the file_permissions utility; it responds:

  Your httpd user: daemon                                      [status]
  Your httpd group: daemon                                     [status]
  You will be prompted for admin password to be able to change [warning]
  permissions with sudo command.
  Security warning: Couldn't write .htaccess file. Please create a     [error]
  .htaccess file inyour private:// directory which contains the
  following lines:
# Deny all requests from Apache 2.4+.
  <IfModule mod_authz_core.c>
  Require all denied
  </IfModule>

  # Deny all requests from Apache 2.0-2.2.
  <IfModule !mod_authz_core.c>
  Deny from all
  </IfModule>
  # Turn off all options we don't need.
  Options -Indexes -ExecCGI -Includes -MultiViews

  # Set the catch-all handler to prevent scripts from being executed.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
  <Files*>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
  </Files>
  # If we know how to do it safely, disable the PHP engine entirely.
  <IfModule mod_php5.c>
    php_flag engine off
  </IfModule>

# drush cr to clear Drupal and Drush caches
# ls -al to see permissions; it shows:

  total 8628
  drwxr-xr-x  7 root   root       134 Jul 23 12:04 .
  drwxr-xr-x  5 root   root        53 Jun  7 13:52 ..
  lrwxrwxrwx  1 root   root        14 Jun  7 13:55 .bitnamimeta -> ../../var/meta
  -r-xr--r--  1 root   root   8826689 Jun  7 13:31 bnconfig
  drwxr-xr-x  4 root   root       146 Jun  7 13:51 conf
  drwxr-xr-x 12 root   root      4096 Jun  7 13:51 drush
  drwxr-x---  9 root   daemon    4096 Jul 18 13:46 htdocs
  drwxr-xr-x  2 root   root        25 Jun  7 13:51 licenses
  drwxrwsr-x  2 daemon daemon      23 Jul 23 13:45 private-files
  lrwxrwxrwx  1 root   root        33 Jun  7 13:54 updateip -> /opt/bitnami/apps/drupal/bnconfig

# ls -al private-files/ to see permissions; it shows:

  total 4
  drwxrwsr-x 2 daemon daemon  23 Jul 23 13:45 .
  drwxr-xr-x 7 root   root   134 Jul 23 12:04 ..
  -rw-r--r-- 1 root   daemon 687 Jul 23 13:47 .htaccess

Needless to say, pretty frustrating since I've spent at least 4 hrs on what I imagine must be simple for someone already familiar with all the components.

Since I am new to servers as well as to Drupal, please break out actual steps vs merely invoking (vague-to-me) concepts such as 'change user group' or the like.


texts: Unresolved dependency updating the module

texts:
I'm updating the Views module on a Drupal 7 site, and I'm receiving this message when I update the database.

How do I resolve this dependency issue when I need to update the Views module first?


texts: How can I add language selection to the user profile in "my account" settings

texts:
I'm currently allowing users to switch language with the "Language switcher" block, but I would like have this as part of the user profile that is managed with the "My Account" settings page.

Is it possible to add this as a field? Adding a field is no problem, but can I make it refer to the language setting that is normally controlled by the language switcher block? I'm using Drupal 7.


texts: How to add Open Graph Tags in Custom Module detail page?

texts:
For Node I already used https://www.drupal.org/project/metatag

For my custom module's detail page would like to add Open Graph tags for FB share.

So in my_test.module

function template_preprocess_my_detail_page(&$variables) {

  $items = $variables['item'];

  $title =  $items->title;

  $og_title = [
        '#tag' => 'meta',
        '#attributes' => [
          'property' => 'og:title',
          'content' => $title,
        ],
      ];

  $variables['page']['#attached']['html_head'][] = [$og_title, 'og_title'];
}

Above one suppose to work but NOT WORKING.

function MY_MODULE_page_attachments_alter(array &$page) {

  $og_title = [
        '#tag' => 'meta',
        '#attributes' => [
          'property' => 'og:title',
          'content' => '',
        ],
      ];

  $page['#attached']['html_head'][] = [$og_title, 'og_title'];
}

Above one is working, But I'm not able to get Page Variables. How will I get $variables in above function?

This one called in all pages of module, but I want to call only on detail page as mentioned in proprocess function


texts: Drupal 8, use variable defined from custom form in custom template twig

texts:
I created a custom form, a custom twig template, and I 'linked' both with a theme hook.

From my buildForm method of Form Class, I defined a variable like this :

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['#foo'] = array("key_a"=>"value_a", "key_b"=>"value_b", "key_c"=>"value_c");
  // do some work ...
  return $form;
}

From my twig template, when I dump or sho all availables variables with :

{{ dump() }}
{# or with kint #}
{{ kint() }}

I see my array '#foo' is present in variables availables from my custom twig template. The "#foo" array is in a 'element' array.
My question is, how can I get and print the content ?

If I do a sample :

{{ #foo }}

I get a syntax error because there is a 'sharp' (#) character.
I tried :

{{ element.#foo }}
{{ element.'#foo' }}
{{ 'element.#foo' }}
{{ foo }}
...

Sometimes I get an error, sometimes a NULL printed result..How can I print my array, get keys and values ?

Thanks you !


texts: How can I make or render a website with wiki features(for e.g wikipedia) with Drupal?

texts: The question is can I render wiki features in my website which is to be made with Drupal.For e.g if I make a website with tons of features how can Wiki feature be made functional with Drupal.If no should I make new themes.


texts: db_select() ignores condition() when used with join

texts:
I want to select all rows from 'ha' table, which access column are >= 0 and node type of that nid is equal $this->ctype.

  protected function queryAlter() {

    if(isset($this->ctype)) {

        $this->query->leftJoin('node', 'n', 'n.nid = ha.nid');
        $this->query->conditions(
                db_and()
                ->condition('ha.access', 0, '>=')
                ->condition('n.type', $this->ctype));
        //dpr($this->query);
    }
    else {
        $this->query->condition('ha.access', 0, '>=');
    }
  }

$this->ctype is set and equal to 'ad'. And I have not any nodes with that type.
But db_select() ignores condition('n.type', $this->ctype) and returns all rows from ha (which NID's are not ad type).

Why this happens? And how to debug db_select() in general?


texts: How to use superfish on commerce kickstart

texts:
Anyone can tell me the steps needed to implement superfish on commerce kickstart 2.32 ?

I have read this (Creating a menu while categorizing my products) but I failed.


texts:
I have developed a website in Drupal 7. Right now I have a requirement: A page should display a PDF file (already generated). Only authenticated users should have access to view or download this file, but anyone with direct access to this static file link can view it and download it.
Is there any method I can use to prevent this and redirect them to the login page? What kind of logical programming needs to be applied in this case?


texts: Programmatically get the list of fields of a custom content

texts:
I want to programmatically create a custom content (custom content created via the admin UI). Before the creation, I want to check the types of fields of my custom content.

My custom content contains a field "body" (type text), a field "description" (type text), an int field (type int), an attached file field (type fid ?).

I tested several ways; this is my last try.

// I get the entity object "my_custom_content"
$entity_object = NodeType::load("my_custom_content");
dpm($entity_object); //Work perfectly

$test = \Drupal::getContainer()->get("entity_field.manager")->getFieldDefinitions("my_custom_content",$entity_object->bundle())

The code returns an error:

  The my_custom_content entity type does not exist.

With this $entity_object, how can I get the list of the fields of my custom content?
I see the EntityFieldManager class, the FieldItemList class, but I still do not understand how to play with Drupal 8.


texts: CKEditor for Drupal 7 does not show the page contents

texts:
This page http://sunsethill-ubud.com/bistro contents some text. When I look at it as admin, I can use the Edit tab. But if I click this tab, I get an empty page in CKEditor:

I tried playing with or without additional modules, with the version of jQuery, with uninstalling and installing again CKEditor, and so on. Probably the problem is very simple, but I don't see any solution.

Thanks in advance for any help!


texts: Are there JavaScript events sent by Webform Conditionals?

texts:
I am using the iCheck module for checkboxes, and the checkbox is initially hidden by the Webform module. Somehow, the Webform module also sets it to disabled while hidden, which is nice.

Once it gets shown, the disabled status is removed from the webform, but the iCheck module doesn't notice. Calling iCheck.update() fixes it, but I need to catch an event to do that.

Are there JavaScript events sent by a webform conditionals?


texts: Remove paper size options on node add forms

texts:
Node add forms show some paper size options no matter who the user is, even regular authenticated users. It seems to be part of the Printer, email and PDF versions module.

I added the following code to my helper (let's call it my_helper) module, as suggested here:

/**
 * Implements hook_form_alter().
 */
function my_helper_form_alter(&$form, &$form_state, $form_id) {
  // Hiding the print fields that print.module puts into the node form.
  if (strpos($form_id, '_node_form') !== FALSE && !empty($form['print']['print_pdf'])) {
    foreach ($form['print']['print_pdf'] as &$print_field) {
      $print_field['#access'] = FALSE;
    }
  }
}

I am also using the Simplify module to hide certain form elements but this isn't coming up as an option there.

Edit: I looked at the system table in MySQL to see that the weight of the module was 0, so I added a .install file to change the weight to 10. But still not seeing an affect.

   function my_helper_update_7100() {
        db_update('system')
        ->fields(array('weight' => 10))
        ->condition('name', 'my_helper', '=')
        ->execute();
    }


texts:
Not being a developer per say, I am responsible for converting the PSDs into HTML, CSS & Js. Our Drupal Web Developer doesn't know the answer to this question so I hope someone here can answer it for me.

After handing over the HTML, CSS & Js file to the developer, this is what he brought back. All the lines of code you see in the firebug that is not green highlighted is Drupal 7 generated (we are using Adaptive Theme with sub-theme Sky which we are further modifying).

I dont understand what all these (& they are a lot) divs do, what purpose they serve.

Are they generated in every Drupal website & is code we should not be worrying about or are we doing it all wrong?


texts: How to translate the book pages content using the Book Translation module?

texts:
My requirement is that a user can see the complete book pages in the selected language (English, Hindi, Bengali, etc) as per the preference. That's why I installed the Book Translation i18n_book_navigation module.

As I installed the module and enabled the language block but it didn't translate my node's content. It only translate the inbuilt of Drupal taxonomy like View, Edit, Outline, etc into other languages. Do I need to configure some other settings for translating the book pages content or am I missing any module to install or enable?


texts: How to create invisible widget in Drupal

texts: I need to create an auto-generated value for every user on my site. No one should be able to edit this field so it should not appear on the user edit form. Is there a better way to achive this than simply removing its edit field with hook_form_alter?


texts:
I am working on a project involving migrating a site with many static pages to Drupal 8. Since a number of the pages are old blog posts, there's often broken links, broken images, etc.

For quality assurance, we are using the httrack command line tool to traverse the new Drupal 8 site and report broken links and images.

It turns out that Drupal 8 is putting some extra <link> tags in the page head (the <head> section of the html, not the header region or anything like that).

First, when there is a page with a taxonomy term in it, there are links to the term's admin pages in the head, like so:

<link rel="devel-definition" href="/devel/taxonomy_term/226/definition" />
<link rel="clone-form" href="/entity_clone/taxonomy_term/226" />
<link rel="token-devel" href="/taxonomy/term/226/devel/token" />
<link rel="display" href="/taxonomy/term/226/manage-display" />

These links are on the page even for anonymous users.

Second, we have media images in our pages, and they are getting weird head link tags, also. For instance, if we have the image inside-a-classroom.jpg, we'll have this: <link rel="image_src" href="Inside A Classroom" />.

The problem is, httrack is finding these links in head, trying to download them, and returning a 404. And of course it would, because when it spiders, it's not logged on and can't access admin menus. In the case of images, they're not even proper links to the image.

Is there any way we can turn these off? They are false negatives in our scraping, and make it difficult to quality check our work.


texts: How to get entity type from entity_metadata_wrapper

texts:
I can use

$entity = entity_metadata_wrapper('node', 1);
$entity->getBundle();

to get the node type of an entity. However, entity-wrappers can wrap other types of entities, e.g. users. When calling getBundle() on a user entity, 'user' is returned. What should I call to return the type of entity (should return 'node' in the example above)? I can see when I print_r($entity) that $entity->type is a protected field of the wrapper object.


texts: programmatically add an existing entity reference autocomplete field in custom form

texts: I need to create a custom form and add an entity reference field to it. The field uses autocomplete with a view for entity selection. The field already exists on a node but i also need it in a custom module. Is there a way to add this field in a custom module with MYMODULE_MYFORM_form()?


texts: Custom Drush command and Settigns::get(), Config::get()

texts:
how can I access site configuration when in Drush command?

Global variable $config === null and when I use Config::get('key'), I get

  Error: Using $this when not in object context in Drupal\Core\Config\Config::get() (line 85 of /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Config/Config.php)`

What is the recommended approach? I can't find it anywhere... thank you!

Edit

I actually intended to access Settings, not Config - that's where the confusion came from. Settings::get() works just fine. To get data from config, just follow the accepted answer.


texts:
I have a simple form inside a block:

function mymodule_block_view($delta = '') {
      switch($delta) {
        case 'some_name':

          $block['subject'] = t('title');
          $block['content'] = drupal_get_form('mymodule_form');
      }
      return $block;
    }

When I submit the form, the mymodule_form() method gets called twice. In the first run the values I have put into the textfields are correctly stored in $form_state. In the second run, they are not there anymore. Does anyone have an idea why this is the case?

What I would like to do is very simple: I'd like to retain the values I have put into the textfields, so when the form gets submitted, the page gets reloaded, and the values I gave are the new default_values of the form. I know how to do this in the code, but as I said, the form_state is empty in the second run, thus the form takes the 'default' default_values.

Why does mymodule_form() get called twice?


texts: Garland sub-theme color functionality is not working

texts:
I have a subtheme in Drupal 7 for Garland theme. below is my my_garland.info file for the sub-theme

name = My Custom Sub Theme
description = Custom sub-theme of Garland
core = 7.x
base theme = garland
stylesheets[all][] = my_garland.css

i have also include some information in the template.php file to help with the color module

function my_garland_process_html(&$vars) {
  // Hook into color.module.
  if (module_exists('color')) {
    _color_html_alter($vars);
  }
}

I have also copied the color and images file from the garland theme therefore the initial blue works perfectly and i can see the color wheel but the total page layout is not changing.
I have also tried to follow this link to see if it will be resolved but all in vain. Thanks in advance for your assistance.


texts: Get display name from hook_preprocess_views_view

texts:
I want to use hook_preprocess_views_view in order for several views to share the same template, by adding theme_hook_suggestions as described in this article: http://greenash.net.au/thoughts/2014/04/sharing-templates-between-multiple-drupal-views/

function mytheme_preprocess_views_view(&$vars) {

  if (in_array(
    $vars['view']->name, array(
      'whatever'))) {
    $vars['theme_hook_suggestions'][] =
      'whatever';
  }
}

Problem is, I need to specify which display of the particular view it should apply to, rather than the whole view itself. I've tried printing the $vars out which results in a huge recurring array which doesn't seem to include the display name anywhere.

I'm also aware you do this via tagging in the views UI. The same problem occurs though - I can't add a tag to a particular display of a view.

If there is another way I can accomplish this I'm all ears!


texts: Contextual filter on entity reference field in indexed view

texts:
I have two pages: jobs and offices.

My jobs page is an indexed view (with Search API) which displays jobs that have an entity reference field to the office it belongs to.

I want to put a link on my office page that links to the job page which only shows the jobs belonging to that particular office.

I've followed a few examples but none of them seem to work with my indexed view. Has somebody done something similar?

This is what I did: https://www.drupal.org/node/1841004 but it doesn't seem to work.

Thanks!


texts: I ajaxly call a route and pass data to it, In my controller, I want to get $_POST['var'] , $_POST['var2'], it seems because of using HttpFoundation in drupal 8, $_POST and $_GET are not exists in old method, How I can access $_POST parameters in custom Controller?


texts: Ubercart 2.x drupal 6 combo attributes price

texts:
Is it possible to set a different price for each combination of attributes in Drupal? For example when A and C, the price is $10; when I select B and C, the price is $12; when I select B and D, the price is $13.
I see http://drupal.org/project/uc_custom_price; it works, but I have too much combination for each product. There is a module, http://www.ubercart.org/project/attr_combo_price, but it is for Drupal 5.

Are there any other solutions?


texts: How can I limit the maximum weight of an order?

texts:
Is there a way in drupal commerce 2 to prevent adding a product to the cart, if the order weight exceeds a certain amount, let's say 40kg?
We are also using the commerce_cart_api plugin, in case this provides some hooks to prevent an add?


texts: Is there a rule condition to check if the url is the front page?

texts: Just wondering if is there a rule condition to check if the url is the front page of the site?


texts: My website is mycapecodvacations.com I need help how to make the default home page mycapecodvacations.com instead of going to mycapecodvacations.com/home I'm using host gator .com and want to know how to make the home page without /home and just " mycapecodvacations.com" i tried removing the htaccess file. do I need to edit a specific file?


texts:
I'd like to create a content type. My problem is this content type will change frequently (every 6 months, I will add some fields and I will delete others).

How would you do it? I had thought several options:

1) Create a "version" field with a default value for every version I make. With the "hook_form_alter" I would hide or I would show fields according to the version.

2) Another option is to create a new content type for every version "contenttype_10", "contenttype_11", "contenttype_20",... Is there any module that makes possible create a new content type copying all the fields of a existing content type?

What do you think about it? What version is the best for you?


texts:
With my current module I have a simple form where a user inputs some information, that information is then sent to an external API, and that API sends some data back.

How do I display the data that is returned from the external API?

Thanks

<?php
/**
 * Implements hook_menu();
 */
function find_rep_menu(){
    $items = array();
    $items['find-representatives/%'] = array(
        'title' => 'My Form',
        'page callback' => 'find_representative_value_callback',
        'page arguments' => array(2),
        'access callback' => TRUE,
    );
    return $items;
}

/**
 * My form
 */
function find_rep_form($form, &$form_state) {
    $form['address'] = array(
        '#type' => 'textfield',
        '#title' => t('Your Address'),
        '#size' => 60,
        '#maxlength' => 128,
        '#required' => TRUE,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Find Rep'),
    );
    return $form;
}

/**
 * Submit handler for the find_rep_form.
 */
function find_rep_form_submit($form, &$form_state) {
    $address = $form_state['values']['address'];
    fetchGeocode($address);
    $fetchGeocode = fetchGeocode($address);
    fetchStateInfo($fetchGeocode['returnedLat'], $fetchGeocode['returnedLong']);
    $form_state['redirect'] = 'find-representatives/' . $form_state['values']['address'];
}

function find_representative_value_callback($address) {
    return t('Value: @value', array('@value' => $address));
    //Once I was able to get this working, I was going to push my returned data through here
}
    /*
     * The fetch code
     */
    function fetchGeocode($userAddress) {
        $userAddress = urlencode($userAddress);
        $fetchUrl = "https://api.mapbox.com/geocoding/v5/mapbox.places/" . $userAddress . ".json?country=us&proximity=38.8977%2C%2077.0365&types=address&autocomplete=true&access_token=APIKEY";
        $result = drupal_http_request($fetchUrl);
        if (in_array($result->code, array(200, 304))) {
            $geoResponse = json_decode($result->data);
            $long = $geoResponse->features[0]->geometry->coordinates[0];
            $lat = $geoResponse->features[0]->geometry->coordinates[1];
            return array('returnedLat' => $lat, 'returnedLong' => $long);
        } else {
            drupal_set_message("Geocode returned: " . $result->code); //For testing purposes
        }
    }

    function fetchStateInfo($userLat, $userLong) {
        $userLat = urlencode($userLat);
        $userLong = urlencode($userLong);
        $fetchUrl = 'http://openstates.org/api/v1//legislators/geo/?lat=' . $userLat . '&long=' . $userLong . '&apikey=APIKEY';
        $result = drupal_http_request($fetchUrl);
        if (in_array($result->code, array(200, 304))) {
            $stateInfo = json_decode($result->data, true);
            drupal_set_message($stateInfo[0]['full_name']);
        } else {
            drupal_set_message("State API Returned Error: " . $result->code);
        }
    }

I was taking some examples from example two on this comment here


texts:
I am using Drupal 7 and focused to work with email option. I am using the Forward module. How can I add the BCC field in the drupal_mail() function.

my default function having,

drupal_mail('forward', 'forward_page', trim($to), language_default(), $params, $params['from']);


texts: How can I distinguish dynamic pages on a hook_menu?

texts:
function mymodule_menu_local_tasks(&$variables) {
   if ( request_path == 'yadda') :
   ....
}

I can do that.. but the problem is I want to include this for the tabs on user/$id/edit and I'd rather not do regex or check the beginning and end of the string...

Is there some way I can pull a variable that relates to that specific page type?


texts: Combining Date Start and Date End in Drupal 8 Views Block

texts: I am new to Drupal 8 Views - How do you concatenate Event Start Date Sept 1, 2019 with Event end Date ie: Sept 4, 2019? The end result is they just want the Month and Day to show up like this Sept 1-4.


texts: Programmatically change import URL of reference node

texts:
My question is similar to this guy's from drupal.org:
https://www.drupal.org/node/2283931

But, I have reference nodes that import content from various URLs and I want after each import, to change the (feeds source) URL of the reference node.
I guess I will use hook_feeds_after_import() but how am I going to target the reference node instead of the importer and run a function on that source?


texts:
I have problem to understand how I should use theme('pager') as explained on
EntityFieldQuery display pager.

I can't make it work (display pager and links to resulting pages).

Does pager(10) in EntityFieldQuery automatically invoke the pager? Should it be displayed with print(theme('pager'))?

Is this functionality included in Drupal core (7.15)?

I am doing my queries in template.php and injecting the query result in article.tpl.php through a variable.

As a workaround, I am thinking of doing two queries, one to find out what the number of nodes that meet a condition is, output links with numbering, attach the variable to those links, read the variable in another query and select the resulting nodes with range($i,$j).


texts: How to show 2 instances of the user profile form, displaying different form modes, on the same page?

texts:
I would like to show 2 instances of the User Profile edit form on the same page.  One form mode only shows the username/password widget with the submit button.  The other form mode only shows the contact information with the submit button.

When I try the following, I get Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "user" entity type did not specify a "user.change_password" form class.  Note that I've changed the form class to change_password as well.

$user = User::loadMultiple([$this->account->id()]);
$form = $this->entityFormBuilder->getForm($user[$this->account->id(), 'change_password']

I asked a similar question regarding custom entities but using that solution would require modifying core files.

Is it possible to do this?


texts: Loading a jQuery plugin from the Libraries 2.X module in Drupal 7?

texts:
I am using the jQuery Easing plugin (http://gsgd.co.uk/sandbox/jquery/easing/) for one of my Drupal 7 themes. I see that there is a Libraries module that loads this plugin in a way that allows other modules and themes to use it: http://drupal.org/project/jqeasing.

Is this the correct way to load the library?

After loading the library, Do I need to explicitly call drupal add js from the template.php theme file? The documentation for the Libraries module for theme development is terrible. I may contribute to it, once I get this sorted out.


texts: Drupal View Show Webforms NOT Submitted By Logged In User

texts:
I'm hoping someone can help me out with this because I have been stuck on this for days...

I have a bunch of webforms that each user needs to submit. I figured out how to show a view of the webforms the logged in user has submitted, but what I am stuck on is showing the webforms the user has NOT submitted in a view. So it would be a list of the webforms the user still needs to fill out.

There must be something small I am overlooking. I appreciate any ideas or help, thanks!


texts: How to retrieve last MySQL INSERT ID from db_merge()

texts:
I am using db_merge for inserting or updating new records in my table.
I want to get the last inserted record id from this table, Thank you.