texts: How to get count on how many times a term is used on a node

texts:
I'm about to create a Tag cloud module that shall have a block showing a list of all terms. The most used terms shall be in big text; the terms that not used often shall be in small text, as in the following screenshot.

I want to have a $count variable that holds the count of how many times each term is used.

I think that I can do so:

$database = \Drupal::database();
$terms_count = $database
->query('SELECT COUNT(tid) FROM {taxonomy_index}')
->execute();

foreach($terms_count as $term_count) {
  print $term_count;
}

But it doesn't show anything.


texts: programmatically check if any field in a node is edited

texts:
I have a content type blog, it has several fields.If any one of the fields changes I want to call a function. How do I check even if one field has been changed.
I tried checking comparing timestamp and revision_timestamp values available for $node and $node->original objects in hook_node_presave. But it did not help.
Can someone help me with this?


texts: Multiple owners for commerce order [or] Allow non-owner to pay for an commerce order

texts:
Scenario:

Drupal site with "Member" and "Spouse" roles.
For any given married couple, Member and Spouse each have their own user accounts.
entity reference field from spouse defines the relationship between the 2 users
an order exists, belonging to Member user (order->uid)

Desired functionality:

Regardless of the uid value for order, allow either Member or Spouse to proceed through checkout and payment for the order.

I realize this is not possible through vanilla Drupal Commerce.  I'm looking for any ideas that will help me figure out how to implement this via existing Drupal techniques, or a custom module.

Specific questions:

Has anyone achieved this successfully?
Are the any specific ways (Drupal techniques) that could help solve this?
What specific hooks or overrides should I be looking at?

Bonus points for elegant workarounds or shortcuts like a simple hook_access override, or a clever way to just-in-time reassign the order uid.


texts:
I want to create a custom login and register page. I want both forms to show on the frontpage in the content area of my template above each other and not on separate nodes. Also, I would like to try to reuse the already existing code for validation of the forms.

I have looked around and found different ways to achieve this so I wonder what's the best way to do this..custom block, module or inside template or...?

Links to content or particular examples would be appreciated.


texts:
Helloo !
I am using the D7 reference option limit module. I have two fields "primary" and "secondary" and I managed to reduce the choices of secondary based on the value of primary using this module. Both of them are required field in the user registration form.
I have a small question, when I set no value for primary, I get for the secondary field: No options are available for the current form values. Try selecting different values for the following fields: Primary.  This is the good behaviour that I want but I want to hide secondary when no value is set for primary instead of displaying this message..
Is that possible? In other words I want to keep secondary hidden until primary has a value.


texts:
When I create a node with entity translation and choose a language the field body is wrong.

language = 'en'
field_body[und].

This only happens with a specific content type and with new ones, not with others.
What's broken?
What can I check?


texts: Why are there two database tables to handle taxonomy terms structure

texts:
There is a taxonomy_term_data table and there is a taxonomy_term_hierarchy table.  Why are there 2 tables, instead of them being combined?

taxonomy_term_hierachy strucutre

description of table: Stores the hierarchical relationship between
field: tid: 'Primary Key: the taxonomy_term_data.tid of the term'
field: parent: 'Primary Key: The taxonomy_term_data.tid of the term's parent.
0 indicates no parent.'

taxonomy_term_data structure:

description of table: Stores term information.
fields: vid, name, description, format, weight

Question motivation
I am the maintainer of the draggableviews module.  Currently module is using just 1 table.  Going forward, the module's goal is to mimic taxonomy structure.  Tried to search the web for an answer but could not find one.


texts: How do I render a field twice with two different field formatters?

texts:
So there was already the same question for D7 (How do I render a field on a node twice with two different field formatters?) but now i wanted to know how to do this in d8.

Maybe this helps a little bit, but i could not get it working.
Rendering arbitrary field values without a parent entity in Drupal 8


texts: feeds importer importing from several sources

texts:
Is it possible to run one feed importer on several sources?

Currently my code is as follow:

My importer module file is

function myModule_import_feeds_plugins() {
  $info = array();
  $info['xml_parser'] = array(
    'name' => 'XML feed parser',
    'description' => 'Imports XML feed.',
    'help' => '',
    'handler' => array(
      'parent' => 'FeedsParser',
      'class' => 'myXmlParser',
      'file' => 'my_xml_parser.inc',
      'path' => drupal_get_path('module', 'myModule_import') . '/plugins/feeds',
    ),
  );

My parser is:

class myXmlParser extends FeedsParser {

  /**
   * Implements FeedsParser::parse().
   */
  public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
    $feed = new SimpleXMLElement($fetcher_result->getRaw());
    $source_feed = $source->config['FeedsHTTPFetcher'];
    $user_tags = isset($source_feed['user_tags'][0]) ? explode(',', $source_feed['user_tags']) : array('tag1', 'tag2');

    $result = new FeedsParserResult();
    $result->title = 'feed importer';
    $result->items = array();
    #$fetcher_result->
    foreach ($feed->channel->item as $item) {
      // Skip if title doesn't
      if ((string) $item->title) {
        $result->items[] = array(
          'title' => (string) $item->title,
          'callout' => '<p>'.(string) $item->description.'</p>', // wrap light_html in P tags
          'pubdate' => (string) $item->pubDate, // _parser_common_syndication_parse_date()
          'url' => (string) $item->link,
          'image_url' => (string) $item->thumb, // http://placekitten.com/g/200/300
          'image_alt' => (string) $item->alt,
          'published' => 1,
          'tags' => $user_tags,
        );
      }
    }

    return $result;
  }

feed screen looks like this

I would like to add an additional field for an optional URL. This way the user can include several sources and import from different places at the same time.

I could not find a way to do so. Ideas?


texts: How do I use the login for an external application?

texts:
Long ago I built a php based application for room reservations which basically ran on its own – outside the website's CMS. It was part of what I would now call a custom made intranet – or "custom-app".

Now the main website finally runs on drupal – but now we have the drupal login and the custom-app login. How could I now 'teach' the custom-app to accept visitors that are already logged in to the dp based CMS?

I know, the 'easiest' or actually 'most correct' way of doing this would probably be to develop the custom-app into a module. But are there other ways e.g. to pass the login information over to the custom-app? Any pointers would help. Thank you!

update1: both are running on the same server under the same domain.

update2: I finally came across this question "How to call drupal_bootstrap from custom file in subfolder?" – I guess going bootstrap would be the right direction for now…


texts: Show specific articles when clicking on tag

texts:
I'm working with a page view that contains articles and a block view that contains tags. I would like to display all the articles tagged with the tag I click.

So when clicking on the CITY tag I only want to display the articles tagged with CITY, does anyone know how I can achieve this?

Thanks


texts: UC Node Checkout for pay to publish user content?

texts:
Is there a way to use this module for a pay to publish set up, like in classifieds where user adds content and then pays to publish it in D7?

Generally speaking that is....I like many others having been paying for a module but the person who created it has disappeared now and it is first time ever I've paid for something re drupal. Normally I study up on anything open source- which just goes to show there are no shortcuts in this world.


texts: Disable "Operating in maintenance mode. Go online."

texts:
The solution for Drupal 7 is using the following code, as per answer of How can I disable the message “Operating in maintenance mode. Go online.” in maintenance mode?

function mytheme_preprocess_page(&$vars) {
  if (variable_get('maintenance_mode', 0)) {
    $message_count = count($_SESSION['messages']['status']);
    if($message_count > 1) {
      array_shift($_SESSION['messages']['status']);
    }
    else {
      unset($_SESSION['messages']['status']);
    }
  }
}

What is the solution for Drupal 8?

I cannot figure out how to do it with https://www.drupal.org/project/disable_messages.

Hide/disable the message for everyone including the user #1.


texts: ob_start() error running Devel on Search API + Search views page

texts:
How can I run Devel on search pages?  I keep getting an ob_start() error.  How can I run debug on these search pages.

The error is:

Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0


texts: how to import from csv file to EntityForm

texts:
I have two drupal sites with exactly same entity forms, I would like to import entityform submissions from site A to entityform submissions site B.

I had a look into feed modules which works very well to import node but there is no option for to import data into entityform.


texts: Programmatically specifying pathauto alias

texts:
I am working on a custom module to specify the pathauto alias of a new node, based on taxonomy terms that a user sets when they create the node. For instance, for my blog post content type, the alias would be auto-generated as /blogs/this-is-a-new-blog-post. However, if the category taxonomy is set to be special-project, I want to change the alias to be /special-project/blog/this-is-a-new-blog-post.

I'm able to load the node using hook_entity_insert(). However, I haven't been able to figure out how to set the alias.

I've found examples of how to set the path when creating a new node, but I already have an existing node object in this hook. I've tried debugging the path from the entity using $entity->toUrl()->getInternalPath(), but that just gives me the default URL (/node/123), not the alias. Trying to debug $node->path, I get an enormous stdClass object that I can't really suss out. Trying to debug $node->path->alias using drupal_set_message("alias: " . $node->path->alias);, I get this: alias:.

How can I see and alter the path alias on an existing node?


texts: How to delete a cck field base in Drupal 6

texts:
I have programatically created some cck fields with this function:

content_field_instance_create($field)

and I tried to delete them with this:

content_field_instance_delete($field_name, 'product', FALSE)

However, this didn't actually delete the cck field from the Product types database table. The fields didn't show up on the UI edit page but they still exist in the database, which is causing me some issues.
How can I systematically make sure the database entry is wipes as well?


texts: Creating a Faculty and Staff Directory with Links to their Profile Pages

texts:
If I add a field to a regular content type, I can configure that field in a view to link to the page for that content type.  On the other hand, if I add a field to a User type, it seems that I cannot link that field in a view back to the user profile.  How can I link a User field to the respective user's profile page?

Cheers.


texts: Can the Devel Generate module generate content for all possible permutations and combinations?

texts:
I love the Devel Generate module as it helps me to create test content very quickly. Random content that the module generates is sufficient most of the times.

But at times I would like to have content for all the permutations and combinations. For example let us say that a content type has three optional fields. So in total I would like to have 8 nodes of that type created that cover all the permutations.

Is this something that can be achieved with the Devel module?


texts: Prevent image uploads with embedded code

texts:
I have a site which allows anonymous users to create a node with an image (the site allows people to submit images with quote memes so that the authenticity of the quote can be verified, quotefail.com).

I just learned, the hard way, that people can upload php code in the image field... somehow. That php code was then used to send out tons of spam from my server. Joy.

How can I make sure that image uploads are really, really only image uploads? This site depends on random people being able to submit images for validation, so I can't just disable the upload.


texts:
In Drupal 6 we had content type export import, I cannot find this in Drupal 7.

Any tips please?


texts:
I am using Drupal 7 and I have added some code to my template.php file in my theme (which I found on a Drupal tutorial) so I can use a custom template for the user login form. The form works and it is using the custom template but it is generating these errors:

Notice: Undefined index: classes_array in template_process() (line 2527 of /includes/theme.inc).
Warning: implode(): Invalid arguments passed in template_process() (line 2527 of /includes/theme.inc).
Notice: Undefined index: attributes_array in template_process() (line 2533 of /includes/theme.inc).
Notice: Undefined index: title_attributes_array in template_process() (line 2534 of /includes/theme.inc).
Notice: Undefined index: content_attributes_array in template_process() (line 2535 of /includes/theme.inc).

The code I have in my template.php file is:

function cr_theme() {
  $items = array();

  $items['user_login'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'cr') . '/templates',
    'template' => 'user-login',
    'preprocess functions' => array(
       'cr_preprocess_user_login'
    ),
  );
  return $items;
}

