texts: How to bulk create an extra node for each user

texts:
I need to create an additional node for each authenticated active user on a Drupal 7 site.

The nodes will be populated with default content from taxonomies, and also with some field content based on content owned by each user.

Something like :

create node with author=user1
field 1= populated from a taxonomy
field 2= Count of number of nodes of content type A authored by user1 that are
published
field 3= current date

And then loop through all active users creating a similar node for each one.

What's the best way to handle this?  Ideally I'd like to do it in a way so that the batch node creation job could be triggered by a scheduled Rule in future.

The idea is to provide a report showing a snapshot of the account status at a fixed time.


texts:
Views Slideshow on Drupal 8 gives me all kinds of 404 errors loading the js files. Missing files:

/libraries/jquery.cycle/jquery.cycle.all.js?v=3.0.3
/libraries/jquery.hoverIntent/jquery.hoverIntent.js?v=1.9
/libraries/json2/json2.js?v=2

Isn't the module supposed to take care of these dependencies?

Any tips on how to solve it?


texts: Accessing all VIEW data in a preprocess hook

texts:
I have the following hook method:

hook_preprocess_views_view_unformatted(&$vars)

I can obtain the VIEW like so:

$view = $vars['view'];

When I dump this result I can see a complex structure with all the data I need...the VIEW can be iterated via:

foreach ($view->result as $index => $record)

Each records data (node details) is navigable via the following path:

$record->_field_data['nid']['entity']->field_XXX

I am uneasy accessing these details with the second property in this chain as usually "underscore" represents private...maybe it is just the OO purist in mean telling me it's bad practice and I am defeating OCP. :)

Ultimately I need the ability to iterate my custom fields and this seems to be the only way I can achieve that -- is there not a API which would encapsulate this access for me?

I assumed the $view object itself would have an API to provide traversing methods or at least result iteration, but it doesn't appear that way.


texts: How can you hide "Your search yielded no results." when no keywords have been entered on the search page?

texts:
On the core default search page located at /search/node, if you visit this URI the page displays "Your search yielded no results." It displays this message whether keywords have been entered that truly have no search results, as well as when no keywords have been entered. It is odd to be presenting "Your search yielded no results." to users when they have yet to actually search for anything.

What's the most appropriate way to remove this message when no keywords have been entered?


texts: Provide a subset of the current theme settings page

texts:
I'm looking for a way to provide a subset of:

admin/build/themes/settings/<theme_name>

on a different path.

THEMEHOOK_settings doesn't appear to offer the necessarily granularity.

Ideally I would achieve this without re-implementing any of the theme subsystem.

Is there a way that I can pass the results from my own form into the theme system such that the configurations are saved in much the same way as THEMEHOOK settings is doing under the hood?

I'm happy to clarify if need be.

Thanks in advance.


texts: Adding javascript to drupal 7 is giving error

texts:
i am trying to add code using drupal_add_js and separate .js file. Its giving the Jquery is not found error.

