texts: Programmatically creating a new instance of a custom content entity that contains a field collection

texts:
I am trying to write a script that will create about a thousand instances of a custom content entity type I defined via a module from existing data that I have prepared. Right now I just need to figure out how to create an instance of my entity type programmatically.

This entity type contains multiple field collections. I don't understand how to structure the arguments of {entity_type}::create() to accommodate field collections.

Following the accepted answers to Programmatically create nodes and How to programmatically insert and update Field Collection values?, here is my function code so far (i have it inside hook_entity_view_alter() just for easy testing):

$food = Food::create([
    'type'  => 'food',
    'title' => 'Allspice',
    'field_category' => 'Spices'
]);
$variation = FieldCollectionItem::create([
    'field_ingredients' => 'allspice',
    'field_safe_for' => [
        'field_nut_allergies' => 'Yes',
        'field_seafood_allergies' => 'Yes',
    ]
]);
$variation->setHostEntity($food);
$food->field_variations[] = ['field_collection_item' => $variation];
$food->save();

where food is my entity type, field_variations is the ID of the field collection in food which may have unlimited values per food instance, and field_safe_for is a nested field collection.

No matter what I do, I always get this:

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

Drupal\Core\Entity\EntityStorageException: Missing bundle for entity type field_collection_item in Drupal\Core\Entity\ContentEntityStorageBase->doCreate() (line 83 of core\lib\Drupal\Core\Entity\ContentEntityStorageBase.php).
Drupal\Core\Entity\EntityStorageBase->create(Array) (Line: 509)
Drupal\Core\Entity\Entity::create(Array) (Line: 39)
food_food_view_alter(Array, Object, Object) (Line: 501)
Drupal\Core\Extension\ModuleHandler->alter(Array, Array, Object, Object) (Line: 268)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 203)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func(Array, Array) (Line: 381)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

which I do not understand in the slightest since my custom entity types don't make use of bundles.

How can I fix this?


texts: How to display specific nodes in an EVA based on common taxonomy

texts:
I am trying to display nodes in an EVA, attached to a node type that shares taxonomy.  The EVA passes the node ID to the EVA, so I have a contextual filter, but am having trouble figuring out how to filter the EVA nodes by their shared taxonomy values.  It seems like I need to create a relationship in some way, but that doesn't work.

How can I filter out the nodes in my EVA that share the same taxonomy terms of the main attached node?


texts: Drupal web cluster with memcached. memcached failover?

texts:
Running Drupal 7 sites (under Aegir) and I'm investigating a method to scale out the web boxes horizontally, so that any Apache server can process a request for any Drupal site. We're currently at ~50 Drupal sites on our platform. All sites also run through Varnish.

At the moment with our single-server setup I have memcached installed locally on the Apache box.

If we add further Apache boxes and each has their own memcached instance, it's likely that cached content in memcached will be different on each different host.
The way around this is to run memcached on our Varnish or database instance, though on our Varnish box makes most sense.

From the settings.php config I can presumably specify multiple memcached servers in the memcache_servers array:

// make MemCacheDrupal the default cache class
$conf['cache_default_class'] = 'MemCacheDrupal';

// Key Prefix: edit this for multisite use.
$conf['memcache_key_prefix'] = $databases['default']['default']['username'];

$conf['memcache_servers'] = array(
    '127.0.0.1:11211' => 'default',
);

How does Drupal choose which memcached server to use from this array?

What I'm looking for is the ability to specify a failover memcached server. So if the primary "shared" memcached instance is down, say we take our Varnish VM down for maintenance, then it starts using another cold memcached instance.

Or as an alternative is there a way for Drupal to failover to using the database cache instead of memcached?


texts: Drupal update system not detecting latest (security) releases

texts:
This morning I got e-mails about security updates and I know one of the modules, path_breadcrumb is installed on some of my sites. So I ssh into these sites, do drush pm-update --security-only and it says no updates available.

rm -rf ~/.drush/cache/download/;rm -rf /tmp/drus;drush cc drush;drush pm-update --security-only

still no security updates available. When I log into the frontend of these sites the available updates page also does not detect anything. It does list available updates that are as recent as 1 week ago. What can explain this delay?


texts: Exclude viewing of a field in a view for a content type without excluding content

texts:
I have 3 types of content (article, product, service) and a view that displays my content on a page.

In my view I added :

a title field
a description field
a content type field

How do I display all the contents in my view by excluding the display of the "content type" field only on the content type "article" (I do not want to exclude the "article" from my view, only the field) ?

I want "product" and "service" to display the "content type" field.

I do not want "article" to display the "content type"


texts: Integrating Drupal into an existing site to manage comments

texts:
I am involved in a project that wishes to post a wide range of products, and allows users to review these products. I don't want to use Drupal for the design, layout, etc. I am only interested in using Drupal for managing all of the user generated reviews. Is this integration possible, or recommended?

Could anyone please point me in the right direction for more information about the subject?


texts: Views Grid Display Images Thumbnail Sequently using jQuery

texts:
I am trying to make an image catalog using views grid. This is what I have done so far.

Created a views grid and gave the test class to each .

tr class="row-1 row-first">

Then I added my custom Javascript to my .info module file. This works since I can confirm it by viewing the page source.

These are the contents of my custom.js :

(function($){
var lis = $('.test').hide(),    i = 0;

(function displayImages() {
        lis.eq(i++).fadeIn(200, displayImages);
})();
})(jQuery);

When I open Mozilla Firefox there is no Javascript error and the effects are not working.

Please guide me to solve this problem. I am following this great tutorial.

Regards,

mbahlol

UPDATE

aha i found it. this is what i do, based on stackoverflow

(function ($) {
$(function(){
var lis = $('.test').hide(), i = 0;
(function displayImages() {
    lis.eq(i++).fadeIn(800, displayImages);
})();
})
})(jQuery);


texts: There is no register form but spams are sending register request in Drupal 7!

texts: There is no register or login form in front-page or any other pages in my website but every day I receive emails of my website that some people asked for registration, How does such a thing is possible and how do they do this?


texts: how to make a form field be required with hook form alter

texts:
I want to alter a form to make the revision log be required.
with drupal 8, I am adding this in a module

$form['revision_information']['#required'] = TRUE;

but the field does not become required.  What am I missing?


texts: How can I hook into entityforms being submitted?

texts:
I've installed entity forms. I have made a form. I would like to fire some code when a user fills out and submits the form I have created. I do not know how to do this. I don't know which hook to use, nor entirely understand how hooks work.

I've done my best to learn php and read the documentation, but I don't understand. I understand that this is likely a very simple question, I have never had any formal computer training, so even the simplest concepts allude me.


texts: Get the first instance of a field where it's not null from rows

texts:
I've got a view page, which is pulling together quite a few content types. All of these content types have a field called field_image, however some are not required and/or are missing.

I basically need to grab the first (latest - sorting by author date in my view settings) row, check if there's a field_image, if there is, we can just return that field, if not, repeat.

I thought about a few different ways of doing this, and I thought that I'd make it a Twig command for ease. My issue is that I can't seem to get the single field I'm looking for.

My Twig function is currently:

public function get_first_instance($field, $rows) {
  foreach($rows[0]['#rows'] as $row) {
    dump($row['#row']);
    exit;
  }
}

I'm running the Twig command from my views-view--my-content-type--page.html.twig template, passing a string, and rows.

I can see that the field_image is located in _entity > #fields > field_image, I'm just not sure how to reference this, or what function to use to load the entity?

Thanks for any help in advance.


texts: Can I override the title attributes on an H2 tag within a specific drupal region or block?

texts: I have a region within a site theme I'm working on, and would like the H2 title attribute to be white as opposed to the rest of the theme which calls for a blue. Can I use CSS to assign specific font size and color attributes to the title tag for that specific region/s within the theme?


texts: theme('table'...) function doesn't print the table header

texts:
I need to generate a table using theme('table',array('headers'=>$header,'rows'=>$rows));

The table is printed but with no header. This is the code: I don't see any error nor missing part for the theme function

    $header = array(
    // creating array that contains data from first cell
    array('data' => t('Header cell1')),
    // second cell
    array('data' => t('Header cell2')),
    // and third cell
    array('data' => t('Header cell3'))
  );
  // creating first row
  $rows[] = array(
    // output of first cell in 1 row
    array('data' => t('Row 1 – Cell 1')),
    // second cell
    array('data' => t('Row 1 – Cell 2')),
    // third cell
    array('data' => t('Row 1 – Cell 3'))
  );
  //second row output
  $rows[] = array(
    array('data' => t('Row 2 – Cell 1')),
    array('data' => t('Row 2 – Cell 2')),
    array('data' => t('Row 2 – Cell 3'))
  );

  echo theme('table',array('headers'=>$header,'rows'=>$rows));


texts: How to use Views with Fields Collection and filter on where used

texts:
I am using Entity Registrations to handle registrations for a sponsored walk. I have setup a fields collection so that registrants can register more than one person at a time.

At the moment there is only one Registration Entity for the 2013 sponsored walk, but in future there will be more.

So.... In views I want to create a table that allows the admin to view the fields collection related to a specific Entity Registration. i.e. Show only those users registered for the Spring 2013 sponsored  walk or just those registered for the Summer 2013 Walk.

I could duplicate my fields collection to make a new one for each Entity Registration, but I would rather avoid that type of duplication if I can help it.

Any ideas?


texts: Get user account content object loaded in node.tpl.php

texts:
By default $account->content object is loaded only on user page.

I want to print $account->content in node.tpl.php.

In user-profile.tpl.php, I tried echo "<pre>"; print_r($account); and $account->content is fully loaded.

How would I do the the same in node.tpl.php ? I tried with user_load(1); but account->content is not built.


texts: How to validate and submit a form using AJAX?

texts:
I've created a webform using the Form API. I'm using the #AJAX field option to add AJAX validation to each field.

