texts: How to insert custom redirect script in index.php without losing it on update

texts:
At the moment I'm migrating an old site to Drupal. To redirect all old url's to new ones, I made a script that has to be inserted before anything goes off, so in index.php at the top.
   <?php

    include 'custom.php';

    use Drupal\Core\DrupalKernel;
    use Symfony\Component\HttpFoundation\Request;
    etc.etc.

All is fine until an update wipes this out.
Could (should?) it be done some other way to preserve this?


texts: Online payemnts with commerce: what charges should I expect

texts:
I am currently trying to setup a website with a simple online shop. Now for the online payments I'm struggling a bit to gather the information of all the things I'd like to know before making a decision. There are different banks, "externalizers", modules etc. and it seems to me that everywhere they want some money and I am not quite sure what for! So to get things straight - where should I expect charges? And if possible, what is the most economic or even free solution? I do not know if this little web-shop is going to work out. I see this list for example (https://drupalcommerce.org/faq/payment-methods) and do not understand how these things work except that every entity says that they are really awesome :-/. I do not find out how I will get the money transferred (and what countries).

I do not really get how online payment works: I need a bank account and something that transfers the money - so 2 things right?

Should I expect to pay for a module?
What should I expect to pay to the bank or entity that is transferring the money?
What are free/economic solutions?
Are there any traps/problems what kind of credit cards will be accepted?
Is there any resource that gives an organized overview of the segment?

Thanks for your help


texts: How to get the correct reference to this item?

texts:
I'm writing a hook for a form but do not get the correct reference. What do I wrong?

  if($form_id == "entityqueue_subqueue_edit_form") {
    foreach ($form[eq_taxonomy_term][und][items] as $row => $rowinfo) {

      dpm($rowinfo[target_id]);
      if ($rowinfo[target_id][value] == 94){

        unset ($form[eq_taxonomy_term][und][items][$row]);
      }
    }
  }


texts: Referenced entity with multiple values making duplicate rows in views

texts:
I checked 'distinct' in my view configuration in Query settings under the 'advanced' fieldset.

So say when I have have three entities connected to one node, there would be three rows in my view of the same node of course one for each entity.

Fields settings

Content: Hour ('event')
Content: Title ('event')
Content: Body ('event')
(Content entity referenced from field_event_performer) Content: Title
(Content entity referenced from field_event_performer) Content: Body
(Content entity referenced from field_event_performer) Content: Foto
Content: Title  ('event')
(Content entity referenced from field_event_performer) Content: Performer

Some fields I've given a class in order to hide them using jQuery and show them in a modal frame when clicked on. That's why fields are shown double. First I thought the problem was be because of the weird field settings. But the nodes that show only one time have the same field settings, only do they have more performers referenced.

I have 4 filter criteria in total:

Content: Published (Yes)
Content: Type (= Event)
Content: Evenement type (= Presentatie) | Settings  (taxonomy)
Content: Locatie (= Kraakhuis)   | (taxonomy)

Having done searches I noticed that everyone who had this problem, only needed 1 field from the referenced entity and could use the aggregation funtion as found under advanced. This works quite fine here as well if I only needed 1 field.

But in my case, when output into a modal frame, one entire row should look like this:

Node123 title
Node123 body
referenced entity 1 title
referenced entity 1 body
referenced entity 1 picture
referenced entity 2 title
referenced entity 2 body
referenced entity 2 picture
referenced entity 3 title
referenced entity 3 body
referenced entity 3 picture


texts: How do I allow custom .php files to be accessable?

texts:
I have already looked at the How do I call legacy PHP files? answers and they didn't fix my problem.

I have a custom php file in my Drupal site (Hosted on Acquia Cloud and I am working on a local version of the site using Acquia Dev Desktop) that needs to be accessable, I added these lines to my .htaccess file trying to allow access to the php file

RewriteCond %{REQUEST_URI} !^/learning/
RewriteCond %{REQUEST_URI} !^/learning/sales/[^/]*\.php$
RewriteCond %{REQUEST_URI} !^/learning/sales/index.php
RewriteCond %{REQUEST_URI} !^/learning/sales/ajax/[^/]*\.php$

But I still get this response trying to go to the index.php file.
"Forbidden
You don't have permission to access /learning/sales/ on this server."

How can I fix this?

Note: if I change the file to be index.html it works just fine (well my ajax call in it doesn't work but it atleast loads) but if it is index.php it returns with the 403 error.


texts:
I'm using the following code to embed an autocomplete field in a block. However the autocomplete process does not execute when I type in input:

function cse_block_info(){
    $blocks = array();
    $blocks['cse_search'] = array(
        'info' => t('CSE Search'),
    );

    return $blocks;
}

function cse_block_view($delta=''){
    switch ($delta) {
        case 'cse_search':
            // The subject is displayed at the top of the block. Note that it
              // should be passed through t() for translation. The title configured
              // for the block using Drupal UI supercedes this one.
              $block['subject'] = t('Title CSE block');
              // The content of the block is typically generated by calling a custom
              // function.
              $block['content'] = cse_block_content($delta);
            return $block;

        break;

        default:
        break;
    }

}

function cse_block_content($which_block){
    switch ($which_block) {
        case 'cse_search':
            $form['cse_search'] = array(
                '#title' => t('CSE Autocomplete TEST!'),
                '#type' => 'textfield',
                '#autocomplete_path' => 'cse/google/autocomplete',
            );

            // Adds a simple submit button that refreshes the form and clears its
            // contents. This is the default behavior for forms.
            $form['submit'] = array(
                '#type' => 'submit',
                '#value' => 'Save',
            );

            return $form;
        break;

        default:
        break;
    }
}

I implement the same code as a stand alone system i:e not placed inside a block and the process works flawlessly.

Can anyone help with suggestions of why my attempt to place an autocomplete in a block does not work?


texts:
I want the Drupal Default Search to look into Field Collection items.

I currently have a field_resources collection with a field_description and a field_file, and the search should be looking into both.

Is this possible? What simple alternative could I use instead? An external search module seems a bit overkill.


texts: Fivestar: How to display description text inline

texts:
By default, the Fivestar module offers (at Structure » Content types » Article » Manage Display » Fivestar settings) to show "Text to display under the stars". It looks then like this:

How to show the description text inline beside the stars?

I wasn't able to do that in CSS (or to find the caused code in the module).


texts: I have added a textarea and i want to store more that 1024 characters in it. Long text is the field type that i have chosen but an error comes up saying :Keywords cannot be longer than 1024 characters but is currently "xx" characters long.I tried using hook_form_alter to increase the maxlength but it does not work. Also tried the hook_form_field_ui_field_edit_form_alter to change the length from 255 to 555 but no success.Is there any other workaround for this ?


texts:
I just started creating a Drupal 8 theme.

For example in Drupal 7 if I want to remove the breadcrumb, I just need to remove this line of code <?php if ($breadcrumb) print $breadcrumb; ?> from the page.tpl.php.

In Drupal 8 I removed {{ page.breadcrumb }} from the page.html.twig and I still seeing the breadcrumb. So not sure how to remove or unset these kind of blocks in Drupal 8.


texts: After installing any module I get "The website encountered an unexpected error. Please try again later."

texts:
I'm a Drupal beginner and after setting up my site and installing some modules I now have this annoying bug.

After installing any module, doesn't matter what one, I get this white page:
http://imgur.com/a/z5MFp

Even though it says it has encountered an error, the module actually just gets enabled without any other error logs.

http://imgur.com/a/U6ymD

(In the screenshot I tested it by enabling ban and telephone module, each time after  enabling it in the module list I got an error page. But the modules actually work and there aren't any errors to be found on the logging page.

It's quite annoying to get a white error page instead of the blue loading bar.

Anyone have an idea what the issue here is?


texts: How can I have facet items set to disabled instead of hidden if no results?

texts:
We currently have a Views page with Search API and Elastic Search.

There are 3 facets available:

Category (radio, single selection)
Range (checkbox, multiple select allowed)
Type (checkbox, multiple select allowed)

We want to be able to select a category, e.g. "Fruit" and have Range selected e.g. "1-10", this should "blur out/disable" different Types which have 0 results e.g. if Type had:
 - Box of 24
 - Package of 6
 - Single item

Then perhaps the Fruit for 1-10 would only have type "Package of 6" and "Single item" available, and "Box of 24" would be blurred out (disabled but still shown in the DOM).

How would we achieve this?

Currently the 3 facets use "OR" instead of "AND" as "AND" causes the facet items to be removed from the DOM...


texts: What is the equivalent of drupal_set_content()?

texts: I am searching for something equivalent of drupal_set_content() for Drupal 7, to assign a block to a region. Do you have any idea?


texts: Path-based context and URL aliases - wrong block shown

texts:
My (Drupal 7) site has a search which uses two blocks - one for entering the criteria and one for the results.

(For brevity, I won't explain in detail why I need two blocks but it's basically because I'm doing a drop-down search a bit like this approach.  Suffice to say that I can't do it all in one block.)

The search is at mysite.com/contact-us.  I've got a context rule which shows the criteria block in the sidebar when the contact-us URL path matches.

I want the results block to appear on the same page as the criteria block, appearing in its place.  Therefore, I've got a URL alias of contact-us/find, which points to contact-us.  My context rules say that if the path is contact-us/find, the results block should be shown.  (The alias was set up via the UI, i.e. Configuration > URL aliases)

So both contact-us and contact-us/find show the Contact Us page, but there are different Context rules and so different blocks are shown in the sidebar.

That's the theory anyway.  Here's what happens in practice:

I browse to mysite.com/contact-us.  I see the criteria block.
I fill in the search criteria
I am taken to e.g. mysite.com/contact-us/find?property=35 (the querystring provides an ID which the results view uses).  I see the results block in the sidebar.  So far, so good!
However, if I then go back to mysite.com/contact-us (e.g. to search again), I still see the results block and not the criteria one!  And it thinks there are no results as I no longer have the querystring.

If I clear the cache, all is well again - I see the correct blocks.  But I need a solution which doesn't require a cache clear - that's not something my users will be doing!

I presume that I'm running into problems because both contact-us and contact-us/find are actually the same node, and so Context can't accurately differentiate between them unless the cache is empty, but I'm not sure.

Any suggestions how I could resolve this one?  Could I have a different type of rule specifying when the blocks should appear?  Or something else?  I'm all out of ideas!


texts: Importing and filtering RSS feeds into nodes

texts: I'm looking for the best way to import a feed, say BBC News, and filter through all the content so only articles containing a keyword are stored in the database. I'd like each item to be shown as a node of a specific content type and for it to be updated every given time interval. Is there a straightforward way to do this? I don't have much experience in PHP at all, so please be specific.


texts: Show link only to user with permission to edit

texts:
I'm using the following code to show the Edit button to edit pages in my blog teasers and others content types.

<a href="<?php echo '[node:edit-url]';?>">Edit

It works fine, but it shows for all users, even the users with no permission to edit. How can I hide it for users that don't have permission to edit?


texts: Setting field attribute as read only in hook_form_alter?

texts:
I'm trying to create a simple custom module to stop the Title of a specific node being edited.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'nodetitle_node_form') {
    unset($form['title']);
  }
}

Currently it just removes any reference to the Title from the edit pages. Does anyone know how I can set the Title field attribute read only?


texts: Check for field values to be unique when storing into the DB

texts:
I have a content type "Research assignment" which has several fields including the field "field_user" and "field_project".

I want to remove any old research assignments having the same user and project fields as newly stored research assignment, before storing a new assignment in the DB.

This could be happily implemented by an UNIQUE SQL constraint, but it seems that the Drupal way is to use fields, not direct access to DB. What could you advise: to do this with fields or to revert to plain SQL?

Also, could you show how to use transactions in this case? I don't want anyone to see a research assignment deleted just before it is inserted again with probably other fields.


texts:
How can you remove the reply button under each comment in Drupal 8? I understand there is an option "Show reply form on the same page as comments", but I am not trying to remove this form. Only the reply button.

How can the reply button be removed?


texts: show images for taxonomy terms in referenced node

texts:
D7 question. I need to have a "clients" taxonomy with an image extra field on each term (the client's logo). Then I have a "project" content type. Projects belong to specific clients, ie the project content type has a term reference field to the client taxonomy.

When I click on a "project", I want to see the clients logo and not (only) the term name. This seems possible by following these instructions http://drupal.org/node/1224916, but this article is misleading: it suggests having an entity-reference field on the project content type instead of a term-reference. The problem with that approach is that when you connect a term and content by an entitity field, these two are not connected as far as taxonomy is concerned. So you lose all taxonomy functionality.


texts: Custom tpl for view mode for all contenty type

texts:
I've saw How to provide template for particular view mode?, but I don't to create a single tpl for every content type for a particular view mode, but a tpl used for every content type for a particular view_mode, something like node--search-results.tpl.php

Is it possible?


texts:
I want to get the value of "vid" knowing the node ID, and get the value of "name" for those rows where "vid" is equal to 2.

If it were a plain query, I would not know how to write it; I don't know how to write a left join query.

The "plain" SQL query in Drupal is the following:

$result = db_query('SELECT tid FROM {taxonomy_index} WHERE nid = :nid', array(':nid'=>$nid));

The equivalent raw SQL query is the following:

SELECT did, name FROM taxonomy_index as ti LEFT JOIN taxonomy_term_data AS ttd ON ti.tid = ttd.tid WHERE vid = 2 and nid = $nid


texts:
I have a question about handling file uploads.  I am trying to implement a form that will allow the user to upload a file.  I do not need to store the file, though.  I just need to take the uploaded file, where its location happens to be, and pass it to an outside API, which uploads it to its server (its Jira).  Is there a way to do this?  The file has to be publicly available to be consumed by Jira's API (in other words, Jira won't be able to provide a username/password to validate against drupal).  This is what I have, so far:

in my _add_form hook:

$form['file'] = array(
                '#type' => 'file',
                '#title' => t('Document'),
                '#description' => t('Upload a file, allowed file types: pdf, images, documents'),
            );

in my _add_form_validate hook:

$validators =  array(
                'file_validate_extensions' => array( 'jpg jpeg gif png bmp txt doc docx xls xlsx pdf ppt pptx ' )
            );

            $file = file_save_upload('file', $validators);

            if (isset($file->filename)) {
                $form_state['storage']['file'] = $file;
            }

in my _add_form_submit hook:

i can see the object form_state->storage->file but I don't see the full path to where the file is residing.  All i see, thats close, is:

 file_name = "myfile.jpeg"
 file_path = "/tmp/myfile.jpeg"
 destination = "/tmp/myfile.jpeg"

but, as I mentioned, I need to full path to pass to another, external, API so that the file can be consumed.  I do not need to store or save the file afterwards.

admin/settings/file-system settings:

File System Path:  sites/mySite.net/files
Temporary Dir: /tmp
Download Method: Private


texts: Can adding a cache tag create another cache row in database

texts:
I want Node breadcrumbs to be updated when the content is updated, so I added the following code to my breadcrumb generation class:

// Set cache tags
$node_cache_tag = 'node:'.$node->id();
$breadcrumb->addCacheTags(array($node_cache_tag));

My concern is that this is a bad idea for sites with a lot of content (300,000+).  I saw this post https://www.drupal.org/node/2891281 and noted that the default cache row limit is 5,000. Would the above code be an issue with over 300,000 nodes? Should I cache the breadcrumbs based on the taxonomy term that created the breadcrumbs (~1300 terms)?


texts: How to add a custom marker icon on gmap using the gmap module?

texts:
I want to add a custom marker to the list of markers on the gmap module
I tried the following link which is as described below :http://mydrupaltricks.be/article/drupal-7-custom-gmap-markers  but it did not worked

<?php
$markerdir = variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers');
?>

By setting the "gmap_markerfiles" variable, we can change the location of our new markers folder. We have to set this variable only once so we put the code in our "my_module.install" file.

<?php
/**
* Implements hook_install().
*/
function my_module_install() {
  variable_set("gmap_markerfiles", drupal_get_path("module", "my_module_name") . "/markers");
}
?>
Now we can create the new "markers" folder in our new module. Gmap expects a .ini file to describe all your markers. We add the file "markers/my_module.ini".
; Defaults
[defaults]
; Note: An empty shadow property will break IE.
; Leave it commented out if you aren't supplying an image.
; shadow = ""
anchorX = 15
anchorY = 17
infoX = 17
infoY = 6

; Marker sets

[drupal]
name = "drupal"
sequence = "marker-green.png"

[salepoint]
name = "salepoint"
sequence = "marker-green.png"

[headquarter]
name = "headquarter"
sequence = "marker-green.png"

[shop]
name = "shop"
sequence = "marker-yellow.png"


texts: Can a theme leverage block config Yaml files when installed for the first time?

texts:
In my Drupal 8 contrib theme, when the theme is first enabled, a number of system blocks are dumped into the first region that's in my theme's info.yml file. From a UX perspective, this is not really desirable as it makes the theme look ungainly and off balance. The two core blocks in question are "Powered by Drupal" and the "Footer Menu" blocks.

I've played around with placing these two blocks where I want them (in my theme's case, the footer_first and footer_second regions), exporting the config for those and then placing the Yaml files in /mytheme/config/install. I then try a fresh Drupal 8 Beta 1 install on my local and activate the theme once again but the config files seem to have no effect. The two system blocks in question are yet again placed in the first region that's in my theme which is the top area.

