texts: Send email after node save based on a checkbox in a vocabulary

texts:
I was wondering if someone could help me with this.

I have a content type called "News", this content type has three fields (Title, Date, Body)

I have vocabulary called "Contacts", this vocabulary has multiple fields including a "Receive all notifications" field and an "Email" field.

My scenario is when a "News" item is saved, I want an email to be sent to each contact term from the "Contacts" vocabulary that has the "Receive all notifications" field checked. The email address pulls from the "Email" field.

Is this possible using rules? I'm having a difficult time trying to get fields to show for the vocabulary when it's not related to the news node that is being saved.

Thanks in advance for any help!


texts: I have a site with about 30 members, but I just added a new mandatory field on the registration. I want the old members to be forced to fill this in as well. What would be the best way to do this?


texts: i have two separate contents in two different content type. The other one is in the basic page, other one is in the content type i made(regional malls). The taxonomy terms or tags is showing in basic page when i publish but my problem is in the regional malls content, when i published, taxonomy terms or tags does not show up, any ideas why is this happening?or advise how to overcome this?


texts:
I downloaded and enabled translations for my Drupal core and modules using these Drush commands:

drush dl l10n_update && drush en -y $_
drush language-add lt && drush language-enable $_
drush l10n-update-refresh
drush l10n-update

I got almost everything translated, and in "Administration » Configuration » Regional and language" I see that I have almost 60% of translations to Lithuanian.

However, not everything is translated. For example, harmony forum module thread reply;

2 replies

Atsakyti

Reply as a new thread

      (0) Like&nbsp;

and user profile statistics

Thread count:

Post count:

How can I edit these strings to be translated?


texts: Why are `drush pm-list` & `drush pm-updatestatus` disabling the default theme?

texts:
I have a Drupal 7 site with 3 themes enabled:

Foo
Adminimal
Shiny

Foo is a custom theme for the front-end, located in /sites/foo/themes/ and set as the default.

Adminimal and Shiny are both installed via drush make into sites/all/themes/contrib/.

Running drush pm-updatestatus disables the default 'Foo' theme.

$ drush pm-updatestatus
Checking available update data ...                             [ok]
Failed to check available update data for Foo settings.        [ok]
Checked available update data for Administration menu.         [ok]
...
Checked available update data for Adminimal.                   [ok]
Checked available update data for Shiny.                       [ok]
Failed to get available update data for one project.           [error]
Checked available update data for 64 projects.                 [status]
 Name                                                        Installed Version  Proposed version  Message
 Administration menu Adminimal Theme (adminimal_admin_menu)  7.x-1.6            7.x-1.7           Update available
...
 Adminimal (adminimal_theme)                                 7.x-1.21           7.x-1.24          Update available
 Shiny (shiny)                                               7.x-1.6            7.x-1.7           Update available

The Failed to check available update data for Foo settings. & Failed to get available update data for one project. [error] lines from the output clearly look relevant, but I'm struggling to identify the underlying cause.

With the Drush's -d debug flag enabled the output includes this line before the Failed to get update data for on project [error]:

Undefined index: foo theme.inc:100 [1.78 sec, 35.7 MB]            [notice]

drush pm-list has the same effect.

Presumably there's something wrong with the declaration, or location of the Foo theme?

Checking the status report via the Drupal admin does not disable the Foo theme.

Why would drush pm-list & drush pm-updatestatus disable the default theme?


texts: Accesslog was removed from the Statistics module in Drupal 8: https://www.drupal.org/node/1446956. Does this functionality now exist somewhere else in core?


texts: Date filter GRANULARITY for Search API VIEWS

texts:
I am working on Search API view. There is a Date Exposed filter. The requirement is we have to filter based on Month-Year instead of Day-Month-Year. But there is no Granularity option to select for Search API View.

For simple views, there is Granularity option to select Day/Month or year. See in attached screenshot .

I am able to achieve this functionality in simple view see in the screenshot

Can someone help me to achieve this functionality for Search API views?


texts:
How to get the highest value of a specific field in a multivalue field collection, USING PHP?

This is about displaying the right discount for a marketplace product.

There is a node type Product with two field collection fields:
(1) field_discount which contains:
    - a field for the minimum quantity required for the discount
    - a field for the discount percentage
(2) field_price which contains:
    - a field for the base price
    - a field for the discounted price

The reason why (2) is also a field collection, is because I want to allow the marketplace sellers to show multiple price options. This might be relevant information because it seems that the views reference filter module does not work with field collections. Using that module would have made this issue a lot easier. Instead, this question focuses on using PHP, unless someone has another solution that does not require or requires less PHP coding.

The discount price needs to be built on the fly when a product node is displayed, using the raw quantity value from the URL and calculating the discount. My solution was to use a jump menu view with numbers 1 to 1000, which adds the quantity to the URL, like http://xxxx.com/node/100/5  in which the "5" as product quantity is inserted by using the jump menu. However, this might not be the most efficient method in the context of this issue. You are free to suggest another approach if that serves a more efficient solution to this issue.

STORING DISCOUNT AS VARIABLE
Only after the customer sees the discount price and clicks ORDER  (a flag button), the transaction values are stored in transaction entity fields. Therefore, the transaction values need to be available as variables.

Using PHP code in Global NULL, Session variables.
My current approach is to use a Global Null as views contextual filter, default value PHP code, in order to fetch field values and calculate discount, and to store the values as SESSION variables. Since no transaction entity is created yet, I can't see another way to store these values for further use in the (possible) transaction.

My experience with php and metadata wrappers etc is insufficient, especially with regard to fieldcollections.

WANTED:
the discount percentage, corresponding with the quantity chosen by the buyer. The discount percentage must be within the range of quantities specified by the product owner.
Solutions with either other Drupal modules, or custom php are both welcome. As mentioned above I tried the views reference filter, using an exposed filter referencing quantity values of the field collection, but I couldn't get that to work.


texts:
I want to ask if it is possible to "virtual" merge 2 different nodes created at 2 different timestamp but which contains the same node Title(only the "explain" text field is different)
I want to rate these nodes with the Fiveestar module but the average has to be calculated from both of them. Now they are treated as 2 different nodes.

Is this possible?

Kind regards

Jürgen


texts:
Right now I have a redirect in my code:

drupal_goto($path);

Per the documentation drupal_goto defaults to a 302 redirect. I want a 301.

However, when I put in:

drupal_goto($path, $http_response_code = 302);

It gives me an error:

  Argument 2 passed to drupal_goto() must be of the type array, integer given,

But if I try something like:

drupal_goto($path, array $options = array(), $http_response_code = 302);

...I get this error:

  Unexpected '$options'

How can I properly change drupal_goto into a 301 redirect?


texts: How to set media rate calculations for shipping?

texts:
I am incorporating UberCart into our existing Drupal 7 website. So far I am happy but can't seem to figure out how to set media rate calculations for shipping for publications and regular shipping quotes for everything else. Any guidance is appreciated.

Drupal 7.50 UberCart 3.6


texts: How to change the markup of a content entity in the Views UI?

texts:
Sorry if this has been asked already, I haven't seen anything yet exactly what I'm looking for.

I'm using the Views UI in Drupal 8 to output a list of a custom content entity type that I created via a custom module. I'd like to know what's the best way to programatically alter the markup of the entire entity.

I know that to do this with a field belonging to the entity you would use {module}\src\Plugin\Field\FieldFormatter\{formattername}.php and this would appear as an option for displaying a field, but is there a way to do this for the whole entity rather than just a field?

If there are any articles on this topic anyone could recommend I would greatly appreciate it, thank you.


texts: How to do path aliases for views like news/%?

texts:
Let's suppose we have a view like news/%.
Where news is my content type, and % is tid of term id from vocabulary "categories".

Obviously that urls like news/3, news/5 etc. works great. But how to do the path aliases for this kind of urls, generated from this view?

I want like this:

news/% -> company-news/[term:name]
Example: news/3 -> company-news/accidents

(where [term:name] transliterated term name from original title, because my site not on english language)

P.s. the just using pathauto for taxonomy terms, and the view "taxonomy/term/%" does not suit, because one term is used by multiple content types, and therefore in multiple views.


texts:
I have a Drupal 7 site with a large database of more than 500.000 items. I want to do some tests because the current search configuration looks for entire words, when a user write in a textfield to search and the idea is to search for partial words.

I need to see the difference of time between the two methods for seeing the performance of the search. I have been searching in Google but I don't find anything. Is there a way to do this?

The idea for the partial words is to search from the final like the SQL sentence Where ____ LIKE '....%' (% at the right)


texts: How to set field permission on same field for different content type

texts:
I have two content type A and B and I have created a field in A by name a1, which I have used in other content type B, so A and B both have field a1.

Now, I have installed Field Permission module, and assigned permission on field a1 for Content Type A, now I want to assign permission on a1 for content type B, but on assigning permission to a1 in content type B, it is changing field permission that of A also.

Please provide me a solution for it.


texts: How to change the link text in Drupal 8 Views?

texts:
I have a simple problem that I can't seem to resolve despite everything I have tried. Googling for a answer has not turned up anything either. Here is my problem:

I have an entity A that references entity B. What I would like to do is be able to link to entity B's content (by that I mean click a link and be taken to the page the displays entity B's content). In Views you would use the "link to content" switch to accomplish this.

However here is the catch, I would like to use entity A's title as the link's text. I figured this would be an easy thing to do in Views, but no matter what I tried I can't do this.

I have tried rewriting the result in Views, but I can't find a reference to say that you want to link to entity B's url. Using the below substitution:

{{ entityA_title }}

you would get a link that looks like:

EntityB Title">EntityA Title

Where EntityB Title would link to Entity B's content and EntityA Title would link to a page that does not exist. It looks like you can't separate Entity B's title from its url - where I just want its url.

Is there a way to accomplish what I want to achieve? I figure this should be possible and straight forward to do, but apparently not.

Thanks.


texts:
i have a site where I use display suite for custom page display. And all works. Now I need to add a custom field formatter for the "Author" field, but I don't find how to link "author" to a new field formatter.

I know that I need to use hook_field_formatter_info() but I don't understand which is the right value for "field types". I have tried with "user", "user_reference", "text","author" but nothing.

I have tried to see how Display Suite define its fields formatter, but for this field the module use "2" for this value:

$fields['node']['author'] = array(
    'title' => t('Author'),
    'field_type' => DS_FIELD_TYPE_FUNCTION,
    'function' => 'ds_render_author_field',
    'properties' => array(
      'formatters' => array(
        'author' => t('Author'),
        'author_linked' => t('Author linked to profile')
      ),
    ),
  );

where

define('DS_FIELD_TYPE_FUNCTION', 2);

So how can I add one new field formatter for the author field ?

Thanks.


texts: How to modify user messages without hacking core user module?

texts:
When "themeing" modules, especially core modules, as far as I know it is a good idea to take the module specific tpl.php files, duplicate the ones you need, and modify them once they're in the relevant theme directory.

However, what if I want to modify a .inc file? Is it the same process as with tpl.php files, or is there a better workflow? Basically what I would like to do is change some of the user status messages found in user.admin.inc in the core Drupal 7 User module. I'm not sure if editing this file directly is a good idea. Thoughts?


texts: How do I show a basic search block on the front page that integrates with search api?

texts: I've been creating my search pages in Search API, but I want to offer a search block on the front page or other pages that can do what the core search block does. Is there a way to either integrate the search block, or a work around to have a search block on the front page while it pulls up search and displays everything on the main search page?


texts: How to prevent SubFormState storage leaking into parent?

texts:
I have ajaxified form where I add or remove plugins. If plugin is present it provides its configuration form.

I am using the SubFormState, as one should, but I have noticed that if plugin sets data into the form state's storage(ie. it also uses ajax), they will leak into the parent form state.

Beside key collision(high probabilty with multiple plugins) the main issue I am facing is that once I remove a plugin but add it again, the data from previous configuration is still present in the form state storage so I end up with already configured plugin form, which is highly undesired.

This is happening because the plugin has no way of knowing it has been removed from the parent form so there is no way to unset the data from storage and the parent form has no way of knowing the plugin(s) put something into the storage as well, so there is no garbage collecting possible.

I am wondering if I should Implement a plugin interface that would have "flushState" method that I would have to invoke when I would remove the plugin from the form or there's a better way to do this?


texts: Does anybody know how to add the remove button in a custom module (field type) with unlimited number of values?

texts: I am trying to add my custom field/module to a content type. I select Unlimited for the Allowed number of values option in Field Settings and I am able to Add another Item, however there is no remove button. Furthermore, each time I edit the content; an extra (blank) field is added.


texts: Images are not showing after migration and were also not migrated into the files folder

texts:
I am trying to migrate drupal 7 to drupal 8 using default migration modules ( Migrate, Migrate Drupal, Migrate Drupal UI, Migrate Plus, Migrate Source CSV, Migrate Tools ) using this modules content and text fields and entity refrence fields all are migrated but only image field is not migrated to drupal 8 also drupal 7 existing images are not migrated to drupal 8 /sites/default/files path what am i missing for migrate image field.

Does anyone have any solution?

Ex : Blank image field showing in migrated article node.


texts: Avoid duplicate product while using variations

texts:
I am new to drupal and fetching Drupal commerce variations from Views and the products are getting duplicated what would be the best way to avoid duplicate when using product variations. Here are the screenshots from views
http://puu.sh/vn1Po/75e158f5c5.png
Any help is really appreciated.


texts: Form element's #required set to FALSE, but form submission still consider it as required

texts:
I am trying to theme Contact form with template file, manipulating the contact form with form API, trying to hide the subject field and make it optional for submission.

$form['subject']['#required'] = FALSE;
hide($form['subject']);

I used dsm() to confirm that the #required is successfully set to FALSE.

However, when I submit the form, it still ask me to fill in Subject field. (The cache has been cleared.)

These are the steps that I have followed:

In the template.php file I added the following code

