texts: ShippingOrderProcessor not registered well?

texts:
I'm trying to implement @jsacksick solution which should force displaying shipping costs on cart page (normally it doesn't exist at that step yet). I created a new module for this and it's structure is simple:
shipping_fix
  src
    ShippingOrderProcessor.php
  shipping_fix.info.yml
  shipping_fix.module
  shipping_fix.services.yml

ShippingOrderProcessor.php is exact copy of @jsacksick class:
https://gist.github.com/jsacksick/fde031197df92236ef5a916775e17a2e
info file contains:
name: Shipping fix
description: Fixes missing shipping info on cart page
type: module
core: 8.x
dependencies:

module file is empty and services file contains:
services:
  shipping_fix.shipping_order_processor:
    class: Drupal\shipping_fix\ShippingOrderProcessor
    tags:
      - { name: commerce_shipping.shipping_order_processor, priority: -300 }

But it's not working. I tried setting break points inside __construct() and process() methods of that class, but they are never reached.
Tried changing last row here to:
 - { name: commerce_order.order_processor, priority: -300 }

as explained here: https://docs.drupalcommerce.org/commerce2/developer-guide/orders/order-refresh-and-process
but then my site crashes when I try to clear the cache?
So to me it looks like that I didn't register this processor object well. Most likely problem is in services file, but I can't figure out what it is ("commerce_shipping.shipping_order_processor" is correct value?).
Tried dumping services with drush like:
drush devel:services
drush devel-container-services
drush devel-services

and even devel mode is turned on for each try I get:
Command "devel-container-services" is not defined.
or similar.
I activated the my module of course, tried clearing caches, but didn't help.
Update:
The error which I get when I change last row of services file to:
 - { name: commerce_order.order_processor, priority: -300 }

is:
Service 'shipping_fix.shipping_order_processor' for consumer 'commerce_order.order_refresh' does not implement Drupal\commerce_order\OrderProcessorInterface.
And ShippingOrderProcess.php file starts with:
<?php declare(strict_types=1);

namespace Drupal\my_module\OrderProcessor;

use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_order\OrderProcessorInterface;
use Drupal\commerce_shipping\ShipmentManagerInterface;
use Drupal\commerce_shipping\ShippingOrderManagerInterface;
use Drupal\profile\Entity\Profile;

/**
 * Ensures there are shipments from the start.
 */
final class ShippingProcessor implements OrderProcessorInterface {

  /**
   * The shipping order manager.
   *
   * @var \Drupal\commerce_shipping\ShippingOrderManagerInterface
   */
  protected $shippingOrderManager;

  /**
   * The shipment manager.
   *
   * @var \Drupal\commerce_shipping\ShipmentManagerInterface
   */
  protected $shipmentManager;

  public function __construct(ShippingOrderManagerInterface $shippingOrderManager, ShipmentManagerInterface $shipmentManager) {
    $this->shippingOrderManager = $shippingOrderManager;
    $this->shipmentManager = $shipmentManager;
  }

...

Update 2:
Managed to clear the cache:
For my file structure name space has to be:
namespace Drupal\shipping_fix;

Also changed servies file and now it looks like:
services:
  shipping_fix.shipping_order_processor:
    class: Drupal\shipping_fix\ShippingProcessor
    arguments: ['@commerce_shipping.order_manager', '@commerce_shipping.shipment_manager']
    tags:
      - { name: commerce_order.order_processor, priority: -300 }

Now cache clearing works, but I still don't see shipping costs on cart page...


texts:
i try to create a multilingual page with drupal.

http://alarabi.biz/category-listing

I created some categoreis and translated them with the Internationalization plugin and i18nviews.

So I can chouse the language in views settings

but all I get is language "und" I think it means undefined.

How to fix it? Terms are translated.


texts: Show views display based on exposed filter value

texts:
I've a views with 2 different displays which are Picture View and List View, both sharing the same exposed filter(the query string).

I have an exposed filter block, one of the exposed filter(Radio Button) is View by: 1) Picture view 2) List View

How to show the respective views result based on user selection (View By filter)?

Updates:
My intention is to let the user to choose which Display she wants to see before clicking the Apply/Search button of the exposed filter block. There is only ONE display at a time, no tabbed/links for multiple display option. Solution similar to Views Mode module is not i looking for.


texts: Filter referenced item without losing other content

texts:
I have 2 entity types Content type A and B.
Content type B has a date field and an entity reference to A.

I need a view that shows all the nodes of content type A
But also shows all the referenced content, until this point I have no problem.

The only problem is that the content type B needs a filter to only show the content from this year. But when I add a filter to the date field all the nodes that don't have an entity reference also get filtered out.

Content type A are assets

Fields:

Title
Address
lat/long

Content type B is the maintenance of these assets

Fields:

Title
Entity reference to A
date field