I can fool Drupal by placing the footer regions first in my theme's info.yml file but this presents other issues - for example, when users view the block admin page and see those regions come up first when they are actually last.

My guess is, there is no good solution for this but I thought I would ask in case anyone had some ideas.


texts: Blank window when i press select media link

texts:
I have created a video content type, created a video field, and used media asset.
When I create a video node and click on "Select media," a blank popup shows up. In this blank popup, I have to choose in which way to upload file.

In the Firefox error console I see the following error:

  TypeError: this.contentWindow.Drupal.media is undefined

I am using Drupal 7.20 and the latest version of the Media module.


texts: Call to a member function label() on a non-object in entity module

texts:
I created an entity type using Entity API and made it exportable. The export link works properly but on Import I have this error:

  Fatal error: Call to a member function label() on a non-object in [...]\sites\all\modules\entity\entity.module on line 903

I couldn't find any reason.
Here's my hook_entity_info():

$return = array(
  'event' => array(
    'label' => t('Event'),
    'entity class' => 'EventClass',
    'controller class' => 'EventController',
    'base table' => 'calendar_events',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'eid',
    ),
    'load hook' => 'events_load',
    'view modes' => array(
      'full' => array(
        'label' => t('Default'),
        'custom settings' => FALSE,
      ),
    ),
    'label callback' => 'entity_class_label',
    'uri callback' => 'entity_class_uri',
    'module' => 'events',
    'access callback' => 'event_access',
    'exportable' => TRUE,
    'admin ui' => array(
      'path' => 'admin/structure/events',
      'file' => 'events.admin.inc',
      'controller class' => 'EventsUIController',
    ),
  ),
);

Tell me if you need more information.

[EDIT]
I figured that the error has been occurred in entity_class_label($entity) in sites/all/modules/entity/entity.module:903. I printed the content of $entity and it seems it is NULL!
Why is it NULL?


texts: exclude from display field so only logged in user can view?

texts:
I am trying to make it so logged in users can delete images they've added to a gallery created in views but I don't want the field link to content to be viewable by anonymous.
So I have added the field in my views gallery link to content but have selected exclude from display. I remember years ago there is a way to set up a gallery in views so you end up with an add and delete content page for users by grouping this field and a few other advanced settings but it was so long ago cannot find the tutorial.

How can I have this field of link to content in views only viewable by logged in users?


texts: My Drupal Website is possibly compromised through a SQL injection and lot of database updates are visible. How to avoid further SQL injection?


texts:
I have select list with options:

$options = array(0 => '0', 500 => '500', 1000 => '1000');

I'm trying to set it's default value to 500:

$form['price']['min']['#options'] = $options;
$form['price']['min']['#default_value'] = 500;

But this don't work.


texts: Load a views block in a tpl file with his custom template

texts:
I have a custom tpl file for a node type, in this file i want to load a views block i created.
This block has a custom template file to style the block itself.

I load the views block in the node template file with views_embed_view() but this just gives me the default html of the block and not the output of the blocks tpl file.

Is this possible with the views_embed_view() function or do i need to use some other function?


texts: How can I judge if a page route is the child of a texonomy item?

