texts: When attempting to run drush ": No such file or directory"

texts:
I've been bashing my head against the wall all day trying to figure out why Drush has suddenly stopped working.

I've re-installed via composer, tried different versions, always the same error.

If I type which drush I get /home/user/.composer/vendor/bin/drush which is correct.

If I type sh -vx drush in an attempt to debug what's happening with the script, I get the following output:

#!/usr/bin/env sh
#
# This script is a simple wrapper that will run Drush with the most appropriate
# php executable it can find.
#
# Solaris users: Add /usr/xpg4/bin to the head of your PATH
#

+
: not found/.composer/vendor/bin/drush: 8: /home/user/.composer/vendor/bin/drush:
# Get the absolute path of this executable
SELF_DIRNAME="`dirname -- "$0"`"
+ dirname -- /home/user/.composer/vendor/bin/drush
+ SELF_DIRNAME=/home/user/.composer/vendor/bin
SELF_PATH="`cd -P -- "$SELF_DIRNAME" && pwd -P`/`basename -- "$0"`"
+ cd -P -- /home/user/.composer/vendor/bin
/home/user/.composer/vendor/bin/drush: 1: cd: can't cd to /home/user/.composer/vendor/bin
+ basename -- /home/user/.composer/vendor/bin/drush
+ SELF_PATH=/drush

+
: not found/.composer/vendor/bin/drush: 12: /home/user/.composer/vendor/bin/drush:
# Decide if we are running a Unix shell on Windows
if `which uname > /dev/null 2>&1`; then
  case "`uname -a`" in
/home/user/.composer/vendor/bin/drush: 15: /home/user/.composer/vendor/bin/drush: Syntax error: word unexpected (expecting "in")

wut

Ok, maybe something wonky is returned with uname -a? The response from my server is:

Linux servername 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

There are no directory permission issues... everything is owned by the user. I'm at a complete loss. I've tried drush 5, 6, and 7 - same sort of error in each.

The server is running Ubuntu 12.04.2 LTS


texts:
I am developing a custom Drupal 8 module on my local VM. When I first created and enabled my module, it did not have a .module file (just a controller). Now I have added a .module file so I can add an implementation of hook_entity_insert() but Drupal is not discovering it. I have tried going to Configuration > Performance > 'Clear all caches' but no joy!

How can I get Drupal 8 to discover the .module file in my custom module?


texts: Why is my .htaccess not working when uploaded to a Pantheon server?

texts:
My drupal site has a .htaccess file on which I am redirecting the page without changing the URL.

It's working fine on local server & other servers but when I upload the files & databases to pantheon server It will not redirect the page saying 404 not found. I placed .htaccess at the root of code folder, I tried placing it in server root folder, sites/ folder & themes/ folder but nothing works for me.

Does anybody know what is the correct placement of .htaccess in a Drupal site on Pantheon? And why my .htaccess is not working on Pantheon?


texts: using Drupal Aggregator module, trying to export OPML

texts:
using Drupal 7, trying the aggregator module. It looked promising, so imported my OPML file from Google Reader to it a while back.  But Aggregator has too many bugs to keep using it. It seems to corrupt the db when deleting or editing items, and it hangs up in the cron job for updates when items are bad, with no good way to find them and fix or remove them. Also, can't do a view of items in a category; that simply does not work (or only works for the primary category set by the feed itself - can't use a category that is set on individual items later).  The block for the category works but you can't get a feed from the block.

so, trying to get my feeds back out of drupal;  but apparently there is no way to export it as OPML...  one way street. a real pain.

does anyone know how to export the aggregator data (preferably as OPML) so I can try using some other service, like The Old Reader.


texts: Alternative to creating large number of fields via UI for a content type

texts:
We need to create a content type with large number of fields(50+). Adding fields one by one via UI is one option but it seems unnecessary that so many tables get created when adding fields via UI.

Other option that I tried was Matrix field module which allows inclusion of multiple fields with widget options for select, checkbox, text etc. However it does have few issues with display.

The other alternative is the TableField module. But then it only provides text options.

Are there any other modules that allow creation of multiple fields without the overhead of creating multiple tables at the same time.

Note: A webform cannot be used in this case due to design considerations.


texts: Sort Criteria for Upcoming Event (list) for multi day/recurring event

texts:
I want to show a list of upcoming events in ascending order.
I have selected the following for my Sort Criteria for the "Upcoming" view

Content: Date - start date (asc)
Content: Effective Date - end date:value2 (asc)

However, I want to push a multi day event or recurring event to the top of the list if the event is occurring on the current date if the start date has passed.


texts: I see it often, $this->ensure_my_table() and I'm not sure what it does and why it is important when building Views handlers.


texts: How to fix SalesForce authentication errors on localhost?

texts:
I am fairly new to developing with Drupal, and new to this forum, so any help would be greatly appreciated.
While trying to authorize SalesForce with a local install I get the following two errors with when going to the oauth_callback.
Note: I have not included the entire path to save space but the reference points are accurate for the doc and line the error references.

Notice: Undefined property: stdClass::$data in Salesforce->requestToken() (line 338 of salesforce.inc)
SalesforceException: Error opening socket ssl://login.salesforce.com:443 in Salesforce->requestToken() (line 342 of salesforce.inc)

Local Environment: Mac OS Mavericks with XAMPP 5.6.3, SSL enabled on port 443 in httpd-vhosts.conf with certs created using OpenSSL.
Extension: php_openssl.dll uncommented in php.ini
Also to note the Drupal install was pulled from a live site that has SF module enabled and working.
I created a new connected app with the proper oauth_callback to the local site which is https://secure.localhost/salesforce/oauth_callback
I have both HTTPS and HTTP enabled, I have noticed that in the Status Report when using HTTPS I do get a HTTP Failure error in the status report.
The request url from salesforce is passing a code EX: https://secure.localhost/salesforce/oauth_callback?code=aPrxMZkm7lCkgfR3...
With a Status code of 500 Service unavailable.
I have looked all over online and on this site, and can't seem to find anything that works. I have tried a few patches to the common.inc file, but none of them seemed to work.
Like I said any help would be greatly appreciated, I am just not sure if it is Drupal, Salesforce, or my local setup.


texts: D8: How to perform ajax call in javascript

texts:
I'm trying to perform an ajax call from a javascfript file by executing this:

            $.ajax({
                url: '/lunapark/ajax/space-invaders/' + score,
                success: function (jsonData) {
                    window.location.replace(jsonData.redirect);
                }
            });

But I keep getting:

  GET /lunapark/ajax/space-invaders/90 404 (Not Found)

If I go to the url in my google chrome, it loads and gives me a JSON object, so the page does exist:

{"redirect":"\/lunapark\/overview","game":"space-invaders","score":"90"}

Now I'm trying this:

new Drupal.ajax();

But I can't seem to figure it out...


texts: create category and subcategory menu on the left sidebar

texts:
I need a category, subcategory and subbactegory based solution for
  example

Project
    Web project
        Project 1
        Project 2
    Desktop project
        Project 1
        Project 2

Project 1 (when i click this then content appear on right side)
Project 2 (when i click this then content appear on right side)

  Basically, when i click on the li page wouldn't be refresh. 1) i click
  on web project then menu expanded Project 1, project 2 appear and if i
  click on project 1 then content related to project 1 appear on the
  right side. Similarly for Project 2 and the subcategory for desktop
  project will be same means i can create subcategory related to desktop
  project.. Like in any category and product relation we need to select
  the category and add the product detail similarly in this


texts:
I created a menu with one specific menu entry. I want to show the menu only on one page.

Does exist a module which places a menu like a block?


texts: Rewrite query string for exposed taxonomy filter

texts:
I have this page: https://www.meubelentheo.be/catalogus

On the top of this page, just below the title you will see links such as Babykamer, Bureau, Decoratie etc.

These are taxonomy terms in an exposed filter. I use the Views module together with Better exposed filter.

If you click on the first term Babykamer, you will see the URL changes to https://www.meubelentheo.be/catalogus?field_portfolio_tags_tid=34

What I want to achieve: rewrite the part after the ? to something like ?term=babykamer or even better, rewrite the whole querystring to catalogus/babykamer

I tried the Query paramters to URL module and this indeed rewrites the URL to but this is not what I want. I want the taxonomy term name to be shown in the URL.

Any ideas?


texts: How to redirect certain requests to use https://www.example.com in pantheon?

texts:
In my Drupal install I would like to direct most URL requests to use https://www.example.com and only a few pages to use http://www.example.com Since my site is hosted on pantheon i cannot use .htaccess and i need to rely on my settings.php file. I tried the following but it doesn't really seem to work.

$redirect_domain = 'www.example.com';
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && $_SERVER['PANTHEON_ENVIRONMENT'] == 'live') {
  $redirect_location = '';
  // Do not require HTTPS for specific pages.
  if (in_array($_SERVER['REQUEST_URI'], array('/node/524','/some/unsecure/iframe'))) {
    // Check if HTTPS is enabled.
    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
      $redirect_location = 'http://' . $redirect_domain . $_SERVER['REQUEST_URI'];
    }
  }
  // Require HTTPS for everything else.
  else if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') {
    if($_SERVER['HTTP_HOST'] != 'www.example.com'){
      $redirect_location = 'https://www.example.com' . $_SERVER['REQUEST_URI'];
    }
    else{
      $redirect_location = 'https://' . $redirect_domain . $_SERVER['REQUEST_URI'];
    }
  }
  // Perform redirect.
  if ($redirect_location) {
    header('HTTP/1.0 301 Moved Permanently');
    header('Location: ' . $redirect_location);
    exit;
  }
}

typing in example.com does correctly redirect to https://www.example.com but typing in https://example.com doesn't perform any redirect.


texts: User to send a list of selected nodes via e-mail to the admin

texts:
I would like the users on a site to be able to select certain nodes and send a list of those nodes to one specific e-mail address.

Gathering the nodes is easy with Nodequeue or Flags, so is sending a mail with Action when a node is flagged. The problem is sending an email with the list when the user want to, when the list is final.

Do you know any solid solution for this problem?


texts: Where do I find the "Security code" to test "Commerce PayPal WPP Credit Card" with my "sandbox buyer account"

texts:
I am on Drupal 7.59 and using Commerce and Commerce PayPal modules.

I am at testing step, using my PayPal sandbox accounts (buyer and facilitator) to check if my PayPal classic and PayPal Credit Card payment methods work fine.