Is it possible to validate and submit the form using AJAX without reloading the page. If validation fails I want to show an error message and if validation is successful then I want to show a message (ideally in a lightbox) and reset the form fields.

My code so far:

$form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => '',
    '#maxlength' => '128',
    '#required' => TRUE,
    '#ajax' => array(
        'callback' => '_validate_name',
        'wrapper' => 'name-error-icon-container',
        'method' => 'html',
        'effect' => 'none',
        'progress' => array(
            'message' => NULL,
        ),
    ),
);

$form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
    '#ajax' => array(
        'callback' => '_handle_form_submit',
        'effect' => 'fade',
    ),
);

callback functions look like this:

function _validate_name($form, $form_state) {

    if ($form_state['values']['name'] != '') {
    $output = 'OK';
    }
    else {
      $output = 'Enter a value';
    }

   return $output;

}

function _handle_form_submit($form, $form_state) {
}

But I'm not sure what should go in the _handle_form_submit function to validate and then either return a message or submit form and reset fields?


texts:
I would like to create multiple blocks using the data rendered from the variable table in Drupal 8. I was able to achieve it in Drupal 7, but I can't find a way to do the same in Drupal 8.

The code I use for Drupal 7 is the following.

/**
 * Create a block that will display the calendar feed
 * Implements hook_block_info
 */
function my_module_block_info() {
  $blocks = array();
  $block_urls = variable_get('my_module_content');
  $block_regions = variable_get('my_module_content_block_region');
  $number_of_blocks = count($block_urls);
  if ( $number_of_blocks > 0 ) {
    foreach ( $block_urls as $key => $block_url ) {
      $blocks['eventblock-' . $key] = array(
        'info' => t('my_module_widget_block_' . $key),
        'status' => TRUE,
        'region' => $block_regions[$key],
        'cache' => DRUPAL_NO_CACHE,
      );
    }
  }
  return $blocks;
}

/**
 * Render the my_module block
 * Implements hook_block_view
 */
function my_module_block_view($delta = '') {
  $block = array();
  $block_urls = variable_get('my_module_content' , array());
    foreach ( $block_urls as $key => $block_url ) {
      switch ($delta) {
        case 'eventblock-' . $key:
          $widgetURL= $block_urls[$key];
          $block['content'] = my_module_content_generate($widgetURL); // Some function to generate block content.
          break;
        }
    }

  return $block;
}


texts:
Hello i was hoping to create a list view that would look something like this-

FOOTBALL TEAM A
football team a link one - football team a link two - football team a link three

FOOTBALL TEAM B
football team b link one - football team b link two - football team b link three

etc etc

I have created a view and have it grouped by team. Everything works well. Its just the links below it are also vertical and not horizontal. You can view it here-
http://onlinebanter.com/football/links

Ive tried various bits of  display:inline aound the view but i just cant seem to find the place that works. Could anyone advise me please?

Thanks


texts: Views caching strategies - relationship between query cache and rendered output cache

texts:
First off, I'm trying to ensure due diligence and not duplicate questions that have come up before. There are numerous posts on stackexchange, and various other places, that discuss views caching and even some specifics about the different types of view caches (e.g., here and here). However, I've yet to find any details that sufficiently explain the relationships between different layers of views caching, and how they may impact case-specific caching decisions. For simplicity I'm also focusing the scope of this question to out-of-the box views 7.x-3.x caching options independent of other layers offered in the contrib space.

Views exposes 2 layers of time-based caching for each display, a "query results" cache and a "rendered output" cache. The specifics of what raw data each cache encompasses is clear, but the ways they interact is not. I'm specifically wondering if a hit on the rendered cache will completely bypass they query cache, or if the 2 layers operate separately. I've seen some references that claim the former (like this one), and some that claim the latter (like this one).

Theory 1 - Separate cache layers

I was initially under the impression (and hoping) that each layer is invoked separately "in series", and that the rendered output cache hashes the actual query results within its cids. This way I would have an elegant way to cache the most expensive post-query load/build work, while still ensuring that new content is immediately reflected in the view ("query results" cache off and "rendered output" cache on). Some quick tests reveal that this might not be possible though, as the rendered output cache may not be aware of the current query results.

Theory 2 - Rendered output cache "encompasses" query results cache

The other possibility is that the rendered results cache is keyed by a hash of the query itself (not the results). If this were the case, a hit on it could return the rendered output directly, without the need to consult the query cache, or DB. If this were the case then I suppose it would not make much sense to have the "query results" cache set with a time interval less-than the "rendered results" cache. The advantage of course would be that one could refresh the rendered output more frequently (if they have lots of dynamic theme logic, or frequent entity updates), while still avoiding direct queries to the DB. However, for all but the most complex view queries, this kind of separation does not seem all that advantageous.

I've done some "black box" tests that point to theory 2, but I'm not sure if there are some other settings that might be at play or if the answer differs by views version. I've also explored the code a bit, but I find it frustrating that most views' plugin methods are undocumented and occasionally hard to follow. No matter what, I think the answer to this would be useful to have as a reference for others.


texts: How to make sure that drupalSettings value gets updated on the JavaScript end?

texts:
Have an ajax callback function within which the data gets generated dynamically based on the custom input from form fields.

//ajax callback submit
$form['action'] = [
'#type' => 'button',
'#value' => $this->t('Submit'),
'#ajax' => [
'callback' => '::getData',
'wrapper' => 'table-data',
'method' => 'replaceWith',
'effect' => 'fade',
];

//ajax callback function
public function getData($form, FormStateInterface &$form_state) {
$table_data = $this->getTableData($form_state);  //getting the data dynamically
$form['section']['#attached']['drupalSettings']['table_data'] = $table_data; //assigning the data to drupalSettings
dpm($table_data); //to check if the assignment is updated
    return array($form['table_markup'],$form['section']);   //$form['table_markup'] is a markup used to display data in the table
   }

//javascript code
(function ($, Drupal, drupalSettings) {
    Drupal.behaviors.display_data = {
    attach: function (context, settings) {
        alert(drupalSettings.table_data);
        var table_data  = drupalSettings.table_data;  //inconsistency noticed in this assignment
    }
};

})(jQuery, Drupal, drupalSettings);

Now whenever I click on the submit button, the $table_data gets updated and assigned to the drupalSettings dynamically, but passing its value to the javascript seems to be behaving inconsistent, meaning the drupalSettings.table_data within javascript does not get updated but shows the previous set values.

For it to work correctly I have to reload the page, change the form inputs and submit.

I've realized it may have to do with the cache and tried to avoid it by setting the routing.yml file as below:

  options:
    no_cache: 'TRUE'

Not sure how to use cache tags here, as I do not have any tags defined
Tried to rebuild the form within the callback which didn't work either.
The form input fields does not get cleared even after reloading the page and I'm confused why this happens even after the no_cache is set to true?

Tried using 'delete' on javascript end, which didn't work either

Is there a suitable approach to make sure that the variable from drupal php, received on the javascript is always an updated one?


texts:
I've enabled the Result summary in the Header for my view... However, it is being displayed at the top of the conetnt. I would like it to be display in between the search form and the search results. Is the only way to do this via a template?

The view is made up of nodes being imported using a Feeds module.

They are displayed in a table, and there is a search on top...


texts: How do I use hook_form_alter() to add CSS classes to a custom input field in user_register_form?

texts:
I want to add a CSS class to the input element of a custom field in my user_register_form.

This is the field markup.

        Personal Best
        <input class="text-full form-text" id="edit-field-personal-best-und-0-value"
               name="field_personal_best[und][0][value]" value="" size="60" maxlength="255" type="text">

This is my implementation of hook_form_alter(), which doesn't work. Changing the submit button works, but adding a CSS class to that input element doesn't.

function em_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'user_register_form') {
    $form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
    $form['edit-field-personal-best']['#attributes']['class'][] = 'timepicker hasDatepicker';
}}

How can I achieve this?


texts: View Slideshow with different effects on the same view

texts:
I want to create a slideshow with caption using Views Slideshow.
I've set up a view with image | description fields, but everything slide at the same time. How can I set different effects for different field? Should I use different views and attach them together?


texts: Path to images not referenced correctly inside custom blocks

texts:
Let me get right into the code to demonstrate the problem.

I have created a custom block layout in /admin/structure/block/block-content with the following html content.

Now, this code works, and I am able to see the flag on the homepage, but if I navigare to other pages, I can't see the image. The html somehow renders the image if I am only browsing my index page.


texts: Replace existing content type with feature

texts:
Once upon a time a made a terrible mistake on one of the test sites by not enabling feature module but cloning database along with content types data from my local dev machine (drush sql-sync @local @test). This test site went live with feature disabled, but content type exists and has content.

Is it somehow possible to enable this feature at this stage to override existing content type and keep it's content?


texts: How can I do "Buy one get two free" with Ubercart?

texts:
For example the firs item is $3 and the second one & the third one are $0. Can I do this?
Maybe Ubercart Discounts (Alternative) can do the result but I don't want to show the discount price and just want to show the second and the third item $0 on the cart page.


texts: How to open pop up window in javascript in drupal 6?

texts:
I have made a custom module in Drupal 6 and want to implement the following: When I click on my link it should open in a pop up window in javascript. But I don't know it how to implement pop up window in Drupal.

Please help me.

This is my link code.

l('open pop up','admin/state_user/stateadmin/state/user/disable/'
  . $result -> uid, array('attributes' => array('title' => t('open pop up'))),TRUE);


texts: How to pass current loged in user id in Drupal view page settings

texts:
I am new to DRUPAL. Recently I have created a view with 3 pages. 1st page shows in the main menu .
2nd and 3rd page shows in main menu . Now I would like to display the list of the images uploaded by the user in one of that menu tab. So in order to accomplish this I have added a path like user/%/MY-images
in page settings. Now if I click this menu-tab I am not getting the user id passed in the url.