(function ($) {
 function mobilizeCustomInit() {

                 // Add new Javascript and CSS files to mobile
                 // file loading list

                 // Note: Slashdot at the beginning of the filename
                 // indicates that the file path is relative to the HTML file location.
                 // This is an internal trick of mobilize.js.

               //  mobilize.cdnOptions.javascriptBundles.push("drupal/sites/all/themes/kanji/mobilize.yoursite.js");
               /**
 * This file is executed when the site is loaded in mobile mode.
 */

/**
 * This file is executed when the site is loaded in mobile mode.
 */

mobilize.extend(mobilize, {

    constructBody : function() {
        // Map different elements to jQuery Mobile theme
        this.constructHeader();

        this.constructContent();
        this.constructNavigation();

        this.constructFooter();
    },

    /**
     * Create mobile site header name and buttons
     */
    constructHeader : function() {
        // Map title and header buttons jQuery Mobile

        // This is the mobile target element
        // which will contain the title.
        $('.mobile-header').css('display','TRUE');
        var mobileHeader = $("#mobile-body div[data-role=header]");

        // Pick the current page title from  section
        var title = $("header h1").text();

        // Set mobile header title to the same text
        var h1 = $("h1").text(title);
        mobileHeader.append(h1);

    },

    /**
     * Move content area from web site to mobile site
     */
    constructContent : function() {
        var content = $("#content");

        // Place content HTML to mobile content area container
        var mobileContent = $("#mobile-body div[data-role=content]");
        mobileContent.append(content);
    },

    /**
     * Create mobile footer
     */
    constructFooter : function() {
        var footer = $("footer").children();

        // Place content HTML to mobile content area container
        var mobileFooter = $("#mobile-body div[data-role=footer]");
        mobileFooter.append(footer);

    },

    /**
     * Use jQuery Mobile nested list to create a navigation.
     *
     */
    constructNavigation : function() {

        // Get list of items which contain links for the navigation building
        var items = $("#navss li");

        // Create navigation list
        var list = $("
");

        // Add list header
        list.prepend("
Pages
");

        // Add list items
        items.each(function () {
            var output = $("
");
            output.append($(this).find("a"));
            output.appendTo(list);
        });

        // Put list below content
        var mobileContent = $("#mobile-body div[data-role=content]");
        mobileContent.append(list);

    }

});
                 mobilize.cdnOptions.cssBundles.push("./mobile-style.css");
            }
})(jQuery);


texts: How to programmatically update a user role name

texts:
I would like to update role name programmatically in Drupal 7. Does Drupal provide its own functions to do that, or do we need to query the database and  update the name manually?

Please note that this is not about changing the role a user has, but changing the name of a role.


texts:
I'd like to set up a simple gallery for users to upload pictures onto my D7 site, but uploading a bunch of images is sure to make my site run slower and my hosting costs go up. So I'm looking at a CDN (specifically, blob or object storage).

Both of the Azure modules (1 and 2) are not actively maintained, and the Amazon S3 module is still in beta, so I'd be hesitant to use it on a production site.

Here's my question: Is there any good Druapl module that will let me bypass the filesystem on the webserver so that users can upload images directly to a CDN? I know there are hooks in D7 that make this possible, but has anyone actually managed to do it yet? I can't believe there isn't better support for CDNs for Drupal. :(


texts:
I've got the following problem:

We've got a hosting with 2 domains applied (second domain (the drupal site) is pointing to a subfolder of the first domain):
    /data/user/www/   < php-docroot & web-root of first domain
    /data/user/www/domain2/   < web-root of second domain & drupal install

calling http: //domain2.tld/ succesfully showing the drupal site,
but instead of:
http: //domain2.tld/content/contact, drupal generates url like:
http: //domain2.tld/domain2/content/contact

I think the problem may be the php-docroot, which is the same for domain1 and domain2.

How to tell Drupal to supress the /domain2/ part in urls?


texts: Retrospective fix to hook_update_n() in current release

texts:
I need to make a correction to a hook_update_N() function in the .install file which is causing SQL constraint errors when some users upgrade to the new release version. The original worked fine providing they ran update.php manually right after upgrading. But some users started using the site before running update.php and then when the did run it they get SQL errors. Also some automated upgrade scripts get the error. In both cases the required update is not performed.

Backgorund details are in issue https://www.drupal.org/node/2706119

The correction is done and ready, but I do not necessarily want to make another release, as it was only three months ago for the last release. 18k users have upgraded but 34k have not yet, so it would be good if the fixed update_n() function could somehow be added into the current release. Is that possible? Can git tag the new commit into current version and then I re-release it again?


texts: Is the "access" table removed during upgrade?

texts:
When a site is upgraded from Drupal 6 to Drupal 7 (or any higher version), do the update hooks remove the access table?

I am developing a module that could import the content of that table, and I need to know if after updating to Drupal 7 that database table is not anymore present.


texts:
I'm using Drupal 7. A lot of text are using quotes like "text" or «text».
I want that for all older text on the site as well as for new text there will be one type of quotes used: «text».

Can you help me with that? Maybe some text filter or module can do this? Tnx for advice.


texts:
Is there any module which works the same as facebook's user wall?

On facebook's wall, users can post/share anything and friends can also post/comment.


texts: Disabling access to admin pages during maintenance

texts: I need to do some maintenance on a website that is updated by a number of contributors, what is the easiest way for me to disable access to the admin part of the website while I'm working on it?


texts:
I want to add block to front page as a new section On ours website, but I didn't succeed, please can you help me to do it? I used views to create it but when i create it doesn't show in blocks.

website: www.awene.com  (is a kurdish website in iraq) designed by drupal 6.

Best regards


texts:
How can I add a custom handler method to a view ?

For example, i add a custom handler in hook_views_query_alter like this:

$this->view->addHandler('page_2', 'filter', 'node__field_subsidiary', 'field_subsidiary_type_value', [], 'custom_handler_subsidiary_type');

how I manage the handler logic?


texts:
I have created vocabulary "Hospital" and created text and image fields like:

Hospital Image: (machine name: field_hospital_image) // image field
Hospital Contact: (machine name: field_hospital_contact_no_) // text field

My code is:

$vid = 'hospitals';
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
foreach ($terms as $term) {
  $term_data[] = [
    'tid' => $term->tid,
    'tname' => $term->name,
    'image' => ...???..,    // image field
    'contact' => ...???..,  // text field
  ];
}

Please suggest namespace also.

I alsready tried :

'contact' => $term->get('field_hospital_contact_no_')->getValue(),

and

'contact' => $term->get('field_hospital_contact_no_')->value,

Errors:

  Error: Call to undefined method stdClass::get()


texts: How to count the number of anonymous users that are currently using the site?

texts:
I want to either use a module or write a module which allows me to count the number of Anonymous Users that are currently using the site.

What is the best method for this to be achieved? I looked at the statistics module but this does not enable me to count the data. I discovered views is capable of  this with this setting, "Content statistics: Most recent views". But, there was no option for anonymous data.


texts: Commerce Paypal Payment Standard Currency Conversion

texts: I have integrated paypal payment standard using commerce paypal module in my website. I have 2 currencies my default currency is AED. Now I have 1500 AED in a cart When I am proceeding to checkout on paypal its showing 1500 USD. Isn't it possible that the amount converts in equivalent USD automatically ??


texts:
I have a custom autocomplete field widget, defined like below:

/**
 * Implements hook_field_widget_form
 */
function mymodule_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $element += array(
    '#id' => 'mymodule-field',
    '#type' => 'textfield',
    '#default_value' => '',
    '#autocomplete_path' => 'some/path',
    '#element_validate' => array('mymodule_autocomplete_validate'),
  );
  return $element;
}

I have a content type with 2 Term reference autocomplete fields: field foo with standard Autocomplete term widget (tagging) widget, and field bar with my custom autocomplete widget.

Field bar has a higher weight than field foo on a node form.

mymodule has weight 20 in system table. taxonomy module has weight 0.

However, when I submit a node form which includes both fields, mymodule_autocomplete_validate() is invoked earlier than taxonomy_autocomplete_validate(), so $form_state['values']['field-myfield-a'] is not processed yet.

The problem is I need to use the processed value of foo in mymodule_autocomplete_validate().

I have another 2 fields with same widgets but another names, and they are processed in the right order.

So the question is: how the order of execution of these functions is defined? Is there a way to change it?


texts: Charging UserPoints for flagging a node with Rules in PHP

texts:
I am trying to charge points for flagging a node with Rules in PHP, an I am using the following code.

 //Get variables and load user.
$uid = [userpoints-transaction:user:uid];
$account = user_load($uid);

// Check the user has enough points.
if ($loaded_points > 10) {

  // DON'T KNOW HOW TO TAKE 10 POINTS.

  // Flag a node.
  $flag = flag_get_flag('purchase') or die('no "purchase" flag defined');
  $flag->flag('flag', $node->nid);
  // Search for the newly created flagging entity.
  $flag = flag_get_user_flags('node', $node->nid);

  foreach ($flag as $flagging_object) {
    $flagging_id = $flagging_object->flagging_id;
  }

  // Load the entity found and create or update a field value.
  $flagging = entity_load_single('flagging', $flagging_id);
  $flagging->purchase['und'][0]['value'] = 'DONT KNOW DEFAULT VALUE OF FLAGGING';

  // Save the updated flagging entity object.
  entity_save('flagging', $flagging);
}

drupal_set_message($msg);

I don't know how to charge them 10 points and what the default value is when flagging a node.


texts: Load Pages Using AJAX to Allow for a Continuous Music Player

texts:
I'm looking to create a music player that will play continuously between page loads. After some research, I've decided AJAX is the best way to do this.

I'm looking to load all the site content using AJAX (minus the music player) in one container  and place the music player in a separate container div at the bottom of the page.

How would this be done? Thanks is in advanced!


texts: Some pages hide content unless "Read more" is clicked

texts: If I have multiple pages on Drupal, some show the full page, and others say "Read more" and will only show the whole page when it is clicked. It doesn't seem to have anything to do with the size of the content of the page or how long it is. What's up with that?


texts: Custom form using custom template, submit the form don't call its validate and submit handlers

texts:
I created a simple custom module where I created a Class Form using a custom template form. If I don't use my custom template (I comment my _theme hook from my .module), when I submit my form, class methods handlers validate and submit are called. But When I use my custom form template, If I submit my form, validate and submit class methods handlers aren't called, I don't understand why.

This is my code; I begin with my templates/form--myformtest-form.html.twig template.

TEST

<form{{ element }}></form>

My myformtest.module code is the following.

/**
 * Implements hook_theme().
 */
function myformtest_theme($existing, $type, $theme, $path)
{
  return array(
    'form__myformtest_form' => array(
      'render element' => 'form',
      'template' => 'form--myformtest-form',
    ),
  );
}

If I comment this hook, my form use the default theme form template. In this case, submit the form call validate and submit class handlers methods. If I don't comment this hook, my form use my custom template. Then when I access to my custom form page and valid the form, validate and submit handler are never called.

This is the simple code from my src/Form/MyformtestForm.php class.

class MyformtestForm extends FormBase {
  //...
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['textfieldtest'] = [
      '#type' => 'textfield',
      '#title' => $this->t('textfieldtest'),
      '#maxlength' => 64,
      '#size' => 64,
    ];

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

    return $form;
  }

  public function validateForm(array &$form, FormStateInterface $form_state) {
    ksm("MyformtestForm Validate handler!");
    // logs never displayed when I use my custom template. If I don't use the custom template, this log appears.
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    ksm("MyformtestForm Submit handler");
    // logs never displayed when I use my custom template. If I don't use the custom template, this log appears.
  }

Why handlers aren't called when my form use my custom override? How can I call them?

These are the variables existing from my custom template when I load my form page.


texts: Bearer Token in url is not parsed by route

texts:
I Installed Drupal 9.1.0 on a VPS running on Ubuntu 20.4 and using Nginx 1.18.0, with Composer 2.0.8.
I installed two modules (Token and Devel) and a theme (Barrio) using Composer. I can enable the modules without problem, but when I try to install Barrio and set it as default theme, I get an access denied error.
I tried to enable other themes, but I always get the same error.
I cleared the cache and installed the theme with Drush. Still, setting the theme as default one causes an error. In this case, the error in the log is the following one.
Path: /admin/appearance/default?theme=THEME_NAME&token=TOKEN. Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException: 'csrf_token' URL query argument is missing. in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 117 of /PATHTOSITE/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

...:: UPDATE ::...
I used to start debugging to check where exactly the problem happens and realized that in line 57 of /Drupal/Core/Access/CsrfAccessCheck.php where code says :
$request->query->get('token', '')
there results become '' , which means $request->query->token is empty. debugging backward I looked at many files including :
Drupal/Core/Access/AccessArgumentsResolverFactory.php where it produces $request for csrfCheck
Drupal/Component/Utility/ArgumentsResolver.php which is used in above file

and finally I got to the place where problem is started:
Drupal/Core/Routing/RouteMatch::createFromRequest
this method can not recognize the token in url and cause all other problems, but I still don't know what cause this method failure
could it be my Nginx configurations?
Nginx config is:
location / {
try_files $uri $uri/ /index.php?query_string;
}
One more thing , when I use dsm on request, token can be find in $request->requestUri (is shown as /admin/appearance/install?theme=stark&token=qI5_B99oNr4TWdNfu5aTdd01NezSpPKOZje8HCVOMEs), But $rquest->query["query_string"] is ""


texts: Why does library-extend not find the additional library?

texts:
I am using the Tara theme, which has a library global-styling. I have created a sub-theme of it, called Art. I want to extend the original library. My setup is as follows:

In themes/custom/art/art.info.yml

name: art
type: theme
base theme: tara
description: 'Art theme based on Tara'
package: Art
core: 8.x
version: 8.1.0
libraries-extend:
  tara/global-styling:
    - art/local-styling
regions:
  header_top: 'Header Top'
  site_branding: 'Site Branding'
  primary_menu: 'Primary menu'
  search_box: 'Full Page Search'
  page_top: 'Page top'
  page_bottom: 'Page bottom'
  highlighted: Highlighted
  breadcrumb: Breadcrumb
  content: Content
  content_top: 'Content Top'
  content_bottom: 'Content Bottom'
  content_home: 'Homepage Content'
  sidebar_first: 'Sidebar Left'
  sidebar_second: 'Sidebar Right'
  footer_top: 'Footer Top'
  footer_first: 'Footer first'
  footer_second: 'Footer second'
  footer_third: 'Footer third'
  footer_fourth: 'Footer fourth'
  footer_bottom: 'Footer Bottom'

And in art.libraries.yml

local-styling:
  version: 1.x
  css:
    theme:
      css/art.css: {}

The result of the page load is a WSOD and an entry in the error log of:

Uncaught PHP Exception `Drupal\\Core\\Asset\\Exception\\InvalidLibrariesExtendSpecificationException:  "The specified library "art/local-styling" does not exist." at /var/www/html/art/staging/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php line 149`

The sub-theme IS the enabled and default theme. Adding the path of its css file as an entry under the base theme's library results in the file being loaded.


texts: How to close (ctools) modal node/add form after submit?

texts:
I wrote this module that print the node/add form for a content type (article) in a ctools modal window. It works and the new node is saved, but the modal window remains opened after submitting the form.

I would like to automatically close the modal window after saving the node, end and optionally redirect drupal to the new node. Any hint?

      <?php

    function modaltest_menu()
    {
    $items['modaltest']            = array(
        'title' => 'Modaltest Page',
        'page callback' => 'modaltest_page',
        'access arguments' => TRUE
    );
    $items['modaltest/%ctools_js'] = array(
        'title' => 'Modaltest page 2',
        'page callback' => 'modaltest_page_modal',
        'page arguments' => array(
            1
        ),
        'access arguments' => TRUE
    );
    return $items;
}

      function modaltest_page_modal($js = NULL)
    {
      $nojs_message = t('Hello World');
    if (!$js) {
        return $nojs_message;
    }
    module_load_include('inc', 'node', 'node.pages');
    $form = node_add('article');
    ctools_include('modal');
    ctools_include('ajax');
    $output   = array();
    $output[] = ctools_modal_command_display(t('My modal test'), $form);
    print ajax_render($output);
    exit();
}

    function modaltest_page()
    {
    ctools_include('modal');
    ctools_include('ajax');
    ctools_modal_add_js();
    return ctools_modal_text_button(t('Popup link'), 'modaltest/nojs',      t('test popup'), 'ctools-modal-test-style');
    }


texts:
I want to theme the language switcher on my Drupal 7 site:

In the header of my site the language switcher shows the actual/selected language and looks like this:

"EN"
"▼"

If you click on the down array, the menue block slides down, shows all languages and looks like this (vertical layout, fly-down, without list-style dot):

"EN"
"FR"
"DE"
"SP"
"CN"
"▲"

If you click on the up array, the menue block closes und looke like above.

If you click on one of the language shortcuts the language of the site changes.

How can I realize this vertical arranged language switcher with slide effekt using jQuery?

How can I change the language labels and use shortcuts (EN, FR, SP, ..) instead?
Thank you very much.


texts: Styles and images are not available when installing

texts:
Can't figure out why but all drupal styles and images are not loaded when I'm trying to install it on server. It's obviously a problem with permissions but all directories from root to seven template dir permissions are 755 and template files are all 644 so I guess it should be readable.
UPDATE.
I checked status report and there are two things about files:

OK File system    Writable (public download method)
If the site is experiencing problems with permissions to content, you
may have to rebuild the permissions cache. Rebuilding will remove all
privileges to content and replace them with permissions based on the
current modules and settings. Rebuilding may take some time if there
is a lot of content or complex permission settings. After rebuilding
has completed, content will automatically use the new permissions.


texts:
Using a Drupal Multisite system, is it possible to have a base set of configuration settings shared across multiple sites?

That is, each site in Drupal has a settings.php file

default/settings.php
site1/settings.php
site2/settings.php
anothersite/settings.php

Is there a master settings.php where I could set a configuration value once and have it apply to all my sites?

Or is this normally handled at the deployment level?


texts: Display a block when a view doesn't return any result

texts:
On node/48, the page is composed from a text and a view. I would like to display a block when the view does not return any result.

How can I achieve this?


texts:
I'm using the jQuery Update module and decided to choose a more recent version of jQuery so in the module settings I changed it from 1.7.1 to 1.8.2

The issue I'm having is that the previous version (1.7.1) keeps getting loaded. So at the moment two versions of jquery are being downloaded. Its worth mentioning that I selected the Google CDN delivery method so the file comes from there.

I have no idea how to solve this. I disabled and uninstalled the module, manually removed the jquery_update_jquery_cdn from the variable table, cleared the cache, cron, restarted nginx and php-fpm, but still the issue persists.


texts: How to add a javascript field to custom content type

texts:
I have a custom content type called 'Visualisation'. I would like a user to be able to upload their own javascript file for each instance of the content type. I would then like to load this script on the page in which the content is displayed.

I have tried adding a custom field 'file', however Drupal doesn't allow javascript files and appends the file with 'txt'. How can I add a javascript file and then load when the content is displayed?

EDIT

As it seems unsafe to achieve this the way I've mentioned above I'll try and elaborate on what I'm trying to do.

The content type is for HTML5 canvas visualisations. Each visualisation will use a custom created script file. The whole content will consist of a title, canvas element, javascript file and description. I therefore need to attach a script to each visualisation.

Would it be better to have a field with just the name of the file and load it in the page template?

Many thanks for any help.


texts: Show 3 different Views displays for same exposed filter block or link Views displays?

texts:
So, I have a View which uses exposed filters which has the exposed form style set to block.

In my first view display, I have one page display which shows the content as teaser view for all results. The teaser of the content type is styled with a custom template (node--my-custom-type.tpl.php).

I then made 3 tabs using the "Quicktabs" module and put my view page as one of the tabs, and 2 generic PHP blocks as placeholders for the other 2 tabs.

I setup a Page in "Panels" (Page Admin) so that I can have the block above and the quicktabs content below. I might change the layout later on but for now it works fine.

My 3 tabs are therefore:

List

This the View Page (Teaser view of the content type)

Map

Currently a block placeholder but should be linked to the same View Page results

Other

Currently a block placeholder but should be linked to the same View Page results

Now, I want to know how can I set the Map and Other tabs to be different View displays for my View that are linked to the same exposed form in my first views display?

Furthermore, the Map and Other tabs would need to just get the custom field: field_id and append the values of all the results to an iFRAME - so I really just need to output PHP and nothing else, no fields or anything.

I suppose I could do this via another custom themed display for the content type... e.g. adding another teaser display type named custom-teaser?

However, how would I "link" all the results between the displays using the same exposed filter block?

UPDATE 17/2/13:

So I tried the "Attachment" display, however that just added the field_id to my "List" tab and I don't want the field to appear on that tab.

UPDATE 4/6/13:

I haven't looked into fixing this issue for a while, but getting back to it now.

So I want the end result to be:

A page with exposed filter and 3 tabs that show each different "view display"

Tab 1: Show results as Gallery (custom CSS styling)
Tab 2: Show results on a Map (results have IDs, would need to get the IDs and pass them to the Map as an array or string as a comma separated list)
Tab 3: Show results on another map using different fields

The results should all correspond to the same exposed filter and should be updated when you update the filter. I currently use Quick-Tabs but I can change to something else to make the tab effect.


texts: How to show different entity in Views with different displays?

texts:
I create a views with 2 displays.

One display show content type.

One display show taxonomy list that related above content type.

When I try to create a display with content type, then I can not create a display with taxonomy.

Content type and taxonomy are different entity, So How to show different entity in Views with displays?


texts: How can I change page elements (menu, blocks, etc) based on a chosen 'audience' link?

texts:
There are many sites which allow users to select their "customer type" or "audience", which then displays different information on the front page and provides them with navigation and content appropriate for their needs. Banks, higher-education institutions, and medical providers do this often (http://chase.com, http://aetna.com).

I'm looking for the best way to implement this on a site I'll be developing over the next few weeks. I need the main navigation to change per audience and I'd like to show specific content on the home page and sidebars based on that context. I don't think I want to use subdomains or multi-site; it seems that there should be a better way.

I'd like the URL structure to look like "mysite.com/audience1", "mysite.com/audience2", "mysite.com/audience3", and so on for the front page. Deeper pages would follow that url prefix ("mysite.com/audience1/products/tools")

There are also 'global' resources which any audience would find useful and I've been wondering about how I'd handle that use-case as well.

Should I look into panels, context, display suite, other modules? Any guidance is appreciated. Thanks!


texts:
I am working in a project where I have to upload files thru a Drupal site. I am having an issue since the files I am trying to upload have not extension. The files are text files, but without the .txt at the end and to be honest I don't mind if Drupal add .txt after the file name.

How do I define a file validator for files without extensions?


texts: DB log message: login failed for user xxx

texts: Does anyone ever get "Login failed by user xxx" messages in their recent log entries?  I have been getting the same message over and over for the past several days, always from the same IP address and user trying to access node/add.  It's kind of freaking me out.  Anything to be done about it?


texts:
I hope this question is in the spirit of Q&A.

I have to develop a module that manages complex datasets in Drupal and I have to decide if it is better to use Nodes or Entities to manage all the necessary stuff (there are pros and cons for any case).

I undestand the different concepts behind (what an entity is, and the relation between the concepts of node and entities), so my question is: when is better to use the former or the latter?

I don't know what: there is a guide, an intereseting experience, a checklist, or something else to allow developers to perform the rigth choice when starting the development? What a Node can do that is impossible to have with an Entity (and in the case is necessary to re-develop in the case)?

Thank you


texts: Show the cart icon only if it exists and it isn't empty

texts:
I'm looking for an easy way to show on my template a cart icon only if the cart has 1 or more elements (Drupal 8, commerce 2.x); I've tried with a view, but I had problems to identify the cart associated to the current (normally anonymous) user.

Does that easy way exist?

Can anyone point me in the right direction? I've searched on Commerce 2.x docs, but I didn't find anything about the feature I'd like to implement. (I don't want to show the cart, only show an icon when the cart exists and has items.)

I've also used suggestions found on How do I count the number of products in cart programmatically? and I was able to create a twig variable using theme preprocess function, but the variable is never updated. Is it mandatory to develop a module?


texts: How to change a fields label name based on another fields value?

texts:
I have a content type and it has two fields:

Field One (select list)
Field Two (text area)

What I want to do is to change Field Two's label name based on Field One's value in node add/edit page and node dipslay. If Option 1 selected in Field One field, then make the Field Two's label name Option 1 etc.

How can I do this?


texts: How to create a taxonomy terms dropdrown with Views

texts:
I need to achieve a block containing a dropdown list of vocabulary terms (called topics). Each topic describe one or many of the content articles. Each topic which is assigned to no articles should not be displayed. When selecting the topic from a dropdown list a page with assigned articles should be displayed.

It seems like achieving a dropdown list of terms from within a view is harder than expected.

Here my steps:
I created a View with display page and exposed form in block: Yes
I selected the term ID and term Name fields; then I expose the filters as "Operator: Is one of," and I selected all. It seems like nothings happens.


texts: Can use taxonomies to I build a list of "conditions" that can be added to and referenced from different nodes?

texts:
I need to build a list of "conditions" that can be added to and references from different nodes. "Conditions" have a title and body. This screamed taxonomy but what's stopping me is that the "conditions" need the ability to modify the body field on a node-by-node basis.

It's a bit difficult to explain but I need:

A library of content that can be referenced and can grow, like taxonomy.
When referenced, the content has to be able to be modified but only that instance (don't modify the referenced entity site-wide). This will will be like an override for the reference.

I can to the first part with taxonomies but don't know how to override on a node-by-node basis as it's just a reference. It seems as if the referenced entity needs to populate a field on the node, and there it can be overwritten.

EDIT: Found the solution using this: https://www.drupal.org/project/entityreference_autofill. I added a long text field on my taxonomy and my content and mapped them together.


texts: How to access field values from a custom block

texts:
How do you give a custom block (in a custom module) access to field values produced by the context of page?

eg: If the page has a field, say 'field_my_custom_id' and I want to use it for some purpose in the Build function of a custom block, how to access it from within my module?


texts: Show news articles only by the year selected

texts: I am working on porting a static site over to Drupal 7, and one of the pages I am porting is a Newsroom page that starts off by listing news articles (which are internal site pages, not links to other sites) and then below that are links to different years. The way the old site works is that when a year is clicked it hides the articles that are up and then shows the articles for that year. Is there a module/plugin that can do this or is there some other way than using javascript to hide and show the different articles?


texts: How to get nid and title from a node array

texts:
use Drupal\node\Entity\Node;

function abc($v) {
  $node = \Drupal\node\Entity\Node::load($v);
  print_r($node);
}

The array structure of $node is as given below

Drupal\node\Entity\Node Object (
[in_preview] =>

[values:protected] => Array
    (

   [nid] => Array
        (
            [x-default] => 166
        )

    [vid] => Array
        (
            [x-default] => 180
        )

    [type] => Array
        (
            [x-default] => sections
        )

    [uuid] => Array
        (
            [x-default] => 7759efc9-cfff-4d58-b392-8d60b9903323
        )

    [langcode] => Array
        (
            [x-default] => en
        )


texts: Numerous dependencies don't get installed with "drush en -y" command for rooms module

texts:
I tried to install the rooms module, obviously a very complex module with lots of dependencies, I tried with drush:

drush en rooms -y

This is the module:

https://www.drupal.org/project/rooms

But even after doing that, from the back end, tons of dependencies are missing.

Additionally, the Rooms page has absolutely no information on required dependencies...

Am I missing something here?


texts: Automatically evaluate an entered value, assign a taxomomy term to the field

texts: We have a user entry field "Budget" which would ultimately be displayed as a range in the published page. We would like to allow the user to enter an exact value (probably rounded to nearest 100), rather than having to choose a range – but have that value trigger the assignment of a taxonomy term to display the range. So it needs to be evaluated as greater than, less than. Any suggestions on how this could be accomplished without custom coding?


texts: Multiple Shipping Quotes After Upgrading Ubercart?

texts:
I have been using D6/UC2 on a big web store for a few years now. I upgraded with DRUSH a few months ago to 2.1, and with products added since then, uc_quote offers an additional First Class option that is too cheap, which is costing the client money. I have uc_quote echoing the request data for administrators, and it looks like there are two requests being sent to USPS quote API. Is it normal for two requests to be made?

Why would the cheap option would start appearing after an upgrade?


texts: 7 - Views Filter where one field equals Logged in User's Email field

texts:
On a custom content type I have created, there is a List(text) field called "Assigned to" that has a drop down selection of certain emails. (E.g user1@domain.com, user2@domain.com, user3@domain.com, etc.)

I have a separate view that displays fields from that content type.

I am looking for a way to filter results where the Logged in User's email field equals what is in the "Assigned to" field.

I thought of using a Contextual Filter, but that would require the user's email to be in the URL.

Could I use php code as a way to make the default contextual filter value equal the logged in user's email?

I have tried to use the following with no success:

global $user;
echo($user->mail);

Thank you.


texts:
I've got a form field that is empty ("") when I submit my form and I cant figure out where I am going wrong. The field in question is reason - as in the reason why this record is being changed. I also include vid because that field is set and passed properly. Full source code of the relevant form here

Form:

public function buildForm(array $form, FormStateInterface $form_state, $part = NULL, $vid = NULL) {
    $form = array();

    //...

    $form['wrapper_form_fields']['reason'] = [
      '#type' => 'textarea',
      '#title' => '*' . t('Reason:'),
      '#value' => '',
      '#rows' => 2,
      '#attributes' => [
        'maxlength' => 250,
        'class' => ['js-modal-reason'],
      ],
      '#prefix' => '
',
      '#suffix' => '
',
    ];

    $form['vid'] = array(
      '#type' => 'hidden',
      '#value' => $vid,
    );

    //...

    return $form;
  }

It appears to render out properly,

The parameter is passed in the HTTP request,

But when I dump it out in submitForm I get a blank value.

  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);

    $reason = $form_state->getValue('reason');

    echo "
";
    var_dump($reason);
    var_dump($form_state->getValues());
    echo "
";
    die;
    //...
  }

Output:

string(0) ""
array(7) {
  ["vid"]=>
  string(5) "78897"
  ["reason"]=>
  string(0) ""
  ["send"]=>
  object(Drupal\Core\StringTranslation\TranslatableMarkup)#1021 (5) {
  ...

Full source code of the relevant form here. One notable design decision is that most of the logic is in a parent class. I have a parent class InfusionCenterStatusForm that creates forms that will change the status of an instance of a content type. This base class is refined in child classes like InfusionCenterInactiveForm which will specialize the base form to set a record to be inactive.


texts:
I need to populate the file field with a value from the database (when editing a database row).

This is the code for the file field.

$form['file'] = array(
'#type' => 'file',
'#title' => t('Image'),
'#description' => t('Upload a file, allowed extensions: jpg, jpeg, png, gif'),
);

The variable $icon contains the value (e.g. icon.png).

In Drupal 7 I made this work with:

  '#type'         => 'managed_file',
  '#description'  => t('Icon file may be a jpg, bmp, gif or png format.'),
  '#default_value' => $default_icon,

How can I do this in Drupal 6?


texts: Create a user via the Installation profile

texts:
I am using Installation Profiles to automate the process of installing Drupal 7 websites

I would like to create a user via the installation profile and assign it a username, password and email address, plus give it a role (This will be a special administrative user that I want every website to have).

How can I do this?
This is the closest tutorial I can find. However, it requires you to set a username/password and email address manually. I would like to store a default values for all these fields.


texts:
got a situation with flags, rules and node type...

I have an event website where people can add events to their own calendar. Once the event is completed, they can then edit their "registration" to add comments and other details.

I am acheiving this using Event type, Flags and action.
Node type: Event
Node Type: Registration
Flag: Add to calendar (attached to the event)

When the event is flagged by the user, a rule is set to to create a registration and update some field to link to the related event and keep the flag id in the registration.
Another rule is triggered if the Registration is deleted, it unflag the event.

Not sure if there's a better way to do this? Any suggestions? Better practice?
It's working, but the problem I have is that it's taking a lot of time to load the edit form of the registration. I am going to try the token tree optimisation, but if there is a better solution, I'm willing to give it a try.
Also, using the current system, it creates a node for every event added to the user calendar.

Thanks


texts: How to test hooks for custom module in PHPUnit kernel tests

texts:
I have a custom module file that has one hook:

mymodule.module:

function mymodule_node_presave(Drupal\Core\Entity\EntityInterface $node) {
  if (isset($node->original)) {
    $orig_node = $node->original;
    if($orig_node->hasField('field_intro')) {
      if ($orig_node->get('field_intro')->value !== $node->get('field_intro')->value) {
        $current_user = \Drupal::currentUser()->getUsername();
        Drupal::logger('mymodule')->notice('Lead changed from @original to @new', [
          '@original' => $orig_node->get('field_intro')->value,
          '@new' => $node->get('field_intro')->value,
          '@nid' => $node->id(),
          '@user' => $current_user,
        ]);
      }
    }

  }
}

And I am trying to test that this works in a PHPUnit kernel test like so:

MyModuleKernelTest.php

protected function setUp() {
    parent::setUp();

    $this->installSchema('dblog', 'watchdog');
    $this->installEntitySchema('node');
    $this->installEntitySchema('user');

    $fieldIntroMock = $this->getMockBuilder(FieldItemListInterface::class)
      ->disableOriginalConstructor()
      ->getMock();
    $fieldIntroMock->expects($this->any())
      ->method('__get')
      ->with('value')
      ->willReturn('hello');

    $this->node = $this->getMockBuilder(Node::class)
      ->disableOriginalConstructor()
      ->getMock();

    $this->node->expects($this->any())
      ->method('id')
      ->willReturn(1);

    $this->node->expects($this->any())
      ->method('__get')
      ->with('field_intro')
      ->willReturn($fieldIntroMock);
  }

 /**
   * Test pre-save hook.
   */
  public function testPresave() {
    $this->node->set('field_intro', 'hello world');
    $storage = $this->createMock('\Drupal\Core\Entity\EntityStorageInterface');
    $this->node->preSave($storage);
    $pgsql_connection = Database::getConnection();
    $result = $pgsql_connection->select('watchdog', 'w')
      ->fields('w', ['type', 'variables', 'timestamp'])
      ->condition('type', 'mymodule')
      ->execute();

    $this->assertCount(1, $result);
  }

However the query above continually gives back a count of 0. Is there some configuration I am missing to allow for the presave hook to fire on saving the mock node?

Thank you.


texts:
I've twice followed these instructions to install Drush 8.
At the end of the process I can run Drush anywhere and it responds as expected.

However, whenever my server connection is broken and I log back into the server, Drush no longer responds.

Can anyone point out why that is happening?

MORE DETIALS:

I honestly don't know what the issue is. I get the following message each time I go through the process of reinstalling Drush:

sisko@localhost:~/bin/drush-master$ drush
No command 'drush' found, did you mean:
 Command 'rush' from package 'rush' (universe)
drush: command not found

I tried another tutorial attempting to install it manually with no success - just the message I pasted above.

I tried running sudo apt-get install drush and it was not found.

If it helps, I am running PHP 7.0.22 on ubuntu 17.04 as shown in the following (and I'm trying to install drush for a Drupal 7 site):

sisko@localhost:~/bin/drush-master$ php -v
PHP 7.0.22-0ubuntu0.17.04.1 (cli) (built: Aug  8 2017 22:03:30) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.22-0ubuntu0.17.04.1, Copyright (c) 1999-2017, by Zend Technologies

The server shell:

sisko@localhost: echo $SHELL
/bin/bash

UPDATE:
I am still experiencing the persistent loss of the Drush command on my server each time the ssh connection drops.
I then have to re-introduce the Drush command by following these steps as detailed by @Sarika:

echo $PATH ---> confirms Drush is **NOT** included in the path
export PATH="$HOME/.composer/vendor/bin:$PATH"
source ~/.bashrc
sudo composer global require drush/drush:8.*


texts: Create a draggable table and save weights

texts:
I'm struggling a bit with creating a draggable table.

I want to have a table that lists node labels, where it's possible to rearrange the order of the nodes. The new weights shall be available when I submit the form.

This is my code so far:

$rows = [];
foreach ($nodes as $node) {
  $weight = $node->weight;

  $row = [
    'weight' => $weight,
    $node->label(),
  ];

  $rows[] = [
    'data' => $row,
    'class' => ['draggable'],
    '#weight' => $weight,
  ];

  $form['table'][$node->id()]['weight'] = [
    '#type' => 'weight',
    '#title' => t('Weight'),
    '#title_display' => 'invisible',
    '#default_value' => $weight,
    '#attributes' => [
      'class' => [
        'draggable-weight'
      ]
    ],
  ];
}

$form['table'] = [
  '#type' => 'table',
  '#header' => [
    $this->t('Weight'),
    $this->t('Title'),
  ],
  '#rows' => $rows,
  '#attributes' => [
    'id' => 'my-module-table'
  ],
  '#tabledrag' => [[
    'action' => 'order',
    'relationship' => 'sibling',
    'group' => 'draggable-weight',
  ]],
];

When I kint($form_state->getValues()) in my submit handler table is equals to ''.

I feel like I'm missing something simple, but the lack of documentation for this makes it hard to find out.


texts: I installed Open Atrium, and there are no default features showing under the features admin panel. No shoutbox, wiki, blog or calendar. Did I choose a stripped down version of Open Atrium to install by accident?


texts: How to associate a product cost to a product in Drupal Commerce?

texts: I have to purchase each of my products from my manufacturer.  I want to store the cost for each product, so I can run reports and get my gross profit.  I have not found any site that demonstrates how to do this.  It seems like this should be basic for Drupal Commerce.  Am I using/searching for the wrong terminology?


texts: Custom DatabaseConnection driver does not get found by drupal!

texts:
I need to customize a method on the DatabaseConnection_sqlsrv (MSSQL) driver, so i created a new driver class called DatabaseConnection_sqlsrvseed and extended all depended classes  from the *_sqlsrv classes.

class DatabaseConnection_sqlsrvseed extends DatabaseConnection_sqlsrv {
  public function driver() {
    return 'sqlsrvseed';
  }
  public function databaseType() {
    return 'sqlsrvseed';
  }
}

Basically all other classes in the database/sqlsrvseed folder are empty classes that inherit their functionality from their parents like this one:

class InsertQuery_sqlsrvseed extends InsertQuery_sqlsrv {}

I am doing this because i need a modification on createFieldSql in DatabaseSchema_sqlsrv to create IDENTITY fields with a Seed value.

However, whenever i set

$database['default']['default']['driver'] = 'sqlsrvseed'

i get the error:

  Fatal error: Class 'DatabaseConnection_sqlsrvseed' not found in
  C:[...]\includes\database\database.inc on line 1686

Although i am pretty sure that the class and all dependencies exist.
I did excactly everything like they did it in the sqlsrv driver:

  Drupal and the SQL Server driver Uncompress Drupal in the web root.
  Uncompress this driver as sites/all/modules/sqlsrv, and copy or link
  the sqlsrv directory found inside it in includes/databases.

So I copied the files from database folder as well as the module folder. But there is a strange difference. I can't activate my custom driver module, whereas i can activate sqlsrv one. Any help? How does drupal gets to know this driver, without core modification?


texts:
Background

I have a large table with lots of values and want to check if any of the names are repeating and only display those results. I have built a view and cannot get the SQL query to return the result I want.

Code

Here is the code as it stands, I've done loads of variations of it but cant get the result and think that there must be a core problem with my logic.

So I have built a view and selected a couple of column and now I want a column that will print out the name of the title the number of times it appears in the database. Or just count the number and print that.

<?php
  $value = $row->title;
  $query= "SELECT node.title, node.type
           FROM {node} node
           WHERE  (node.type IN ('institution')
           AND node.title  =".$value.")";
  $result= db_query($query);
  $wat = $result->fetchAll(PDO::FETCH_COLUMN, 0);
  foreach($wat as $res){echo $res;}
?>

So as you can see I get the value of title at the row I'm on and compare it to every value for title in the database, then return only results that match. After that I loop through them and get the value printed.

I have managed to get all the titles out and print them but as soon as i bring $value into it it breaks. I have checked the value of $value and it returns the expected result. I just cant figure out what is wrong with my SQL query.

Question

What is wrong with my Query? is there something that stops me using the $row->title in drupal that I don't know about?


texts: How to restrict block for particular subpath, yet allow for all other subpath of a specific parent path?

texts:
I have created the custom page and assigned for the Underwriting content type nodes like underwriting/, but I want to restrict the block for a node of that content type; for example, show it for underwriting/, but not for  underwriting/example.

Is it possible to restrict a block for particular sub-path, and allow it for all the other sub-paths of a specific path?


texts: How to know add/edit page in hook_form_alter?

texts:
I want to know whether form is add/edit in hook_form_alter. In Drupal 7 we can get all these in hook_form_alter.

I tried like this in D7:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  // Check pages(s) , don't use $_GET.
    if (strpos($form['#action'], '/add/') !== FALSE) {
      $page = 'add';
    }
    if (strpos($form['#action'], '/edit') !== FALSE) {
      $page = 'edit';
    }
}

Here I am getting add/edit in D7. Whereas in D8 I am not getting any it in $form['#actions']. And i don't want to use $_GET.
Is there any way to check add/edit page in hook_form_alter.


texts: How can I add admin comments to webform submissions?

texts:
First time question, apologies for any mistakes.
I'm using the workflow module maestro, and in combination with webform i am attempting to add a section to show admin level comments as part of a moderation workflow.
I haven't attempted much yet but could use some suggestions on how best to achieve this?
I could make the webform a node and attach a comment block with permission controls, i could write a custom maestro module and add a custom task to achieve this also.


texts: How can I view what causes a page to load slow?

texts:
i currently have the devel module on and i'm trying to figure out why my site is slow. I get the following info line:

Page execution time was 4661.1 ms. Memory used at: devel_boot()=3.27 MB, devel_shutdown()=65.39 MB, PHP peak=70 MB.

Is there a way to view why my page is taking 4661 ms to load? Here's a view of what the page is loading:


texts: Code to add node add form to a custom block (not working)

texts:
I am trying to use code below to display node add form for a custom content type in a custom block.

Any guidance on why the code below may not be working is sincerely appreciated.

function stories_block_info(){
  $blocks['post_story'] = array(
    'info' => t('Post a Story - Neil Block'),
    'cache' => DRUPAL_NO_CACHE,
  );

  return $blocks;
}

function stories_block_view($delta = ''){
  switch ($delta) {
    case 'post_story':
      $block['content'] = drupal_get_form(stories_node_form);
      // $block['content'] = block_contents($delta);
      break;
  }

  return $block;
}


texts: While I can filter on content types in Workflow / Data Alterations I do not see anything for roles when adding users. Is it somewhere else or is it something needs to be developed? If the latter, where can I find some pointers, examples on how?


texts: hook_library: if two libraries share common file, might this cause files to get loaded in wrong order?

texts:
I am using hook_library to define two libraries:

mymodule_views_plugin_style_library
mymodule_views_plugin_row_library

The "style" library gets loaded in my custom style template:  drupal_add_library('mymodule', 'mymodule_views_plugin_style_library')

The "row" library gets loaded in my custom row template:  drupal_add_library('mymodule', 'mymodule_views_plugin_row_library')

Each library contains 3 javascript files, which must be added in the specified order.

The style library contains these 3 files:

mymodule_views_lib.js
mymodule_views_style1.js
mymodule_views_style2.js

The row library contains these 3 files.

mymodule_views_lib.js
mymodule_views_row1.js
mymodule_views_row2.js

Note that both the "style" and "row" library have a file in common (mymodule_views_lib.js) and that this file needs to load first.

Here is my hook_library code:

function mymodule_library() {
  $path = drupal_get_path('module', 'mymodule');
  $libraries = array(
    'my_views_plugin_style_library' => array(
      'js' => array(
        $path . '/mymodule_views_lib.js' => array('group' => JS_LIBRARY),
        $path . '/mymodule_views_style1.js' => array('group' => JS_LIBRARY),
        $path . '/mymodule_views_style2.js' => array('group' => JS_LIBRARY),
      )
    ),
    'my_views_plugin_row_library' => array(
      'js' => array(
        $path . '/mymodule_views_lib.js' => array('group' => JS_LIBRARY),
        $path . '/mymodule_views_row1.js' => array('group' => JS_LIBRARY),
        $path . '/mymodule_views_row2.js' => array('group' => JS_LIBRARY),
      )
    ),
  );
  return $libraries;
}

My problem:
The file mymodule_views_lib.js does not load before mymodule_views_row1.js.  It does not load until the "style" library (which happens to load after the "row" library) is loaded.

Question #1:
I see here that there is a solution to my problem:  I can create a separate library for the common js file, and then add this library as a dependency.  I am wondering, though, whether this is the only solution.  Is it possible to specify the relative load order when two different libraries share a common file?

Question #2:
Assuming my libraries do not share any js files, is it safe to assume that the library files will be loaded in the same order in which they are listed, in hook_library?  Or must I explicitly specify a weight?

UPDATE

I added a weight to each js file, as suggested by tenken below, and that solved the problem.  The javascript files now load in the desired order:

   function mymodule_library() {
      $path = drupal_get_path('module', 'mymodule');
      $libraries = array(
        'my_views_plugin_style_library' => array(
          'js' => array(
            $path . '/mymodule_views_lib.js' => array('group' => JS_LIBRARY, 'weight'=>1),
            $path . '/mymodule_views_style1.js' => array('group' => JS_LIBRARY, 'weight'=>2),
            $path . '/mymodule_views_style2.js' => array('group' => JS_LIBRARY, 'weight'=>3),
          )
        ),
        'my_views_plugin_row_library' => array(
          'js' => array(
            $path . '/mymodule_views_lib.js' => array('group' => JS_LIBRARY, 'weight'=>4),
            $path . '/mymodule_views_row1.js' => array('group' => JS_LIBRARY, 'weight'=>5),
            $path . '/mymodule_views_row2.js' => array('group' => JS_LIBRARY, 'weight'=>6),
          )
        ),
      );
      return $libraries;
    }


texts: is there a way to find out which quicktab tab is active?

texts:
I would like to know which tab is active so I can set it to default until another tab is active then that will be set to default

my problem is that I cant seem to find a way to see which tab is active at the moment and getActiveTab seems to always return the default tab

any help well be greatly appreciated

thanks in advance


texts: How do I say to Twig where to look for the template files?

texts:
I want to add another path where the templates are stored. In standard PHP I'd use $loader->addPath('../path/to/templates'). I found Twig_Loader_Filesystem::addPath(), but I have no clue where and how to use it.

Is there any hook?


texts: Trying to print results of Apache Solr Search

texts:
I'm trying to print to Drupal message, the indexed items as an object in Drupal.

Here's what I have so far:

function resource_library_search_apachesolr_process_results(&$results, DrupalSolrQueryInterface $query){
    drupal_get_message(print_r($results, true));

    }

I'm not seeing any results on any of my search pages - am I doing anything wrong? How do I get information on the indexed items as an object?


texts: What is the difference between l() and url()?

texts: Why does Drupal provide l() and url(), which seems to have the same purpose?


texts: Overriding the logic of "request new password" in Drupal?

texts:
I currently have:

function mymod_menu() {
    $items['user/password'] = array(
        'title' => 'Request new password',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('user_pass'),
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
        'file' => 'user.pages.inc',
    );
}

mymod_form_alter() {
if ($form_id == 'user_pass')
    {
        // do form alterations here...
    }
}

The first part isn't really necessary for editing the form. But my problem isn't the form. My problem is that I don't know how to change the IMPLEMENTATION of this form. I want the change the way the entire "forgot password" process works. I have a fully integrated login solution that relies on a separate database, and I now need to be able to access that database to generate a unique forgotten password url, based on different validation rules.

What would I have to override to change the way the forgotten password page works?


texts: How built in functions like theme_field() are called in drupal?

texts:
I have function theme_field() in my field.module. But I don't know how it's getting called. I have searched entire drupal project for the function calling statement . But I couldn’t find it. How this function is getting invoked? Please advice.

function theme_field($variables) {
//    print_r($variables);
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '
' . $variables['label'] . ':&nbsp;
';
  }

  // Render the items.
  $output .= '
';
  foreach ($variables['items'] as $delta => $item) {
    $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
    $output .= '
' . drupal_render($item) . '
';
  }
  $output .= '
';

  // Render the top-level DIV.
  $output = '
' . $output . '
';

  return $output;
}


texts: How can I insert Javascript right before the body in my custom theme?

texts:
I want to make the same jquery menu in my custom drupal theme but I could not insert the inline script right before the body.

I made a separate JavaScript file, and added to my custom .info file, but this is not the right way to insert inline JavaScript, obviously.

This is my info file.


texts: How to access node field from field template?

texts:
Afternoon all,

I have a node of type X.  This node has a list field and a field collection.  I've created a node template for node type X and a field template for the field collection.  From within the field collection template, I need to be able to check the value selected of the list field.  Is there a way to pass this value from the node list field to the field template?

I thought that the best way to achieve this would be to use a field template specific preprocessor in template.php (mytheme_preprocess_field__field_collection()), but that function won't fire.  I can set a variable in the generic 'field' preprocessor in my $vars array, but don't have access to the $variables array, where I've added the value for the list field.

Any help would be appreciated.  Thank you for your time.

current template.php code:

function mytheme_preprocess_node__X(&$variables) {
    $node = $variables['node'];
    $node_wrapper = entity_metadata_wrapper('node', $node);
    if ($node_wrapper->field_collection_field->value()) {
        $variables['field_collection_field_value'] = $node_wrapper->field_collection_field->value();
    }
    else {
        $variables['field_collection_field_value'] = 'not found';
    }
    dsm($variables['field_collection_field_value']);

}

function mytheme_preprocess_field(&$vars, $hook){
  $vars['field_collection_field_check'] = 'setting the variable manually';
}


texts: How can I re-write feeds xpathparser data?

texts: I have a feed content type with an author(s) field. Some of the nodes have several authors, so I am able to explode the data into an array with feeds tamper. However, I'd also like to re-write the author entries from LAST_NAME, FIRST_NAME to FIRST_NAME LAST_NAME. Before I dive into writing a plugin, I was wondering if there were another option for this, it seems like a common use case.


texts: Form not receiving a CSS class, it's block wrapper does instead

texts:
I have a custom form built with Form API that I am trying to add a class to on the form tag.

In the buildForm method, I have:

$form['#attributes']['class'][] = 'hl__single-input-form__form';

But the class doesn't appear on the form tag. Instead, the class appears on the div wrapper for the block that outputs the form.

In the block, the build method has:

  /**
   * {@inheritdoc}
   */
  public function build() {
    return $this->formBuilder->getForm('\Drupal\harlib_newsletter_signup\Form\NewsletterSignup');
  }

The only way I have been able to solve this is with a custom twig file with the following:

<section class="hl__single-input-form">
  <form{{ attributes.addClass('hl__single-input-form__form') }}>
    {{ children }}
  </form>
</section>

But the twig shouldn't be necessary. I also notice that the form id as a css class also goes on the block wrapper, too. What is happening here?


texts: Body Summary field showing literal ampersand character code in view

texts:
I have a Drupal 8 site where we've created a view, and decided to use the summary field instead of the trimmed body field, so that we could have more control over it.

However, I got a bug report that the page had funny characters. When I looked, I found that a literal ampersand character, &, was changed to the HTML code &amp;.

Thinking this was some weirdness introduced by our settings and configuration, I built a view on a clean install of Drupal 8.7.3 and generated some nodes with devel_generate. Sure enough, the ampersand HTML code appeared.

Node:

View Page preview:

View Page:

So, I want to get this to display a regular ampersand, as the user entered it.

I found this question explaining how to modify a twig template to use the raw value, but I'm not sure that's what I want to use. I don't want raw values for the whole field-- users could enter HTML in the summary field; I just want a non-encoded ampersand.

How do I get unencoded ampersands in the summary field in a view?

Edit leymannx recommended to uncheck Display any HTML as plain text on the text formats filter. However, both on my test fresh install and my real site, that filter is not checked, for any format.

I did my fresh install from downloading the Drupal core, and I think leymannx  user composer, so I am going to try that, to see if I get the same behavior as he does.  Also, I'm not going to install the devel modules to generate content, I'm just going to do one by hand.

These are screenshots from my fresh install:

Also a screenshot from my actual environment:

So, from those settings, it doesn't seem like the filter is what's causing this behavior.

Edit 2 I found something that I now suspect as perhaps the source of the error. The view on the fresh install is a view of files. I did not find the summary field in the list of fields, so I added a body field and re-wrote it with {{ body__summary }}. This is the config export yaml of the view I created.


texts: Which should I use and when: node_load() or entity_load()?

texts:
Title says it all.

I understand that entity_load provides a performant and efficient means to load multiple nodes whilst reducing database queries, so I presume in that instance I should be using entity_load(). But when I just want one node, which should I use? And will node_load() be deprecated in d8 in favour of the more generic entity_load() api?

I guess the same question goes for the familiar user_load() too.


texts: Only allow certain roles to publish content, other roles can save as unpublished?

texts:
I have a Content Admin and a Translator Roles.

Content Admin's can create, edit, delete, and publish content (this is working fine)

Translator's shouldn't be allowed to publish content, they should only be able to create and edit translations. (it should save as unpublished).

Anyone know how to achieve what I'm trying to do in Drupal 8? Or know if a module that does this has been ported to Drupal 8?


texts: I'm frustrated. I'm trying to import products and sales history to get a Commerce Kickstart 2 store running. I didn't find out how fraught this is until -after- the site was mostly done. The Commerce Kickstart Migrate module and Migrate seem to be incompatible. I've tried upgrading the Migrate module and it throws several PDOExceptions. Does anyone have a solution for taking spreadsheet or SQL data and importing into Commerce products?


texts: Content REST view does not work because of moderation states

texts:
I've created a simple view using the REST export to export all published content in JSON format, but I get this error:

Symfony\Component\Routing\Exception\RouteNotFoundException:
    Route "entity.moderation_state.canonical" does not exist.
    in Drupal\Core\Routing\RouteProvider->getRouteByName()
    (line 191 of core/lib/Drupal/Core/Routing/RouteProvider.php).

Drupal\Core\Routing\UrlGenerator->getRoute('entity.moderation_state.canonical') (Line: 285)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.moderation_state.canonical', Array, Array, 1) (Line: 110)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.moderation_state.canonical', Array, Array, ) (Line: 754)
Drupal\Core\Url->toString() (Line: 291)

Moderation states have indeed been added, but I have no idea why that's throwing this kind of error...


texts:
I have a search results View which list the (Commerce) products. I show the title and the image fields. I those fields to wrap in a custom <a> link tag. When I am adding fields, I miss the 'Link to product' field, so I am able to rewrite the fields and use the path {{ path }} token and theme it to my needs.

Do I miss or do I have to activate something?


texts:
Is there a way we can specify which link to use to sort a drupal table, or atleast, specify some parameters to the header links?

To be more clear, my table uses the following link when I click on the headers to sort the table: http://mysite.com/node?sort=asc&order=Name

What I would like the header link to look like is this: http://mysite.com/node?nid=123&pager_element_id=3&sort=desc&order=Name

Is there any way we can give the parameters to the header links?


texts: Which tables can i share in multilingual multi-site installation?

texts:
I have a multi-site installation with different databases. I've shared i18n_; language; locale_ tables. On the main installation several languages work just fine.
But on the others sites which i am trying to use also with multilingual settings i can't get language switcher appear whatever i try. They don't want to use prefix between nodes. Translated nodes are connected but there's no way to switch between them.
Please could you give advice which tables am i able to use to have shared translations without problems?


texts: Rendering field with the help of functions

texts:
I have a field and I can render its value in a such way:

<?php print $entity1->field_list_of_options['und'][0]['safe_value'];?>

But I have many different entities at the page so I want to hide the following tail in a function in order to get something like this:

<?php print $entity1->Get_list(); ?>

How can I do it? I tried to get predefined functions in a custom module but couldn't find a proper hook. How can I handle this problem?

I wrote the following in order to collect my "tails":

function mymodulename_getText($entityId,$field){
    return $entityId->$field."['und'][0]['safe_value']";
}

And so, I use it in such way:

<?php
$enityId = 2;
$entity2 = entity_load_single('entitytype', $entityId); ?>

<?php print getText($entity2, field_list_of_options); ?>

But I don't know how to implement my function to my custom module in order to get it in node's body where I want to print it using PHP Filter.


texts: Can Drupal's search index external tables?

texts:
Can Drupal's search system index external tables?
I have looked up how external tables can be linked to Drupal using the Data module, hook_views_data etc.,
Can the content of the external tables be indexed and searched by Drupal's search system?


texts:
I don't think this is hard at all but beeing a beginner at PHP and Drupal I need some help to do this.

I want to be able to add classes to my navigation elements that are outputted with this code:

function mytheme_menu_link__menu_block__1($variables) {

$element = $variables['element'];

$sub_menu = '';

if ($element['#localized_options']['attributes']['title'] != 'misc' && $element['#localized_options']['attributes']['title'] != 'something') {

    if ($element['#below']) {
        $sub_menu = drupal_render($element['#below']);
    }

    if ($element['#original_link']['in_active_trail'] == 0) {
        $output = ''.$element['#title'].'';
    }
    else {
        $output = ''.$element['#title'].'';
    }

    $link = l($output, $element['#href'], array('html' => TRUE));

    return $link;
}
else {
    return '';
}
}

If the menu item is active, it should have class X, otherwise class Y.
Could someone explain how I add this?

------------------------- Correct Answer -------------------------------

Here is the correct code that longboardnode helped me come up with.

function mytheme_menu_link__menu_block__1($variables) {

$element = $variables['element'];
$sub_menu = '';

if ($element['#localized_options']['attributes']['title'] != 'misc' && $element['#localized_options']['attributes']['title'] != 'something') {

    if ($element['#below']) {
        $sub_menu = drupal_render($element['#below']);
    }

    if ($element['#original_link']['in_active_trail'] == 0) {
        $output = $element['#title'];
        $class = 'activeClass';

    }
    else {
        $output = $element['#title'];
        $class = 'otherClass';

    }

    $link = l($output, $element['#href'], array('attributes' => array('class' => array($class)), 'html' => TRUE));

    return $link;
}
else {
    return '';
}

}


texts:
I manage a small drupal (openAtrium) site at work that we use for project management. Last week the wysiwyg textbox used to edit content stopped working. By stopped working I mean html was displayed regardless of the setting chosen. At the time I was using tinyMCE although since this I have tried CKEditor and openwysiwyg to no avail. For some users this only only an irritation but for others, who relied on the wrodprocessor features of wysiwyg mode it's more of a show stopper.

I can't find any error messages or indeed any indication that something is wrong in drupal. In terms of browsers I do get one JS error which maybe related.

Error: Syntax error, unrecognized expression: select:[name="field_oa_section[und]"], select:[name="field_oa_space_type[und]"]

All browsers I have tried (IE, Firefox, Chrome, Konqueror) are affected. Does anyone have any ideas? I can't find anyone else who has experienced similar problems.

Thanks.


texts: Considerations displaying page titles in page or node template

texts:
This is very similar to this, hopefully its different enough to warrant its own question: How to display a field before node title?.

On our Drupal sites we have a dozen content types, many of which have custom node templates to control how they are rendered. We like this setup because our design/web production team can edit the template files easily but not more heavy drupal code.

However, we currently have only 1 page.tpl.php (we have a custom theme loosely based on bartik). In this template, we have ugly if-statements to make the page print different things based on the content type. Unfortunately, as the number of nodes increases this page.tpl.php is becoming unwieldy. The problem is that each node usually has different fields printed above and below the title, and usually modifies the ID of the title attribute.

What are the alternatives to adding more IF-statements into the page.tpl.php?

Move the printing of the title (and content above and below the title) down into each node.tpl.php
Modify the way that we are adding content above and below the title to use the existing title_prefix and title_suffix arrays
other?

If we switch to render arrays method, I worry that coming up with the ordering and formatting of the content above and below the title will become more difficult for non-coders.


texts: How to get a list of entities programmatically?

texts:
I wrote custom rules action to get a list of active simplenews subscribers, but I can not process it with "loop" cycle. Action should get list of active simplenews subscribers ("entity_fetched" array). Then I pass it to "loop" for processing (and to get "list-item" variable) and there are no errors. But when I try to set status message (add action - system - set message) with "list-item:uid", system says: "Data selector list-item:uid for parameter message is invalid". More, I can not select "list-item" token at all. I think, there are some mistakes when the code returns "entity_fetched" array. There is my code:

<?php

   function custom_simplenews_rules_rules_action_info() {
      $actions = array(
         'custom_simplenews_rules_actions_get_subscribers' => array(
            'label' => t('Get subscribers by Simplenews Newsletters category'),
            'group' => t('Custom'),
            'parameter' => array(
               'category' => array(
                  'type' => 'text',
                  'label' => t('Category'),
                  'options list' => 'custom_simplenews_rules_options_list',
                  'description' => t('Specify category to select users from'),
               ),
            ),
            'provides' => array(
               'entity_fetched' => array('type' => 'list', 'label' => t('Fetched entity')),
            ),
         ),
      );

      return $actions;
   }

   function custom_simplenews_rules_options_list() {
      $taxonomy_vids_objects = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE module = :module", array(':module' => 'simplenews'))->fetchAll();

      $taxonomy_vids_array = array();
      foreach ($taxonomy_vids_objects as $value) {
         $taxonomy_vids_array[$value->vid] = $value->vid;
      }

      $taxonomy_vids = implode(',', $taxonomy_vids_array);
      $taxonomy_tids = db_query("SELECT tid, name FROM {taxonomy_term_data} WHERE vid IN (:vids)", array(':vids' => $taxonomy_vids))->fetchAll();

      $categories = array();
      foreach ($taxonomy_tids as $value) {
         $categories[$value->tid] = $value->name;
      }

      return $categories;
   }

   function custom_simplenews_rules_actions_get_subscribers(&$category) {
      $categories_array = array();
      foreach ($category as $key => $value) {
         $categories_array[$key] = $key;
      }

      $categories = implode(',', $categories_array);
      $subscribers_snids = db_query("SELECT snid FROM {simplenews_subscription} WHERE vid IN (:vid)", array(':vid' => array_keys($categories)))->fetchAll();

      $subscribers_uids = array();
      foreach ($subscribers_snids as $value) {
         $subscribers_uids[$value->snid] = db_query("SELECT uid FROM {simplenews_subscriber} WHERE snid = :snid AND activated = 1", array(':snid' => $value->snid))->fetchAll();
      }

      $users_list = entity_load('user', $subscribers_uids);

      return array('entity_fetched' => array_values($users_list));
   }

Can not determine what I've done wrong. Please help!


texts:
I was trying to write PHPUnit test in D8, but am blocked due to a weird issue which I am not able to track.

The module for which I am writing the test is at https://github.com/ajitdev/phpunit_d8

I have created a basic class Math with some functions https://github.com/ajitdev/phpunit_d8/blob/master/src/Math.php

<?php
namespace Drupal\phpunit_d8;
class Math {
  public function addNum($a, $b, $c) {
    return $a + $b + $c;
  }
  public function substract($a, $b) {
    return $a - $b;
  }
  public function divide($a, $b) {
    return $a / $b;
  }
}

And the test in tests/src/Unit directory https://github.com/ajitdev/phpunit_d8/blob/master/tests/src/Unit/MathTest.php

<?php
/**
 * @file
 * Contains Drupal\Tests\phpunit_d8\Unit\MathTest
 */
namespace Drupal\Tests\phpunit_d8\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\phpunit_d8\Math;
/**
 * Class MathTest
 * @package Drupal\Tests\phpunit_d8\Unit
 *
 * @group math
 */
class MathTest extends UnitTestCase {
  public function addNumTest() {
    $math = new Math();
    $this->assertEquals($math->addNum(1,2,3), 6);
  }
}

The test shows up on /admin/config/development/testing, but throws the following exception:

Uncaught PHP Exception Drupal\Core\Database\IntegrityConstraintViolationException: "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'file' cannot be null: INSERT INTO {simpletest} (test_id, test_class, status, message, message_group, function, line, file) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array
(
    [:db_insert_placeholder_0] => 14
    [:db_insert_placeholder_1] => Drupal\Tests\phpunit_d8\Unit\MathTest
    [:db_insert_placeholder_2] => fail
    [:db_insert_placeholder_3] =>
    [:db_insert_placeholder_4] => Other
    [:db_insert_placeholder_5] => Drupal\Tests\phpunit_d8\Unit\MathTest->Warning()
    [:db_insert_placeholder_6] => 0
    [:db_insert_placeholder_7] =>
)
" at /Applications/MAMP/htdocs/d8/core/lib/Drupal/Core/Database/Connection.php line 673

The issue is empty value for the file value. I am not able to trace down the issue. Any pointers would be really helpful.


texts: I am using service module 7.x-3.12. The index call by node resource provides provides node related data but only from node table. I can't fetch the value from custom fields of a node. So I want to alter the query in index call build by services_resource_build_index_query() function. But I can't find any way to alter the query.


texts: Why does Views add space when putting a Multiple field content field into the same row?

texts:
Views seems to be adding some kind of space when putting multiple fields into a single row, but only for one field and not another. What did I do?

'field_item_options' => '                        //THIS IS BAD
Option A                                         //THIS IS BAD
,                                                //THIS IS BAD
Option B                                         //THIS IS BAD
', 'field_item_options_price' => '$1.00, $2.00', //THIS IS GOOD

1) Double checked the content type setup: Structure >> Content type >> Manage fields. They're the same:

'field_item_options': Field: text; Widget: text;
'field_item_options_price': Field: text; Widget: text;

2) Structure >> Content Type >> Manage display. Noting strange here:

'field_item_options': Format: plain text;
'field_item_options_price': Format: unformatted;

3) Show Multiple field settings: Display all values in the same row
Tried this on and off. When its off, the Option B disappears from the Views array.

4) Rewrite results: Remove whitespace
No effect

5) I made various attempts to remove the extra space include using trim() and using using \t,\n,\r,and \s with preg_replace() in a views template override:

$striped_array_options = trim($row['field_item_options']);
$stripeded_array = preg_replace('~\s+~', 'y', $striped_array_options);

I used the 'y' replacement character to show the changes, but at most there was at most two y's.

The end result is supposed to be a separate row for each value so I can format the OptionA to align with its associated PriceA and OptionB with PriceB with more control.

And then there's this under Multiple fields share same row
"If using group by, please make sure to group by "Entity ID" for this setting to have any effect." I don't know see how the entity ID is chosen for a group by, since "File Usage: Entity type" is the only field you can add to the View. Ah, $#@! I'm frustrated. Where is this space coming from and how do I get rid of it?


texts:
I created a custom field adding a .yml file in config/install. This field is listed under admin/reports/fields. Now I want to delete this field completely.

I tried uninstalling my custom module, but the field was still there.
I tried the following code, but it didn't work.

/**
 * Remove field_MY_FIELD_NAME.
 */