texts:
I build a forum using forum module and create several items and their subitems. For example, I have a top texonomy item of "discuss", which has a child item of "IT", then I post a topic of "drupal is amazing" in the "IT" item. Then others may post other topics in other texonomy items and subitems.

My question is, when the user navigate in the forum, how can I judge if the current page belongs to a special item, or a subitem is the child of another topitem in the hook_preprocess function ?


texts: How to access multiple values of field collection in node.tpl?

texts:
I have field collection for one of my content type.
The fields in field collection are

Title
Body
Image

The field collection can have many values at a time.
I tried to get the values using entity load in foreach loop but its not loading anything.
Also i am embedding a node in field collection which is also not working any guesses why its not showing node embed.

Here is my code

foreach($field as $my ) {
  $section_content_id = $my["value"];

  $field_info = entity_load('field_collection_item', array($section_content_id));

  $section_value = $field_info[$section_content_id]->field_title[LANGUAGE_NONE][0]["value"];

  $section_desc = $field_info[$section_content_id]->field_body[LANGUAGE_NONE][0]["value"];

}


texts: Form submission with AJAX to override a block content

texts:
So, I have a block that I render with the following code.

public function build() {
  $filterForm = \Drupal::formBuilder()->getForm('Drupal\smeno\Form\FilterForm');

  $renderArray['filterform'] = $filterForm;
  $renderArray['McRefund_data'] = $this->getMcRefund();

  return [
    '#theme' => 'Remboursement-sur-compte',
    '#McRefund_build_data' => $renderArray,
  ];
}

As you can see within this block, I render a form and data (McRefund_build_data) which I put in a table(couple of Divs). The purpose of the form is to filter the data and put the response back in the block so that the block get rendered with the new filtered data. For this process I want to use AJAX to avoid the page from being reloaded.

I tried adding this on buildForm().

$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
  '#type' => 'submit',
  '#value' => $this->t('OK'),
  '#button_type' => 'primary',
  '#prefix' => '
',
  '#suffix' => '

',
  '#attributes' => array(
    'class' => array('proximabold', 'tc', 'transition', 'no-underline', 'ph3', 'pv2', 'mb2', 'dib', 'white'),
  ),
  '#ajax' => [
    // 'callback' => 'Drupal\smeno\Controller\RemboursementsController::filterRefunds',
    'url' => Url::fromUserInput('/filterremboursement'),
    'event' => 'click',
    // 'wrapper' => 'edit-output',
    'progress' => [
      'type' => 'throbber',
      'message' => t('Verifying entry...'),
    ],
  ],
);

I added a route and a controller to handle the request and the response.

Route

filterRemboursement:
path: '/filterremboursement'
defaults:
  _controller: 'Drupal\smeno\Controller\RemboursementsController::filterRefunds'
  _title: 'filterRemboursement'
methods:  [POST]
requirements:
  _access: 'TRUE'

Controller

function filterRefunds() {
  ddl('HELLO WORLD'); //devel module debug messages (usefull for ajax requests)
}

This isn't working, though.


texts: Do not let Drupal handle 404's on development environment

texts:
Drupal handles 404 error pages, but on localhost that can be very annoying, especially if you have missing assets (such as uploaded images). For each image, CSS and such that is not found, a drupal is bootstrapped and ran.

How can one best disable this?

Removing the line ErrorDocument 404 /index.php from .htaccess gives no change. Should that work?

Changing it to ErrorDocument 404 "development not found" does not work either.


texts: View block - show only field content from own page

texts: I am creating a view block to be displayed on every page of a specific content-type. Among other things, this view shows a field from that content type. How can I configure the view so that it will only display the field data from the page it is on? Right now it shows the data from every instance of that content-type field. Is there a way to reference the 'parent' page only?


texts:
what is the token used to get the curent language, I want to use this token on a link in the block body, like that:

About us

I find this token [site:url] is good, but in default language the link become //about-us two slashes, otherwise /fr/about-us in the french language(good).


texts: Why do sub-menu items not appear on front page, but work on other pages?

texts:
I have added a link to a Panels page in my main menu.  Beneath that link are items which link to a couple of Webform pages and a Basic page.

On the home page, the sub-items do not appear beneath the heading, but on all other pages, they show up just fine. If I look at Structure->Menus->Main menu, everything is set up correctly. I have cleared caches multiple times, to no avail. Any ideas?

Thanks in advance.


texts: How to set up component on another site?

texts:
I've been tasked with setting up a simple gallery component on a global site.

The component exists and works on a sub-site, but I want to move it to the parent site and ensure it's available globally.

I found the component's files in the sub-site and moved them to the same directory in the global, parent site.

The good news is that I can now see the component when I go to add it to a panel. But I can't access it to set it up. Clicking on it does nothing.

Does anyone know if there are any other steps I need to take to do this?


texts:
Hello guys i am trying to add data to one of my tables... when the submit button is pressed.
I have the following script:

function review_m_admin_settings_form($node){
    $form = array();

    $form['overview'] = array(
        '#markup' => t('This interface allow adminss to manage general content types and vote them up!'),
    );
    $form['select'] = array(
        '#type' => 'select',
        '#title' => 'Choose a content type!',
        '#options' => node_get_types('names'),
    );
    $form['mark'] = array(
        '#type' => 'textfield',
        '#title' => 'Give a mark to the content type(1 to 10)!',
        '#size' => 60,
        '#maxlength' => 2,
    );
    $form['text'] = array(
        '#type' => 'textarea',
        '#title' => 'leave a feedback!',
        '#cols' => 60,
        '#resizable' => FALSE,
        '#rows' => 5,
    );
    $form['created'] = array(
        '#type' => 'textfield',
        '#title' => 'Enter the date!',
        '#size' => 60,
        '#maxlength' => 10,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Send review'),
        '#weight' => 10,
    );
    $form['action'] = $url;
    return $form;
}

this is my form.... i called the function with the _submit at the end .. but it doesn't work!

    function review_m_admin_settings_form_submit($form, &$form_state){
    if(!isset($node->text)){
        $node->text = '';
        }
        if(!isset($node->created)){
            $node->created = '';
        }
        db_query(
            'INSERT INTO {review_m} (rid, nid, uid, mark, text, created)'
            . "VALUES (%d, %d, %d, '%s', '%s')",
            $node->rid,
            $node->nid,
            $node->uid,
            $node->mark,
            $node->text,
            $node->created
        );
}

Help!


texts: I'm using the media module for displaying files.  I have PDF Preview set up, which falls back to the image formatter, and then Large Filetype Icon.  PDF Preview and the Image formatter are set up to link to the file, but Large Filetype Icon doesn't have that option.  How could I either alter that view to add the link or add a new formatter that does the same seem as the Large Filetype Icon, but with a link?


texts: How do I add an external link in a module?

texts:
I'm attempting develop a module in drupal-8 that provides a link to an external password reset system. Specifically on the login page I'd like a reset my password link that points to a link such as https://reset.my.password/

I've tried adding my module.links.task.yml file. What else do I have to create to add an external link?


texts: Import CSV, row by row, into custom table

texts:
I have a Drupal 7 submit method for updating CSV row by row to a custom table which I found under this link. I have tried to update it so that it works in Drupal 8 to no avail. How do I to modify it to work in Drupal 8?

function custom_module_submit($form, &$form_state) {

    $file = $form_state['values']['csv_upload_file'];
    $file->status = FILE_STATUS_PERMANENT;
    $file->filename = str_replace(' ', '_', $file->filename);
    file_save($file);

    $csv_file = file_load($file->fid);
    $file = fopen($csv_file->uri, "r");

    while(! feof($file))
    {
        $customer = fgetcsv($file));
        db_insert('your_db_table')
            ->fields(array(
                'column1' => $customer[0],
                'column2' => $customer[1]
            ))
            ->execute();
    }

    fclose($file);

    drupal_set_message('CSV data added to the database');
}

The Drupal 8 code that I am trying to use is as below:

public function submitForm(array &$form, FormStateInterface $form_state)
{
    $file = $form_state->getValue('csv_upload');
    $file->status = FILE_STATUS_PERMANENT;
    $file->filename = str_replace(' ', '_', $file->filename);
    file_save_data($file);

    $csv_file = \Drupal\file\Entity\File::load($file->fid);
    $file = fopen($csv_file->getFileUri(), "r");

    while (!feof($file)) {
        $customer = fgetcsv($file);
        \Drupal::database()->insert('your_db_table')
            ->fields(array(
                'column1' => $customer[0],
                'column2' => $customer[1]
            ))
            ->execute();
    }

    fclose($file);

    drupal_set_message('CSV data added to the database');
}

Errors include:

Fatal error: Call to a member function getFileUri() on null in /home/annuities/public_html/modules/custom_module/src/Form/CustomForm.php on line 90.

Line 90: $file = fopen($csv_file->getFileUri(), "r");

Warning: Creating default object from empty value in Drupal\custom_module\Form\CustomForm->submitForm() (line 85 of modules/custom_module/src/Form/CustomForm.php).

Line 85: $file->status = FILE_STATUS_PERMANENT;

Notice: Undefined property: stdClass::$filename in Drupal\custom_module\Form\CustomForm->submitForm() (line 86 of modules/custom_module/src/Form/CustomForm.php).

Line 86: $file->filename = str_replace(' ', '_', $file->filename);

The file could not be created.
Notice: Undefined property: stdClass::$fid in Drupal\custom_module\Form\CustomForm->submitForm() (line 89 of modules/custom_module/src/Form/CustomForm.php).

Line 89: $csv_file = \Drupal\file\Entity\File::load($file->fid);

Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 227 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).


texts: My website suddenly started giving Error 200 on anything AJAX related!

texts:
The other day my website suddenly started acting weird. When using the Flag module to flag content, i get a 200 error! The content does get flagged once i refresh the page, but when clicking the flag link i get this error below.

When editing any of my Views, and say i click on the THEME INFORMATION link to modify the theme files i get another 200 error (see image).

