texts:
I'm writing a module that contains a star field. Now I'm placing the stars using the viewElements function of my field formatter. Everything is working. But I need to place some syling to the field output. Can I send some css styling to the active theme using my module?

My field formatter looks like:

public function viewElements(FieldItemListInterface $items, $langcode) {
    $element = [];

    foreach ($items as $delta => $item) {
    $total = $item->rating/2;

    $stars = '';

    //Place colored stars
    for($i =0; $i < floor($total); $i++)
    {
        $stars .= '';
    }

    //Place half star
    if(floor($total) != $total)
    {
       $stars .= '';
    }

    //Place open stars
    for($i = ceil($total); $i < 5; $i++)
    {
        $stars .= '';
    }

      $element[$delta] = array(
        '#markup' => $stars,
      );
    }
    return $element;
  }

The only thing that I'm missing is the css style that looks like:

.star {
    font-size: x-large;
    width: 50px;
    display: inline-block;
    color: gray;
}
.star:last-child {
    margin-right: 0;
}
.star:before {
    content:'\2605';
}
.star.on {
    color: gold;
}
.star.half:after {
    content:'\2605';
    color: gold;
    position: absolute;
    margin-left: -20px;
    width: 10px;
    overflow: hidden;
}


texts: Commerce functionality using Domain Access + i18n

texts:
I have several sites using modules Domain Access and i18n, using Drupal 7. I am completely newbie to commerce, and have read about the options of modules Ubercart and Drupal Commerce.

However, I want to have the flexibility of Domain Access, so I would like to have a store section which is different for any domain (at the least) and possible different for any domain-language combination (less likely).

What would be the best option of the above modules? Are they both compatible with Domain Access? How do I need to install Drupal, first the commerce or better (I guess so) the Domain Access + i18n and, after that, the module ( I had great problems with a module related to Domain Access just because of the order of installation, with no even the developer knowing what had happened or if it was a bug after all ).


texts: Avoiding content-type overkill: 5 slightly different pages = 5 different content types?

texts:
My drupal 7 site mainly consists of a main menu with 5 entries, each linking to a more or less simple page. These 5 pages have a lot of common fields, simply some fields are slightly different. Normally, i would have to create a content type and an actual node to accomplish this — but since there is only one actual node for each of the content types, it feels like an overkill to me.
One alternative is to handle all fields in one singe node, separating the 5 areas in the edit-form by fieldgroup-tabs, and generate the pages with views …
Downside of this approach: instead of using display suite to do the theming, i would have to theme using views-fields, which is a pain.

The node field module, which allows you to add custom extra fields to single drupal nodes doesn’t work for me, since i am using entity-reference fields, which aren’t supported.

So what’s your best practice?

(Annotation: The content isn't very often updated and the content of the fields hasn't to be used in tokens, but i have to use a more or less "rigid" field structure in order to make editing content an easy no-brainer for the content maintainers. using „wide open“ WYSIWYG textareas isn’t a way to go, because maintainers will alternate often and will have only little knowledge about the project.)


texts: Show extra information in D7 ubercart order pane

texts:
The code was converted from existing D6 'Simple package tracking' module to D7. it is supposedly show 'tracking number' with 'delete' in D7 Ubercart order pane page so that admin and customer can view the tracking number, but it is not showing anything. When i enter tracking number which is other function of this module, admin comments shows 'tracking number 1Z0609610 added by admin'

thank you for your help. :-)

function simple_package_tracking_order_pane_tracking_numbers($op, $order) {switch ($op) {
case 'view':
case 'customer':
  $rows = array();
  $result = db_query("SELECT tracking_id, tracking_number, tracking_carrier, tracking_url FROM {tracking_numbers} WHERE order_id = :order_id",array(':order_id' => $order->order_id));
 //while ($tracking = db_fetch_object($result)) {
    foreach ($result as $tracking) {
    $row = array();
   $row[] = $tracking->tracking_carrier != NULL ? $tracking->tracking_carrier : t('Other');
   $row[] = l($tracking->tracking_number, $tracking->tracking_url, array('attributes' => array('target' => '_blank')));
    //if (user_access('fulfill orders')) {
      $row[] = l(t('Delete'), 'admin/store/orders/' . $order->order_id . '/tracking/' . $tracking->tracking_id . '/delete');
   // }
    $rows[] = $row;
  }
if (count($rows)) {
    $headers = array();
    $output = theme('table',array('header' => $header, 'rows' => $rows));
    return $output;
  }
break;  }}


texts: Show multiple content in a view in drupal 7?

texts:
I have a content-type named Accessories. Where I can create content related product i.e. Product name, product detail, etc. I have a view named shop where I can display all products of the content-type i.e. Accessories.

Now I want to create a view where I can show the product detail. I can't find-out how to do this.

Please help to create Views to show my product details.


texts: Drupal function field_get_items vs user_load

texts:
In Drupal, I want to read a custom field value for a group of users while logged into an admin account. I only need 1 field value from each user, the same field and I do not need this information cached.

When I use user_load it requests the user object as I only need one field this is very inefficient.

So I investigated field_get_items, but I cannot see how to use this function without first using user_load.  I have attached my code and MARKED the line that is giving me an issue.

how can I use field_get_items without using user_load, if not possible is there a efficient way of doing this?  Please don't mention user_load_multiple
with user_load does setting , $reset = TRUE prevent Drupal caching the data or does it force a cache reset, get the data from the DB and then re-cache the new data?

Code I use:

$user_a = array();  //  This is the array of URIs we need to query
foreach ($user_a AS $uid){
  $account = user_load($uid, $reset = TRUE);  // access the user objects, one at a time
  $fullname[$uid] = $account->field_fullname[LANGUAGE_NONE][0]['value']; // extract value
}

$user_a = array();  //  This is the array of URIs we need to query
foreach ($user_a AS $uid){
  **$account = user_load($uid, $reset = TRUE);**
  $fullname[$uid] = field_get_items('user', $account, 'field_fullname');  // extract array
  foreach ($fullname[$uid] as $item) {
    $fullname[$uid] = $item['value'];  // extract value
  }
}


texts: I have a webform that has a textarea input. I am trying to update the placeholder text. It seems to have a limit of 128 chars. Is it possible to update this to allow for a longer placeholder?


texts: How to transform the CSV link in the Views Data Export module in a non-image link display?

texts:
I'm using the Views data export module for my search interface so users can click a link to download the search results. It's working and displaying. But it's not pretty.

My Data Export has the following settings:

Format: CSV file
Filter criteria: published, type=resource, topic > (exposed), category (exposed), search terms (optional)
Data export > settings > path: /search-export Attach to: search footer: global: text > area (what I've been trying to add the manual link to)
pager: display > a specified number of items > 0 items (required to make the CSV export > not return all results be default)

Right now there's a button at the bottom of the page that the module creates in the format of a tiny bright orange button with white text that says 'CSV'. I think it's an ugly button. A user may not even know what it means. Here's the code via inspect element:

If the user set exposed filters or set a keyword in the search box when clicked this link adds parameters to the URL (ie. /search-export?field_topics_value=All&etc).

I don't know how it's adding those parameters which is probably the crux of my problem.

I could just swap out my own image I guess...but...

I'd rather change this to not use an image whatsoever and instead have it just be a link that says 'download results' or some such thing.

I tried just adding a link manually to the header or footer in the search view that has the same link as the image but it doesn't capture the parameters the way the button does for some reason.

The link I tried adding:

    Download Spreadsheet

When clicked the above doesn't include the parameters in the URL like the image does, it just exports ALL the results (and ignores whichever filters are set).

My question: How to fix my new download spreadsheet link so it outputs the results only with the exposed filters and keywords as the view itself does (and as the CSV button does)?


texts:
I'll try to make this as simple as possible.

I use Drupal Commons and want to add this code:

if (module_exists('user_badges')) {
    print user_badges_for_uid($uid);
}

to my profile user's profile page.

Does anyone know where I can find that?

What I want to do: https://www.drupal.org/node/942014


texts: How to display multiple products under each category in a views grid?

texts:
Currently I have a views with grid display that has the fields Content: Category and Content: Title, and a filter criteria of Content: type (is a product). This displays all my ubercart products with their associated category above them. So I have a result like:

Category 1: product x
Category 1: product y
Category 2: product z
Category 2: product t

What I want is to have each category only appear once with a few products listed below each category. Such as:

category 1:

product x
product y

category 2:

product z
product t

I tried giving the field Content: Category and multiple field setting where all values of the field will be shown in the same row but that did not work.


texts: How do I profile a REST API request from the Simple oauth module?

texts:
I am trying to profile a REST API endpoint (/oauth/token) for performance issue. I want to see what database queries are executed during that API request.
Can I get it using webprofiler with the Devel module?


texts: Unlimited field collection pagination in node edit page

texts:
In my node I have a field collection which is set to unlimited.
How to enable pagination for node edit page, where all items from that field collection are displayed?
For display there are couple possibilities - pagination modules, views etc. but how to do it for node edit page?


texts: Using Automatic Entity Label how to add number if title is already used (unique)

texts:
I have setup auto entity label with tokens. All works great.
Lets say I have a title
e.g. tokens
[firstname] [lastname]

Displayed as:
Tom Cruise

But if there are multiple identical titles named "Tom Cruise".
e.g.

node 65: Tom Cruise
node 90: Tom Cruise
node 23: Tom Cruise

What I want is it to validate, the title is not unique therefore add number on the end.

node 65: Tom Cruise
node 90: Tom Cruise 1
node 23: Tom Cruise 2

Or something like that. I have been using nid / serial field to make them unique but that isn't what I need.


texts: Use mytheme_preprocess_block() to display HTML (icon fonts) in block titles

texts:
Unfortunately, HTML commands in block titles are not being rendered. I would like to be able to add icon font symbols to my block titles by adding comands like <i class="icon-envelope"></i> (this is Font Awesome syntax) to them WITHOUT installing yet another contrib module.

Is there a way to let HTML in block titles being rendered by adding a mytheme_preprocess_block() function to my template.php?

I came across a solution to let HTML commands in menu links being rendered by adding
function mytheme_link($variables) {
    $variables['options']['html'] = TRUE;
    return '' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '';
} to my template.php but haven't managed to modify the code for block titles.


texts: Twig get value of field in entity reference

texts:
i have a content type "actuality" with a reference to an other content type "event".
In "event" i have a "field_date" which i want to print into my "actuality" node.
What is the best way to do that ?

I've already created a template node--actuality.html.twig and trying to print inside node.field_event_associated.field_date but it's not working.

Regards,


texts: Is there any way in Drupal 7 to load a node and its fields without the Entity Query API?  I need to get a field value based on another field in an external script, and don't want to bootstrap Drupal.


texts: Drupalgap: Hello World sample - where is app folder?

texts:
I have a Drupal 7 website and wish to develop a mobile app for it. I have successfully installed Drupalgap. I am trying to run the Hello World sample app described in the Drupalgap 7 docs. The instructions say to create a custom module and place it in the app/modules/custom/my_module folder. The problem is that I don't have an "app" folder anywhere. What am I missing?
Thanks for any insights.


texts: New Event in existing/enabled module not showing in web profiler

texts:
I have added an Event to an existing, and already enabled, module.  I'm including the relevant code below without comments for brevity.

  namespace Drupal\my_module\Event;
  final class MyModuleEvents {

  /**
   * @Event
   */
   const NUMBER_CODE_VERIFIED = 'my_module.number_code_verified';

  /**
   * @Event
   * THIS IS THE NEW ONE
   */
   const INCOMING_INIT = 'my_module.incoming_init';
  }

Here is the Event

namespace Drupal\my_module\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\Request;

class MyModuleIncomingInit extends Event {

  protected $request;
  protected $type;

  public function __construct(Request $request, $type) {
    $this->request = $request;
    $this->type = $type;
  }
  public function getRequest() {
    return $this->request;
  }
  public function getType() {
    return $this->type;
  }
}

I'm either missing something in creating this new Event or maybe there is something specific I need to do when adding Events to an existing and enabled module.

EDIT: Not really an answer, so I'm putting it here.  I went ahead and implemented the EventSubscriber like the Event existed.  Once I did that and cleared the cache (again) the event was showing in both drupal event:debug and web profiler.


texts:
We have local stored video that we display using the media module and Video in field views.

In a view with several videos only a few gets a thumbnail image representing the video. This configuration:

Controls: visible
Autoplay: nej
Loop: nej
Muted: nej
Size: 100% x 225
Multiple files: tags
Field template: Drupal default

With Firefox we got 90 % of the videos with image preview and with Chromium 50 %.


texts: Get the displayed node of a commerce_line_item in a component rule using 'commerce_display_path', doesnt work

texts:
I ve found something quite interesting in an other post Discount based on a field in product display node in Drupal Commerce?

It describe a way to get the 'node display' associated with a line_item

Build a component rules action set with custom php code in it,
providing a 'node_fecthed' provider variable and then use it with
other rules to do what you need.
The php code use the commerce_display_path backlink exploded url to find the displayed
node, then return it.
The given code is the following :

$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$url = $line_item_wrapper->commerce_display_path->value(); $url_parts = explode('/', $url);
$nid = $url_parts[1];
return array('node_fetched'=> $node);

Just before the return line, i added, regarding to a comment suggestion from the original post, 2 lines :

$node=node_load($nid);
dpm($node);

when rules is run, devel dpm() displays the right associated node as expected.
But when in an other rules i try to display/debug/use the 'node_fetched' it appears to do nothing as if it was set to null.
What may be wrong with that ?
Any suggestions will be appreciated as i'm going mad with that for 2 days.
Thx


texts:
I installed Simplenews 8.x-1.0-alpha2 using /admin/modules/install and then pasting the url to the tar file.
Now I want to uninstall/delete it, but I cannot find where the folder is.
I have checked in /modules and /core/modules
I even tried uploading the dev version to the /modules folder, but it does not ask me to overwrite.
This is so strange, where else could it be?
Update
I tried as suggested by sanzante using Devel and echo drupal_get_path('module', 'simplenews')
it says modules/simplenews

but when I try to go there with FileZilla, it does not let me. I also re-started FileZilla multiple times.


texts: Where can I find custom content type templates file?

texts:
Sorry for ask this easy question, I know the net its full of tutorials, but the info is a bit confusing since they are always showing the diference between D7 and D8 (i didn't use a CMS before so it is not helpfull enough)

My "news" custom content displays itself without classes, with the title of every field in the content and I want to modify the creation template.
Am I allowed to do that? or its supposed to reach this goal through other way?.

Thanks in advance


texts: How can I make web scraping of a field more difficult?

texts:
I have a text field that I get with <?php print render ($content['field'][0]['#markup']); ?> in node.tpl. I'd like to somehow make loading the markup require a click, and deselecting it to put the placeholder markup back. It's a select dropdown if it matters.

I thought javascript might work, to test if scripts worked in node.tpl I tried

var test ="<?php print render ($content['field'][0]['#markup']);?>";
document.write(test);

but it loaded the markup for every node on the page in one line. My php/js skills are weak so I'm hoping there's a module that might help me. I'm open to any suggestions though.


texts: Custom Content with Image upload button drupal 7 programmatically

texts: I want to create custom content with image upload on it programmatically. When i install the module it will install the database tables and the custom contents form. Any help will be greatly appreciated.


texts: How to use multi-value, full calendar date picker in node form?

texts:
Users previously reported vehicle use in an Excel sheet formatted to look like a full month calendar. Clicked cells in the "calendar" marked visual x's (via macro) on days they used a vehicle, and cleared the cell if clicked again.

Converting to a Drupal node form now requires three times more clicks for every day. The 'dates used' field as multi-value (not always a contiguous date range), so they have to:

click in the text box to launch the jQuery date picker
click one of the days they used a vehicle
click to add a new date field
click one of the days they used a vehicle
etc.

If they have 10 days to report, it takes 29 clicks! Yes, it's a 1WP, but it is poor UX compared to ye olde Excel file, where 10 days took 10 clicks.

Need a full calendar UI date picker in node form. Not the jQuery popup calendar, and actual full calendar display (such as you'd get with Calendar module display), and clicking on days records those days in the node's date field.

Essentially a full calendar widget is needed. There are many node display calendars, but none in entry form that are not a popup. Tried availability calendars module, but it tracks dates in it's own way using votingapi, not interfacing with the Dates module. I need it to be saved as normal dates for later use in views and etc.

Ideas? Thanks in advance!


texts:
For some reason, sub-menus do not work on all pages on my site. Here is one (basic page) that shows the submenus

and here is a screenshot where it doesn't even though the mouse is hovering over the Home menu item.

The links are enabled in Main Menu and I tried toggling "Show as expanded" on and off but neither one makes a difference. The background image is hidden by a display:none css style in the second image/page. If I go to the Contact page, which looks similar to the first image the submenu does not show up on there either. The Contact page was created using the webform module.

Any help figuring this out would be much appreciated.

Thanks,

Kamal

UPDATE: I noticed that on the pages where the submenu works, the following code is generated for the menu.

Home

Host A 51@EarthHour Event

Whereas on the pages where it doesn't work, I only see

Home


texts: How to edit fields' display markup in a search view?

texts: Working with searchapi and views. I have a view based on a search inWondering how to edit the markup for the fields? There's a general option to strip the markup elements, but how to control the markup for individual fields?


texts: How do I limit permissions to manage an event?

texts:
I'm using the RNG Event module in D8 and have an issue where any registered user can click on an event and has access to the view and event tabs. And then through the event tab they can access the settings, access, conflicts, etc.

They can also click to view other user's registrations and delete them.

How do I limit normal logged in users to only see the event, and to register or delete a registration for only themselves? If they can see the other registrants that's fine, but they shouldn't be able to delete.

I have checked all normal permissions settings and see nothing that could grant their current level of access. The only other thing I see under Content Type > Event type > Access Defaults are the three stock rules that also seem to be correct.

This may or may not be connected to the issue I'm having here - Why does the "Registration List" tab not appear for my events for users with adequate privileges?


texts: Show English tabs regardless of current site language

texts:
A localised Drupal 7 site has four languages. Three non-English languages are for the site content, and English is the admin language. Most users won't be logged in. The only logged-in users will be admin or editors.

For logged-in users, the View/Edit/Translate/Devel tabs ($tabs in page.tpl.php) are shown in the current site language. But as these are only intended for admin, it makes more sense to show these in the admin language (English).

How can I always show the tabs in English (or the admin language)?

(One workaround is to remove the translations for the strings in the tabs, but that would have to be repeated if any new tabs or languages are added.)


texts: Create a views "exposed filter" to compare two fields

texts:
First of all:

I know that there's a static filter with Global: Fields comparison that would do it. But I need an exposed filter in views to fullfill my needs.

Let's say I have a table with 3 cols: "nid" | "changed" | "another datetime".

Now I want to have an exposed filter as a select list with options "none", "old" and "new".
If "old" is selected, show rows where "another datetime" > "changed".
If "new" is selected, show rows where "another datetime" < "changed".

I've been looking for a solution for multiple hours.


texts: Translation: File upload error. Could not move uploaded file

texts:
I would like to import an translation file *.po. When I import it, I become the error:
"For security reasons, your upload has been renamed to bootstrap-all.de_.po." and "Error message File upload error. Could not move uploaded file."

Could anyone help?


texts: Uploaded images classified as files rather than under the media tab

texts:
In Drupal 8 if you go to admin/content there is a tab for Files and a tab for media.

I believe it is the media entity browser what distinguishes what area an uploaded file will be placed, but I could be wrong on this.

My question is, as well as that, is there an easy way to move files which have been uploaded and placed under the files tab by accident into the media tab without having to re-upload them all?

Thanks for any help on this


texts: How can I create a content type in a custom module?

texts:
I would like to create a content type called announcements for a module that I'm creating, but haven't found much to make this work. I tried this:

    function srl_dash_install() {
    //drupal_install_schema('srl_contactics_monthly_apps');
    $t = get_t(); // runs in both the installer and runtime

  /* Create and save a new content object */
  $announcement = 'announcement'; // machine name of the content type

  // define the node type
  $announcements = array(
    'type' => $announcement,
    'name' => $t('Announcement'),// Display name of the content type
    'base' => 'node_content',
    'announcement' => $t('Announcement'),
    'description' => $t('Add Contactics Announcements.'),
    'custom' => TRUE,
  );

  // set other node defaults not declared above
  $content_type = node_type_set_defaults($announcements);

  // add the body field
  node_add_body_field($content_type, $t('Body'));

  // save the content type
  node_type_save($content_type);
}

but I'm not sure how to make this hook run.

Any help would be appreciated.


texts: How to access private page (views page) with authentification in the URL?

texts:
All the pages of my site are private (by role). I have nodes and views pages.
I want to access to a views page with an external link. But, If the visitor isn't logged, this visitor can't access to the page.

Is there a solution to specify a token or the login / pass in the URL to automaticaly access to the page?


texts: Attach drupal ajax events to links that were loaded via ajax

texts:
So I have links that are created when a page first loads that use a render array that is something like this:

array(
    '#type' => 'link',
    '#title' => html_entity_decode(t($title)),
    '#href' => $href,
    '#post_render' => array('_dva_post_render_ajax_link'),
    '#attributes' => array(
        'class' => array('ajax-link'),
        'rel' => url($href),
    ),
    '#ajax' => array(
        'path' => 'dva/ajax/'. $href,
        'wrapper' => 'content',
        'effect' => 'fade',
        'prevent' => 'mousedown',
        'progress' => array(
        'type' => 'none',
        'message' => '',
        ),
    )
);

These all work as expected and properly run the ajax and change the page content, etc.

However, when the page content also includes one of these links, the links included in the ajax response are just normal links and have no ajax functionality. The links are created using this same render array and they render correctly (that is, their markup appears the same as the links that work)

How can I tell Drupal to attach the ajax event handlers to the new links that have just been added to the DOM?


texts: How to add another form mode(commerce_order_item) in add to cart formatter?

texts:
I need to configure multiple form mode(commerce_order_item) for add to cart formatter. By default add to cart points to add to cart form mode. I have created couple of form modes like quick add to cart and foo add to cart that is supposed to attached to formatter on different pages respectively.1
For examaple :
Product page : add to cart form mode
View page: quick add to cart form mode
Code where form mode is attached by drupal commerce
https://git.drupalcode.org/project/commerce/-/blob/8.x-2.x/modules/product/src/ProductLazyBuilders.php#L83
Is there any way I can configure/select another form mode for add to cart formatter?


texts: Drupal Webforms arrange fields and labels

texts:
I need to create form like below

Label(Full Name)     TextField            Textfield

                 Label(First Name)    Label(Last Name)

How can I achieve this in webforms?
In webforms there is no option to show labels below.


texts:
My url is node/3?filter-value=67&filter-value=80 and when i try to do this code:

$param = \Drupal::request()->query->all();`

$param['filter-value']

It shows the value 80 only. I want to get both of them.


texts: How can I change the css classes on a menu's ul when it is placed in a particular region?

texts:
Drupal 7: I am struggling to figure out a way to change the menu structure that is printed when I place a menu block in a particular region.

What I want to do is change the classes on the ul when the menu is printed to a sidebar.

Everything I can find, and attempt will change the structure for all menus, but I need to print them differently depending where I put the menu.

Also, I need it to work for any menu I place in the region if possible. I will be creating menus for different areas of the site, and I hope I can get this to work based on the region that the menu is placed in.

Thank you


texts: How to theme markers bubble with Gmap module?

texts:
I've installed Gmap and location modules. I have a view with gmap display and i'd like to be able to display more than one field in the marker bubble, but the module doesn't allow more than one field in the bubble. How do i achieve that ? Is there a template or a theme function that'll allow me to do that?

Thanks.


texts: Why does the count of the Menu badge not decrease after page is viewed?

texts:
I have created a view, which shows activity logged by Message module.

I then created a menu badge which shows the numbers on the menu item. - In start, when there is no activity, it shows 0, After there is some activity it shows the count, but when the page is viewed the count remains the same and does not decrease or disappear.

When the whole activity page is viewed, the numbers should disappear.


texts: Content type or web form(creating own form using hooks) Which one is best way of collecting input from user?

texts:
I am new to Drupal and learning is in progress. I know about content types and creating webforms using hooks. Now I want to collect data from user and store it to db and view it later (easily I can do with a content type) but I need to apply some jQuery events. i.e. if user choose a country then in another drop down I want to show the states of that particular country and I want to change input style.

Which suits best for above problem and why not another one more suitable?


texts: Drupal 8 Private file is accessbile by anonymous user

texts: I have created a content type with file field and set Upload destination is private files. I have also set the $settings['file_private_path'] = '/path/to/private'. But the file is accessible by anonymous user.


texts: views relationships not working for me in views 3.7

texts:
I'm trying to create a block with related posts by taxonomy term, however, i cannot setup views relationships properly. What have i done (url, where i have found this solution: https://stackoverflow.com/questions/10454507/creating-list-of-similar-nodes-in-drupal-7-views-3):

   Create a block view
    Add Contextual filter -> Content: Nid -> Provide default value -> Content ID from URL
    Add Relationship -> Content: Taxonomy terms on node -> specify the appropriate vocabulary
    Add Relationship -> Taxonomy term: Content using vocabulary as specified above -> Check off Require this relationship
    Turn on Views aggregation
    Assuming you are listing title only, edit the title field to use the Relationship you set up in #4 above.
    Add new sort criteria of Content: Nid. In aggregation settings, select Count. Use relationship from #4 and sort descending
    Add Contextual filter -> Content: Nid -> Use relationship from #4 -> Provide default value - Content ID from URL -> Scroll down and expand "More" then check "Exclude" to remove current node from the view

When i add relations i cannot use them on my node:title, there's just no option to choose these relations i have created. Any ideas?


texts: Embedded Media Field Video: Output both Video Flash Object and Video Thumbnail in Node Display?

texts:
I would like to be able to access both the Video Flash Object, as well as the Video Thumbnail filepath from the Node Display. Please let me know if I can provide more info, not sure anything else is relevant! Thanks!

Clarification: Basically I want to be able to be able to output both the video with a custom resolution, and the thumbnail through an imagecache preset, from either a custom module, or within template.php. Essentially I would hope to end up with both the final video HTML and image HTML as individual objects or php variables, so I can then output them wherever I like from within the relevant node.tpl.php. I'm assuming there's a simple theme() function I can use for both of the above. The embedded video at this time can come from either Youtube/Vimeo.


texts: Show a message after file_transfer is executed

texts:
I am using file_transfer to send a download to the http client.
The problem is that file_transfer executes drupal_exit so that no more code is executed after it.
How do you show a message or redirect to another page after sending a file_transfer ?


texts: Error when submit a Webform with Ajax using Jquery

texts:
I am having a webform in my drupal. I am using the jquery Ajax submit method to submit it.

This is the code I am using.

$("#webform-client-form-59--3").ajaxForm(function() {

$(".talk-region").html("
Thankyou,
 Our representative will be contacting you soon.
Close")

});

$("#webform-client-form-59--3").validate();

But when I check in firebug.. Its posting, but the response am getting is

302 Moved Temporarily
        5.2s


texts: How do I get a LEFT OUTER JOIN in Views that displays all rows with no match in the LEFT JOIN-ed table?

texts:
Views 7.x-3.x

Staff

sid name
1   Adam
2   Barbara
3   Carol
4   David

Staff Roles

sid rid
1   1
2   1
2   2
3   2
3   3

Let's say that I want a list of all staff, excluding staff who have a particular role, and that role id (rid) will be provided in the URL.

Let's say that the rid we want to exclude is 2. So we want our view to display Adam, David.

My approach has been to list all the staff in a view, then add the relationship to Staff Roles, put the rid into a contextual filter, and then say it is to be excluded.

Unfortunately, what this produces is a LEFT JOIN of all the rids except 2. So we get Adam, Barbara, Carol.

So you might think: let's not exclude the contextual filter for rid. Let's include it on a non-excluding LEFT JOIN. Then we can maybe filter for rows with a rid of NULL. Unfortunately, views puts the contextual filter into the WHERE clause of the query, so we end up with just Barbara and Carol.

So my question is:

How would you build a view to list all staff, excluding staff who have a particular role, where that role id (rid) will be provided in the URL?

Alternatively:

How can I get conditions from a contextual filter into the ON part of a view query, instead of the WHERE part?


texts: How to keep Display Suite CSS classes in code?

texts:
I'm using DS in my D7 project along Features, so I've been able to keep all my new DS layouts, CCK, etc. in code, by generating a custom feature.

All good there... until I had to add some custom CSS classes to Display Suite:

Can't see how these values can be exported in code to persist in my project, rather than my DB. Nothing from the feature module either.

Is this actually possible? Thanks in advance :)


texts:
I have: drupal 7 - php module enabled - rules module enabled

On one of my rules I have the action: custom php code

when I enter <?php echo 'test code'; ?> it correctly shows the text

I want to include javascript, I've attempted:

<?php
    drupal_add_js('var google_conversion_id = 1003933475; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "IC5cCMXVqwcQo57b3gM"; var google_conversion_value = 0;', 'inline');
    drupal_add_js('http://www.googleadservices.com/pagead/conversion.js', 'external');
?>

and

<?php
echo '<script src="http://www.googleadservices.com/pagead/conversion.js"> </script>';
?>

but when I view the source, there's nothing included. It's somehow stripped out or something.

What am I doing wrong? Is there a better approach?

Thanks for your advice


texts: Using Panels and Views to override taxonomy listing - which argument to use?

texts:
I'm using Panels to override the taxonomy display at taxonomy/term. I just enabled the term_view page that comes with Panels and it works great.

So going to mysite/colours/blue shows the Panels page no problem.

Now I want to add a View to the panel that lists the returned nodes. I create the view, and add a relationship 'Content: taxonomy terms on node' (selecting the required vocabulary 'colours').

The I add an argument (contextual filter) on 'Taxonomy term: name'. This works great in the view preview if I enter the value 'blue' but not if I enter 'colours/blue' (no results). And it doesn't work in the panel because 'colours/blue' are the arguments being passed to it.

How do I get the view argument to work with this URL?


texts: Multiple path aliases based on taxonomy term

texts:
I have taxonomy terms from A-Z and each article can belong to multiple terms.

for an example, when I create a new article, I have a multi select list for terms. Therefore a particular node should work for multiple URLs.

example.com/categories/a/planning
example.com/categories/g/planning
example.com/categories/s/planning

Please let me know if this can be achieved using a contributed module or can it be built with a custom module?


texts:
This is a local install of Drupal 8.8.1 I have setup for learning drupal dev. I have my route file setup like so, the controller just returns a paginated list:

    mymodule.configurations:
  path: '/admin/structure/mymodule_configurations'
  defaults:
    _controller: '\Drupal\mymodule_configurations\Controller\ConfigurationsController::pager'
    _title: 'List of module configurations'
  reuqirements:
    _permission: 'access content'

so when I try to access the page under admin/structure, logged in as an admin I get an access denied message. Shouldn't access content let anyone at all view the page? As an admin shouldn't I see it anyway?


texts:
I'm trying to create an image repository with Drupal, but I face some problems.
I want to create a node with several images attached, but since the relation between images to nodes can be many-to-many (an image can be attached to more than one node) I don't want to duplicate the same image on the server.
I've tried different solutions but none of them can really fit my needing.

Imagefield solution:

I can easily attach multiple images to a node, but it's hard to reuse the same image.
The best solution would be using filefield_sources, but it's a bit buggy (I can't find a way to use the IMCE integration in a proper way).

Image solution:

It has an image browser, but without search or folder tree, it can't be used with many images.

Did anybody face the same problem and found a good solution?
Thanks in advance.

==UPDATE==

Example:

Product-1 - I can attach Image-A, Image-B, Image-C and Image-D (with image module or imagefield)
Product-2 - I can attach Image-E, Image-F, Image-G and Image-H

Product-3 - I want to attach Image-A and Image-F.
I need to upload them again or I can use Image Browse (part of the Image module) to display an image picker with ALL the images uploaded before (without any search filed or filter).
I see 8 images, I can pick Image-A and Image-F and attach them to the node.

What about Product-1200? At that time I could have 4000 images displayed in Image Browse: it would be really hard to find the one I need to attach to the node!
I would like to find a better way to select the images!

==SOLUTION==

I created two content types: product and image.
Image has an imagefield field.
Product has a nodereference field.
I mass imported all my images with imagefield_import.
I use nodereference_browser with a custom view with all the filters I need to search between Image nodes and select which one to reference.


texts: Programmatically check if a D8 version exists for all site modules

texts: I am listing all modules used by site on our platform. Given a module name, how could I programmatically check if a Drupal 8 version is available?


texts: Inline add/edit/delete data in views in Drupal 7

texts:
I am trying to create a content type (say Meter). Each Meter consists of a "Meter Reading". This meter reading content contains three fields, say title, date range and usage. I have a Panel page where I display all the Meter Readings related to a parent Meter. I have displayed the Meter Readings in a tabular format.

I want the user to be able to add new Meter Readings without going to the default Meter Readings creation page. Rather than the default form kind of page, the user should be able to enter the data in the table view provided and it should be automatically saved into the project itself.

So, I want the functionality to be like:-

Display all the meter readings with two links, i.e., Edit and Delete,
When the user clicks on Edit link, the meter reading row should become editable and the user should be able to make the changes inline in the same table,
In the footer there should be a link for adding a new meter reading and when the user clicks on it, a new blank row should be added dynamically to the table and the user should be able to make a new entry into it.

Is there a module in Drupal 7 for doing so?? I have already tried out several modules for this such as SlickGrid, jQGrid and jEditable.

Any help would be great. Thanks in advance.


texts:
drush make unsuccessful, because download of patch fails  -

I have (apparently equal) boxes, on one my drush make fails, on the other it's fine.

Unable to download                                                [error]
https://drupal.org/files/l10n_update-proxy_support-1863544-1.patch.
drush make FAILED. Exiting...

I am behind a proxy but checked that it is not the basic problem. http_proxy is set and I can use wget on shell.

2nd approach is to change the URL to http.

UPDATE: Found now patching itself fails. just wondering why it works on the other box.

UPDATE2:

I created a test branch and removed all modules except for the failing one. And tried another module version where a similar patch exists. Here are both entries:

;projects[l10n_update][version] = "1.x"
;projects[l10n_update][patch][1863544] = "http://drupal.org/files/l10n_update-proxy_support-1863544-1.patch"
; ISSUE: https://drupal.org/node/1863544#comment-6832354

projects[l10n_update][version] = "1.0-beta3"
projects[l10n_update][patch][1791100] = "http://drupal.org/files/l10n_update.inc-1791100.patch"
; ISSUE: https://drupal.org/node/1791100#comment-7422500

here i have now:

l10n_update-7.x-1.0-beta3 downloaded.                             [ok]
http---drupal.org-files-l10n_update.inc-1791100.patch retrieved      [notice]
from cache.
(Stripping trailing CRs from patch.)                                 [notice]
patching file '<html>l10n_update.inc'
patch unexpectedly ends in middle of line
Hunk #1 FAILED at 257.
1 out of 1 hunk FAILED -- saving rejects to file
'<html>l10n_update.inc.rej'
Unable to patch l10n_update with l10n_update.inc-1791100.patch.   [error]

Is it a patch format drush cannot handle ??


texts: Altering an image fields output in a View

texts:
On our site, users are given the choice to make their profiles private or public. They also have the ability to upload a profile pic, and if they don't, there's a default placeholder image.

If a user who's profile is set to private creates a piece of content, and another user looks at that piece of content, a broken image is displayed (with a 403 forbidden error message). We are using the Views module to display the bits of data.

What is the best way to alter the View so that if the account is private, rather than serving up the broken image, it displays the placeholder?


texts: Using a sweet alert with preventDefault()

texts:
I have an event on a form submit.

I set preventDefault() to stop the form submitting then pop a sweetalert with a confirm callback.  If they decide to go ahead is POSTS the form to Drupal.

The issue is that it does not hit the form_submit method but redirects to the same page with a GET request.  If I simply return true from the jQuery submit event it works.

If they confirm I have tried

form.off('submit').submit()

but it still does not work.

Can anybody help as it is driving me crazy?


texts: How to use Views Photos Grid module with custom minimal theme

texts:
I use Views Photos Grid module and it shows the results correctly with Stark theme.
However, it shows all the images stacked in only place in my custom theme.
I do include modules css and js files:

<link rel="stylesheet" href="/modules/views_photo_grid/css/views-photo-grid.css">

I also render the expected divs:

...more views-photo-grid-item divs are here...

Java script console shows no errors.
I've checked in debugger that the main JS function (function ($, Drupal, drupalSettings) is called but none of the other JS functions is called.
Could this be the cause?


texts: Apply a dynamic string to a field before validation

texts:
I am attempting to set the "title" value of a content type before it becomes "required" . So what happens is the title field becomes hidden based on user name, after filling in the "first name" and "last name" fields I need to take those values and then apply them to the "title" field, before drupal states that the field is required. Here's what I have so far

/**
*  Implements hook_form_alter().
*/

function editorhide_form_alter(&$form, &$form_state, $form_id){
//form id = artist_node_form
//title id = edit-title label: edit-title

global $user;
global $fullTitle;

if($form_id == 'artist_node_form'){
    hide($form['artist_node_form']['edit-title']);
   if( $user->name == 'Editor'){

        // drupal_add_js("jQuery(document).ready(function(){
        //  jQuery('#edit-title').hide();
        // });","inline");
        $form['#submit'][] = "editorhide_form_submit_handler";

     }
}

}

//submit form handler.

function editorhide_form_submit_handler ($form, &$form_state) {

  $fullTitle = array();
  $fullTitle['0'] = $form_state['values']['field_firstname']['und']['0']['value'];
  $fullTitle['0'] .= ' '. $form_state['values']['field_lastname']['und']['0']['value'];
  form_set_value( $form_state['title'], $fullTitle['0'],$form_state);

}

With the current code it throws a error:: Recoverable fatal error: Argument 2 passed to drupal_array_set_nested_value() must be an array, null given, called in


texts:
I am working on a new Drupal 7 site that is making heavy use of Panels to build pages.

I have a page where a view will be added to a content pane.  For various reasons, the view cannot be its own page.  This particular view has a Contextual Filter on it, Content: Has taxonomy term ID.  View works great with numeric arguments.

I would like my panel page to use the term name as the argument for the view instead of the term ID.  And, for various reason, I cannot use the taxonomy/term/%taxonomy_term override that comes with Panels.

If I set up the context option for the page (Settings / Arguments) to use Term Name, I can get the argument to work.  My problem is that the vocabulary I need to use has terms with lots of capitalization and spaces in it.  So, the URLs end up unreadable.

We have a custom ctools arguments plugin that can handle pathauto-style term names, where the term is lowercased and spaces are converted to dashes, but it was done for Drupal 6.  Before I spend the time to rework it for Drupal 7, I wanted to see if there is a better and/or existing solution.

In summary,

I have a panel page with path foo/!term
Panel page has a view with a taxonomy term ID argument, where the view argument should be based on the URL
I would like to have URLs like foo/apple-beet-carrot instead of foo/Apple%20Beet%20Carrot
I cannot use the system override for taxonomy/term/%taxonomy_term

What is the best way to go about this with Drupal 7, Views 3, ctools, and Panels, short of making a new ctools argument plugin?


texts: Programmatically add new role to group member

texts:
Trying to update a group membership to add an additional role, but cannot find any help on how to do this.

I want to add the role of "manager" to all owners of "client" type groups, using the following code:

// Get the group owner
$owner = $group->getOwner();

// Get the membership details of the owner
$membership = $group->getMember($owner);

// Get the roles of the owner
$roles = $membership->getRoles();

// Check whether the owner has manager role
if (!isset($roles['client-manager'])) {
  // No, so add the manager role to the membership
  // >>> The following doesn't work, but I hope you get the idea <<<
  $manager = new GroupRole();
  $membership->addRole($manager);
  $membership->save();
}

Any help or advice with this problem appreciated.

I was using hook_group_user_roles_alter(), but this has been removed in the latest release (8.x-1.0-beta5), so now need to implement a db update function to set it permanently.


texts: is there any way to implement java into drupal?

texts: I am a programmer, I primarily program in java, but I am now working with drupal. drupal uses html and css for most of its design, from blocks to views. but I have discovered that it is much harder to create things that are dynamically designed. what I am used to is designing things in android programming where you use XML to design the layout, and java to control it. is there any way to do this in drupal (using a module or something of the sort that will allow me to create things like blocks using java or even javascript, or something similar). also, is there a way to develop my own modules using java, or can I only do it in PHP?


texts: Multilingual redirects don't work from node url

texts:
Drupal 7, node translation method being used. Having an issue with translated content url aliases right now. Aliases work, language prefixes in urls work, but using the node/# url does not redirect to the node's alias if not in the default language. English is set to the default language.

Example:

English version: node/1 if being viewed goes to its alias, /alias.

French version: node/2 if being viewed does NOT go to its alias, /fr/french-alias, node is viewed correctly at node/2. If you view /fr/french-alias you see the node correctly as well. So you can view the French version of the node two ways when I really want only /fr/french-alias to work and if you go to node/2, I want it to redirect to its alias.

It's like the site is having the issue of applying the language prefix in the url to redirect with. How do I correct this?


texts: How can I hide the authoring information?

texts: Normally I would just click manage display and disable authoring information from showing, but with layout builder enabled, I don't have this option. I only have the Manage Layout option, which doesn't contain any way to disable the authoring information.


texts: Where are the add to cart form settings?

texts:
Im just trying to find the settings page for the add to cart form. I cant find it...

Im trying to change the setting when someone adds the same item to the cart twice it will combine it into one line item, rather than creating to separate line items as it is doing now.

I have attempted to add the setting here:

but no luck. still getting multiple line items.


texts: Drupal 8 - How to edit a user as admin without changing the password

texts:
Does anyone know how to edit user profiles as an administrator in Drupal 8(change roles in my case) without having to know or change the password?

Thanks


texts: Change path prefix URL for multilanguage

texts:
I''ve got my drupal 8 content in 5 languages and now I'm trying to change path prefix foreach lang (e.g: zh-hant by zh).

The problem cames when trying to edit some content type and I've got a 404 error. There's no problem for the content with the new path prefix

old url --> www.mysite.com/zh-hant/mycontent
new url --> www.mysite.com/zh/mycontent (works fine on front)
new edit url --> www.mysite.com/zh/mycontent/edit (Crashes with a 404)


texts: D7 - Commerce Stock - Track products in different unit (e.g. grams?)

texts: I'm using Commerce Stock to track the amount of product stock we're currently carrying. That said, Commerce Stock only seems to let me track product in increments of 1? Is it possible for me to change the unit stock is tracked in? For example, grams? E.g. If my user purchases 10 grams, it should subtract 10 from the total 100 grams in stock.


texts: Dynamically remove library based on user role, cache context not working

texts:
I want to remove all libraries of modules & themes, except those from modules/themes that are defined by me.
This should only be done for anonymous users. All libraries should be served to authenticated users.

I'm adding the user.roles cache context in the html preprocess hook and remove all library definitions that are not desired:

/**
 * Implements hook_preprocess_html().
 */
function mytheme_preprocess_html(array &$variables) {
  $variables['page']['#cache']['contexts'][] = 'user.roles';
}

/**
 * Implements hook_library_info_alter().
 */
function mytheme_library_info_alter(array &$libraries, $module) {
  /* Remove all libraries that are not needed.
  Only remove them for anonymous users, since a lot of libraries are required for the admin interface to work. */
  $allowed_modules_with_libraries = [
    'mytheme',
    'google_tag',
    'my_custom_module',
  ];

  if (!in_array($module, $allowed_modules_with_libraries) && !Drupal::currentUser()->isAuthenticated()) {
    $libraries = [];
  }
}

My problem is, that the attached libraries are not completely separated by user role cache context:

My test workflow:

Clear all caches
Requesting page as authenticated user
Contrib assets in browser sources panel:

This is as expected.

Requesting same page as anonymous user
Contrib assets in browser sources panel:

This is not as expected, nothing should be present here.

The other way around:

Clear all caches

Requesting page as anonymous user
No contrib assets are displayed browser sources panel.

This is as expected.

Requesting same page as authenticated user
Assets in browser sources panel:

This is not as expected, paragraphs and webform assets are missing.

The x-drupal-cache-contexts HTTP response header content: languages:language_content languages:language_interface languages:language_url route session theme timezone url.path url.query_args user

The user cache context is there, shouldn't the response be cached by user (including the role) then?

I tried doing this by using hook_page_attachments_alter, but not all libraries that are attached to the response are listed there.
I'm not sure if changing the library definitions with hook_library_info_alter is the right approach. Since I don't want to change the libraries. I just want to detach them from the response.

The page_cache and dynamic_page_cache modules are enabled.


texts: How to connect to default drupal database using php

texts:
I have drupal setup on my local machine (Aquia dev desktop). I created a table in my database called "pin_code". I want to write a php script that would involve connecting to the database. I have used the values from my settings.php file. Unfortunately i get the error "No connection could be made because the target machine actively refused it."

Please what could i be doing wrong?


texts: Alter a path alias depending on a node property

texts:
I use the Pathauto module and I'm trying to get, for the same content type, two different path aliases depending on a Boolean field that content type has.

I would like to have a path alias like mysite/node_name if the Boolean field value is false and  mysite/[a generic term]/node_name if its value is true.

Is there a way to do this?


texts: Can Google Bot Crawl authenticated pages?

texts: I am using Organic Groups and most of the pages i.e Discussions and related pages are only accessible to an authenticated user, can google bot crawl all these pages as well or is thrown a 403 error ?


texts:
Use Case

We will have users submitting forms that will then be mapped to one of three content types based on the information they've entered.  We don't want to burden the user with trying determine what content type to use on their own.  They should just enter the data and then we'll make the call based on that.

Best Approach

The way I see us doing this is creating a webform that we then hook into with a custom module that programatically creates the new nodes of the appropriate content type.

I wanted to check with the brain trust here that this makes sense for our use case and there isn't a module to use that makes more sense.

Thanks.


texts:
This is the situation.

I have a product type and in this type i use a term reference field. Then i add some products.
Next step, i create the product displays using the product reference field (the default one).
So far so good. Then i use views and enable the build in view for taxonomies which in non commerce site shows the nodes for each taxonomy. Now it displaying nothing. I tried to add the product relationship but still nothing.

Any ideas?? Thank you


texts: bulk update ubercart stock and threshold values

texts:
I have Ubercart running on my Drupal site and would like to bulk update my product stock levels.

I would like to accomplish this using a Views Bulk Operations Execute PHP Code operation. What code will update stock levels? I have thought about updating the stock table, uc_product_stock, but products without stock levels are not entered into the table.

Also, how do I set an initial stock value for all products?


texts: Proper way to add fields to custom content entity

texts: I created custom entity, added basefields in class and now I want to add fields. I know I could add them with UI but wondering how to do that with code. Is the proper way to add .yml files in config/install and when module is installed this config should be too or do I need to use hooks to add fields and .yml part doesnt work in this cases?


texts: What is the parameter $instance_id in the function Block::setVisibilityConfig?

texts:
I need to programatically set the visibility of a block. I've loaded the block, and I know I need to use the Block::setVisibilityConfig method, but I don't know what the $instance_id variable is.

Does anyone know what to pass here to the function?


texts:
There's a search index for the Apache Solr module. However, I don't see any way to change this index. It seems that various fields and items are added to the index without rhyme or reason.

If I wanted to index a field called "keywords" how would I go about this? Do I have to use the method described in Adding Customized Fields to the Apache Solr index in Drupal?

Basically, there's a keyword field, which will have comma separated values of keywords, and I want to index this for Apache Solr search.


texts: Why is the login redirecting to the access denied page?

texts:
This question has been asked before but I see only D7 versions of the question, and none of their answers have helped me in D8.
I log in perfectly fine with Chrome or Firefox, but IE 11 redirects to the /user/1 page (or /user/2, or whoever you are logging in as) and states 'Access Denied.'  If you enter incorrect credentials it states "unrecognized user/pass," but if you enter correct ones it just does the redirect and nothing happens.
This is on a fresh install of D8 RC2 and what's worse is I can do a fresh install of D8 RC2 on a different server and IE 11 login works fine.  It's something about my server that's causing this. I thought it might be cleanURLs but mod-rewrite is on for both servers.
D7 solutions seem to say, check settings.php and the cookie_domain or base_url variables, but those don't seem to be a part of Drupal 8.
I have cleared IE's cache/cookies about a thousand times.


texts: Repeated elements in translations of a block view

texts:
I have a small problem when translating taxonomy terms inside of a block view.

View configuration:

Output:

The translation is correct but the element quantity is incorrect. The idea is to have one of each term in each block regardless of translation.


texts: Exposed date select list in descending order

texts:
Using Drupal 7 Views with exposed filter on date, the select list is working fine. Problem is that the list is always in ascending order, for example 2000:2014, but we want it the other way round, like 2014:2000 so that the recent years are closer at hand.

I don't mind if the solution (changing date list to descending order) is affecting every select list of the whole site. Preferably if don't need to change code.


texts:
I have a small problem with altering js code loaded from custom module. I need to change the js script from a module for a custom page

Module code code :

function module_script_src($environment) {
  $script = '';
  $script_id = variable_get('script_id', '');
  $script_hash = variable_get('script_hash', '');
  switch ($environment) {
    case 'prod':
      if ($script_id && $script_hash) {
        $script = '//example.com/' . $script_id . '/lib-' . $script_hash . '.js';
      }
      break;

    case 'dev':
      if ($adobe_dtm && $site_hash) {
        $script = '//example.com/' . $script_id . '/lib-dev' . $script_hash . '.js';
      }
      break;

  }
  return $script;
}

The goal is to change $script just for one custom page, i try to add case for my custom page, simply new case to module

 case 'custom page':
       if ($node && $node->nid = "my_node_id"):
     $script = '//example.com/' . $script_id . '/custom-' . $script_hash . '-.js';
  }
      break;

But it does not work, if it possible in module to load custom is for the specific custom page?


texts: Is there a 'text or user reference' module?

texts:
Currently, I'm planning on using a text field for full names (added fields field_profile_full_name and field_profile_partner) on user entities, so that one user can link to another. However, I might not get matching entries in autocomplete (which rules out user references). What I want is this:

A match to text entered in field_profile_partner is found in field_profile_full_name: return/use the text in field_profile_full_name.
A match is not found: use the text the user entered in field_profile_partner, without creating a new user.

I know that a 'text or node reference' module exists for Drupal 6 and 7, but I've been unable to find a module that does the same thing for user references. Does such a module exist or will I have to clone and adapt 'text or node reference'? Can I configure entityreference to give me this functionality?

Note: I know that I could write a custom form and autocomplete page to handle this, but the functionality needs to be on the user account/registration form. If this can be done in hook_form_alter, please provide it as I've had no luck getting that hook to work whenever I implement it on anything.


texts:
Does anyone know of a way to integrate Drupal 7 with Magento?

I see that the Magento module doesn't have a version for Drupal 7, but I'd like to keep my Drupal installation shiny and new at the start of the project. I'm talking to the powers that be about using the commerce module instead, but I suspect that's going to be a non-starter.


texts: Entity Reference - Auto complete field in content type

texts:
I had an issue before (please click here to see it) related to entity reference and I was able to solve it with no problem. Now I have another issue:

I have 2 content types called projects and partners.

In the content type partners I have a field "projects" and I'm able to select from all the project pages that exist in my site. So far so great.

Now, in the content type projects I have a field "partners" and I would like this field to be autocompleted with the partners where that project was selected before.

What's the best way to do this?

Please let me know if you need any clarification, I know my English isn't the best.

Thanks so much in advance!


texts: How do I define an external URL in settings.php and call it in a custom module?

texts:
In the settings.php file, there are (for example) $base_url, $settings['hash_salt'].

I defined $settings['external_url'] = "google.com";

In my custom module, I want to get the $settings['external_url'] value.

<?php

namespace Drupal\my_custom_module\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Site\Settings;
use Drupal\Core\Form\FormStateInterface;

/**
* Contribute form.
*/
class MyCustomClass extends FormBase {

   private $base_url;
   public function __construct(){
       $this->base_url = Settings::get('external_url') . '/maps';

   }

   public function validateForm(array &$form, FormStateInterface $form_state) {
      $pb= $form_state->getValue('pb');
      $url = $this->base_url . '?timeline' . $pb;
   }
}

Then I got this error:

Notice: Trying to get property of non-object

I am using Drupal 8 and PHP 7.


texts: Is there any way to show a "computed field" value in edit mode?

texts:
I have a content type (Structure) to which I added a text computed field.
In a module I added the following code.
function computed_field_field_reference_compute($entity_type_manager, $node, $fields, $delta) {
  return GedProjectUtils::computeReference($node);
}

It works: In view mode, the field is well calculated.
Now I would like to show this field on edit mode. I added this code to the module.
function gedproject_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'node_structure_edit_form') {
    $form['field_reference']['widget'][0]['value']['#type']='textfield';
    $form['field_reference']['widget'][0]['value']['#title']='Référence';
    $form['field_reference']['widget'][0]['value']['#attributes']['readonly'] = 'readonly';
  }
}

The field is shown empty.

What do I need to change in the code I added?


texts:
How do I change the URL present under Home » Administration » Configuration » System in my Drupal site?
I want to get rid of the stuff circled in red, but it only seems that I can add different pages only in the blank input box next to it.


texts:
Having code issue.

I am rendering a the regions[ad_spot] = 'Ad Spot' so that it shows up after the first row.

For some reason it is not showing the region even tho I have put a block in there. So far I have not had an issue with my other regions I have made.

http://dev-honey-in-the-wild.pantheon.io/

Code is here: https://codeshare.io/bHx5N

Am I doing this correctly?

thanks!


texts: Date popup field won't display in tableselect element

texts:
I am attempting to embed a couple of date fields within a tableselect element, and after trying to use both textfield and date_popup field types, I can't get either to work. Here's my form function using textfields:

function language_dashboard_overview_form($form, &$form_state, $entity) {
  $form = [];
  $options = [];

  $header = [
    'language_locale' => t('Language Locale'),
    'status' => t('Status'),
    'staging_url' => t('Staging URL'),
    'start_date' => t('Start Date'),
    'end_date' => t('End Date'),
    'display_title' => t('Display Title')
  ];

  $translations = $entity->translations->data;

  foreach($translations as $locale => $locale_data) {
    // Get data for all the other fields here
    ...
    // Define start and end date text fields.
    $start_date = new DateTime($entity->field_locale_publishing_dates[$locale][0]['value']);
    $new_start_date = $start_date->format('m-d-Y');

    $end_date = new DateTime($entity->field_locale_publishing_dates[$locale][0]['value2']);
    $new_end_date = $end_date->format('m-d-Y');

    $start_date_field = [
      'data' => [
        '#type' => 'textfield',
        '#size' => 10,
        '#maxlength' => 10,
        '#default_value' => $new_start_date
      ]
    ];

    $end_date_field = [
      'data' => [
        '#type' => 'date_popup',
        '#date_format' => 'm-d-Y',
        '#date_year_range' => '0:+20',
        '#default_value' => $new_end_date
        ]
    ];

    $options[] = [
      'language_locale' => $locale_link,
      'status' => $status,
      'staging_url' => $stage_url,
      'start_date' => $start_date_field,
      'end_date' => $end_date_field,
      'display_title' => $title
    ];

  }

  $form['dashboard'] = [
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options
  ];

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

  return $form;
}

With that, I get the fields, but no default value is filled in (and I've verified that the $start_date_field and $end_date_field  variables have the desired data).

If I try it with date_popup fields like so:

$start_date_field = [
  'data' => [
    '#type' => 'date_popup',
    '#date_format' => 'm-d-Y',
    '#date_year_range' => '0:+20',
    '#maxlength' => 10,
    '#default_value' => $new_start_date
  ]
];

$end_date_field = [
  'data' => [
    '#type' => 'date_popup',
    '#size' => 10,
    '#maxlength' => 10,
    '#default_value' => $new_end_date
  ]
];

I get no field at all in those columns. From the multiple items I've read on this, I'm adding the fields correctly to the tableselect. Is there something else I'm missing?

UPDATE: I discovered that for the text field, you use #value instead of #default_value. changing that shows my default date as desired. so the only remaining issue is that I can't get anything to show for a date_popup field.


texts: Profile fields shown during registration

texts:
I want to have one profile with some fields shown during registration and other fields not shown during registration. I can't seem to do this.

I am using the Profile2 module (drupal.org/project/profile2)

From what I can see, a profile selected to "Show during user account registration" will show all fields associated with that profile during registration. And a profile that is not selected to show during registration will not show any fields during registration.

I am not seeing any options within a profile to make a given field override the selected setting for the profile.

So currently I have two profiles for the users - one with the fields I want shown during registration and a second profile with the fields I don't want shown during registration.

The result is two profile links for the user, which is not what I want.

How can I make a given profile field override the profile's registration setting?

Thanks for your answer, CR47. I am currently unable to select your response as the answer or even add comments because of a JavaScript problem. I will select your answer as soon as the error is resolved.

https://meta.stackexchange.com/questions/188125/dreaded-error-stack-overflow-requires-external-javascript-from-another-domain


texts:
I just updated the Drupal Commerce installation to beta 7 which includes support for promotions and coupons. I just can't seem to get the coupon redemption form in the cart to test this functionality. I checked the cart view, there is a field 'Coupon' in the global footer, but that is just meant to show the already activated coupons I believe. At least it didn't do anything for me.

I tried to add 'Coupon' to my relationships in the view, but this broke down the website (incorrect query generated).

In the code I also noticed the CouponRedemption FormElement. I'm not sure how to add this to my cart (view), but that seems to be what I need.


texts: Set view's filter to show nodes of entity refference field of current node

texts:
I have nodes of content type "product" and this content type has an entity reference field with multiple values, that contains references to another product nodes.

Is it possible to set the filter of view block to show only products that are in current opended product's reference field?


texts: insert webform component values into a custom table

texts:
i am having trouble storing webform component values into a custom database table,
i have created a custom module to insert the data into the table but its not working and i can't figure out where my problem is can someone please help
here's my code  thanks

<?php
function customform_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'webform_client_form_24') {
        $form['#submit'][] = 'customform_additional_insert';
        if ($node = menu_get_object()) {
            $form['submitted']['node_id']['#value'] =$node->nid;
            $form['submitted']['amount']['#value'] = @$node->field_needed_amount['und'][0]['value'];
            $form['submitted']['full_name']['#value'] = @$node->title;
            $form['submitted']['image']['#value'] = @$node->field_student_photo['und'][0]['fid'];
        }
    }
}

function customform_additional_insert($form, &$form_state) {
    $data = $form['submitted'];

    // Insert a record into a 3rd-party module table when a submission is added.
    db_insert('sponsorship')
        ->fields(array(
            'n_id' => $form['submitted']['node_id']['#value'],
            'user_id' => 1,
        ))
        ->execute();
}
?>


texts: Point me in the direction of developing new forum features?

texts:
Probably the most confusing part about Drupal for a beginner (read: Me!) is figuring out which modules should be used to develop new functionality. I'm looking for the path I would need to take to develop the specific functionality I'm trying to create.

This is what I'm looking to accomplish:

-Attach a user created "idea" or "opinion" to a forum post or thread

-Allow users to vote on & modify these "ideas" and "opinions"

Any leads are appreciated.


texts: What does "Argument #1 is not an array in _form_set_class()" mean?

texts:
In Drupal 7, I'm getting this error and want to fix it:

  Warning: array_merge() [function.array-merge]: Argument #1 is not an array in _form_set_class() (line 4021 of {my site}/includes/form.inc).
  Warning: array_merge() [function.array-merge]: Argument #1 is not an array in _form_set_class() (line 4021 of {my site}/includes/form.inc).
  Warning: implode() [function.implode]: Invalid arguments passed in theme_radios() (line 2746 of {my site}/includes/form.inc).

What does this mean, and what should I do about it?


texts: how to make images clickable in a listing (numerous thumbnails)

texts: in our event_parent http://imgur.com/a/ezlMM content view we have a listing (field_listing) field that contains numerous thumbnails and they need to redirect to their specified event page. we are on drupal 7


texts: JavaScript dependencies for a specific block or page

texts:
I am migrating a Drupal 7 site to Drupal 8.  I have a custom block (visible only on the home page) that has some tabs on it.  Currently, the tabs are implemented using jQuery UI tabs and it would be nice (but not necessary) to keep them using that.

In order to get this to work, I need to use the jQuery and jQuery UI JavaScript files.  However, everything I have seen online talks about module and theme dependencies.  There doesn't seem to be any way to tell Drupal 8 that a specific block (or page, etc.) needs specific JavaScript files loaded in order to work correctly.

I know that I can just import the javascript files directly with script tags, but that doesn't seem to be the preferred method, especially considering all of the various optimizations that are part of Drupal (to make sure that a file is only included once, for example).

How do I include the required JavaScript files (available in core) on a specific page or as part of a specific block?

I don't really want to create a custom module for every time that I need to do this, but all of the references I have found online talk about dependencies for themes or modules, nothing for specific content.

EDIT: Multiple suggested answers involve PHP, custom modules, YML, etc.  These are not what I am looking for.  I am looking for a solution for front-end content creation (pages, nodes, blocks for the "custom block library", and so on), not requiring back-end coding and development.  Modules on Drupal.org that allow this to be done generically are perfectly acceptable.  Maybe I need to create one and put it up there, but I would think there should be an existing solution by now.  It seems strange to me that there isn't, but maybe I'm missing something.


texts: Webform Submission not Working with .tpl.php file

texts:
I have a webform that i needed to style a little differently. So I did this creating a webform-form-3.tpl.php file (the node of my form is 3). Inside that I have this code:

<?php // Contact Us form ?>

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

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

Unfortunately, by doing this, it stops the submitting functionality of the form. I am assuming that I messed up on missing some of the submitting options. Does anyone have any ideas where i may have gone wrong? Any help would me much appreciated! Thank you!


texts:
Apachesolr search and attachments ver. 6.x-1.x

Apachedolr by default has filters for node content types.  However, there are no filters for file attachments attached to nodes. Furthermore, the  node content type filters do not filter file attachments, even if they are attached to nodes that match the filter.  So, if you execute a search, and receive results with file attachments, there is no way to filter the results to receive all nodes and file attachments within one node content type.

Is it possible to create a content type filter for both nodes and file attachment documents? If so, how?


texts: Combination of textfields and checkboxes in a custom form

texts:
I need to create a custom form that contains a list of checkboxes and textfields next to each other, as in:

There are many meal items in the list. Right now I'm using something like:

$form[$meal_type->sku] = array (
    '#type' => 'fieldset',
    '#attributes' => array('class' => array('container-inline')),
  );
  $form[$meal_type->sku]['meal'] = array (
    '#type' => 'checkbox',
    '#title' => $meal_type->title,
    '#return_value' => $meal_type->sku,
  );
  $form[$meal_type->sku]['quantity'] = array (
    '#type' => 'textfield',
    '#default_value' => 1,
    '#size' => 5,

  );

This creates an individual fieldset for each meal item and quantity.  I just wanted to see if there are any suggestions for a better approach. Thanks!


texts:
I'm trying to use the Token Module to create a menu item that links to the user overlay in Drupal so that users can find their CiviCRM profiles easily. So it should be going to something like:

/user/peradmin#overlay=user/%/edit

I'm having trouble working out how a token can be created - or found! Any ideas?

I've been following the instructions from here but I haven't worked it out.


texts: How to print Json data from Facebook in a block?

texts:
I would like to print the amount of Facebook likes for a url into a block.
The Facebook API returns JSON like so:  https://api.facebook.com/method/fql.query?query=select%20like_count%20from%20link_stat%20where%20url=%27https://drupal.stackexchange.com/%27&format=json

What is the Drupal 8 way to print this data in an block?


texts: Make Facebook comments on Facebook page show up on my Drupal site

texts: Using Drupal 7. I post some stories on Facebook and receive a lot of comments. I want these comments to also show up on the article page on my drupal site, not just on the Facebook page inside facebook. That is, when users comment on the post inside Facebook, i want the comment to show on the article page on my drupal website. Any ideas in getting this to work?


texts: How can I get Differentiation to work with taxonomy?

texts:
I was able to successfully set the display of Markers in different colors in the map generated by the view with Format set to "Map (Leaflet API, via IPGV & M)" using the differentiation system based on Content Type. I just enter the machine name of the Content Type and associate a color for the Marker and it works fine.
Since associating a Marker with a Content Type requires a different Content Type for each Differentiation, in the end I will have many Content Types and so I chose to use the Differentiation method using taxonomy terms. With a Term Reference I can only have one Content Type, which makes everything easier ..
The problem is, after a week of testing and testing, I can't get Differentiation to work with taxonomy.
With the Content Types I entered the machine names to be associated with the colors and everything worked fine but with the taxonomy I don't know which machine name to use. I tried to simply enter the name of a term but the color is not intercepted by the Differentiation System. The following tip also appears above the Map:
IPGV & M: no differentiator values found for node_term_node_tid. Cannot assign marker images.
I also tried with a flat vocabulary and a hierarchical one but I can't solve the problem.
I added the field in the View that I use in the Differentiation assignments:
Content: All taxonomy terms (All taxonomy terms)
I don't know what value to put at the requested node_term_node_tid.
I also tried with a decimal field but without success :(
Any suggestion to solve this problem?
Best Regards


texts: REST post plugin broken from Drupal 8.4.5 to 8.5

texts:
I just upgraded my Drupal installation from 8.4.5 to 8.5
Now my REST plugin is not getting any data on POST.

My client post like this:

POST /rgptemprest?_format=hal_json HTTP/1.1
Host: 10.10.10.1:443
Authorization: Basic ****REPLACED******
Content-Type: application/hal+json
Accept: application/hal+json
User-Agent: ESP8266
Connection: close
Content-Length: 108

{"netcard":"997800940160","DS18B20":"28ADBCE70800008C","battery":"2952","temperature":"23.375","rssi":"-33"}

On my drupal server I have a plugin
with this code (not complete)

public function post(array $data = [])
{
    var_dump($data);
    if (!empty($data))
    {

....

And here I see the difference
on 8.4.5 it show an array of the data sent:

array(5) {
  ["netcard"]=>
  string(12) "997800940160"
  ["DS18B20"]=>
  string(16) "28ADBCE70800008C"
  ["battery"]=>
  string(4) "2952"
  ["temperature"]=>
  string(6) "23.500"
  ["rssi"]=>
  string(3) "-33"
}

but on 8.5 it's empty

array(0) {
}

What has changed between 8.4.5 and 8.5? And what do I need to change?


texts:
I am trying to meet the following requirement:

I want to create a node (custom content type) that contains only a paragraph reference.

I have the following paragraphs in my node

Billboard (large image + Caption)
Testmonial (slideshow sentences)
Body
Here i want to display a view that contains news articles (nodes from the custom news content type)
Call to action

But i can't seem to do this properly?

I can create a block display for my view and attach it to the page by path, but then the view is located below my paragraphs, where I want the view to be one of the paragraphs, since there is a call to action that needs to be located below the view.

Anyone ever tried this?

All suggestions welcome!

If you have a solution that does not use paragraphs, I am also happy to hear!

Many thanks in advance

EDIT:
After some additional searching, it seems that for D7, this module seems to be capable of doing this: https://www.drupal.org/project/entityreference_views_formatter more information can be found here: https://www.drupal.org/node/2756315

Still no solution for D8 though...


texts: Deny access to URL non-authenticated users

texts:
I have a drupal 7 site with an academic paper that should be accessible only to authenticated users. At the moment the paper is set up as a hyperlink in the full text field of a biblio page and only authenticated users can reach the page.

However, if non-authenticated users get their hands on the url that leads to the pdf version of the paper, they can download it. How can i redirect non-authenticated users that use the url to an error page?


texts: New field widget (for custom field type) does not save data

texts:
I am trying to make my own field type. I order to do it I modify field_example from drupal examples.

I added new widget_form (declared also in widget_info). The problem is, value is not saved in the database using my widget.

CODE:

function field_example_field_widget_info(){
  return array(
      'field_example_text' => array(
      'label' => t('Choose game type using text input'),
      'field types' => array('field_example_rgb'),
    ),
    'field_example_list' => array(
      'label' => t('Choose game type using select'),
      'field types' => array('field_example_rgb'),
    ),
  );

}

function field_example_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $value = isset($items[$delta]['rgb']) ? $items[$delta]['rgb'] : '';

  $widget = $element;
  $widget['#delta'] = $delta;

    $options = array('Tic Tac Toe', 'Memory', 'Mastermind');
    $default_value = array(1,2,3);

  switch ($instance['widget']['type']) {
    case 'field_example_text':
      $widget += array(
        '#type' => 'textfield',
        '#default_value' => $value,
        // Allow a slightly larger size that the field length to allow for some
        // configurations where all characters won't fit in input field.
        '#size' => 1,
        '#maxlength' => 2,
      );
      break;

    case 'field_example_list':

    $widget += array(
        '#type' => 'select',
        '#default_value' => $default_value,

        // Do not display a 'multiple' select box if there is only one option.
        //'#multiple' => $multiple && count($options) > 1,
        '#options' => $options,
      );
        break;
  $element['rgb'] = $widget;
  return $element;
}

Validation was also modified:

function field_example_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  foreach ($items as $delta => $item) {
    if (!empty($item['rgb'])) {
      if (!preg_match('@^[1-3]$@', $item['rgb'])) {
        $errors[$field['field_name']][$langcode][$delta][] = array(
          'error' => 'field_example_invalid',
          'message' => t('Invalid game number: 1 - 3.'),
        );
      }
    }
  }

}

Value is not saved into database using ..._list, but is saved using ..._text and proper values (while adding; in the adding form) are displayed in the source code (in both case). I have no idea how to fix it.


texts: How do I theme repeating dates output field?

texts:
I currently have a calendar of events and each event has multiple repeating dates. Now when i display them it shows all those repeating dates in a long list. How would i theme this to show only if there are more than 3 dates to display":

Has multiple dates in the coming month

I was thinking of doing this via tpl's, but what should i name my tpl as to override this output?


texts: Drupal 7: Variables in external file access

texts:
Im having a tough time accessing variables from my own external file.

I gave this file:

?php include_once('/exercise_names.php'); ?

Which contains the following:

 ?php

//Exercise Names

$memory01 = '1';
$memory02 = '2';
$memory03 = '3';
$memory04 = '4';

?

I cannot get the page to render the names.  I keep getting the following errors:

Notice: Undefined variable: memory01 in eval() (line 4 of /home/webapps/drupal/releases/modules/php/php.module(80) : eval()'d code).

Basically its telling me it cant find the required variables, but they are in the file.  For some reason it cannot read the included file.

Any ideas?

thanks, Mac


texts: Search/filter box for Views on separate page

texts:
I am running the latest versions of Drupal 7 and Views 3.

I have a Views catalog with exposed filters for two different fields. What I would like to accomplish is to have a search box for the catalog on a different page (let's say the front page) with one field only - searching/filtering within either of the two fields. Upon submission, the user is taken to the catalog page with the results showing, and the exposed filters are free to be used again.

The only way I've been able to approximate this is to have a Global Combine fields filter running which is hidden on the catalog page, and utilized by a search filter box that I hard coded via a module. But the fact that the hidden combine field will actually have content in it once the page is loaded compromises the functionality of the visible exposed filters.

Is there a way to go about doing this?


texts: Is there a module to create incentivized social media marketing conditionals?

texts: Currently I'm looking to implement a feature where a user can facebook/twitter share a link or a snippet of text to their social media network and then have drupal capture that feedback to see if they did it or not. From there I want to be able to give them a % discount when purchasing something from my site which is running drupal 7 commerce. Is there something like this built already? if not how would one go about doing this feature?


texts:
I'm trying to send attachments with my email from Drupal. In my custom module i have added:

class SponsorprogramMailSystem implements MailSystemInterface {
  /**
   * Concatenate and wrap the e-mail body for plain-text mails.
   *
   * @param $message
   *   A message array, as described in hook_mail_alter().
   *
   * @return
   *   The formatted $message.
   */
  public function format(array $message) {
    $message['body'] = implode("\n\n", $message['body']);
    return $message;
  }
  /**
   * Send an e-mail message, using Drupal variables and default settings.
   *
   * @see http://php.net/manual/en/function.mail.php
   * @see drupal_mail()
   *
   * @param $message
   *   A message array, as described in hook_mail_alter().
   * @return
   *   TRUE if the mail was successfully accepted, otherwise FALSE.
   */
  public function mail(array $message) {
    $mimeheaders = array();
    foreach ($message['headers'] as $name => $value) {
      $mimeheaders[] = $name . ': ' . mime_header_encode($value);
    }
    $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
    return mail(
      $message['to'],
      mime_header_encode($message['subject']),
      // Note: e-mail uses CRLF for line-endings. PHP's API requires LF
      // on Unix and CRLF on Windows. Drupal automatically guesses the
      // line-ending format appropriate for your system. If you need to
      // override this, adjust $conf['mail_line_endings'] in settings.php.
      preg_replace('@\r?\n@', $line_endings, $message['body']),
      // For headers, PHP's API suggests that we use CRLF normally,
      // but some MTAs incorrectly replace LF with CRLF. See #234403.
      join("\n", $mimeheaders)
    );
  }
}

and i can send mails with html, that part is working.

But when i try to attach a file it does not arrive in my inbox. I attach my test file like this:

$attachment = array(
        'filecontent' => file_get_contents(DRUPAL_ROOT . '/README.txt'),
        'filename' => 'test.txt',
        'filemime' => 'text/plain',
      );

But nothing arrives.

Anyone know how i can fix it?


texts: What's the alternative to using the Conditional Rules module?

texts:
The Conditional Rules module allows for including Rules Conditions within Rules Actions (using its If/Else constructs), something you cannot do by only using the Rules module. Here are just a few (out of many) typical questions that can be solved by using Conditional Rules:

How to create a rule to assign roles to users based on some checkbox items in their profile?
How to use Rules to email users when any field(s) is changed in a node (and include the unchanged/changed values for that field)?

However, there are some issues with the Conditional Rules module, such as:

It does not have an official release for D7 yet.
There is not a lot of documentation about it (and no Community documentation).
There are some scenarios for which this module produces incorrect results.

Is there any alternative solution for building equivalent Rules logic, and which doesn't require using the Conditional Rules module?


texts: Add epsacrop to programmatically added image field

texts:
I'm adding an image field to my theme form in order to setup a default image for the user.
I'd like the user to be able to use EPSAcrop to crop the image he uploads here.

Is this possible, if so; How?

This is what I have now:

function MYTHEME_form_system_theme_settings_alter(&$form, &$form_state, $form_id = NULL)  {
  $form['header_images'] = array(
    '#title' => t('Header image'),
    '#type' => 'managed_file',
    '#description' => t('The default header image on every page. Unless a header image is selected in the node of the page.'),
    '#default_value' => variable_get('header_images', ''),
    '#upload_location' => 'public://header_images/',
    '#upload_validators' => array('file_validate_extensions' => array('png, jpg, gif')),
  );
}


texts: Drupal Commerce 2 updating with composer

texts:
I am a retired civil servant -- NOT a developer by a long shot -- and while I have used Drupal for about 19 years, I am new to composer and drush and Drupal Commerce 2.

I was able to successfully create a Drupal commerce 2 site with the following command:

composer create-project drupalcommerce/project-base mystore --stability dev

My question is this:  using composer, how do I update the project-base?  I visited the Drupal commerce wesite here:

https://docs.drupalcommerce.org/commerce2/developer-guide/install-update/updating

and the instructions there said to use the following command:

composer update --with-dependencies "drupal/commerce*"

Is that in fact the correct means of updating the project-base?  Will Composer automatically do the updating in the correct directory ("mystore")?  And is it generally a good idea to update all dependencies at the same time?


texts:
How can I check if a user has a certain role?

I found this but it is for Drupal 6.


texts: How can I monitor the number of user password reset requests?

texts:
I would like to keep track of the number of times users request that their password be reset to make sure that users are able to reset their password successfully.  I am getting reports a couple of times a month that users are experiencing difficulty resetting their passwords; to see how common this is, I want to see if users are requesting their password be reset several times in a row (within the same day).

To do this, I was thinking of e-mailing myself every time a user requests that their password be reset.  My first instinct was to do this with Rules, but there is no Event like "When a user requests that their password be reset."


texts: Storing additional data to image field, like title and alt

texts:
I'm using Multiupload Imagefield Widget on a node form and after the image upload is completed, I'ld like to be able to add a term ID (TID) of a certain vocabulary to each image and store this TID alongside the image in the same database table.

In my custom module, I've altered the related database table, adding the "tid" column. I've also managed to add a field to the form right after "title" and "alt" fields of each image using hook_field_widget_WIDGET_TYPE_form_alter. My problem now is that I can't make the values to get stored or retrieved. What are the basic steps to add that "tid" field to my system?


texts: How can I identify what version of Drush is installed on a given system?


texts: How can I set up RNG Conflict with a multi day event

texts:
I'm loving the RNG module and the conflict functionality, but I'm a little confused regarding how to set up my seminars and events.

My current use case is I have a simple four-day event with one optional seminar every day.

Initially, I created one registration type "spring seminars", and one event type "Registration". Then I created the four seminars as content, and couldn't figure out how to allow people to register for more than one, as conflict made the other three days unavailable as soon as a registrant registered for one day.

Then I went back and created four different event types, "spring seminar day 1, spring seminar day 2, etc." Then I recreated the four seminars, one per event type, and it allows registrants to register separately. This allowed registrants to register for more than one, but doesn't allow me to keep all sessions under the same seminar [event type] and doesn't work well with calendar if I decide to have more than one seminar per event per day [when I would like to keep them all under the same event type]. It also seems like I was missing a simple "no conflict" option when all four seminars were under the same event type.

Here's the basic layout of the two seminar [registration type?] & session [event?] types the Kobe Education Commission puts on;

3-5 day seminar > 1 timeslot per day > 1 session per timeslot
Registrants can register for any of the events as there is no conflict with either timing or with having specific topics for different groups of registrants. I'd like these to be the same registration type "spring seminar" if possible.
1 day seminar > 5 timeslots per day > 3-5 sessions per timeslot
Registrants can only register for one seminar per timeslot, and there may be specific sessions that a group of registrants isn't eligible for.


texts: Add execute button to Commerce POS modal?

texts:
I'm building a custom POS modal similar to the POS_Button_Modal_View -based ones that present a view. I wrote a modal that presents a page from a given callback:

class POS_Button_Modal_Page extends POS_Button_Modal {

  public function modalPage(CommercePOS $pos, $js) {
    $form_state = array(
      'title' => drupal_get_title(),
      'build_info' => array('args' => array($pos->getState()->getOrder())),
      'ajax' => $js,
      'pos' => $pos
    );

    if (!$js) {
      return drupal_build_form($this->config['page callback'], $form_state);
    }

    $output = ctools_modal_form_wrapper($this->config['page callback'], $form_state);

    return $output && !$form_state['executed'] ? $output : FALSE;

  }
...

The modal displays my page as intended, but I don't know how to build a submit button that works like the buttons in the POS-provided views.

The view in, eg. the SetUser POS modal uses the commerce_pos handler to render a button that executes the command:

class commerce_pos_handler_field_pos_command extends views_handler_field { ...

How can I build a submit button in my custom modal that executes my new command?

My command extends POS_Command with my custom implementation of execute()

class POSCommand_MyCommand extends POS_Command {

  function execute(CommercePOS $pos, $input = '') { ...

It seems like a POS_Button_Command should be created and rendered in the modal. But how does that get connected to my command?