My contextual filter is working fine. Only thing I need to pass the user id through the URL.

Can anybody help me out to figure the solution.

Thanks in advance


texts: Coding a Load and delete Field Collection with Entity API

texts:
I'm trying to delete all values of a multivalued field containing a field collection. I want access with Entity API wrappers. I use this in a custom rule with hook_rules_action_info()

I'm using drupal 7.39 and field collection modules 7.x-1.0-beta8 and

I'm testing this code but doesn't work for me, this node has 2 values in field_collection

$node_wrapper = entity_metadata_wrapper('node', $node);
dpm($facWrapper->field_collection,"Field Collection");
//Prints a EntityListWrapper object
dpm($facWrapper->field_collection->count(),"Field Collection count");
//Prints zero, it should be 2
dpm($facWrapper->field_collection->value(),"Field Collection value");
//Prints array() 0 elements, it should be 2 elements
//And obviously doesn't enter into this foreach, it should enter
foreach ($facWrapper->field_collection as $fc) {
  dpm($fc,"Field collection item");
}

The questions are:

How to load or access to the field_collection in the entity wrapper way ?
When I have access, How can I delete ? I want to delete the field_collection_item and its reference in the node.


texts: fill fields in entity forms when checkbox is set

texts:
I have a entity form with some text fields.
When the user checks a checkbox the fields should be filled with his user data (name,...) from his profile.

I tried to solve this with the conditional fields module. It works partially, in that I bind a new created state and end up in Javascript. Here I can set the value of the text field, but this new value never shows up in the form.
What is the correct way of doing this?


texts: I want to override results of an autocomplete field (Entity reference in a content)

texts:
I have a content type Intertainment and i made a reference of a view(entity referene).

I used inline entity form complex widget in manage form display the entity reference and i checked "Allow users to add existing jeux".

When i add/edit the entity reference field of type Intertainment ,  when i click "ajouter une jeu existant - or add jeu existant."

=> Results of autocomplete are when i taped something its give all titles of references entities like this :
test taxo 1

My need is to override the array results of autocomplete of inline entity form module and i don't want to add a new widget.

Example add type of content in the key of result array of autocomplete.

=> What i want to make :


texts:
So I have installed the latest Drupal 7 stable on my new server, and it asks for an FTP user/password every time I try to install a new module from a .zip file. (Or using an URL).

The problem is that I don't have an FTP installed on the machine, and I don't really want to install one. I'm pretty sure this is related to some configuration/permission, but I'm not sure where to start. Tried searching around about the question, but only found "random" answers. Nothing clean and/or official.


texts: set min - max values drupal date_popup timepicker

texts:
Is it possible to set the minimum and maximum values of the timepicker in a date_popup field? I use this code for the field, but something like 'minTime' is not working.

  $form['fetch_date'] = array(
    '#type' => 'date_popup',
    '#description' => t('Datum waarop u uw bestelling wil ophalen.'),
    '#required' => TRUE,
    '#title' => 'Afhaal Datum',
    '#datepicker_options' => array(
      'minDate' => 0,
    ),
  );


texts:
I'm installing Drupal Commerce on a Vardot installation and I get the following error.

  Address requires the commerceguys/addressing library.

There is a solution for this on
How to install the commerceguys libraries for Drupal Commerce 2.x? but it requires Composer and I don't want it.

How do I install the dependencies without Composer?


texts: Content moderation - workflows / weird behavior

texts:
I have set a content moderation workflows for my content type : Draft and Published states.
Pretty basic, i create a content in Draft which is not published, i can change the moderation_state to Published to published it.
But when i do the following workflows : Draft -> Published -> Draft again, the content is still published. Is it a normal behavior ?
My core version is 8.8.3.


texts:
My site uses the Domain and OG modules.

I created the following content types: Group and  Group Post. I added OG visible field on Group, and OG content visible field on Group Post. Then, I created a group node, set the visibility as private. I created a group post node, and set the visibility as private.

I log out, and verified that anonymous users can see both.

I tried to build a new site with Drupal, and OG. When I follow the above steps, the result is right: Anonymous users can't see the two nodes.

I googled the issue, and found Visibility Access issue and Domain Access.

It seemed that the Domain and OG modules can't work together.

Does anyone have any solution?


texts: Displaying follow up fields for a content type

texts:
I have a form that asks the user to answer several yes or no health questions. These questions are radio button widgets and what I've been trying to do is ask the user to fill out a follow up question, a text area which should be invisible until when the user selects the 'Yes' radio button. I have one method which involved some Javascript, but my I'm mostly a backend developer so I'm really struggling.

Anyone know how I can do this?


texts: Trying to override the default taxonomy behavior, from a module

texts:
Tried to catch the routes used for taxonomy display, didn't work, which leads me to believe that I'm not taking the right approach.

  $items['taxonomy/term/%'] = array(
  'title' => 'Activities',
  'page callback' => 'activities_route',
  'page arguments' => array(1),
  'access arguments' => array('access content'),

I'm using aliases which is why i'm trying to catch the system path.

My ultimate goal is to assemble & display three views into one page, based on the vocabulary of term that is passed in. Some views are shared, while others are separate and only need to be returned for a specific vocabulary.

I'm a PHP dev, but still learning about the Drupal stack.


texts: Best Method to Separate Drupal Website from Customized Scripts

texts:
I currently have 2 small cloud servers: (1) database server; (2) web server.

The web server hosts my Drupal 7 website plus a lot of continually running scripts that process data and hook into Drupal's API functions (e.g. node_save, taxonomy_term_save).

I would like to split up my web server into two servers so that now I have 3 servers: (1) database server; (2) Drupal website server; (3) data processing server.

Since my custom scripts tie into Drupal's API functions, I am not sure how to actually run these scripts from a completely separate server without essentially cloning the web server and just blocking public access to the website on the data processing server.

Any ideas would be greatly appreciated! Thanks!


texts:
I have installed drupal 7 in my vps running centos, but while i run clean url test using the drupal 7 clean url option in order to enable it the it shows error like this: "The clean URL test failed."
After diving into this problem i found that there is someting i should do in the httpd.conf, So i have added this to my httpd.conf file:

<Directory "/var/www">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Then i have restarted my apache like so:

sudo service httpd restart

But still The clean URL test failed :/
Any idea? Thanks

Edit:

From MF82 Comment: The site located in /var/www/my_domain_name.com/public_html
I have also try this with no luck:

<Directory "/var/www/my_domain_name.com/public_html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

From  Clive♦ Comment:
From the command i get this in my terminal:


texts: How to use Views Page + Attachment to show parent and children nodes?

texts:
I have a site with a node type Lesson, which has a Category field that points to a taxonomy term.

There is another node type Exercise which is a child to a Lesson node.

I previously figured out how to make one view page for a term url that displays both a parent and child nodes. But I was thinking that maybe it is better to have a page view with an attachment, where the page would display a Lesson node's fields and an attachment would display the children Exercise node's fields.

The page view has relationship set to taxonomy term and contextual filter set to the category. Then it is set to display Lesson fields.

In the attachment view, parent is set to page, relationship is set to a Lesson reference field. But I have no idea what to choose as contextual filter because there is no filter for me to choose that will get me the lesson id. The attachment doesn't seem to have a way to get the parent node id (lesson id) from a contextual filter, since the url will only have the term id.

Any ideas on how to make the attachment display the children of the parent that is displayed in the page view?

Thanks!


texts:
I have a database of persons with birth/death times (Year-Month-day) and biographical data, and I want to make a Calendar View that lists the birth/death events that happened on some specifical day. Eg. a person born 1845. Dec. 16. would show up in this calendar at the field Dec. 16 - With name and biographical data. Also, the viewer could list back in time for other months, to see what happened on dates from eg. August, May, April etc.

I tried to make a calendar with the content types and filters, but had no luck.

Any help please?
Thanks.


texts: Advantage of including file in .info file and also in hook_theme()

texts:
While studying the code in the Elements module, I noticed that the file elements.theme.inc is listed in elements.info, but is also listed for each theme implementation in elements_theme().

elements.info

name = Elements
description = Provides a library of Form API elements.
core = 7.x
files[] = elements.module
files[] = elements.theme.inc

elements.module -> elements_theme()

function elements_theme() {
  return array(
    'emailfield' => array(
      'arguments' => array('element' => NULL),
      'render element' => 'element',
      'file' => 'elements.theme.inc',
    ),
    'searchfield' => array(
      'arguments' => array('element' => NULL),
      'render element' => 'element',
      'file' => 'elements.theme.inc',
    ),
    'telfield' => array(
      'arguments' => array('element' => NULL),
      'render element' => 'element',
      'file' => 'elements.theme.inc',
    ),
    'urlfield' => array(
      'arguments' => array('element' => NULL),
      'render element' => 'element',
      'file' => 'elements.theme.inc',
    ),
    'numberfield' => array(
      'arguments' => array('element' => NULL),
      'render element' => 'element',
      'file' => 'elements.theme.inc',
    ),
    'rangefield' => array(
      'arguments' => array('element' => NULL),
      'render element' => 'element',
      'file' => 'elements.theme.inc',
    ),
  );
}

The Question

is there any advantage or performance improvement from listing the elements.theme.inc file in both places? Is there another reason why this might be necessary?

As always, I appreciate all responses.


texts:
I have a view with a custom PHP field containing the following code.

$storeArray = array();
$result = db_query("SELECT nid FROM node WHERE type ='emp'");

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $storeArray[] =  $row[nid];
}

if ($storeArray) {
  echo 'not empty';
}

The query doesn't return anything. Why?


texts: Change permission on Content Overview page