When trying to open modal forms, same thing. This problem seems to have come out of nowhere overnight, as my site was ok, i went to sleep, next day problems. Now, i get the error on both my own theme (when say flagging content) and also on the Admin theme (Seven) when say editing a View. So i would guess that its related to a module rather than the theme? Anyone have any idea how i can go about figuring out whats causing this? My JS is not good at all so im beat here, been on this for a few days now :(

Any help would be much much appreciated.

When flagging a content:

When editing a View:


texts: How to disable CACHE in VIEW PAGE display

texts:
DRUPAL 8

I am using VIEW module to create a page which loads data from a database table.

Seems this view page is caching because whenever I add a new record in this table via custom input form, it doesn't show on view page immediately after refresh. I can clearly see this new entry in the database table but not on view page.

Then I have to manually clear cache from the site > performance section and then I can see new entry on the view page.

Please note that database table is a custom table and I am using hook_views_data() to add custom table fields in the view page.

BTW I had disabled 'Disable views data caching' on '/admin/structure/views/settings/advanced' page but it has no effect on my view page.

Can anyone please advise what should I do to avoid CACHE?

Thanks.


texts:
I have two content type, content type A and content type B , I used Entity Reference field in content type B to reference content type A.

I created view with field Entity Reference ,In Entity Reference there are more field included how can i separate this all field in view ?


texts: Drush Not recognizing it's in a drupal root

texts:
Drush commands seem to succeed but don't.

For example, drush dl module results in:

  Install location /doc_root/feeds_tamper already exists. Do you want to overwrite it? (y/n): y
  Project feeds_tamper (7.x-1.0-beta5) downloaded to /doc_root/feeds_tamper.
  Project feeds_tamper contains 2 modules: feeds_tamper_ui, feeds_tamper.

However, it's the wrong download location, and there is no feeds tamper in that location.

Drush status returns:

  PHP configuration: C:\xampp\php\php.ini
  Drush version: 5.9

I am in the document root of the Drupal site.

This is on Windows with Cygwin.


texts: Internal server error on admin/modules/list/confirm

texts:
I have recently decided to move one of the sites to another hosting provider, and now started to receive this 500 error when submitting changes to admin/modules. The new hosting has different environment where all sites might have their core and contributed modules connected to the central repository; now, in admin/modules all 850 local repository modules can be seen as they were in sites/all/modules. In server logs this error reflect as:

  mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87437 bytes) in /opt/drupal7/includes/cache.inc on line 463, referer: admin/modules

  mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /opt/drupal7/includes/form.inc on line 1820

  mod_fcgid: stderr: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 8208 bytes) in /opt/drupal7/modules/field/field.crud.inc on line 711, referer: admin/modules?render=overlay

  mod_fcgid: stderr: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /opt/drupal7/includes/file.inc on line 200, referer: admin/modules

The site has a 128 MB memory limit; it is more than on previous hosting, but now some of the enabled modules (like OpenLayers) sometime also issue memory errors (like those above, but on site they work without any 500 errors).

What can be the reason of this errors? Is there any additional information that can help find what to fix?


texts: add title to front page teaser news feed

texts:
I would like to add a title to my news feed. I have tried to edit node--teaser.tpl.php and added

<?php if($page['feed-title']): ?>
<!-- start feed title -->
<?php print render($page['feed-title']); ?>
<!-- end feed title -->
<?php endif; ?>

on top, then I added

regions[feed-title] = Feed Title

in my theme.info file. I created a block which is assigned to this region but still, nothing is being displayed, why not? Am I doing something wrong or can I not add regions into a region template file?

Thanks!


texts: Do I need to comment out the line setting $base_url to be able to access a site with the https:// protocol?

texts:
Initially the site was working under HTTP protocol and everything was fine. Then we bought an HTTPS certificate  and tried to open the site through HTTPS. All the css and js were broken. I opened the page source code and saw that all these files are loaded through HTTP.

@import url("http://...");

So, I opened /sites/default/settings.php. At first, I added $conf['https'] = TRUE; but it didn't work. Then I commented out $base_url.

//$base_url = 'http://sitename.com';  // NO trailing slash!

Afterward, both HTTP and HTTPS started to work.

Is it the correct way to solve the problem?


texts: Creating a Feeds Plugin Child from a custom module and calling the new method

texts:
I’ve got a module where I need to overwrite a method from another Feeds Plugins class. To do this I’ve followed the developer's guide to Feeds.

So I have implemented hook_feeds_plugins and hook_enable. These are being reached fine. The aim of my new child class is to override the parse method in  FeedsCSVParser

In my code I have this line:

$result = $this->importer->parser->parse($this, $result);

This still runs through the parent class and not the child one I’ve created.  How do I tell my Module to use the new parse method instead?

When i break point this line I can see in $this->importer->parser->pluginDefinition that this array should probably be of the new info I've entered in hook_feeds_plugins, but is showing that previous class instead.

Thanks for any guidance that can be given.


texts:
DC2 - latest
I have promotions (discounts/coupons) working so can see adjustments etc.
I have set up a custom tax type - 20% and territory - UK
set values on my Order item types (Physical goods, Digital goods,Services,Events)
* How are these values related to assigning tax on a product in cart?

I can add a tax manually via order UI as admin.
I'm not seeing tax entries on checkout, and no tax entries in adjustments table (other than manual one).
* How is link between tax and order made?
thanks


texts: How to manage programmatically the access of a content node type?

texts:
From a custom module, I created a new type of content type via the drupal api (using the hook node_info). Thanks that, I can create node of this content type.

I would like allow access to nodes of this content type only for his author. And I want the author have only access to the view page of the node (edit page denied). How can I do that?

In Short:
In my custom module, how allow only access to the view node page only the author of the node?
The author can only access to the view page of a node created by the author. And, edits pages aren't be accessible for all non-admin users.


texts: How to add region just above title for omega theme? I try to add a region just above title. But no sccessful.


texts:
Need to count field specific value in Views.
I have 2 content types "project" and "task" In the task i have reference field for project (assign task to project) And another field "task_status" as a list: closed / open

I want to calculate the closed and total tasks so i can get the results in percentage:
closed_task / total_task * 100
How can i get the count for closed tasks value ?

Sorry for my bad English :)


texts: All special characters get outputted as question marks

texts:
I have a Drupal 8 (8.2.5) setup on a Debian Jessie Server PHP 7.0.15-1~dotdeb+8.1 and MySQL 5.5.54. All of a sudden Drupal converted all special characters like ü,ä,ö,ß,–... into question marks like Das mu?? doch nicht sein.

At first I thought, this must be a problem with a false encoding in the HTML header, but the encoding of the page is: UTF-8. Then I realized, that in the database all those characters are really 'converted' to question marks. As I have on the same server many Drupal instances (v. 6, 7 and 8) running, the which never had shown such behavior, I don't think, it is an issue with the server setup. The MySQL logs did not show anything referring to this issue neither.

After restoring the Data base, the same issue occurred again after some days.

I have absolutely no clue, what is going on. Has anybody an idea what could be the cause of this problem?

UPDATE: This problem is getting more wired: It turned out, as soon as I clear the cache, all special characters are gone. A look into the database (with PHPMyAdmin) shows, they really are. When I then restore a former database version, all special characters are shown on the site correctly again, but in the database they are still shown as  questions marks. My first guess was: They are already »converted« in the database dumb I was using, but only correct in the cache table. But, when restore the database and directly edit an affected node, all special characters are correctly shown in the form field. After saving it, they are correct even in the database. So I could restore all special characters by bulk republish them from the /admin/content interface. Also it turns out that not only special character in node fields are gone, but also in path alias and taxonomy terms. For example: Where »ä« should be converted to »ae« within a path alias, it was turned to a »?«.

Let me demonstrate this with some screen shots. The special character in this case was an en dash (–):
This is how it looks like on the site, when the issue occurs, a question mark is shown where originally an en dash was:

PHPMyAdmin shows us in the next picture, that this en dash was really converted to an question mark:

Looking into the backups of my data base with a text editor show, that in there the special characters are not corrupted.

Uploading the database file with Mackup and Migrate or with drush sql-cli < path/to/my/file/database.sql a look into the database shows, it gets corrupted immediately:

But on the site as long as I don't clear the cache all looks good. That means the cache table aren't corrupted. But surprisingly even if I edit an node, it is shown as if it weren't corrupted:

For a commoner like my that leads to the conclusion:

Some how, if I edit a node, it's content is loaded from cache tables!

So my questions are:

Which Drupal module or function could be responsible for touching
all most every database entry, but not the cache tables?
If I re-save a node or entity (without making any change), how is it
possible, that the database entry of the affected fields change?


texts:
When I update my  8.7.12 site to 8.8.5 I get the following error:

Fatal error: Uncaught Error: Call to undefined method Drupal\Core\Installer\InstallerKernel::installationAttempted() in /usr/www/users/XXX/core/includes/errors.inc:311 Stack trace: #0 /usr/www/users/XXX/core/includes/errors.inc(125): _drupal_get_error_level() #1 /usr/www/users/XXX/core/includes/bootstrap.inc(638): error_displayable() #2 /usr/www/users/XXX/core/includes/bootstrap.inc(622): _drupal_exception_handler_additional(Object(Error), Object(Error)) #3 [internal function]: _drupal_exception_handler(Object(Error)) #4 {main} thrown in /usr/www/users/XXX/core/includes/errors.inc on line 311

Can anyone advise? I am uploading the files via FTP.


texts: Module to display file from an SVN repo?

texts:
Looking for a way to display text files that are stored in an SVN repo or local filesystem. Exactly like http://www.mediawiki.org/wiki/Extension:Include works for mediawiki.
Thanks a lot


texts: How to generate content to Drupal 7 with a PHP-script?

texts:
I have been given the task to generate a couple of thousand of pages in drupal that should contain text generated by a php-script. After that is done, I'm supposed to perform searches on the generated words and play with the settings in Drupal to make the searching as fast as possible.

I have the php-script that generates the text but what I am asking for is the php-script that generates the pages and for each one calls my php-script to put a mass of generated text on the page.

I know that there is a file in Drupal that I can use since I read this page https://api.drupal.org/api/drupal/scripts!generate-d7-content.sh/7, but that one generates text that I can't perform my searches on. I think I need to modify it to call for my own text generator but I'm not sure of how?

Is there someone out there that maybe could help me? It would be most appreciated!


texts: Post to Pardot hook_form_alter On user_register Form Not Working

texts:
Alright, so this server I'm working on is running Drupal 6 and I need to send form data to Pardot upon user registration. I followed the answer on This Question, while adjusting http_build_query to fit its Drupal 6 parameters.