function mytheme_theme() {
  return array(
    'contact_site_form' => array(
      'render element' => 'form',
      'path' => drupal_get_path('theme', 'mytheme') . '/templates',
      'template' => 'contact-site-form',
    ),
 );

I created the contact-site-form.tpl.php file with the following code

$form['subject']['#required'] = FALSE;
hide($form['subject']);
print drupal_render_children($form);

I cleared the cache


texts: What does Page Content contain in Panels Everywhere when site template is enabled?

texts:
Panels Everywhere (PE) configuration allows a site template to be used to "wrap" any page in a panels display.

If I edit the content of this panel, for example like this:

does it mean that any (I mean all) other page will be crammed in the Page Content item defined in the template?

In other words:

Are pages always inserted in the template's page content?
Is there anything else than pages ever ending in the template's page content? If yes, what and when?


texts: How do I print an image in field collections (for custom theme)

texts:
When I try and print an image in my custom field template using field collections module, I only get the word "array" instead of an image. This is Drupal 7 btw.

Following this great tutorial
http://fourkitchens.com/blog/2013/06/03/better-way-theme-field-collections
I have added the following to my template.php file:

function rows_from_field_collection(&$vars, $field_name, $field_array) {
  $vars['rows'] = array();
  foreach($vars['element']['#items'] as $key => $item) {
  $entity_id = $item['value'];
  $entity = field_collection_item_load($entity_id);
  $wrapper = entity_metadata_wrapper('field_collection_item', $entity);
  $row = array();
  foreach($field_array as $field){
  $row[$field] = $wrapper->$field->value();
}
$vars['rows'][] = $row;

}
 }

function TKC_preprocess_field(&$vars, $hook){

if ($vars['element']['#field_name'] == 'field_roster') {
$vars['theme_hook_suggestions'][] = 'field__field_roster';

$field_array = array('field_athlete_full_name','field_roster_image');
rows_from_field_collection($vars, 'field_roster', $field_array);
 }
}

And then created a custom filed template in my theme file called field--field-roster.tpl.php

In this file, I have the following code - all of which works like a charm, excpet for the image filed which prints the word "array"

<?php foreach($rows as $row): ?>

        <?php print $row['field_roster_image']; ?>

<?php print $row['field_athlete_full_name']; ?>

<?php endforeach; ?>

I think this is a basic issue and not sure how to change the line

<?php print $row['field_roster_image']; ?>

to make it render the image. Any ideas?

Thanks in advance !!


texts: How do i use Webform API to submit my Custom Module form?

texts:
OK kinda noob-ish question but im unfamiliar with the programing side of Drupal... Im currently building a Form from scratch in drupal 7 (custom module since im using Form_Panel to arrange my form fields) and i would like to implement the webform API into my code as the submit handler.(This way i can hopefully use webform UI to deal with submissions and viewing results at least) Currently i have all the form fields and a submit button but not much else...

function my_module_menu() {
$items = array();
$items['my_module/form'] = array(
'title' => t('Subscription'),
'page callback' => 'my_module_form',
'access arguments' => array('access content'),
'description' => t('Subscription'),
'type' => MENU_CALLBACK,
);
return $items;
//some random fields from form API after
///////////////////////////////////////////////////
////////////////// Submit button
$form['submit'] = array(
 '#type' => 'submit',
 '#value' => 'Submit',
 '#submit' => array('my_module_my_form_submit'),
);
return $form;
}
function my_module_my_form_submit($edit,$form, $form_state) {
drupal_set_message('Submission recieved.');
}

And thats it.It shows perfectly on site and submit refreshes the page.. What i need to know is which function and methods should i use to get webform or drupal period to save my values(create a db table first?) and display them at the necessary time through whatever links on the site.


texts: Dependency injection in Drupal queueworker plugin

texts:
I am creating a queueworker plugin, and would need the QueryFactory and EntityManagerInterface.
I set these as 'use' statements, and added them in my parameters in __construct(),
but i get following error:

  TypeError: Argument 1 passed to Drupal\custom_example\Plugin\QueueWorker\SalesQueueProcessor::__construct() must be an instance of Drupal\Core\Entity\Query\QueryFactory, array given

My QueueWorker plugin:

namespace Drupal\simplified_bookkeeping\Plugin\QueueWorker;

use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\custom_example\Entity\BookingEntity;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\EntityManagerInterface;

/**
 * Processes Sales Tasks.
 *
 * @QueueWorker(
 *   id = "sales_queue_processor",
 *   title = @Translation("Generate sales from bank/cash statements in queue"),
 *   cron = {"time" = 10}
 * )
 */
class SalesQueueProcessor extends QueueWorkerBase {

  public function __construct(QueryFactory $entity_query, EntityManagerInterface $entityManager) {
    $this->entity_query = $entity_query;
    $this->entityManager = $entityManager;
  }

  /**
   * {@inheritdoc}
   */
  public function processItem($bid) {}
}

What am I doing wrong?


texts: Randomly italicized words appear in the admin UI

texts:
None big deal, but I noticed that various parts of admin UI (e.g. some of the field name headers, admin menu menu items) get randomly italicized by <em> tags inserted for unknown reason.

Has anyone bothered to pin that down to some pattern?


texts: How to get a week range as a Views filter - Thursday to Wednesday

texts:
I need to return nodes that have a date within a date range of Thursday to Wednesday. I have tried many different combinations, but none do the trick all the time.

The closest I can get is to set the Date From to:
"Last Thursday"
and the Date to, to:
"Wednesday"

This works whenever the day isn't Thursday. As a demo:
Today is Saturday 24th. The Filter would return everything from Thursday 22nd through to Wednesday 28th. Perfect!
However on Thursday 22nd, it returns everything from Thursday 15th through to Wednesday 28th. A whole extra week of content I don't want!

Any ideas on how to combat this in Views?


texts:
I am trying to update a node after a form submission with the following code, but it is being run twice:

if(isset($params['commit'])){
  $node = node_load($params['commit']);
  $field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_commits'));
  $field_collection_item->setHostEntity('node', $node);
  $fc_wrapper = entity_metadata_wrapper('field_collection_item', $field_collection_item);
  $fc_wrapper->field_email->set($email);
  $fc_wrapper->save(TRUE);
  $commits = $node->field_commitments['und'][0]['value'];
  $commits = intval($commits);
  $commits = $commits+1;
  $node_wrapper = entity_metadata_wrapper('node', $node);
  $node_wrapper->field_commitments->set($commits);
  $node_wrapper->save();

  header('Location: /take-action');
}

I am using a standard HTML form with method="post" and action="?commit=[NID]" because the markup is already given and trying to convert it to work with drupal_get_form and all that is not feasible. Then I'm processing the parameters within the callback's template.

Can anyone give me any idea why the save() methods above are called twice? e.g. I submit a single email string, and it gets added twice and so on.

Thank you.


texts:
I'm working on module that should behave as API endpoint.

I created Controller which handler POST & GET requests from external system, but I need to add user authentication so only authenticated user can acccess these endpoints.

My mymodule.routing.yml:

mymodule.show_content:
  path: 'api/getContent'
  defaults:
    _controller: '\Drupal\mymodule\Controller\ContentController::getContent'
    _format: hal_json
  requirements:
    _method: 'POST'
    _custom_access_check: 'TRUE'

My mymodule/src/Access/CustomAccessCheck.php:

class CustomAccessCheck implements AccessInterface
{
    public function access(AccountInterface $account)
    {
        return ($account->hasPermission('access content')) ? AccessResult::allowed() : AccessResult::forbidden();
    }
}

My mymodule.services.yml:

  mymodule.custom_access_check:
    class: Drupal\mymodule\Access\CustomAccessCheck
    arguments: ['@current_user']
    tags:
      - { name: access_check, applies_to: _custom_access_check }

I created a user called REST with REST role. I gave him 'access content' permission and tried to make request with Postman using POST method and following headers:

{
    Content-Type: application/hal+json,
    Authorization: Basic <base64_encoded user:pass>
    X-CSRF-Token: token obtained from <page_url>/rest/session/token
}

When I make request with admin user, I see in recent logs, that admin access the route /api/getContent but access was denied. When I use my REST user it logs as anonymous user. Even when I log the status of authentication inside CustomAccessCheck::access function I see that user is authenticated with TRUE

I need to keep this authentication separated (out of controller, in service or something) because I need to authenticate every request (re-use auth) so only internal users can use API (and not everyone with URL). I don't understand what is missing and why only my admin user is recognized by drupal and the REST user not.


texts: How to allow user registration and allow them to upload videos?

texts:
I am creating a video sharing website like youtube, dailymotion etc. So I need to allow registered users to upload videos when they come to their profile on my website.

I have already setup a media content type with images and video options.

How can I allow users to create it?


texts: What is the most drupally way to add a slide show (as a block? So I can reuse it in multiple places)

texts:
I'm very new to Drupal 7, and just getting started.

I'm looking to add this slide show on my site:
http://jquery.malsup.com/cycle/int2.html

The "Manual and Auto Advance
(hover to pause, click to advance)" one.

What is the best way to do this?  My understanding is that Drupal 7 already supports a lot of core jquery stuff.  So, in which drupal file would I add the code

$('#id_name').cycle({
    fx:     'fade',
    speed:   300,
    timeout: 3000,
    next:   '#s3',
    pause:   1
});

If this plugin is not already supported, then in which drupal file would I add the jquery cycle declaration, and where would I install those files?

More importantly, I am asking these operating under the assumption that I should make this a block, so that I could conceivably show this slideshow in multiple places on my site.  Is that a good strategy, or is there something better?


texts: Adding a button or text link to a content's view (Drupal 7)

texts:
I would like to add a link or a button to my content's main view (I.E. ?q=node/120) that will redirect the user to a java applet that the node already has a reference to.

Is there an easy way to add such a button or link?


texts:
Using Drupal 8 and the Language module.

The vast majority of the site is in the default language (en). We've added languages en-sci and en-sci-simp. Only a handful of pages, limited to a single content-type, are en-sci or en-sci-simp. As soon as a user goes to a page prefixed with /en-sci or /en-sci-simp, the language setting is prefixed on all other URLs.

This works as far as getting the user to the proper page, but instead of generating a menu link to ie /research, it is built as /en-sci/node/1000. This breaks a few things other than my sensibilities such as block visibility based on current path.

Is it possible to configure path generation to include the language prefix only for multi-language pages or content-types, leaving everything else "native"?


texts:
I installed XAMPP on my local machine to use it for Drupal. But all the navigation between all the localhost websites are really slow, no matter if it's a brand new vanilla Drupal website or if it's a commerce website, drupal 7 and/or drupal 8.

I tried everything from apache config to mysql config to windows config.

I decided to try to either re-install XAMPP or install Acquia Dev Desktop instead.

2 questions:
 if i want to re-install XAMPP, do i need to uninstall it first or will it reinstall over it just fine?
 if i want to install Acquia DEV Desktop, do i need to un-install XAMPP first?

Thanks...


texts: How to load nodes that are associated with the child of a taxonomy term

texts:
This questions has some similarities with How to display list of nodes that share the same Parent taxonomy term as current node, but I've not managed to figure out how I can get to what I need to do given the answers there.

A have a set of nodes that are associated via term reference with a taxonomy, that is two levels deep.  I'll call the parent level area and the child level task.

This is a migration from another website that has pages for publications associated with each area but in my current data structure I only associate the publication nodes with the tasks (children of the areas).  The areas each have a legacy_area_id field populated with the area id that was used in the url on the old site.

What I want to do now is create a view that will listen on pub/by/area/% and take a legacy area id as a contextual filter, and show a list of all nodes associated with a child of the taxonomy term that has that value in its legacy id field.

An example:

With a data setup like this, a request to /pub/by/area/1

Should return a listing containing Nodes 1, 3, and 4

One option would be to go back and change my migration to associate the publications with areas too, but that seems likely to make the task of moving tasks between areas later quite a bit more complicated.

Another option would be to add the legacy area id to the tasks as well, but that provides similar challenges.

In reality, my end goal is to redirect these pub/by/area/# requests to a different view with the area name in the url similarly to what I've done for other old addresses in How to redirect based on matching a node field?.  So really I suppose all the view really needs to give me is the data required to redirect to another view.  I'll keep working on this, but help would be appreciated.


texts: How to locally export config from a remote environment?

texts: If I have config that's out of sync on production, I may want to export it without copying down the database, or I may have environment-specific config that interferes with exporting config from the local environment. Is there a way to export config from a remote environment locally?


texts: Get a notification if a new version (tag) is created

texts:
Before there was a RSS fead that got update if a new release of drush is available, see question:
Getting an email notification when a new Drush version is available.

But after drush is moved to github it seems that the RSS feed does not get updated anymore.

Is there a possibility to get an email notification if a new release tag is created on the github site?


texts: How to change the default navigation "active-trail" class to something different (or add an extra class)?

texts: How do I change the default "active-trail" class on the navigation menu <li>-item to something different, or add an extra class to the current active item?


texts: Remove order from Field Collection set in form

texts:
I am using the Field Collection and Field Collection Fieldset modules to group a set of elements in my form. But what i see in the form is an Order column for the fieldset items, which i would like to hide, as shown in the below screenshot.

I have tried a lot to figure out if i can hide the Order from the backend, but i could not find a setting for it anywhere. So i am now looking forward to use a hook, to hide it. I also checked the field level structure using Devel module and dpm($form); but i have no idea on how to accomplish this. Can anyone help me?


texts:
I'm new to drupal 7. I am trying to configure a side menu that has links in it from a block within a View I made.

All I want to do is to make it so that the external links in that menu go the actual page themselves (WITHOUT USING A MODULE SPECIFICALLY FOR LINKS).

Is this possible? Is it simply a matter of settings for the fields specific for the links. Here is a screenshot of my view from my daskboard, any help is appreciated


texts:
How I change node edit form, which created by CCK module?

Now if the form is submitted, CCK update some field in mysql database. I need to change this, because in one form input contains three values, and this values need to be recorded in three fields in databse. How can I do this?

Jimmy Ko said, that I can retrieve the submitted value in $form_state['#values'], but I don’t know in what .php file I can do this?


texts:
I've replaced the deprecated functions with non-deprecated functions using drupal-check and PHPStorm. The site builds on Drupal 8.9.13. I update composer.json to 9.1.5 and run composer update. drush status output is the following.
    Drupal version   : 9.1.5
    Site URI         : http://default
    DB driver        : mysql
    DB hostname      : 127.0.0.1
    DB port          :
    DB username      : ----
    DB name          : ----
    Database         : Connected
    Drupal bootstrap : Successful
    Default theme    : - - - -
    Admin theme      : seven
    PHP binary       : /usr/local/Cellar/php@7.3/7.3.27_1/bin/php
    PHP config       : /usr/local/etc/php/7.3/php.ini
    PHP OS           : Darwin
    Drush script     : /usr/local/bin/drush
    Drush version    : 10.4.0
    Drush temp       : /tmp
    Drush configs    : ----
    Install profile  : standard
    Drupal root      : ----
    Site path        : sites/default
    Files, Public    : sites/default/files
    Files, Private   : sites/default/files/private
    Files, Temp      : /tmp

When I run drush cr, it fails.

PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Drupal\hal\Normalizer\ContentEntityNormalizer::__construct(), 3 passed in /web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 257 and exactly 5 expected in /web/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php:57
Stack trace:
#0 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(257): Drupal\hal\Normalizer\ContentEntityNormalizer->__construct(Object(Drupal\hal\LinkManager\LinkManager), Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Extension\ModuleHandler))
#1 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(447): Drupal\Component\DependencyInjection\Container->createService(Array, 'private__...')
#2 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(460): Drupal\Component\DependencyInjection\Container->resolve in /web/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php on line 57
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Drupal\hal\Normalizer\ContentEntityNormalizer::__construct(), 3 passed in /web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 257 and exactly 5 expected in /web/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php:57
Stack trace:
#0 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(257): Drupal\hal\Normalizer\ContentEntityNormalizer->__construct(Object(Drupal\hal\LinkManager\LinkManager), Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Extension\ModuleHandler))
#1 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(447): Drupal\Component\DependencyInjection\Container->createService(Array, 'private__...')
#2 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(460): Drupal\Component\DependencyInjection\Container->resolve in /web/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php on line 57

Then I run drush updb (which is doomed). locale_update_9101 runs, but the Hal module post-update returns this error.

ArgumentCountError: Too few arguments to function Drupal\hal\Normalizer\ContentEntityNormalizer::__construct(), 3 passed and exactly 5 expected in Drupal\hal\Normalizer\ContentEntityNormalizer->__construct() (line 57 of /web/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php)
#0 [internal function]: Drupal\hal\Normalizer\ContentEntityNormalizer->__construct(Object(Drupal\hal\LinkManager\LinkManager), Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Extension\ModuleHandler))

The front page in the browser shows the same.
The container is not created. How do I debug this?


texts: How to show all subterm nodes of a parent term with the simple_hierarchical_select module?

texts:
I use drupal 7 and simple_hierarchical_select module.

I have a vocabulary called "news group" that has two level term (parent term and subterm) like the attached picture:

When I use exposed filter and simple hierarchical select for this (select term reference filed for "news group vocabulary") views filters show me two select list.first level list show parent terms (like HSE) and when select any option from first select list another select list appear that contain subterms of this parent term (like 5 subterm of HSE term) So I must select a option from Secound select list (subterms)  to have any result for my view.

I want to filter views results by first level (parent term) of taxonomy (like HSE) . But the Simple_hierarchical_select module Does not support first level of terms.must select deepest term for result.

I am not selected "force use to select deepest level" in field settings of term reference field.

Is any way to force SHS module to filter all subterms of a parent term?  Is another module for add "select all subterms of a term" feature to views exposed filter?


texts: When page is not node entity site breaks

texts:
How can correct this, my problem is that I'm using node label to set class. And everything works perfectly until I visit contact form or user login form which are not node entities, then site completely breaks, only on that two pages. How can I make some condition if it's not node or its contact form?

  if ($vars['node']->getType('location')) {
    $node = \Drupal::routeMatch()->getParameter('node');
    $title = $node->label();
    $vars['location'] = str_replace(' ', '-', strtolower($title));
  }


texts: Restrict access of (an) individual comment(s) to (a) certain user(s)

texts:
So, there are a lot of modules (and Drupal-Answers posts discussing them) to restrict access of certain node types / individual nodes to individual users, and it can be a pretty hard task to know which 1 might be best, according to your needs.

Now, something else: is there a possibility to restrict access of individual comments to individual users?

Would this be possible with the module Block Access? (Since they state to be able to change:)

  permissions at the individual block level

Perhaps, if there would be a module; restricting node access to individual users; that can also restrict access to comments, then perhaps the choice of an access-restriction-module could be easier for people interested in this feature.


texts: How to display on UI the CLI output on the remote server

texts:
My custom Drupal module connects to remote server through SSH and executes several commands there. I don't want to keep Drupal user left completely blank during the process.

As the last resort, I will have to use some kind of pseudo-progress bar, however ideally I'd prefer to show the progress that is going on the remote server's CLI.

I wonder is there any way Drupal could display output of the things that are taking place in (local or remote doesn't matter in fact) server's CLI?


texts:
I am using following code to build the select box for Month and year

$form['billing']['expiry_db'] = array(
    '#type' => 'date_select',
    '#title' => t('Expiry Date'),
    '#default_value' => date('m Y'),
    '#date_format' => 'm Y',
    '#date_label_position' => 'within',
    '#date_year_range' => '0:+20',
    '#required' => TRUE,
    '#prefix' => '<div class="field-wrapper-w1">'
);

I am passing following value in database

$form_state['values']['billing']['expiry_db']['month']

and

$form_state['values']['billing']['expiry_db']['year']

but it is only showing value '2' for month and value '2' for year. However I am selecting month 'December' which has value '12' in HTML. Please help


texts: Ajax replaced elements not available in form submit callback

texts:
I have some elements in a form as below:

$form['provider'] = array(
    '#type' => 'select',
    '#title' => t('Provider'),
    '#required' => TRUE,
    '#options' => $some_options,
    '#ajax' => array(
        'callback' => 'my_callback_func',
         'wrapper' => 'tests-div',
         'method' => 'replace',
         'effect' => 'fade',
     ),
);

$form['tests'] = array(
    '#type' => 'select',
    '#title' => t('Tests'),
    '#required' => TRUE,
    '#prefix' => '
',
    '#suffix' => '
',
    '#options' => array(''),
    '#validated' => TRUE,
 );

When the provider select box value is changed, the callback my_callback_func checks the chosen value of the select box, and returns a modified version of tests select box with some new options set.

function my_callback_func($form, &$form_state) {

    [snipped code which reads form data and calculates $some_new_opts ]

    $form['tests'] = array(
          '#type' => 'select',
          '#title' => t('Tests'),
          '#required' => TRUE,
          '#prefix' => '
',
          '#suffix' => '
',
          '#options' => $some_new_opts,
          '#validated' => TRUE,
    );

    return $form['tests'];
}

So far so good - when I change the value of the provider select I can see the Ajax event firing, the new options appear in the tests checkbox and I can select from them. But then when I submit the form using

$form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'go for it',
    '#submit' => array('my_post_submit_function'),
 );

none of the Ajax supplied values are visible in either form or form_state within my_post_submit_function. Instead, the original value (the empty array) is always shown in $form['tests']['#options'], and $form_state['values']['tests'] is null ("").

What am I doing wrong ?

Updated 4th Sept

I'm still trying to solve this problem.
I've looked in a debugger at what happens when I click the submit button.

index.php and menu.inc direct control to form.inc, where drupal_get_form makes a call to drupal_build_form.

At this point $form_state seems to be being reconstructed from somewhere (the cache_form table?) as it certainly doesn't contain the settings I made to it during my earlier processing. (for e.g. I set $form_state['foo'] = "bar"; which has now disappeared.)

Does anybody know how this works in more detail? Does form caching mean that it's impossible to submit Ajax-modified data to the submit handler?


texts:
I'm struggling with view results. This is the first time I've ever posted on one of these! I set up a view to filter responses from a survey on a webform. The responses are supposed to show up if one required question is marked true. The other filters are exposed.

The problem is that the results do not show up correctly. Two of the results are included twice, and after a certain date, none of the results are included. Can anyone help? Thank you!


texts:
My programming skills are really not up there.

I'm trying to load a module, and whatever instructions in there, only when a node ID is viewed.

I think I need to use hook node_load.

In other words, if Node ID of type webform is being viewed, load the following instructions from enabled custom module.


texts: Fetching more than id's of an entity using EntityFieldQuery

texts:
I have just learnt how to use the EntityFieldQuery to make simple queries.

In the example below I fetch all the comment id's for the logged-in-user.

global $user;

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'comment')
->propertyCondition('uid', $user->uid)
->addMetaData('account', user_load(1));
$result = $query->execute();
var_dump($result);
$cids = array();
if (isset($result['comment']))
$cids = array_keys($result['comment']);

  Is it possible to get the comment body and the node id where that
  comment belongs using the way i use above?