texts:
I have granted an admin 'Administer Content' permission under People->Permissions. This gives him the ability to publish/unpublish nodes. But I don't want him to be able to go to the Content overview page where he can delete and unpublish in bulk. This is because I have setup certain workflow rules with node_validate which only let him delete or unpublish nodes under certain conditions within the node edit screen. If he goes to the Content overview page, he can circumvent the workflow logic.

So how do I programmatically take 'Administer Content' permission away when he goes to the Content overview page? I still want him to be able to see the Content overview, but I don't want him to be able to unpublish, delete, or do any of the other bulk operations.

Any thoughts would be appreciated.


texts:
How can I create a Drupal "Page" (not a block) without any theme?
I do not want this "Page" to include any header / footer / left / right column.
My understanding is that this isn't possible but could I create an additional theme for my site which is just completely blank, and apply this to the appropriate pages?
We have a salesman that wants to build his own set of pages within Dreamwever and then I would apply this blank theme against just these pages without impacting the existing theme that is utilized for the other pages.


texts: Alter existing route to a different route for a specific content type node using RouteSubscriber

texts:
I want to modify node edit of a specific content type node to a different route .

Eg : suppose i have a node edit page route as entity.node.edit_form (core feature) . And now i want to change this route to custom_module.edit_form when taking the node to edit .

I refered This  which explains altering the existing route to a different route . It only says to route to a different url . It may not work in my case as node edit form will contain node id as parameter . Its not mentioning how routes can be placed in $route->setPath() though .

For eg:
In custom_module/src/Routing/RouteSubscriber.php