Now I want to show all the assets in a view.( also the ones that don't have maintenance done)
In the same view there should be a column with all the maintenance within a certain timespan.

When I have this view i can put these on a google map and show which assets need maintenance and which are already done


texts:
I have created a view, which basically queries files of type image. That view creates a block, which associated with a certain content type. So the block is displayed whenever one of the nodes of that type is displayed, exactly what I would like to have.

Each of the files displayed has an entity reference field, which contains multiple references to that content type. So that is a one to many relationship, where one image can have multiple nodes of that type associated.

Is it possible within the views ui, to set a contextual filter that it sorts out each file, whose entity reference field (to that content type) contains the current node id?

In pseudo SQL the statement should look like:

SELECT filename, path, node_refs FROM files WHERE node_refs contains <current node id>;

Thanks in Ahead!


texts: How to get users with similar term as current logged in user?

texts:
On /admin/config/people/accounts/fields, I added several term reference fields, for example: profession/skill/interest. Now I need to show users with similar profession/skill/interests as current logged in user.
There is a module similar by terms, unfortunately, it does not support user entity.


texts:
i have any fields form register user drupal 7. I want to when user choice select box : User 1 or User then any fields hide or show. Please help me
Thank to all.


texts: I was wondering if it is possible to either remove or rename the "Home" tab Drupal puts in by default. The site is being used as a store/shopping cart and for it's purposes does not need a convention "Home" tab.


texts: How to give the image path in the check box field option for a content type

texts:
I am creating a checkbox field in my content type and I want images to be displayed as checkboxes option.

In Drupal 7, there is a feature to add images as field list, but I am unable to give the full path for that image.

See the below screenshot for better understanding.

I cannot give my image path as http://localhost/sites/default/.. because the base path changes when we move to the Production. How can I achieve this?


texts:
I'm trying to utilize some pre-built code to display data in a Block. Specifically, show a crude oil price quote in a block.

On oil-price.net, they give you code to embed on an HTML site to display a price quote. So how the heck do i get this on a Block?...it looks like this:

This is what they give to embed...

 To get the BRENT oil price, please enable Javascript.


texts: Is there a Drupal Commerce integration with Facebook/Instagram Shopping?

texts:
Facebook catalog allows selling through their catalog. They have integrations for several platforms like Big Commerce and Shopify. The basic integration without commerce requires manual shipping. Big Commerce verified that their Facebook catalog integration allows you to tie back to your ERP system for tying to business shipping function.

Does DC have a FB catalog/shopping integration similar to this?

Thanks,
Kevin


texts: Add a relationship to logged in user, not content author, on content view?

texts: I want to filter my content view by a field on the logged in user (the content type has that same field). I could implement hook_query_alter and add add a where condition with the field from $global user, but is there a way to do this out of the box though the UI?


texts:
I searched for this for some time now but couldnt find an anwser. I am using drupal 9.1.5 and pathauto. I have content types department and depratment news. The news are linked to the department. So whenever you create a department news you link it to a department. Now I want to display all depratment news linked to the department when i am on the department page (all children) and when I am on a page of a children (department news) I want to display all siblings, i.e. all departments news linked with the same department.
My url for departments is
[node:title]
and for department news is
[node:field_department:entity]/[node:title]
I thought that using a contextual filter in my view using the raw value from the url would work. So I used path component 1 and checked to use path alias. However this does not display anything.

When using path component 2 and disable to use path alias it works for the department news, which makes sence as I am internally on page node/xxx. I was so frustrated that I tried every other combination of path component and use path alias but nothing works. When using a fixed value for a department everything works as expected for that specific department


texts: How to display all records by default on a view with exposed filters

texts: I've managed (after a lot of struggle) to create a view with four exposed filters (all filters are taxonomy fields). My problem is that now by default no data is presented to the user whene the page loads and data appears only when a filter term is chosen. I'm trying to achieve the exact opposite: have all data presented and then filter it accordingly. how can i do it?


texts: What is the variable/method to address the content type in a template file?

texts:
What is the variable/method to address/fetch a particular content type in template files?

What variable/method shall I put at the blank space so my statement/logic will be like if contentType == 'article'?

{% if ____________ %}
  ......
  ........
{% endif %}


texts: Site goes down every 4 or 5 days, and a new vendor directory is added

texts:
About once a week, the site goes down and gives the following error:

  Symfony\Component\HttpKernel\Exception\NotFoundHttpException: in Drupal\Core\PathProcessor\PathProcessorFront->processInbound() (line 43 of core\lib\Drupal\Core\PathProcessor\PathProcessorFront.php).

When I look in my root directory, a new folder is there called "vendor" and it seems to be full of different frameworks, including Symfony. I reinstall Drupal (version 7.54) and it works for about a week, then goes down again. I tried to to disable the modules to see if that was the issue, but when I try to access the modules page, I get a 500 error. This started happening on December, and I hadn't made any changes to the site at that time.


texts: How do I sort a taxonomy in a different way depending on the language?

texts:
I have a taxonomy (list of hobbies) translated using Entity Translation.

The list is in alphabetical order, which is great for English.

However, I also translated the list into Japanese, which uses a completely different order from English.  Unfortunately, within Drupal this list is shown in the same order as the English list.

I need to show this list to both Japanese and English speakers and have the terms linked so using two separate lists is not an option.

How can I sort a taxonomy list differently based on the language?  Is it possible to have a solution such as different weights for different languages?


texts: How do I recover a deleted Views display?

texts:
I installed a module (FAQ) which provides multiple Views displays, which are based in code. I accidentally removed the master display, and am left with the various block and page displays also created by the module.

Is there any way to retrieve/recover the master display, short of removing/reinstalling the module?


texts: Advice for Image Management with New Site

texts:
I am looking for the best image management options for a new Drupal site. The original site has several thousand images, and a dynamic site is expected to explode that number to tens of thousands.

I'm currently strongly in favor of using Media Module 2.x, particularly for the fields that come with File Entity.

My concern right now is that this solution doesn't meet some of my other needs, particularly with managing file paths. File Field Paths and File Aliases look promising, but don't appear to work well with Media / File Entity.

What I'd like to achieve:

Fieldable files for alt-text, title, caption, taxonomy, and pinterest caption. Also probably source credits, and other important attributes. I will want to generate galleries from image tags (taxonomy).

I would prefer to keep the files in the default location, but serve them as if the public filesystem path is "/". IE, example.com/images/rest-of-path/image.jpg, example.com/pdf/document.pdf, etc.

I will need to brand images, and would prefer to keep the original, though not serve the penalty from using private files. Are there any modules that will enforce serving a default style? Barring that, I will learn the Drupal way of setting custom htaccess rewrite rules to achieve it.

Any advice or relevant best practices would be helpful. I seem to keep finding bits that would fit one need or another, but not necessarily work well with each other.


texts: Is it possible to access the `session` table using db_query/db_update/db_insert?

texts:
is there a security feature that is preventing me from doing anything with sessions?

I'm pretty sure this is a bad idea, but I'm switching users around after login.

User A logins in using their credentials, but we switch them to be User B.

Perhaps there's a better way to do this and I don't need to directly change sessions at all.


texts: Is there a way to force some block caching despite system block caching option is disabled?

texts:
In /admin/config/development/performance settings page, my "cache blocks" options is disabled due to "Block caching is inactive because you have enabled modules defining content access restrictions."

But I absolutely need to globally cache some blocks (in particular some superfish blocks because they recreates menu items on every page load if not cached).

I've already tried Block Cache Alter module, but without success, probably because this module can works only if system "cache block" option is enabled (see: https://drupal.org/node/1954224 )

Thank you for help


texts:
I'm trying to figure out someway to allow end-users to format page content into columns. Right now if they edit a page they get a title field and a body field which is fine a lot of the time but what if they want to do something like this...

-------------------------------------------------------------------------
| TITLE                                                                 |
|                                                                       |
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam      |
| pharetra lorem mollis dui egestas convallis. Nam vitae sapien urna.   |
| Nam quis tellus ligula, non gravida metus.                            |
|                                                                       |
|              HEADER                             HEADER                |
|                                                                       |
|      ----------------------             ----------------------        |
|      |                    |             |                    |        |
|      |                    |             |                    |        |
|      |       image        |             |       image        |        |
|      |                    |             |                    |        |
|      |                    |             |                    |        |
|      ----------------------             ----------------------        |
|                                                                       |
|    Lorem ipsum dolor sit amet,       Aliquam pharetra lorem mollis    |
|    consectetur adipiscing elit.      dui egestas convallis.           |
|                                                                       |
|                                                                       |
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam      |
| pharetra lorem mollis dui egestas convallis. Nam vitae sapien urna.   |
| Nam quis tellus ligula, non gravida metus.                            |
|                                                                       |
-------------------------------------------------------------------------

A title followed by a full width paragraph
then two 50% width columns with headers, images, and text
and a full width footer paragraph

This is just an example of what they might want to do. I'm using the WYSIWYG module's ckeditor to edit the page contents. The only way I can think of doing this is either allowing them to inline css in style attributes or using something like panels.

using inline styles and predefined classes might work but it would require the end user to know css. Panels looked good as I could create the layout the way I liked and add custom content (or otherwise customize the page) but I couldn't figure out how to translate the panels page into another language like I can with nodes.

This must be a common situation but I haven't found the solution yet. Anyone have any suggestions?


texts: Attach/ Display same Fieldset for every checkbox option

texts:
how do I re-use a fieldset/group for each checkbox option of a List field. [Please see the form mock-up attached]

"Samples collected" is a List(check boxes) field with few options (one, two, three, etc..)

I want to attach a fieldset for each checkbox option, and display each fieldset only when its checkbox is ticked. The fields in the fieldset are same for every options.

What is the best way of achieving this?

I have tried Inline entity ref field instead of fieldset, but empty entities are created even for those check-boxes not checked.


texts: Purpose of the .htaccess files in the Drupal files directory?

texts:
Besides the .htaccess file in the Drupal site main folder, I've found a .htaccess file in the sites\default\files folder, and further such files some sub-folders of sites\default\files folder (for example, in sites\default\files\private).

My question can actually be broken down into two separate questions:

How would you define in simple words the purpose of both the main .htaccess files, and the others under sites\default\files (I assume there aren't anymore .htaccess files?).
Is the only reason for splitting the Python syntax to different .htaccess files is to not make a single huge file? Or there are other reasons?

Thanks,


texts:
I have a Drupal 7.30 installation that I'm trying to develop on webenabled ( I also had it on network solutions shared hosting), and every time I attempt to send an email, I get the error unable to connect to the smtp server, and unable to send email, contact the system admin if this persists.
I have read numerous articles and check the drupal forum, but I have had no luck. None of the solutins work for me. I'm wondering if it is the configuration on the shared hosting. That is why I left network solutions. They culd not help, and were rather rude about my attempts.
Thank you ahead of time for anyone that can provide an answer.
SimmonsOne (Drupal username)


texts: Missing File Module Warnings on drush ups

texts:
I am preparing for a Drupal 8 Core module (Current version is 8.7.4) and in the process, I used 'drush ups' to check for available module updates. Doing this command generates the 'following module is missing from the file system' problem. Here is the following log:

The following module is missing from the file system: ds_test_layout_theme bootstrap.inc:278                                                       [warning]
Unknown path for ds_test_layout_theme module.                                                                                [warning]
The following module is missing from the file system: webform_test_bartik bootstrap.inc:278                                                        [warning]
Unknown path for webform_test_bartik module.                                                                                [warning]
The following module is missing from the file system: webform_bootstrap_test_theme bootstrap.inc:278                                               [warning]
Unknown path for webform_bootstrap_test_theme module.                                                                                [warning]

I tried to look for the specific modules in my filesystem and they actually existed in my file system. I did some research and some posts suggested to use 'drush sql-query delete' to remove the module from the database. However, when I tried to query for that specific module in the database it yields no results which means the aforementioned solution would not work. I appreciate any suggestions or solutions to solve these warnings so that I can feel safe to do the updates.

One other question is: are these warnings actually dangerous? Since I noticed that the missing modules are the test modules of a 'bigger' module.

Thank you!


texts: Problems with SQL Syntax using Left Join and OR

texts:
I need some help with my SQL. I've got the following code but it's returning multiples of each item and I don't understand why. When I only include the first Left join it returns results as anticipated...but when I add a second LEFT join and include the 'OR' in the WHERE part of the query it returns multiples of the same resources names. After my query I explain more about the context.

$result = db_query("
SELECT rn.field_resource_name_value,
       rn.entity_id,
       el.field_experience_level_value,
       rl.field_role_value,
FROM {field_data_field_resource_name} AS rn
LEFT JOIN {field_data_field_experience_level} AS el ON rn.entity_id=el.entity_id
LEFT JOIN {field_data_field_role} AS rl ON rn.entity_id=rl.entity_id
WHERE el.field_experience_level_value='$level' OR rl.field_role_value='$role');

This code is part of a recommendations page where users get resources displayed based on their answers to (we'll say two for now) questions on a form. The questions are radio buttons and ask for their experience level and role. These values are saved in session vars that I've already put in $level and $role respectively so those are values like 'Novice' and 'Writer'.

What I'm trying to accomplish - and what the PHP code that displays results (not shown, but below the query) does - is display a list of resources that match the experience level and role the user selected on their form. Obviously I only want each resource to display once, not five times for each. Also, if a user selected both Novice and Writer, let's say, I'd want any resources returned that had EITHER role set to writer OR exp. level set to novice, not necessarily both (although that's fine too).

I have a resource content type that stores it's values in various tables. So each resource title will store its name in the table field_data_field_resource_name, and the matching experience levels (each resource can have multiple levels - some are good for both Novices and Experienced users for example - these are set as list fields in the resource content type). The matching experience levels are stored in another table (ref. in the sql above) and the matching roles, likewise, are ref. in a separate table. The only thing all of them have in common is the entity_id field which matches them all to the resource name...hance the SQL above.

Pfew. So given all that background. Can some knowledgeable SQL expert advise me as to what is going on here?

Thanks!


texts: Create a view for a specific content(Not for a specific content type!)

texts:
I have two content types: departments and teachers. Every teacher node has an entity reference field which points to the department to which that teacher belongs.

I want to create a view that shows the list of all teachers from the particular department and I want the link of that view to be shown on the department page. So, each department page will have a link of a view page which will show the list of all teachers from that department.

I can create a view for a content type, but how can I create a view for
a specific node of a content type (e.g Computer Engg department)?


texts: How to change redirect after adding node of a particular content type

texts:
I am currently developing a D7 site.  One content type is a "resource," which is a link to an external site, or uploaded pdf file.  I have a page view to list out all resources (/resource-list/edit ) that allows an admin to see resources broken up by category, reorder them, edit, and delete.

The edit, and delete links were added via views.  I have also added an "Add new resource" button to the header of the view, which properly opens the add resource form in the admin overlay.  However, when the admin submits the new resource, they are redirected to the new node that was created.  Instead, I would like them to be redirected back to /resource-list/edit.  How would one go about changing the redirect only for this content type, and only when triggered from the /resource-list/edit view page?


texts:
Using the locale modul (core) and i18n it is possible to show a language switcher, which will guide the user to corresponding nodes in another language. In case of views, this language switcher points to a view in every language. The views path i.e.

www.website.com/path/to/view

gets "translated" to every language

www.website.com/language-path/path/to/view.

Is it possible to change this behaviour or to restrict the view to specific languages?


texts:
Is there a way to force node access to allowed if there is a hook in a different module marking it as forbidden?

I have a custom module where i implement hook_node_access, returning allowed should certain conditions apply, but the result is being override by a contrib module that sets node access to forbidden.

Can i force my result?


texts: Route isn't being created for custom rest resource

texts:
I'm attempting to create a custom rest resource, and have followed very many examples but I can't seem to get it to work. Every time I test it using https://www.hurl.it/ I just get a 301 error.

I'm using
http://example.com/myrest_test/1?_format=json
as the url as a GET request.

My format is as follows. I have a custom module called rest_test

Inside /rest_test/src/Plugin/rest/resource/MyRestTest.php I have

<?php

namespace Drupal\rest_test\Plugin\rest\resource;

use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;

/**
 * Provides a resource for accepting rest calls
 *
 * @RestResource(
 *   id = "myrest_test",
 *   label = @Translation("My Rest Test"),
 *   uri_paths = {
 *     "canonical" = "/myrest_test/{id}"
 *   }
 * )
 */

class MyRestTest extends ResourceBase {
    /**
     * Responds to GET requests.
     *
     *
     * @param int $id
     *   The ID.
     *
     * @return \Drupal\rest\ResourceResponse
     *   The response.
     */
    public function get($id = null) {
        $response = ['message' => 'Hey this worked and this is the id'.$id];
        return new ResourceResponse($response);
    }
}

and inside a form.js file I have

 (function($) {
    $(function() {
        console.log('form.js executed successfully');
        jQuery.ajax({
            url: "/myrest_test/5",
        }).done(function(msg){
            console.log(msg);
        });
    })
 })(jQuery);

I receive the 'form.js executed successfully' message so I'm certain the javascript is running, but msg is empty. I've tried with the entire url instead of just the relative one as well.  I've also made sure I'm clearing the cache
But I can't seem to get any proper response. Is there something I'm missing? Why doesn't my rest resource response to my ajax calls?

UPDATE: Looking in the error logs it looks like I'm getting page not found errors for that rest call

UPDATE 2: When I visit directly in my browser I receive
/myrest_test/{id}

  {"message":"No route found for \u0022GET /myrest_test//234\u0022"}

UPDATE 3: After narrowing down the issue to it being a routing problem I found a similar question here No route found for custom REST resource however when I add

 *   uri_paths = {
 *     "canonical" = "/myrest_test/{id}",
 *     "https://www.drupal.org/link-relations/create" = "/myrest_test"
 *   }

I still encounter the same error


texts: How to hide the filename in drupal 7 files and add link to icon?

texts:
I would like to know how to hide the filename in Drupal 7 files and add a link to an icon? The default style is awful I would like to change that.
I am looking for the simplest solution because I just know basic HTML and CSS.
Maybe I can use some module to do that? If somebody can explain me step by step how to do it will be great.


texts: Remove certain content types from search

texts:
There are certain content types such as book pages that I don't want to appear on the search results page.
I found example code implementing this on drupal 7 here

/**
 * Implements hook_query_alter().
 * removes content types defined in the excluded_content_types array from search results
 */
function hook_query_alter(&$query) {
  $is_search = FALSE;
  $excluded_content_types = array(
      'product',
      'billboard',
    );
  foreach ($query->getTables() as $table) {
    if ($table['table'] == 'search_index') {
      $is_search = TRUE;
    }
  }
  if ($is_search) {
    foreach ($excluded_content_types as $content_type) {
      $query->condition('n.type', $content_type, '<>');
    }
  }
}

However I want to implement this in 8.
Is there a way to exclude certain content types from search results?

UPDATE: I've also attempted to restrict the search types from within the search-result.html.twig however it does not seem like I have the content type variable available.

{{ attach_library('classy/search-results') }}
{{ title_prefix }}

{{ dump(info_split) }}

  {{ title }}

{{ title_suffix }}

  {% if snippet %}

{{ snippet }}

  {% endif %}
  {% if info %}

{{ info }}

  {% endif %}

When performing {{ dump(info_split) }} it does not show content type as an available variable.


texts:
Using Drupal 8.

I want to display the value of a field (field_date) at the top of my page, in the header, so I need to output it in page.html.twig. I'm having issue with this, though, which I think boil down to the scope of where variables are available.

To clarify - I can print field_date in node.html.twig no problem by just using content, but since I need it so high on the page, I'm hoping for a way to print it in page.html.twig.

I'm open to any solution, but here's a possible solution I picked up from searching on this same topic:

In THEMENAME.theme

/**
 * Implements template_preprocess_field().
 */
function THEMENAME_preprocess_field(&$variables) {
    $element = $variables['element'];

    if($element['#field_name'] == 'field_date') {
        $variables['promo_date'] = $element[0]['#markup'];
        dpm($variables['promo_date']);
    }
}

In page.html.twig:

{{ promo_date }}

In this example, the dpm does work, but the promo_date displays nothing. Doing kint(node) returns a large number of methods, but none seem to be the fields I need.  Unfortunately the solution I borrowed from was taking a page-level variable and adding it to field.twig.html, and I think the scope reversal is the problem.


texts: Can you change the list builder class used by an entity?

texts:
There's an entity created by another module and I'd like to change some of the fields used on a listing page. Currently that page is using the entity's list builder class. Is there a way I can define a new list builder class, make my changes, and use that for this entity? I have tracked this down to where D8 get's entity definition and loads the list builder class from that. I can't find a way to alter the definitions or another way to inject a different class here.

In more specific terms, I have created an entity with ECK and want to override the functionality around EckEntityListBuilder.


texts: what to fill in after $items in hook_field_is_empty

texts:
I'm trying to build a module that constructs a field that needs to show in Manage Fields. I'm trying to understand what it is function by function. Looking at the example field module the code says

function field_example_field_is_empty($item, $field) {
  return empty($item['rgb']);
}

Where does this 'rgb' come from? What is $item? How do I know what to put there in another field? My guess is that it just represents whatever is filled into the field, the actual value. Becuase the value of my field is going to be an HTML link, my guess is, for now at least, to type $item['link']. But I can't really verify it.


texts: How do I get the menu ID based on the menu title?

texts:
I am looking for a function to call like in the following snippet:

get_menu_id("my menu title");

Do you have any tips?


texts: Using `hook_field_attach_presave` for replacing characters

texts:
In Drupal 7, I used hook_field_attach_presave() to replace characters of a body field in the moment when the node is saved. Now i want to use the code for Drupal 8, but could not get it to work:

function my_module_field_attach_presave($entity_type, $entity){
  dpm($entity);
  $replacement_pattern = '/(?<=\d\ )x(?= \d)/'; // replace a "x" surrounded by numbers with symbol "×"
  if(!empty($entity->body->value)){
    $entity->body->value = preg_replace($replacement_pattern, ' &times; ', $entity->body->value);

}
The above code does not work, not even the dpm($entity) is printed. What is the problem here, is the hook not available in D8? I just found it here, not on official drupal sites. So if it does not exist, what's the alternative?

EDIT: Thanks to @Clive I got it working. Here's the code:

function my_module_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
  $entity->setTitle('dd The new Title');
  $replacement_pattern = '/(?<=\d\ )x(?= \d)/';
  if(!empty($entity->body->value)){
    $entity->body->value = preg_replace($replacement_pattern, ' &times; ', $entity->body->value);
  }
}


texts: Replace 'all' for 'All' at any exposed filter criteria

texts:
I'm trying to replace the 'all' value for 'All', because I'm getting an error if I use it as 'all'.
Is there any way to accomplish this?
Before: price_selector=5&price[]=5&play_styles=All&theme=all
After: price_selector=5&price[]=5&play_styles=All&theme=All
I tried to use: processInbound but without any success because the view is embedded in a node.
In fact Drupal form has this "issue" too: https://www.drupal.org/project/issues/drupal?text=views+all+parameter&status=all&priorities=All&categories=All&version=All&component=All
(Status parameter = 'all')


texts:
After installing D8 on my server, I wanted to add some modules, so I went to Extend / Install new module and was told I needed FTP access to the server.  I've got my server configured to only use SFTP, and that's not an option in the Connection method drop list - only FTP is offered.  For initial installation, that wasn't much of a problem - I went to the PuTTY windows I have open with SSH connections to the server, wrote a script to download, extract and correctly place the modules in the Drupal directory tree.  That made the new modules available on the Extend page so I could mark their checkboxes to enable them.

Now there are updates, and again I'm being told I have to use FTP to upload to the server - and FTP is the only Connection method available.

I've configured my Drupal-driven site with an SSL certificate, and set it up for full-time HTTPS - any attempts to access the site as HTTP are redirected to an HTTPS connection.  Consequently, I know the site has a working SSL certificate.

What do I have to do to make SFTP available as a Connection method in the page for installing and updating modules for my site?


texts: How to only allow specific users to edit certain "fields" when creating content?

texts: I want to be able to hide specific fields form users on the create content form. For example, I might let any authenticated user create an article but only the editors can use the upload a picture field and the category field.


texts:
I have the following statement in my module code:

db_query("ALTER TABLE {tripletex_invoice} AUTO_INCREMENT = :number", array(':number' => $start_value));

During SimpleTest I get the following error message:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near ''20000'' at
line 1: ALTER TABLE {tripletex_invoice} AUTO_INCREMENT = :value; Array (
[:value] => 20000 ) in _tripletex_add_invoice_log() (line 1769 of
/var/www/d7/sites/all/modules/tripletex/tripletex.module).

Why?


texts: How to change menu item URL in menus for Drupal 7 multiiste

texts:
I am using drupal 7 multisite (sharing the same database, same code base) i.e

1) one.example.com

2) two.example.com