texts: Multisite Installation (Attempt) Goes To My Main Site

texts:
I am attempting to perform a multisite installation. My main (presently working) site is located in a subdirectory called "beta" of my ~/public_html folder. This is the site for jackstahlco.com and it is working. I also want to have this installation of Drupal run two other sites.

The first other site I am trying to get to work is meadowlarknm.com. This site is presently resolving to jackstahlco.com, which is NOT correct. I created ~/public_html/beta/sites/meadowlarknm.com/ and ~/public_html/beta/sites/meadowlarknm.com/files. I copied default.settings.php into meadowlardnm.com/ and changed the permissions, as well as creating a 'files' directory. The settings.php also contains

$databases = array ();

and no other database configuration.

When I navigate to www.meadowlarknm.com, I just see the www.jackstahlco.com website, instead of the Drupal installation screen that I expect. You can go there to see what I'm talking about, unless I fix this problem immediately after writing this question.

I am suspecting that this may be a .htaccess issue, but I am not sure. It's a little bit weird that I am trying to run multi-site from a subdirectory, but it seems like this should be possible (if my understanding was complete.)

Here is my .htaccess (inside ~/public_html, I did NOT change the .htaccess inside ~/public_html/beta):

########## End - Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

# RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.jackstahlco\.com$ [NC]
RewriteRule .* http://www.jackstahlco.com/      [L,R=301]
RewriteRule ^$ beta/index.php   [L]
RewriteCond %{DOCUMENT_ROOT}/beta%{REQUEST_URI} -f
RewriteRule .* beta/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* beta/index.php?q=$0 [QSA]
#
#RewriteCond %{HTTP_HOST} ^(www.)?jackstahlco.com$ [NC]
#RewriteRule ^(/)?$ /beta/$1 [L]

RewriteCond %{HTTP_HOST} ^(www.)?jackstahlcompany.com/puertadelsolsite$
RewriteRule ^(/)?$ puertadelsolsite [L]

RewriteCond %{HTTP_HOST} ^meadowlarknm\.com$ [NC]
RewriteRule ^(.*)$ http://www.meadowlarknm.com/$1 [L,R=301]

########## Begin - Joomla! core SEF Section
#
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !^/index.php
#RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
#RewriteRule (.*) index.php
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
<IfModule mod_suphp.c>
 suPHP_ConfigPath /home/jsco
 <Files php.ini>
   order allow,deny
   deny from all
 </Files>
</IfModule>

Additionally, the following is in /home/jsco/public_html/beta/sites/sites.php:

  $sites = array(
   'www.jackstahlco.com' => 'default',
   'www.meadowlarknm.com' => 'meadowlarknm.com',
  );

The end goal here is to re-do the existing sites on this server (some Joomla! as you may have guessed from the .htaccess) to a single Drupal system running multisite.

I don't believe this is a DNS issue. nslookup says these are all going to the correct place, and my domain-to-folder mapping on cPanel (sending everything to ~/public_html) looks OK.

Additionally, the multisite wizard says MOST of my steps are OK.

OK Create sites/sites.php file
OK Fill up sites/sites.php file with domain-folder array
OK Create sites folders inside sites/ folder
OK Each site folder should have own settings.php file
NOT OK - Prefix inside each settings.php file should be unique. I think I want a different DB

Thank you very much for the help.

-Brian J. Stinar-


texts: How to disallow users from changing their emails?

texts:
I need this because it makes life a bit more difficult for 'professional' spammers who just change their emails after logging in, so that the can use that very email for the next registration, after being blocked.

Appreciate your hints.


texts:
With this callback code - is it possible to restrict url just to be example/page1 (2 arg) but not example/page1/321 or example/page1/abc/efg...?

// hook_menu example
function example_menu() {
 $items['example/page1'] = array(
'page callback'     => 'example_page1_callback',
'access callback'   => TRUE,
'type'              => MENU_CALLBACK,
 );
 return $items;
  }

 // hook_meny callback function