function cr_preprocess_user_login(&$vars) {
  $vars['forgot_link'] = l(t('Forgot password?'),'user/password');
}

and my user-login.tpl.php file contains:

  <?php print drupal_render_children($form) ?>

<?php print render($forgot_link); ?>

I have been trying to find the cause of the errors which I think is probably something I have not added to my cr_theme() function but now need some help.


texts: How to add e-mails in 2 different databases in drupal 7

texts:
I used drupal 7.10 to built my website and i used 2 modules, the first is the webform to build the membership form, and the simplenews to write and send newsletter to users.

Anyone could subscribe in the newsletter even if it is not a member by enter her\his email in a newsletter subscribtion block in the home bage.

but what i wnat is that, when a user becomes a member he will join the newsletter service by adding his e-mail directly to a newsletter database, he don't need to enter his email in the newsletter subscribtion block agine.

How can i do this???


texts: setting template file using template_preproccess_page not working

texts:
I have a list of pages with url

?q=value/abc/1
?q=value/abc/2
?q=value/abc/3
?q=value/abc/4

for which i require a specific template.I have written a template_preprocess_page function,but it does not call the required tpl file.But if i set the test variable as
$test = array("value/abc/1");
the template file is being used.Could someone tell me what i am doing wrong..??

function template_preprocess_page(&$var){
 $test = array("value/abc/%");
        if(in_array($_GET['q'], $test)){
            $var['template_file'] = 'testing';
        }
}


texts: Is there a way to add encryption to images once they are uploaded on the website and stored on the server?


texts: How do I apply check_markup() as Twig filter?

texts:
I am trying to modify output in my twig file. In D7, I was able modify data in my array with this

check_markup($tweet->text, 'full_html');

and I see that this function still exists in D8. However, I'm not sure how I would use this in a filter in twig. This is what I have so far:

{% for tweet in params.tweets %}

    {{ tweet.text }}

{% endfor %}

I actually tried to do this before I sent it to the template as well, but it didn't change anything:

 foreach($tweets as $tweet) {
  $tweet->text = check_markup($tweet->text, 'full_html');
  $cleanTweets[] = $tweet;
}
dpm($tweets);
$params = array('tweets' => $cleanTweets);
$tweet_template = array('#theme' => 'twitter_pull_tweet_listing', '#params' => $params);
return $tweet_template;

What I'm trying to do here is make drupal create links for web links in the twitter tweet text. This worked fine for me in D7.


texts:
I want to set the value of a textfield based upon the selection of a field above. You can choose a template and the textfield would have it as a value.

This is the select field used to select the template with the ajax call

// Template Select field
$form['template'] = [
'#type' => 'select',
'#title' => $this->t('Template'),
'#options' => $event_templates_select,
'#required' => TRUE,
'#ajax' => [
    'callback' => '::changeOutputValue',
    'disable-refocus' => FALSE,
    element.
        'event' => 'change',
        'wrapper' => 'edit-output',
        'progress' =>[
            'type' => 'throbber',
            'message' => $this->t('Updating e-mail template'),
        ],
    ]
];

This is the textfield that I want to display the value. It's in a ckeditor.

// Textarea field
$form['output'] = [
'#type' => 'text_format',
'#format' => 'full_html',
'#required' => TRUE,
'#disabled' => FALSE,
'#value' => 'hallo',
'#prefix' => '
',
'#suffix' => '
',
];

And finally, the ajax function

  public function changeOutputValue(array &$form, FormStateInterface $form_state) {

    $selected_option =  $form_state->getValue('template');
    if ($selected_option == 0){
        $output_text = '';
    } else {
        $template = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($selected_option);
        $tempate_content = $template->get('field_template')->getValue();
        $tempate_content = $tempate_content[0]['value'];
        $output_text = $tempate_content;
    }

    $form['output']['#value'] = $output_text;

    $response = new AjaxResponse();
    return $response;

  }
}

Can someone explain what I'm doing wrong. I was trying to follow the drupal 8 form api docs but I can't get it to work with a ckeditor field.

The select field contains a number of e-mail templates. Upon selecting one, I want to display the template in the output field with a ckeditor so the user can still make changes if necessary.

I'm using Drupal 8 with a custom module.

Thanks in advance.


texts:
I'm wanting to alter the commerce cart page form.

By using var_dump($form_id) or chrome inspect I can see the id is id="views-form-commerce-cart-form-orange-default-42". If I write my hook as :

function module_form_views_form_commerce_cart_form_orange_default_42_alter

I can see that I am altering the form. But this has been altered in my theme hence the extra bit on the id orange_default_42. If I do :

function testingstuffs_form_views_form_commerce_cart_form_alter

I cannot alter the form.

How do I hook into this form correctly / is there  a correct way to find form ids?


texts:
Just transferred my brand new Drupal webshop to shared to host and guess what: it doesn't work.

I can't figure out that why node add page is lacking form? Everything else is in place. And to be more spefic it is just for one content type, other work fine.

I've tried drush rr, drush cc all etc. I've checked permissions etc. I'm using Display Suite forms as template for node add form.

This all of the rendered form markup that has a empty div container:

<form class="node-form node-content_type-form" enctype="multipart/form-data" action="/content_type" method="post" id="content-type-node-form" accept-charset="UTF-8" novalidate="novalidate">

</form>

And this is for anonymous users. For admins it work normally but it also has another theme.

When I tranferred the site I took a archive dump with drush and imported it into shared host.

UPDATE

Like always this Drupal like problem seemed very odd. So I decided just to change the theme and see if it has any effect.

Using the base theme of my custom the form is rendered normally.

However, custom theme works just fine on my localhost so I can't tell what is the problem. Seems like a theme issue but on the other hand not.

UPDATE 2

Base theme showed some "new" errors on second load. These errors refer to a oooold theme and shows that Drupal is trying to use that tpl file. I assume that this is the core problem which causes different results depending on theme.

'/home/user/public_html/sites/all/themes/custom_boot/node-content_type-form.tpl.php

UPDATE 3

I found the old code that registered this "theme" or template and which is still somehow required/requested on page load:

function custom_boot_theme($existing, $type, $theme, $path){

    return array('node__content_type__form'=>
            array(
                'render element' => 'form',
                //'path' => drupal_get_path('theme', 'custom_boot') . '/templates',
                'template'=> 'content-type-node-form',
            'user_register_form'=>
            array(
                'render element' => 'form',
                //'path' => drupal_get_path('theme', 'custom_boot') . '/templates',
                'template'=> 'content-type-node-form',
            ),
        );
}

How could I undo this?

UPDATE 4

If I remove this old theme and run drush rr, it will give following error every time:

    The following theme is missing from the file system: custom_boot. For information about how to fix this, see the documentation page. bootstrap.inc:1128

Even though custom_boot is removed from system table by drush rr, it will still try to find some files related to this removed theme.

UPDATE 5 - FINDINGS AND POSSIBLE SOLUTIONS

First of all it seems that the problem is somehow in the current theme.
What is it? I don't know.

Secondly, why does this site work perfectly on localhost but not on this live server? Could I make some changes to PHP ini settings that would "look through"/disregard the small hickup of missing theme? I don't understand that why localhost won't die on this missing theme problem...

UPDATE 6

Well, since I couldn't get a rid of I had to stick with it. I've just enabled this old theme but which I'm not using. Now the form shows but it is rendered with this old themes custom form template file described above.

BUT, as soon as I visit /admin/structure/types/manage/content-types/fields the form starts failing again. So Display Suite and old theme have some issues.

AND TO ADD, it is all the same if the content-type-node-form.tpl.php file has content or not: the form is rendered and I can put any code in there and it won't change or break anything.


texts: How to create a PHP file that returns a list of nodes as XML?

texts:
How do I create a PHP file that returns a list of nodes as XML when called if I have a menu structure like this:

<GalleryXML>
--gallery 1
---Item 1
---Item 2
---Item 3

And I want a url like localhost/getgallery.php

this url will then return my gallery as xml, something like this

<galleryXML>
    <gallery name="gallery1">
        <item name="item1">
            <image>localhost/site/default/image1</image>
            <imagethumb>localhost/site/default/image1</imagethumb>
            <url>http://google.com</url>
            <description>lorum ipsom</description>
        </item>
    </gallery>
</galleryXML>

Where Image, Imagethumb, url and description are fields on the item node

Thanks in Advance!


texts: Facing this error while Acquia Drupal set up

texts:
Parse error: syntax error, unexpected '[' in
  /Users/***/Sites/devdesktop/acquia-drupal-7.41.47.6289/profiles/acquia/modules/sqlsrv/sqlsrv.install
  on line 10

What can I do to fix this error?


texts:
I want to generate an internal URL in my twig template
Here is my code but it's not working

{% if(is_admin) %}

                        Edit Menu

{% endif%}


texts: Feeds with multiple Entity References per node?

texts:
I have been racking my brains on how I can import a massive database I have collected into my Drupal website.

I have collected the below data for over 3000 players so manually uploading is not an option.

Can anyone help?

Player Content Type

Player,
Position(Term Reference)

Season Content Type

Season,
Appearance,
Substitute, Appearances, Tries, Yellow Cards, Red
   Cards, Club (Term Reference)

Each Player would have multiple seasons worth of data assigning to them, relating to previous seasons.

I cannot see a way in Feeds to implement this, I have tried with Entity Reference, but cannot see how I can add multiple Seasons to the same player through Feeds.

Here is some sample data.

Player - John Smith,
Position - Flanker

Season - 2013/2014,
Apps - 22,
Subs - 10,
Tries - 2,
YC - 3,
RC - 0,
Club - York RFC

Season - 2012/2013,
Apps - 12,
Subs - 1,
Tries - 0,
YC - 0,
RC - 0,
Club - Leeds RFC

I have some experience with Feeds, but not when using Entity References and the community does'nt really have anything that fits my bill.

If there is a better way to structure the data then I am open to suggestions as this is just the way I logically can work it out. I just ideally do not want to have multiple fields assigned to each player in one content type like 2013_apps, 2013_tries, 2012_apps, 2012_tries etc which would be the easy route...

Thanks

Craig


texts:
When saving an internal link to content (within the wysiwyg editor), the paths don't get aliased like they do with D7.

If I have a node (at path /node/10), with an alias of /some/other/path, when that page gets saved, then cached/viewed, the link that gets generated for the user is /node/10.

This has several drawbacks, not the least of which is that we have our breadcrumbs reliant on the URL path.

I've looked at all the input filters on the appropriate text format, but there's nothing there for it. This seems like kind of a huge issue for Drupal, I'm hoping that the fact that I can't seem to find anything on the issue means I just have a config wrong somewhere.


texts: How to rsync files between two remotes which share the same host?

texts:
I've two remotes: @remote.dev and @remote.test.

I'm trying to rsync between these two remote Drupal instances by:

$ drush -vy rsync @remote.dev @remote.test

But rsync complains that:

  The source and destination cannot both be remote.

Both remotes are on the same machine, but they're using different path.

Is there any workaround?


texts: How to override the H1 element from module?

texts:
I am trying to override the h1 element on a node view for a content type. I do not want to change the meta tags or anything else. Any tips how I could achieve this?

I have been trying something like this, but it has no effect

function xxx_preprocess_node(&$vars) {
    dpm($vars);
    if ($vars["type"] == 'mycontenttype') {
        $custom_title = $vars["title"] . " TESTING";
        $vars['title'] = $custom_title;
        dpm($vars);
    }
}


texts: Award user points for selecting an avatar?

texts:
I'd like to award my happy little users when they select an avatar.

Anyone know of a module that melds User Points and Avatar Selection?

Both modules are awesome, but I can't find a way to combine them into thanks-for-making-your-profile-pretty goodness.


texts:
For some reason, my Drupal 8 page it's just showing plain text after performing an update (8.1.8). I unchecked the Aggregate CSS and JavaScript files option, and cleaned the cache, but it didn't work. Everything was working fine, until I did the update.

How can I fix this?

Update:

Report/status Report shows this

Protection disabled
The file sites/default/settings.php is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.
The file sites/default/settings.local.php is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.


texts: Where to place PHP code for a node if not in the node body block itself?

texts:
Up until now, I have found it most convenient and easy to place PHP code into my node by placing it in the node body and enabling the PHP filter. However, I have been informed that this is incorrect and unsafe.

Furthermore, I also know that it would be incorrect to place PHP code in node.tpl.php.

Could someone please tell me where the correct place to place PHP code for a node would be?


texts: Looking for most reliable and compatible (with other Drupal modules) multiple photo uploader and gallery system in Drupal 6 and Drupal 7?

texts:
DrupalGardens hosted (Drupal 7) sites use a fantastically easy multiple photo uploader - i.e. one can select multiple image files from an Explorer Browser box (or other OS equivalent) using CTRL, SHIFT and upload them all at once into a gallery.

Question 1) What modules is this based on, so that I can export and deploy a site outside of DrupalGardens?

More importantly:

Question 2) If I was building a Drupal 7 site from scratch with my own hosting, what modules would I need to achieve this?

Question 3) If I was building a Drupal 6 site from scratch with my own hosting, what modules would I need to achieve this?

I wish to stay with Drupal 7 in my consideration as to which version to use. But if Drupal 6 has more rich functionality then I may use that.


texts: Warming up dynamic page cache for authenticated users

texts:
We're currently working on a rather complex Drupal 8 based website. After clearing caches, the majority of pages/routes require about 30-60 seconds for being rendered/returning the desired results. Leveraging Drupal 8's dynamic page cache, this figure goes down to 250-700ms on subsequent requests.

Therefore, we implemented sitemap-based cache warming strategies (requesting all sitemap URLs through a NPM script after Drupal updates have been applied, configuration was imported, and caches cleared) for publicly accessible pages into our CI flow.

Now, I'm seeking to improve this solution. We want to additionally warm up the dynamic page caches for pages, that are available to authenticated users only. This comprises a lot of pages and custom entities with individualized content for various user groups and users, as well as a fine-grained permission scheme to selectively add/hide information per user.

Once again, when hitting these pages with cleared caches, they require loads of processing time until the first content is delivered to the browser. Subsequent hits for the very same user/route are fast enough for a decent (back-end) user experience.

There are about 2k different users and more than 400 user groups. Warming up all caches for all available user contexts would take about a day (given sequential warming and considering the current deployment times).

So I started wondering, whether I'm missing something, that could help warming up (as many as possible) dynamic page caches for authenticated users.

Is there any practice/strategy, that can be pointed out by the pro's in this group?


texts:
This is taken from the examples module(http://drupal.org/project/examples). More specifically in the 'Generate textfields' ajax section. The form attempts to demonstrate an ajax call by presenting 2 checkboxes and generating a textfield based on which checkbox was clicked.

This is the ajax callback. We have a textfield with key 'first_name'.

function ajax_example_autotextfields_callback($form, $form_state) {
  $a = $form['first_name'];
  $a['first_name']['#value'] = 'foobar';
  $a['first_name']['#disabled'] = TRUE;
 return $a;
}

The form rendered has value textfield with value 'foobar' as expected, but the textfield is not disabled? How come?


texts:
In Drupal v7.22 I'm trying to order the query below for a custom module but I cannot seem to find documentation that fits this query.

$sql = "SELECT field1, field2 FROM {tablename} WHERE field3 = :var1 AND field4 = :var2";
$result = db_query($sql, array(':var1' => $var1, ':var2' => $var2));
$num = $result->rowCount();
if ($num != null) {
  foreach($result as $line) {
    // Do something
  }
}

I've found details on 'orderBy' but only with examples as below which are not in the same format as my query. Any help would be appreciated.

$query->groupBy("thread.sid");
$query->having("MAX(comment.created)");
$query->orderBy("comment.created", "DESC");
$result = $query->execute();


texts:
I would like to create a custom query processor to filter Commerce products, based on a user field and a product field.
Users have a boolean field "hide special products", and products have a boolean field "special". If a user can't see special products, all special products have to be hidden in the Search API view.
I have to add this condition in the Search API index, but I haven't found an example of a query processor. Could some show me an example of this custom processor?


texts: Create contextually filtered view of shared fields across multiple content types

texts:
I have a content type "Construction Job" with the title field renamed "Job #". When we create a new job, we assign it a unique job number in the title field.

I have two additional content types, "Update team 1" and "Update team 2". These content types have different fields because the work being done is different, but they share a field called "pictures". Each content type also has an entity reference field to the "Construction Job" content type so we can tie them together.

I'm trying to create a dashboard type display with various different views so management can review jobs with all of the information in one location. I'd like to create a slideshow off all of the pictures uploaded from either of the two update content types, and contextually filter that slideshow so that only the images from the updates for that particular "Construction Job" are shown.

I can create a separate slideshow view for the pictures from each respective Update type, but then I'm left with two separate slideshows on the same page. I'm trying to combine this into one slideshow as we're looking at adding a third different Update content type.

I've tried adding a contextual filter for each entity reference field from the two independent content type, but that doesn't work. That is I can create a contextual filter for the entity reference field for the first content type, but the view then eliminates all images from the second update content type. When I add the second contextual filter, the view returns no results when I enter a value in the filter preview.


texts: How to trigger rules action if cart is empty?

texts:
We have a field in our user profiles that is checkmarked when a user adds a product to their shopping cart (with Drupal Commerce). This is used to display a message reminding them to checkout if they have items in their cart. I have successfully set up rules to check the field when they add a product, and uncheck it when they make it through checkout.

However, I also need to uncheck the field if a user removes all products from their cart. I can't seem to figure out what conditions to add to check if the user's cart is empty after a product has been removed.

Any suggestions?


texts: limiting shipping method if a specific product is selected

texts: I am trying to limit a number of shipping methods (from 5 to 3) if a specific product is chosen and inserted into cart. What is the best method to do it (I am using drupal commerce)


texts:
I'm very new to Drupal and web dev in general (J2SE C/ObjC background). I've just installed Drupal For Facebook. With its help I'm able to get my FB App to get its content from my Drupal site. However, none of the standard Drupal themes seem to format nicely for facebook.

My criteria are:

formats pages to < 520 pixels wide (main criteria)
shows the page contents but very little else (no breadcrumbs or menus)

I thought about writing my own theme to achieve this end. But I thought I'd ask if there's anything readily available out there that I can use, since I can't be the first guy that wants this. Or if there's a way to constraint the page width and hide the menus and breadcrumbs using only CSS trickery, I'd love to know about it too (mind you I'm an HTML noob here)

Gracias


texts: Drupal Commerce Payment Method: Pay as you Go Options?