Everything is working correctly and my site using the same menus for all the sites.

for primary domain, menus are working correctly like
there is one menu item named as test and published to both the sites
but
If I access the first site i.e one.example.com then my menu URL is
one.example.com/test

and same when I access the secondary domain i.e. two.example.com then my menu URL should be two.example.com/test instead of one.example.com/test
and currently, menu URL is one.example.com/test


texts: How can I override a module's file via hook_menu_alter()?

texts:
I have the following code in my hook_menu_alter().

<?php

function bonus_menu_alter(&$items) {

  if (!empty($items['things'])){

    $items['things']['title'] = t("New title");
    $items['things']['callback'] = 'new_callback';
    $items['things']['file path'] = drupal_get_path("module", "bonus")."/includes/";
    $items['things']['file'] = 'bonus.pages.inc';

  }

}

The problem is that the file path of the new file is including the original modules path and spitting this out:

/var/www/staging/sites/all/modules/things/sites/all/modules/bonus/includes/bonus.pages.inc

The original implementation of the parent hook_menu():

/**
 * Implements hook_menu().
 */
function things_menu() {
  $items['things'] = array(
    'title' => 'Things title',
    'page callback' => 'things_callback',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
    'file' => 'includes/things.pages.inc',
  );
  return $items;
}

What could I be doing wrong?