function MYMODULE_update_8001(&$sandbox) {
  $entityManager = \Drupal::service('entity.manager');
  $fields = $entityManager->getFieldDefinitions('node', 'MY_CONTENT_TYPE');
  if ($field = $fields['field_MY_FIELD_NAME']) {
    $field->delete();
  }
}

I ran the cron tasks after running the code, but it didn't help.

Is there a way to completely delete a field?


texts: Image Field Caption not showing on inserted images

texts:
I've added Image Field Caption module to my site, and the caption field now shows up underneath each image field perfectly. However, when I go to the page, the caption doesn't show up. From what I can tell, the SPACE for the caption is there, but the actual text is not.

I should mention I'm using a custom framework from my university and can't immediately get to the code.

I found an old thread about this: https://www.drupal.org/forum/support/post-installation/2013-08-20/image-field-caption-not-showing-up

This particular field is an "additional images" field.  When I SHOW that field via the Content Type > Field > Display, the images all pile on the bottom of the page, but the caption IS there.  However, I obviously want to be able to put the images onto the page wherever I want and still want the caption to show up.

Thanks in advance for any help.


texts: How to remove status messages from admin theme?

texts:
I am working with Drupal 8. I have enabled "Seven" as admin theme. When I have added an image with high resolution I am getting 2 error messages at a time(screenshot). I want to hide "green" colored status message from this particular page. I have tried with hook_page_attachments(array &$attachments) in my custom module to include the css for admin theme.