I get nothing on the Pardot end of things, and I'm honestly pretty stumped.

My .module file reads as such:

    /**
    * @file
    * A module which posts registration information to Pardot
    */

    function pardot_post_form_alter(&$form, &$form_state, &$form_id) {
        if ($form_id == 'user_register_form') {
            $form['#submit'][] = 'send_to_pardot';
        }
        drupal_set_message('This is happening.');
        $msg = "TEXT";
        dpm($msg);
    }

    function send_to_pardot(&$form, &$form_state){
        $url = 'url';
        $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
        $method = 'POST';

        $data = $form_state;

        $data_to_send = array();

        $data_to_send['mail'] = $data['mail'];
        $data_to_send['profile_firstname'] = $data['profile_firstname'];
        $data_to_send['profile_lastname'] = $data['profile_lastname'];
        $data_to_send['profile_company'] = $data['profile_company'];
        $data_to_send['profile_title'] = $data['profile_title'];
        $data_to_send['profile_phone'] = $data['profile_phone'];

        $retry = 3;
        $timeout = 15;

        try {
            $result = drupal_http_request($url, $headers, $method, http_build_query($data_to_send, '', '&'), $retry, $timeout);
        } catch (Exception $e) {
            drupal_set_message('Error incured while processing your information: ', $e->getMessage());
        }
    }

On the drupal_set_message() and dpm() calls; I'm trying to get any sort of output client-side to let me know if I'm incurring errors, what's going on with my variables, what-have-you. I get nothing. I've tried mail() to send me the contents of the form behind the scenes, but still nothing. I'm new to Drupal and altogether uninitiated in the world of PHP, so I'm not sure where functionality like displaying messages to a user or enabling mail could be disabled or where I might even begin to investigate that.

I've enabled the module in the administration section of Drupal, and I'm pretty sure it's altering the form, as whenever I update the file with an error the form fails to load.

I'm hitting a dead-end here. I could probably figure this out if I could just figure out a way to debug the script.

If anyone with similar experiences or just more experience could shed some light on my issue, it would be greatly appreciated.


texts:
Both dev and prod are on the same server, but not in a multi-site install.

I have set up an alias file including %dump-dir path - a path that should be writeable by the account I'm doing the command from.

drush sql-sync @prod-studies @dev-studies

Error is

Access denied for user 'CorrectUser'@'localhost' to database 'CorrectDB'

Is it something to do with the fact that it is trying to ssh around on the same server that it is starting from?

Note that syncing the files works fine:

drush rsync @prod-studies:%files/ @dev-studies:%files


texts:
I need to output a field in a view as a field, how can I make part of the path the value of a CCK field?

For example if for a given item, my CCK value = '19' how can I make my path automatically be website.com/directory/19?


texts: Drupal and Require.js not playing nice - double load of jQuery

texts:
I’ve been given a design library from a large cooperate client built utilizing Bootstrap 3 and Require.js. It’s very robust and well-built with the various scripts using Require.js to load jQuery. Problem is, Drupal has already loaded jQuery and the double load is causing some items to fail. If I remove all the Require.js calls, Drupal jQuery stuff works great. If I remove the base Drupal jQuery file, all the stuff using the Require.js stuff works great. Here’ are options I have considered:

Stop jQuery from loading with Drupal, use require to load jQuery on
every page - I haven’t tried this yet, but it just seems wrong. I
think I can remove jQuery with hook_library_alter() in my theme?
Wondering if anyone has tried this… My front end and admin screens
actually use 2 different themes, so I think I'd have to modify both.
Stop jQuery from loading with Require.js – I tried this and none of
the other libraries that are loaded with require.js can find query
if it’s not loaded with  Require.js, so I don’t think this option
works. This is my first time using require.js so maybe there is some
fun fix for this I haven't figured out?
Add all libraries to the site with Drupal – This seems like a lot of
messy work as I would have to remove all the require.js dependencies
in the library, and there is an expectation that we not modify the
library/framework so implementing new releases is easy.

Any other recommendations?


texts:
I have a view called 'Profile' that shows some user fields on my users' profile pages. I'm using the Zen theme and I'd like to change the way these fields are displayed.

As a total newbie in theming, I don't have a clue where to start. I read a lot about template files on the internet, but I don't know if that's what I'm looking for. I'm not asking for help with the CSS code, but for the place where I should put it.

Which files should I adapt?


texts: jQuery length of object to determine existence gives error?

texts:
The following jQuery in my module gives an error that breaks LOTS of other javascript on other modules on the page. I want to know why. Why?

 var pid = $('input[name="product_id"]').attr('value');
 if ( pid.length )
   // do stuff

But this works fine:

var pid = $('input[name="product_id"]').attr('value');
if ( typeof(pid) !== 'undefined' )
  // this works fine

I've been using the first example for years in other environments to test for the existence of an object and it always works. What am I missing?

TIA.


texts:
I just installed Open Atrium 2.0 and noticed, as many people have, that the Issue Tracker functionality is not included. I understand why they didn't want to include it in version 2: to make way for a better solution that fits in with Drupal Core.

However, this functionality is pretty killer for what I use Open Atrium for.

So, other than https://drupal.org/project/oa_worktracker, are there other alternatives to implementing issue tracking within Open Atrium. I guess I'm unaware of a standard issue tracker for D7.


texts: Is it possible to use drush to save a theme setting?

texts:
I need to set a theme setting via a scripting mechanism (specifically phing). Is it possible to use drush to set a very specific theme setting, without passing JSON?

drush vset {theme_setting} {specific_theme_setting}

I can use drush vget theme_{custom_theme}_settings --filter=json and get the JSON string, but I can't (at least I'm not aware of a way) set a specific key item of that array...?


texts: Remove RSS feed icon and create custom RSS feed

texts:
I want to disable the default Drupal 7 RSS feeds located at /rss.xml.
Can this be achieved?
I want to create my own custom RSS feeds.
I have tried with the Views module, but I can't define my own fields, and default feed contains a lot of HTML etc. I just want to create a clean RSS feed with title and body summarized to 150 chars, but without HTML, like in this feed: b.dk/seneste/rss.


texts:
So I have created a product in Commerce: a £15 one-off donation.

I don't need a product page for this (I have a custom block with links for different donation amounts). When you click a link, I want to use the product ID, and push the product straight to checkout.

How would I go about this?


texts: Change quantity of product kit based on attribute

texts:
It's a shop where you can buy drinks. For every bottle/can there has to be an extra item with bottle/can deposit visible to the user.

So for this I added the cans and the deposit as single items. Every can has 3 attributes for the packaging unit of the tray: 6x250ml (default), 12x250ml, 24x250ml.

After that I added a product kit with 1x "can tray 6x250ml" and 6x deposit. This works fine. But if the user selects 1x "12x250ml" the deposit will just calculates the normal 6x.

Now I thought about manipulating the cart before it is visible to the user. For example: Take the quantity of the item, calculate the deposit by the checked packaging unit and multiply by the item quantity. The calculation is pretty simple.

What function/hook can I use to do this?

I tried to deal with hook_uc_cart_item_presave($entity) but it seems, that the function gets triggered once for every product in the product kit. I can't find a solution to check the quantity on the main item as well as the checked attribute and then pass it to the second run for the deposit item.


texts: Merge 2 collumn (Display suite) to one collumn depending on resolution

texts:
In a situation with display suite and two columns (left and right) I would like to accomplish to move everything to the left column and have the ability to reorder the fields.
In a classic situation the whole right column is moved under the left.
For example in the left column I have field1,field2,field3 in the right field4,field5,field6
When resolution is < 800 px I want to end up with a left column with field1,field4, field2,field5,field3,field6.
Not sure how I can make this happen, and any example or suggestion is welcome.

I think one option is to start with one collumn to begin with and build a 2 collumn situation like this: http://demos.wpmission.com/strong-testimonials/examples/two-columns-via-css-column/
But maybe there is other solution to use code to move and rearange the fields from the right to left ds column?

Thx a lot !


texts:
I am confused on how to output links from a content type into a list in HTML. Currently I have the following code.

<div class="lenders-block-content clearfix">
  <ul>
    <?php print render($content['field_link']) ?>
  </ul>
</div>

The output just adds the links back-to-back within an <a> tag.

Is there a way to render the links so its outputted within a <li> tag?

I am using multiple links. When adding a content type you can add up to ten links.


texts:
protected function alterRoutes(RouteCollection $collection) {
    if($route = $collection->get('entity.node.edit_form')) {
      $route->setDefault('_entity_form', '\Drupal\alerts\Form\EditAdvisoryForm');
    }
  }

Causes a permission error. The logs say

Path: /node/1277957/edit?destination=/admin/content.
Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException: in
Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 117 of
/app/web/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

It doesn't seem to prefill the form with the editable info. This is also not content type specific.
Please advise. Other posts close to this do not have an answer.


texts: Views: Use default value from URL for contextual filter, THEN show all if default value empty?

texts:
Short version, general question: You want to pipe in a 'Default value', specifying a URL argument, to a contextual filter in Views 3. You also want all results (the full unfiltered view) to be displayed if this argument in the URL is empty. However, "Default value" and "Display all rows if empty" settings in Views contextual filters are mutually exclusive, and the default if nothing is passed to the filter is to show nothing.

How can you achieve this?

Full version with case specifics: I'm using a Context View with a contextual filter on a Search API index to search based on search terms in a URL: path like "/search/my%20search%20terms, loaded into a Page Manager panels page as a page context so that bits of the view can be dispersed across the page regions. Pretty standard use of Search API Views.

Since you can't specify what arguments or contexts to pass to a context view in Page Manager / Panels when loaded as contexts in the Contexts form (unlike block views etc, loaded as content, where you can explicitly pass in arguments or contexts), I need to tell it which URL argument it will find the search terms in using the 'Provide default' options under Contextual Filters in the Views settings for the view.

This works, but has an unintended side effect - if someone goes to the search page without any terms (navigates to /search or submits an empty search box), they get nothing. I'd like this path to show the full unfiltered view (it's full of search facets and such so just navigating to it without search terms works like a drill-down browse/advanced search page).

If this was a block or loaded as content in panels/page manager, I could set "If no filter value is provided" to show all rows and use panels/page manager to pass in the current URL argument. But, in Views UI, default values and 'Show all' are mutually exclusive.