texts:
There is a default templating system PHPTemplate in Drupal, they say.

But where can I see it? I don't see anything more than pure php in template files .tpl.php. Once I've seen template system Smarty in non-drupal webpage files and there was tempalting syntax with { } braces in .php files with HTML. I also have seen Blade templating syntax in Laravel framework's files.

So where is the PHPTemplate in Drupal (or how it works and what it do?)


texts:
I've created a new content type event (With title, body and date), but I can't select the type when editing my calendar view (screenshot included).

How come I can only select comments and dates, ..?

edit: it's because I added a view from template (Comments). How do you change the type of this view from comments to content? Is that possible?


texts: Event calendar help - creating view of event with all registered users in a block

texts:
I am new to Drupal so I encounter this problem. I've installed Event Callendar. Using tutorials found all over the web I made a signup content type and displaying list of registered users for each event using Eva reference.

I would like to make a block of latest event and registered users in the front page. The problem is that my list of registered users take context filter from node URL (where event content is displayed).

How can I put all of this in a single block and set context filter of users list to URL of the event?

This is very confusing. I am trying to do it for the last two days with no luck ...


texts: Give access to private files to certain role?

texts:
I have a few image styles set up. But they are all stored as "private" files. I want to be able to give anonymous users public access to these files, or find some other way by which to generate access to this file. My goal is to provide access to private files for certain anonymous users depending on certain conditions.

I am hiding all images on the server to avoid anyone accidentally gaining access to them, but some "private" images should be viewable if a certain style is applied. For example, I am selling images on my site. The "waterproof" image style should allow any user (including anonymous) user to see the private file preview. But only logged in users should be able to view it with the "high_res" thumbnail.

This is how I generate the URL:

$imageURL = file_create_url($badge->field_badge_image_image->entity->getFileUri());

This url can only be accessed by logged in users. If I try this code, I still get access denied.

$imageURL = ImageStyle::load('farm_logos')->buildUrl(
    $badge->field_badge_image_image->entity->getFileUri()
);

Is there no way to generate a URL that is accessible via public?

I also tried the "hook_file_download":

function mymodule_file_download($uri) {
    return array(
        "Accept" => "Accept",
        'Content-Type' => "image/jpg"
    );
}

But I was hoping this would make all private files public, but unfortunately it did not.


texts: Converting a helper class into an Entity

texts:
I am working on a Drupal 8 module, and a separate module of examples, on how to use the first module. In my example module, I have a function in my controller that looks like this:

public function basicUsage() {
  // Basic line chart.
  $series[] = [
    'data' => [[0, 3], [4, 8], [8, 5], [9, 13]],
  ];
  $params = [
    "data" => $series,
    "theme" => "flot_examples_basic_usage",
  ];
  $flot = new FlotD8($params);
  $output[] = $flot->outputPlot();
  return $output;
}

I would like to use the standard entity notation if possible to simplify things, and make it look like this:

public function basicUsage() {
  // Basic line chart.
  $series[] = [
    'data' => [[0, 3], [4, 8], [8, 5], [9, 13]],
  ];
  $output["flot_d8"] = [  //maybe name needs to be FlotD8?
    "#data" => $series,
    "#theme" => "flot_examples_basic_usage",
  ];

  return $output;
}

Here is the code for my class. What do I need to do or change to give it the behavior I'm looking for? Is it just a matter of extending a certain Core Entity class? I do not need any schema or database functionality.

<?php
namespace Drupal\flot_d8\Entity;
class FlotD8 {
  protected $id;
  protected $theme;
  protected $data;
  protected $options;

  function __construct($params){
    $this->id = isset($params['id']) ? $params['id'] : 'placeholder';
    $this->theme = isset($params['theme']) ? $params['theme'] : 'flot_d8_my_template';
    $this->data = $params['data'];
    $this->options = isset($params['options']) ? $params['options'] : NULL;
  }

  /*
   * Create the theme output.
   */
  function outputPlot (){
    $drupalsettings['flot_d8'][$this->id] = ['data' => $this->data, 'options' => $this->options];
    $output = [
      '#attached' => [
        'drupalSettings' => $drupalsettings,
      ],
      '#theme' => $this->theme,
      '#options' => $this->options,
      '#data' => $this->data,
    ];
    return $output;
  }
}


texts: How do I move a view display from a view to another one?

texts:
I have a old view named Users with two displays (All-Users and Flagged-Users) and today I create another view named Flags and I have a display named Flagged-Books, but now I want transfer my display named Flagged-Users to my view named Flags.

I search inside the view configuration and inside the display configuration and I can't found this functionality. There is a trick or a way to achieve this?

I have installed Views 3.11.


texts:
This is a very frustrating and recurring problem for me because it seems to come and go at random, one minute it is working beautifully, the next moment I make a change and it breaks.  Even if I change everything back the way it was and clear the cache again it is still broken.

I have a form, in the form is a table that allows users to enter ingredients into the form.  There is a "More ingredients" button.  Once clicked an AJAX call is made and the form is rebuilt and a new row is appended to the table.  For some reason This "More ingredients" button has been broken.  On click, it adds one ingredient, then on the second click, nothing.  The button will not even trigger the receding animation as it does other buttons, it is as if the button has just disapeared...

Here is the code.