texts:
I'm researching the different payment methods available for Drupal 7 Commerce (Authorize.net, paypal, sagepay, etc.). They all seem to require a monthly price of ~25+ dollars (and sometimes setup fees and other fees). I understand there are fees associated with credit card transactions. I'm starting a new service on my site however and I'm not sure how popular it will be. I would like a payment method that allows me to just pay for each transaction and not necessarily a monthly cost (but also allows me to have the payments made directly on my site - without redirection as it is in paypal wps - to another site), so it looks professional from the get-go.

Any suggestions?


texts: Can I group fields by their Field Group in Views?

texts:
I'm using Field Group module to manage field in content type and I want to display field as table in views, but group field not showing properly. What should I do?

I attached an example below.

e.g.


texts: Views Slideshow vs list View+jquery cycle lite?

texts:
The rotating images on my work site's home page are created as a View in list format. I'm using the jQuery Cycle Lite plugin for the rotator effect. The cycle.lite.js file is set in the scripts array in my theme's .info file, and there's a bit of code in page.tpl.php to check whether this is the homepage, and if so, set up the rotator.

Now I'm working on a second rotator for another section, and I've been trying out the Views Slideshow module.

What are the pros & cons of each approach (theme vs module), especially from a server load or page weight point of view?


texts: Where to initialize module specific variables

texts: I have been using hook_init in order to initialize some _SESSION variables on my application, however a problem I got after... is that hook_init is called on every ajax request. That's why I wanted to ask, what other hook, function or method should I use in order to initialize my module specific variables. I'm looking for something that's called just the first time the user enters the page, and not when a submit button is launched. (similar to isPostback???).


texts:
What are the functions  in Form API that perform the task just like form load and unload
I want to perform few checks when the form loads and delete those checks when the form is unloaded.

           function form_example_form($form, &$form_state) {
                 $form['search'] = array(
                '#type' => 'textfield',
                '#title' => t('Search for Members'),
                '#size' => 60,
                '#maxlength' => 128
                );
                $form['submit'] = array(
                '#type' => 'submit',
                '#value' => t('Search'),
                '#submit' => array('myform_newform_submit'),
                );
                 $header = array(
                    array('data' => t('ID'), 'field' => 't.id'),
                    array('data' => t('First Name'), 'field' => 't.fname'),
                    array('data' => t('Last Name'), 'field' => 't.lname'),
                    'operations' => array('data' => t('Operations'), 'colspan' => 2),
                  );
                if((variable_get('results'))!="") {

               $query = db_select('myform', 't')
              ->extend('TableSort')        //Sorting Extender
              ->orderByHeader($header)
              ->extend('PagerDefault')
              ->condition('lname',variable_get('results'),'=')
              ->limit(2)
              ->fields('t', array('id', 'fname', 'lname'));
              $results = $query->execute();
              foreach($results as $node)
              {
               $rows[]=array(
                    'id' => $node->id,
                    'first_name' =>$node->fname,
                    'last_name' => $node->lname,
                   'modify' => l('Modify', 'myform/modify/'.$node->id),
                    'delete' => l('Delete', 'myform/delete/' . $node->id));
               }
               }
               else
               {
               $rows = array();
               }
            $form['pager_table'] = array(
              '#theme' => 'table',
              '#header' => $header,
              '#rows' => $rows,
              '#empty' => t('Empty Rows')
              );
              // attach the pager theme
              $form['pager_pager'] = array('#theme' => 'pager');
                return $form;
                                     }

                             function form_example_form_submit($form,&$form_state)
               {
        variable_set('results',$form_state['values']['search']);
                   }

Now when I change the link how do I free the variable at form unload


texts: Can I limit a view mode to show on the "Manage Display" settings page for only one node type?

texts:
I have a module that creates a custom node type ("answers") and a custom view mode ("answers_full_node") for that node type.

Now, when I look at the "Manage Display" settings page for any node type, the custom view mode is available.

Is there a way I can restrict it so that it shows up only for my custom node type?


texts: How to get Entity Reference Autocomplete results to display in a table?

texts:
I am currently working on a site which will take in an unlimited amount of nodes (in this case inventory numbers) for a Sales Order which I can then save, view and export into a CSV in Drupal 7. I am wondering how I can take the results of the Sales Order and form the results into a Views Block that is attached to the Sales Order NID page.

For example here is my Entity Reference Autocomplete:

Then when I save this, I want to be able to view the results in a table when I click on the Sales Order. I would like the table to display certain information from the item (which I know is done in a view).

Here is how my Views Block is set up currently (with the preview results):

I am unsure as to why nothing shows up on either the preview or the page.

I have also tried using Inline Entity Reference but that doesn't seem to work either. I am a Drupal Ameteur, but need some help with this.

Is the Entity Reference Autocomplete list not saving properly or does it save it anywhere at all? If so, how do I access it?

EDIT: So I have the block assigned to the Sales Order Content type and it is assigned in the Content section in the Blocks menu. (I think this is right)

I also just changed the Pages section to No Restriction and nothing changed.


texts: How to create independent sections, which consits of menu and more pages automatically

texts:
I have little problem with creating independent sections on the web.

I have content type named project. It is basically landing page, which has own menu and this menu can link multiple simple pages. These projects have simillar structure, on every on them is page like timeline, news & events... Now when I want to create new project, I need to create new project, than create multiple simple pages, create menu, add menu to this project and so on. It is really complicated. Is there any way how can this be automatized?

Example: I will create new project, and menu and simple pages will be created automatically.


texts: how to restore the calendar view created by the calendar module?

texts:
When you install the calendar module a calendar view is automatically created. For some reason it seems that I deleted this view. Now I need to use the calendar module and I need this view.

The version of the module is: 7.x-3.4

I can't find a way to make that the calendar module recreate that view. This is what I did:

1) I disabled the calendar module

2) I uninstall the calendar module

3) I enabled the calendar module again

But the view is not created at all.

How can I have this view restored.


texts: How do I delete all the user's posts, using drush?

texts: I frequently need to delete all comments/posts of a particular abusive user. It takes a hell of time to accomplish this with a browser. It would be great if someone could tell me how to do it using drush.


texts: EntityQuery with a condition on an array

texts:
I try to list all fields where a paragraph type is referenced (to find all contents which have paragraphs of a specific type).

My problem: I do a EntityQuery on field_config entity type to find the fields. But, the condition on which paragraph_type are targeted doesn't work correctly and return all fields which can content a paragraph disregarding the type.

Here my code:

// Recover my paragraph_type selected in my form.
$paragraph_type = $form_state->getValue('paragraph_type');

// List all field_config which referred this paragraph_type.
$query = \Drupal::entityQuery('field_config')
  ->condition('field_type', 'entity_reference_revisions')
  ->condition('settings.handler', 'default:paragraph')
  ->condition('settings.handler_settings.target_bundles', $paragraph_type, 'IN');

$field_config = $query->execute();

For exemple, I have a paragraph type "press_release_about" which can be add only in press release in a specific field. But for this paragraph (and all others), it's all fields which can contains a paragraph in the system which are returned.

When I inspect a field_config which referred paragraph, I can see that settings.handler_settings.target_bundles is an array of the paragraph types which can be add with this field. The format is:

[settings:protected] => Array
    (
        [handler] => 'default:paragraph'
        [handler_settings] => Array
            (
                [target_bundles] => Array
                    (
                        [1col_text] => 1col_text
                        [1col_image] => 1col_image
                        [1col_quote] => 1col_quote
                        [1_col_graphique] => 1_col_graphique
                        [2_cols_texte_media] => 2_cols_texte_media
                        [2_cols_texte_graphique] => 2_cols_texte_graphique
                        [2_cols_text] => 2_cols_text
                    )
              )
         )

If I remove the condition ->condition('settings.handler_settings.target_bundles', $paragraph_type, 'IN'), this change nothing. And if I change the INby NOT IN, I have no result.

I don't know if I don't write my condition correctly or if my error is elsewhere.


texts:
I use the following snippet to restrict who can see a block inside admin pages. Can you help me add the restriction of a path /cart* for non admin users into this snippet?

if (user_access('access administration pages')) {
  return FALSE;
} else {
  return TRUE;
}


texts:
I have some difficulties finding a correct code (VCL) to configure varnish to detect if the device is a tablet or a mobile or a desktop.

Here is the best module version found today, but still not detecting tablet if not an iPad.


texts: Ajax call not working until page refresh

texts:
When I just logged in this ajax request not working. When I hit refresh (F5) in my browser, then works well on all pages, and see in firebug call to /js/my-callback/. History repeats if I logout, login... What I should add to this function to work properly?

(function ($) {

  Drupal.behaviors.myModule = {
     attach: function(context, settings) {
       $.ajax({
         url: '/js/my-callback/',
         success: function(data) {
            $('#myID', context).html(data);
         }
       });
     }
  };

})(jQuery);


texts: How to determine form id match in form alter?

texts:
In Drupal 8, I want to alter taxonomy vocab and term add/edit forms. Vocab is easy enough, but the form id for term forms seems to have this pattern:

taxonomy_term_(vocab name)_form

What can I reference to know that the form being altered is a taxonomy term add/edit form?

I tried using hook_form_BASE_FORM_ID_form_alter, but that stopped working unless I implemented hook_form_alter() elsewhere in my module.


texts: I need a content profile title token. I downloaded this small module, but it works only for text_field and I need a title.


texts: How to make my user notifications module notify node authors about new comments?

texts:
I need to send a notification to the article owner when some user comments on the review added to an article.

But in the Rules module, while adding a Rules Action, there is this action: 'Send notification to user when flag is applied' (part of a custom module I inherited from a prior mantainer of this site). With this action, notification is only sent to the reviewer, not the article owner.

Can anyone help to get this to work? Or is there another way to make this work without the custom module I'm struggling with?

Here is my rule:

{ "rules_send_notification_when_commented_on_article_listing" : {
    "LABEL" : "send notification when commented on article\/listing",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "user_notifications", "comment" ],
    "ON" : { "comment_insert" : [] },
    "IF" : [
      { "entity_is_of_bundle" : {
          "entity" : [ "comment" ],
          "type" : "comment",
          "bundle" : { "value" : {
              "comment_node_article" : "comment_node_article",
              "comment_node_page" : "comment_node_page",
              "comment_node_comment" : "comment_node_comment",
              "comment_node_company" : "comment_node_company",
              "comment_node_review" : "comment_node_review"
            }
          }
        }
      },
      { "NOT data_is" : { "data" : [ "comment:node:author" ], "value" : [ "comment:author" ] } }
    ],
    "DO" : [
      { "user_notifications_action_send_notification_flag" : {
          "flag_as_flag" : "commented",
          "content" : [ "comment:node" ],
          "message" : "commeted on ",
          "heading" : "d"
        }
      }
    ]
  }
}


texts: How do I ouput a node reference field using a node reference template in Drupal 7?

texts:
In drupal 6 you can create templates to control how node reference fields are output on a content type basis using the suggestion below:

node-nodereference-exampletype.tpl.php

and then output a node reference field that references 'exampletype' nodes in a node template like so:

$node->examplenodereference[0]['view'];

The file naming conventions and output syntax have changed in drupal 7.

Working off the information at this link http://drupal.org/node/998848 I have tried template suggestions like these with no luck:

node--nodereference--exampletype.tpl.php
node-nodereference--exampletype.tpl.php
node--nodereference-exampletype.tpl.php
node-node-reference-exampletype.tpt.php
and so on...

I have tried adjusting the display mode for the field from teaser to full content etc.

I have tried outputting the field with:

print render($content['field_example']);

and

print $field_screening_movie_title;

and variations on the above.

What is the correct way to name a node reference template file in drupal 7? Do I need to use the render function to output a node reference field using the template?

Thanks


texts: Subdomain involuntarily redirects to primary domain after logging in or saving

texts:
I made a development site using development.breinwijzer.be as subdomain. After I've logged in, I'm already back at my primary domain www.breinwijzer.be.

I tried different browsers.
I cleared caches.
I cleared browser caches.
I checked the settings.php file of the development site to see if I have the correct database set for the development site.

Other than this, I'm clueless.


texts: Commerce Kickstart 2 Need Rule To Apply Sales Tax To Shipping

texts:
I need a Rule to apply sales tax to shipping on a sales order.