/**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    // Change path '/user/login' to '/login'.
    if ($route = $collection->get('user.login')) {
      $route->setPath('/login');
    }
    // Always deny access to '/user/logout'.
    // Note that the second parameter of setRequirement() is a string.
    if ($route = $collection->get('user.logout')) {
      $route->setRequirement('_access', 'FALSE');
    }
  }

How can i do this ?


texts: How to log custom entries in 'Recent log entries'?

texts:
I am developing a custom module, and I'd like to log my own log entries with their own type, so that they can be accessed and filtered at admin/reports/dblog.

But I can't find the appropiate function or script. Any suggestions?


texts:
how can I delete all comments at once? I have seen how to do it with nodes and bulkdelete module, How to delete all nodes of a given content type?
but am looking at a similar solution for comments.

I am looking for a solution that does not leave any artifacts in the database. Is Views Bulk Operations the best solution?


texts:
I need to implement a progress bar using Drupal 7. This is the code I am actually using.

$form[$name][$name.'_enc'] = array(
  '#type' => 'submit',
  '#value' => t($name.' Enable'),
  // '#submit' => array('submit_'.$name.'_enc'),
  '#ajax' => array(
    'callback' => 'submit_'.$name.'_enc',
    'wrapper' => 'ajax-response-goes-here',
    'method' => 'replace',
    'effect' => 'fade',
    'progress' => array (
      'type' => 'bar',
      'message' => 'convert..',
      'url' => 'misc/progress.js',
      'interval' => '1500'
)


texts: Multistep user registration using profile2

texts: How can we create a multistep user registration form in drupal 7 using profile2 module.


texts: How to select Google Web Fonts (via @font-your-face) from drop down in SWeaver UI?

texts:
I am using the SWeaver module for "in-situ" editing of the (CSS) styles of elements on pages i.e. by "in-situ" I mean within Drupal style changes (instead of raw editing the theme files CSS via FTP).

Sweaver provides the means to change the font of the text on a page via it's pop up user interface panel that resides at the base of the page.

I am trying to get the Google Web Fonts listed in the drop down menu of available fonts but this does not show. Apparently, Sweaver provides support for various web font foundries including Google Web Fonts via @font-your-face. So I've gone into the Admin/Configuration for @font-your-face and enabled Google Web Fonts and enables the fonts I want but they don't appear in the Sweaver drop down list.

Can someone supply a step-by-step guide to getting Google Web Fonts to appear in the drop down list of fonts in Sweaver

References:

http://drupal.org/project/sweaver
http://www.google.com/webfonts


texts: How to customize the data retrieved by a REST call?

texts:
I've enabled the REST server (plus services) and can retrieve user profile data at www.example.com/endpoint/user/123

How can I customize the data that's being retrieve? I want to not include the email address and add a couple of other fields.

When I make a login request at www.example.com/endpoint/user/login I would like to have those additional fields included as well.


texts: Responsivness: blocks order + collapsible menu

texts:
I'm using standard Responsive Bartik theme because of its responsive capabilities, but I have one issue. When smaller version of site is displayed (phone, tablet,..), navigation menu (first sidebar) jumps below the main content, but I want it to be on top of it - is this possible? How please?

Second question is, if it is possible to switch navigation menu (in phone or tablet version only) to some collapsed state? Like main menu switches itself (please see attached image)

Thanks in advance

Lukas


texts:
I am using a Zen subtheme with Sass. I am using CodeKit to compile the Sass into CSS. In my workflow, I enjoy using CodeKit's visual system for project settings because then I can use autoprefixer and souremaps etc easily.

Zen comes with Compass support out of the box. In CodeKit, settings for the styles.scss file is disabled, saying "To change options & output paths for Sass files in a Compass project, you must edit the Compass 'config.rb' file directly."

I could find no way to edit the file to make it behave the way I want, so I want to disable Compass completely.

I tried deleting the lines which seemed related with Compass from the sass files, deleting the config.rb but there seems to be a setting somewhere which I cannot find. I checked out the project settigns in CodeKit but could not find a 'switch' to turn Compass off.

In short, how can I take Compass out of Zen's css system and use CodeKit to fine tune the compile settings?


texts: How do I get language drop-down programmatically?

texts:
How to get language Drop down programmatically in template file?

With current language selection & on change of current page that page language also should change


texts: Enable storing of taxonomy term name instead of ID in views filter criteria

texts:
Background
I use Features module to deploy the code to my stagging. For e.g. I have a feature which exports:

content type - Player
Taxonomy term on this content type of vocab - Medals
View which lists the Player with filter type: Content: Has taxonomy term (=gold)

Medals has three terms - gold, silver, and bronze.
In the feature the vocabulary is being exported while the terms are not. I need to add the terms manually again on the server.

Problem
The feature exports the term id of the term instead of the name (tid : 1). So, when I enable the feature on the stagging server, and if the term name for tid : 1 is silver. The views filter criteria is changed and it is conflicting with the use case.
I was just wondering if there is a way to export the views taxonomy filter name instead of id?


texts: How can I watermark images with a taxonomy term from the node they belong to?

texts:
I'm working on a site for a business who would like to watermark all their product photos with the brand name of the product (which is a taxonomy term reference field on the product content type).
Looking into this, I found a variety of modules that will watermark images in various ways, but most expect to just put a single image or text overlay on all images of a given style, which is not what I need here.
The one exception I found was Textimage, which works with the Image Effects module and, at least in theory, supports node tokens. But when I tried out those two modules, I was unable to get any token for the taxonomy field in question to work. I tried [node:field_brand] and [node:field_brand:entity:name] without success — it just put the text of the token instead of replacing it with the brand. Other tokens, like [node:title], did work, but not the one I wanted (even though it was in the list of available tokens).
I posted to the issues queue for Textimage, but it doesn't seem like anyone's monitoring it regularly, and I'm on a deadline.
Does anyone know either how I can get the node replacement to work in Textimage, or alternatively any other way of doing this? I'm not at all wedded to Textimage and Image Effects — they're just the only modules thus far that claim to be able to do what I need to do.


texts: How to sort users in a view by the number of nodes authored of a specific node type?

texts:
I was happy to find that in Views 3 I can sort users in a view by the number of nodes they have authored (Using a relationship "User: Content authored" and the Aggregation / 'Group by' - Count function, see here).

How can I do the same, but counting only nodes of a certain node type? (I'm actually using this in a view of profiles (Profile2), but using the relation "Profile: User UID" the solution would probably be the same).


texts: How to use drupal_mail() to send emails with custom template

texts:
I would like to use the drupal_mail() function to send out emails but with a custom HTML template so that they are in keeping with my website design but I am a complete newbie to hooks and modules etc., so I'd appreciate some sort of explanation or beginners guide please.

I can create the template myself, I just need to know how to get drupal_mail() to use it.


texts: How to load a file located in core/includes?

texts:
I'd like to execute PHP code that requires functions available in the includes files of core located in core/includes.

I found ModuleHandler()->loadInclude() and module_load_include() but I am afraid this 2 options can load files from core/modules directory only, according to the doc, but may be I misinterpreted it:

  Loads a module include file.

For example if I execute:

\Drupal::moduleHandler()->loadInclude('core', 'inc', 'install');
drupal_rewrite_settings(); // the func that I want located in install.inc

I get:

Call to undefined function drupal_rewrite_settings()

which means install.inc has not been loaded.


texts: How can I create user profiles in drupal 7?

texts: I would like to know how to create a user profile (registered user block) similar to the one on this site. I am using Drupal 7 and the Zen theme.


texts: why is hook_access_node running three times?

texts:
I'm working on a custom node access module. For this I'm working with hook_node_access hook (for the first time).
I want visitors to be able to view a node only when they are looking at them from the right domain. For this I have a content type page, in this content type I created a field field_domain.
Now I create a two nodes, Node A with field_domain value d9-a.lcl and Node B with field_domain value d9-b.lcl.
Now I wanted to create the module based on the this tutorial. But before this I created a simple check to see if I can get the value from the field and current domain. So I wrote this:
function hook_access_node_access(NodeInterface $node, $op, $account)
{
    $type = $node->bundle();
    if ($type == 'page') {
        $currentDomain = $_SERVER['SERVER_NAME'];
        $readerDomain = $node->field_domain->value;
        dpm($node->id());
        dpm('Current domain: ' . $currentDomain);
        dpm('Pages domain: ' . $readerDomain);
    }
}

Now going to Node B from domain d9-b.lcl made me expect to see three values. And the values I wanted to see are there but they get returned three times.

So for some reason the hook is called three times and I can't figure out why. Is it normal that this hook is called three times? And if it is is there a better way to do what I want?


texts: drupal_goto forcing redirects to https when external link is http

texts:
Our server uses https, but when we want to redirect to an external site that uses http, the https still gets added on. We will often have mixed links where some links are http and some are https. Our current call goes as:

drupal_goto($link, array("external" => TRUE));//where $link is the link we want to redirect to

Is setting the https option to false the way to go, or will it kill the links that should be https? I would think for an external link that drupal would not be trying to change that.

We changed the code to this, but it did not fix the issue:

$parsed = parse_url($link);
if ($parsed["scheme"] === "http") {
  $https = FALSE;
}
else {
  $https = TRUE;
}
// Forward to requested URL.
drupal_goto($link, ["external" => TRUE, "https" => $https]);


texts: Showing different nodes for same taxonomy terms on different URLs

texts:
I'm facing this design issue regularly.

For example I've Jobs and Company node types. Both have one common taxonomy term reference field City.

Now when we go to a City term it will show both Jobs and Companies(I don't want this mixing).

I want that it show only Jobs or Companies(in different URL's)

One solution is to duplicate City vocabulary as City Jobs and second as City Companies.  Now I get what I want. But in programming it'll complicate as same city in both Vocabularies will have different term id's.

What is the best way to achieve this?


texts: Check to see if two nodes are translations of each other

texts: What is the easiest way to check to see if two nodes are indeed part of the same translation set? Is there a function or some property that can be used? I am using the i18n suite of modules to perform node translation.


texts: How to add attributes (classes, id, ...) to preprocessed text of field?

texts:
I'm working on a theme for Drupal 9 where I'm rendering a node's field, which consists of multiple "raw" HTML elements (without any attributes). The item.content variable inside my field template looks as follows when I dump() it:
array(4) { ["#type"]=> string(14) "processed_text" ["#text"]=> string(27) "
Sub heading

Lorem ipsum
" ["#format"]=> string(10) "basic_html" ["#langcode"]=> string(2) "de" }

This gives me, as expected, just
Sub heading

Lorem ipsum
. In this case, simply using the tags for styling is not acceptable as I wish to follow specific conventions, so I'd like to add suitable class attributes to these elements, for instance each
 inside this template should get a defined class, each
 another class. As I don't want the person typing the text inside the editor take care of the styling, I'd rather not change the editor's setup to include classes. How can I do things like that, importantly without affecting any other elements to be rendered somewhere outside this template? Unfortunately my own research did not lead to an answer so far. Thanks for your help!


texts: How do I get the translated node type of a node?

texts:
I am trying to use the node type name in page.tpl.php for certain content types.
Actually, we have modified the article type and renamed it as News. It's name is News in all languages but in Spanish, where it is Noticias.

The translations are defined under Structure>Content Type>Article.

I tried to use this code :

if(!empty($node) && $node->type == 'article'):
  print node_type_get_name($node);
endif;

but the node type is always printed as News, even on Spanish pages.

I tried wrapping this in a t() , but no change.
Am I doing something wrong here ?
Thanks for your help !


texts: Views output into multiple columns based on variable of results

texts:
Scenario:
I want to output a 3-column display, i.e. first 5 results on left column display, next 5 in middle column, last 5 on the final column.

I can do this with a fixed amount of results using different views + offest, but I want to do this with one view with a varied amount of results:

e.g.
Col-1: 4 items
Col-2: 3 items
Col-3: 3 items

Example is iTunes website:
https://itunes.apple.com/au/genre/podcasts-technology-tech-news/id1448?mt=2&letter=X

They even account for pagination
https://itunes.apple.com/au/genre/podcasts-technology-tech-news/id1448?mt=2&letter=T

What would the best way to approach this? Would you need to get a count of results then set the offset for the 1st, maybe 2nd column if it's not a divisible number?


texts:
I have a Boolean field with Yes/No values with default style of Drupal .

I want to change that field to ON and OFF toggle style like below .

I understand that it can be done using the bootstrap theme and the bootstrap toggle module. But I don't need to change my theme. How can I do that ?


texts: How to fetch a field's values from a lot of nodes?

texts:
I need to create a list of all submitted values from a field named field_telephone from thousands of nodes from a specific content type.
using the node_load() function takes long time.

What is the fastest way to fetch the field's values?


texts: How do I map active directory group membership (ldap authorization) to og groups in open atrium?

texts:
I can successfully bind to the ldap server, and I have set up authentication successfully - ldap users can log in to my open atrium site. However, the authorization mappings for the groups aren't coming through.

I have this as a mapping under:
admin/config/people/ldap/authorization/edit/og_group

CN=Human Resources,OU=Groups,OU=Domain Users,OU=Domain Controllers,DC=domainname,DC=com|node:100:6

Where "100" is the node id for the open atrium space (og group), and "6" is a custom group admin role with a set of permissions defined in:
admin/config/group/roles/node/oa_space

However, when I log in with a user that is confirmed to have this "memberof" attribute in active directory, the user does not have the corresponding access to the organic group.

I have tried both "Convert full dn to value of first attribute before mapping" checked and unchecked with the same results.

The mapping is shown to be enabled here:
admin/config/people/ldap/authorization

I'm finding the documentation a little lax here. Am I mapping the correct og role id? Does the og role id translate to the role id in admin/config/group/roles/node/oa_space? Is this set somewhere else? Where? Is there anything else I have to do to bring these mappings over?


texts:
Looking to tie a recurring product to the published status of the node it created.  I've tried this by creating a node on checkout in a number of ways, but my most recent and promising attempt involves line items and rules creating the node on checkout and setting data values for it coming from the line items, similar to this video by Josh Miller.

My thought is to use a recurring product type and have the node publish on completed payment of that product.  Then, at some point in the future, when the user/customer cancels the subscription to the recurring product, the node that was created upon initial payment should be unpublished.  Additionally, the node would be deleted (also by rules) after a given unpublished grace period.

Note: I have used the Commerce Node Checkout module, but am not able to select multiple products at a time.  I'm also aware of the Commerce License Node module, but considering the lack of documentation I've found, do not have a lot of confidence in the progress I've made there thus far.

So, any thoughts/ideas on how to use rules to unpublish the node created at checkout when the recurring product expires upon user cancellation?

Clarification:  I'm able to create a node through line items, save it, and publish it on successful payment at checkout.  The problem is connecting the created node to the recurring product/order that created it beyond the moment of creation.  In other words, I'm stuck at trying to use rules to unpublish the node in the future according to the status of the order that originally created it.

I could set an interval field on the node upon creation equal to the value of the interval of the recurring product/order, but that does not allow the node to react to changes in the order going forward.  So, if the node has a value (let's say 12 months), and the recurring product/order has a corresponding value (also 12 months), I could use rules to tell the node to unpublish after that period on the node (12 months).  But what if the order is renewed or set to be unlimited until cancellation?  The order and payment will continue beyond the original period (12+ months), but the node will unpublish according to its original static value (12 months).

I have tried using rules to look at the Order ID and work back from there to the entity created (node), but I think I need to make a more concrete connection between the node and the order first.  I've considered using a node reference field on the product, but haven't figured out how to connect that field to the entity created either.  Maybe I'm off in how I'm approaching this, but it feels like the answers just around the corner.  So, how do I use rules to unpublish a node according to the status of the recurring order that created it through rules?


texts: How to create 2 or more different registration pages in Drupal 7

texts:
I'm trying to create (on this, my first project) 2 user registration pages, one for free, the other one could be a 'paid' subscription sign up via UberCart. I'm using AutoAssignRole, Profile2, Views, roles.
I'm sure it is really very easy, but I seem to be going around in circles and not getting anywhere. Maybe I can't see the 'logic' for the 'trees'.
The Drupal forums lack any specific answers.

I'm running a Dev machine on an Ubuntu localhost (without WAMP) prior to any.
It's all very frustrating and I'm trying to learn ASAP as to get back in to work. Does any one have a simple answer, or any suggestion for a tutorial on the above?
I'm a newbie to Drupal 7 and web programming, but I have 25 years of experience in IT, previously on Microsoft platforms.


texts: URL Alias Preventing a Pattern on Vocabulary

texts:
I am trying to setup a replacement pattern with URL Alias on a vocabulary called 'Media Categories' using the pattern 'media/[term:name]'.  However whenever I try and generate the aliases this vocabulary is left unchanged.  I have tried changing the pattern to something else like 'edia/[term:name]' and that works, it seems as though it is reserving the 'media/[term:name]' somewhere.

I have tried flushing the cache, deleting the vocabulary and terms and adding them again, however I have still had no success.  The only option I have had so far is to manually enter the url alias.

Has anyone come up against something like this before?  All I can think of is that 'media/[term:name]' is reserved somewhere...


texts:
I need to show only the preview and not all page and forms

I made a new window after clicking preview but I see ALL page (a duplicate) including header, footer and form compiled. I need to show the preview only.

function node_form_build_preview($form, &$form_state) {
  $node = node_form_submit_build_node($form, $form_state);
  $form_state['node_preview'] = node_preview($node);
}

can someone help?


texts: How to group drush command sets together in sequence?

texts:
For example, when installing a drupal site, there are 3 sets of commands:

drush dl drupal-7.x

drush site-install standard --account-name=admin --account-pass=admin --db- url=mysql://YourMySQLUser:RandomPassword@localhost/YourMySQLDatabase

drush make example.make

Is there a way to group these 3 tasks and have drush do them one by one without having the user do it 3 times?


texts:
I've got a simple Text field which allows 2 values, let's call it field_text. My source database has two columns, let's say text1 and text2.

I want to set my migrate field mapping so that text1 is used as the first value for field_text and use text2 as the second value for field_text.

In other words, something like this:

$this->addFieldMapping('field_text[0]', 'text1');
$this->addFieldMapping('field_text[1]', 'text2');


texts: How to update a field, after a view page is visited?

texts:
Scenario:

I want to use a view to allow user to check a given code (string-like, eg "abc123") whether it is exists in the database, as well as whether the code has been checked before.

A content type called "code" is set up, has a field of "field_code_checked", either "0|Not yet checked" or "1|Checked",  and the title field represents the "code" string. The title field will be use as argument a.k.a the contextual filter of a view page to check the code.

So a view page 'check' is set up.
http://mysite.com/check/[code-title]  => e.g  http://mysite.com/check/abc123

For example:
If 'abc123' exists and field_code_checked value is '0' (not yet checked), then view will output the code node information.

My problem is: how can I manage to update 'field_code_checked' to 1, once a checking visit is done? So when abc123 node is created, it has a field_code_checked set to 0 by default, when a user visit http://mysite.com/check/abc123, I want field_code_checked of abc123 node set to be 1.
Any solution?

Thanks.


texts: How can I update this db_query statement to db_insert for D7?

texts:
I'm trying to update someone's module to D7, but I'm unsure of how to convert the usage of places and values in the query to use 7's api properly.

$fields = implode(',', array_keys($args));
$places = implode(',', array_fill(0, count($args), "'%s'"));
$values = array_values($args);

$insert_result = db_query(
  'INSERT INTO {bluga_request}(' . $fields . ') VALUES (' . $places . ')', $values
);


texts: White screen appears when viewing huge number of nodes as view result

texts:
I have a View which display fields of nodes. I have to display all of the items. I cannot introduce a Pager.

There are approximately 4000 nodes as the result of the view. The View preview works perfectly fine, i.e all 4000 nodes are displayed, in the View preview result.

Placing the View on a panel page and loading the page gives the "White screen of death".

What could be the problem?


texts: Add attributes to a template based on current node

texts:
I need to add a style attribute to the .region-content tag in order to set a field-dependent background image.

How do I do this? I have the node in page.html.twig in the page.node variable, but not in region.html.twig, and there doesn't seem to be a way to transfer it from one to the other at that level.

Edit:

This seemed like a good first attempt:

function [THEME]_preprocess_page(&$variables) {
  $variables['page']['content']['#context']['node'] = $variables['node'];
}

function [THEME]_preprocess_region(&$variables) {
  if ($variables['region'] == 'content') {
    var_dump($variables['context']);
  }
}

Unfortunately, that doesn't work - the context variable is still an empty array. How do I transfer context from one theme element to one of its children?

This could be done with a global* variable or something, but that looks horrendously inelegant.

Edit: Well, preferably a call to a function with a static variable, but that still seems like a bad hack.


texts: Migrating XML source twice, according to language

texts:
I am writing a scheduled import using the Migrate module, where I have an XML feed which gives me a number of reports.
These reports have most of their fields in common, but have two fields ("location/name" and "desc") which are supplied twice, each specific to a language.

My question is how I could import this into two nodes, one for each language? My first thought went out to using stubs, but thinking on that I can't figure out how.

Ofcourse, the "location/name" and the "desc" elements should only import the one relevant to the language being imported.

Altering XML structure is not possible, data in the fields has been altered for privacy reasons.

Example XML and current code: https://gist.github.com/Tagini/8319661

P.S.: Any help on migrating the location (using Location module) is welcome.


texts: How do I create new content type with editable fields?

texts:
I want to create another content type similar to the basic page. I've designed a simple html layout with a block of copy on the left hand side and an image with a caption floated next to it on the right hand side.

I want to be able to add this as a template to the Drupal UI so that a user can pick this template and enter their copy, choose/upload an image, enter an image caption and possibly show a widget below the content based on what the page is about.

How would I go about configuring this so I can add this page template as a content type into the Drupal UI?


texts: Incorrect Login Notification Missing using user-login.tpl.php

texts:
I've customized my logged in user page using a template file in D7 (user-login.tpl.php).

Problem I can't figure out is that if they type in the wrong login/pass, it just reloads the page and there is no message stating "Sorry, unrecognized username or password". This can be confusing for them. How can I get it to show up?

Here is my code for my template file:

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


texts: Drupal views print date 'time ago' as a PHP conditional field

texts:
I am trying to make a custom PHP field that returns the value of 'user last access' field as an integer of minutes 'time ago'.

I have created a normal views field for 'user last access' which returns almost exactly what I want from the normal field value:

x mins - this being x mins time ago, created by using 1 as the time units to display.

I just don't know how to return this value through a new PHP field that just references and displays the integer value for this field without ' mins' text ?

I want to then take this raw value and use a conditional statement of:

If user last access is less than 3 minutes print 'Online'
else
Print 'Offline'


texts: How can I update multiple drupal 7 sites on my server, using drush

texts:
I just installed drush in my ssh home directory. Is there a drush command for updating all sites inside home directory that have drupal 7?

There is to mention that i have also non drupal sites and i would not like drush to mess with these.

Thanks


texts: How to have one stylesheet for logged in users and another one for anonymous users?

texts: Anyone know how to have one CSS stylesheet for logged in users and another for anonymous users?


texts: How do I pass dynamic parameters to a service?

texts:
Is it possible to pass dynamic parameters when calling a service?
mymodule.services.yml
services:
  my_module.default:
    class: Drupal\services\DefaultService
    arguments: ['@entity_type.manager']

DefaultService.php
namespace Drupal\my_module;
use Drupal\Core\Entity\EntityTypeManagerInterface;

/**
 * Class DefaultService.
 */