But it is not working. How to solve this issue?

.


texts: How to display most recent node in different Panel

texts: I have a magazine with two content types: Issue and Article. Regarding the Issue content type, I want one design for the most recent Issue and another design for all the past Issues. The past Issues are taken care of with Display Suite. For the current Issue I would like to use a panel/node variant. My question is, how do I display only the most recent node from the Issue content type without changing the design for all Issue nodes?


texts: In drupal 7 Forums under some topic I want to add a upload image field with the comment field. How can i achive this?


texts: I want to display the node count along with the filter in views exposed filter same feature like facets can any one help me out in this.


texts: Internal Server Error with Multiple Tags

texts:
When creating a Drupal view that filters based on multiple tags, I'm getting the following error when I click preview:

  An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging
  information follows. Path:
  /admin/structure/views/view/breakfast_things/preview/page_1/ajax
  StatusText: Internal Server Error ResponseText:

And the following error when I hit save:

  Notice: Undefined property: Drupal\views\ManyToOneHelper::$query in
  Drupal\views\ManyToOneHelper->add_filter() (line 312 of
  core/modules/views/lib/Drupal/views/ManyToOneHelper.php).

Here is a screenshot of my page (this was after I clicked save)

If I keep everything the same but only use one tag, like eggs, then it works perfectly fine. Anyone know what's wrong here? I'm trying to create a view that will show all posts about eggs, spam, and other breakfast items.