function example_page1_callback() {
 // please provide code within this function to turn these next three
  // variables into separate output variables for the template.
  $variable_to_print1 = 'Foo';
  $variable_to_print2 = 'Bar';
  $variable_to_print3 = array('bing', 'bang', 'bong');
  return;
 }


texts: view content filtered by taxonomy children

texts:
I`m having a view block displayed on node page. In this block i want to show only other nodes that have the same child taxonomy selected.

I tried with contextual Content: Has taxonomy term ID (with depth)

and those settings and is not working https://www.screencast.com/t/b8GJftJSanwA

The taxonomy looks like this

parent term1
- term1
- term2

parent term2
- term3
- term4

And on node are selects both parent and child.

Any ideas?


texts:
I am relatively new to Drupal, so I apologize in advanced if my question is confusing.

I am building a school website that will have a parent district site and then school websites within the district. I want to have give the teachers permission to only edit their own respective sites as well.

I feel like I could do this easier with D7 but I want to be future proof so I am attempting this with D8.

Are there any methods I could try to achieve this?


texts: too many arguments error after updating drush to latest dev

texts:
I am getting the following error when I try to run any command in drush.

Error in argument 1, char 2: option not found r
/home6/whereisa/.composer/vendor/bin/drush: line 124: [: too many arguments

This started happening after i upgraded to the latest drush (7.x.dev).  all 6.x versions of drush work fine
I am running php 5.4 on bluehost shared web hosting.

Please advise

Regards,
Ash


texts: How can I customize the way my taxonomy terms are displaying?

texts:
I have been searching all over the place for some help on this.

I currently have my tags displaying for each node like such: tag,tag,tag

Now I would like them to display a little cleaner and more appealing to my visitors. So what I would like to do is have them display like such: tag \ tag \ tag

Now from what I have read, I need to target the field API? and use a preprocess function to alter what the array is spiting out? Please correct me if I am wrong.

This seems like an easy task to complete but I just can't seem to find a solution.

Thanks in advance


texts: How exactly does a View Preview differ from what is rendered on a page/block?

texts:
There are a number of questions relating to this issue. I'm interested in a general explanation so I can troubleshoot why my complex (contextual filters, relationships, etc) view preview would be working as expected while the view block shows different results.

What exactly is being run for the preview compared to the normal display of the view? What happens 'after' the preview, or are these different paths/processes/methods/hooks altogether?


texts: Trying to rewrite url for a custom module with an extra custom variable using PathAuto

texts:
I needed to create a custom module to show product information. It's a custom module because the data comes from a remote database. This module has a block which I add to a basic page.
(It was my first drupal website from some time ago, and I know it's not the conventional method.)

Now in this module I do a $_get call from a product id in the url. For example if the page is /product?id=50, it will get the product of id 50 and show that information in the block.
Now at request of the client the url needs to look like /product/50 for SEO reasons. Also true for categories for example categories/boots instead of categories/category=boots

I tried using http access file but I can't get it to work. Also see: Drupal does rewrite url but can't load css/themes

Now they suggested to use Pathauto module. So I've installed the module. But it won't create those url's taking the custom variables into account.
Is there a way so I make Pathauto take into account those extra variables needed for my $_get? Or is there a better method?

I've never used this module before, so noob proof advise is appreciated.


texts: Any solutions for announcing policy changes?

texts:
We want a slide-up notification to announce a change to the terms of use on our site, only shown 1x/user.

Is there any way to do this? Or would it be better to use a block and some custom js to do the user-limitation?


texts: Edit user - Check what is selected in "list" field

texts:
On user edit page, i have a "list" field where user can choose is it male or female.

I need to check whether user choosed Male or Female..

Is it possible to check what user have choosen?

Thank you!


texts: How do I add menu-entry to the admin menu with node reference?

texts:
Task:
I want to add an edit option in the admin menu that would only appear while viewing a node while logged in as admin.
The link of the edit item can be like node\%\edit so that clicking on the link would take the user to its edit page.


texts: How to disable stripping tags for View header?

texts:
I have created an view and set its header to:

    Filters
    <select><option value="Select filter" disabled default">Select filter</option></select>

But when I access it (via block created from view and placed anywhere on website) I get:

    Filters
    Select filter

So how to prevent Drupal 8 from stripping those form tags?


texts: Pages intermittently or randomly end up in 404

texts:
My drupal website is running on acquia cloud behind cloudflare. And there are there levels of cache avaialble.

Cloudflare
Acquia Varnish
Drupal cache

All these caches are set to expire after 5 mins. Now some Drupal basic pages intermittently end up in 404 (though it happens once a month, but it is continuously happening) and they don't show up again until we clear cloud-flare and varnish cache and sometime Drupal cache even though the cache expire time is set to 5 mins.
I have tried to stitch down various logs available for one single request that started the 404 status code for one of the page.
Apache Log
52.87.163.150 - - [16/Jun/2020:08:20:01 +0000] "GET /local-resources HTTP/1.1" 404 16153 "-" "curl/7.58.0" vhost=exp.prod.acquia-sites.com host=www.example.org hosting_site=exp pid=27277 request_time=397436 forwarded_for="52.87.163.150, 173.245.54.240" request_id="v-2cb707ec-afaa-11ea-9f04-07a6ece75a44" location="-"

Drupal request log
[16/Jun/2020:08:20:02 +0000] www.example.org GET /local-resources http_code=404 query= uid=0 php_pid=32196 php_time=0.379 queue_wait=0 request_id="v-2cb707ec-afaa-11ea-9f04-07a6ece75a44"

Drupal watchdog log
Jun 16 08:20:01 ded-30946 exp[32196]: https://www.example.org|1592295601|page not found|173.245.54.240|https://www.example.org/local-resources||0||/local-resources request_id="v-2cb707ec-afaa-11ea-9f04-07a6ece75a44"

FPM access log
Jun 16 08:20:01 ded-30946 exp[32196]: https://www.example.org|1592295601|page not found|173.245.54.240|https://www.example.org/local-resources||0||/local-resources request_id="v-2cb707ec-afaa-11ea-9f04-07a6ece75a44"

Now I am looking for answers to these questions:

why Drupal application through 404 status code for these pages at first place.
why varnish cache don't refresh new version of page after 300 seconds

Thanks and looking forward.


texts: How to configure fivestar's star set in Drupal 7?

texts: The FiveStar module says the star set is configurable, but where can one select the star set in Drupal 7? I have searched, but could not find the proper page. (I am still new to Drupal).


texts: receiving incorrect url from amazon s3 module

texts:
I am using drupal 7. I have installed amazon s3 module and its dependencies. I have created a bucket for saving my files on amazon server. Everything went good.. But when i try to get the path for the file it looks like this

http://bucketname.s3.amazonaws.com/abc.pdf

Later i came to know the actual path must look like
https://s3.amazonaws.com/bucketname/abc.pdf

As a result i am unable to access the pdf. It always shows access Denied as a response.

Please help me to over come this.


texts: How to restrict access to files to files of a node while keeping the node itself viewable?

texts:
I'm writing a module that allows users to configure special access restrictions on nodes to reflect academic publishing agreements (called 'embargoes'), which are stored in a custom config entity that points to a node and describes what types of access restrictions should be applied, and who is exempt (users, roles, IP ranges, etc). One of the requirements for the module is that users should be able to restrict access to the entire node (a "node embargo"), OR just the files on the node (a 'file embargo') so that the node itself is accessible and shows up in searches, but the files associated with it are not accessible.

I have implemented the 'node embargo' portion of the module using hook_node_access and checking a custom service to determine if the user should see the node or not, and returning \Drupal\Core\Access\AccessResult::forbidden() if they shouldn't. This works exactly as desired, and not only blocks access to viewing the node, but also access to the files associated with the node.

function embargoes_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account) {
  $nid = $node->id();
  $ip = \Drupal::request()->getClientIp();
  $embargoes = \Drupal::service('embargoes.embargoes')->getActiveNodeEmbargoesByNode($nid, $ip, $account);
  if (!empty($embargoes)) {
    $access = \Drupal\Core\Access\AccessResult::forbidden();
  }
  else {
    $access = \Drupal\Core\Access\AccessResult::neutral();
  }
  return $access;
}

What I cannot figure out how to do is implement the "file embargoes" in which the node is still viewable but the files are not. Since the private files are no longer accessible when hook_node_access returns \Drupal\Core\Access\AccessResult::forbidden() on the node they belong to, there must be some system in Drupal that is checking to see what node the files belong too. If I could figure out how to access that I might be able to use hook_file_download and check the node the file belongs to and see if the file should be accessible or not; in fact I already have a function in my custom service that does exactly this, but it needs a node ID in order to see what embargoes exist for the node.

Does anyone know how to do this? What is Drupal doing when a private file is accessed to see if the associated node is accessible or not?


texts: Module WYSIWYG with the 4.4.7 Ckeditor library stopped working

texts:
What I got in Drupal 7:

WYSIWYG module 7.x-2.2

CKEditor library 4.4.7.3a35b3d

Changes I made:

1. This get's ckeditor library to work with WYSIWYG:

In .../modules/wysiwyg/editors/ckeditor.inc change line from function wysiwyg_ckeditor_version($editor)

if (preg_match('@version:\'(?:CKEditor )?([\d\.]+)(?:.+revision:\'([\d]+))?@', $line, $version)) {

to

if (preg_match('@version:\"(?:CKEditor )?([\d\.]+)(?:.+revision:\"([\d]+))?@', $line, $version)) {

This changes version number search from single quotes version: '4.0' to double quotes version "4.0"

This changed error in console log about jquery version.

2. In .. Wysywig .../modules/wysiwyg/wysiwyg.js change function

$('.wysiwyg', context).once('wysiwyg', function () {

to

 $('.wysiwyg:not(.processed)', context).addClass('processed').each(function() {
       if (!this.id || typeof Drupal.settings.wysiwyg.triggers[this.id] === 'undefined') {
         return;
       }

3. Iv'e cleared caches.

4. Added Full HTML format to /admin/config/content/formats

5. Added buttons at /admin/config/content/wysiwyg

6. Tried to "downgrade" to the 3.6.x version of CKEditor

7. Tried Ckeditor module https://www.drupal.org/project/ckeditor without wysiwyg module

8. Tired TinyMc library with wysiwyg

9. !Solution! need lines of kode at sites/all/templates/html.tpl.php to load wysiwyg.js .:

<?php print $page_top; ?>
<?php print $page; ?>
<?php print $page_bottom; ?>


texts: How to add a term ALIAS(!) to content URL pattern?

texts:
I have latest Panopoly distribution installed (with Drupal 7).

What I need:

my content items of a certain content type to have the f-g URL:

"vocab term URL alias"/"Node-title"

(first part of the URL should be term alias(!), not the term name as I have my term names in Cyrillic).

What I did:

created the vocabulary with Terms
added the term field to the content type

What I managed to get:

I have a nice URL of that type: "term name"/"node-title". But I need
the term alias instead of term name.

I have looked for the answer but no dice so far.

Thank you in advance.


texts: Drupal 7: entity field as single/multivalued based on content type

texts:
I have a 'gender' entity(taxonomy) field.

I want to use it as single valued for content type X and multi-valued for content type Z in Drupal 7?

Is there any other work around to achieve this functionality?


texts:
My site is installed in a sub-directory:

http://example.com/cms

When I define trusted_host_patterns, the following is OK:

$settings['trusted_host_patterns'] = array(
  '^example\.com$',
);

However, I cannot enforce the host pattern with a sub-directory, i.e.:

$settings['trusted_host_patterns'] = array(
  '^example\.com/cms$',
);

Does trusted_host_patterns support sub-directories?


texts:
How do I change the date format of a date field in WEBFORM?

I have enabled popup calendar for this field, and when I select a date from the calendar, the default format is in Y-m-d  which I want to change it to d-m-Y.

I do not see any configuration available in date field edit page.

Under configuration -> Date and time -> Short date type has the format "d M Y", I have tried updating this to d-m-Y but with no lock!

Help! Screenshots attached:


texts: Extending EntityFieldQuery's method finishQuery doesn't work as supposed

texts:
Extending EntityFieldQuery's method finishQuery with the following code causes query return nothing:

class ClientEntityFieldQuery extends EntityFieldQuery {

  public function finishQuery($select_query, $id_key = 'entity_id') {
    $select_query->leftJoin('field_data_field_date', 'o', 'client_event.eid = o.entity_id');
    $or = db_or()
      ->condition('o.field_date_value', time(), '<')
      ->isNull('o.field_date_value');
    $select_query->condition($or);

    // Call parent method
    parent::finishQuery($select_query, $id_key);
  }
}

But when I copy the contents of finishQuery to the extended class (see below), the query works fine. So why does it not work when altering $select_query in the extended class and then calling parent::finishQuery($select_query, $id_key)?

This works:

class ClientEntityFieldQuery extends EntityFieldQuery {

  public function finishQuery($select_query, $id_key = 'entity_id') {
    $select_query->leftJoin('field_data_field_date', 'o', 'client_event.eid = o.entity_id');
      $or = db_or()
        ->condition('o.field_date_value', time(), '<')
        ->isNull('o.field_date_value');
    $select_query->condition($or);

    // This is copypaste from EntityFieldQuery's method finishQuery
    foreach ($this->tags as $tag) {
      $select_query->addTag($tag);
    }
    foreach ($this->metaData as $key => $object) {
      $select_query->addMetaData($key, $object);
    }
    $select_query->addMetaData('entity_field_query', $this);
    if ($this->range) {
      $select_query->range($this->range['start'], $this->range['length']);
    }
    if ($this->count) {
      return $select_query->countQuery()->execute()->fetchField();
    }
    $return = array();
    foreach ($select_query->execute() as $partial_entity) {
      $bundle = isset($partial_entity->bundle) ? $partial_entity->bundle : NULL;
      $entity = entity_create_stub_entity($partial_entity->entity_type, array($partial_entity->entity_id, $partial_entity->revision_id, $bundle));
      $return[$partial_entity->entity_type][$partial_entity->$id_key] = $entity;
      $this->ordered_results[] = $partial_entity;
    }
    return $return;
  }

}


texts:
My users always skip adding the "description" to the file field because they can. I tried implementing the code posted here:

How do I make Drupal File Description Field Required?

(and thank you) -- but I have a question. My users now do see a red asterisk suggesting that the description is required ... but if they do not enter a description, they may still click save and create the node ... with no description entered in the box. Any ideas on how to get this to really force the issue and require the description?


texts:
I'm using Drupal 7, CKEditor (not wysiwyg module). By default the nodes are not paginated but the client wants to have nodes of certain content-type to be paginated. And wants control of this pagination i.e. set page breaks.

How can I make the nodes to paged? And how can I control it?

P.S. I cannot find any  useful explanation (tutorial) of how drupal pager works, so if you know any, it's highly appreciated to post it here.


texts: Getting pages defined by taxonomy to display in a view

texts:
I have a page view that displays video thumbnails in a grid layout (three columns.) Above each thumbnail is the title of the video and below it is the category. The category is defined by taxonomy and selected by the user when he uploads his video.

The overall view (all videos regardless of their category - ex: /videos/all) displays nicely in a page view (no taxonomy term involved here.)

The display problem arises when a user selects a category. Although the items belonging to that category are properly filtered, I cannot get a view (ex: videos/movies) to display them in the same manner as the overall view (three columns.) I get instead the node teaser layout (thumbnails in one column with a "read more" link below each. A page view with the same path as the corresponding taxonomy term (ex: videos/movies) does not take control of the display.

How can I solve this and have all category views display like the videos/all page? Display Suite does not "see" the videos/movies page created by taxonomy.

Any and all help will be greatly appreciated. Thank you. :)


texts: A Product Page with dynamic variants without using Commerce

texts:
I have a page that is product page for an offline product. This product will never be sold through the website, so the Commerce module would be serious overkill I think. There are some features of the the product pages I've seen possible in Commerce that I need though. Like product colors.

For what I'm working on, the product model has different builds, (see the wireframe image) and each build has different color options. I need to be able to toggle back and for between color options for a build, and build options for the model.

I would like the model to be all one content type. There are common elements in the model that should stay the same no matter what the build, but items that are build specific that should update when a build is clicked. I'm  still trying to figure out the best way to structure the content type fields and such too.

I'm sure someone has had a similar need and I'm looking for tips in the right direction for the content type and the display. Since everything is part of the same content type, I figured I'd use a specific layout and use Panels to stitch it together, especially since I have related content to the model below the product.

Here are my direct questions:
How would I go about segmenting the different build levels in the same content type?

What would be the best way to pull all this back into a display and have the right areas work to allow the large image of the product be able to be switched when the color links are actioned and then have all the right parts change when a different build is selected?


texts:
I have a small module that basically contains a controller and a block plugin. I cannot figure out how to include a class in both of them

The files are located in sites/all/modules/my_module. That directory contais

$ ls -R
.:
config/  my_module.info.yml       my_module.links.menu.yml  src/
css/     my_module.libraries.yml  my_module.routing.yml

./config:
install/

./config/install:
my_module.settings.yml

./css:
hello_block-layout.css

./src:
Controller/  Plugin/  Utils.php

./src/Controller:
MyController.php*

./src/Plugin:
Block/

./src/Plugin/Block:
MyBlock.php

The problem is the namespaces:
MyController.php has namespace Drupal\my_module\Controller and
MyBlock.php has namespace Drupal\my_module\Plugin\Block

I can use the class definition in Utils.php for one of the two, if I insert a require_once in the file (with the whole path, use of .. seems not to be working) AND I use the same namespace in it.

So if MyController.php starts with

<?php
namespace Drupal\my_module\Controller;
use Drupal\Core\Controller\ControllerBase;

require_once '/home/rdgon/public_html/sites/all/modules/my_module/src/Utils.php';

and MyBlock.php starts with

<?php
namespace Drupal\my_module\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;

require_once '/home/rdgon/public_html/sites/all/modules/my_module/src/Utils.php';

and Utils.php starts with

<?php
namespace Drupal\my_module\Controller;

then the class is used by correctly by the controller. But then MyBlock.php complains about not finding the class, because the namespaces don't match.

My question: is it possible to share (include) a class definition by several components of a module? What location should I use for the shared code and what is the proper way to include it? (using the full path of the file cannot be the way to go)

thanks in advance, Ruud


texts: How to handle separated stock for a product bundle?

texts:
Following the scenario that I want implement in my store. There are three products: A, B, C. My purpose is to sell two bundle composed by AB and BC.
Each product has its stock: A x10, Bx5, Cx20. The bundle products are dependable by the stock of every single product so it will not possible to order more than 5 AB product (or BC product) because every time a bundle product is bought the stock of every single must descrease.

When a single product's stock runs out, every bundle product composed by that single product can't be sold.

Is there any way to achieve my purpose?


texts: How to change the default date format in Rules?

texts:
I've created a rule to send an html email which contains a date, printed using tokens as [commerce-order:field_delivery_date]. In email, the date looks like 2016-07-08 00:00:00 to 2016-08-02 00:00:00. The date may or may not be an interval.

How can I alter the date format in Rules?

I know that I can use something like [commerce-order:field-delivery-date:value:custom:j m] - [commerce-order:field-delivery-date:value2:custom:j m Y] which outputs 08.07 - 02.08.2016.

But, I don't always have an interval, I can only have the start date, which should be printed as 08.07.2016.


texts: How to configure trusted patterns for localhost:8082/d8multisite.com?

texts:
I have my drupal site running on localhost:8012. My url looks something like this : localhost:8012/d8multisite.com/ . I tried the following for enabling trusted_host_patterns.
$settings['trusted_host_patterns'] = array(
  '^d8multisite/.com$',
  '^localhost:8012//d8multisite/.com$',
  '^localhost/:8012//d8multisite/.com$',
  '^localhost/:8012//d8multisite/.com//$',
);

I don't have much knowledge of regular expressions. I have been following the official Drupal 8 documentation for reference. Please guide me as to where am I going wrong. Any help would be much appreciated.
Thanks.


texts:
How can I embed a view inside a user edit form depending on that user's role. I have used the Context module but it does not have the right conditions.

At the moment is uses the (user page -> User account form) condition. I cannot use the User role condition because it is for the currently logged in user.


texts: How good is the default encryption method provided by the Encrypt module?

texts:
I want to encrypt certain field values from webform submissions and will use webform_encrypt module to achieve this. This is dependant on encrypt module.

I am interested to know how satisfactory are the default encryption methods which are included with Encrypt module?

For encryption method settings, I am using the default settings as below

Mcrypt AES (CBC Mode)
Uses PHP's Mcrypt extension and AES in CBC mode. The key MUST be 16, 24, or 32 bytes.

I am also using the Base64 decode method with the key stored in a file outside the web root.

The generated key looks like this (I have changed most of the characters)

EKEIoRp+R8de2bP4JPj7Ut==

I don't know much about this stuff and I am unsure how strong this key is? It has 24 characters. Is it therefore a 24bit key?

Are any simple methods available to use a much longer key?


texts: Change all article text format to basic html

texts:
I installed Drupal 8 on my site and used migrate to migrate my old site Drupal 6 to Drupal 8.

The error message pop out.

But when total articles have been all imported to new site Drupal 8.

The content of the article is not displaying. Only title of article shown.

I checked the article, there is content there.

It needs to be change from text format FULL HTML to BASIC HTML to make it appear on the site.

I have more than 20,000 articles.
How do I do change it for all?

Is it adding the script here and press "Format"?


texts: Is there a way to load the current entity object?

texts:
Is there a way, from anywhere in drupal, to get the current entity object? I'm using the hook hook_filter_FILTER_process() and I'd like to replace things in the $text with data from the entity, but it doesn't look like there is a way to access the entity without doing something like

if (!empty(arg(0)) && is_numeric(arg(1)) {
    $entity = entity_load(arg(0), array(arg(1)));
}

This works most of the time, but sometimes (like taxonomy terms) it doesn't. On top of that, this is really messy as it makes another call to the database.

Is there a better way to do this?


texts: How to create a user1, user2 and 3 others like this post?

texts: I'm creating a website and there is a problem that I have encountered. I need to create list of posts. And each posts have a like button and shows who's liked the post exactly as in Facebook. The likes are handled by the flag module. The list of posts is in a view. What I need to do is figuring out each nid every post has in the view and pull the latest likes and the number of likes each post have.


texts: Problem with adding Views - they cannot be saved

texts: I have problem with creating new views (or clone old ones). All process is doing well, I choose my filtres etc; but when I'm trying to save it's an error - and they don't show in the views list (even if it's said that it "has been saved"). I've already tried several times but it doesn't work. I dont know why - before I didn't have this problem...


texts: How to create a simple list of links to Drupal panel pages?

texts:
I would like to create a simple HTML menu made of links to pages A, B, C created in Drupal (but not all pages, only a subset). Unfortunately, menu's in Drupal are displayed as li lists, not just a list of urls, which adds bullets to the display.

A view displayed as unformatted list would be great, but you cannot create a view of miscellaneous page links.

I could create a mini-panel and hardcode the links, but hardcoding is always a bad idea. Ideally, there should be a way to set relative links to pages and let Drupal generate absolute links.

What would be the best way to create a simple a list of links to pages created in Drupal? A block or a mini-panels are acceptable solutions.


texts: Alter custom menu links with a session variable

texts:
I've got a new problem, searched everywhere but was unable to find a solution.

I'm quite new to PHP / Drupal.

To explain :

I would like to use a session variable (got from a form) in my custom menu links, like this :

/path/{year}

So,in a module I have routes and links defined this way :

my_module.routing.yml :

testlink:
  path: '/path/{year}'
  defaults:
    _controller: '\Drupal\my_module\Controller\PageController::init'
    _title: 'Test'
    year: ''
  requirements:
    _permission: 'access content'

my_module.links.menu.yml :

testlink:
  title: 'test'
  description: 'test'
  parent: my-custom-menu
  menu_name: my-custom-menu
  route_name: testlink
  route_parameters: { year: '0000' }

Everything works fine, my menu link is displayed like this :

/path/0000

But I cannot find a way to use my session variable to replace "0000".

Any idea ?

Thanks in advance.


texts: Custom webform component for displaying a list of nodes

texts:
I would like to have a content-type with Add to cart button that would allow a user to add current node to the cart. Then there would be a webform that would list all the items (nodes) that the user added to the cart.

Can anyone give me directions on how to achieve this? I think it has something to do with creating custom webform component.


texts: adding all children node flag count to sort parent

texts:
i have created two content type parent and child. a parent has children. and each child has own flag count value. like:

under Parent A
   child1 had flag count=5
   child2 had flag count=2
   child3 had flag count=0

under Parent B
    child1 had flag count=3
    child2 had flag count=1
    child3 had flag count=0
    child4 had flag count=6.

now sort the parent according to all children's flag count value.Like here Parent B should come first because he has his children flag count value is 10..

please help me to short out this scenario...


texts:
I need to send Emails to site users with specific role like "Administrator".

This is achievable using view on any action like "After saving new content".. etc..

But i want to send emails on one menu click event, I have menu item in Management Menu of Drupal and on click of that i want to send mails to all admin users.

How this is achievable?? Please suggest me guys..

Thanks in advance..!!


texts: Unusual behavior of Shopping Cart (Drupal Commerce)

texts:
I am using Drupal Commerce for a portal & I am facing a issue which is re-producible on fresh instance as well.

Suppose if I have a account on a website and I am logged in. I add some items to my cart and leave. It will remain in my cart even if I login from another system.

But if I don't login from another system at start & click "Add to Cart", item get added to my cart with help of session. Now if I login into system, only current items are in cart, not which I have added from another system in my account.

I mean, we loose those items which were in cart before.

This behaviour I checked on some other ecommerce website as well, but they add session cart into the account cart once you login.

What can be the solution of this ?


texts: How to set Drush sql-sync not to clone users between @dev and @staging?

texts:
As I wrote in my previous question,
I am using the following drush commands to synchronize development and staging environments.

drush rsync @dev @staging
drush sql-sync @dev @staging

How to set up drush sql-sync not to clone users between @dev and @staging environments?
I would like to have separate users (and passwords) on @dev and on @staging sites.


texts: How to restore missing field from feature?

texts:
I've not removed any tables from db, but when I was trying to edit user profile I've got error about missing field from profile2 entity:

  EntityMetadataWrapperException: Unknown data property field_my_name.
  in EntityStructureWrapper->getPropertyInfo()

Indeed field is missing and db field tables too :/

Field is exported to feature. So I thought this may restore my table:

  drush fr my_feature --force -y

but don't...

I've also noticed that I have a lot of tables like field_deleted_data_[number] in db.


texts:
I have a view which presents values of specific content type, nothing special, just a normal regular view with a table display. Later on I added to it a field from views field view module. Everythink works as expected. Now I need to hide every row which has an empty value of this views field view field?

Any ideas how can I do it?

I tried to use hook_views_pre_render but in this case I can only get an access to values of fields from parent view not from the one which comes from views field view.

Any help will be appreciated!

P.S. The question applies to Drupal 8


texts: How to get in Views RESTful API non latin's letters on fields?

texts:
With this guide, I do my RESTful API view (through core modules: RESTful Web Services and Serialization). Ater go to API page, I get this JSON:

[{"title":"\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0431\u044e\u0434\u0436\u0435\u0442\u043d\u044b\u0439 \u0424\u0440\u0438\u0437 \u041c\u0430\u0433 (Freeze Mage)"}]

All \u0xxx codes — it's non english/latin letters (Russian/Ukraine in UTF-8, for example).

How to correct (readable) display in JSON response?


texts: Where to place the admin screens for a module

texts:
When developing a module with an admin-area, what are the guidelines for menu-placement?

There is admin/settings/*, admin/structure, admin/content and so forth.

From what I can see, most modules follow arbitrary guidelines and often clearly content-related pages end up in admin/settings/foobar, or pages that have little to do with the architecture of the site end up under structure.

What are rules-of-thumb? What are the guidelines?

For example, I have a module that renders a tag-cloud, and I have some settings that allow manipulating how this module renders its pages. Settings such as "what vocabularies to include" and "amount of tags to render".

From a user POV, I would expect the first setting under admin/structure yet the other one under admin/config/user-interface. But I'd rather keep them together; since I believe a user (1) installs and then (2) immediately configures this type of module, once.


texts:
I've currently got a view on a Node type (Prospects) where part of the filtering is a Contextual filter filtering a 'Sales Region' taxonomy field against a Sales Regions taxonomy field in the User. The idea is that, given a path of, e.g., /user/4/prospects, the view should only show Prospects whose (single) Sales Region term matches one of those in the Sales Regions terms for user 4. This is actually currently working quite nicely.

The problem comes in that we have just added another pair of taxonomy fields to the Prospect and User - a Company field in each. The User has one Company term, and the Prospect can have multiple. The idea is to additionally limit the Prospects shown to those who have a Company Term that matches the selected user's Company Term. The issue (which I realized when I tried to modify the view to handle this) is that I essentially need to tie the one Contextual Field (a UID) to two different Relations - one for the user's Sales Region field, and one for the Company field, but the Contextual Field UI only appears to allow tying it to one Relation. Is there actually a way to do this, or am I going to have to do something like write a custom filter to handle the additional Company filter?


texts:
how can I put logo and site name in an unordered list?
I am using a bootstrap subtheme !


texts: How to get varchar type input from users on my website?

texts:
I want to add a field to get a bank account, swift code, card no and IBAN type values from users on my Drupal 7 website.

These fields require a mix of numbers, alphabetical characters and "-".

How can I get this type of info from users?

Note: Core Text field is not sufficient to get varchar type input from users.


texts: javascript turned off - can not switch tabs

texts:
I am experiencing this problem for the first time on drupal 6 install.
http://www.biome.cz/sampon-proti-vypadavani-vlasu-revita
Here after disabling javascript, it is not possible to load other tabs. The links seems to be ok but after clicking any tab, the content remains the same, even url is changed.

Can anyone help me debugging this?
Thank you


texts: Access the field class from within FieldItemList (D8)

texts:
When I would like to get the values inserted in a form, I use:

$form_state->getValue('myfield');

If I would like to have some information on the field definition, I use:

$form_state->getFormObject()->getEntity()->myfield->getfieldDefinition();

Every time I check the class resulting from the following statement:

$form_state->getFormObject()->getEntity()->myfield

It is of the type Drupal\\Core\\Field\\FieldItemList which is fine for getting/setting the values

Suppose that "myfield" is of the type "language_field" defined in \Drupal\languagefield\Plugin\Field\FieldType\LanguageItem.

This class have a public function

public function getNativeName()

To get the full name of the language.

But My question is: how to access this function fromwithin the FieldItemList object? (Same problem arise with many other field type)

Added info:

With the help of @Eyal, I could access my object method:

$form_state->getFormObject()->getEntity()->myfield->get($delta)->getNativeName();

But this is valid only if the entity is already saved.

In the case of a new (or edited) item, the entity doesn't store the new value. Here is the code for what I am trying to explain:

The 2 variables will have the same value if I open and save the form without change, but this will not be the case if I update the item at delta=1.

function my_validate($form, FormStateInterface $form_state) {
  $val_by_entity=$form_state->getFormObject()->getEntity()->myfield->get(1)->value;
  $val_by_form_state_value=$form_state->getValue(['myfield', 1, 'value']);
}


texts: Now during order edit it is possible to apply only a fixed discount. How to to add a percent-based discount?


texts: Restrict Menu options when building Nodes

texts: Drupal 7, when creating a basic page I want the users to be able to add a menu item as a sub item only under local menu items, not under items that link off site. How can I restrict the list of menu Parent item to only ones that point to node/# and not display any that are absolute urls?


texts:
I have customized a block.tpl.php file and I want to access the individual fields in it. But when I put print render($content['field_name']) in my code nothing is printed out. And also print_r(array_keys($content)) doesn't give anything.

I have used the above codes in my page.tpl and node.tpl files successfully before.

I'm on D7.

So is it done somehow differently in block template? What's going on?


texts: How to duplicate a line item in shopping cart programmatically

texts:
At certain point in the checkout process I'd like to seperate line items with quantity more than one into individual line items with quantity 1.

So for example if I have a line item in cart with quantity 5, I'd like to create 4 new line items just like the original one, add them to the cart with quantity 1 individually.

I tried cloning the line item entity into a new variable and use commerce_line_item_save() with it, but it doesn't work.

Does anybody know how to achieve something like this from a module?

Thank you!


texts:
I'm a total newbie. I'm building a site which includes images, such as photographs, with text captions under them.

Recently (?!), some of these text captions have broken and slipped, with the first words appearing to the left of the image and the rest still below it where they should be. I've tried monkeying with the margin width, but that doesn't seem to be the problem.

Any clues?


texts: Use "Login destination" to redirect the user to a page of Views

texts:
Hi everyone.

I have a type Article page, whose alias is: /primaria/docentes/kit.

I have a type Views page, whose alias is: /primaria/docentes/kit.

When a user log, whose role is "primaria", I want to redirect it to the view: /primaria/docentes/kit, not the article: /primaria/docentes/kit. (To do this, I use the Login destination module).

If we write /primaria/docentes/kit in the browser, the page type "article" is always displayed. The view is never displayed. Drupal has a preference for display pages of content types, instead of pages made with Views.

How to redirect the user to view?

In the module "Login destination" add a rule, and use Page returned by this PHP code (experts only). I use this code:

$views_page = views_get_view('kit_docente', $reset=FALSE);
if (is_object($views_page)) {
  foreach ($views_page as $a => $b) {
    if($a == "display") {
      foreach ($b as $c => $d) {
        if ($c == "kit_docente_primaria") {
          foreach ($d as $e => $f) {
            if ($e == "display_options") {
              foreach ($f as $g => $h) {
                if ($g == "path") {
                  return $h;
                }
              }
            }
          }
        }
      }
    }
  }
}

This code works fine. But redirects the user to the article. No view of views.

Thanks in advance. :(


texts: IF statement to check if loaded entity is of type

texts:
In my module (fork of ECK Clone) I'm trying to set a default value when an entity of type "Course" is cloned.
Currently I do:
function eck_clone_clone_entity($entity, $account = FALSE) {

  $original_entity = clone $entity;

  $entity->id = NULL;

  if ($account && isset($entity->uid)) {
    $entity->uid = $account->uid;
  }

  if (isset($entity->created)) {
    $entity->created = NULL;
  }

  if (isset($entity->changed)) {
    $entity->changed = NULL;
  }

  if (isset($entity->title)) {
    $entity->title = t('Clone of !title', array('!title' => $entity->title));
  }

  $entity->status = 1;
  $entity->some_boolean = 1;
  $entity->content_status = 1164;

  $context = array('original_entity' => $original_entity);

  drupal_alter('clone_eck', $entity, $context);

  entity_save($entity->type, $entity);

  return $entity;
}

PS: some_boolean value gets set, but not the status. I wonder why.
What I need is to check if the $entity is of the type "Course".
I thought it would be as simple as wrapping it in an if statement like so:
if($type == 'course') {
    $entity->some_boolean = 0;
    $entity->content_status = 665;
    $entity->course_number = 3;
    $entity->tag_line = "some other tag line here";
  }

But that doesn't work. Any idea?
PS: some_boolean value gets set, but not the status.


texts:
I have a height field for users.

How can I make a simple filter in views where visitors can search to and from?

Like:

Search users: From 150cm To 180cm

Thanks,
Bruno


texts: Commerce License Billing: How do I charge or refund a prorated amount when the user's plan changes and the billing cycle is prepaid?

texts:
I've implemented a simple Views-based interface for upgrading and downgrading subscription plans in my Drupal Commerce store. The plans are powered by Commerce License and Commerce License Billing. I've implemented a custom license type in order to provide the option of metered billing.

I'm noticing that the default behavior of changing the plan ($license->product_id) is simply to change it and update the due amount on the next prepayment. However, it doesn't charge for the upgraded plan for the rest of the billing cycle right away. Is this something I can tell the license or the billing cycle to do, or is it something I have to handle on my own? If so, how can I properly calculate the prorated amount to charge?

The question is basically the same re. refunds, and I assume that once I know how to calculate a charge, I'd simply process a refund if the amount was negative. I guess I would have to refund some of the most recent payment...I'd actually prefer to give them a discount on their next order, but I don't know how to do that either. Because Commerce License Billing manages so much in the Order Refresh process, how to approach all this is a bit muddy for me.

Worth mentioning that I am using commerce_cardonfile and commerce_stripe.


texts: How to display respective node data after clicking its link on navigation page

texts:
Im new to Drupal. I want to display all the bundles called 'department' in the navigation link and on clicking each navigation link the respective department node will be displayed. Im not being able to display the corresponding nodes. Here's the code:

 $query = new EntityFieldQuery();
 $result = $query->entityCondition('entity_type', 'escholar')->propertyCondition('type', 'department')->execute();
 $ids = array();
 foreach($result['escholar'] as $r)
 {
   $ids[] = $r->aid;
 }
$artifacts = entity_load('escholar', $ids);
foreach($artifacts as $key => $artifact)
{
    $items['escholar/' . $artifact->aid] = array(
   'title' => $artifact->title,
   'page callback' => 'escholar_page_view',
   'page arguments' => array(1),
   'access arguments' => array('user access')
  );
}

function escholar_page_view($escholar, $view_mode = 'full') {
// Remove previously built content, if exists.
$escholar->content = array();
if ($view_mode == 'teaser') {
  $escholar->content['title'] = array(
  '#markup' => filter_xss($escholar->title),
  '#weight' => -5,
  );
 }
// Build fields content.
field_attach_prepare_view('escholar', array($escholar->aid => $escholar), $view_mode);
entity_prepare_view('escholar', array($escholar->aid => $escholar));
$escholar->content += field_attach_view('escholar', $escholar, $view_mode);
return $escholar->content;
}


texts: How to include the same block in two regions?

texts: I created a views block and have included it in the Content region for one of the pages... I would like to call the same block on a different region on the homepage. Is this possible?


texts:
I would like to use the whole tease as a link to the node. I could google (and adapted) the following code but still not working.

following line:
scripts[] = js/new_teaser.js is added in the ".info" file of my theme (Business)
and this code to the "new_teaser.js":

$(document).ready(function(){

    $(".node-teaser").click(function(){
      window.location=$(this).find("a").attr("href"); return false;
    });

    });

the class of my teaser is ".node-teaser" and the "NoScript" addin of my browser is switched off. I assumes that the problem is in the JS code.

Drupal 7, theme Business

Could someone help me please?

EDIT: as far as I can see, there is no link to the new_teaser.js file in the source code of the page... (even if the file is in the js/ folder and in the theme .info file


texts: Have Select Dropdown of Taxonomy but allow user to enter new term

texts:
Is there a way to have my Taxonomy Terms in Dropdown but also allow the user to enter a new term (Like autocomplete widget does) if they don't see their term in the select list?

So essentially I would have a backup to allow the user to create one.

My use-case is I have a bunch of businesses, when someone adds a new one, if they don't see their business type, they can just add a new one.


texts: How to delete old images uploaded via FAPI

texts:
Consider the following bit of code in my custom module... It allows a user to upload an image, saves the fid as a variable, and in a custom submit function, it makes sure that the file in the file_managed table is saved permanently.

This all works great, but when my users are uploading a file, then saving, then removing that old file and uploading another and saving, all of these files are left in the file_managed table, with a status of 1.

function MYMODULE_admin() {
  $form = array();
  $form['style']['business_logo_fid'] = array(
    '#title' => t('Business Logo'),
    '#type' => 'managed_file',
    '#description' => t('Upload a logo for your business in one of the following formats: jpg png jpeg.'),
    '#default_value' => variable_get('business_logo_fid', ''),
    '#upload_validators' => array(
    'file_validate_extensions' => array('jpg png jpeg'),
    ),
    '#upload_location' => 'public://',
  );

  $form = system_settings_form($form);
  $form['#submit'][] = 'after_save_ui';
  return $form;
}

function after_save_ui($form, &$form_state) {

    $business_logo_fid = variable_get('business_logo_fid');
    if ($business_logo_fid) {
        $business_logo = file_load($business_logo_fid);
        $business_logo->status = FILE_STATUS_PERMANENT;
        file_save($business_logo);
    }

}

How do i mark these old images as unused after a new one has been saved in its place? Is there something I can do to get the fid from the old file and mark its status as 0 before the new one gets saved? or is this something that Drupal handles already for me?