relevant form function

 if (isset($form_state['add_ingredients'])) {

//reset add ingredients under form_state
unset($form_state['add_ingredients']);

//Get number of added ingredient for proper naming below.  Allows us to use row theme instead of table theme for loading only an ingredient.
$ing_number = count($node->recipe_ingredients['ing']);

//Be sure ajax returns proper row number.
$form_state['ing_number'] = $ing_number;

//Add ingredient to our ingredients array.
array_push($node->recipe_ingredients['ing'], array('ri_id' => NULL, 'name' => '', 'quantity' => '', 'unit_key' => '',  'note' => '', 'weight' => $max_weight + 1));

//Theme this row only, uses $ing_number to designate it will only be themed by row theme function, not table.
$form['recipe_ingredients']['ing'][$ing_number] = array(
    '#theme' => 'ingredients_row',
    '#row_number' => $ing_number
    );

$form['recipe_ingredients']['ing']['1'][]
. . .

$form['recipe_ingredients']['recipe_more_ingredients'] = array(
'#type' => 'submit',
'#name' => 'ingredientadd',
'#value' => t('More ingredients'),
'#description' => t("If the amount of boxes above isn't enough, click here to add more ingredients."),
'#weight' => 1,
'#submit' => array('recipe_more_ingredients_submit'),
'#limit_validation_errors' => array(),
'#ajax' => array(
  'callback' => 'recipe_more_ingredients_js',
  'wrapper' => 'ingredient-list',
  'effect' => 'fade',
  'method' => 'append'
  )
);

Submit

function recipe_more_ingredients_submit($form, &$form_state) {
//Set Drupal's form rebuild option to true...  not sure if this is really needed...
$form_state['rebuild'] = TRUE;

// If they clicked the more ingredients button, flag it in form_state['add_ingredients']
  if ($form_state['values']['recipe_ingredients']['recipe_more_ingredients']) {
   $form_state['add_ingredients'] = TRUE;
  }

}

Ajax Callback

function recipe_more_ingredients_js($form, &$form_state) {

return $form['recipe_ingredients']['ing'][$form_state['ing_number']];

}

Row theming function

function theme_ingredients_row($variables) {

$form = $variables['form'];

$row_number = $form['#row_number'];

// Build the table row.
$row = array(
    'data' => array(
    drupal_render($form['ri_id']) . drupal_render($form['quantity']),
    )
  );
  $row['data'][] = drupal_render($form['unit_key']);
  $row['data'][] = drupal_render($form['name']);
  $row['data'][] = drupal_render($form['note']);
  $row['data'][] =  '<button class="ing-remove" type="button">Remove</button>';

//Start HTML of row
$output = '
';

//Wrap each cell in proper HTML tags
foreach ($row['data'] as $key => $value) {

    $output .= '' . $value . '	';

}

$output .= '
';

watchdog('ROW', $output, null, $severity = WATCHDOG_NOTICE);

return $output;

}


texts: How to determine if view has translations and which ones

texts:
I have a view

$view = \Drupal\views\Views::getView($view_id);

How to determine if it has been translated into other available languages and which ones


texts: Advantages of utilizing Entity Field query over views?

texts:
I've been reading a little about entity field queries.

What are the advantages of using entity field queries (EFQ) over views?

What are the largest pain points/disadvantages of using EFQ ?


texts: How to unpublish postings according to the value of a field?

texts:
I was able to set rule to unpublished after +30 days. But I would like to tweak my rule to give to my users the possibility to choose between posting for 2 weeks, one month or 3 months.

So, I guess that there would be an "if choice X, than unpublish after Y period of time". Can the field (to choose duration) be a text dropdown?

Can this be done without PHP? If so how?

So, I figured out that I can add a condition like this :

Parameter: Data to compare: [node:field-time-limit], Data value: 2 weeks

But since I have 3 choices for my ads (2 weeks, 1 month, 3 months), does this means that I have to make 3 different rules, one for each time limit?
(it seems to make sense, but I'm not shure).

Note: I'm aware of the thread about "Tutorial 2: Publish content exactly 24 hours after it was created".


texts: How do I get the default billing/shipping customer profile in code?

texts:
Is there a way to get the default billing/shipping customer profile from a user?

I'm getting all customer profiles with:

$profiles = commerce_customer_profile_load_multiple(array(), array('uid' => $user->uid));

But which customer profile was set as default by the user?


texts: Blocks not showing on front page, but they don't have any page/content restrictions

texts:
I do maintenance on a drupal site and between my last maintenance and this one someone changed -something- in the configuration which is causing the front page to not have a sidebar. The behavior is the same for anon users and admin users.

If I click on any of the other Pages or Articles, all the blocks in the sidebar show up again. I've checked their configurations in the Blocks Admin page, but neither of the blocks have any kind of restriction on pages or content type:

I've checked that the default theme doesn't set a different front page, so it should be using the default feed.

I've also checked if Views was used to replace the front page, but the Front Page View is not enabled:

I've looked through all of the settings in the default theme (MAYO) and I don't see anything that would prevent the sidebar or the blocks from showing up.

What else could be causing the front page not to have a sidebar?


texts: How do I create a file download popup form?

texts:
I am new to drupal, and I want to create a popup form with with form fields for name and email, and a buttom to download and to close the popup.

When users click on the download link, the popup form appears; users enter their name and email address; once the data have been validated, the users can download the file, and see how many users downloaded it.

How can I achieve this.


texts: How to change the link in the view by content type?

texts: I change my question. Content type: How to add link field?


texts: Advice Needed on Associating Articles by user with Nodes

texts:
I am building a national site, with 30 locations. Each locations page is built from a single content type, "venue".

For each location, the manager is given their own login details so they can keep their venue page up to date.

They will also be able to create an Article whenever they have news. All Articles will display a teaser on the main national page, but It should also appear on that managers location page, but not all of the others.

I am after some advice on how to make this happen with views. Obviously I wouldn't want to create a separate view for every location page and only display results by author.

Ideally there would be one view that I could display in a block on every venue page. It would need to get the related author information (maybe from a CCK field), and then display the article results of the owner of that venue. But how do I connect a node to a user, that a view can read?

Hope that makes sense, I'll try and explain it better if you need me to!


texts: Content Type template override - Dash or Underscore?

texts:
I am looking for some clarification on whether to use and underscore ("_") or a dash ("-") when creating a page template override for a content type. Some tutorials and articles say the format should use underscores such as ...

page--content_type_name.tpl.php

while others specify the format as dashes like ...

page--content-type-name.tpl.php

If my content type has a multi-word name how should the template override filename be formatted?


texts: Drupal 8 Installation Symphony routing error

texts:
I am installing a second Drupal 8 site on an existing server configured to redirect a sub-domain to the new site. The Install was uneventful, but when I visit the site to confirm it is working I am met by:

The website encountered an unexpected error. Please try again later.

Inspecting the apache2 error.log i see the following:

Uncaught PHP Exception Symfony\\Component\\Routing\\Exception\\RouteNotFoundException:
"Route" search.view_node_search" does not exist." at
/var/www/html/subdomain/core/lib/Drupal/Core/Routing/RouteProvider.php line 187

I have double checked my rewrite module and it seems to be setup correctly for the sub-domain. I even tried re-setting it in the virtual host and the .htaccess file but no luck.

The directory for the sub-domain does differ in name to the actual site address, though I think this should not be a problem.

Can someone please explain what this means and how I fix it?


texts: Display Content on the basis of child terms of selected taxonomy term

texts:
I have created A vocabulary like

Category
-category1
--category1.1
---category 1.1.1
--category1.2
---category1.2.1
-category2
--category2.1
--category2.2

trying to display content having category 1.1 and category 1.2 node view where term is category 1
 But its also displaying the child node of category 1.1 i.e category 1.1.1 and child 1.2 i.e category 1.2.1.


texts: How do I programmatically change the admin theme?

texts:
How do I define a different administration theme for a user and administration role in Drupal 8?

I have looked at the context module for Drupal 8. There is a problem with the context condition and the reaction theme related items are all based on the front-end themes. I need the same but for the back-end themes.

My code is the same as the context reaction code for Theme.php. I just changed the submitConfiguration().

 /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    $configuration['admin'] = $form_state->getValue('theme');
    $configuration += $this->getConfiguration();
      \Drupal::configFactory()
          ->getEditable('system.theme')
          ->set('admin', $form_state->getValue('theme'))
          ->save();
    $this->setConfiguration($configuration);
  }

I defined the following in the context configuration.

Condition => Role:User

Reaction => Admin Theme: Customtheme
Condition => Role: Administrator

Reaction => Admin Theme: Seven

Is this possible? Are there other methods for achieving this goal?


texts: I'm having some trouble trying to put an if else statement into my "page.tpl.php". I don't remember (I did it in the past), how to check something like that,  but with some other page for example "www.example.com/home-2" or www.example.com/info . In my case is a page view, I would really appreciate any help you can provide.


texts: Not showing clickable links in search results

texts:
I'm fairly new to Drupal but have gotten a hang of installing modules and setting up there configuration pages.
The company site i'm working on is running on Drupal 7.1.4 and is using Node Search to look through books that they have created for documentation of their products. The problem with the node search was the lack of proper phrase search and partial words not being found.  I have Search API, Search Facets, Search Pages and Fuzzy Search modules installed and it appears to be working but not as expected.

Unfortunately the results come back as unclickable links, with some results coming back as text only excerpts of certain books and most results coming back as what appears to be just the author name with a time stamp of the books that are available.

I'm having a bit of trouble finding a way to display these search results as proper links and text excerpts with highlighted search terms.

Was hoping someone here would be able to assist.


texts: How to check if a database query has results?

texts:
How do I check if the following code has results?

I tried the empty function but it always returns FALSE

$query = db_select('my_table', 't');
$query->condition('code', 10)
      ->fields('t', array('cid'));
$result = $query->execute();


texts: Programmatically get all names of an entity reference field

texts:
Example: I want to get all tag names that are inside field_tags of node 5.

I can get the target_id with $node->field_tags->getValue();

But the problem is, I don't know what entity the target_id value belongs to. Could be a node id, term id, user id. Without that info, I am not able to use the target_id to get the name of the tag.

How can I get all the names of an entity reference field?


texts: search in node-with-comments plus in unpublished nodes

texts:
I need on my site a search. It should index the comments too, fulltext index is fine, they could be seen as part of body.

But as I use workbench with many steps, most nodes are unpublished. And I guess that ist not possible with builtin search.

So I checked search_api and it works for all content and its fields but NOT the comments.

Any suggestions what I could try?


texts: How to enable "find content" for a role in Drupal 7?

texts: I created a role called "Writer".   When a writer logs into the system, they have the black toolbar across the top of the page.   They have the "add content" link which is great.  How do I enable the "find content" link for a writer?


texts: Where is the button that will translate all countries from Countries module in all my 10 languages?

texts:
After installation of Countries module I rest only 15 countries that I've translated one by one with Google Translate and my hands.

It's a pity cause my site is viewing and using in other countries too. But I need the automatic translation of country list in 10 site languages.

There is one more question that does not have an answer: How to translate all the country names provided by the Countries module in one shot?

And google also shows this: https://www.drupal.org/node/2096581 But if I try to upload this translations it does not change anything cause by default language is russian.

One professional developer said that here I can get de database http://dev.maxmind.com/geoip/geoip2/geolite2/ and using https://www.drupal.org/project/smart_ip I can translate my list of countries. But I do not believe in my power.

Please let me know if I can have solution of: How to translate countries list in several languages?


texts:
I don't like second node_save. But I need nid for title.

$node = new stdClass();
$node->type = 'bill';
node_object_prepare($node);
$node->uid = $user->uid;
$node->field_body['und'][0]['value'] = $bodytxt;
$node = node_submit($node);
node_save($node);

$node->title = 'Bill # '.$node->nid;
node_save($node);

Is there more elegant way?


texts: Set parent service when registering a service in a ServiceProvider

texts:
I want to create dynamic services, therefore I added a ServiceProvider class to my module.

I have created a base service that my other services will have as parent.

When doing this in my_module.services.yml, I can just use:

parent: service_name

But I can't find out how to do in the ServiceProvider class.

My class looks like this:

class MyModuleServiceProvider extends ServiceProviderBase {

  /**
   * {@inheritDoc}
   */
  public function register(ContainerBuilder $container) {
    // Create services for our base normalizer classes.
    $container->register('MY_MODULE_rest.entity_normalizer_base', EntityNormalizerBase::class)
      ->addArgument(new Reference('entity_type.manager'));

    // Create node normalizer service.
    $container->register('MY_MODULE_rest.node_normalizer', NodeNormalizer::class)
      ->addTag('normalizer', ['priority' => 1])
      // How can I set "MY_MODULE_rest.entity_normalizer_base" as the parent for this one?
      ->addArgument(new Reference('path_alias.manager'))
      ->addArgument(new Reference('language_manager'));
  }
}


texts: Display latest three news on a custom template

texts:
I'm building a custom theme and I would like to display last three inserted news (i.e. nodes with content type = News) on the bottom of the home page from inside the home page template.

Something like this:

+-------------------------------+
| +---------------------------+ |
| |                           | |
| |          Slides           | |
| |                           | |
| +---------------------------+ |
|                               |
| +---------------------------+ |
| |                           | |
| |           Page            | |
| |           Body            | |
| |                           | |
| |                           | |
| +---------------------------+ |
|                               |
| +-------+ +-------+ +-------+ |
| | Last  | |Second | | Third | |
| | News  | | Last  | | Last  | |
| |       | | News  | | News  | |
| +-------+ +-------+ +-------+ |
+-------------------------------+

I created a content type named Home page, with fields for manage slides and the page body, then I created a new content (a new node) of type Home page.

Inside my custom theme I created a template file named node--home-page.html.twig and inside it I can handle the Home page's fields (slides and body) and how to render them inside the page.

After that I created another content type News and I added some content of such type.

Now I would like to display latest news inside the homepage template as in the figure above. What is the better/simplest way to do it?

I'm thinking to load latest news in some hook_preprocess_HOOK function (using the EntityFieldQuery object) then add them inside a variable for the Twig template. Inside the template I will perform a for loop rendering latest news at the page's bottom. Is this a good way to do it or I'm completely out of the way?

EDIT

Correction: I would like to display latest news between slides and body, in this way:

+-------------------------------+
| +---------------------------+ |
| |                           | |
| |          Slides           | |
| |                           | |
| +---------------------------+ |
|                               |
| +-------+ +-------+ +-------+ |
| | Last  | |Second | | Third | |
| | News  | | Last  | | Last  | |
| |       | | News  | | News  | |
| +-------+ +-------+ +-------+ |
|                               |
| +---------------------------+ |
| |                           | |
| |           Page            | |
| |           Body            | |
| |                           | |
| |                           | |
| +---------------------------+ |
+-------------------------------+

Where slides and body are two fields of the Home page content type.


texts: How to send email to submitter anytime webform modified

texts:
I have a webform page to submit data from authentic users. The moderator should see this to verify the data. When the moderator changes the submitted data, I want the system send an email to the submitter notifying the data has been changed.

How Can I do that. Is that any additional module(s) to handle that task?


texts:
When I try to update modules or clear cache with drush on my local dev machine (Mac OSX) I get the following four times at the beginning of the command result, and it fails.

  Invalid argument supplied for foreach() pm.drush.inc:584

My sites are D7, and the drush version is 6.0-beta1.  I can't find what the latest version is anywhere.  Is this it?

I looked on drupal.org and found a patch here: https://drupal.org/node/2041875

But I don't know how to apply a patch to drush. Can anyone point me to that information or tell me how to do it?


texts: How much server-side resources does the Omega theme use? Is the Omega theme scalable?

texts:
The omega theme is pretty 'fat'.   Currently its probably the biggest theme on drupal.org.  You can do anything and everything in the GUI. You can completely customize the layout, turn responsive design on/off...I could go on for awhile.

My question is,  do all of the extra settings eat up server resource to serve a page to the client? If I have a website that receive 100,000+ page visits a day,  should I use omega, or create my own theme?


texts: how to create new drupal-wall node through custom module?

texts:
I have using drupal wall contributed module to posting purpose,and these posts create through custom module, i have used node_save() to create a new nodes.

but problem is instead of user/author name  Anonymous (not verified) shown in posting page.

$node = new stdClass ();
$node->type = 'drupal_wall';
node_object_prepare ($node);
$node->uid = 10;
$node->name = "Your node title";
$node->language = 'und';
$node->comment = 2;
$node->body[$node->language][0]['value'] = 'hello';
$node = node_submit($node);
node_save($node);

i want user name displayed instead of  Anonymous (not verified) . any ideas???


texts: How to display only the menu items and not the parent menu?

texts:
I am trying to build on the footer a set of 3 menu links: About us, Terms of Use, Contact.

The problem is that I want to have only these 3 links as menus and I do not want their parent menu to be displayed. Can anyone help me on this?

When I do it, I can display the 3 links, but also their parent menu is shown.
I want to display only the submenu items:

MenuItem1

submenuitem1
submenuitem2
submenuitem3

Is that possible? Can The Panel module do this?


texts: How can I programmatically set the default export path?

texts:
In Drupal 7, you can set the default export path for the features module by setting the variable 'features_default_export_path':

variable_set('features_default_export_path', 'sites/all/modules/custom/features');

What is the equivalent in Drupal 8? Can the export path be set in the features.settings configuration object?


texts: How to use the data from a deleted Field Collection item in a Rule?

texts:
My 'Article' nodes have a Field Collection, called 'Amounts', that contains an integer field. After deleting a Field Collection item, I'd like to substract some Userpoints from the node's author, based on the sum of the integers in the non-updated and updated node.
In order to do so, I created a Rule with the event "After updating existing content of type Article" in which I'm looping over 'Amounts' for the updated and non-updated node. The problem is that both loops use the data from the updated node (after the Field Collection item was deleted, that is), resulting in identical values.
Here's the Rule's output for a node that has 3 items with corresponding values 1, 2 and 3 after deleting the first item:

Non-updated node: Sum = 5. (This should be 6.)
Updated node: Sum = 5.

Is it possible to run the Rule before deleting the Field Collection item in order to be able to grab the necessary data values? Is there another way to use the deleted data?


texts:
I have created new field for my content type "Flag", its list type field

possible values of it is

-Draft
-Sent
-Approved
-Rejected

now for this field new table is created,now i want to store date here,what i exactly want is like:

-Draft on date DD/MM/YYYY (the date of the creation of the project)
-Sent on date DD/MM/YYYY
-Approved on date DD/MM/YYYY
-Rejected on date DD/MM/YYYY

now how to achieve it.

am using drupal 7


texts: How do I remove unwanted hreflang links from page

texts:
I have a content page in English with Japanese and Chinese translations. Even when I unpublished the translation nodes, the page source code will display the hreflang attributes to the unpublished languages in header.

<link rel="alternate" hreflang="en" href="https://testsite.com/dining.html" />
<link rel="alternate" hreflang="ja" href="https://testsite.com/ja/dining.html" />
<link rel="alternate" hreflang="zh-hans" href="https://testsite.com/zh-hans/dining.html" />

This seems to be generated automatically. And when I run a test for SEO these language links throws 404 error because they are unpublished. How do I remove the unpublished links from the hreflang. (And it should be automatically added when I publish the translations)


texts: switch views or hide block based on content type

texts:
I have a block view that gets its contents based on a contextual filter. I only want to use this filter if it's a certain node type being displayed ie. the block would use the contextual filter on basic pages but on article and other pages I would like to set the contextual filter to a default value.

One way I thought I might do this is to change the views display based on the node type and then override the settings in the second display. Is this possible?

I created my second display for the view and I added both blocks to the same region. One of them I set to only display on basic pages. The other one I would like to set to only not display on basic pages. The block system only lets me select which content types to show the block on not which content types to exclude it from. I don't want to keep coming back to this page and having to check more boxes as I add new content types.

Is there any way to exclude a block from being shown on a certain content type?


texts: How can I add an AJAX callback to a checkbox?

texts:
I am using taxonomy manager module I want to add ajax callback to checkbox tree view for checkbox is checked condition but it is not working can some one please suggest me. I have modified the code like this
$form[$term->tid]['checkbox'] = array(
      '#type' => ($multiple) ? 'checkbox' : 'radio',
      '#title' => $term->name, // Escaping is done in theme wrappers.
      '#value' => $value,
      '#return_value' => $term->tid,
      '#ajax' => array(
        'callback' => 'ajax_example_autocheckboxes_callback',
        'wrapper' => 'checkboxes-div',
        'method' => 'replace',
        'effect' => 'fade',
      ),
      '#required' => FALSE,
      '#theme_wrappers' => ($multiple) ? array('taxonomy_manager_tree_checkbox') : array('taxonomy_manager_tree_radio'),
      '#highlight' => in_array($term->tid, $terms_to_highlight) ? TRUE : FALSE,
    );

This is the taxonomy manager module theme function.
function theme_taxonomy_manager_tree_checkbox($variables) {
  global $user;
  $element = $variables['element'];
  $element['#attributes']['type'] = 'checkbox';
  $element['#attributes']['ajax']['event'] = 'change';
  element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));

  // Unchecked checkbox has #value of integer 0.
  if (!empty($element['#checked'])) {
    $element['#attributes']['checked'] = 'checked';
  }
  _form_set_class($element, array('form-checkbox'));
  $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
  /* custom alter function */
  if(user_is_logged_in()){
    if(!user_access('administer taxonomy')){
      $cdms_taxonomy_id = taxonomy_term_load($element['#return_value']);
      // echo "IF"; exit;
    }else{
      $cdms_taxonomy_id = taxonomy_term_load($element['#return_value']);
      // echo "Else"; exit;
    }
  }
  // echo '<pre>';print_r($variables);  echo"Term load"; print_r($cdms_taxonomy_id);  exit;
  $data = [
    'title' =>  $element['#title'],
    'tid' => @$cdms_taxonomy_id->field_cdms_txy_id[LANGUAGE_NONE][0][value],
    'count' => '',
  ];
  // Calling all modules implementing hook_my_data_alter():
  drupal_alter('my_data', $data);

  if (!in_array("Client User", array_values($user->roles))) {
  $title = $element['#title'] ."(".$data['count'].")";
}else{
   $title = $element['#title'];
}
  if (in_array("Client User", array_values($user->roles))) {
    $title = check_plain($title);
  }else{
    if (isset($element['#link'])) {
        $attr = array();
        $attr["class"][] = "term-data-link";
        $attr["class"][] = "term-data-link-id-" . $element['#return_value'];
        if (isset($element['#extra_info'])) {
          $attr["title"] = $element['#extra_info'];
        }
        $title = l($title, $element['#link'], array('attributes' => $attr));
      }
      else {
        $title = check_plain($title);
      }
  }

  $element['#children'] = '<label class="option">' . $output . ' ' . $title . '</label>';
  $element['#title_display'] = 'none';
  return theme('form_element', array('element' => $element));
}