texts:
Background / use case

The entityqueue module is a great way to bridge content with configuration:

The entity queue is created in config, and created automatically on deployment. It can then be included into a panels page or another type of configured element.
The entities can be created, placed and controlled by editors, without polluting the exported configuration (stored in features for D7) of the queue.
The ordering of items is controlled by the editor.
The weights are stored outside the actual entities, which means that sorting does not fire all the entity update hooks.

The usual way would be to let editors add existing nodes to the queue.

Now we want a bit more than that: Every entry should have a custom title + link destination, in addition to the reference to a node.

Current solution idea

The first idea would be an entity queue with a list of "mini entities" (e.g. using eck or nestedbox), each with a title field, link field, and an entityreference field to reference the node.

Editors would have to create those mini entities, and then add them to the queue.

Question

Is there an easy way to combine the two steps of creating the mini entity, and adding it to the queue?

Is it possible for the queue to "own" these mini entities, like a node "owns" its paragraphs items? We don't want to end up with a pool of homeless mini entities.

Alternatives I considered

Solutions which require a "host entity"

Another solution could be a paragraphs field.

Or something else with inline entity form. A colleague built a solution with a fieldable panels pane referencing other fieldable panels panes via entityreference + inline entity form.

In all of these solutions we need a host entity, which would itself be content and not configuration, with the known flaws:

The host entity is content and not configuration, and thus won't be automatically created on deployment.
If the host entity is placed e.g. into a panel, it will pollute the exported configuration due to its auto-increment id or uuid.

Solution with taxonomy terms?

Taxonomy terms already give us a sorting UI out of the box. So we could create a vocabulary with some fields, and use the terms as "mini entities". Then the term weight would replace the entity queue.

One flaw in this solution is that every queue would require a new vocabulary (taxonomy bundle), because the sorting is global to the entire vocabulary.

Content export for host entity?

Perhaps the problem with the "host entity" would be solved by exporting the entity to config with its uuid?

Firstly I am not sure how well this works in general.

But either way, if the host entity is exported in config, then changing the referenced mini entities would pollute the configuration.

Host entity in a queue?

Another option would be to have

a host entity with paragraphs or entityreference + inline entity form for the mini entities, as above
a queue holding the host entity.
create an empty host entity on deployment with hook_update_N().

This will properly isolate content from exported configuration.

However, now the editor needs to know the url of the correct host entity when editing.

Also, since the host entity is officially content, it could get messed up by editors.

Overall this adds one level of content architecture which I would rather avoid.


texts: hook_menu access argument returns 3 instead of data

texts:
I am trying to access an api that I wrote, with an access that is limited to administrators only.