On PayPal classic I used WPS, and it works well
On PayPal Credit Card, I am using WPP, but something is missing somewhere.

About my PayPal WPP Credit Card (2)

All configuration is good, all the API credential that I have is correct. But one is missing : the Security code. In all tutorial I've watched, nobody talks about that field "Security Code". But it is a required field!. Whithout it I can not continue payment process which PayPal CB.

Can't anybody help ?


texts: Most efficient way to do simple Entity API queries by node id and content type?

texts:
A very basic 8.x API question.

What is the approved/simplest methods of confirming a node matching a certain content type and ID exists, and then loading it as an object?

(Use case: a module which accepts a node ID in the URL, that needs to be checked.)

Currently I have:

$node = \Drupal::entityTypeManager()->getStorage('node')->load(123);

if ($node->getType() == 'application') {
  return $node;
} else {
  return false;
}

My first attempt was in reserve (longer/less efficient):

$nids = \Drupal::entityQuery('node')
  ->condition('type', 'application')
  ->condition('nid', 123)
  ->execute();

// followed by entityTypeManager()->getStorage('node') etc.

But I was wondering if there was a way to make entityQueue() return a flat array of IDs rather than an associative [1=>1,2=>2,3=>3] which you then have to mess around with.


texts: How do I fix the "The each() function is deprecated" error?

texts:
I am using Drupal 7.6.0 on a server with PHP version 7.2.11.

I get this error message.

  Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of C:\xampp\htdocs\portailcommerce\includes\menu.inc).

How can I fix it?


texts: Programmatically create node using feeds

texts:
I'm creating nodes from XML using the Feeds module (great module BTW).