texts: Expose a computed field (or external data) to Views

texts:
I want to add a virtual field to a "node", its content should be computed  from other fields of this node (with the module of the same name or with a hook) AND it must be usable by Views filter and sorting.

Is this possible (using modules or PHP code) ?


texts: How to update a language's language code

texts:
I have a multilingual site with English as default language.

The language code for English is currently en but I want to convert it to en-US.

I thought about adding a new language with the correct langcode, but I don’t think that’s the best solution since I have a lot of translated content, and I don’t want to add all the translations again for the new language.

Is it possible to update a current language's language code, if not, what can I then do?

TL;DR
I have a bunch of languages on my site, and I want to update all of their language codes without loosing my translations.


texts: How to print a date from Date module using user timezone

texts:
I would like to send an email out to a user when a new 'event' content type is posted. In this email, I want to display the title of the event, the body, and the date itself. For the date, I would like to print the date in the timezone of the user receiving the email.

So, when I send the email, I first get the user's account and the event node:

<?php
  $account = user_load($uid);
  $event = node_load($nid);
?>

I want to first check if the user has a timezone set in the user's profile, and if not, default back to the timezone used (and stored) with the event itself. So, something like:

<?php
  $timezone = $account->timezone ? $account->timezone : $event->field_event_date[$event->language][0]['timezone'];