My code is:

mymodule_menu() {
/**
 * Create api callback to return list of users in a give site
*/
  $items['api/v1/userslist'] = array(
    'type' => MENU_CALLBACK,
    'page callback' => 'mymodule_api_userslist',
    'access arguments' => array('administer permissions'),
    'delivery callback' => 'mymodule_json',
  );

  return $items;

this just return the value "3" for no reason.

If I remove access argument and put         'access callback'   => TRUE,
everything is working. So it is a problem with the permission.

Any ideas?

function mymodule_json($data) {
  if (isset($data['error'])) {
    drupal_add_http_header('Status', '400 Bad Request');
  }

  echo drupal_json_output($data);
}


texts:
I have created a web site with a bunch of Webforms used to collect data from surveyors.  My client is interested in having the ability to make individual submissions non-editable by the surveyor while not removing the ability for surveyors to edit their own submissions generally.  In other words, she wants the surveyors to be able to edit their submissions at her direction, but once she considers the submission complete, she wants to lock it down and prevent further editing, partly to prevent confusion if the surveyor perhaps has two or three different webforms they are working on.

Do you know any way to do this?  Thanks!


texts: How do I extend the xmlsitemap module to include the google news / images and videos formats

texts: The xmlsitemap module covers the standard google xml site map. However, https://support.google.com/webmasters/answer/178636?hl=en is the information for the google image search and the specific markup for creating a sitemap for image content. Likewise https://support.google.com/webmasters/answer/80472?hl=en is for video content. I don't think that the xmlsitemap module supports these additional types.  (Google news sitemap is another one). Can anyone offer any more information about extending the module or if there are any patches that will achieve the above.


texts:
I have a block view which filters for a specifiy content-type. I'd like to fully style it myself and also write the html myself it outputs. So I went and created the file views-view-fields-header-image-slider--block.tpl.php in /templates.

Now, I do have the $view object but no $field etc. Also var_dump($view->field['description_title']); result in Null.

I'm a bit confused how I can access the fields nor properly so I can render the image + description and all the other stuff.


texts:
I am attempting to incorporate a feature I created which uses a content type and taxonomy terms, among other things. I had to re-add the taxonomy terms for the vocabulary which was included in the feature, however, both before and after adding the terms, I received the following error once I tried to add the content type on a new website:

  Fatal error: Call to undefined function
  title_taxonomy_allowed_values() in
  /Applications/AMPPS/www/example/docroot/modules/taxonomy/taxonomy.module
  on line 1496

Any help to troubleshoot this issue is greatly appreciated.

Drupal 7.54
Local Dev using AMPPS


texts: When setting up the Drupal 7 database (mySql/mariadb) what database user accounts should be created?

texts:
When installing the database (mariadb) for use with Drupal 7 on Centos 7, what database admin and user accounts should be created and with what permissions?

Do specific directory permissions or file ownerships need to be provisioned for these database user accounts?  -Thanks


texts:
I discovered the quiz module a few hours ago and  began experimenting.

I setup a quiz node and added one multipleoption question. I added three options to the question.

The problem is when I edit the question and add to the existing 3 options, the forth and fifth options do not showup when viewing the quiz question - only the original three questions show.

Instead a new "multiple choie question" node is created - not what I intended nor asked for.

Can anyone help me understand and fix this issue?

PS: If anyone knows of a better alternative to the quiz module, please let me know.


texts: How to change string which comes from breadcrumbs?

texts:
I have used custom breadcrumbs module.

Now one of my title of blog has single quote or double quotes, which is having problems.

So, in titles i have added

  [node:title]

so output of the title whose having quotes are like

Home > blog > Politics > No Democracy but many other &#039;o-cracies&#039;

and i have added hook which will show the output is like this..

function myowntheme_breadcrumb($variables) {
    $sep = ' &gt; ';
  if (count($variables['breadcrumb']) > -1) {
    return implode($sep, $variables['breadcrumb']);
  }
  else {
    return t("Home");
  }
}

How to remove that hash tag values and show on simple version ?


texts: What do I have to do to get the Modernizr module to work in Drupal?

texts: I would like to use modernizr in drupal to take adcvantage of css media queries, box-shadow and border-radius. I have followed the installation instructions perfectly. I have installed the Drupal Modernizer module and created and properly placed my customized Modernizer build to include support for these three features. Does modernizr just pick up my already existing media queries and css3 styles automatically or do I have to do something else?


texts: Can I disable the #required form attribute temporarily?

texts:
I have functionality set up where an admin can create a user with a content profile. The content profile has a required field but I want the user himself to fill it out. How can I disable the required-ness of that field when the admin is creating the user so he can submit the form. I tried setting #required to 0 or unsetting it, but that does nothing.

function mymodule_form_contenttype_node_form_alter(&$form, &$form_state) {
        $form['field_reviewer_instruments']['#access'] = FALSE;
        $form['field_reviewer_instruments']['#required'] = FALSE;
}


texts: Tried to Inline CSS with AdvAgg but still get errors in Google

texts:
My Right-to-left site uses clean Bootstrap subtheme and has CDN, Internal caching (including Boost), Minification, Compression and aggregation, but still I get very low grades with all that has to do with CSS performance. Therefore I tried to inline all the CSS in my site via AdvAgg (please see image), what helped me in another theme, but not this time...

Is there anything else you think I should try?


texts: How can I use the OpenLayers module to draw a route between nodes?

texts: I have some nodes; I need to build a route using the location assigned to them, and I want to draw it on a map. How can I do that?