I tried the following code (borrowed from here: https://www.drupal.org/node/2307695) and it doesn't work for me:

{ "rules_apply_sales_tax_to_shipping" : {
"LABEL" : "Apply sales tax to shipping",
"PLUGIN" : "reaction rule",
"WEIGHT" : "5",
"OWNER" : "rules",
"REQUIRES" : [ "commerce_tax", "commerce_shipping" ],
"ON" : { "commerce_shipping_calculate_rate" : [] },
"DO" : [
{ "commerce_tax_calculate_by_type" : {
"commerce_line_item" : [ "commerce_line_item" ],
"tax_type_name" : "sales_tax"
}
}
]
}
}

Maybe there is a typo? There are only two tax_types on our site, sales_tax and VAT so I don't think so.

Do I need to add this as an Action onto our Sales Tax? I don't see how to do this... this does not appear in the drop down list of available Actions.


texts: If there is no nodes in current taxonomy term to display, load vocabulary and display other

texts:
difficult to formulate a question

I have made a View, which display title, image, body(trimmed) on nodes pages with Content type - Home, its related nodes to this one(. Home has different categories - taxonomy, for example looks like this:

Homes one
homes two
homes three

So for example if my current node has taxonomy term - homes two i should display only nodes(title, image, body(trimmed) of this term. I did it like this - with contextual filters Content: Nid - i exclude current node to not display it in my view and

Content: Has taxonomy term ID

When filter is not available - i provide my own value, php code:

 $node = node_load(arg(1));
 if($node) {
 foreach($node->field_home_category[LANGUAGE_NONE] as $term) {
    $terms[] = $term['tid'];
 }
    return implode('+',$terms);
  }
  else {
    return
  }

$node->field_home_category[LANGUAGE_NONE] -  is a field which contains taxonomy term id.

And its works fine, but if my node is only single in homes two taxonomy term, the view returns nothing(for obvious reasons) and if this happens i need to display any other Home nodes.

I think i should load my taxonomy vocabulary and get all the terms and pass them to my view in this situation. Like this:

$tree = taxonomy_get_tree(2); // vocabulary id - is 2
    foreach ($tree as $term) {
        $options[] = $term->tid;
      }
      return implode('+', $options);

but i dont know how to add this to my view.

Something like this ->

PSEUDO CODE:

IF THERE IS NO NODES IN CURRENT TERM
   DO
      LOAD VOCABULARY OF HOMES
    AND
      DISPLAY ANY AVALIABLE NODES OF THIS VOCABULARY

//////////////////////////////////////////////////////

I will post full solution, maybe helps someone:

//////////////////////////////////////////////////////

No results behavior is great, but there is few situations:

For example:

homes two contains 2 homes, one is excluded, so view will display only 1 home, but we need 3 homes to be displayed all the time.

What i did is created new view, which displays 3 homes randomly(global Random sort criteria)
and excluded nid in contextual filter, i allow to pass multiple values to nid.
and in THEME_views_pre_render(&$view) i did next thing:

function THEME_views_pre_render(&$view) {
  if ($view->name == 'home') { // check is this my view
      $args = $view->args; //passed arguments
      $results = &$view->result; // this is important , you should pass it by reference
      if (!empty($args) && isset($args[0]) && isset($args[1])) {
        $node = node_load($args[1]);
        if ($node->type == 'home') { // check node type
            foreach($view->result as $row) {
                $restricted[] = $row->nid; //push current nodes to array, to pass them later to our new view, to not display them
            }
            $result_count = count($view->result);
            switch ($result_count) {
                case 1: // if one home
                    //gett the results of my view which display all nodes
                    // and do not display node which already displayed
                    // aka $restricted array
                    $result_array = views_get_view_result('related_homes_and_features', 'block_3', $restricted);
                    //add this results to current view
                    //
                    array_push($results, $result_array[0],$result_array[1]);
                    break;
                case 2:
                    $result_array = views_get_view_result('related_homes_and_features', 'block_3', $restricted);
                    array_push($results, $result_array[0]);
                    break;
                case 3:
                    $result_array = views_get_view_result('related_homes_and_features', 'block_3');
                    array_push($results, $result_array[0], $result_array[1], $result_array[2]);
                    return;
                    break;
            }
        }
    }
  }
}

home that helps someone.


texts: Converting date into unix timestamp not giving expected result

texts:
Basically I was trying to get age from date of birth, for which I am using Computed Field module.

Following code was used:

$isoArray = explode ( '-', substr($entity->field_dob1[0]['value'],0,10));
$bdayunix = mktime ( 00, 00, 00, (int)$isoArray[1], (int)$isoArray[2], (int)$isoArray[0]);

$nowunix = time();
$unixage = $nowunix - $bdayunix;
$age = floor($unixage/ (365 * 24 * 60 * 60));

$entity_field[0]['value'] = $age;

When I checked the code, I found that this part of code is not giving the correct  result:

 $isoArray = explode ( '-', substr($entity->field_dob1[0]['value'],0,10));
 $bdayunix = mktime ( 00, 00, 00, (int)$isoArray[1], (int)$isoArray[2], (int)$isoArray[0]);

I can say that because when I try to convert $bdayunix into date,whatever the date of  birth is, I always get the result 1999.

ie; $dob = date("Y",$bdayunix ); always gives result:1999.

Could you please tell me where I am going wrong? Is this problem of Computed field module or I am doing some mistake in my code ?

(Date format in users bday field is yyyy-mm-dd and I have tried all types: Date, DateISO format and Date Unix timestamp).

Thank you in advance.


texts: How do I hide nodes that shouldn't be directly accessed from users and search engines?

texts:
I've found that there are times I have a node that simply contains content that will be displayed somewhere else, but shouldn't be viewed directly. That is, no one should ever go to node/1234, but the content in node 1234 should be displayed somewhere else. For example, I create an about page with tabbed content using views. So there are "About Me", "About Us" and "About Them" pages. All of these are displayed in a single page with tabs using Views. So I don't want people to get directly to the "About Us" node because then they wouldn't see the tabs for the other pages. At the same time, I don't want Google giving people a direct link to this node, I want to limit access so users can only get to it through the View (i.e., the tab).

So I need to restrict access to the node, remove it from the Drupal search results, and make sure Google doesn't pick up on it. Any suggestions?


texts: Loop trough a list of referenced nodes, "entity_metadata_wrapper()" style

texts:
I have a Template node that holds an Entity Reference multivalue field to a series of other nodes, all referenced nodes of the same type. The referenced nodes have a text field whose value I need to get.

In template node I have a computed field that do some calculations using the values from referenced nodes.

Now I have:

$tpl = field_get_items($entity_type, $entity, 'field_plan_tpl');
$values = array();
foreach ($tpl as $field_item) {
  $values[] = node_load($field_item['target_id'])->field_some_field[LANGUAGE_NONE][0]['value'];
}

How can I load the referenced entities in order to get field values, using entity_metadata_wrapper()?


texts: Node token in rules (Events: When an order is first paid in full)

texts:
In comments there is Product reference-Inline entity form-Single value, so when a product is posted in comments, it can be bought by somebody.

Is it possible to have a node token in Conditions or Actions in rules when in Events 'When an order is first paid in full' is used? For example, it would be nice to have a node token in Conditions-'Entity has field' and in Actions-'Set a data value'.


texts: Using drush to install multiple sites, how?

texts:
I'm executing the following commands in /var/www/html on a clean Ubuntu 14.04 installation:

drush dl --drupal-project-rename=Platform
cd Platform
drush site install standard -y --db-url=[mysql connection string]/drupal --site-name=Example1

This sets up the site and it's awesome (especially after fighting for two days with the web interface and silly errors).

But now I want to install a 2nd site on this installation:

drush site install standard -y --db-url=[mysql connection string]/drupal2 --site-name=Example2

I get an exception that says, "To start over, you must empty you existing database. To install to a different database, edit the appropriate settings.php file in the sites folder. To upgrade an existing installation etc. etc.".

Is it still trying to install to the original database, thus the reason why I'm getting this error? I created drupal2 prior to running this command, so there's an empty database that exists.

How would I go about fixing this error?

Is it possible to use 1 database for all sites with crush?

Edit: Creating a subdirectory in sites and using the --sites-subdir option in the site install command seems to have worked. Not sure how to point my browser to the site or how to use one database yet, but baby steps!


texts: Why Views Data relationship between custom entity type and node doesn't work?

texts:
Fields names are equal in both tables.

Inside hook_views_data:

  $data['stream']['table']['join'] = array(
    'node' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );

 $data['stream']['nid'] = array(
    'title' => t('Related node'),
    'help' => t('Node related to stream item.'),
    // Define a relationship to the {node} table, so example_table views can
    // add a relationship to nodes. If you want to define a relationship the
    // other direction, use hook_views_data_alter(), or use the 'implicit' join
    // method described above.
    'relationship' => array(
      'base' => 'node', // The name of the table to join with.
      'base field' => 'nid', // The name of the field on the joined table.
      'field' => 'nid',
      'handler' => 'views_handler_relationship',
      'label' => t('Default label for the relationship'),
      'title' => t('Title shown when adding the relationship'),
      'help' => t('More information on this relationship'),
    ),
  );

(similar to example from api page)

but there isn't above relation in Add relationships box. Could some one give me any hint?


texts: Why do I not see a join in the view query?

texts:
I added a field to the user content type called metro_id.

I am trying to display that field along with the user's name in a view.  I expected to see a join in my view sql. Instead I see that everything is being selected from user table and a field has been added to the select clause: 'user' AS field_data_field_metro_id_user_entity_type

How is this working?


texts: Add custom fields to the Apache Solr search results

texts:
I'm trying to configure a search page from Apache Solr module, and add some custom fields to the items. Here is the code I'm using for this

Custom module:

function hook_apachesolr_query_alter($query) {
$query->addParam('fl', 'ts_field_up_short_description');}

Function in tamplate.php:

function tamplate_preprocess_search_result(&$variables) {
$variables['ts_field_up_short_description'] = $variables['result']['fields']['ts_field_up_short_description'];}

Display field in search-result.tpl.php:

<?php if ($ts_field_up_short_description) : ?>
     <?php print $ts_field_up_short_description; ?>
<?php endif; ?>

I'v created 3 nodes with this field, but only one of them displays the short description field (if displaying the search results with views everything is fine). Please tell me am I missing something? Thanks


texts: How do I install Flysystem and Flysystem S3?

texts:
I'm using the Flysystem module, but I am not able to install the module. I am getting this error:

  Dependencies missing: Flysystem, replicate adapter, stream wrapper.

I followed the steps given on https://www.drupal.org/node/2541116, but I am still not able to install the module.

I have installed the Replicate and Stream wrapper modules.

Is there any other method to integrate S3 with Drupal 8?


texts: I want to get all of the allowed values of a field

texts: Let's say I have a field in Drupal called resource_type, and I wanted to get all allowed values. Is there any easy way to do this with a command, or do I have to do a database query? I'm not seeing anything specifically that would make this easy.


texts: How to Display terms only if associated with a node

texts:
Using Drupal 6:
I need to show child terms for the currently viewd taxonomy term in a block. I finally stumbled on a piece of code that does exactly what I want. Original code from here

As per the instructions I've added the following to my template.php

function themename_child_terms($vid = 1) {
  if(arg(0) == 'taxonomy' && arg(1) == 'term') {
    $children = taxonomy_get_children(arg(2), $vid);
      if(!$children) {
        $custom_parent = taxonomy_get_parents(arg(2));
          $parent_tree = array();
          foreach ($custom_parent as $custom_child => $key) {
            $parent_tree = taxonomy_get_tree($vid, $key->tid);
          }
          $children = $parent_tree;
      }

    $output = '
';
    foreach ($children as $term) {
      $output .= '
';
      $output .= l($term->name, 'taxonomy/term/' . $term->tid);
      $output .= '
';
    }
    $output .= '
';

    return $output;
  }
}

I've then created a block and added :

<?php // $vid is the vocabulary id.
    print themename_child_terms($vid = 1);
?>

This shows the child terms of the current term perfectly. However, it shows ALL terms that exist under the parent term, even if there are no nodes tagged with that term.

e.g. viewing the page with all items in 'Term 1', I get

child 1
child 2
child 3

correctly listed in the block. But, if there are no pieces of content tagged with 'child 3' for example, it's still showing up that term in the block. This isn't very useful as it links to an empty term page.

How would I modify the code to only show children that actually have nodes associated with them. So if there are no children tagged 'Child 3', then that term would not show up..

I've found this function in taxonomy.module
Can I use this function to do what I want?

/**
 * Count the number of published nodes classified by a term.
 *
 * @param $tid
 *   The term's ID
 *
 * @param $type
 *   The $node->type. If given, taxonomy_term_count_nodes only counts
 *   nodes of $type that are classified with the term $tid.
 *
 * @return int
 *   An integer representing a number of nodes.
 *   Results are statically cached.
 */
function taxonomy_term_count_nodes($tid, $type = 0) {
  static $count;

  if (!isset($count[$type])) {
    // $type == 0 always evaluates TRUE if $type is a string
    if (is_numeric($type)) {
      $result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid'));
    }
    else {
      $result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type);
    }
    $count[$type] = array();
    while ($term = db_fetch_object($result)) {
      $count[$type][$term->tid] = $term->c;
    }
  }
  $children_count = 0;
  foreach (_taxonomy_term_children($tid) as $c) {
    $children_count += taxonomy_term_count_nodes($c, $type);
  }
  return $children_count + (isset($count[$type][$tid]) ? $count[$type][$tid] : 0);
}

Thank you kindly for any solutions.

Nick


texts: How to bulk resize images imported with feeds importer module?

texts:
I have a Drupal 7 site on a test machine (Windows 7/Apache/PHP 5.3), with the Commerce and Feeds modules installed, and succeded in importing a CSV of more than 400 products (images included!), which made me really happy.

Now I've got a problem: in the Commerce product settings, the maximum width & height are set to 700px and 400px, respectively. The feed importer didn't resize the product photos, so now I'm stuck with product images that are the original hi-resolution photos (all above 2000x1000 pixels)!

Is there a way to make Drupal automatically re-process all the Commerce product images (call it a bulk resize, or a batch resize...)? Or have I got to reprocess them through Photoshop or something like that, and then re-import the CSV?

I know that probably not many people have faced a similar situation... any hint is appreciated!

Edit

I'm using Views Slideshow with jQuery Galleria, which loads the original images and resizes them via img tag attributes width and height.

That is a reasonable part of the problem, because even if I use Image styles (Configuration>Media>Image styles), Galleria keeps using the original image, which slows down the browser and consumes a lot of RAM.


texts: author_picture twig variable outputting title and bio?

texts:
Reading the D8 documentation, it says the appropriate twig for displaying the author's picture is:

{{author_picture}}

When I use that, however, I'm getting the author's title, and description as well.  Is there a way to fix that other than CSS fixes to render the other fields invisible?  Or is there something I'm missing?


texts: What is The Best Practice for Custom Plugin Files Placement

texts:
I'm going to create a custom plugin type, so I need to create a plugin manager, plugin base, plugin Interface and a plugin annotation, the annotations goes to ModuleRoot/src/Annotation but for the rest I saw 2 approaches

Place PluginManager, PluginBase and PluginInterface in moduleRoot/src
Place PluginManager, PluginBase and PluginInterface in moduleRoot/src/Plugin

but I couldn't resolve which one is the best practice?


texts: How to filter the view2 fields and show by clicking on view1 node

texts:
I have view1 and view2,  when I click on the node link of view1 say

ex:  id [mc] it should get view2 and display corresponding  information like strain , projects etc based on the id[mc].

So far to get the view2 while clicking on view1 node, I have performed following,

In view1 I have rewritten the tittle[node] output to link and specified the path of view2.
Given contextual filter to filter and to get the related field value of view2.

Problem is when I click on particular node of view1 it gives the view2 but it is not filtering based on the  node we have clicked.

So can you please tell me how to filter and get the field values of view2.


texts: Entity reference get all related items in a view

texts: I'd like to have a view block on my content page that shows ALL related content. ALL in the sense of chaining - if Node A references Node B which references Node C which references Node D, then nodes B, C, and D all show up on Node A's page even though it itself is only related to Node B. How can I set this up?


texts: How can I form a Views query that retrieves all nodes that are referenced by a node in another content type?

texts:
I have a content type of Artist. I also have a content type of Release. The Artist content type has a node reference field that points to the Release content type. This node reference field allows an Artist to have 1 or more Releases.

I created a view that displays fields from the Artist content type as a page. Let's call this view "Artist Page." Artist Page has a single argument of Node: Title and a path of artist/%. This works really well.

I would like to add another view for a block of Releases belonging to a particular Artist. I hope to display this block in the sidebar for Artist Page.

How can I form a Views query that retrieves all Releases that are referenced by an Artist?

(I am making my first non-trivial Drupal 6 site and I appreciate your patience. I am happy to RTFM but please tell me where to go!)


texts: How to handle caching on a Drupal 8 custom Views access plugin that checks a User's Profile's field value

texts:
I have a custom Views access plugin that check access against a value in the current User's Profile (entity) field value.

The plugin works but if I change the profile field value the access does not check again until the cache is cleared. I know this is an issue with setting up the cache tags/contexts but I cannot not figure out what is needed so that the cache is cleared when the user profile is updated.

Right now I'm not using any cache tags/contexts in my View access plug and I've tried various combinations without luck. Help!

Current cache functions:

public function getCacheMaxAge() {
    return Cache::PERMANENT;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return ['user'];
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    $profile = \Drupal::entityManager()->getStorage('profile')->loadByUser(user_load(\Drupal::currentUser()->id()), 'employee');
return $profile->getCacheTags();
  }


texts: Is this correct usage of hook_node_view()?

texts:
hook_node_view_alter(&$vars, $hook) {

  global $base_url;

  if($vars['#node']->status == 0) {
    header('Location: '.$base_url.'/?errCode');
  }
}

Simple hook to redirect unpublished nodes to prevent 404s (this is just a proof of concept).

Factor 1: There is already existing unpublished pages that have redirects (via the Redirect Module from Drupal Core) - this shouldn't affect that.

This is placed in my theme/template.php file but I'm not confident that this hook is best suited (although it works). Is there a lower level menu router hook which I can use?


texts:
We have Synology DSM (Disk Station Manager) Installed in our office, and my Drupal 7 site is hosted on it. I want to use Directory Users to use Drupal with same credentials using LDAP.

I installed the LDAP required modules, but I am still having trouble configuring and connecting.

Did anyone work with LDAP with Drupal?


texts: Handling circular entity references with Migrate

texts:
I am using Migrate D2D on a Drupal 6 to Drupal 7 migration right now.

I have three types: type1, type2, type3.  Each of the three types has a entityreference field on it, which is configured to be able to point to all three types.  This means that there can be circular references, and when a particular node is being migrated, the destination node may not exist yet and could potentially be any of the three types.

My migration class looks like this:

class MyNodeMigration extends DrupalNode6Migration {
  public function __construct(array $arguments) {
    parent::__construct($arguments);

    $this->addFieldMapping('field_legacy_nid', 'nid');

    $this->addFieldMapping('field_the_reference', 'field_the_reference')
      ->sourceMigration(array('type1', 'type2', 'type3');
  }
}

$node_arguments = array(
  array(
    'class_name' => 'MyNodeMigration',
    'description' => 'type1',
    'machine_name' => 'type1',
    'source_type' => 'type1',
    'destination_type' => 'type1',
    'dependencies' => array('roles', 'users'),
  ),

  array(
    'class_name' => 'MyNodeMigration',
    'description' => 'type2',
    'machine_name' => 'type2',
    'source_type' => 'type2',
    'destination_type' => 'type2',
    'dependencies' => array('roles', 'users'),
  ),

  array(
    'class_name' => 'MyNodeMigration',
    'description' => 'type3',
    'machine_name' => 'type3',
    'source_type' => 'type3',
    'destination_type' => 'type3',
    'dependencies' => array('roles', 'users'),
  ),
);

$common_node_arguments = $common_arguments + array(
  'user_migration' => 'users',
);

foreach ($node_arguments as $arguments) {
  $arguments = array_merge_recursive($arguments, $common_node_arguments);

  Migration::registerMigration($arguments['class_name'], $arguments['machine_name'], $arguments);
}

When I run the migrations, most nodes are fine, but I get a decent amount of Stubs (*) created.  Some of the destination nodes have the entityreference pointing to these Stub nodes.  The source nodes are fine.

What I have uncovered is that the bundle on the destination nodes that are being made as stubs are incorrect, and look like they are all type1.  A node of the proper type does end up being created, but it never gets set as the entityreference target.

Another way to explain this is that I end up with

node: nid=123, type=type1
node: nid=234, type=type1, field_the_reference=123
node: nid=345, type=type2

where it should be

node: nid=234, type=type1, field_the_reference=345
node: nid=345, type=type2

How do I handle this situation?

(*): a "Stub" in the context of this question here refers to a node which is created for the purpose of being a reference target, but does not get its data initially. The term is used throughout the Migrate documentation and source code.


texts: Trigger views exposed filter on custom select box

texts:
I have this view which contains an exposed filter to filter out a simple content type listing page.
The problem is about theming and keeping the view functional.
I succeeded in theming the view with a select filter, as provided to me in a static html file.

The filter is select box but the theming have it's proper tags that works similar to a select box model.
For example:

<!-- Basic select box in Drupal -->
<select data-drupal-selector="edit-filterone" id="edit-filterone" name="filterone" class="form-select">
  <option value="All" selected="selected">- Any -</option>
  <option value="13">term 1</option>
  <option value="15">term 2</option>
  <option value="16">term 3</option>
</select>

<!-- Our themer select box model -->
<custom-select label="Filter label" name="filterone">
  <custom-option label="- Any -" name="filterone" value="All" selected></custom-option>
  <custom-option label="term 1" name="filterone" value="13"></custom-option>
  <custom-option label="term 2" name="filterone" value="15"></custom-option>
  <custom-option label="term 3" name="filterone" value="16"></custom-option>
</custom-select>

Then the value selected get stored in a JS object.

In this view I use BEF (Better exposed forms) module and autosubmit is activated with a hidden apply button.

Using twig suggestions I can populate the select list with the filter values but there is no action trigged when I change the item.

The view is not applied and it act just like a static html. I need a way to keep the filter functional as normal.

I can get the values with js when a select list change but I don't know (or have a clue) how to send these values by ajax and alter the view and get back the results as normal views do.

My first thought is to keep the select boxes provided by drupal and just hide them from display and when the user changes value in the 'fake' select box, have them copied to the hidden one; and then just trigger the click on the (hidden) apply button.

Any suggestions please?
(I don't know if my explication is that clear but I can be more specific if needed, thank you)


texts: Change published status directly in database

texts:
I want to change published status of nodes according certain criteria. So I directly modified 'status' column of 'node' table. But it seems to be not reflected when nodes are viewed or edited (I want to avoid using node_lodad() and node_save())

That is, if I change 'status' column value of a row in 'node' table, it does not reflected in when corresponding node opened in browser.

So, from where it takes the 'status' (publihed/unpublihed) value other than 'node' table?


texts: How to make exposed timestamp filter accept human readable date

texts:
I'm using Drupal 8. I created a new content type (title, body, image, date).
The date is a timestamp field.

I used the devel module and the Realistic Dummy Content module to generate a test content for my view test.

I created my test view and chose the date as an exposed filter.

Here is my configuration:

And this is my view:

When I apply my filter, I want to say all contents having a date greater than my input:

If I test with 01/31/2018 - 02:54, nothing was changed!

But If I test with the unix value: 1538323253, my filter works well!

Any idea please to make the filter with human readable value?


texts: Is there any website that allows to write and test Drupal Code online ? Like this one for PHP writecodeonline.


texts: How can I preview the CiviCRM contribution thank-you page

texts:
I want to modify the HTML in the CiviCRM thank you page but I need to see how the page looks on the site before making it public. Is there a preview page or even a live link I can use?
Further is there a way to preview the automatic receipt e-mail.

Thanks


texts: SEO - redirect old urls to node/### paths or node aliases?

texts:
We've got an old site that we just finished migrating to D8. We are adding a ton of redirects to the site, but I'm wondering whether it's best to issue these redirects to the new node/### paths or their path aliases?

My gut tells me to issue the redirects to the node/### paths since those will always and forever stay the same, whereas something might happen to the path aliases. I know that redirect handles auto-redirecting old aliases to new aliases, but in the event that something goes wrong with this I figure it's better to have the redirects pointing to the node/### paths instead.

Any thoughts?


texts: Can't update nodes / node unpublishes itself

texts:
This problem has been bugging me for some time now and I haven't been able to find this issue online anywhere else.
My Drupal 7 website has a very simple photo gallery, using a custom node type called gallery with image upload fields.
One or two of these nodes (but not all) have started behaving very strangely. When I upload new images, the files appear to upload successfully and the thumbnails appear, but immediately I get a message directly above the field on the edit page saying "Gallery (node title) has been updated." Normally this message would only appear after submitting changes using the save button.
When I click 'Save', I get the following message:
"The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved."
At this point, the node unpublishes itself, and the changes I make are not saved. The only way to publish the node again is by using the /admin/content interface.
I have noticed that nodes that have many images are the problematic ones. One such node has 160 images.
This behavior only happens with the gallery node type. I have tried creating a new node type with the same fields and recreating the node from scratch, but the same thing happens. I have tried using the image widget and the multiupload widget.


texts: How can I properly duplicate Fields on entities?

texts:
I have an entity that has an image field attached to it. This field can hold multiple images.
I would like to be able to display a single/first image with one field formatter from this field at one place and all images with another formatter from this field in another place.

~~So I need to somehow clone this field, most likely via custom configuration to store some basic data and attaching it via hook_entity_base_field_info().

What I am not sure about is how to use the proper field type for this "computed" field so I can use proper field formatters, how to set proper source of data(the original field) and how to properly use isEmpty() method on that field so this field won't show up if the original field is empty without using my own field class to do that(since I would lose the compatiblity with proprr formatters).~~

Sorry, that was a bit misleading. I only need to be able to display the field with different formatter which means I only need another instance of that field in the entity_view_display.

hook_entity_extra_field_info() seems like the best solution, but it does not allow formatter settings.


texts: Security concerns with cache_get() and cache_set()

texts:
are there any security concerns with Drupal's cache_set() and cache_get() functions?
I mean, I receive some values through an Ajax-GET-request. Can I pass them to the two functions with the following validation?

Javascript:

//token was passed through drupal_add_js() to Drupal.settings.my_module
var url = path + token + '/' + var1 + '/' + var2;
$.get(url);

Page callback:

function my_module_ajax_callback($token, $var1, $var2) {
  if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])
      && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
      && is_numeric($var1)
      && drupal_valid_token($token, $var1)) {

    if (is_numeric($var2) && $var2 >= 0 && $var2 < 3600) {
      //can I pass $var1 and $var2 to cache_get() and cache_set() at this point? e.g.:
      cache_set(var1, var2);
      //Are there still security risks?
    }
  }
}

I would welcome every advise.

Thanks!

Daniel


texts: How do I prevent CKEditor 4 from stripping Google AdSense asynchronous tags?

texts:
For whatever reason, CKEditor 4 is stripping Google AdSense asynchronous tags from my Full HTML text format.

What starts as this (placeholders substituted for IDs):

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
<!-- Top Banner -->
<ins class="adsbygoogle"
    style="display:inline-block;width:728px;height:90px"
    data-ad-client="ca-pub-XXXXX"
    data-ad-slot="XXXXX"></ins>
<script>
    (adsbygoogle = window.adsbygoogle || []).push({});
</script>

Ends up as this:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
<!-- Top Banner -->
<script>
    (adsbygoogle = window.adsbygoogle || []).push({});
</script>

Again, this is in the Full HTML text format and I'm able to get the ins tag through without attributes, but not with attributes, even though other tags have no problems getting their attributes through to save.

For what it's worth, I do have the following set on the CKEditor profile:

config.allowedContent = true;

UPDATE

CKEditor is only stripping the ins tag (and attributes) when it's an empty tag as given by AdSense. If I add anything – a non-breaking space, even – CKEditor is preserving the ins tag and attributes.

Per tenken's suggestion, I added the following line to my config, but it didn't help.

config.protectedSource.push( /<ins class=\"adsbygoogle\" style=\".*\" data-ad-client=\".*\" data-ad-slot=\".*\"\><\/ins\>/g );


texts:
How do I check there is a revision exists for a node? I can load the node details using the following code.

$nid = "my_node_id";
$node_details = \Drupal\node\Entity\Node::load($nid);

How do I check if there is a revision for a node? Putting it differently: How can I get the revision ID of a node after creating a new revision?

I create a new revision using this code.

  $original_revision = \Drupal\node\Entity\Node::load($nid);
  $original_revision->my_field_to_be_modified= "my_value";
  $original_revision->setNewRevision(TRUE);
  $original_revision->setRevisionCreationTime($time_stamp);
  $original_revision->save();


texts: Setting a field collection default value for a field using form

texts:
I'm trying to set up a default value programmatically to my field which is in field collection. This has proved quite hard and I cant seem to get around it. Any assistance will be appreciated. This is the code i have tried to far without any success.This field is a select list with different select items. Now i want it to pre-select one of the items.

$field_collect = $form["field_fielc_collection_group"][LANGUAGE_NONE];

                            foreach ($field_collect as $fielders){
                                        if(is_array($fielders)){
                                        $somethin = $fielders["field_to_set_default"][LANGUAGE_NONE]["#default_value"];
                                        $default_val =array(t('something'));
                            array_push($somethin,$default_val);


texts:
When i override atome title in gallery items, The title displayed in the images of my gallery does not change, the displayed title is the name of the image.

Can someone confirm that this is a scald gallery issue ?

Thank's


texts: Reload form after displaying custom message using modal

texts:
How can I display the form after ajax call and closing the modal? Right now when I use ajax to display the custom message ,but it preserves the state. When I click on modal button it display the same custom message but not the form

My code is as follows:

function demo_demo_form($form, &$form_state) {
  return array(
    'email' => array(
      '#type' => 'textfield',
      '#title' => t('Join our Newsletter'),
      '#required' => TRUE,
      '#attributes' => array(
        'placeholder' => t('mail@example.com'),
      ),
    ),
    'submit' => array(
      '#type' => 'submit',
      '#value' => t('Subscribe'),
      '#ajax' => array(
        'callback' => 'demo_form_ajax_submit',
        'wrapper' => 'demo-demo-form',
        'method' => 'replace',
        'effect' => 'fade',
      ),
    ),
  );
}

/**
 * Ajax callback function.
 */
function demo_form_ajax_submit($form, $form_state) {
// Dummy/dumb validation for demo purpose.
  if (!empty($form_state['input']['email'])) {
    $message = "subscription form submitted!";
    return $message;
  }
  else {
    return $form;
  }
}

But when I click modal button it shows the same message. I can use window.location.reload but I only want to reload the form in the block.

Javascript is as follows:

// On Load
(function($) {
  Drupal.behaviors.demo = {
    attach: function (context, settings) {
      $('#mybutton').on( "click", function() {
        $('#block-demo-file-upload').modal('hide');
      });
    }
  };
})(jQuery);

How can I display the form when I open the modal window next time without reloading the page?


texts:
I am using SHS module. What I want to do is, override the SHS widget such that the I can alter the query used to fetch the data in the widget. Till now, I have overriden the route controller and have found that the underlying query is being generated from the loadTree() function of the  core/modules/taxonomy/src/TermStorage.php file.

Now what basically I want is, to override this function, such that I may be able to alter the query to my requirement. Im not sure what is the correct way to do that in OOPS.

Please help.


texts: How to pass rendered form results to page

texts:
Drupal 8.7.x

I have a custom form that currently replaces the form with the output of the form like so:

CalculationForm.php

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

    ...

    // Result overview.
    $result = [
      '#theme' => 'THEME_calculation_overview',
      '#name' => !empty($values['company_name']) ? $values['company_name'] : $form_state->getValue('firstname') . ' ' . $form_state->getValue('surname'),
      '#product' => $product,
      '#address' => $address,
      '#results' => $result_clean,
      '#urls' => $product_urls,
    ];

    // Bundle (rendered) results.
    $results_overview .= render($result);

    // Show rendered results.
    $this->response->addCommand(new ReplaceCommand('#form-calculation-container', $results_overview));
}

Currently the form submission makes an ajaxcall that replaces the container which holds the form with the rendered output (Replacecommand). Because we can't track the form submission with GTM I'm switching over to a normal form submission which redirects to a page.

My question is, how can I pass $results_overview to the redirect page and make it render as part of the content variable.

Thanks in advance


texts: How do I set an empty link title in a menu item?

texts:
I'm using a fontawesome icon in a menu (with the tbmegamenu module) and I want to remove the text. Drupal forces me to enter something, &nbsp; doesn't work so as a temporary solution I put at dot .
How can I remove the dot without resorting to very dirty CSS tricks?

See also the actual HTML at the website.

Entering an empty string in the menu title would be the cleanest way to get to a solution now.  Maybe it's possible with a hook that lets me put <none> in the menu title?


texts: How to set webform message below the submit button?

texts:
I need to render the HTML of the errors messages below the submit button for styling purpose. I find out about Inline Form Errors; however, this will display an error message after the field and not after the submit button.

Any idea how can achieve this?


texts: How can I use the Mail System module to send one e-mail differently than others?

texts:
Problem

I would like to configure Mail System to use a different mailing class (one that does not format e-mail with Mime Mail) for the "welcome (no approval required)" e-mail.  Mail System supports adding a New Setting, which takes a module and a key.  For module I selected Core: user module, but what should I select for the key?

Background

On my D7 site, I am using the Mail System module to manage e-mail.  By default, everything is formatted by the Mime Mail module and sent with the Smtp module.

This is great for every message except the "welcome (no approval required)" email.  The reason is that I am using Logintoboggan and that e-mail contains the link to validate the account; when it is formatted with HTML (processed by the Mime Mail module), then sometimes users on mobile phones are not able to click the validation link.


texts: Using setAttributes() returns a fatal error

texts:
I have the following code in a rule:

$imgpath = file_load(($node->field_image[LANGUAGE_NONE][0]['fid']))->uri;
$image = theme('image_style', array('path' => $imgpath, 'style_name' => 'thumbnail'));

$link = l($image, "node/$node->nid", array('html' => TRUE));
print $link;

I need to add a class to the thumbnail picture. I change the code as follows, but I get a fatal error about calling a member function on a non-object.

$imgpath = file_load(($node->field_image[LANGUAGE_NONE][0]['fid']))->uri;
$image = theme('image_style', array('path' => $imgpath, 'style_name' => 'thumbnail'));
$image->setAttribute("class", "AnyClass");

$link = l($image, "node/$node->nid", array('html' => TRUE));
print $link;

What am I doing wrong?


texts: Have module .install create a table in a non-default DB

texts:
I have constructed a module that, using the .install file, creates a table on a database different than the default.  The module installs fine and functions fine – just a hello world example in the controller. However, when I uninstall the module I get: “The website encountered an unexpected error. Please try again later.” and the reports log there is:
DatabaseExceptionWrapper: SQLSTATE[42S02]...

Here is the .install file code:

function hello_world_schema()
{
    db_set_active('notTheDefaultDB');
    $schema['create_table'] = array(
      'fields' => array(
        'id' => array('type' => 'serial', 'not null' => TRUE,),
        'name' => array('type' => 'varchar', 'length' => 40, 'not null' => TRUE,),
        'last_name' => array('type' => 'varchar', 'length' => 40, 'not null' => TRUE,),
        'message' => array('type' => 'varchar', 'length' => 250, 'not null' => TRUE,),
        'boogie' => array('type' => 'varchar', 'length' => 20, 'not null' => TRUE,),
      ),
      'primary key' => array('id'),);
    return $schema;
}

I do realize that I'm tell hook_schema to switch to notTheDefaultDB and don’t switch it back – if it is switched before the return statement the table is created in the default.

As I said, the module seems to function as intended, but blows up when uninstalled.

Is there a way to write the module so it doesn’t blow up on uninstall or perhaps an entirely different way to do what I’m after?


texts: "Organic groups: Group node" equivalent?

texts: I have several Drupal 6 views that use the "Organic groups: Group node" relationship.  Does anyone know what the equivalent relationship in Drupal 7 is?  Trying to set this up in Drupal 7 and the wording is confusing as I don't know what.


texts: Is it possible to have custom, default fields added to all new product types In Commerce 2?

texts:
I have multiple custom fields that will need to be on all new product types (Commerce 2). The fields are already created on the 'default' product type. But new product types do not inherit the custom fields.

Is there a way to have custom fields automatically added to all new product types?


texts: Set default value radio button in template

texts:
I'm trying to set a default value in a template file for a radio button on my register form.

Female has value 0 and male has value 1. This is the code I use to set a default value:

    $form['field_personal_details']['und'][0]['field_gender']['und']['#default_value'] = '1';

I also tried

    $form['field_personal_details']['und'][0]['field_gender']['und']['#value'] = '1';

This should check the radio button as male, but it doesn't work.
Whenever I set the default value to male through the UI it does work and I get the same outputs when I do a dpm.

What am I doing wrong?


texts: Role based exposed filter is not showing anonymous and authenticated roles there. Can anyone tell me any method to add that roles?

texts: I've created one drupal7 view which will filter all contents based on roles not current user role. For that I've created one relationship 'author' then in view filter criteria I've given exposed author roles. But by default Anonymous and Authenticated roles are not showing there. Do we have any method to add Anonymous and Authenticated role to that filter?