?>

But, at this point, I'm not sure exactly how to print the date in the node in the correct timezone. I'm thinking I might have to first create a new DateTime object, then convert it using date.module's date_format_date, or maybe convert the date to a timezone, calculate the offset, and use PHP's date() function or format_date() to display the end result, but this all seems overkill.

Is there a simpler way to print out a date from a date field attached to a node in a user's timezone?

[Edit:]

I'm trying to format the date using format_date() or date_format_date(), but format_date() requires a time stamp, which is difficult to create from the date field's output, and date_format_date() also requires proper timezone information when I create a date object, and I've found it difficult to account for the timezone supplied by the date field, and then translate that into the timezone for output.

[Edit 2:]

Here's the code I ultimately used:

<?php
  $event = node_load([nid]);
  // Build event date + timezone.
  $timezone = $account->timezone ? $account->timezone : $event->field_event_date[$event->language][0]['timezone'];
  date_default_timezone_set($event->field_event_date[$event->language][0]['timezone_db']);
  $date = strtotime($event->field_event_date[$event->language][0]['value']);
  $date_formatted = format_date($date, 'custom', 'M j, Y g:i a', $timezone);
?>


texts:
Long story short, I'm building a Superfish menu structure that looks like the following:

http://i.imgur.com/3h0KQGX.png]1

I'm using superfish & have everything in order except the labels on each of the sub-menus (GUIDES and BUSINESS STRATEGIES in the image)

How can one duplicate the parent link & add it to the sub-menu as a label above the links?

Ideally the strcture would look something like:

Link 1

Link 2

    Link 2

Link 3

Link 4

      Link 4

Link 5

Link 6

Thanks All, I'm stuck on this one, open to any & all solutions.

Edit: I should have specified that the labels need to be added automatically. I don't want to make the client add a bunch of duplicate labels by hand if I don't have to.


texts:
I want the webform submitted report to be sortable (or filtered), suppose there is the "Country" field in the form with selectlist of Countries,

I must be able to filter the reports with specific value,suppose "USA" or something else.

Thank you.


texts: I am not able to traverse from the last step to the first step in a multistep form

texts:
I have created a multistep form with five steps using programatically. Is there any way to traverse to first step form the fifth step?
I have created multistep form as given in example module. In the module, each step gives previous and next link only, and I am not able to go to the first step directly from the fifth step.


texts: Does Quick Edit function work for embedded entities?

texts:
I have a view which creates a block of User data related to the author of the node. The view display is a view mode of the User entity.
I see my entity when the block is placed on the node page; but there is no quick edit functionality. Is this expected behavior?


texts: Why Can't I Call Drupal Function From .inc File?

texts:
I have an inc file which I am including in my module using module_load_include. It contains the following function:

function _get_vid($vocabulary_name) {
    $vocabs = taxonomy_get_vocabularies();
    foreach ($vocabs as $vocab_object) {
        if ($vocab_object->name == $vocabulary_name) {
           return $vocab_object->vid;
        }
    }
    return NULL;
}

But PHP keeps complaining that taxonomy_get_vocabularies is an undefined function. Why? I know I've used Drupal functions in .inc files before with no issues.


texts: How can I make this with the Views module?

texts:
I am trying to find out how to make a view which, in pseudo code, does this:

  If year = 2005 and month = 04 and page = 2 then display 2 articles

I have Views3 installed, but I can't find out how to make the date filter, and how to make the page filter.


texts: Is it possible to force your module's update hook to run?

texts:
I am the author of the Date iCal module, and the new major version I'm working on (3.x) requires a two-part schema update for users who had 2.x installed. I've written the update hook that makes these changes, but if one of my users fails to run the database update script, they will get an error message relating to their iCal feeds importers.

The right solution is for them to run the update script... but if they just go in and manually change their importers to get rid of the message, their importers will remain permanently broken (because the second part of the schema update won't have been executed).

So is there any way to display a message to users who haven't run the update? Or somehow forcibly execute the update hook the first time a page load occurs when 3.x gets installed overtop of 2.x?


texts:
We are using Drupal 7 with context. I have understood that in Drupal 6 the core block system is inefficient in terms of performance. According to this article http://treehouseagency.com/blog/neil-hastings/2010/10/14/context-everywhere in context module (Drupal 6 version) there is a setting to disable the core block system. But in Drupal 7 context module configuration I cannot find this setting.

How can I make sure the core block system doesn't take part in the showing of the blocks? Ideally I would like to block access to admin/structure/block (since I don't want anybody to set blocks via that interface) but allow to access to admin/structure/block/add (since I want to be able to create blocks but show them with context).


texts:
Context:
Drupal 8.5, Search API Solr 2.2

There's a Solr-based view with Field display mode, as the results are not just nodes, there are non-Drupal content too.

Right now the dynamic page cache is not effective on the page.

Either the whole page comes from the cache or nothing. The pageload time is around 3 seconds on localhost (the rest of the site produces ~1s response times even as logged in user, due to dynamic page cache)
We did profiling, the Solr part is not significant, less than 1% of the execution, as a justification, the empty result page is like 100% faster than the page with actual results.

What's the most time consuming according to XDebug is the rendering and Twig.
One view row for the result is almost static, only the excerpt changes based on the keyword.Out of the box, for Views, is https://www.drupal.org/docs/8/api/render-api/auto-placeholdering active? Is it really the right way to speed up such a view?


texts: Regular Drupal 7 site users do not see new tabs added by hook_menu_local_tasks_alter

texts:
I used hook_menu_local_tasks_alter to add new tab items for node pages like so:

function custom_module_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  if (arg(0) == 'admin' || arg(0) != 'node') { return; }

  $href='user/'.arg(1).'/hobbies';
  $data['tabs'][0]['output'][] = array(
    '#theme' => 'menu_local_task',
    '#link' => array(
      'title' => t('Hobbies'),
      'href' => $href,
    ),
  );
  $href='user/'.arg(1).'/events';
  $data['tabs'][0]['output'][] = array(
    '#theme' => 'menu_local_task',
    '#link' => array(
      'title' => t('Events'),
      'href' => $href,
    ),
  );

However while admin can see the new tabs, regular users (Drupal 7) do not. Adding '#access' => TRUE, to item array does not help as hook_menu_local_tasks_alter doesn't have options for access argument.

And they appear normally if users are given node edit permission.

How can I make access to these new tabs without giving users permission to edit their nodes?


texts: How do I chose recipient email address depending on textfield value?

texts:
I have created a webform which has a "Reference number" textfield.

When someone types 101 in that textedfield, the submitted form should be send to example@gmail.com; if someone types 777, the submitted form should be send to example222@gmail.com.

Is there a way to achieve this?


texts:
I have installed the following modules:

Pathologic
Advanced Aggregation

I implemented hook_link_alter() where I set $variables['options']['absolute'] = TRUE;.

This helped with fixing:

All links within text formats using input filter
Javascript and CSS file paths
Menu link paths

However, this does not help with Image Style paths or custom text generated by the Views module.

Is there a way to do this on a global basis instead of chasing down every single link generation method and altering it?

I also looked into an Existing issue, but unfortunately it didn't help.


texts: Create a simpletest test to add additional form elements using the "Add another item" button

texts:
I am trying to create a test case for my custom module using simpletest in Drupal7.  I want to create a node.  The problem is that the node edit form contains a number of fields which can have multiple values.  Addition values are added by clicking on the "Add another item" button, which adds an addition field (nothing fancy here, just the standard Drupal form behavior).

I would like to create a node with two values for email.  By default the node form only displays one email field element.  To add a second email address I would have to first click the "Add another item" button, and then enter the email address. I am struggling to understand how to recreate this behavior in my test case. Any ideas?

The following is what I have so far:

  // Create a namecards_namecard node using the node form.
  public function testNamecardsNamecardCreate() {
    $this->drupalGet('node/add/namecards-namecard');
    // Create node to edit.
    $edit = array();
    // Enter surname
    $edit['title'] = $this->randomName(8);
    // Enter given name.
    $edit["namecards_namecard_given_name[und][0][value]"] = $this->randomName(8);
    // Enter email address.
    $edit["namecards_namecard_email[und][0][value]"] = $this->randomName(8) . '@' . $this->randomName(5) . '.com';
    // Click "add another item" for another email field.
    $this->drupalPostAJAX(NULL, array(), array('namecards_namecard_email_add_more' => 'Add another item'));
    // Enter another email address.
    $edit["namecards_namecard_email[und][1][value]"] = $this->randomName(8) . '@' . $this->randomName(5) . '.com.cn';
    $this->drupalPost('namecards/add_contact', $edit, t('Save'));
    $this->assertText(t('Namecards namecard @title has been created.', array('@title' => $edit['title'])));
    $this->assertText($edit["namecards_namecard_email[und][0][value]"]);
    $this->assertText($edit["namecards_namecard_email[und][1][value]"]);
  }


texts: Show contact form in block only, not page?

texts:
I'm using the Contact and Contact Form Blocks modules to create a contact form and display it in a block.

The problem is that the Contact module creates a page but I don't want a page, only the block.