class DefaultService implements DefaultServiceInterface {

  /**
   * Drupal\Core\Entity\EntityTypeManagerInterface definition.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  private $myValue;

  /**
   * Constructs a new DefaultService object.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;

    //how set $myValue?
    // $this->myValue = ???
  }

}

Is there a way to dynamically set myValue when calling this service,  for example while calling the service from hook_ENTITY_TYPE_update(), passing the $entity->id() value?
I've found similar questions, such as How do I pass parameters to a service? or  Create service with argument, but they don't answer my problem.


texts:
I have a custom views filter extending Drupal\user\Plugin\views\filter\Name that I am trying to add an additional form element. The existing filter is an autocomplete field that I need to add a checkbox element. I've tried updating ::valueForm.
// Working code that creates the autocomplete field.

$existingElement = $form['value'];

$form['value'] = [
  '#tree' => TRUE,
  'existing_element' => $existingElement,
  'new_element' => [
    '#type' => 'checkbox',
    '#title' => t('Checkbox'),
    '#default_value' => FALSE,
  ],
];

It throws this error.

Error: Cannot create references to/from string offsets in Drupal\Component\Utility\NestedArray::setValue() (line 155 of core/lib/Drupal/Component/Utility/NestedArray.php).

It seems to be related to the form state, but I have troubles in figuring out exactly what is missing.


texts: Equivelant of node_type_load() for entity bundles

texts:
If I know the entity type and bundle, I want to load the bundle object with its settings. Drupal core has this for nodes, but is there any way to do it for entities?

See node_type_load() in core:
https://api.drupal.org/api/drupal/modules!node!node.module/function/node_type_load/7

EDIT: So to elaborate, I'm asking about a way to load up the data about the entity bundle, not a specific entity.

E.g.

var_dump(node_type_load('page'));

object(stdClass)[628]
  public 'type' => string 'page' (length=4)
  public 'name' => string 'Page' (length=4)
  public 'base' => string 'node_content' (length=12)
  public 'module' => string 'node' (length=4)
  public 'description' => string 'Use pages for your static content.' (length=43)
  public 'help' => string '' (length=0)
  public 'has_title' => string '1' (length=1)
  public 'title_label' => string 'Title' (length=5)
  public 'custom' => string '1' (length=1)
  public 'modified' => string '1' (length=1)
  public 'locked' => string '0' (length=1)
  public 'disabled' => string '0' (length=1)
  public 'orig_type' => string 'page' (length=4)
  public 'disabled_changed' => boolean false


texts: How do I get a field count from an executed query?

texts:
I'm sure this exists, but after a few dozen searches, I'm not any closer to an answer.

After I've executed a query in Drupal (for example)

$dbParts = db_select("parts", "p")
    ->fields("p")
    ->execute();

How can I get a count (or list) of fields without pulling this first record? With MySQL I was able to use "mysql_num_fields".

UPDATE

Just to give a little background... I have some old code (using mysql_* functions) that export data to the DBF format. In order to format the header of the DBF, I need to have a field count (and information about the fields) even if the record count is 0 in order to format a "blank" database.


texts:
I have a jquery code that is supposed to complete certain fields on my webform but am getting an Uncaught TypeError: undefined is not a function for the following line:

 $("#city").autocomplete(ac_config);

The following is my entire jquery:
   Drupal.behaviors.mywebform = {
attach: function (context, settings) {
    var ac_config = {
        source: "/devtest/sites/democities.php",
        select: function(event, ui){
            $("#city").val(ui.item.city);
            $("#state").val(ui.item.state);
            $("#zip").val(ui.item.zip);
        },
        minLength:1
    };
    $("#city").autocomplete(ac_config);
  }};

And the following is my php file:

$cities = array(
    array('city'=>'New York', state=>'NY', zip=>'10001'),
    array('city'=>'Los Angeles', state=>'CA', zip=>'90001'),
    array('city'=>'Chicago', state=>'IL', zip=>'60601'),
    array('city'=>'Houston', state=>'TX', zip=>'77001'),
    array('city'=>'Phoenix', state=>'AZ', zip=>'85001'),
    array('city'=>'Philadelphia', state=>'PA', zip=>'19019'),
);

// Cleaning up the term
$term = trim(strip_tags($_GET['term']));

// Rudimentary search
$matches = array();
foreach($cities as $city){
    if(stripos($city['city'], $term) !== false){
        // Add the necessary "value" and "label" fields and append to result set
        $city['value'] = $city['city'];
        $city['label'] = "{$city['city']}, {$city['state']} {$city['zip']}";
        $matches[] = $city;
    }
}

// Truncate, encode and return the results
$matches = array_slice($matches, 0, 5);
print json_encode($matches);

Any help is appreciated.

Thanks!


texts: How do I send an email to all users that has flagged a node using rules?

texts:
I need to send an email when there is a new comment on a node to all users that have flagged that node? How do I do this?

The flag is called "Follow" and the content type is "Blog"


texts: How do I test if a field has a value in twig?

texts:
I am writing a template and if 2 fields, one of which is required the other is not.  I would like to display the one thats not required if has been filled out by the user.

I have tried numerous things

{% if content.not_required %}
 {{ content.not_required }}
{%else%}
  {{ content.required }}

{% if content.not_required  is null %}
 {{ content.required }}
{%else%}
  {{ content.required }}

{% if content.not_required  == false %}
 {{ content.required }}
{%else%}
  {{ content.required }}

{% if content.not_required  == null %}
 {{ content.required }}
{%else%}
  {{ content.required }}

{% if not  content.not_required %}
 {{ content.required }}
{%else%}
  {{ content.required }}

all of these display all stories the same whether or not content.not_required was filled in.

Is there a way to do this in twig or do I need to set up some variable in a preprocess function?


texts: Why doesn't drush check for updates of dev versions of my modules installed by composer?

texts:
I am using Drush (8.0.3) on my Drupal 8 site (8.0.3) to check for updates, but Drush is not checking for updates of any modules that I checked out the dev branch for.

$ drush @mysite ups --check-disabled
Checking available update data for Drupal.                                  [ok]
Checking available update data for Address (address).                       [ok]
Checking available update data for CloudFlare (cloudflare).                 [ok]
Checking available update data for Commerce (commerce).                     [ok]
Checking available update data for Composer Manager                         [ok]
(composer_manager).
Checking available update data for Chaos tools (ctools).                    [ok]
Checking available update data for Domain Registration                      [ok]
(domain_registration).
Checking available update data for Entity (entity).                         [ok]
Checking available update data for Google Analytics                         [ok]
(google_analytics).

I have dev branches of the following modules:

Inmail
SMTP
Rules
Several others not in the list above

Now I have some idea about what may be wrong: I am using Pantheon for my site, and I added these modules to composer.json, then ran composer update to install them.  For dev modules, this adds .git repositories for each dev module.

I then committed all this to Pantheon, which gave me a message about not supporting submodules.  I ignored this message because I could still install the modules on Pantheon, but I now suspect that either this or installing via composer has somehow busted Drush for me.

How can I get Drush to also check for updates to the dev branches of modules installed by composer?


texts: Drupal Commerce - Add to Cart form tweaks

texts:
I am setting up a very simple drupal commerce site for a few courses with 3 product variations for different price levels. I created a product type "Course Registration" and gave it these payment options:
DEP|Deposit
EB|Early Bird
FULL|Full Price

I have a content type "Course Display". On the bottom of a product display page I get this:

Payment Option
o Deposit
o Early Bird
o Full Price
[Add to Cart]
$250

From what I've been able to figure out the radio buttons and submit button are displayed part of the "Add to Cart form" widget for 'product' field. The price is coming from the 'Product: Price" field. I would like have the price show above the submit button like this:

Payment Option
o Deposit
o Early Bird
o Full Price
$250
[Add to Cart]

I assume this means getting the "Add to Card form" to show the price? I'm at a loss for how to proceed.

Thanks!


texts: Entity query - using parent/grandparent ids as a condition

texts:
I have relationships linking a node to a child paragraph, with a grandchild paragraph:

Node
 |_ paragraph child
        |_ paragraph grandchild

Using an entityQuery, I can get child items using parent_id as the field/property:

return  $this->paragraphStorage->getQuery()
  ->condition('status', 1)
  ->condition('type', 'paragraph_grandchild')
  ->condition('parent_id', $paragraph_child_ids, 'IN')
  ->execute();

My problem is that I want to get all grandchildren, but don't want to run 2 queries, and I can't see how to get use the node ID as a condition like I do with parent_id.

For example (this doesn't work):

return  $this->paragraphStorage->getQuery()
  ->condition('status', 1)
  ->condition('type', 'paragraph_grandchild')
  ->condition('parent_id.entity.parent_id', $node_ids, 'IN')
  ->execute();


texts: How do I extend the schema of an existing config_object?

texts:
Module A defines the following schema in module_a.schema.yml.
module_a.settings.api:
  type: config_object
  label: API settings
  mapping:
    store:
      type: string
      label: Store code
    credentials:
      type: mapping
      label: Credentials
      mapping:
        username:
          type: string
          label: Username
        password:
          type: string
          label: Password

Module B extends the Module A configuration form and defines additional schema properties in module_b.schema.yml.
module_a.settings.api:
  mapping:
    additionl_one:
      type: mapping
      label: Additional one
      mapping:
        additionl_one_sub:
          type: label
          label: Additional one sub

The definition from module_b.schema.yml isn't picked up by Drupal. I'm checking with config_inspector and proving it by the fact that the new properties can't be translated.
Available articles/tutorials out there are doing the same thing but seems like this is either outdated or never worked:

https://www.drupal.org/forum/support/post-installation/2019-02-06/add-a-new-custom-field-to-site-infomation-form-in-drupal8

http://www.jaypan.com/tutorial/drupal-8-extending-core-configuration-extending-core-forms-and-overriding-core-routes#comment-33507


texts: How to avoid caching on access callbacks?

texts:
I am using Views Access Callback module to set my custom callback access check. I have written a custom module and implemented the hook provided by this module. I have added a condition to return TRUE and FALSE. But the access callback get cached.

/**
 * Implements hook_views_access_callbacks().
 */
function my_custom_views_access_callbacks() {
  return array('my_custom_module_access' => t('Allow my views access.'));
}
function my_custom_module_access() {
  $password = \Drupal::config('my_custom.settings')->get('my_custom.pass');
  if (isset($_SESSION['my_custom_pass']) && $_SESSION['my_custom_pass'] == Crypt::hashBase64($password)) {
    return TRUE;
  }
  return FALSE;
}

I have added callback like above. So when I drush cr from command line it will return FALSE because there is no session in terminal. So when I access the view in browser it still shows access denied because of cache I guess.

My question is how to handle this callback without being cached?


texts: How to implement some super admin feature to facilitate password retrieval for existing users?

texts:
I'm aware that Drupal 7 saves the user's password in a more compact way and it's really hard (impossible?) to convert such password back to a human readable text format (even not into database).

Actually I do not want to implement any hack to Drupal, but it's a requirement that a super admin can somehow view the username along with its password for any user. Super admin is a trust worthy role and actually will help through secured communication media to other users after forgetting their password.

So there is a need to create a block to show all the usernames with their corresponding password, which can only be used by a super admin.

Any suggestions about how I could implement all this?

Note:  Users are not allowed to reset passwords, I just want only super admin can access their usernames and passwords and then re-assign to other user if any of them forgot his password.


texts: how to exclude PHPUnit based functional tests from runnning?

texts:
I am trying to run only unit test for my custom module.

./vendor/bin/phpunit -c ./web/core ./web/modules/custom/testing_example --testsuite=unit .
But I keep getting the following error:

There were 2 errors:

1) Drupal\Tests\testing_example\Kernel\ExampleFixtureManagementTest::testNodeCreation
Exception: There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh. See https://www.drupal.org/node/2116263#skipped-tests for more information.