So, how to use a default value for a contextual filter, then show all if that default value isn't present or is empty?


texts: Form is not rebuilding on "Add another item" in unlimited value entity reference field

texts:
In a content type I have a field of type 'entity reference', 'auto complete' widget with unlimited values.

The whole idea was to give user an option to add referenced node items but only once, Hence selected node items should be excluded for new added fields.

I altered the form to change #autocomplete_path of this field. I took care of altering path for all the added fields, But when clicking on 'Add another Item' it is not updating #autocomplete_path as it should while rebuilding the form. My code could help answer it better way.

In my form_alter

if (isset($form['field_article_test'][LANGUAGE_NONE])) {

  // Loop through all the fields to collect the default set values.
  $selected_nids = array();
  foreach ($form['field_article_test'][LANGUAGE_NONE] as $delta => $field_object) {
    if (is_numeric($delta) && !empty($form['field_article_test'][LANGUAGE_NONE][$delta]['target_id']['#default_value'])) {
      $dval = $form['field_article_test'][LANGUAGE_NONE][$delta]['target_id']['#default_value'];
      $selected_nids[] = substr($dval, (strrpos($dval, '(') + 1), -1);
    }
  }

  //dsm($selected_nids);
  if (count($selected_nids) > 0) {
    // Implode the exsting selected nids so we can pass them in autocomplete custom menu path.
    $nids_hsv = implode('-', $selected_nids);
  }
  else {

    $nids_hsv = '-';
  }
  // Loop through all added fields and get #autocomplete path updated.
  foreach ($form['field_article_test'][LANGUAGE_NONE] as $delta => $field_object) {
    if (is_numeric($delta)) {
      $form['field_article_test'][LANGUAGE_NONE][$delta]['target_id']['#autocomplete_path'] = 'sform/autocomplete/article/' . $nids_hsv;
    }
  }
}

In above code, I collect all selected nodes in variable $nids_hsv and pass to my custom auto complete menu callback so that I can exclude these nids while fetching nodes as options.

Does the form rebuilds on "Add new item" action, if so, Is this possible to update #autocomplete_path of the same field on rebuild of a form?


texts: How to make language choice Required for Taxonomy term

texts:
Is there any way to make the language choice required for taxonomy term.

I'm pretty sure there is a way to perform this.

Otherwise, how can I at least set a default language choice for my taxonomy.
By exemple, I would like to make English as default language. That's mean when the user will create a term the first time, the language choice will be english.

Thanks a lot


texts: PaymentMethodManager() get plugin on NULL ubercart error

texts:
Hi when trying to create an order in checkout state, the order gets created however when trying to view the order it errors out with the error below:

  Error: Call to a member function getPlugin() on null in Drupal\uc_payment\Plugin\PaymentMethodManager->createFromOrder() (line 45 of /srv/bindings/6204a08fb5564631b33e310ef75fe465/code/modules/contrib/ubercart/payment/uc_payment/src/Plugin/PaymentMethodManager.php) #0 /srv/bindings/6204a08fb5564631b33e310ef75fe465/code/modules/contrib/ubercart/payment/uc_payment/src/Plugin/Ubercart/OrderPane/Payment.php(50):

Ubercart version: Version: 8.x-4.0-alpha5+227-dev

My payment methods are all setup however in order creation code we don't need payment method. Anyone facing the same issue?


texts:
Intro:  In the root page of the book, there's an index on the bottom that lists all the child pages.  There are also links to previous and next page in each of those child pages.  Not sure what the correct terminology is for that index.

My problem:   What I would like to do is to completely re-design those links.  Since the book contains mostly videos, I want each link to have a thumbnail of those videos.  Of course, I would modify the content type of the page to upload that thumbnail image.  If I could replace those pages with a panel and a view block for example, that would completely solve the problem. (but not sure if it's possible to create such view to list the child nodes)

Question:  Is there a module to redesign those indexes and/or what are the templates I would need to modify to do that?  Thanks!

Note: Using Drupal 7.  Not a newbie, but not an expert either.


texts:
I am using a Drupal Multiple Site (several sites running on 1 Drupal installation). Each site is part of a subdomain.

For example:

mysite.com
store.mysite.com
blog.mysite.com

Each site has its own separate database. Do I set up Google Analytics on just the main site or on all the sites?

In this post, it says you need to set it up on all the sites. However, it also says you need to  "show the ".domain setting" in footer". I can't find this setting anywhere in the UI.


texts: What is the best practice to split up a long global.css in an Omega theme?

texts: I am building out a theme based on the excellent base theme Omega. I am using the standard CSS files for narrow, normal, etc. My global.css file is getting large. I would like to split it up. Is there any kind of best practice for this in Omega, or should I just do as I would any other Drupal theme?


texts: Messed-up div IDs for ajax-modified form field

texts:
I want to change, using Ajax, some attributes to field2 (a select widget) when field1 changes:

In mymodule.module:

function mymodule_form_NODETYPE_FORM_alter(&$form, &$form_state, $form_id) {
    $form['filed1']["widget"]['#ajax'] = array(
        'callback' => 'on_filed1_change',
        'wrapper' => 'edit-field-filed2-wrapper',
        'event' => 'change',
        'method' => 'replace',
    );
}

function on_filed1_change(array $form, FormStateInterface $form_state)  {
    $form['field2'] = $modified_field2;
    return $form['field2'];
}

This works only the first time.

I found out the following id's have been changed with additional trailing random numbers:

edit-field-field2-wrapper--GCPg2vSCav0 for field2 wrapper <div>
edit-field-field2--EXhOuuWQld8 for field2 <select> element

Since the original Ajax wrapper edit-field-field2-wrapper no longer exists, no further modifications to field2 are possible.

Why does this happen? And how can I prevent this from happening, or use the new IDs as wrapper in the Ajax call?

I'm using 8.6.0-dev.


texts:
I have been trying to get the support ticket system module to work and for some reason I got a problem few problems.

My clients cannot post support tickets or cannot see them.

Every time my client try to post a support ticket they got this error:

  Unable to subscribe user, USERNAME does not have permission to view
  this ticket.

And if my client try to see a post that the administrator post they got an access denied.

My understanding is that this problem it was with the permission. So I gave the clients all permission except to administrate the module.

These are the permission that they have

Support

Can administer state
Can suppress notification
Can subscribe other users to notifications
Download mail via support/fetch
View other users tickets
Can select state
Can select priority
Can select client
Can assign tickets to self
Can assign tickets to any user
Access CLIENT tickets.

Node

Support ticket: Create new content
Support ticket: Edit own content
Support ticket: Delete own content
 -

I have follow all the steps from the INSTALL.txt from the module.
I have rebuild my permissions.

How can I troubleshoot this problem ? I'm doing something wrong ?

[EDIT]

I figure out that if I give the user this permission Administer support they are going to have access to view this tickets. But they also have access to do anything with the module something that I dont want.


texts: Rules, Flags, Follower and New Content Notification

texts:
I am trying to setup a couple of rules. So far I have messed with rules some but since I am new, haven't had any success. This is what I am trying to achieve.

Have created a user flag called FOLLOW. (Flag module)

These are the two rules I am trying to set.

Every time a user FOLLOWs another user, the user being followed gets an email saying: Hey user [username] is now following you.
The second rule will send an email to a user every time someone they follow posts new content of type Article.
Example: I am an authenticated user following JOE. Every time JOE posts an article I will get an email saying: Hey JOE who you are following just published a new article. Check it at this url [url-link token].

Any help from Rules experts will be greatly appreciated.

Thank you for taking the time to read this.


texts: Add an item to a list for Rules and References

texts:
I have a Node Reference in Users.

When I set Add an item to a list with Node identifier for some event, it doesn't add.
It looks like this

Add an item to a list
Parameter: List: [account:field-badges], Item to add: 28

Set a data value works with comma separated list.


texts: How use settings.local.php with Acquia Cloud

texts:
I try to setup my .gitignore file. My local repo is a clone from my Drupal 8 distro from Acquia Cloud.

(I want to theme my template locally and then, step by step I want to push it to Dev on Acquia Cloud.)

So regarding handeling settings.php, whether or not to ignore settings.php and whether or not use settings.local.php:

If I look in my current settings.php is see this:

// On Acquia Cloud, this include file configures Drupal to use the correct
// database in each site environment (Dev, Stage, or Prod). To use this
// settings.php for development on your local workstation, set $db_url
// (Drupal 5 or 6) or $databases (Drupal 7 or 8) as described in comments above.

I am confused and don't know anymore how to setup my .gitignore file with all this information and whether or not use settings.local.php. Please can somebody advice my what I have to do exactly, so it's setup correctly from the beginning.


texts:
function sms_user_delete($uid, $number = FALSE) {
  userfieldmobil_user_update($account->uid); // my custom field about users i call this manually.
  $query = db_delete('sms_user')
    ->condition('uid', $uid);
  if ($number) {
    $query->condition('number', $number);
  }
  $num_deleted = $query->execute();
}

function userfieldmobil_user_update($uid) { // i make it manually not able to update this
$num_updated = db_update('field_data_field_mobilnumber')
->fields(array(
'field_mobilnumber_value' => '',
))
->condition('entity_id', $uid, '>=')
->execute();
}

What i'm doing wrong sms_user delete OK but my custom field has value but not updated.


texts:
I need to set the og:iamge metatag using the Metatag Module.
Since there is no option for editing the names of the metatags or adding custom ones, I'm unsure if this is possible.

Is it possible to do this not programatically/from the backend?


texts: What is a front page in drupal ($is_front)?

texts:
Nice to know for drupal beginners:

What is a front page in drupal and particularly in which case is $is_front true ?


texts:
I have a twig template for a custom block, I want the entire block to be wrapped in a link. I'm using the link field, but I'm not sure how to get the url from the field within the twig template. This seems like it should work, but doesn't:

{{ content.field_link.0.getUri() }}

I've looked at url() and path(), but they are dealing with routing, so I don't think that's what I'm looking for.

Note, I would like to use either external or internal links in the field.


texts: D7: HTML email sent shows markup, how to fix?

texts:
Im using Linode VPS but mails are routed via SMTP authentication to Google. Email is sending correctly and I'm using mail system and html mail with smtp authentication.

When I send test email as html to test mailbox, it shows markup and wont render to html. How can I fix this?

HTML Mail > Send Test

Creating HTML mail and sending it with SmtpMailSystem sending class. Output when viewed at gmail receiving it:

This is a test letter.

Lets add some html

So all markup is visible. What I'm missing?


texts: How can I print a custom message for unpublished nodes upon submission?

texts:
Structure > Content type > ContentX > Edit > Unchecked published.

Structure > People > Permission > Anonymous users have access to create node for Content Type "ContentX".

An anonymous user goes to the page ../node/add/geo and fill up the form and be able to save the unpublished node. However, the user goes not get any message stating that the node is saved. I like to display a message to the user that user is saved and it is pending approval.

Based on my research, I need Rules module.

Enabled the Rules module for D8.

In Rules module, I like to configure it to display a message to the user when the unpublished node is saved.

Here I am not sure what to enter:

How would I configure the settings in Rules module to display a message when a node from a specific content type is saved but not published?


texts: How to upgrade outdated Drupal 7 version

texts: I'm using Drupal 7.10 which is an outdated version. Is it safe to just upgrade to the latest version or should I upgrade version by version from 7.11 until the latest version 7.21?


texts: How to enable Views caching for all pages instead of only the first page?

texts:
Problem

I'm trying to cache my view (search specific). However doing so only caches a single page of results and stops me from changing pages either with the pager, or by manually changing the URL.

Has anyone else run into this problem? And if so how have you fixed it?

Details & Thoughts

The hyperlinks on the pager still look ok. It's just that using them only gives the first page of results so it seems to do nothing.

It seems like Drupal is only capable of caching a single page of results and then returns that for all queries.

For example: If I change the caching (signalling the cache needs to be rebuilt) then enter the URL for page 3 of views results, then it caches that instead of the first page and will only return that for all searches.

My Set-Up is:

View Based On: Search API index.
Caching: Search Specific | 1 Hour

And caching mechanism's I have running are:

Memcached
Authcache
Varnish

I don't think it's related to Authcache. If I turn it off I get the same problem. (I presume view caching is separate and un-related to caching based on users. Also see the next point.)

I'm running Authcache Debug and it's telling me that it can't cache the view because of a client form token. (I have an exposed form on the views page which will block Authcache.)


texts: Caching pages with boost based on a cookie value

texts:
I have a Drupal website where a part of each page varies depending on the value of a certain cookie. In order to use Boost in this situation, I was thinking of rewriting the cookie value into a query parameter, because Boost takes these into acccount for its cache.

To achieve this, I put the following lines in my .htaccess before the Boost code:

RewriteCond %{HTTP_COOKIE} cookie=([a-zA-Z0-9\-]+)
RewriteRule ^(.*)$ $1?cookie=%1 [QSA]

I tested this on a simple PHP script which shows all GET parameters, and the cookie parameter is added based on the cookie. Which is the way it should be. I also tested that these rules actually rewrite the %{QUERY_STRING} for later use, and they seem to do that. However, Boost does not seem to take into account this new query parameter.

Any ideas about what could be wrong? Does Boost do something special with the query string?

Thanks in advance!


texts: Attach shipping courier selection at drupal cart commerce line item

texts:
Anyone have Idea how to attach shipping courier selection at drupal commerce cart? As seen at capture bellow, I want to attach shipping courier selection at cart, so I can pick shipping courier for each order line item. Anyone have Idea?

https://lh3.googleusercontent.com/-OMoDWmIZcyo/VFkLxBQGcWI/AAAAAAAACtc/lCidjfXgeSI/w1043-h396-no/Capture.PNG


texts: taking in account access forbidden items in views total row count

texts:
the {{ view.total_rows }} inspired by Get total row count in views-view-fields.html.twig
is not accurate when some rows are not accessible to the user.
Any idea how can we display the current total row accessible to the user?


texts: Views Output Field as Link: Change link text

texts:
I've got a View showing some images. I want to include a link to the image which automatically downloads the file. I'm using the DownloadFile module which makes sure the browser actually downloads the image instead of just displaying it.

I've added the Image field that I want displayed in my View, and I'm checking the Output this field as a link but I don't see any field where I can control the link text. I see title, rel, etc., but I want the actual link text to simply say "Download".

i.e.:

Download

How can I control the link text of the link being rendered by Views?


texts: Move views global text field into code (attached fields and fields via relationships)

texts:
I have recently done away with using views php as it is unsafe. I have read a comment by @letharion whereby he mentions that adding a php directive disable_functions = eval is a good practice to tighten up security.

I have a problem with the views global text field:

One cannot run php functions on fields
It is a bit messy to have a lot of the html markup in the database
It runs the markup through filter_xss (which is good) without giving
one the flexibility of expanding on the allowed tags.

I have read this question: Move php in views to module and would like to broaden it a bit.

I have implemented the accepted answer and it works with a slight modification:

custom.module:

function custom_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'custom') . '/views',
  );
}