function boardgamegeek_menu() {
  $items['games/add/%/%'] = array(
    'title' => 'Boardgamegeek add game',
    'description' => 'Boardgamegeek add game',
    'page arguments' => array(2, 3),
    'page callback' => 'boardgamegeek_add',
    'access arguments' => array('access content'),
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

function boardgamegeek_add($objectid, $title) {
  $node = new stdClass();
  $node->type = 'boardgame';
  $node->title = $title;
  $node->feeds['FeedsHTTPFetcher']['source'] = 'http://www.boardgamegeek.com/xmlapi/boardgame/' . $objectid;
  node_save($node);
  /*
  // This does an import
  $myFeed = feeds_source('game_importer');
  while (FEEDS_BATCH_COMPLETE != $myFeed->import());
  */
  return 'http://www.boardgamegeek.com/xmlapi/boardgame/' . $objectid;
}

When I run this code, a node is created with a title field value from $title (that's exactly what I want). The import doesn't start automatically, and when I start the import myself, another node is being created without any title.

I would like to update the node I created...

The feed_nid and the entity_id should be the same. The feed_nid is the node id from the node I created, the entity id is the node id feeds created.

Any ideas?


texts: Keep the URL alias for a node when using href

texts:
I am using Drupal 6 and I have set aliases for my nodes under Administer > Site building > URL aliases. This works properly; for example, I have alias = about/faq, node = node/33, and when I click on my menu the page shows up properly on the browser address bar as about/faq.

The problem I have occurs when I want to reference my node from hyperlinks placed in a page on the website (or any other website). I want to use
 instead of
 so that I don't have to change the href if I later decide to change the alias. However, when I do this, the page shows up as http://mywebsite.com/node/33 on the browser address bar.

I was wondering whether it would be possible to have it show up as http://mywebsite.com/about/faq on the address bar instead.


texts: SearchAPI + FacetAPI: How to add a facet programmatically

texts:
Using SearchAPI and FacetAPi with Solr I have a facet block filled by one Solr indexed field i.e. "region".

Example:

  Region A
  Region B
  Region C

I need to programmatically combine two of the active facets to show the accumulated results, while keeping the original facets untouched.

How to achieve this?

  Region A
  Region AB <= new facet which accumulates Region A + Region B
  Region B
  Region C

There is a similar use case described in How can I merge or combine facets?

The difference in my use case is that I need the "combined facet" as an additional item, not replacing an existing facet item.

Any idea or hint is highly appreciated. Thank you.


texts:
I need to learn more about OpenLayers for Drupal 7. There is a ton of documentation for D6, some of which is helpful and some which isn't.

I'd like advice or suggestions for tutorials for a few different pieces..

When creating content, I want users to add a point or an area using a map. I know this is GeoField with the OpenLayers Map widget (so they don't type anything, but select visually), but I'm not sure how to then use this data in views.

In views, I need to create a map that displays the content. I want to set the default area based on the users' location.

Thanks.


texts: Attach a form input to a node that will be submitted by multiple users

texts:
I'm trying to create a content type that serves as a "Contest". Each contest needs the ability to upload an image by the user. Basically, I'm looking for the best way to attach a form field (file upload) to each Contest and be able to monitor all submissions, and by a user basis, for each individual contest, separately.

I've looked into Webform and Entityforms, but kind of running into road blocks. Does anyone have any suggestions?


texts: Making content available to a user after certain amount of time

texts:
I  want to restrict content access to subscribers over a period of time. Each user should be allowed to access the content in a sequential manner. So, after one week of membership, users would be able to access "Week 1" material; after 2 weeks users could access "Week 2" material.
Membership would just be a particular role.

Something similar has been done in Drupal 6, using PHP as reported in Release Content to Subscribers in a Sequence.

I am wondering if this is possible just using modules, like Rules and Rules scheduler.


texts: Finding and display custom user variables

texts:
I have create a series of user fields. Some of these fields reference taxonomy terms, require a mobile number or are just basic text fields. I used the below to print one of the fields (the number field) inside my page.tpl.php.

global $user;
$user = user_load($user->uid); // Make sure the user object is fully loaded
$number = $user->field_phone_number['und'][0]['value'];

if (isset($number) && !empty($number)) :
print 'Cell: ' . $number;
endif;

My question is how would I go about finding the information I need to print the other fields? The potion that reads ['und'][0]['value']; in particularly is where i'm stuck. I have used devel before to find this information for node variables but I cant find similar information for custom user variables.


texts: How can I make a node template that works on any url I specify?

texts:
At the moment I can make a template for a specific node based on the node id.
However I want to make the same template work off of the url or title of the node so I can use it on multiple sites for the same node which doesn't have the same node id on each of the sites.

How can I do this?


texts: Page title set from the title callback doesn't change

texts:
I created a simple download module to redirect a user when they click the download button to another page. Now I need to change the the page title every time a new download is triggered.

This is my code.

function custom_download_menu() {
  $items['download-code'] = array(
    'title callback' => 'custom_download_page_title',
    'page callback' => 'custom_download_view',
    'access arguments' => array('access content'),
    'access callback' => TRUE,
  );

  return $items;
}

function custom_download_page_title() {
  if (isset($_POST['title'])) {
    $title = "Downloading " . $_POST['title'] . " Code";
  }
  else {
    $title = "Download Code";
  }

  return $title;
}

But most of the time, the title does not change. It seems that it is using the title that is cached before.

I already added the following code so the page will not be cached:

drupal_add_http_header("Last-Modified", gmdate("D, d M Y H:i:s") . " GMT");
drupal_add_http_header("Cache-Control", "no-store, no-cache, must-revalidate"); // HTTP/1.1
drupal_add_http_header("Cache-Control", "post-check=0, pre-check=0", false);
drupal_add_http_header("Pragma", "no-cache"); // HTTP/1.0
drupal_add_http_header("Expires", "Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

Am I missing something?

Update:

<form id="form1" name="form1" method="post" action="/download-code">
    <input type="hidden" name="title" id="title" value="[node:title]" />
    <input type="hidden" name="download_code" id="download_code" value="[node:field_code_file]" />
    <input type="hidden" name="uri" id="uri" value="[node:url:relative]" />
    <input type="submit" class="downloadButton" value="Download Code">
</form>


texts:
I'm having a problem with drupal commerce and saving new products. When I click the save button twice (or as often as you can before the page reloads), the product gets saved multiple times. Is there any possibilty to stop multi-saves?
In a standard version, it should prevent that by checking the sku, but as I am using auto-sku module, every click generates a new sku.


texts: Help to get taxonomy term views to display custom fields based on term name not ID

texts:
I am having a situation where I would like to have a views page display a result set based on a taxonomy term.

I followed this tutorial here. Although this is for 6, it works perfectly for D7.

http://www.leveltendesign.com/blog/dustin-currie/link-taxonomy-terms-custom-views-drupal

It works great! It's exactly what I want, except for one issue - I have to use the ID, and I want to use the term name.

I did change the the token to use the [name] field instead. I'm 99% there. The problem is now terms with two words are broken up by spaces instead of hyphens.

Basically I am trying to get this to print out the custom url with hyphens instead of spaces. Any thoughts?


texts:
I have a custom order processor which currently just logs a debug message, so that I know that the order has been processed by it.

For whatever reason, my order processor is never run, I've checked against the docs, looked at how other commerce modules does it (commerce_promotion and commerce_tax), none of them show that I am doing anything wrong.

custom_commerce.services.yml

services:
  custom_commerce.order_tax_processor:
    class: Drupal\custom_commerce\OrderTaxProcessor
    tads:
      - { name: commerce_order.order_processor, priority: 300 }

OrderTaxProcessor.php class

<?php

namespace Drupal\custom_commerce;

use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_order\OrderProcessorInterface;

/**
 * Provides an order processor that adds tax to order if order has adjustments.
 * It does not affect order items.
 */
class OrderTaxProcessor implements OrderProcessorInterface {

  /**
   * {@inheritdoc}
   */
  public function process(OrderInterface $order) {
    \Drupal::logger('Custom commerce')->debug('Order processed check');
  }
}

Can anyone see what I am doing wrong? Other order processors seem to be running fine, but mine seems to be ignored/not run.

Running Drupal 8.5.3 and Commerce 2.6.0


texts: Drupal Commerce cart page to enter items

texts:
I have a website I am working on, and I want to have a shopping cart page that is basically like a purchase order entry form, where a customer can enter the products he wants and then save it or post it, etc. In other words, so you don't have to go through the whole site selecting the products you want like a shopping cart, but rather just enter the item codes like you were writing out a purchase order. The website is for a producer basically and the customers are distributors.

I need to be able to enter products by item code or UPC (need both), and it would be a bonus if each user account could have a list attached to it where the customer could enter their own item codes for our products.

I hope this makes sense, can someone point me in the right direction?


texts:
I would like to create a View that allows me to see where Paragraph Components are being utilised.

It would just need to be a basic tabular View consisting of the following fields:

Paragraph Component Type / Name
Parent Node Title
Parent Node URL

Using exposed filters on the View it would then be ideally possible to filter by Paragraph Type so that you can easily see what nodes / pages are using what Paragraph Component Type / Name.

Is this possible through the Views UI? I have tried setting relationships between the node / field / entity, but can't get it to join up.


texts: add link to edit content in admin top bar

texts:
I'm theming a web site that I haven’t created and I‘ve noticed this useful link placed in admin top bar (see screen shot) :

It provides link to edit / delete content.

How can I place this link on other website ?

I use Admin Toolbar + Adminimal Admin Toolbar with Adminimal 8.

Actually, I have the native menu and it is quite disturbing when you work on theming because it is placed inside content.


texts: Access denied when enabling or setting by default a theme (on Nginx)

texts:
I get an Access denied error page when attempting to enable or set by default a theme. It is kinda weird as I am allowed to perform other admin tasks.

I checked that my user is an administrator and it has all the permissions granted. I also made other checkings that I found in Drupal's forums and Drupal Answers but everything seems to be OK.

I have a standard install with no additional modules. Watchdog logs show the access denied warnings from http://drupal-testing/admin/appearance/enable?token=<...>&theme=encoreweb. In addition to check the permissions of my user, I reviewed settings.php to verify $cookie_domain was commented.

I've found that I'm not the only one with this problem, but I couldn't come to a conclusion.


texts: What is the best slideshow to CCK image field?

texts: I would like to know your suggestions about the best slideshow module to images uploaded from CCK image field. When I mean best, I want to say quality/quantity of features supported according your experience, but if you know another criteria (like support), please feel free to give your suggestion according your criteria.


texts: Drupal How to use regex or specific keywords as menu arguements

texts:
I have a drupal website, in which I wanted to add a new URL. This menu have two arguements which should be passed from the client side.

function campaign_management_menu() {
  $items = array();
  $items['campaign-management/test/%/%'] = array(
    'title' => 'Campaign Management',
    'description' => 'A section where you can manage your campaigns',
    'page callback' => 'cm_home',
    'page arguments' => array(3, 4),
    'access callback' => TRUE,
  );
  return $items
}

Here, for the fourth argument, there should be only two options {add/edit}. Is there any option in drupal to set these two keywords explicitely. ie,

$items['campaign-management/test/%/{add|edit}'] = array(
  'title' => 'Campaign Management',
  'description' => 'A section where you can manage your campaigns',
  'page callback' => 'cm_home',
  'page arguments' => array(3, 4),
  'access callback' => TRUE,
);


texts:
I have this stray node showing up in places (mainly menus) on my site - I don't know how it got created, but I would like to delete it and I can't find a way to delete it from the administration interface.

The url looks like this:

www.organization.com /node/dc436a14-ff7d-4ff8-85f2-ee2b4f9e81ad

and when you click it, it goes to the 404 page.

Anyone know a way to delete this node without having to go into the database?

Thanks!


texts: Using a field for populating the meta-tags of view pages

texts:
I've got taxonomy pages that are emulated by real views. The vocabulary terms have an additional field "field_meta_description", where meta-description tags can be added. On the view page of each term, this field should be used to populate the content of the html tag <meta name="description"/>.
How can this be accomplished? I know there are some modules out there like metatag, but I am looking for a custom way to do it by lightweight self-coding.


texts:
I am trying to create a custom button that modifies a field in a form then saves the form in the same way as the default save button. The following code creates the button but I am having trouble finding where/how to perform the operation that clicking the default save button executes, with validation and updating every field before executing my submit code.

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

     if ($form_id == 'submission_node_form') {
         $form['actions']['final_submit'] = array(
            '#type'   => 'submit',
            '#value'  => t('Submit'),
            '#submit' => array('mymodule_form_final_submit')
         );
     }

}

function mymodule_form_final_submit($form, &$form_state) {

}


texts:
We are currently upgrading a site from 8.4.8 to 8.5.3. After doing so and running our Behat tests the Behat tests seem to randomly fail on node create with an array_flip error:

  Warning: array_flip(): Can only flip STRING and INTEGER values! in /Users/Allison/Sites/devdesktop/secgov-dev/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php line 227 (Drupal\Core\Entity\EntityStorageException)

Even on different runs the node create will sometimes pass and then sometimes fail with the above error.

Has anyone run into something similar?


texts: Ignoring unpublished/published as criteria for "Has new content"

texts:
I have rudimentary Recycle Bin system based on Flags and unpublishing / republishing content. However, when republished, "Has new content" displays Updated.

I still want New and Updated for when there are new comments so I'm not sure of the best way to go about it.

Thanks.


texts: Tpl for page having url like product/checkout/%/%

texts:
I have created a page with hook menu with url product/checkout/%/% where % will be userid and product id.
How can I add a page tpl for this url ?


texts: How to email individual content to email field?

texts:
I have a content type that contains information about people, if these people want this information forwarded to them, I'd like to be able to capture an email in an email field and send the published content to them in an email.

I've been hunting around for a way to do this but can't find anything. Is there a way to do this?


texts: Can't use exit(0), how else can I terminate a response?

texts:
Here's my code(using Drupal 8):

public function checkForRedirection(GetResponseEvent $event) {
    $is_authenticated = $this->currentUser->isAuthenticated();
    $route_name = $this->routeMatch->getRouteName();

    if (!$is_authenticated && $route_name !== "user.login") {
      header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
      header("Cache-Control: post-check=0, pre-check=0", FALSE);
      header("Pragma: no-cache");
      define("SITE", "www.google.com");
      $response = new RedirectResponse(SITE, $this->redirectCode);
      $response->send();
      $exit(0);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = ["checkForRedirection", 30];
    return $events;
  }

So I'm redirecting an authenticated user away from my site. It works perfectly how I want it to, the only problem is PHP Mess Detector doesn't allow the exit(0) function, so wondering what are my alternatives to produce same functionality that exit(0) does here?


texts:
i'm beginning with Drupal 7, and i would like to do a "block" with a picture to the left, a title right to the picture, and a description below the title.

I made a new structure, there is already a field title, and a field body, so i just added a field image.

Then I made a new view containing this new structure, but the problem is that it shows the title, then the picture, then the description.

I think the solution would be to put the title field and the description field into a div block, and then with css, declare the div and the image as "inline-block". How could i do this please?


texts: How to display certain links in a menu only if a precondition is met?

texts:
I've added a checkbox to menu creation so that certain items in the menu will be displayed only if that checkbox is ticked (For test user).

That's the theory anyway.
How can I determine if that checkbox is ticked when displaying the menu on a page?
I assume some hook is involved here, but I can't quite figure out which one.
Any nudging in the right direction is more than welcome.


texts: Can I conditionally hide a route (e.g. action / local task)

texts:
Consider an action button on a custom entity's canonical page:

mymodule.actions.yml:

entity.item.action:
  route_name: entity.item.action
  title: 'Do something'
  appears_on:
    - entity.item.canonical

mymodule.routing.yml:

entity.item.action:
  path: '/item/{item}/action'
  defaults:
    _controller: '\Drupal\mymodule\Controller\ItemController::action'
    _title: 'Do something'
  requirements:
    _permission: 'edit items'

I would like to show or hide the action button depending on the value of some field of the entity.

How could I achieve this? Would it be wise to add custom access checking for this?


texts: How to reset validation errors in ajax callback?

texts: I would like to not validate fields if I submit button with ajax callback. Currently, on every button click it displays validation errors of another fields. The button doesn't submit the form, it does some another action (add more fields).


texts: Error message when deleting folders/files on Maintenance mode

texts:
I turn the site in maintenance mode for update Drupal Core from 7.30 to 7.32. I follow the step on Drupal docmentation to delete all folders and files, beside "site" folder(on step 5). However, I got the error message and warning about missing files. I dont think that how maintenace mode should be. What am i missing?

PS:
1. the site does show in maintenance mode before I delete all the folders and files(beside site folder)
2. Site back to normal after copying v7.32 folders and files(beside site folder)


texts: Drupal 8 entities inheritance and bundles

texts:
I have 2 questions about entities inheritance and bundles in Drupal 8.

Let's assume that I have a content entity called "foo" (entity type) and "foo" as its bundle, and now I want to create the content entity "bar" with the bundle "foo", and add new properties to it. Is it possibile?
Is it possible to use inheritance with content entities, something like the following inheritance (and if so, is that considered to be a bad practice?)
:

class foo extends ContentEntityBase {}

class bar extends foo{}

class baz extends bar{}


texts: Is it possible to return a form element AND an ajax response from the same ajax callback function?

texts:
I have an ajax callback function that needs to return a form element and also an ajax response. Is it possible to do both?
In my callback I need to set and return something like:
$form['fid'] = array(
  '#type' => 'textfield',
  '#value' => 1,
);
return $form['fid'];

And also something like:
   $response = parent::uploadAjaxCallback($form, $form_state, $request);
   return $response;

Is there a way that I can achieve return both a form element and an ajax response?
EDIT: Latest attempt is returning the form element for display but when I examine the $form from the form build function the value is still empty.
class MyManagedFile extends ManagedFile {

  /**
   * {@inheritdoc}
   */
  public static function uploadAjaxCallback(&$form, FormStateInterface &$form_state, Request $request) {

    $response = parent::uploadAjaxCallback($form, $form_state, $request);

    $form['fid'] = array(
      '#type' => 'textfield',
      '#prefix' => '
',
      '#suffix' => '
',
      '#value' => '1',
    );

    $response->addCommand(new ReplaceCommand('#fid', $form['fid']));
    return $response;

  }

}

Examining the $form from the form builder (dpm($form)) results in:
[fid] => Array
(
[#type] => textfield
[#prefix] =>
        [#suffix] =>

    )


texts: Organic Groups module  messes up node editing

texts:
Updated header to reflect real cause of problem

I've created some content types using node references for "belongs to" or "owned by" relationships.

When I add a new node, selecting the node references seems to work fine, and the default "list view" showing the newly created nodes also shows that the relationsship is correct. However, when I try to view or edit a single node, the form displayed includes only the "Title" field, and nothing else. I've also verified through "Manage fields" and "Manage display" that my node reference field is supposed to be displayed, but it still does not seem to work.

Do you have any ideas?


texts: How do I render the 'user_picture' of a user account?

texts:
I load a user object, and I would like to be able to show the user's picture somewhere. I tried the following code.

$row_user = \Drupal\user\Entity\User::load($uid)->user_picture->first()->view('large');

What I get is this (using kint()).

This user has a picture and it is shown correctly in the user page.

How do I exactly show the picture associated with a user account?


texts: I use the User Points module. I've set a rule that add 10 points per content viewed. This was easy. THEN I want to check if user points is greater than 100 and, if it is, send an email to admin, AND set points to that user back to zero.


texts: Users can spam votes and users will get userpoints

texts:
I created the following rule:

Event: User votes on a Материал
Condition: Check the value of the vote, greater than 0
Action: Load points of a user, node:author
Action: Grant points to a user, node:author 1

When a user votes on a node, the node author will get 1 user point. The same user can vote more than once, and the node author would get 1 user point each time.

UPDATE. Solved my issue by myself. Will add link to solution soon.


texts: Get an Un-submitted/Active Form Field Value in $form_state?

texts:
I am unsure how to get unsubmitted/active form field values from a number/textfield into $form_state. field_count could be saved as 4, then is changed to 115, how do I pass that change to $form_state before a submit during $form_state->setRebuild(TRUE);?

/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {

  $config = $this->config('MYMODULE.settings');

  $form['#tree'] = TRUE;

  $form['fieldset'] = [
    '#type' => 'fieldset',
  ];

  $form['fieldset']['field_count'] = [
    '#type' => 'number',
    '#default_value' => $config->get('field_count') ?: 1,
  ];

  // This doesnt get a usable value.
  $form_state->set('field_count_state', $form['fieldset']['field_count']);

  $form['fieldset']['rebuild'] = [
    '#type' => 'submit',
    '#value' => 'Rebuild',
    '#submit' => ['::rebuildFormSubmit'],
  ];

  $form['fieldset'] = [
    '#type' => 'fieldset',
  ];

  for ($i = 0; $i < $config->get('field_count'); $i++) {

    $form['fieldset']['field'][$i] = [
      '#type' => 'textfield',
      '#default_value' => $config->get('field')[$i] ?: '',
    ];

  }

  return parent::buildForm($form, $form_state);

}

/**
 * {@inheritdoc}
 */
public function rebuildFormSubmit(array &$form, FormStateInterface $form_state) {
  $form_state->setRebuild(TRUE);
  // ???.
  $this->messenger()->addMessage($form_state->get('field_count_state'));
}


texts:
I am working on sidebar menu in a Custom Drupal 8 Theme. I am trying to set a class of sidebar__menu--submenu-1,sidebar__menu--submenu-2, sidebar__menu--submenu-3 and so on depending on the level of the submenus.

So far, I was able to add the class sidebar__menu to the first level & sidebar__menu--submenu to all the submenus. However, I want to add the class sidebar__menu--submenu-(number of the level) so I can style & control the sidebar better on css.

Any help will be really appreciate it!

Here it is my code menu.html.twig:

{{ menus.menu_links(items, attributes, 0) }}

{% macro menu_links(items, attributes, menu_level, menu_name) %}
  {% import _self as menus %}
  {%
    set menu_classes = [
      'sidebar__menu' ~ menu_name|clean_class,
    ]
  %}
  {%
    set submenu_classes = [
      'sidebar__menu' ~ menu_name|clean_class ~ '--submenu',
    ]
  %}
  {% if items %}
    {% if menu_level == 0 %}
      <ul{{ attributes.addClass('container mx-auto', menu_classes) }}>
    {% else %}
      <ul {{ attributes.removeClass(menu_classes).addClass(submenu_classes) }}>
    {% endif %}

    {% for item in items %}
     {%
      set classes = [
        'sidebar__item',
        item.is_expanded ? 'sidebar__item--expanded',
        item.is_collapsed ? 'sidebar__item--collapsed',
        item.in_active_trail ? 'sidebar__item--active-trail',
      ]
      %}
      <li{{ item.attributes.addClass(classes) }}>
        {{ link(item.title, item.url) }}
        {% if item.below %}
          {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
        {% endif %}
      </li>
    {% endfor %}
    </ul>
  {% endif %}
{% endmacro %}


texts:
When using $link = $_SERVER['QUERY_STRING']; in page.tpl.php the result of print is:
f1=All&f2%5Bvalue%5D%5Byear%5D=2009&f2%5Bvalue%5D%5Bmonth%5D=1
Is there a way to correct the url to print as:
f1=All&f2[value][year]=2009&f2[value][month]=1
Thanks.


texts: 8.4 - Use entity browser in a module block from in same way as I would in a custom block

texts:
I am having trouble adding an image picker to a block form defined in a custom module.

If I create a custom block type I can define an image field as entity_reference and in the block's form view tell it to use entity_browser and media_entity_browser.  This provides me with an picker with which I can select my image:

I am trying to recreate this in a block provided by my custom module, without much success

// /src/Plugin/Block/MyCustomBlock.php

function blockForm($form, FormStateInterface $form_state)
{
    ...

    $form['image'] = [
      '#type' => 'entity_browser',
      '#entity_browser' => 'media_entity_browser',
      '#title' => $this->t('Image'),
      '#default_value' => $this->configuration['image'] ?? null,
      '#weight' => '0',
    ];

    ...
}

This gives me the following.  Note the lack of the bounding box, title and option to edit remove items:

Exporting the configuration files for the working form view gets me this:

// core.entity_form_display.block_content.lead_block.default.yml

...

field_image:
    weight: 1
    settings:
      entity_browser: media_entity_browser
      field_widget_display: rendered_entity
      field_widget_edit: true
      field_widget_remove: true
      selection_mode: selection_append
      field_widget_display_settings:
        view_mode: default
      open: false
    third_party_settings: {  }
    type: entity_browser_entity_reference
    region: content

 ...

But if I try and use 'type' => 'entity_browser_entity_reference' in my blockForm function the field disappears altogether.

Looking into various core files I can see that entity_browser is a @FormElement and entity_browser_entity_reference is a @FieldWidget but I don't really understand the difference.

As you might guess I am fairly new to Drupal and I feel like I am missing something fundamental.  I (think I) understand that custom block types are actually nodes internally and that they are subject to different rules to blocks which I define in my custom modules, but I don't fully grasp what the differences here are.

Is is it possible to use the entity browser in my custom module block form in the same way as it is used in the form which I build through the admin's custom block type builder?

Thank you.


texts:
I have a simple class to which I am providing some values via constructor and I would like to use DI. This class has no relation to Drupal(not a plugin, form, entity,...).

It serves as a wrapper for dataset where I need to do some data manipulation by using few services.

I wanted to use the ContainerInjectionInterface but it only has the create() method and it does not look like it can be used for this purpose.

Can the DI in D8 even be used for this purpose?


texts: Detecting a form change. Is jQuery the way to go?

texts:
I have got a form with quite a lot of checkboxes (can go up to the 100's) in a table and I would like to detect if a checkbox has been clicked by the user.  If they have, I would like to automatically display a warning in the form informing the user that they need to save the form if they want the changes to take effect.  Similar to how the draggable tables in Drupal work.  Anytime, a form element changes, then, show a warning.

My question is, will using jQuery to attach a change event on each checkbox take a major performance-hit?  Is there a faster Drupal way to do it?  Will using the Drupal way, make performance faster?


texts:
I have products that are being sold through Ubercart - there are different kinds and different sub-kinds of products. These types are based on taxonomy so a product will be type "Card" and sub-type "Childrens".

For instance I want .com/cards to show all products that match "Cards" and I want .com/cards/children to show all products that match both "Cards" and "Childrens".

For each type and subtype I want there to be a page that shows only suitable products - I can do this using Views but I have to set up a filter that matches the correct types/sub-types. Since I plan on adding various types/sub-types in the future and don't want to add new views for each individual type is there a way to relate this to the URL in some manner?

How do I go about doing this with Contextual Filters? I know this is possible but I think I'm just having a total brain fart over it.


texts: How to validate a file upload field added to a form using hook_form_alter?

texts:
I am trying to add a file upload field to all story node forms. I tested the code and I am successfully getting the file upload field  on the form.

$form['my_file_upload'] = array(
    '#attributes' => array('enctype' => 'multipart/form-data'),
  '#type' => 'file',
  '#title' => t('Image'),
  '#description' => t('Image should be of minimum 50x50px width and should be of type png or jpg'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  '#size' => 48,
  '#weight' => 4,
);

Now the question is How do I validate the file and also how do I retrieve the file after it has passed validation?

(Site runs on Drupal 6)


texts: How to use function like 'rtrim' in drupal?

texts:
I need to remove extension from string, i'm wondering what function could do that ?

Some like the rtrim($string,'string to remove')

$string could be the filename

I've added a file into database, now to retrieve it, i want to remove the extension '.epub'

this is the postman response :

{
 "code": "0",
 "response": [
{
  "epub": "http://localhost/drupal/sites/default/files/moby-dick.epub",
  "f_id": "5",
  "uid": "64"
   }
 ]
 }

I want to retrieve :

"epub": "http://localhost/drupal/sites/default/files/moby-dick",<== no .epub

This is my first try :

$file = file_load($fid);
            //$realURI = drupal_realpath($file->uri); ca marche

            $realURI = file_create_url($file->uri);
            $new = drupal_basename($realURI, '.epub');
            $n = file_create_url($new);
            $res->epub = $realURI;<== show the new (without .epub)

but now it shows :

"epub": "http://localhost/drupal/moby-dick"

I need to keep /sites/default/files/ because the file is there
What can i add for keep it work with the right path please

Thank you


texts:
When using Panels module I have noticed that one of the ajax calls is creating an url with colon inside :

For Example :

dev-www.redbusbingo.com/panels/ajax/editor/select-content/panel_c

%3A = :

The problem is that iis Dont know how to Handle ":/" , or to say this colon in the end of string

This case break the site with error 500 .

500 Error Case : "dev-www.redbusbingo.com/panels/ajax/editor/select-content/panel_c" ( Colon at the end Before "/")

Good Case :

 "dev-www.redbusbingo.com/panels/ajax/editor/select-content/panel_c" ( NO colon at the end Before the "/")

Is there any way to replace this colons ?

Just to say i have reported this bug to Microsoft and they said that this a security issue and because of that they will not allow colons in the url .

Currently i can't work on my site because of this error and my iis ,
Please assist me with this .

Thanks
Haniel


texts: ubercart checkout review button position

texts:
I use drupal 6 and ubercart 2.

I would like to change position of the checkout button on checkout/review page to the top or possibly to duplicate it (it is currently on the bottom of the page which is not very user friendly)
I found a function in uc_cart.pages.inc called

function theme_uc_cart_checkout_review($panes, $form)

Inside on the bottom I found the code for review button

$output .= '
'. $form
        .'

';

However, moving the code above the table code, breaks whole page. (I tried this inside the .inc file, because adding the function inside template file, I got an error) What would be the correct way of achieving my task? Thank you


texts: How to get the untranslate original string?

texts:
In a form, there a submit button:

  $form['previous'] = array(
    '#type' => 'submit',
    '#value' => t('Modify')
  );

In the form _submit function:

  switch($form_state['values']['op']) {
    case 'Modify' :
      // ...
      break;

the case 'Continue' will not match if Modify is translated. How can I always get the original untranslated Modify string for the sake of string comparison?


texts: How do I call an implementation of hook_form_alter()?

texts:
I have a function in my module that implements hook_form_alter(): function getuserform_form_alter(&$form, $form_state, $form_id).

How do I call it? How do I pass it the required parameters?


texts: How to use Twitter Bootstrap with panels?

texts:
I am using D7 to built a new site. I am using Twitter Boostrap to create responsive themeing in my site. But most of my design has to be built with panels, the panels does not work responsive with the twitter bootstrap. I found that adaptive theme can be used with panels to make it responsive, But my requirement is to use twitter bootstrap for responsive themeing.

Is there an chance by which I can make the panels responsive with the twitter bootstrap?

Thanks.


texts: How to remove "site email address on behalf of" and just keep the sender email address in "from:" part of a mail from drupal 7

texts:
I am getting from part of a mail sent from my drupal 7 website like below

From: (site mail address) On Behalf Of (sender mail address)

Here I want to remove everything except sender email address, how can I do this?

I have found following url but it is expired

http://www.fosspedia.com/drupal-remove-on-behalf-of-from-the-sent-mails/

Any help???

Thanks


texts:
1- I tried to set an error message in Drupal 8 from javascript with the new Messages API using the following code:

const messages = new Drupal.Message();
messages.add('test message');

I get the following error on the console log:

drupal.js?v=8.8.5:13 Uncaught TypeError: Drupal.Message is not a constructor.

How can I include this API?

2- As I can see in message.es6.js, there is an option to set message type: error, warning and status. How to pass these params once I get the function working?

Reference Documentation: https://www.drupal.org/node/2930536

Thank you.


texts:
I've been using this code from drupal.org to add javascript to a page node.

    function example_preprocess_html(&$variables){
       if(arg(0) == 'node' && arg(1) == 585) {
         drupal_add_js(drupal_get_path('theme', 'theme_name') . '/js/accform.js');
       }
    }

What I want to do is add the javascript based on page and sub pages with it.

Example: www.example/about and www.example.com.about/directions

Is a way to do this in the existing code?

https://www.drupal.org/node/304178


texts: Show View When Empty and Hide View When Not Empty!

texts:
I have a webform as a block which sets a value connected to the logged in user. I want to display the webform if it hasn't been filled in yet by authenticated users, and hide it when it has (based on whether the value has been set or not).

I thought I could do it by using views with the Views Block Area to display the webform as a block when there is no result. But I want to hide the view when there is a result, which seems impossible?

If anyone can suggest how I might be able to achieve this, not necessarily using views.


texts: Theming custom field directly in custom module folder?

texts:
we're trying to build a template for the custom field we developed. We don't want to put the template into our theme folder since the template should work between different themes. As far as we know we have the option of putting a custom field.tpl.php somewhere or override theme_field() in our module. What we've been trying with naming these files/functions kind of didn't work out and now we need your help. :-)

What's best practice with building templates / templating for custom fields, where to put it and how to name it?

Thanks! :)


texts:
is there a way to show content from an external URL (e.g. from GitHub) in a page?

I was using PHP code but because of security reasons I would prefer to use a module instead.

$c = curl_init();
curl_setopt($c, CURLOPT_URL, "https://raw.githubusercontent.com/foo/bar/master/file1.txt");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);

I am looking to something similar to https://www.drupal.org/project/url_embed but without WYSIWYG. I just need to add some tags with the URL in the appropriate place on the page to display it.


texts: Commerce product variation with different variations

texts:
I'm still pretty new to Drupal Commerce so I don't know if it's possible to group different variations under a product variation. This may sound weird, so here is an example of a grouped product variation.

As you can see the different product types have common values. The networking one has all values. So this is what I would like to achieve:

Create one product variation called transmission
Have the option to select the product type

The selection you made in the product type column will change the values you need to fill in.

Is this possible? Or would there be an other recommended solution to group like this. I would like to prevent that I have to create variations for each product type.


texts:
I am attempting to send an email to a field selected value using the Rules module.
The user selects a faculty member and saves the node. The rule should fire off and email based on the field's key. I have the field set up as:

  john@email.com|Doe, John

I am attempting to send to the key using [node:field-advisor-:key] as a replacement pattern. But I think it's still trying to send to the label.

I am still very new to Drupal so my vocabulary and skills are relatively limited.

Here is the exported rule:

  { "rules_email_to_adviser" : {
  "LABEL" : "Email to Adviser",
  "PLUGIN" : "reaction rule",
  "OWNER" : "rules",
  "REQUIRES" : [ "rules" ],
  "ON" : { "node_insert--timeclock" : { "bundle" : "timeclock" } },
  "IF" : [
        { "user_has_role" : { "account" : [ "node:author" ], "roles" : {
        "value" : { "20" : "20" } } } },
       { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_advisor_" } }
    ],
  "DO" : [
    { "mail" : {
        "to" : "[node:field-advisor-:key]",
        "subject" : "Time Card Submitted for Review",
        "message" : "[node:author] has submitted a time card for your approval. \r\n\r\nPlease review the time card at: [node:edit-url]\r\n\r\nThank you.",
        "language" : [ "" ]
      }
    }
  ]
  }
}

Notes:

All of the faculty members (such as "John Doe") have accounts on the site.
If it would help (simplify things) to make the rule work, I'm OK with replacing the implementation of that field_advisor_-field by a more appropriate field (with similar functionality).


texts:
I altered the node form and added an manage_file-field; then, I added a callback on the #entity_builders property.

$fid = $form_state->getValue('file')[0];
$file = File::load($fid);

$file->setPermanent();
$file->save();

// $node->set('field_file', $file);
$node->field_file->setValue([
  'target_id' => $file->id(),
]);

However this gives me the following error:

  The file used in the File field may not be referenced.

At this point, I cannot use file_usage, since the node is not yet saved.

How can I solve this?


texts: Using as shipping address the value entered as billing address

texts: In Drupal Commerce 2 how can we allow a customer to select as shipping address the same address entered as billing address?


texts:
How can I override link title in the local tasks menu?

I tried like this, but didn't work:

function mymodule_menu_local_tasks_alter(&$data, $route_name) {
  // Override 'Revisions' label menu link
  $data['tabs'][0]['entity.node.version_history']['#link']['localized_options']['attributes']['title'] = t('View history');
}


texts: How to set the views exposed filters default value programmatically?

texts:
I have a view which has a term reference exposed filter.

I want to set the default values of this exposed filter programmatically based on a certain condition.

I have tried the following code but the values are not selected in the filter.

function example_views_pre_build(&$view) {
  if ($view->name == 'events') {
    $tids = array(5, 6);
    foreach (tids as $tid) {
      $view->display[$view->current_display]->handler->handlers['filter']['field_category']->value[$tid] = $tid;
    }
  }
}

AND

function example_views_pre_view(&$view, &$display_id, &$args) {
      if ($view->name == 'events') {
        $tids = array(5, 6);
        foreach (tids as $tid) {
          $view->display[$view->current_display]->display_options['filters']['field_category']->value[$tid] = $tid;
        }
      }
    }

I also tried with form_alter, in form alter the values gets selected in the filter but then it does not display correct results after removing/applying again the filter.


texts:
In the Rules module, is it possible to write php code in mail body?
There is no input format beneath body text area.


texts: Pass value of a field to another content type in Drupal 7

texts:
I have a content type 'Exhibit' with fields 'uuid'(text with single value), 'name'(text with single value), 'description'(long text and summary), 'section'(text with unlimited values). I have used views to display 'Exhibit' in table format.

Now when i click on Add section. I want the field Section in Exhibit view to be uuid values in Section content type. I want the uuid values as a drop down . so that customer can select one uuid and enter the details for that uuid. How can i achieve this? Please help.


texts: Allow users to choose from multiple avatars while registration in drupal 7

texts: Currently I am working on a website registration page and I want a new user to select a default avatar from a given list if they have not uploaded a profile image while they are registering. I am using drupal 7 so avatar selection module is not compatible with this version so can you kindly suggest me some other way out


texts: Create taxonomy terms from content type field

texts:
I'm looking to add a taxonomy term to a vocabulary upon the creation of content type.

For example I have a taxonomy vocabulary called "Widget Type".

I have a content type of Product. When I create an instance of product I would like the title (product.title_1) to be added as a taxonomy term to Widget Type.

Then every time a new product is created a term is added.
Widget Type would then contain the terms...
title_1
title_2...etc.

Does this require a custom module or is there an easier way to do this that I'm not aware of?

Thanks


texts: How to ignore specific Drupal release in update notifications?

texts:
I'm using Drupal 7.28 and getting this message:

  There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately! See the available updates page for more information and to install your missing updates.

Sadly, there is a critical bug in 7.29 that makes this particular release totally not workable for me. No way I'm installing it, it's that simple. I'll either apply some of 7.29 patches manually, or wait for 7.30. Thus, I don't want to be bothered with release I know I will not install. How can I make my Drupal ignore it? I do want to be notified when 7.30 is ready, so simply turning off all messages about updates is not an answer I'm looking for.


texts: Disclaimer screen when adding new content

texts:
I'm looking for a way to have a disclaimer page/popup be a part of creating a certain type of content, in this case a OG group. Is this something that could somehow be done with Webforms?

I found http://drupal.org/project/legal but it just doesn't quite do the trick... Any other ideas? :)


texts:
I want to override and use page.tpl.php from within my module. I think I can do this with hook_theme_registry_alter(). So I don't want Bartik to override this, however, I want a sub theme of Bartik to be able to override it and use its own implementation of page.tpl.php, if it exists.

How would I do this? Do I put a condition in hook_theme_registry_alter(), if so, how can I tell if the current theme is a sub theme of Bartik?


texts: By default, in Drupal 7, the "Submitted by" date type is set to Medium.  I want the "Submitted by" date to be rendered using a different type.  How do I do this?


texts: how to connect to database in drupal in order to display the content in a table

texts:
I am using drupal in order to create a website on my localhost machine.

I have a mysql database that i want to connect it  to the drupal website and display its data in a table.

and in the drupal I download the Views Database Connector (VDC) module in order to  connect to the external database.

but it did not work .

second method  I used views and created content types that are the fields table of the  external databases.

but I do not know how to continue to display the data.

third method  I created the tables in drupal database and want to display  its content .

I am new to drupal so I want  any of these method to  work for me

note  feeds module  also did not work because its not set up yet on the drupal 8.x


texts: Drupal commerce - purchase a product at registration

texts:
I'm trying to use Drupal Commerce for a subscription site that will have only one product to purchase - a subscription to a service.

I'd prefer if a user could either do product subscription as a part of user registration, or immediately be redirected. Currently I'm trying the redirection with a rule to a custom order page (which I'm creating with rules), however rules doesn't seem to know what the order id is of the created entity.

So I'm either looking for a way to fix that, or another solution that I may have missed. Basically I want registration to be the easiest thing possible.


texts:
I'm working on a controller that queries a table based on the value in a route parameter

Example route path:

path: '/path/{parameter}'

Controller:

  public function myFunction($parameter) {
    $connection = \Drupal::database();
    $query = $connection->select('my_custom_table', 'mct');
    $query->condition('mct.col', $parameter, '=');
    ...
    $result = $query->execute();
    $records = $result->fetchAll();

Is there any sanitization that should occur in this circumstance or does the database API take care of this?


texts: Should I share the same image style as much as possible or create different styles for each size?

texts:
I have an image field displayed in slightly different sizes.

Let's say :

100px X 100px as a view field format
120px X 120px as another view field format
150px X 150px as a node view format

My question is :

Which is the best practice ?

1.
Creating three different image styles for each size.

2.
Creating just one image style and share it (Fixing the size accordingly by CSS)
For example, create just the image style of 150px and then make it smaller for 100px and 120px by CSS

Why I wonder is :

1 obviously creates more files but 2 uses unnecessary bigger files for 120px and 150px


texts:
I'm creating custom theme. I am struggling to create main menu with drop down. I created a menu with custom code:

 <?php
            $main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
            print drupal_render($main_menu_tree);
          ?>

But it doesn't working as I want. I need to add class in that particular <UL> tags. How can I achieve that?

I tried to Hook custom function in templates file. But no luck. How to call custom function into view page?

Below are some more screenshots.

Main menu with correct:

Menu with Wrong:

How to call custom menu design in custom theme?


texts:
Me again with the noob question.
I want to achieve this:
At the url http://ROOT/something/{numeric_id_here} to get a page that lists the header and the footer of the theme and my custom content. The content is not manage-able through the admin. It depends on the numeric id.
Here is what I got so far.
I use the hook_menu for this:

function something_menu() {
    $items['something/%id_here'] = array(
        'title' => 'Some title',
        'type' => MENU_NORMAL_ITEM,
    );
    return $items;
}

I have the function that parses the url and gets the numerical value:

function id_here_load($arg) {
    $data = get my custom data from an external xml feed based on $arg; //this works nicelly - I get an array with the data I need.
    //WHAT'S NEXT?
}

Now I'm stuck. how can I pass $data to a template and render that template in the content of the page?
My question is somehow similar to this one. Just that the answers provided there don't cut it for me.


texts:
So I have got a base theme that is being used across multiple sites, but am wanting to add subtle tweaks to certain sites and was wondering what would be the best way to go about it.

I have created a sub-theme, which works fine. But, in order for it to work I need to bring all the files over from the parent theme, although I'm only changing the CSS. I thought it would use the files in the sub-theme and any files not in that folder just use the parent themes files.


texts: How to link two content types from each other

texts:
I have content type A and content type B. Users need to be able to link between them while creating either content type (A or B). When they link them up I would like it to be saved in one table. Currently using something like node reference would put it in two different tables.  Know of any module or functionality that can do that?

Clarifying
I want a user to be able to go into content A and save a reference to content B. We also need a user to go into content B and save a reference to content A. Ideally both references would be stored in one table as a many to many relationship.


texts:
On Drupal 7, I am trying to create a different version of the default taxonomy template file for a theme. When a user clicks on a taxonomy term, the new template file is used instead of the default one.

So far all I have managed to do is finding the correct template file name (page--taxonomy.tpl.php). The problem that I have is that the variables copied from the template file the Taxonomy module uses simply don't work, as they are obviously not being populated.

<?php if ($content = render($page['content'])): ?>
  <div id="taxonomy-term-<?php print $term->tid; ?>" class="<?php print $classes.' channels-'.strtolower(str_replace(' ','',$term_name)); ?>">
    <?php if (!$page): ?>

<a href="<?php print $term_url; ?>"><?php print $term_name; ?>

    <?php endif; ?>

      <?php print render($content); ?>

<?php endif; ?>

So any variable beginning with $term is NULL. What/where do I call to populate these?


texts: Can I temporarily stop update notifications for one project only?

texts:
Is there a way I can tell Drupal not to notify me about a particular version of a module? For example, if it isn't security related and I choose not to update one module but would like to receive notifications about other modules (or future versions of the module in question)?

The Drush command from one of the answers to this question is close to what I want except if there are future security updates I would still like to know about it, just no more notifications for this particular version.

drush pm-updatecode --lock=module_to_ignore


texts:
I'm using Drupal 7.56..
I want to upload images from other urls..
I use:

$image_original_path = '.. here my original path..';
$my_destination = 'sites/default/files/images/';
$my_new_name = 'my_image.jpg';
$filename = $my_destination.$my_new_name;
$image_object = file_get_contents($image_original_path);
$file = file_save_data($image_object,  $base_url.'/'.$filename, FILE_EXISTS_RENAME);

But the image is not uploaded..
Any idea please?
Thank you..


texts: Error when using LDAP Views within Rules

texts:
My objective is to pick a user from an ldap and then create his drupal account.

In order to do this,

1) a user picks a name (dn) from an LDAP server using the LDAP Entry Reference module (which offers autocomplete search)

2) after the user has completed his input, I use a Rule to create the drupal account :
 - dn enables me to search the LDAP with a "View Loop" and get the email
 - with the name and the email, the rules can create the drupal account.

I use LDAP Query and LDAP Views to build the view.

The problem is that the View Loop returns empty results although the views results are correct if I use the views from UI.

I have tested the view with no parameter, no filter, simple LDAP Query, minimalistic ldap (3 users in the LDAP).
My connection to the LDAP is OK : new users can log in with LDAP before drupal account creation : all this is OK.

Do you know of such an error using LDAP Views as a Rules View Loop ? or could you advice how to debugg ?

Or do you know another way to achieve my goal ? (pick a user from ldap then programmatically create the drupal account ?)

my need is exactly what is described here : https://drupal.asu.edu/resources/docs/modules/asu_userpicker . But the module is not available at this url and is designed to be used with other tools.

Thanks


texts: theming form of block subscription newsletter module

texts:
someone could tell me how to form theming block newsletter subscription module,
I use the bootstrap theme and I want to change the markup and add some classes css


texts:
Sorry if my question seams trivial, but I wonder if it is actually possible.

In Drupal 7, with the i18n module I can easily translate a content entry, but from this, I feel like it creates a fork of my language source content. So my update on the source language are no longer reflected on the translated content.

Example:
I have a content defined as an image plus a text field.
I want only the text field to be translated, not the image. Can I do that?

I have the situation with a website with many languages, I would prefer if I don't need to update all the images for each language whenever I want to update the image.


texts: Retrieve the list of posts for a particular forum

texts:
From this question, I know how to retrieve a list of forum posts (forum topics?) from drupal.

curl -i -X GET  \
 -H Cookie:SESSe6a353351df0bcafe98787beef=B0YAHD3-reWwwW-kzhqw6A-SgeShSYUAAQQjh \
 'http://myserver/rest/node?parameters\[type\]=forum'

Now, I'd like to limit the list of forum posts to those belonging to a particular forum.  How do I filter the result by forum? I know the forum tid. I just don't know how to format the query.

This doesn't cut it:

curl -i -X GET  \
 -H Cookie:SESSe6a353351df0bcafe98787beef=B0YAHD3-reWwwW-kzhqw6A-SgeShSYUAAQQjh \
 'http://myserver/rest/node?parameters\[type\]=forum&tid=4'

The above returns all forum posts. This also does not work:

curl -i -X GET  \
 -H Cookie:SESSe6a353351df0bcafe98787beef=B0YAHD3-reWwwW-kzhqw6A-SgeShSYUAAQQjh \
 'http://myserver/rest/node?parameters\[type\]=forum&parameters\[tid\]=4'

It gives me:

  "Invalid query provided, double check that the fields and parameters you defined are correct and exist. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tid' in 'where clause'"

I get the same error if I try to reference parameters\[taxonomy_forums\]

Any help?


texts:
I've a site with a main menu, and submenus as block. If I'm on node "50" I want to hide every submenu, except the submenu with the link to node "50".

Question: How can I hide a block based on it's variable menu_name (I think it is this variable) without javascript.

Here's a wireframe, so you can get an overview.


texts: Flexslider views messing up my other images styles

texts:
Installed flexslider and the flexslider views module.
But when in enable them my other image styles don't work no more.
In my view everything (image style) is ok.
But on my page it doesn't work.
www.thewizard.eu
Someone advise?

Thanks,
Tom


texts:
I need to re-save about 300 user to initialize geo-coding on their address fields. On /admin/people, I don't see any bulk action that would fit my needs. I have tested the update path-alias but with no luck.

Also, the VBO module for Drupal 8 doesn't offer a solution for users, AFAIK.

Any help is appreciated.


texts: Open a pop-up/modal window after add/edit node to share

texts: I'm using Social Share to generate share links on my nodes but I want the user to be prompted to share after adding and/or editing a node. Is there any possibility of creating a pop-up/modal window that contains those links after the add/edit window has been submitted?


texts:
Possible Duplicate:
  Clean way of building simple taxonomy browser of arbitrary depth

I have a multilevel taxonomy, like following:

term1
-term1.1
--term1.1.1 - node1
--term1.1.2 - node2
-term1.2
--term1.2.1 - node3
--term1.2.2 - node4
term2
-term2.1
--term2.1.1
---term2.1.1.1 - node5
---term2.1.1.2 - node6
--term2.1.2 - node7
-term2.2
--term2.2.1 - node8
--term2.2.2 - node9

I want to display on one page all main terms:

term1

term2

Each term should link to another page with the child terms, who have to link to the next page, etc untill the corresponding node is displayed.

I tried to do this with the taxonomy module, but then I create a collapsed menu tree, that's not what I want. Each page may only show the terms of the same level from the same parent.

I found some solutions with views on the internet, but I really don't understand how to solve this. Something with contextual filters? I would really appreciate some help or  some hints.


texts:
I have stock commerce module which is very handy. When item reaches 0, it will say out of stock in the page. However, in the main page where I list the products and small thumbnails, customers don't know if it is sold out or not, unless they click it.

I have seen sites where a small red sign saying out of stock is automatically generated overlapping the preview picture. So at one glance customers know it is out of stock without being annoyed by clicking on it.


texts: AJAX button - HTML in #value causes problems

texts:
i have an Ajax button, the code looks like this:

class coolButtons {
  public function getFormFieldAjaxButton() {
    return [
      '#type' => 'submit',
      '#value' => t(' Ajax Button'),
      '#name' => 'ButtonAjax',
      '#submit' => ['ajax_submit'],
      '#ajax' => [
        'callback' => 'ajax_callback',
        'wrapper' => 'button-fieldset-wrapper',
      ],
      '#attributes' => ['class' => ['btn-primary btn-sm']],
    ];
  }
}

function cool_form ($form, &$form_state) {
  $buttons = new coolButtons();
  $form['fieldset-buttons'] = [
    '#type' => 'fieldset',
    '#title' => t('Buttons'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#prefix' => '
',
    '#suffix' => '
',
  ];

  $form['fieldset-buttons']['button_ajax'] =
        $buttons->getFormFieldAjaxButton();
}

function ajax_callback($form, $form_state) {
  if ($form_state['triggering_element']['#name'] == 'ButtonAjax') {
    return $form['fieldset-buttons'];
  }
}

function ajax_submit($form, &$form_state) {
  if ($form_state['triggering_element']['#name'] == 'ButtonAjax') {
    drupal_set_message('You clicked a very cool ajax button!');
  }
}

The value of the button has HTML in it, which causes problems.

1.) I can't have more than one of these buttons with html in the #value in one form, because then every button will perform the first defined statement in ajax_callback and ajax_submit regardless of the if statements (and thus, regardless of fieldset, #name etc.).

2.) At the bottom of the form, text will appear in the following form:

Ajax Button" />

Is there a way around it, or is the only solution to not use HTML in the #value of the buttons?

I am using Drupal 7.

Edit:

The slightly altered functions in rdp_cellmodel.module:

/**
 * Implements @see \hook_theme_registry_alter().
 */
function rdp_cellmodel_theme_registry_alter(&$theme_registry) {
  drupal_set_message('Boop?');
  if (isset($theme_registry['button'])) {
    $theme_registry['button']['function'] = 'rdp_cellmodel_button';
  }
}

/**
 * TODO: Description
 *
 * @param $variables
 *
 * @return string
 */
function rdp_cellmodel_button($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'submit';
  element_set_attributes($element, array('id', 'name', 'value'));

  $element['#attributes']['class'][] = 'form-' . $element['#button_type'];
  if (!empty($element['#attributes']['disabled'])) {
    $element['#attributes']['class'][] = 'form-button-disabled';
  }
  if (!empty($element['#glyphicon'])) {
    $glyph_name = $element['#glyphicon'];
    return '<button' . drupal_attributes($element['#attributes']) . ' /> '.
      $element['#value'] .'</button>';
  }
  else {
    return '<input' . drupal_attributes($element['#attributes']) . ' />';
  }
}

And here the form field in a class file:

/**
   * @return array
   */
  public function getFormFieldGeneratePreview() {
    return [
      '#type' => 'submit',
      '#value' => t('Preview Name'),
      '#name' => 'PreviewButton',
      '#submit' => ['ajax_submit'],
      '#ajax' => [
        'callback' => 'ajax_callback',
        'wrapper' => 'hpscreg-fieldset-wrapper',
      ],
      '#attributes' => ['class' => ['btn-primary btn-sm']],
      '#limit_validation_errors' => [],
      '#glyphicon' => 'refresh',
      '#suffix' => '

',
    ];
  }

Edit 2:


texts:
I've this code who show the number of users who 'flagged me' (I'm using flag module)

$flag = flag_get_flag('poke');

if ($flag) {
  print "The number of people who voted for this proposal:";
  print $flag->get_count($user->uid);
}

I want to show a list of the user name instead.

Thanks for your help !


texts: Select fields with group names in Drupal 7?

texts:
When you make a select list on a webform module you get the option to group values by a group name or category: "Option groups for lists and menus may be specified with . <> can be used to insert items at the root of the menu after specifying a group." Reference : http://drupal.org/node/325766 -> "Entering options through the interface"

Is this something I can do with the defualt node select fields aka (list module) ie. http://drupal.org/documentation/modules/list ? I have never heard of it but it would be nice. I have to make a list of working group positions on my site and I have 3 groups each with it's own group name, Hospital, Dental and Physicians and I am trying to figure out the best way to list these groups and their positions in a nice select value widget, I was thinking of using taxonomy but it's not really the same thing as what I want.


texts: Using entity query build to select entities applying conditions on all revisions

texts:
Background

Best practice deems that you should use EntityFieldQuery (d7) for making queries that somehow involves fields on entites.

An example of such a query could look like this.

$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')
  ->fieldCondition('field_foo', 'value', REQUEST_TIME, '>')
  ->execute();

In the above example, we are looking for nodes which has a timestamp value set in the future, it works just fine and all is good.

Question

Is it possible using these APIs (which handles that fields potentially could be stored anywhere), and apply the condition on all revisions, instead of only the active revision?

When using SQL, you could make a custom query on the field_revision_FIELDNAME table, but doing this would require you to make some database assumptions and break best practice.


texts: How to grant edit access for specific nodes to 1 or more selected users?

texts:
I am building a school site on Drupal 8.  Among others, I have two content types, one for teachers, one for courses.  Teachers also have user accounts and belong to a role, say 'teacher'.

I want teachers (authenticated site users who belong to the 'teacher' role) to be able to edit the pages of the courses they teach.  The problem is, there are courses which are being taught by more than one teacher, hence I can't solve this simply by enabling 'edit own content' and have them as owners.

So all in all, I want to give 'edit access' for specific nodes, to specific, sometimes multiple, users.

I researched before asking this fairly simple question.

There is a very similar question here - however its four years old, and the node access module which is suggested as a solution is not usable for Drupal 8 yet.

There is a mention of another module, flexi access, but that is only available for Drupal 7.

There is also a link to ACL, "an API for other modules to create lists of users and give them access to nodes", but that in itself is only in pre-release for Drupal 8, and a module which seems to be using it, Content Access has open security issues (and also is in pre-release status).

Searching around, I also found Permissions by Term module, seems stable and very well documented, however I didn't find it very intuitive to be honest, and also it seems to cater basically for restricting view access to nodes (as suggested here, but also from its video tutorial).

I want something simpler.  And I obviously want all nodes to still be publicly viewable by anyone (even anonymous users, of course).  So although Permissions by Term seemed a possible choice, I don't know if I can/should use it.

There is also the Group module which is frequently referenced, but that also seems an overkill and way too complicated for the simple task I want to accomplish.

I 'm a bit lost on this one .. It seems quite simple, yet I can't find a way to do it.  Any help would be greatly appreciated ...


texts:
Hello im playing about with my node.tpl so as i can show the title of a video below the video ala youtube. Ive managed to sort that ok but my body field was showing above the title still so i rectified that with

<?php print $node->content['body']['#value'];?>

Now im going to remove the print content bit from my node.tpl but that will mean no video.

could anyone advise on how to display the video field?

Im presumming i need to add some code which shows the fields and then print out the field.

This is where i am stuck.

thanks

(drupal 6)


texts: Using Drupal Commerce Product Reference Field, missing products

texts:
I've followed instructions here: https://drupalwatchdog.com/volume-1/issue-1/building-drupal-commerce-product-display

When I create my Product Display, the list of products to choose from is missing most options, as can be seen here:

I have many more products under "Dips" added, but they aren't showing up. Any ideas why?


texts: Drupal 7 website on my hosting-“Fatal error: Undefined class constant ‘MYSQL_ATTR_USE_BUFFERED_QUERY’

texts:
I can’t transfer a Drupal 7 website on my hosting place due to the following error.
“Fatal error: Undefined class constant ‘MYSQL_ATTR_USE_BUFFERED_QUERY’ in includes\database\mysql\database.inc on line 46”

  My hosting server is Godaddy windows plan.

For this issues, i found the following solution,

  Please make sure PDO, PDO mysql is correctly installed. Also
  php_pdo_mysql should be enabled. You can do this by uncommenting
  extension=php_pdo_mysql.dll in php.ini and restarting apache.

But when i contacted the support system ,they gave the following reply.

How can we over come this issue by adding a php.ini file in root?Could you please show me the sample ini here.?

  Go Daddy Support 5/3/2013 1:02 pm Dear Mohd,

  Thank you for your reply. Please note that we cannot modify the server
  settings of the plan you are hosting on. If you need to modify the
  configuration of your plan you will need to do so through the php.ini
  file in the root of your hosting plan.

  Please let us know if we can assist you in any other way.

  Regards, Eddie P. Online Support

  Mohd Qureshi 5/3/2013 5:04 am Dear Ashley,

  PHP.ini is located in your Apache server and we have no access to this
  files.You are only authorized to make any changes in Apache server
  files.We cannot override your php setting by adding my php.ini file in
  the root folder.

  Please check it with a tech guy and resolve my issue asap.

  I don't like to argue with you.

  Please do reply asap.

  Go Daddy Support 5/2/2013 7:10 pm Dear Mohd,

  Thank you for contacting Online Support. I understand that you are
  trying to move your website to your hosting account with us. Your
  php.ini file is not a file we can create or update for you. It is a
  file you will need to create and add to your hosting account.

  Please let us know if we can assist you in any other way.

  Sincerely, Ashley H. Online Support

  Mohd Qureshi 5/2/2013 10:35 am

  i am not trying to install Drupal in this server,I'm transferring a
  Drupal website from dev to the go-daddy server.The files are almost
  completed ,DB also transferred.

  Please note the error got when i checked the url

  "Fatal error: Undefined class constant
  'MYSQL_ATTR_USE_BUFFERED_QUERY'"

  When i searched on Drupal support and they told me to enable the
  following settings in php.ini.

  Please make sure PDO, PDO mysql is correctly installed. Also
  php_pdo_mysql should be enabled. You can do this by uncommenting
  extension=php_pdo_mysql.dll in php.ini and restarting Apache.

  Please update me asap.Client is waiting for the live site.


texts: Deciding which field should be on Product node and which on product variations

texts:
I'm wondering if I'm implementing my products the right way.

As I understand it should be the following.

I have different product variations with each their specific fields and SKU.
For example storage = 8 GB or 16GB

Then I have the main product to which these variations belong with main attributes such as the product name or compatibility. These are shared over the different variations.

So I consider I have my product nodes (or product displays?) with al my product information that is the same over the variations.
And I have my product variations with the SKU's and fields that are specific to each variation of the main product.

For me personally I think this is the correct way because you don't have duplicate data in your database. And if some field data needs to change, if it's a product specific field and not variation specific, you don't need to edit it over all the variation entities.

But I'm not sure that this is the correct way to do this according to standards, advise, other things I'm missing, ... . Because I'm very new to drupal commerce.


texts: PDOException : SQLSTATE[42000]: Syntax error or access violation: 1142

texts: I meet a error when I cleaned the cache or I run an update. It blocks my website, do you have a solution ? thank you


texts: Drupal 7 Rule to save node based on fetched entity throwing EntityMalformedException if field empty

texts:
So I have a rule that attempts to fetch a node using fetch entity by property, and re-save it with a new author if a user field value matches a node field value upon user login.

It works just fine unless it can't find a match, in which case I get the following error:

  EntityMalformedException: Missing bundle property on entity of type
  node. in entity_extract_ids()

I'm kind of surprised I get this error if the value doesn't exist, but now I need a workaround.

Is there some condition I can add here to prevent the error, or am I looking at removing the "fetch entity by property", and adding a db_query()?


texts: Using the menu API, how do I get only the enabled links?

texts:
Using the code below I am able to get all the titles and links from the main menu, however, I only need the enabled ones.
I have been searching for an answer for a couple of days but have been unable to find any.

$tree = \Drupal::menuTree()->load('main', new MenuTreeParameters());
foreach ($tree as $item) {
  $title = $item->link->getTitle();
  $url_object = $item->link->getUrlObject();
  array_push($menulinks, $title);
  array_push($urlformenulink, $url_object);
}

Please assist.


texts:
I created a module with a hook_theme(). It works fine but when I copy my-custom-template.tpl.php file into my theme folder to customize the override doesn't work. I  don't understand what I am doing wrong.

function foo_bar_theme() {
  return array(
    'something' => array(
      'template' => 'my-custom-template',
      'variables' => array(
        'zone' => null,
        'location' => null,
        'class' => null),
    ),
  );
}

Can someone help me please? I've checked everything, cleared the cache, checked the spelling, made sure the names are original to not have name clashes.


texts: media_gallery images are not opening with proper size

texts:
I have set up a media_gallery with colorbox in http://www.mountvilleresorts.com/. The gallery is working fine, but gallery images are shown very small.

After opening the images again, they are shown in the right size.

What is wrong with galleries that shows the images with a wrong size?


texts:
My setup is:

Addressfield on nodes to collect address data
Geofield using "Geocode from another field" choosing the addressfield and the Google Geocoder

When I edit/save a node in the UI, the data is geocoded.  However, I have thousands of nodes and am trying to write a script to update the geocode info on each node.

I tried loading all the nodes and doing a node_save() but the geocode hooks didn't fire.

How can I programmatically update the geofield information?  Is there a hook I can use?


texts:
I'm currently trying to customize my registration form with a custome template file.

Everything is going fine except for the date-field where users can set their birthdate (field_geboortedatum in my code).

<?php
print drupal_render($form['form_build_id']);
print drupal_render($form['form_id']);
?>

<?php print drupal_render($form['field_voornaam']); ?>
<?php print drupal_render($form['field_naam']); ?>
<?php print drupal_render($form['field_geboortedatum']); ?>
<?php print drupal_render($form['account']['mail']); >

<?php print drupal_render($form['submit']); ?>

I'm using the Date module (http://drupal.org/project/date) with Drupal 7.

Ayone any ideas how I can render the datefield corectly? I don't want to render my whole form at once because I want more control over my layout.


texts: How do I get the menu title via the menu name, Drupal 7 API

texts:
I'd like to get the title of the menu.

if I do:

menu_navigation_links('menu-name');

I get only the links without the title, which is good but I still need the title.

Any ideas ?

Cheers


texts: How to limit access to a meeting content type to only the participants specified via Entity Reference?

texts:
I have a content type that contains information about meetings. One field of this content type is 'members', which is of type Entity reference (a field type provided by the Entity Reference module). It specifies the included users in the meeting (using a multiple select list).

I want the content to be accessible only by these specified users.

Is it right to use the Node access user reference module for this purpose? If so how?


texts: I want to add a field in drupal commerce products by default like commerce_price?

texts:
I want to add some default fields whenever new product types are added like we have for commerce_price field in drupal commerce.
I already have a field_abc_attribute(widget is select list and field type is option_set_reference) added which in one of the product type
I was checking through hook_fields_extra_fields() function but it did not create new fields on
How can I achieve it?

function custom_module_field_info() {
  drupal_set_message('jsdfsdfsdfsd');
  return array(
    'field_product_attribute_val' => array(
      'label' => t('Product Attributes'),
      'description' => t('This field product attributes.'),
      'settings' => array(),
      'instance_settings' => array(),
      'default_widget' => 'commerce_option_set_reference_select_list',
      'default_formatter' => 'commerce_option_set_reference_form',
 //     'property_type' => '',
   //   'property_callbacks' => array('commerce_price_property_info_callback'),
     // 'default_token_formatter' => 'commerce_price_formatted_amount'
    ),
  );
}

function commerce_module_field_extra_fields() {
  $extra = array();
  drupal_set_message('nerer');
  foreach (commerce_product_types() as $type => $product_type) {
    $extra['commerce_product'][$type] = array(
      'form' => array(
                      'field_product_attribute_val' => array(
                                     'label' => t('Product Attribute For Vendor'),
                                     'description' => t('Product Attribute Field For Vendor form element'),
                                     'weight' => -10,
                      ),
      ),

      'display' => array(
        'field_product_attribute_val' => array(
          'label' => t('product attribute vendor extra'),
          'description' => t('The product attribute vendor extra of the product'),
          //      'theme' => 'commerce_product_sku',
          'weight' => -10,
        ),
      ),
    );
  }
  return $extras;
}


texts: Automatic Google translation when there is no real translation

texts:
I have a multilingual site.

I want it so that if a user has chosen French as they preferred language, but no French translation exists for a particular page, then an automatic Google Translation is displayed.

I have tried doing things like installing the Google website translation module:
https://translate.google.com/manager/website/
but this of course cannot display the proper translation if one exists because it does not integrate with Drupal. I have also looked at options like GTranslate https://www.drupal.org/project/gtranslate, which has a Drupal module but that does not integrate properly with Drupal multilingual sites.

Any suggestions for a solution to this? The only way I can think of doing it is to The Translation Management Tool (TMGMT) module and to use Google translate all pages and have those Google translations as proper Drupal translations, although this has disadvantages as well in that it will be cumbersome to do with this hundreds of pages. Any ideas?


texts: print jwplayer module in a page from specific node

texts:
How can I print jwplayer from specific node in a page (Drupal 6)?

I'm looking for the php code and I can't use views here. I tried following codes:

$node= node_load(5);
print $node->field_video;

and

print theme('jwplayermodule');

http://drupal.org/node/1260116

I know those are wrong and I'd appreciate your help.


texts: Caching pages for anonymous users prevents other cache logic?

texts:
I'm looking to confirm my suspicions as anything but, if I enable caching for anonymous users then any cache logic I've implemented in custom modules, views and blocks is thrown out, is this correct?  What I mean is, if I have a block showing some weather information that has a 5 minute cache but I turn on anonymous page caching, the cache logic of my block is never considered.

Is there a way around this?


texts: How to save each array values in next line?

texts:
I am having a requirement that, automating the contributed module configurations via hook_update. I have a text area, where i need to mention different URLs with one  URL/line. For reference look into the image:

To achieve this I have to use variable_set(); function.
I tried something like below but not able to get all the values displayed.

$test = array('abc/*','xyz/*','ijk/*');
variable_set('boost_testing', $test);

This code is setting only first row, it will not come to next row.

So please suggest something I can do by using <br> or \n so that i can display each values next row. Any help will be appreciated.


texts: append meta data for same url with different query string using jquery

texts:
I am new to Drupal. I want to append the url parameter as well as meta data for the same content page onChange or onSelect through jquery. How can I do this?. Your help will be greatly appreciated.

Note- I know how to append the url for normal html page using the Jquery but not know how to do it in Drupal.


texts: How do I use an OR condition in an exposed filter?

texts:
I have a view with more than 10 checkboxes for the multiple selection in exposed form with some field. Using the Drupal exposed filter for the multiple fields make the query of AND, but somehow I need the multiple selections in OR condition.

Is there any way to change the query to use a OR condition?


texts: How do I change the view sorting for this field?

texts:
I am using Drupal 7 and I have a List (text) field showing a list in this format:

0|a
1|b
2|c
3|d
10|e
11|f

Now when I create a view and sort it ascending order, list is showing in this order: a,b,e,f,c,d. I need it to be shown as a,b,c,d,e,f.

I have a lot of data. I had to choose a list of integers.

Is there is any other way to fix this issue?


texts: How to limit the quantity of a product to 1?

texts:
Some stores sell products that can only be purchased once (for example, on iTunes, you can only buy a song for yourself once, or on Steam, you can only buy a game for yourself once).

So for products like this, how can I limit the quantity to 1 in Commerce?  (Users should never be able to order 2+ of any individual product of type myproducttype.)

There are some answers for doing this in Drupal 7:

Using rules to restrict anonymous users to quantity of 1
Limiting order quantity

Unfortunately, these solutions use Rules, which is still in alpha for D8.

So how can I programatically restrict the product quantity to 1 for a given product type?