I only want to run PhpUnit tests and not functional/browser tests.


texts: A module or solution to build first time user walkthrough?

texts: Is there a module or existing solution out there that can be used to create first time user walkthroughs of a site? For example, a user logs in for the first time and gets redirected to a certain page and then can follow steps to learn the site etc etc. I have done some googling on the matter but as you can imagine the results are hold to filter when searching for terms like "guide", "walkthrough", "module", "new user" and so on...


texts:
I am struggling a bit with the array structure of Drupal.

I am using PHP in a contextual filter inside views. I have the same vocab on both a content type and user via profile2. I manage to get the filter working for single term. The key is in how I return the values at the end of my function.

return $items[0]['tid'];

This returns 2, a correct tid on user profile taxonomy.

I can also get other values by using:

return $items[1]['tid'];

This returns 4, also a correct tid.

How would I be able to say?

return $items[ALL_ARRAYS]['tid'];

So that it would print all the term ids associated with that vocab?

My PHP code:

global $user;
$profiles = profile2_load_by_user($user);
    foreach ($profiles as $profile) {
      if ($items = field_get_items('profile2', $profile, 'field_your_interests')) {
        break;
      }
    }
$tids = array();
foreach ($items as $item) {
  $tids[] = $item['tid'];
}
//returns nothing in view, not sure if a contextual filter can handle 'and'?
//return implode(',', $tids);

//This works with 1st value in array
//return $items[0]['tid'];

//This doesn't return anything
  return $tids;


texts: How do I get the (date)timestamp since last cron run?

texts:
I'm building a module but am stuck..
I need the timestamp from the previous cron as I run a hook_cron job so I can check which nodes are new and email those.

So I need the date/time stamp from the last cron run but how do I get there'?


texts: Entity Metadata Wrapper Save VS Node Save when invoked from hook_node_insert

texts:
Can somebody shine a light into the difference of the two, in terms of their interaction with database when hook_node_insert() is invoked? The documentation explains that

  Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and node_save() goes out of scope.

In fact, when I tried doing node_save($node), it will give me an error.

However, if I was doing it this way,