function custom_print_my_link($nid, $type){
  return $nid . '-' . $type;
}

custom.views.inc:

function custom_views_data() {
  $data['node']['custom_stuff'] = array(
    'field' => array(
      'title' => t('Custom link'),
      'help' => t('Provide a custom content link.'),
      'handler' => 'views_handler_field_node_custom_stuff',
    ),
  );
  return $data;
}

views_handler_field_node_link_custom_stuff:

class views_handler_field_node_custom_stuff extends views_handler_field_node {
  function construct() {
    parent::construct();
    $this->additional_fields['type'] = 'type';
    $this->additional_fields['nid'] = 'nid'; // this had to be added !!!
  }
  function query() {
    $this->ensure_my_table();
    $this->add_additional_fields();
  }
  function render($values) {
    $type = $this->get_value($values, 'type');
    $nid = $this->get_value($values, 'nid');
    return custom_print_my_link($nid, $type);
  }
};

I have set up the view with two hidden fields (nid and type) that appear before this custom field.

This works perfectly for fields attached to the node table.

My question is: How do I implement it for attached fields, and access the fields across relationships as well?


texts: How to disable Ubercart order mail notification?

texts:
Everytime a customer places an order, the store owner gets an email with the order invoice. Where can I disable this? (the webshop is still in production)

Also, is it possible to set up a conditional to only send an e-mail when the customer has paid? (right now paypal payments works)


texts: Unsupported operand types error when creating new Webform handler

texts:
Following the example here: https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-programmatically-add-a-handler-to-a-new-webform