Is this possible, perhaps with a different set of modules? If not then I guess I can deny access to the page using .htaccess, but that seems a bit of a hack (although since it's easier to do that than to add custom code, I'm not really interested in a custom code solution).

EDIT: I've tried using a webform instead but have the same issue. There's an option to make the webform available in a block, but the page (node) is also created


texts: How to export menu per role permission in features module?

texts: I added custom permission in my menu using menu_per_role module. I want to export the permission configuration that I made in my menu. using features module my question is how can I export my menu permission configuration. is features module support exporting configuration came from menu_per_role module? I also tried to check it in strongarm but I can't see it.


texts: Development without pulling production DB to your local machine

texts:
When you push configuration to production, any configuration that has changed in production that has not been exported into code will either be reset to the values in code or be wiped out entirely if they never existed in code. One out of many examples is changing the site name. If that change didn't go into code (i.e. if a content admin changed it, not a developer), the next deploy would reset that change.

Now the solution we have in place is to pull the production DB down and export the configuration against production code. Any differences appearing in the export are configs that have changed on production since last deploy. It's a process that you can easily wrap your head around (prod config - deployed config = changed config -> you check this in) and works pretty well so far.

But there are issues with this approach, one in particular is pulling the production database down. The DB may be huge, well into the hundred megabytes. It may contain sensitive info you don't want on your machines. Or it can only be retrieved indirectly (e.g. last night's cron job) and could already be stale by the time you work on it.

I know D8 config management is not perfect, and some things can't be avoided due to the current design of things. But I still would like to ask:

Is there a better way to do the process of resolving configs on deploy?
Is there any way to do this without pulling down the production database down?
Is there a Drupal/Drush/third-party module feature that already does what I am describing?
Is this more of a content workflow issue? i.e. never let content admins touch config?


texts: How to get the current currency code chosed by a site visitor in commerce

texts: Is there a way to get the currency code chosed by a site visitor in drupal commerce?


texts:
I'm using the Page Title module to set the <title> tags on nodes, etc.
I'm using the [current-page:page-title] token in my patterns.

According to the manual, this should let me write a custom page title on node level.

  This allows some nodes to 'inherit' the title from the node title and other nodes have the option to override the [page-title] token.
  [...] in this case, the author could override the node title and provide a separate page title [...]. Note that this field does not allow the admin to completely override the Page Title, but just the [page-title] token, which will be inserted as normal into the Pattern for that node type.

And the manual also says:

  So, basically, if you use the [page-title] (or [current-page:page-title] in Drupal 7) token in the patterns/template settings, it will take it's value in the following order:

  the value of the "Page Title" field.
  the Entity Title (eg, Node Title, User Name or Term Name), if Page
  Title field has no value (in 1).
  the value of the title returned by Drupal's "get title" system (i.e. a fallback). This is usually defined by the Menu API system.

However, when the pattern is set to [current-page:page-title] and I do NOT write anything in the Page Title feed on node level. Then the node gets no title at all. It doesn't fall back to the pattern: It simply doesn't get any title.

Have I misunderstood anything?


texts: When does the computed field get calculated?

texts: I don't understand when a computed field computes. Does it compute when the fields it draws on are updated or when someone views the node it's used in?


texts:
I have a View and inside it I have and Attachment display. In this attachment I set a Header with the value you can see in the image below.
I'm sure I have register_globals = 1;
But nothing is printed...


texts: User anonymity while using user_external_login_register()?

texts:
I am using D7 and implementing my own 3rd party authentication against campus LDAP by hook_form_alter()ing a user_login_form to my use own custom user_login_authenticate_validate() which eventually calls user_login_external_register().  As general examples see these blog posts for this technique:

blog entry 1

blog entry 2

But using this method, or even the D7 LDAP module; I see Drupal eventually calls user_login_external_register() with $username and $password.

I dont want to store ANY $username or $password in Drupal as this is considered private student campus data. So, can anyone suggest a mechanism provide dummy user $username and $password for thousands of users logging in? What can I stuff into $username or $password to be able to know that if a student logs in 2 weeks from now they have the same Drupal account they used 2 weeks ago.

All I can think of is generating thousands of custom PHP uniqid()'s and provisioning 1 per each user just prior to calling user_login_external_register() by stuffing faux $username and $profile into the $edit or $account before Drupal creates the account and after the authenication by the 3rd party.

Any feedback and thoughts appreciated.


texts: Default customer profiles re-added on order edit, even without address field present

texts:
My site uses 2 custom profile types for a particular set of customers. For these, I have the default billing and shipping profile panes completely removed on the order edit screen via Customer Profile Type UI, yet any edit to an order (manual or programmatic) still re-adds them to the profile on save (resulting in 4 profiles for the order).

The address field has been identified as the culprit, but in my case, the default profile panes are not present in the form, so I don't understand how an address field that isn't there could trigger a new profile being added. Is there another mechanism in Commerce that would add default profiles if they are missing?


texts: Accessing Leaflet maps from custom module

texts:
Trying to add to Leaflet map marker from the custom module. Leaflet map created with IP Geolocation Views & Maps module. I try to connect to the map as described here http://dripl.nl/blog/taming-leaflet-maps-drupal
The message alert appears with the coordinates, but the map does not increase the zoom. What could be the reason?

I also tried to replace the string myMap = lMap; with var myMap = Drupal.settings.leaflet [0] .lMap; not help.

test_module.module

function test_module_form_article_node_form_alter(&$form, &$form_state, $form_id) {
    $form['field_photo']['#element_validate'][] = 'test_module_validate_function';
}

function test_module_validate_function($element, &$form, &$form_state){
    $marker = [49.055688666667,34.338167222222];
    test_module_add_marker($marker);

}

function test_module_add_marker($marker) {
    drupal_add_js(drupal_get_path('module', 'test_module').'/test_module.js');
    drupal_add_js(array('test_module' => array('marker' => $marker)), array('type' => 'setting'));
}

test_module.js

(function($) {
  $(document).bind('leaflet.map', function(e, map, lMap){
    myMap = lMap;
  });

    Drupal.behaviors.test_module = {
        attach: function (context, settings) {
            latlon = settings.test_module.marker;
            alert(latlon);
            myMap.setView(latlon, 14);
        }
    };

})(jQuery);


texts:
As it stands

I am currently developing a multilingual website using Drupal 7 and the i18n module.

The problem

When i do a search using drupals built in search form it is returning content for all languages, rather than just for the currently selected language (as i would expect it too).

What i need

I need the search to only return results for the currently selected language.

Thanks in advance for your time.


texts: URL Redirect created over SSL only works over SSL

texts:
I have added a redirect via:

  Configuration > Search and Metadata > URL Redirects

While accessing the site via SSL. When I add the link the from box auto fills the root of the redirect with https://myRootURL.com/ :

This redirect works for https://myRootURL.com/redirectedLink but does not work for non-ssl: http://myRootURL.com/redirectedLink. I would expect all of these redirects to be ssl/non-ssl agnostic - and the ones auto-generated by Drupal all seem to be.

Is this a configuration issue - or known problem? I have had no luck with Google or browsing the known issues, but I am not sure I am articulating the problem correctly.

EDIT: I am experiencing the same functionality with URL Aliases as well... what configuration options could impact this?


texts: Margin before admin menu with Views admin pages

texts:
Screenshot shows the problem:

This margin appears on all admin pages which use Views on Seven theme and module Administration menu. As example, Drupal Commerce products list. Actually this is because of body class .contextual-links-region. I didn't find any issues about it. Can anybody comment it?

UPD: Problem disappeared after Drupal update to 7.8.


texts:
One can retrieve field items from an entity with

// Find all terms on $node in field 'field_tags'.
$terms = field_get_items('node', $node, 'field_tags');

But is there a convenient way to do the reverse, Core, or otherwise?

// Attach new term $term to $node in field 'field_tags'.
$term = taxonomy_term_load($tid);
$node = field_set_items('node', $node, 'field_tags', 'taxonomy_term', $term);
node_save($node);

I would like to avoid the hassle of manually assigning a $term, go look in devel what the array structure looks like and then build the array by hand, as it is sometimes non-trivial.

The only issue in the core queue I could find that looked vaguely similar was about the field language api DX.


texts: After installing Drupal I cannot use the dashboard menu because none of the URLs are found. I cannot google my way to find a solution to this so.


texts: How can I change the "sites/default" into "web/sites/subsite" on the new location?

texts:
I have moved the content (files and database) of my "traditional" site (no composer, single site, using sites/default/files folder ) to a subsite on a multi-site that is created using composer. The images do not show, because the new site is still using part of the old path.
The path to images used is

https://subsite.domain.be/sites/default/files/201505/image.jpg

while it should be:

https://subsite.domain.be/web/sites/subsite/files/201505/image.jpg

Path in admin/config/media/file-system on the subsite seems correct:

Public file system path : sites/subsite/files
Public file base URL : https://subsite.domain.be/web/sites/subsite/files

In the source code of some of the body fields holding the images, I see the ancient URLs of subsite.drupalgardens.com ?!? (does no longer exist, while these images did show up on the traditional site that uses default/files)
Why are the images addressed wrong ?
How can I change the "sites/default"  (or the drupalgardens-link)  into "web/sites/subsite" on the new location ?
Or what could/should I have done before importing the database ? (I can start over, no problem)


texts:
We are trying to create a single page that has all the available user related forms available without have to click between pages.

We have been able to render some forms, like change password, but we are trying to include other forms rendered outside of the user module.

Specifically having trouble with rendering commerce_addressbook existing values and the 'add new address form'.
https://www.drupal.org/project/commerce_addressbook

Could anyone please outline the correct way to do this?


texts:
I have this code:

$form['custom'] = array(
'#title' => t('Some title'),
'#type' => 'select',
'#options' => $custom,
'#default_value' => isset($option->name) ? $option->name_id : '',
'#description' => t('Some text goes here.'),

Now when i do print_r i get data from option and the name_id of the selected one.
No how can i get this data (name_id) from "#default_value" ??

In submit function i have this:

$custom=$form_state['values']['custom'];

But this only gets me the name not the name_id .