$nodeWrapper = entity_metadata_wrapper('node', node_load($node->nid));
$nodeWrapper->title->set(t("Saved by Entity Save"));
$nodeWrapper->save();

It works just fine. Has the new node being committed into the database after the $nodeWrapper->save() was executed?


texts: How can I programmatically copy all blocks of a given theme into the same regions of a new theme?

texts:
I would like to switch admin themes from a core theme (seven) to a custom sub-theme so I can add some customization without hacking core.

When I install the new sub-theme it creates all the block placement settings and leaves them header or content. I haven't changed any regions between the two themes, and just want to copy all the blocks from the seven theme to the current theme. I know I can check block settings with block plugin manager (plugin.manager.block) but I don't know what blocks to edit. I would like to know how to get a list of all the blocks from the old theme and copy all the placement to new theme programmatically.


texts: How can I print the translated entity title in a template?

texts:
I have a reference field for nodes and I have a field template to render the the fields.
{{ item.entity.title.value }}

But I can't get the translated title of the node.
Can someone help?


texts: Redirect whole site to HTTPS, with exceptions

texts:
I've successfully redirected my entire Drupal 7 site to HTTPS using the snippet:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

from How to simply make the whole site HTTPS?, but now I want to add an exception for a specific URL (it's an XML feed for products, created with Drupal Commerce + Views Data export). I've tried many variants of this:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !^/xmlfeedurl
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP:X-Forwarded-Proto} !http
RewriteCond %{REQUEST_URI} ^/xmlfeedurl
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

but haven't managed to get it to work. When I visit http://www.example.com/xmlfeedurl, I'm redirected to https://www.example.com/index.php.

I'm guessing that there's some interference with Drupal's rule that redirects all URLs to index.php but I have no idea how to solve this (all the above snippets are placed in the detault .htaccess file, just before Drupal's redirect to index.php). Can someone help?


texts: How do I get the MIME type of a file basing on its content and not its extension?

texts:
I want to get the exact MIME type basing on the file content, not its extension.
I have used PHP methods and the API exposed by a module, but they return the MIME type basing on the file extension.

How do I get the MIME type from the file content?


texts: How to allow a role to add users without giving them a password?

texts:
I have a situation where I would like a specific user role be able to add users without assigning them a password but I can't seem to find a way to do this. Has anyone done this before? I feel like this is something commonly done. Any help would be appreciated.

Here is the module I have and currently, this code just outputs at the top of the screen for all pages? This is my first module.

Here is my hide_some_fields.module file

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

  global $user;

  if($form_id == 'user_register_form')
  {
    if(in_array('operator', array_values($user->roles)))
    {
      unset($form['account']['pass']);

    }
  }
}

Here is my .info file as well:

name = Hide Some Fields
description = Hides some fields. The password field when the operator adds patients.
core = 7.x


texts: Managing different view modes for a single content type

texts:
I have three different view modes for a single content type on my site. Besides the default and teaser view modes, using Display Suite, I made a custom one called "simplified" . What I need is to make a page view with a list of node titles which would link to the nodes in  the simplified view mode, which would themselves contain a link to the full content view mode.

I am not sure as to what the best way to do this would be. It could be something very simple which I failed to think of, since I am relatively new to Drupal.

I also found the View Mode Page module, which is a great idea, but it doesn't seem to work at all.


texts: Using different markup for views last item

texts: I need to use different markup for last item displayed by views. Using first last css item does not do the job for me. I assume I would need custom php template probably views-view-fields.tpl.php. What would be the way of doing it?


texts: Add custom content to custom layout Panels

texts:
Is it possible to add custom content to a custom Panels layout?

Specifically, I've created a layout with a couple of columns for a content type called 'Stuff' and I always want to add the same images in a certain column of the teaser (that means every node of the 'Stuff' content type has to contain these images). I created several custom content panes with these pictures, but I don't know how I can use them in the custom Panel layout or the content type.

Any ideas? Or is there a better way to achieve my goal?


texts: Entity field value inherited from another entity programmatically?

texts:
I'd like to setup two content types in a parent -> child relationship.

Node A of content type "parent" has custom field:

(text) Description

Node B of content type "child" has custom fields:

(text) Description dynamically inherited (referenced) from parent node.
(reference) to parent node

When the description of Node A changes, Node B automatically reflects this change.

I'd like to achieve this entirely on the backend, no UI or forms needed.

I will be creating the child nodes programmatically.

Topics I've found have danced around what I'm trying to do but lack the details I need to execute it.
inheriting fields from a base content type

I have experience with Drupal 6 & 7 but am new to Drupal 8's entity apis.

A detailed explanation or example of how to achieve this would be greatly appreciated.

Thanks

One possible solution:

Store the parent node's updated date in the child node.
Upon loading the child node, lookup the parent node's updated date, if it differs, copy the parent's field value to the child.

The parent node will not be updated frequently.


texts: Content type add page misalignment in drupal 8

texts:
In D8 in all the content type adding pages the settings which display on the bottom of the page have been misaligned , refer the pic below .

How can i fix this , Is it related to any style issues ?

UPDATE

In garland theme that portion is coming properly but have some other style issues in it .


texts: Is it possible to set the user picture as the value of an image field from a node?

texts:
Use case: On my site, I need a workflow that allows user pictures to be approved.  Users submit images using a special content type.  Of these images, they must designate one as their user picture.  I use the Rules module to manage the approval workflow.

I managed to get everything set up in Rules so that the picture they designate shows up in their profile appropriately.  However, many modules (such as Privatemsg) make use of Drupal's default user picture.  Is there a way to set the Drupal user picture value with the value from the uploaded field?


texts: How do you pass page arguments from panels to a view?

texts:
I'm creating an online store using Ubercart.  I have Views and Panels installed.  I'm using the Page Manager and Panels to configure each of my pages.  I've modified the default view to accept taxonomy terms as arguments.

My question is simple, "How do you pass arguments from Panels to a View?"

I followed the direction's at this URL, but, in the process, actually discovered a much better way (I posted the solution in the article, but I'm also going to post it here):

[a link] http://itscommonsensestupid.blogspot.com/2009/04/passing-arguments-from-panel-to-views.html)

I will post the best solution to this question in a couple of hours.


texts: Gmap Location in views - exposed filter by distance/proximity and post code

texts:
I am currently working with Drupal 7 and Location 7.x-3.4 module
I have created a view, choose the Gmap format, and added the post code and distance field in filter section, so that the visitors are able to search for the locations they want.
Gmap Settings:

Data Source = Location.module
Marker handling = Use single marker type

Here is my configuration for the Location: Distance / Proximity :

Expose this filter to visitors, to allow them to change it = 1
Filter type to expose = Distance / Proximity
Operator = Proximity (Circular)
Postal code = Blank
Distance = Blank
Origin = Postal Code (assume default country)
Filter identifier = distance

After saving the changes, the result is not changing. Is anyone knows what's wrong with my configuration above? Please help..


texts: How to translate views infinite scroll Loading message

texts:
I have an Arabic website and I have views infinite scroll module to allow ajax paging.

I want to translate Loading the next set of posts.... I have tried to search for it in the translate interface, but I could not find it. I tried to import its *.po file from this link but also I could not find it. I have tried to search among the module views_infinite_scroll files, for that string to change it from the source, but also I could not find.


texts: Saving form data and running custom queries in mysql

texts:
I'm new to drupal and although I've researched and asked some questions I'm still stuck on how I can achieve my end result.
I have built a php/html/mysql website (www.gbpokerclub.co.uk) but I now want to create it in drupal, mainly so I can easily give different users their own permission levels, and also so I can have my admins do some of the content editing.

Most of that I've worked out but the bit I'm stuck on both practically and conceptually is how I can record data into custom tables and retrieve that into leaderboards and results tables.

At present an admin logs poker game results via a form, this records the venue id, player id, finishing position etc into a mysql table. I have other tables that record venue details, player details, agent details etc. I then have some complex mysql queries that take data from results, player and venue tables, performs some calculations on it and spits out a leaderboard showing who has the most points.

This is currently done using forms to input the data, and mysql queries and php include files to drop the data back into a presentable format on the webpage.

My big question is ..

  How can I emulate this process in Drupal?

the feedback I've had so far suggests I could use content nodes with specialised types, or custom DB tables and views to present it back, or coding a custom module, but I've also been warned against using SQL and to use the database.api instead.

To be honest there seems to be many solutions to the achieve what I need, but I'm ideally looking for someone to tell me exactly which method I should go with and how I should go about implementing the solution.

I hope that all makes sense!
Thanks


texts: I want a Notice message when save configuration

texts:
I have a module and a form with a checkbox...What i really want is when the user press the button save configuration to take a notice message..Could anyone know how to do this thing?

foreach (watchdog_severity_levels() as $severity) {
    $severity_options[$severity] = check_plain(drupal_ucfirst($severity));
  }

  // Generate checkbox list for given severity levels.
  $form['severity'] = array(
    '#type'        => 'fieldset',
    '#title'       => t('Select the severity.'),
    '#collapsible' => true,
    '#collapsed'   => true,
  );

  $form['severity']['severity_levels'] = array(
    '#type'          => 'checkboxes',
    '#options'       => $severity_options,
    '#default_value' => array_values($severity_levels),
  );

  return system_settings_form($form);
}


texts: How can I set Drupal 7 so that all incoming traffic is redirected to the homepage? I need to ensure all visitors go to the homepage, even if they click a link on some other site that links to example.com/section/node-1


texts:
I'm currently running my drupal site on a subdomain (a.example.com). I would like to temporarily redirect any requests to example.com and www. example.com to a.example.com.

Mark Trapp already offered a great solution using .htaccess files. In this case I would prefer to add a little module code. I was thing about checking $GLOBALS['base_url'] and then redirecting with drupal_goto(). Are those the right functions and which hook would I use?