I've created my handler manager sucessfully, however, when I go to create the handler, I get the error

  Error: Unsupported operand types in Drupal\webform\Plugin\WebformHandlerBase->setConfiguration() (line 363 of /var/www/sitename/web/modules/contrib/webform/src/Plugin/WebformHandlerBase.php

Here's a sample of the code I'm using to get this error

$webform_machine_name = 'form_id';
$webform = \Drupal\webform\Entity\Webform::load($webform_machine_name);

$handler_manager = \Drupal::service('plugin.manager.webform.handler');

// Create webform handler.
$handler_configuration = [
  'id' => 'my_form_handler',
  'label' => 'My form handler',
  'handler_id' => 'my_form_handler',
  'status' => 1,
  'weight' => 0,
  'settings' => [],
];

$handler = $handler_manager->createInstance('my_form_handler', $handler_configuration );


texts: How do Organic groups and virtual sites relate to each other?

texts:
I just want to know that a site which is built in Openscholar, a LMS for Drupal.

Therefore, how organic group is tied up with virtual sites? Also I want to know the the Views module's role in such circumstances.


texts: Views: how can I cleanly add a row of arbitrary text within a collection of fields?

texts:
I have a view that displays fields.  I want to add a text-based explanation as one of the rows in the view.  The display looks like this:

Field A (Picture)
Text 1: A row that contains explanatory text that appears regardless of whether there is any data below or not
Field B (Data- may or may not be present)
Field C (Data- may or may not be present)
Field D (Data- may or may not be present)
Field E (Data- may or may not be present)

What I'm currently doing to implement Text 1 is adding a field that will definitely always be available (user ID, etc.) and rewriting it to show the text I want to display.  This does what I want but it feels like an ugly hack.  Is there a better way to do this?


texts: Show exposed filter value when returning results

texts: I can't seem to figure this one out. I have a view that returns nodes with a set of taxonomy term exposed filters. What I would like to do is show the selection the user has made on the screen (e.g "Showing results for..."), preferably using a text field in the views header else through the views template files. Can anyone help me please?


texts: Entire site broken because of one custom module! No pages found anymore. How to fix?

texts:
I wrote a custom module and implemented it.  Now I cannot access any pages on my drupal site.  They all say something like: Page not found.  The requested page "/" could not be found.

I removed the module by hand from the table by running:

UPDATE system SET status=0 WHERE name='MyModule';

Even with this, no pages are working anymore.  I thought it was an htaccess issue or a clean url issue, but even doing /?q=user does not get me to my login screen.  Any ideas on how implementing my one custom module broke the entire website?  My module was basically this:

function MyModule_menu() {
  $items['MyModule_views'] = array(
    'title' => 'MyModule test',
    'page callback' => 'MyModule_list',
    'access callback' => TRUE,
    'type' => 'MENU_CALLBACK',
  );
  return $items;
}

function MyModule_list() {
  return t('hello');
}


texts: Module: See Last Modified Articles And Submitted Articles

texts: I would like to be able to see who did what and what articles were submitted, possibly on the admin dashboard - is there any module that you would recommend?


texts: Drupal 7, Ubercart, Product search by price range

texts: I'm using Ubercart 3.x, Drupal7. Can anybody tell me how can I create a form for searching in products with price in specified interval? I.e. user should fill this form with minimum price in the interval and maximum price and after posting form he will see all suiting products.


texts: Add large number of images to drupal site

texts:
I am trying to create an image gallery in my drupal site from the backend. Also I want to add images to existing content types since there are large number of nodes and attaching image to each of them from the front end is not feasible. What I have understood follows here:

The database contains the table named files that consists of path and type of each file uploaded from fronted. The fid corresponding to each of these paths is used in corresponding content type table to produce images at required node.

Plase tell me if this approach is wrong:

I wanted to upload images in bulk and add image names and there path in the files table as well as corresponding fid's in the content type tables.

But this does not work. Can someone help me with this. Have I analysed it wrongly?


texts:
I'm currently using the insert module to allow forum users to easily upload a image and insert it into the forum topic body. I'm looking for a way to allow users replying to a topic to do the same thing. So, for example, user A could create a thread titled "Post your photos on mountains here" and users could reply to the thread and post their photos.

I'm sure this is possible through the text editor with IMCE or similar, but I find that route to confusing for simple forum users. That's why i like the insert mod, select your file and hit upload/insert. simple. So, any alternatives or something I'm overlooking?


texts:
Can I add a custom table class name to a View that outputs a table, Or just add the name of the view to the table class name? There isn't a setting in Views to add a table class name, you can only add row class names.

My View name is view-a1. I would like to the name of the View to all table class names.I am trying to do it with hook_preprocess_views_view_table. But I don't know how.

The default twig template uses this markup

The method in the url below worked, it will add a custom hardcoded table class name. I changed the hook in the example to hook_preprocess_views_view_table. What I really want to do it add the name of the View as the table class name. How can I do that?

https://www.drupal.org/docs/8/theming-drupal-8/modifying-attributes-in-a-theme-file


texts: Integrating FBA (or Amazon MWS) with Ubercart

texts: I am going to be rebuilding an ecommerce site in Drupal 8 using Ubercart.  The site was originally built with Drupal 6 and Ubercart and had Amazon FWS integrated into the store.  Is there anything similar I can use for Drupal 8?  Basically the client needs FBA (fulfillment by Amazon) integrated into the site.


texts:
I have a view of type log entries. The message field can be pretty big, so I set rewrite options to truncate it to 256 chars and add a read more link, with path set to
admin/reports/dblog/event/{{ wid }}

to display the full message details.
When clicking on the link, it loads the full page, replacing the view. I'd like to be able to instead display the full message in a colorbox (or other popup), so the view will remain on the page. Typically, I use this to see a summary of messages and I'd like to be able to more quickly click to see the detail without the overhead of a full page load, followed by another page load to get back to the view. Not sure how to accomplish this.
I've tried colorbox_load and colorbox_simple_load, which didn't work. What would be a good approach for this? Is it possible to override views/Plugin/views/field/FieldPluginBase/renderText() and add a colorbox link to $more_link_path? Or perhaps something simpler, maybe not even using colorbox?


texts: How do I ensure that a 'no results' view block is still refreshed by Block Refresh

texts:
I have Block Refresh enabled on my site.  It does a great job refreshing content blocks unless the original block load contains zero results.  If a block is loaded without results, and a new node (which should appear in the block) is created, the new node will not appear in the block unless the page is refreshed.  It seems that the refresh code is not active unless the view is loaded with at least one item of content.  Is there a way to ensure that the view always loads?  I'm thinking that I need to change the 'no results' behavior in my view.

Edit =========

I am currently setting the 'no results' behavior to 'Global: Result summary' and setting the response to 'Empty'.  This seems to work.


texts: How to get the list of fields available in the user entity

texts:
I have created a custom field to allow users to set their privacy settings based on the fields attached into their account.

I would like to get the list of fields available in the user entity so that I can create a table select form where the users can select the permission per field based on account type.

How to do it in a custom field?

Here's my curreny code:

  namespace Drupal\privacy_settings\Plugin\Field\FieldType;

  /**
   * @FieldType(
   *   id = "privacy_settings",
   *   label = @Translation("Privacy Settings"),
   *   description = @Translation("Privacy Settings"),
   *   default_widget = "privacy_settings_widget",
   *   default_formatter = "privacy_settings_formatter_default"
   * )
   */
  class PrivacySettingsField extends FieldItemBase {

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties['value'] = DataDefinition::create('string')
      ->setLabel(new TranslatableMarkup('@operation access', ['@operation' => 'Privacy Settings']));
    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    return [
      'columns' => [
        'value' => [
          'type' => 'blob',
          'size' => 'big',
          'serialize' => TRUE,
          'not null' => TRUE,
        ],
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function setValue($values, $notify = TRUE) {
    if (isset($values['value']['table']['rows'])) {
      $values['value'] = serialize($values['value']['table']['rows']);
    }
    parent::setValue($values, $notify);
  }

  /**
   * {@inheritdoc}
   */
  public function isEmpty() {
    $value = $this->get('value')->getValue();
    return $value === NULL || $value === '';
  }

  /**
   * Return the list of operations available.
   *
   * @return array
   *   The list of operations.
   */
  public function getOperations() {
   return [
      t('Account Type 1'),
      t('Account Type 2'),
      t('Account Type 3')
    ];
  }

}


texts: How to run the Flags module after the Rules module?

texts:
As a sequence on this question, I'd like to deduct 2 User Points when a user's first reaction on an Article is deleted (I mentioned my flag 'First reaction' there). I created a Rule 'Reaction removed' with the following settings:

EVENTS: After deleting a comment

CONDITIONS:

Comment is flagged Parameter: Flag: First reaction, comment: [comment], User on whose behalf to check: [comment:author]

ACTIONS:

Grant points to a user Parameter: User: [comment:author], Points: -2, Points category: Reaction, Operation: Delete, Moderate: Automatically approved
Unflag a Node: Parameter: Flag: Commented on a node, Node: [comment:node], User on whose behalf to flag: [comment:author], Skip permission check: false

I thought it looked all right, but it doesn't work, because apparently the comment is always handled as if it's unflagged, even when it's stored in the database as flagged with 'First comment'!

This is the Rules evalution log:

0 ms Reacting on event After deleting a comment.
11.674 ms Evaluating conditions of rule Reaction removed. [edit]
15.543 ms The condition user_has_role evaluated to FALSE [edit]
28.531 ms The condition flag_flagged_comment evaluated to FALSE [edit]  <--- going wrong here
28.547 ms AND evaluated to FALSE.
28.575 ms Finished reacting on event After deleting a comment

What went wrong and how can I solve it?


texts: Cron job to transfer files to remote server

texts: How would I go about scheduling a monthly file transfer (via FTP) to send files in a specific directory on my remote VPS to a server on my internal Corporate network? Once files are transferred, I'd also like to job to delete the files on the VPS?


texts: How to change url of views exposed filter, where will be send a request

texts:
I need to change a request in javascript of views exposed filter.
I want send value clean url arguments in the exposed filter.

I have a part of code but it doesnt work.
Will be gratefull for the help.

Drupal.behaviors.DoCategoriesForm = {
attach: function (context, settings) {
var categories = settings.drucity_do.categories;

$('select.do-advert-category', context).once('DoCategoriesForm', function () {
var form = $(this).parents('form');
$(this).attr('name', '');
$(this).change(function() {
var value = $(this).val();
$(form).attr('action', categories[value]);
});
});
}


texts: How do I reference (what is the syntax I have to use) to get the data of my Profile2 custom fields?

texts:
I have used the Profile2 module (D7) and created some custom fields for my users. One of those fields (for example) is "field_company" with the label "Company."

Now I am using a computed field (Company) on a content type (Games). When user creates a Game, I want my computed field Company to be computed/populated automatically, based on the "field_company" field I have set in my profile2.

I am trying to find how to get that information. This is as far I got, so far, but it doesn't work.

$entity_field[0]['value'] = "";
$name=$profile2->field_onoma[LANGUAGE_NONE][0]['value'];
$entity_field[0]['value'] = $name;


texts:
I'm using textbox replace in a view for an ICAL and I need to get the special characters to render. Right now calendars like Google Calendar just shows the encoded characters instead of the decoded characters. I want ' instead of this ' .

right now it's not doing anything. I've tried multiple ways to pull this off using  |render or using replace | but nothing works. It still just shows up with the encoded characters. example below

{% set special_1 = '&#039;' %}
{% set result_1 = "'" %}
{% set special_2 = '&amp;' %}
{% set result_2 = '&' %}

{{ title_1|replace({ (special_1): result_1, (special_2): result_2 }) }} - {{ field_sport|replace({ (special_1): result_1, (special_2): result_2 }) }}


texts: Field type where big data is not loaded into memory if not needed

texts:
Background
Normally when an entity is loaded in D7, the 'field_attach_load' step will load all the data from fields into the entity object.
The field_sql_storage_field_storage_load() loads the data from all columns by default.
On a page with a view, this could happen for many entities.
Use case
We want to create a field to be used for very long html.
This content should only be loaded on specific pages where this html is actually being displayed.
Problem
We want to avoid the big html from being loaded into memory in the field_attach_load step, to avoid memory problems.
Solutions considered so far
I think we would need a custom field type with its own loading logic.
I have not found any contrib solutions yet.
The obstacle seems to be the default field_attach_load logic, which always loads all the columns from the field table. I don't see a way around that.
We could store the data in a separate table, but this would need babysitting to keep the extra table in sync with the field table.


texts: How to post to remote url on form submit

texts:
We want to silently submit a Drupal6 form to a marketing partner, and redirect the user to page on our site.  Is this the correct syntax?

function my_form_submit($form, &$form_state) {
  $form_state['action'] = url('http://example.com/?method=cSurveyWebservice.submit&mode=test');
  $form_state['redirect'] = array('campaign/thank-you');
}

Certainly it processes and redirects, although I'm not sure how to independently validate if the form is actually posted to the specified URL.


texts:
I'm trying to add an ajax link to my tableselect rows and replace part of this form with ajax.

$options = array();
foreach ($result as $camp) {
    $options[$camp->uuid] = array(
        'select_link' => array('data' => array(
            '#type' => 'link',
            '#name' => 'select_link',
            '#title' => t('use'),
            '#href' => 'ajax_use_data_callback/nojs/',
            '#attributes' => array(
                'class'=>array(0=>'use-ajax')
            ),
            '#ajax' => array(
                'wrapper' => 'selected-data-div',
                'method' => 'replace',
            ),
        )),

        ...

    );
}

This triggers an alert with a 404 error and the site's default html. How do I tell this ajax link to be handled like a regular ajax form element?


texts: How to change payment state programmatically?

texts:
I had created a custom module to update order state and payment state. In my controller I used the following code to change the order state of order.

 $order = \Drupal\commerce_order\Entity\Order::load($order_id);

 if ($payment_status === 'payment.captured'){
   $order->set('state', 'completed');
   $order->save();
 }
 else {
   $order->set('state', 'pending');
   $order->save();
 }

How can I now change the payment state of a payment which comes inside that order?

This is the screenshot of my payment. Now the payment state is pending. I want to change it to something else by using code, for example completed.