texts:
I am trying to resize an colorbox containing an iframe. The following code works fine on normal sites but in Drupal it is having problems. Can anyone suggest what I am doing wrong? The colorbox is supposed to resize to the size of the content plus a specified offset in the Resize function.

(function($) {
    $.fn.formToWizard = function(options) {
        options = $.extend({
            submitButton: ""
        }, options);

        //Resize the colorbox
        function Resize_Box(){
            var x = $("body").width();
            var y = $("body").height()+30;
            parent.$.fn.colorbox.resize({
                innerWidth: 600,
                innerHeight: y
            });
        }

        var element = this;

        var steps = $(element).find("fieldset");
        var count = steps.size();
        var submmitButtonName = "#" + options.submitButton;
        $(submmitButtonName).hide();

        // 2
        $(element).before("

");

        steps.each(function(i) {
            $(this).wrap("

");
            $(this).append("

");

            // 2
            var name = $(this).find("legend").html();
            $("#steps").append("

");

            if (i == 0) {
                createNextButton(i);
                selectStep(i);
            }
            else if (i == count - 1) {
                $("#step" + i).hide();
                createPrevButton(i);
                createNextButton(i);
            }
            else {
                $("#step" + i).hide();
                createPrevButton(i);
                createNextButton(i);
            }
            Resize_Box();
        });

        //Create the previous button
        function createPrevButton(i) {
            var stepName = "step" + i;
            $("#" + stepName + "commands").append("< Back");

            $("#" + stepName + "Prev").bind("click", function(e) {
                $("#" + stepName).hide();
                $("#step" + (i - 1)).show();
                $(submmitButtonName).hide();
                selectStep(i - 1);
                //Only resize if going back to the first step since it has fewer options
                if(i==1){
                    Resize_Box();
                }
            });
        }

        //Create the next button
        function createNextButton(i) {
            var stepName = "step" + i;
            if(i != count-1)
            {
                $("#" + stepName + "commands").append("Next >");
                $("#" + stepName + "Next").bind("click", function(e) {
                    var currentq = document.querySelector('div#step'+i+' input[type=radio]').name;
                    if($('input[name='+currentq+']:checked').length > 0) {
                        $("#" + stepName).hide();
                        $("#step" + (i + 1)).show();
                        if (i + 2 == count)
                            $(submmitButtonName).show();
                        selectStep(i + 1);
                        //Only resize if going from the first step since all other steps have more options
                        if(i == 0) {
                            Resize_Box();
                        }
                    }
                });
            } else {
                $("#" + stepName + "commands").append("<input id='SaveAccount' type='submit' value='Submit' class='next notvalid'/>");
            }
        }

        function selectStep(i) {
            $("#steps li").removeClass("current");
            $("#stepDesc" + i).addClass("current");
        }
    }
})(jQuery);


texts: How to print CCK field on product page if radio button attribute is selected

texts:
I would like to print the contents of a specific field when an Ubercart product's radio button attribute is selected. For instance,

Radio Button with options A, B, and C.

If "A" is selected, no change.

If "B" is selected, show data from field "1".

If "C" is selected, show data from field "2".

How can I add this functionality to my product page tpl file?

Thanks!


texts: content by users is unpublished - How I can make it publish automatically?

texts:
I am building Drupal 7 site.

I created a content type.
When an administrator is writing new content - it is immediately published.

But when it is authenticated user - the content is not publish automatically and it's unpublished by default.

When I checked the "publishing option" on the content type, the check box of the "Published" is checked.

Why it's suddenly happen?
Why the content of authenticated users is being unpublished by default?


texts: Generate image style from existing one instead of original image

texts: How can I make Drupal to generate image style from existing style, instead from original image. For example, original image is 3000x2000. I have a style medium (1000x700). And then I need a style thumbnail (100x100). How can I make Drupal to resize 1000x700 -> 100x100 and not 3000x2000 -> 100x100 (for optimization purposes).


texts: How do I redirect to a route with POST method?

texts:
I want to redirect to a route and also want to send some parameters which I don't want to expose on URL.

So, I need to redirect with a post method. How to do this?

$form_state->setRedirect('route.name', array('key' => 'value'));
new RedirectResponse(\Drupal::url('route.name',array('key' => 'value')));

all these above procedure to redirect is done through GET methods.

So, is it possible to do this with POST method?


texts: How do I make form_set_error() affect the submitted form only?

texts:
I have a couple of different forms on one page; each has a 'name' field.

Sensibly, on submission drupal processes the submitted form, but in what seems a completely barmy way of doing things, form_set_error() just takes a field name, and appears to have no knowledge of which form was submitted.

So if the name field is invalid on the submitted form, it gets marked as invalid on all the other forms that use a field called 'name'.

Does this mean that every field needs a unique field name, e.g. name-somemodule1 and name-somemod2? This will break user convenience (browser probably knows what to pre-fill for 'name').

Sure I've missed something, but have read a lot of FAPI pages and code comments and am still confused.

In the screenshot below, you'll see 2 forms. The one on the left is the submitted one, with 'invalid-name' in a field called 'name'. The one on the right is not submitted (can only physically click one submit button at once!) and yet it's 'name' field (with 'admin' in it) is also marked invalid.

These are entirely separate forms.

Here's my modules' code (email field omitted, some attrs omitted just to reduce post size)

function mymod_contact_form() {
  $form['comment'] = array(
    '#title'         => t('Enter query'),
    '#default_value' => '',
    '#type'          => 'textarea',
  );

  $form['name'] = array(
    '#title'         => t('Enter name'),
    '#default_value' => '',
    '#type'          => 'textfield',
  );

  $form['submit'] = array(
    '#type'  => 'submit',
    '#value' => 'Send',
  );

  return $form;
}

function mymod_contact_form_validate($form, &$form_state) {
  $name = trim($form_state['values']['name']);
  if (strpos($name,' ') === FALSE) {
    form_set_error('name', t('Please enter your full name'));
  }
}

function mymod_contact_form_submit($form, &$form_state) {
  $vals = $form_state['values'];
  // …
}


texts: How can I integrate a stemmer with Search API?

texts:
Exactly what the question says - I'm using Search API with Database Search. I also have the Porter Stemmer module, but my understanding is that it only works with the Drupal built-in search.

Any help with this would be greatly appreciated.


texts: Can I insert the version number in the info file of a module for internal use?

texts:
The documentation on the creation of custom modules says,
# Note: do not add the 'version' or 'project' properties yourself.
# They will be added automatically by the packager on drupal.org.

so I never put a version number in my module. But then I add difficulties writing database update scripts, I never managed to get an N in hook_update_N() that the update would recognize.
Also, my module really doesn't have any utility outside of my organization, since it has very specific domain requirements; therefore it is not, and never will, be released as a contributed module.
So, can I use a version number in my info file, and use it to generate the name of the update function? And if I insert it in an update of my module, will it be correctly managed?


texts: How to run cron automatically after node published?

texts:
cron has to run after some time  of node publishing.I tried like this

 function custom_module_cron{
//($updated = node published time)
if(date("Y/m/d H:i:s") == date("Y/m/d H:i:s",$updated+60)){
//code here
}
}

but its not running automatically. Can anybody help ?


texts: How do I override the subscription block?

texts:
I am developing a Drupal 8 website and I want to override the subscription block used by the Simplenews module. I know how to achieve that at Drupal 7, but the module is different now. For Drupal 7, I followed http://api.worldempire.ch/api/simplenews/theme%21simplenews-block.tpl.php/7-2.

I want to do the same for Drupal 8. How can I achieve it?


texts:
I am using the following code to query an ECK entity.

$query = \Drupal::database()->select('object__field_amount', 'f');
$query->fields('f', array('object__field_amount_value'));
$query->addExpression('MAX(object__field_amount_value)', 'maxvalue');
$query->execute()->fetchAssoc();

It raises the following exception.

  Drupal\Core\Entity\EntityStorageException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'maxvalue FROM object__field_amount f'

I've tried multiple other options, without result.

How do I avoid the code raises an exception?


texts: Hiding the password field during user registration?

texts:
When I deselect the Require email verification when a visitor creates an account option, users must enter a password during registration. I want users to be able to register without a password, and also not receive a new signup email. When users create an account, they should be able to immediately log in, which means I can't use the blocked state for the user. I added a new field for "true confirmation", after they click on the link in my own custom email.

An even better solution would be if I could use Drupal's login method, but the users should still be able to log in, even when they aren't confirmed. Is there anything that does this already?


texts:
I have a taxonomy view that outputs to the a page
example.com/food/toast  that works correctly. It shows a list of nodes that have the term food within them.

When I try to change the path to meals/toast, the view breaks and I can not figure out why.

Any idea to help me??


texts: How to identify disabled fields in form submit handler?

texts:
I have a pretty complex form, on which fields are getting enabled and disabled conditionally. I'm using JavaScript to do that without call to server for performance purposes.

How can I not save values from fields that are disabled? Some of the conditions are not entirely based on field values, but also on user's behavior on a form, so it is not possible to simply recreate logic in PHP.

Currently I'm emptying disabled fields before submit, and then testing if $form_state['values']['field'] is filled and $form_state['input']['field'] is empty. If so, I assume field also got disabled, as my script does not allow to submit empty enabled fields. This gives me workable approximation of what I need, but prevents me from implementing graceful degradation for no-js clients, so I need a better solution.


texts:
I am trying to change the <h2> tags that block.tpl.php uses to wrap <?php print $block->subject ?> to <h3> tags so that I can target them with jQuery UI Accordion. I've got the following code:

<?php
    function MYTHEME_block_view_alter(&$data, $block) {
        if($block->module == 'block' && $block->region == 'sidebar') {
            $data['subject']['#tag'] = 'h3';
        }
    }
?>

This doesn't work...I assume I'm screwing up the reference to the render element. Does $data['subject'] contain an array where the HTML tag is stored? What is the correct way to target it?

Alternatively, should I look for a way to re-write block markup so that, in the sidebar region, it renders only the <h3> and <div> required by jQuery UI Accordion? Unless there's a fantastic module for turning blocks into Accordion-ready HTML already out there, I'd rather not install another module.

Many thanks for any help!


texts: How to show views block output in drupal menu?

texts:
I have views block and I want to display its output in sub menu when user mouseover on main menu. I on't know how to implement it. Is there any module for it?
Please help tell me how can I display views block in drupal menu?.


texts: Running multiple Drupal installations on one URL: is it advisable?

texts:
My employer is considering replacing our fairly static website with Drupal, mainly so we can more easily implement a few ideas we've had, and also as a way of future-proofing it. It's something of an umbrella organization in that it has a few different customer-facing departments which aren't really related to each other, apart from falling under the same organization.

So, broadly speaking, each department has pretty specific needs - certain types of defined users, types of nodes; some require their own little forums, basic shopping carts, etc. My first instinct is to treat each department as its own Drupal installation with its own specific configuration of modules and keep things separate in that way. That said, there might need to be some functionality that spreads across the entire site. For example, one or two more senior members of staff might need to be able to log in and edit content across a few of the departments.

Is it possible to do this? To run different installations at domainname.org/dept1, domainname.org/dept2, domainname.org/dept3, etc. More importantly, is it advisable? What issues would I be likely to face if I were to go ahead with a setup like this?


texts: I'm trying to achieve working slideshow from images in single node. Images are uploaded from the image field. It's drupal 7. I made new content type and all I made now is slideshow from multiple nodes (with one image in every node). This works fine but thats too problematic to add new node for every single image.


texts: How do I change the current language in a Kernel test?

texts:
I'm writing a test for something that returns a Url from an entity. This should be language-aware, so the test needs to change the current language.
I started off writing a Kernel test for this, because they're faster, but I can't figure out how to make the test code change the current language:
  public static $modules = [
    'system',
    'user',
    'language',
    'content_translation',
    [SNIP]
  ];

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

    $this->installConfig(['language']);
    $this->installEntitySchema('configurable_language');

    $this->languages['de'] = ConfigurableLanguage::createFromLangcode('de');
    $this->languages['de']->save();

    $config = $this->config('language.negotiation');
    $config->set('url.prefixes', [
      'en' => 'en',
      'de' => 'de',
    ])->save();

    \Drupal::service('kernel')->rebuildContainer();
    \Drupal::service('router.builder')->rebuild();
    $this->languageManager = $this->container->get('language_manager');
    $this->languageManager->reset();

    [SNIP]
  }

  public function testCurrentLanguageChange() {
    // Change the site's current language.
    dump(\Drupal::languageManager()->getCurrentLanguage());

    \Drupal::service('language.default')->set($this->languages['de']);

    dump(\Drupal::languageManager()->getCurrentLanguage());
  }

}

In the test code above, both dump() calls output the 'English' language object.


texts: enable secure site only on certain pages

texts:
I am sending out user generation emails, but users can not access their one time login because of secure site  from this link i see something about "Bypass Login Filter Page" and an option to set secure site login exceptions on certain pages but I can not find that anywhere.

http://drupal.org/node/98514


texts:
I want to theme a form in drupal. I know I can add and remove things to the form using hook_form_alter(), change the text etc. Great!

I also want to add some custom html to the form. For example adding a div with some text between two form elements.

I want to do this on the comment form. The comment form has the ID comment_form. So I need to add it to the theme registry.

function mytheme_theme() {
    $items = array();
    $items['comment_form'] = array('comment_form' => array('arguments' => array('form' => NULL)));
    return $items;
}

So I then need to add a function to be called

<?php
  function mytheme_comment_form($form) {
    // stuff goes here
  }
?>

How do I affect the html in this function and render it on the page?


texts: How do I use arguments with the Path Breadcrumb module?

texts:
I am using the Path Breadcrumbs module to create breadcrumbs. I don't fully understand how to use arguments and selection rules, and thus I'm not sure how to create the following breadcrumb:

On the gallery node page (/gallery/%node), I want to use home > events >[event-name] > schedule as breadcrumbs.

Every Event node contains a node reference to a gallery node. I am trying to add this event name to the breadcrumbs. I already have retrieved the event name from $variables, following  How do I retrieve node data for a referenced node in a template file?


texts: How enable Taxonomy to work with Basic Pages

texts:
When I create an Article I choose an appropriate Tag from my Taxonomy List and save the article. When I click the tag after I save the article I get a list of articles with the same tag.

But how do you make a Basic Page work this way? I've researched Manage Fields and Manage Displays in admin-structure-types-manage and I CAN choose a tag and save it with the Basic Page...but I can't click on a tag on a Basic Page and get a list of all Basic Pages with the same tag.

Can you assist?


texts: How to set a yml sequence config value via drush cset

texts:
When the drupal config value (as defined in .schema.yml) is a sequence what is the correct syntax for drush config-set so that the value is a sequence not a simple string? For example, with the devel module
drush config-get devel.settings error_handlers returns

'devel.settings:error_handlers':
  1: 1

So what is the syntax to set the value to 4: 4. I have tried lots of combinations, such as 4:4  [4:4]. error_handlers.4 4 but have not hit on the right way yet. I could not find any examples or documentation, so asking here. Thanks.


texts: Drush bootstrap fail - wrong MySQL username

texts:
drush sql-connect produces valid, working MySQL credentials:

  mysql --user=drupaluser --password= --database=core_20161101
  --host=127.0.0.1 --port=33067

So does drush status:

  Database driver        :  mysql
  Database hostname      :  127.0.0.1
  Database port          :  33067
  Database username      :  drupaluser
  Database name          :  core_20161101

However drush -d uinf admin and anything else that needs to read the database fails with:

  [...] sql-query: SELECT 1; [0.35 sec, 4.88 MB]
  [notice] Executing: mysql
  --defaults-extra-file=/private/tmp/drush_dZeMQb --database=core_20161101 --host=127.0.0.1 --port=33067 --silent  < /private/tmp/drush_Tu2o2g   ERROR 1045 (28000): Access denied for user
  'root'@'localhost' (using password: YES) Bootstrap to phase 1. [0.37
  sec, 4.88 MB]
  [bootstrap] Bootstrap to phase 6. [0.54 sec, 6.68 MB]
  [bootstrap] Bootstrap to phase 5. [0.54 sec, 6.68 MB]
  [bootstrap] Command user-information needs a higher bootstrap level to
  run - you will need to invoke drush from a more functional Drupal
  environment to run this command. [0.54 sec, 6.68 MB]
  [error] The drush command 'uinf admin' could not be executed. [0.54
  sec, 6.68 MB]
  [error] Drush was not able to start (bootstrap) the Drupal database.
  [...]

Note the username is wrong, root@localhost, not drupaluser@127.0.0.1.

Any ideas why it would be switching to the wrong username?

Versions:
Acquia Dev Desktop 2 (built Sep 5 2016)
PHP 5.5.33 (as set by Dev Desktop)
Drush 8.0.5
Mac OS 10.11.6


texts: How to disable Toolbar on certain pages / theme?

texts:
Before deprecation of hook_page_build/hook_page_build_alter() we used good old method:

$page['page_top']['toolbar']['#access'] = FALSE;

(Source)

It disabled Toolbar for specific route in specific theme.

Now I checked hook_page_top(), hook_toolbar() and hook_preprocess_page(). Nothing helped, so I temporarily removed {{ page_top }} region from my html.html.twig but it doesn't look as the right approach.


texts:
I am currently working on a project where I have 2 databases: the internal site database, and an external database that contains a table with establishment information I want to display as pages on my site.

The external database can still be modified from another application.

How do I go about doing this?
Should I create a module to generate static pages, or nodes?
What are the differences, or implications of choosing either option?


texts: Should a form only be users to collect input and not display it?

texts:
I'm using the Form API in a custom module to collect a large amount of user data, which is then collated and assessed to provide an output.

Currently I'm using ajax to refresh the form and display the output when the user submits the form. Should I be displaying the results in a different manner, or is it perfectly reasonable to do it in this manner?

Say for example I have a Myers-Briggs type survey. The user would answer a long string of questions, which on submission, I then collate and redisplay the form with results, links to other content, relevant articles etc (not just a simple result).

Is this too heavy use of the Form API to provide content, or is it reasonable for a performance and development standpoint to do it this way?

i.e.

$form['results']['#markup] = '<my markup>'


texts: drush cc segmentation error when clearing theme-list

texts:
I'm working on Vagrant/Virtual box and get a segmentation error when I drush cc theme list (8).

I'm new to Drupal and Vagrant and have no idea what this means. Would anyone be able to point me in the right direction?

Thanks


texts: Views autocomplete with aggregation (and panels)

texts:
I have panel that displays data from two custom content types, Funding and Partners. There are various attributes of Funding and Partners that I have exposed as filters.

There are two types of views I'm using to display data in the panel. The first type is simply a list of Funding instances. This is working just fine (I have the relationship setup between Funding and Partners, I'm using Content: title with the relationship, the autocomplete field points to this Content: title field, etc.).

The second type of view is giving me trouble. I'm using Aggregation to display the total number of Funding instances and the total amount of Funding, based on the exposed filters. This works just fine for most exposed filters, but it doesn't work for the Partner name. This is because I cannot include the Partner name in the list of fields and still get the aggregation behavior I want (including the Content: Type with the relationship gives me a list of funding, not the totals). Of course, when I remove the Partner name I no longer have to field to point the autocomplete exposed filter to.


texts: How can I tell if a node has more than one parent taxonomy term assigned to it

texts:
I have a situation where the colour scheme of a node depends upon which taxonomy terms have been assigned to it.

However, if a node has more than 1 parent taxonomy term assigned to it, this is a certain colour scheme of itself. I'm not sure of the technical name but by parent taxonomy term I mean the top level taxonomy term, as there will only ever be 2 levels deep, so I call this parent taxononomy term.

So I need a certain html class to be created for these special nodes who have more than one taxonomy term assigned to them.

I was thinking even to use a hidden field and to write a module which checks how many parent taxonomy terms have been assigned before creating or saving this content type in question, and then simply adds a value to this hidden field, I could then use this field to add a class to my content in views.

Am I allowed to ask for suggestions here for this, I am sorry if this is against rules


texts: How can I create a View to give me a list of nodes that share a nodereference with the User's profile?

texts:
I have a "Company" node type and a "Content" node type.

In my User profiles I have added a nodereference to the appropriate Company node, and
in the Content nodes, I have also added a nodereference to the Company owning the content.

What I am trying to do is to construct a view that will present the logged-in user a list of all Content nodes owned by (i.e. with references to) the user's company.

Pseudo-sql would be something like this:

SELECT n.title FROM node n,user u WHERE
n.company_reference = u.company_reference AND logged_in_user.uid = u.uid

There ought to be a way to do this via Views, I just have been unable to figure out how, so any suggestions or pointers will be greatly appreciated


texts: Is there an easy way to check when I last made changes to a particular view or views display?


texts: Does calling filter_xss() or filter_xss_admin() more than once have undesired effects?

texts:
Background
Some sanitization functions cause undesired effects if called more than once.
$str = 'a < b';
$f = 'check_plain';
$f($str) === 'a &lt; b';
$f($f($str)) === 'a &amp;lt; b';

It seems this is not the case for filter_xss_admin():
$str = 'a < b';
$f = 'filter_xss_admin';
$f($str) === 'a &lt; b';
$f($f($str)) === 'a &lt; b';

We can distinguish different categories of sanitization functions:

idempotent: Calling it twice is the same as calling it once. https://softwareengineering.stackexchange.com/questions/387990/what-is-a-term-for-a-function-that-when-called-repeatedly-has-the-same-effect-a
invertible/bijective: No two distinct inputs give the same output. This could be called encoding instead of sanitization.

The only function I can think of that has both qualities is the identity function.
Question
Does filter_xss() ever further modify an already-sanitized string?
Or: Is there a string $str where filter_xss_admin($str) !== filter_xss_admin(filter_xss_admin($str))?
Use case
See https://www.drupal.org/project/drupal/issues/2408955 and https://www.drupal.org/node/2824413
Drupal 7 core prints status messages unfiltered.
The Bootstrap theme passes them through filter_xss_admin().
I work on a contrib module where I want to use this theme hook, and I want to have consistent behavior no matter which theme.
I want to find out if I need to actively prevent double-escaping.
Thoughts
The filter_xss() function contains a bunch of str_replace() and preg_replace(). I find it hard to predict whether this is reliably idempotent, but I also find it hard to come up with a counter-example.


texts:
Short version: I'd like to change what is displayed in a certain rendered Node field, if the viewing user meets certain conditions. I think the Rules action "Execute Custom PHP" can do this? But I have no experience with PHP.

Less short version: On the site, users read artistic content. A link at the top of the page gives them the option to buy said content. This should give them access to a .zip file that contains Goodies.

The node's Download field shows a link to go and buy the content. On page load, if the user owns the content (determined by a Rules condition), I want the link to be replaced with a download link. Ideally, the new link would be retrieved from a hidden field on the node.

Clever use of the "hidden" parameter could also achieve this effect, but I imagine the solution would look pretty similar. Or is this at all doable in the way I've described?

Pointers to solutions or alternatives would both be appreciated. Thanks!


texts:
I am building a drupal website for a customer (=content manager) of mine. Normaly I would just adjust the permissions for the content manager so he can change what he needs to. But it would be much simpeler if I could provide a menu with shortcuts of the actions he needs.

To keep everything clean I would like to use rubik and the admin menu.

Is there a way to hide all the "admin" links for the content manager and add some custom menu links my own ? So I can provide a "custom" content management system for his needs without all the drupal possibilities (which I only need).


texts:
Can someone explain to me how node permissions are structured (or point me in the direction of a detailed list) - I'm trying to setup an editor role and want this to have full access to every content types.

It appears the only way is to tick 'Bypass content access control'?

Yet 'Administer Content' ("Promote, change ownership, edit revisions, and perform other tasks across all content types.") doesn't seem to do very much?

For example, I tick 'Administer Content' and untick 'Bypass Content Access Control', I don't seem to be able to "Promote" anything using the Actions dropdown, nor do I have an edit button next to anything on /admin/content, or any other way of accessing revisions or the ownership settings.

If I tick all the options for one content type, e.g. Basic Page, I get full access to those nodes, as expected.


texts:
I want to save a managed file from an external site. Previously, I've used this code:

$managed = TRUE; // Whether or not to create a Drupal file record
$image_file = system_retrieve_file($product['img'], 'public://product-img-' . time() . '.jpg', $managed);
if ($image_file) {
  $file = file_load(db_query('SELECT MAX(fid) FROM {file_managed}')->fetchField());
  $item['field_image']['und'][0] = (array) $file;
}

However, it's throwing 403 errors for me so I decided to use cURL in my PHP code to get this image:

$ch = curl_init('http://g02.a.alicdn.com/kf/HTB15eliFVXXXXbKaXXXq6xXFXXXa/Original-Blackberry-Z10-Dual-Core-4-2-TouchScreen-2GB-RAM-16GB-ROM-8MP-Camera-Blackberry-os.jpg');
$fp = fopen('test.jpg', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

With cURL, it works correctly, and I can get the image. How can I save this data as a Drupal managed file?


texts: How to render an image at its original size?

texts:
There are plenty of examples on the internet on how to render a styled image; for instance this one from web omelette:

$render = [
    '#theme' => 'image_style',
    '#style_name' => 'thumbnail',
    '#uri' => 'public://my-image.png',
    // optional parameters
];

However I do not want to use an image style. I want to render the original untouched image. So I tried:

$render = [
    '#theme' => 'image_style',
    '#style_name' => NULL,
    '#uri' => 'public://my-image.png',
    // optional parameters
];

Which did not work.
How do I render the original full-size image?


texts:
I am using Drupal 6 with the OpenAtrium distribution, and I'd like to completely remove the account settings menu. In other words, I don't want users (or, even better, certain users) from access account settings. I know that it can be done by hiding the menu via CSS, but I am looking for some kind of module that can make it easier.

EDIT:

Ok what I did was creating and activating a new module called disablepermissions:

function disablepermissions_menu_alter(&$items){
     $items['user']['access callback'] = FALSE;
     $items['user/%user/edit']['access callback'] = FALSE;
     $items['user/%user']['access callback'] = FALSE;
}

This actually works as intended but if I try to set some kind of permissions I only get a blank page with a 500 Internal Server Error, why? The following code does not work...

function disablepermissions_perm() {
    return array('visualizza utenti');
}

function disablepermissions_menu_alter(&$items){
     if (access_user('visualizza utenti') {
     $items['user']['access callback'] = TRUE;
     $items['user/%user/edit']['access callback'] = TRUE;
     $items['user/%user']['access callback'] = TRUE;
     }
     else {
     $items['user']['access callback'] = FALSE;
     $items['user/%user/edit']['access callback'] = FALSE;
     $items['user/%user']['access callback'] = FALSE;
     }
}


texts: Chosen working on one select but not other selects

texts:
I'm facing a strange problem with the Chosen module. I've have 3 term-reference fields added to a content-type.

While editing & adding any nodes of this content-type, Chosen UI interface is applied & working with all 3 fields.

Now, I created a view and exposed the filters for all these three term-reference fields. In the view, Chosen UI interface is applied only to one field and not applied to the rest.

In the settings of chosen module (admin/config/user-interface/chosen)
Apply Chosen to the following elements is set to select

These are the Drupal settings outputed by Drupal into javascript:

"chosen":{
  "selector":"select",
  "minimum_single":"20",
  "minimum_multiple":"20",
  "minimum_width":"300",
  "search_contains":true,
  "disable_search":false,
  "disable_search_threshold":"Never Apply",
  "placeholder_text_multiple":"Choose some options",
  "placeholder_text_single":"Choose an option",
  "no_results_text":"No results match",
  "multiple":{
     "field_tags_tid[]":true,
     "field_working_area_tid":false,
     "field_published_in_tid[]":true
  },
  "max_selected_options":{
     "field_tags_tid[]":false,
     "field_working_area_tid":false,
     "field_published_in_tid[]":false
  }
   }
}

What might be the problem? How can I rectify it?

EDIT: Here is something interesting. When I manually enter jQuery('select').chosen() into the browser console, then other two exposed filters (select elements) which were not rendered as Chosen UI elements are now rendered.

Any idea, about what might be wrong with it?


texts: Forena Reports, does not appear in the Drupal menu Structure

texts:
I installed the downloaded the 8.x-1.x-dev version of the Forena module, and it installs correctly. When I go to the menu Structure to start creating the report, the Forena Reports link doesn't appear.
How can I solve this problem?
I also have the Forena UI sub-module enabled, but Forena's Release Notes include this:

Basic rendering of reports and document types are complete, however the GUI version of the report writer has not yet been ported. Sufficed to say, this version can be used by Drupal 8 report writers who are comfortable writing .frx files and sql elements by hand.


texts: Using views to overwrite Taxonomy pages for content *and* user terms?

texts:
First: I'm developing a site on a site-wide Drupal 7 installation. It's not quite vanilla Drupal, but I can't add modules to it.

What I'm trying to do: Use views to create a team directory. The taxonomy is associated with users, whom check off the teams they are on. I have a directory page that with a user table that links to the taxonomy terms.

Second: We have taxonomies associated with content and would like to display a table list of all content with those terms, overwriting the standard view for taxonomy pages.

I've created two views - one (Content) view that overwrites /taxonomy/terms/% and displays the table of content terms using a contextual filter on taxonomy term IDs.

The other is essentially the same - one (User) view that overwrites /taxonomy/terms/% and displays the users with that term associated with them.

Making two separate views was the only way I could find to access both User fields and Content fields. I'm hoping there's a way to have them both work but only when the term meets the correct criteria, otherwise the one vocabulary shows blank pages when the other works, or vice versa.

Am I close or off the mark? I seem to be able to get one or the other to work, and they both work in preview mode.


texts: Ajax processed not added on link element

texts:
I am stuck on a case where I am trying to ajaxify a link, following the tutorial placed here http://clikfocus.com/blog/simple-ajax-example-drupal-6-and-7.

The problem is that the .ajax-processed is not added to the link.

Can you suggest any common pitfalls here?

The weirdest part is that some of the other modules is blocking the functionality. Could it depend on the setting of the view that prints this element?


texts:
Using the Internationalization Module I have configured multiple languages (all English, but different countries). We are using the languages to present variable data on pages but don't necessarily want to translate the body. For example, Canada and the US have different phone numbers and currency but the language is still English and the copy may or may not need to be changed.

For the most part a node is Language Neutral (und) but when we need a single translation for the node, we still need to create the remaining translations as well. This is a lot of extra clicks and we have to do this hundreds of times.

Is there a way to create all of the translations with the click of a button? I spent a good deal of time searching with no luck and any help would be greatly appreciated.


texts: How to make Entity View show Entity's custom dynamic label as page title (D8)

texts:
My custom content Entity overrides label() to provide a dynamically generated, human-readable label like:

public function label() {
  return $this->displayName();
}

Unfortunately, that label does not get used by the EntityViewController. In my module.routing.yml file I have:

entity.veranstaltung.canonical:
  path: '/admin/veranstaltung/{veranstaltung}'
  defaults:
    _entity_view: 'veranstaltung'
  requirements:
    _entity_access: 'veranstaltung.view'

I can now view my "veranstaltung" entities, but the page title is blank and the breadcrumb just shows the entity's id instead of its label.

Looking in EntityViewController::buildTitle() I can now see why this is the case:

$label_field = $entity->getEntityType()->getKey('label');
if (isset($page[$label_field])) {
  $page['#title'] = $this->renderer->render($page[$label_field]);
}

I don't have a label key, as I want the labels to be dynamically generated.

Any suggestions how to best deal with this problem?


texts: Can we use Panels for Responsive web design?

texts:
I would like to make a new site using responsive design using the Omega theme.
Are panels modules suitable for responsive design or should I use something else(like the Context module)?
Thanks


texts: How to load all field values from multiple entities?

texts:
I have an EFQ that finds the users whose field values match a given array of values:

  $users_query = new EntityFieldQuery();

  $users_query->entityCondition('entity_type', 'user')
    ->fieldCondition('field_my_field', 'value', $array_of_values);

  $users_query_result = $users_query->execute();

This will create a list of uid's but I need to know which uid goes with which value in the array.


texts: Views search for term reference in field collection

texts:
I have content type where tagged persons names are automatically saved as a taxonomy term. These created terms have a field, which is a field collection of a date and another taxonomy term which keeps information about the unit. What I'm trying to achieve is, to search for nodes via the unit taxonomy term which will bring up nodes where persons from this unit are tagged. I have no clue how to get it work. I guess somewhere under relationships or contextual filters should be the options but so far I wasn't able to figure it out.

Node

title
Person (taxonomy term)

date / unit (taxonomy term in a field collection field of taxonomy term above)

image


texts: How do I redirect on flag save programmatically?

texts:
I want to redirect users to a view when they flag a taxonomy term.
This question is about how to use Rules to redirect on flag save.  I want to do this programmatically.
I tried to use hook_form_alter() to add a submit handler with the redirect.  Unfortunately, while flaggings have an edit form that can be targeted by hook_form_alter() (MYMODULE_form_flagging_FLAGTYPE_edit_form_alter()), they do not seem to have a "create" form.
So how can I add a redirect programmatically upon flagging?
EDIT
Based on 4k4's comment I looked at /flag/srs/Entity/Flagging.php:
 *    "form" = {
 *      "add" = "Drupal\flag\Form\FlaggingForm",
 *      "edit" = "Drupal\flag\Form\FlaggingForm",
 *      "delete" = "Drupal\flag\Form\UnflagConfirmForm"

However, when I tried to do a hook_form_alter() with:

function MYMODULE_form_flagging_FLAGGINGTYPE_add_form_alter(&$form, FormStateInterface $form_state, $form_id)
function MYMODULE_form_flagging_add_form_alter(&$form, FormStateInterface $form_state, $form_id)

I could not get either to pick up my code (I rebuilt the cache).


texts: insert data into database using web service

texts: I am creating a custom web service. In this, as soon as service call, data should be store into database. I am using Hook_service_resource() function. How can i implement insertion into database using services. I created my_module.install file and prepare database schema. BUT i actually don't know how to use query in hook_service_resource() function.


texts: I have a view which generates pages based on taxonomy terms. I have set up a navigation which links to each term in my website. Is there a simple way way I can return a default message if the view is empty?


texts: How will I store the block contents into an array or object?

texts:
Recently, I have an existing Slick Slideshow as a view created from the dashboard.

Right now, I wanted to just manage the slideshow from the backend and then display the slides in a different manner. So, what I have in mind is to store the slideshow data as an array or object and then from there I can freely manipulate/control how would I want my slides to be displayed.

Currently, when I use print_r() the slideshow displayed is already an html markup, I want to get the raw data of the slideshows in an array or an object. How would I do that? I am by the way a Drupal 7 newbie. Thanks a lot.


texts: What all contributes to drupal page execution time?

texts:
I have a site I am investigating that has major performance issues, using memcache I was able to bring number of queries down both in number and total exectution time ( from 3 secs to 230 ms) but the page execution time is eluding me ( I am looking at values outputted by devel) my understanding is that page execution time = time taken for php to execute therefore I installed APC and I can see php opcode being cached and stats showing hits in APC control panel ( apc.php shipped with APC ) but my page execution time does not go down. So I think my question is two-fold:

What all contributes to ( better slows down) page execution time? Is it just time taken to execute php?
What approaches should I take to bring down page execution time. I tried APC but not much help

P.S number of modules used on this site is just enormous ( 168 ) but right now I am not in a position to make that recommendation, its more like a fire in the hole situation.

Edit: Output of running xhprof on local instance (recommended by mikeytown), this seems to be crazy I think the later results are due to thrashing? diff runs for the same url have drastic difference and its just too much resource usage. Also not sure why is it showing values which are not from today :| (I just installed xhprof on this laptop)


texts: Modify custom module's setting.yml without reinstalling

texts:
I have made a simple custom module in Drupal 8, in which I use a settings file (config/install/my_module.settings.yml)

I have one entry, let's say

module:
  key: 'qsdqsd'

So when I install the module, I can use this entry in my controllers.
But if I need to modify anything in this file (adding an entry, for instance...) I can't use it in my controllers (config->get(module.new_entry) returns NULL) unless I uninstall then reinstall the module.

drush cache-rebuild did not help neither.

What am I missing?


texts: How to add a Library as a dependencies in another Library?

texts:
I'm building D3 libraries to visualize data. The visualizations require the topojson Javascript library to manipulate geo shapes.

I want to include the topojson javascript library as a dependency in my custom libraries and right now I'm simply including it in the .info file for the each library:

files[js][] = 'js/topojson.v0.min.js'

However, this adds the topojson file to <head> section of the page more than once when I have several of these includes.

I want to be able to load the file once and use it in anyone of my D3 libraries. How do I do that?


texts: What is wrong with my custom token to embed entities via token?

texts:
Edit: I guess it has something to do with the info part:

function mymodule_token_info() {
  $info = array();
  $info['types']['embed'] = array(
    'name' => t('Embed'),
    'description' => t('Embed entities via token.'),
  );
  $info['tokens']['embed'] = array(
    'name' => t('Embed entities using embed:node:nid:viewmode'),
    'description' => t('Embed entities'),
    'dynamic' => TRUE,
  );

  return $info;
}

I wrote a small module to allow embedding entities, such as nodes, via token:

/**
 * Implements hook_tokens().
 */
function mymodule_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = [];

  if ($type == 'embed') {

    // return $replacements;

    foreach ($tokens as $name => $original) {
      $args = explode(':', $name);

      if (count($args) > 1) {
        $entityType = $args[0];
        $entityId = $args[1];
        $viewMode = isset($args[2]) ? $args[2] : 'full';

        $entity = \Drupal::entityTypeManager()->getStorage($entityType)->load($entityId);
        $viewBuilder = \Drupal::entityTypeManager()->getViewBuilder($entityType);
        $renderable = $viewBuilder->view($entity, $viewMode);

        $replacements[$original] = \Drupal::service('renderer')->render($renderable);
      }

      // @todo: use cache bubbleable_metadata better
    }
  }

  return $replacements;
}

The token [embed:node:1] actually works fine.

For some reason though, I get the error:

  Fatal error: Cannot use object of type
  Drupal\Core\StringTranslation\TranslatableMarkup as array in
  /modules/token/src/Token.php on line 89

when saving any node, sometimes even regular admin pages/ forms. Uninstalling my module fixes the issue.

Is something wrong with how I return the replacements?

Token.php:

/**
 * Extracts data from the token data for use in array_multisort().
 *
 * @param array $token_info
 *   List of tokens or token types, each element must have a name key.
 *
 * @return string[]
 *   List of the names keyed by the token key.
 */
protected function prepareMultisort($token_info) {
  $by_name = [];
  foreach ($token_info as $key => $token_info_element) {
    $by_name[$key] = $token_info_element['name'];
  }
  return $by_name;
}


texts: Webform AJAX submission, same problem with multiple approaches

texts:
I'm trying to set up a Webform with AJAX submission. I've tried 3 approaches in order to complete it, all 3 resulted in the same problem.

I've tried the Webform AJAX module, I've tried a code from this answer and I've tried another module that is in sandbox only in Drupal.org but it supposed work just fine.

Some of these approaches worked on other Drupal projects on mine but not on the current one.

After clicking on the Submit button, the little AJAX loading gif shows up and then the gif remains there but the submission never finishes, the form doesn't get submitted. Exactly the same problem for all approaches.

This is a JS error I'm getting in console

Uncaught TypeError: Object function ( selector, context ) {
        // The jQuery object is actually just the init constructor 'enhanced'
        return new jQuery.fn.init( selector, context, rootjQuery );
    } has no method 'handleError' jquery.form.js?v=2.52:12
s jquery.form.js?v=2.52:12
window.(anonymous function) jquery.form.js?v=2.52:12
onload

Do you have any idea what could possibly cause a bug like this in Drupal 7 with AJAX webform submission?


texts: How to customize Commerce order admin view

texts:
I would like to customize the Commerce order admin layout, the tables shown when admin clicks View or Edit in the Orders table.

These pages are typically shown on the following URLs:
yoursite/admin/commerce/orders/order_id/view and
yoursite/admin/commerce/orders/order_id/edit
where order_id is a number.

I want to add a custom column (a field from my product content type) to these tables. I have searched all the views which were created automatically when I installed Commerce but wasn't able to find the one which is rendering these pages.


texts: How to get the View Header and Footer in Custom Module?

texts:
I've made a custom view and display for it like this:

How do I get the Views Header (Global Summary here) ? I'm able to get the Views title  like this:

$views = Views::getView('items_list','page_2');
$views->setOffset($page_id);
$views->execute();
$view_results = $views->result;
print_r( $views->getTitle());exit;

Hope someone could help me out.


texts: Database returning empty result from dynamic-queries

texts:
I have Tested the Query in PHPMyadmin and it work fine, then I use the Query Coder Module to build the query but it keep returning empty. I still went back to use PHPMyAdmin to cross-check it work over their.

What am trying to archive is to pull data from Comment table and a field table linked to fiverstar, below is my SQL

SELECT SUM(`f`.`field_culture_rating`) AS total
FROM
field_data_field_culture f
JOIN comment c ON c.cid = f.entity_id
WHERE  (f.entity_id = c.cid) AND (c.nid = 1)

Here is the Drupal Query

$query = db_select('field_data_field_culture', 'f');
$query->innerJoin('comment', 'c', 'c.cid = f.entity_id');
$query->addExpression('SUM(f.field_culture_rating)', 'total');
$query->fields('f', array('entity_id', 'field_culture_rating'));
$query->fields('c', array('cid', 'nid'));
$query->condition('f.entity_id', 'c.cid');
$query->condition('c.nid', 1);

The above produce:

SELECT f.entity_id AS entity_id, f.field_agriculture_rating AS field_agriculture_rating, c.cid AS cid, c.nid AS nid, SUM(f.field_agriculture_rating) AS total
FROM
{field_data_field_agriculture} f
INNER JOIN {comment} c ON c.cid = f.entity_id
WHERE  (f.entity_id = :db_condition_placeholder_0) AND (c.nid = :db_condition_placeholder_1)

I have use both of these for output but still empty

$result = $query->execute()->fetchField();
$result = $query3->execute()->fetchAssoc();

I dont know what am doing wrong


texts: My question is a little bit vague. Why do we use stdClass(es) to represent objects in Drupal 7? is there a practical use to it ? Why not just using arrays ?


texts: Can www.example.com/node/123 be used as a canonical url?

texts:
We are sharing some of our content with partners and want to include a canonical reference to the pages on our Drupal site.

I like the idea of using www.example.com/node/$nid for the simplicity of it, but I don't know whether it is acceptable for a canonical url to be redirected (as is commonly done with clean urls, path_auto, redirect, etc)?


texts: Authenticate joomla users to drupal website

texts:
I know this is not 100% drupal question but It might be the case that someone has StumbleUpon this one before.

I would like to give the opportunity for people having an account on a Joomla website to login to mysite and create a very basic account(automatically) when doing that.
Something similar to facebookconnect.

Has anyone done this before?

One solution could be to use the connect module and find a way to expose the needed info on the joomla website.


texts: How to load jquery cookie library for anonymous user

texts:
It seems  with login user jQuery Cookie added and worked correctly but when I visit my website with not login user(anonymous) then  I faced with TypeError: $.cookie is not a function. Why This happened and how can I attach jQuery cookie libraries for not logged in users by default?

Notes:
My theme is based on Drupal Bootstrap theme


texts: How to export a view to module file with CTool Bulk Export module?

texts:
I am trying to export some views to module file. It could be done by Views Bulk Export module, but it looks like that Views Bulk Export no longer exists for Views 3??

It (views_export.module) left a node says

<?php
// This module has been removed, and this note is left here to ensure
// that users who don't delete their directory before upgrading have
// the code removed and to let people looking for it to know to use
// the CTools bulk export module instead.

So how can I export my view now?


texts: Migrate module showing 0 processed on production server

texts:
We intend to run regular migrates to update content and the initial migrate was on my local machine.  Now that its up on production I changed the connection strings to the database and its showing 0 processed.  This is the same database structure except one is local and the other is on production.

How can I get migrate module to recognize the production database with these nodes already processed?  I would just reimport them but the problem is that there are other nodes that reference these already and it will mess up a lot of structure.


texts: Custom line items to be included in $order->getTotal()

texts:
I am using Ubercart for our e-commerce on Drupal 8 website. Everything seems to be working fine except for the $order->getTotal() function - it does not somehow pickup the amount from my custom line items (for eg. 'shipping and handling') that I have added to the order.

It only seems to be going over the default 3 line items (subtotal, total, generic) that are provided by the uc_order module.

How can I achieve that? Thank you in advance.


texts:
I've enabled the Commerce Extra Login module and the login form now now appears when an anonymous or a user who is not yet logged in checks out.

Is there a settings which will make login required before a user can continue through the checkout process? I don't want users continuing without logging in or creating an account.


texts:
I have a custom field with formatter which is currently outputting via field.html.twig

I've modified the theme function to

function mymodule_theme()
{
    return [
        'field__field_family_and_education' => ['base_hook' => 'field'],
    ];
}

and the twig debug indicates it's now using this template, however, despite copying the field.html.twig to field--field-family-and-education.html.twig the variables are not being passed to the template. I want the template to reside in the module, not in the main theme so this is being done within the module that defines the field & formatter.

I'm guessing I've missed an obvious step, any ideas?


texts:
I'm working with a site that has many files that have been uploaded to it. Data has been pulled from these files to populate fields such as title, description, etc. Some of these fields contained ampersands which now appear as &.

Is there a way I can batch correct these—such as a find/replace? I tried the Find/Replace Scanner module but it doesn't seem to be able to work with file nodes.


texts: How to access the user's email field with Field Permissions?

texts:
This is a sort of sequel to my previous question How to hide specific fields and the according label in a view, based on field permissions?. One of the fields I'm displaying in my view is the standard User: Email field. I'd like to hide this field in my view except for the administrator and the user himself/herself.

How can I do that? I can't find a way to access the field with the Field Permissions module. If someone could show me a way to do that (my previous question is solved), this question would be solved.

Or is the Field Permissions module not suitable for this situation?


texts: How to uninstall taxonomy_menu keeping and converting links in normal menu items?

texts:
After a migration, I've used Taxonomy_menu module to generate taxonomy menu links from some vocs with hundred of terms.

These terms will never change now, so I don't need to keep enabled TM any more, but I need to keep and convert generated menu links in normal menu items.

I'm going to proceed in this way:

Disable Taxonomy_menu module
Convert all "taxonomy_menu" entries to "menu" in my database ("module" column of "menu_links" table)
Uninstall Taxonomy_menu module

Please tell me if the above stuff is enough and if it is safely, or there will be bad consequences I can't image now.

Thank you very much for helping me

MXT


texts: How can i add WYSIWYG editor for my custom form textarea?

texts:
I wrote a custom form module in that I placed one text area:

I've tried in this way:

$form['message'] = array(
  '#title' => t('Message'),
  '#type' => 'textarea',
  '#format' => 'full_html',
  '#default_value' => isset($ntemplates->message) ? $ntemplates->message : '',
  '#maxlength' => 255,
  '#attributes' => array(
  'class' => array('field_info'),
  'rows' => '5',
  'cols' => '200',
  ),
  '#wysiwyg' => TRUE,
);

But it doesn't work. How can I integrate WYSIWYG editor in to my text area?

Note: I'm using wysiwyg-7.22 and ckeditor-3.6.6.2. In the basic page body section it's working. I wrote one custom module for form. In this I am unable to integrate wysiwyg editor.


texts:
I have problem with import/export. After import it always says that there is changes after sync.

Anyone faced this issues? How to fix it (showing no changes after import all)?


texts: Where are the content types stored in the database?

texts:
In Drupal 7 with this query:

SELECT * FROM node_type;

I can obtain the list of all my content types, now in Drupal 8 I can't find the node_type table.

I know that with this code:

$content_types = \Drupal::service('entity.manager')->getStorage('node_type')->loadMultiple();

$content_types_list = [];
foreach ($content_types as $content_type) {
  $content_types_list[$content_type->id()] = $content_type->label();
}

I can obtain the info, but where is this information stored now in the database?


texts:
I have view with one date field. Now I want to preprocess this date field(lets say I want to change the date format).

Twig file override : views-view-field--field_date.html.twig

Prepocess code I have tried but kint is showing me only DEPTH TOO GREAT value.

function my_sub_theme_preprocess_views_view_field__field_date(&$variables) {
    kint($variables['view']);
}

Please let me know how to preprocess this field. Is it possible to change date format in twig itself?


texts:
I'm on page of my website and I'm viewing it with the theme developer module, which gives me a lot of information. It gives me some theme suggestions based on theme_hook_suggestions() which are:

html__profile_personal
html__profile_personal__%
html__profile_personal__113
html__profile_personal__edit

How can I create a new theme for this page?  What naming convention should I use, given the info above?


texts: Webform depending on Select List - Number of delegates

texts:
Webform 4.x

On a Webform booking form how would one add the functionality where from a dropdown list of number of delegates (1,2,3...) would then add the necessary number fields on the form. So if 1 was selected from a list then only 1 set of fields is presented, but if 2 is selected from the list then 2 set of fields is presented.

For example:

Booking Contact Name: Booking Email address: Number of Delegates:(Select options: 1,2,3,4,5...) Number 2 Selected!

Delegate Name: Delegate Date of Birth:

Delegate Name: Delegate Date of Birth:


texts: How do I enable comments for user profiles?

texts:
With users being entities in D7 I assumed the user type would would have built in "comment" option. That doesn't seem to be the case.
I just want to allow users to leave comments on the user profile page. Is there a simple way to doing that?


texts:
I been using Drupal for a while, but I am completely in the dark when it comes to Roles, permissions, etc.

What I want to do is have all my content types, but I want to restrict certain nodes for certain roles. Does anybody know any modules or if the core can do this? The reason why I am doing this is to share with a specific group of people on my site.

Thanks!


texts: Views - adding relationship adds duplicate row for each relation

texts:
Sorry if the title is a little vague, I don't know how else to describe it in the space.

I have a view that shows Drupal Commerce
orders. I am trying to add the SKUs of each product in an order as a field for filtering reasons. However, when I add a relationship to reference line items in the orders, I end up with duplicate rows, one for every line item in an order. I've tried aggregation and making queries distinct, neither of which do what I want.


texts: D8 Widget Column is missing on manage field page

texts:
I haven't worked with Drupal for a long time and particularly I never worked with D8. Looks like the manage fields screen doesn't have widget column. Specifically I would like to use https://www.drupal.org/project/inline_entity_form widget for entity reference field, but I couldn't figure out where do I go to change widget type for the reference field.

See screenshot:
https://screencast.com/t/eZvspoNHTDQv


texts: How to show " 1 new" when there is a new message when using views to override private messages block

texts:
I have private messages installed. In my project, I disabled the block that comes with the private messages module. Using views, I created a link that allows users access their private messages.

In the default private message block, the word "new" appears beside the "message link", when the user has a new message.

Please, how can I mimick this attribute in my custom message link.

Thank you.


texts:
Sometime back I'd gone through a Lullabot video that showed me how to simply click a form and see all its elements using Krumo using Devel module.

But I've searched all internet I'm not able to find this feature. How do I simply click a form and see all of it's elements in Krumo?


texts: How do I invoke a service after submitting a form?

texts:
I am very new to Drupal and I am asked to create form with a submit button and a service that makes a get request to an API with the values from the form. The API is a simple API that the user can enter a country and it will return a response with the correct greeting from that country.
This is my routing file.
hello_world.salutation:
  path: '/hello'
  defaults:
    _controller: Drupal\hello_world\Controller\HelloWorldSalutation::salutation
    _form: Drupal\hello_world\Form\GreetingForm
    _title: 'Get a greeting from a different language'
  requirements:
    _permission: 'administer site configuration'

First problem is that I do not know how to make the form and the controller in the same routing,
and second is that I do not know how to invoke that service when the user has entered submit.
This is the services file.
services:
  hello_world.salutation:
    class: Drupal\hello_world\HelloWorldSalutation
    arguments: [ '@config.factory' ,'@tempstore.private']
  cache.nameofbin:
    class: Drupal\Core\Cache\CacheBackendInterface
    tags:
      - { name: cache.bin }
    factory: [ '@cache_factory', 'get' ]
    arguments: [ nameofbin ]

I will skip some lines from the GreetingFrom class to keep it simple, but I can add them if it is required.
Here is the submitForm function from the GreetingForm class. The idea is to put the input in a global tempstore so I cal access the values from the controller I guess.
  public function submitForm(array &$form, FormStateInterface $form_state)
  {
    $search_str = $form_state->getValue('greeting');
    // check the input
    $params['items'] = $form_state->getValue('greeting');
    // 2. Create a PrivateTempStore object with the collection 'greetingForm_values'.
    $tempstore = $this->tempStoreFactory->get('greetingForm_values');
    // 3. Store the $params array with the key 'params'.
    try {
      $tempstore->set('params', $params);
    } catch (\Exception $error) {
      // dump the error for now, read error, --fix this!
      dpm($error);
    }
  }

And the salutation function from the controller looks like this.
  public function salutation()
  {
    $tempstore = $this->tempStoreFactory->get('greetingForm_values');
    $params = $tempstore->get('params'); // this value should come from the search form
    return [
      '#markup' => $this->salutation->getGreeting($params),
    ];
  }


texts: Drupal 7 url with hex code for special characters?

texts:
The URLs for a Drupal 7 site are like the following ones:

http://example.com/drupal7/?q=node/1#overlay=%3Fq%3Dnode%252Fadd%252Farticle
http://example.com/drupal7/?q=node/1#overlay=%3Fq%3Dadmin%252Fconfig%252Fcontent%252Fformats

I am into module development and this is quite irritating. How do I display the special characters, the "slashes/", "#", "&" symbols that have been converted to hexadecimal codes?


texts: How to use dependency injection for Plugins/Blocks [\Drupal::formbuilder() and \Drupal::config()]?

texts:
I cannot get my head around this dependency injection theory. How are we supposed to get the below methods aligned with dependency injection?

\Drupal::routeMatch()->getParameter('node');
\Drupal::request();
\Drupal::formBuilder()->getForm('Drupal\enquirycart\Form\EnquiryForm');
\Drupal::config()

Here is a class that I need to fix this warning message when viewed in
https://pareview.sh/

  "\Drupal calls should be avoided in classes, use | | dependency
  injection instead"

    class EnquirycartBlock extends BlockBase implements BlockPluginInterface {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    $default_config = \Drupal::config('enquirycart.settings');

    return [
      'label_display' => FALSE,
      'enquiry_email' => $default_config->get('enquirycart.email'),
    ];

  }

  /**
   * {@inheritdoc}
   */
  public function build() {

    $builtForm = \Drupal::formBuilder()->getForm('Drupal\enquirycart\Form\EnquirycartButtonForm');
    $renderArray['form'] = $builtForm;

    return $renderArray;

  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    $form_new = parent::blockForm($form, $form_state);

    return $form_new;

  }


texts: Views to use currentlylogged in UID or override via URL

texts:
I have followed this:

Drupal 7 views, filter by owner

I have a situation where I want the view to show only results by author UID of currently logged in user and/or have the URI explicitly provide the UID.

I can get one or the other to work but not both -- the URI scheme I have is:

http://mydomain.local/myproject/%/test/test.html

I was thinking the placement of the % might affect the results -- it does not.

Ideally when someone access the page:

http://mydomain.local/myproject/test/

And they are logged in the see the results specific to them

When someone accesses the page:

http://mydomain.local/myproject/3/test

The see only the results for the specific user UID = 3

Any ideas???


texts: How to set default value for textfield programmatically in drupal 7?

texts:
I need a form_alter code or something that I could use to set my field value. I'm getting the value from the parameter and I've tried a lot of ways but nothing works for me. This is the list of codes I've tried on my custom module:

function custommodule_node_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#node']->type == 'custom_package') {
      $default = $_GET['field_product_add_ons'];
      $form["field_add_on_nids"][LANGUAGE_NONE][0]['value']['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE][0]['value']['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE][0]['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE]['#default_value'] = $default;

  }

  if($form_id == 'custom_package') {
      $default = $_GET['field_product_add_ons'];
      $form["field_add_on_nids"][LANGUAGE_NONE][0]['value']['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE][0]['value']['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE][0]['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE]['#default_value'] = $default;

  }
}

I think the code will be simple but the field is still blank. My field is just a single text field.

Thank you in advance for your help!


texts: Drupal 7: Can't Update node using php script

texts:
I'm trying to update a node->body using a php script in my root directory of my Drupal 7.22 installation.I call the script through a browser (firefox) with [http://MYSITEURL/nodeupdate.php]
But somehow I don't get it to work.
Here is the code I use:

<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$nid = 9; // YES node 9 exists.
$node = node_load($nid); // where $nid is the node id

echo "$node->title
"; // Just to make sure it changes the right node and it does.

$node->body[$node->language][0]['value']   = "Test updated";

if( $node = node_submit($node)) {
    node_save($node);
    echo "Node with nid " . $node->nid . " updated!
";
}

print_r($node); // Check if we see any changes.
?>

The script executes fine without any errors. Through the print_r function I can see that the "changed" field and "revision_timestamp" field are changing.
However the body doesn't change!
I have been googling and found many posts from which I gather that this is the way to do it.
What am I missing?


texts:
I used Views Bulk Operations to modify entity values.
I chose  two fields/values to be displayed.

It works fine. But I wanted to remove the checkboxes(the checkboxes are used to choose what values you wanted to be displayed).

I want to automatically display the two fields. Since the other field is dependent to the other field.


texts: Domain Access Module not working for second domain?

texts:
I have installed the Drupal on Main Domain and install the module Domain Access. Under the setting of Domain I have setup the other domain where I want to use .

EX: example.com
Ex: example.com.au

For First domain it's working fine but after setup other domain it's not working . I have added the domain with godaddy account and it created the sub directory with the example.com.au  .

Step by setup:

Install Drupal Primary Domain.Example.com
Add the subdomain example.com.au
Install the Domain Access Module
Configure the Domain Under Setting of Module

It's showing error message during active other domain

The server request to http://example.com.au/ returned a 500 response. To proceed, disable the Test server response in the form.

After uncheck "Test Server Response" able to add the other domain.


texts: How do I apply a defined Image Style as a View Mode for a File field?

texts:
I'm currently working my way through O'Reilly's "Using Drupal", but I appear to have reached an impasse.

I'm trying to specify a view mode for a File field-type which utilises the Media File Selector widget. The problem is, I'm not getting any of my set Image Styles in the View Mode drop-down. I'm just getting:

default
teaser
Full Content etc.

(see screenshot of view mode options: http://i.imgur.com/CdogRKu.png)
(this screenshot shows my image styles: http://i.imgur.com/ZRE8nqO.png)

The book was published April 2012 so I'm not sure if anything might have changed significantly since then? I'm using the most up-to-date version of Drupal and all modules.

Can anyone tell me if this is wrong way to perform this task, and if so what the right way is?

Cheers!


texts: How to sort comments by a new field in the comment table?

texts:
I'm writing a module which allows users to put comment on each paragraph.

I have added a new field to the comment table, called paragraph_id, and in the comment form I have added a field that asks users which paragraph do they want to put comment on.

So now all I have to do is to alter the comment query. So something like what sort comment module does, it alter the comment query so that they got sorted by date, now I have to sort them by paragraph_id field.

This is the sort_comment.module :

  <?php
  /* drupal@ganovelli.it - blackice78 */
 define('SORT_COMMENTS_OLDER_FIRST', 1); // default
 define('SORT_COMMENTS_NEWER_FIRST', 2);
 /* Alter node type form: allow user to decide comments sorting */
  function sort_comments_form_node_type_form_alter(&$form, $form_state) {
  $form['comment']['comment_default_sorting'] = array(
 '#title' => t('Sort'),
 '#type' => 'select',
 '#options' => array(1 => t('Older first'),
                     2 => t('Newer first')),
 '#default_value' => variable_get('comment_default_sorting_' . $form['#node_type']-           >type, SORT_COMMENTS_OLDER_FIRST),
    );
  }
 /* Alter comments query */
 function sort_comments_query_comment_filter_alter(QueryAlterableInterface $query){
 if ( ($node = $query->getMetaData('node')) && (get_class($query) == 'PagerDefault') ) {
  $sort = variable_get('comment_default_sorting_' . $node->type,           SORT_COMMENTS_OLDER_FIRST);
  if ($sort == SORT_COMMENTS_NEWER_FIRST) {
  $orderby =& $query->getOrderBy();
  $expressions =& $query->getExpressions();
  if (isset($orderby['torder'])) {
      unset($expressions['torder']);
      unset($orderby['torder']);
        $orderby['c.thread'] = 'DESC';
      } else {
       $orderby['c.cid'] = 'DESC';
     }
  }
}

So, does anybody know how can I sort the comments by paragraph_id field?


texts: Way to show changes to a particular node to users

texts:
I'm currently looking for a way to show changes that occured on a node and its related nodes.

Currently we are using the diff module and it works great except that it is a bit too advanced on what we show them (ex: html changes).

It there some way or modules to show revisions of a node and it's related nodes in a much simpler way?


texts:
A JS error for devel themer actually :

Uncaught TypeError: Cannot read property 'type' of undefined devel_themer.js?r:193
thmrRebuildPopup devel_themer.js?r:193
themerDoIt devel_themer.js?r:87
themerEvent devel_themer.js?r:126

Any idea about fixing this?


texts: entityQuery filter by content moderation state

texts:
I need to filter a node by moderation state. I am using the Drupal 8 content moderation module.

I basically want to get NIDs of all nodes in draft state. Something similar to this.

$nids = \Drupal::entityQuery('node')
      ->condition('moderation_state', 'draft')
      ->execute();


texts:
I am trying to create a module (Drupal 7) which will have the following workflow:
 1. User enters data via form  (frontend)
 2. The data is validated and get stored in database (custom content type e.g. Reservations )
 3. User will receive confirmation e-mail
 4. User will be redirected to another page
 5. Data will be manipulated by Admin (CRUD functionality)

Ideally, I would create custom content type via GUI e.g. Reservations. And when use the Views module to manipulate the data.
Could anyone suggest any tutorial or explanation about how should I proceed
Pls. Note that already played with Webform module and found that I prefer to do it via custom module and Form API

Thank you in advance


texts: Best practice to separate content per city

texts:
I'm trying to find the best practice to separate user content per country/city in a way that allows the user to select the country or city once so that whenever he adds content it will be automatically assigned to this city/country
and when searching, the results will be related to currently select city too.
so it's more like a global choice across the website.

How is this best achieved usually in drupal,, I used taxonomy to classify content per city.. but this doesn't feel like the solution.
Any guidance is highly appreciated.


texts:
I have installed Drupal 7 in FTP server. I am trying to apply a Drupal patch.

I did see many links online but no one shows how to do it while Drupal is in FTP server of the hosting account. I think there are many ways I can do it. One way would be to get the Net Beans. I am not sure whether I need to install Net Beans in FTP server first or install to my local machine.

If you could provide some details for beginner, it would be helpful.


texts:
I would like to POST a node to REST API on my Drupal site. On that site, I have enabled the following Web services modules:

HAL
HTTP Basic Authentication
REST UI
RESTful Web Services
Serialization

The configuration of REST UI looks like this:

My code is based on this Guzzle example:

$url = 'http://my-site/node?_format=hal_json';
$auth = ['admin', 'password'];
$body = json_encode([
  'title' => [['value' => '2']],
  'field_bar' => [['value' => 'bar']],
  'type' => [['target_id' => 'bar']],
  '_links' => ['type' => [
    'href' => 'http://my-site/rest/type/node/bar'
  ]],
]);
$headers = [
  'Content-Type' => 'application/hal+json',
  'X-CSRF-Token' => 'my-token',
];

try {
  $response = \Drupal::httpClient()
    ->post($url, ['auth' => $auth, 'body' => $body, 'headers' => $headers]);
  $code = $response->getStatusCode();
  if ($code == 200) {
    \Drupal::messenger()->addMessage($this->t('Success!'));
  }
  else {
    \Drupal::messenger()->addMessage($this->t('Bad response!'), 'error');
  }
}
catch (RequestException $e) {
  \Drupal::messenger()->addMessage($this->t('Foo'), 'error');
  \Drupal::messenger()->addMessage(Psr7\str($e->getRequest()));
  if ($e->hasResponse()) {
    \Drupal::messenger()->addMessage(Psr7\str($e->getResponse()));
  }
  watchdog_exception('foo', $e);
}

When it runs, it throws:

  No route found for the specified format hal_json. Supported formats: html.

Full message:

POST /node?_format=hal_json HTTP/1.1 User-Agent: Drupal/8.6.3 (+https://www.drupal.org/) GuzzleHttp/6.3.3 curl/7.54.0 PHP/7.1.14 Authorization: Basic some-string== Host: my-site Content-Type: application/hal+json X-CSRF-Token: my-token {"title":[{"value":"2"}],"field_bar":[{"value":"bar"}],"type":[{"target_id":"bar"}],"_links":{"type":{"href":"http://my-site/rest/type/node/bar"}}}

HTTP/1.1 406 Not Acceptable Cache-Control: must-revalidate, no-cache, private Content-Language: en Content-Type: application/hal+json Date: Sun, 25 Nov 2018 11:19:16 GMT Expires: Sun, 19 Nov 1978 05:00:00 GMT Link: https://my-site/node?_format=html; rel="alternate"; type="text/html" Strict-Transport-Security: max-age=0 Vary: X-Content-Type-Options: nosniff X-Debug-Info: some-string== X-Frame-Options: SAMEORIGIN X-Generator: Drupal 8 (https://www.drupal.org) X-Platform-Cache: MISS X-Platform-Cluster: some-string X-Platform-Processor: some-string X-Platform-Router: some-string X-Request-Id: some-string X-Robots-Tag: noindex, nofollow X-Ua-Compatible: IE=edge Content-Length: 88 {"message":"No route found for the specified format hal_json. Supported formats: html."}

Note: A cURL from the command line works.

Any ideas? Thanks.


texts: Module not appearing in list after pushing to Acquia Cloud

texts:
I have added a new module in my local code repository. After adding, I committed and pushed it to my remote repository on Acquia Cloud, but it is still not showing up in the modules list.

Can anyone suggest why this is happening?


texts: How to create an edit form for admin input

texts:
I would like to create from a module an add/edit form.

For now I made an add form that looks like this:

$form["locationTitle"] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas nosaukums"),
    '#description' => t("Piem. Rīga"),
    '#required' => true
);

$form['locationsLat'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas platums"),
    '#description' => t("Piem. 56.966058"),
    '#required' => true
);

$form['locationLng'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas garums"),
    '#description' => t("Piem. 24.162004"),
    '#required' => true
);

$form['locationDay1'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas pirmdienas darba laiks"),
    '#description' => t("Piem. P 8.00 - 20.00"),
    '#required' => true
);

$form['locationDay2'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas otrdienas darba laiks"),
    '#description' => t("Piem. O 8.00 - 20.00"),
    '#required' => true
);

$form['locationDay3'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas trešdienas darba laiks"),
    '#description' => t("Piem. T 8.00 - 20.00"),
    '#required' => true
);

$form['locationDay4'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas ceturdienas darba laiks"),
    '#description' => t("Piem. C 8.00 - 20.00"),
    '#required' => true
);

$form['locationDay5'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas piektdienas darba laiks"),
    '#description' => t("Piem. Pk 8.00 - 20.00"),
    '#required' => true
);

$form['locationDay6'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas sestdienas darba laiks"),
    '#description' => t("Piem. S 8.00 - 20.00"),
    '#required' => true
);

$form['locationDay7'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas svētdienas darba laiks"),
    '#description' => t("Piem. Sv 8.00 - 20.00"),
    '#required' => true
);

$form['locationTel'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas telefona nr."),
    '#description' => t("Piem. Telefons +371 67225566 Mob +371 28301555"),
    '#required' => true
);

$form['locationDescription'] = array(
    '#type' => 'textfield',
    '#title' => t("Vietas apraksts"),
);

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

I would like an edit version where admin selects one of locations entered and then can edit them. I thought i could add a combobox and let the person pick if wants to edit something or create a new one. The though was to have it all in the same form.. And then it would be dynamic in the choice.

But I dont really have a much of a clue what could i substitute the combobox with.. And If it is even possible to make it that dynamic.

Thanks for help :)


texts: The requested URL /node was not found on this server

texts:
I am setting up Drupal locally in my Ubuntu.
I used drush to download and install Drupal 7. (using mysqladmin to create the database and the user)

All worked well, I have the default homepage, but when I try to do any action (logging in, registering) I get a 404. I imagine the mod_rewrite doesn't work..

I installed the Apache module and enabled it, restarted the server, but no lack...

I am guessing mod_rewrite needs more parameterization...?

update: I can access correctly the page with this url:

http://localhost/index.php?q=user

so I guess my mod_rewrite clearly doesn't work as it should..


texts: How to use a terminate kernel event to log page access statistics?

texts:
In Drupal 7 hook_exit is implemented in the Statistics module to gather statistics for page accesses. This change record suggest the equivalent in Drupal 8 is to listen for kernel.terminate events. Here's my code:

/mymodule/mymodule.services.yml

services:
  mymodule.page_exit:
    class: Drupal\mymodule\EventSubscriber\PageExit
    tags:
      - {name: event_subscriber}

/mymodule/src/Event/Subscriber/PageExit.php

namespace Drupal\mymodule\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;

class PageExit implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    $events[KernelEvents::TERMINATE][] = array('logAccess');
    return $events;
  }

  /**
   * Call this method whenever the KernelEvents::TERMINATE event is dispatched.
   */
  public function logAccess(PostResponseEvent $event) {

    // $access_info = $event->getRequest()

    \Drupal::database()->insert('mymodule_table')
      ->fields(array(
        'hostname' => '?',
        'referrer_url' => '?',
        'timestamp' => REQUEST_TIME,
      ))
      ->execute();
  }
}

Currently, for a single page request, the method logAccess gets called five times. I'm interested in logging the hostname and referrer url of my page visitor, just once.

In essence, I'm trying to port some of this this Drupal 7 code from statistics_exit in statistics.module:

drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);

// For anonymous users unicode.inc will not have been loaded.
include_once DRUPAL_ROOT . '/includes/unicode.inc';
// Log this page access.
db_insert('accesslog')
  ->fields(array(
    // 'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
    // 'path' => truncate_utf8($_GET['q'], 255),
    'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
    'hostname' => ip_address(),
    // 'uid' => $user->uid,
    // 'sid' => session_id(),
    // 'timer' => (int) timer_read('page'),
    'timestamp' => REQUEST_TIME,
  ))
  ->execute();

Any ideas?


texts: I am using node_save() to alter a node field, but HTML code is showing escaped

texts:
This is the code I execute with "Execute PHP" with the Devel module.

$lang = LANGUAGE_NONE; // Replace with ISO639-2 code if localizing
$node_type = 'my_writings'; // Machine name of the content type

$query = new EntityFieldQuery;
$result = $query
  ->entityCondition('entity_type', 'node')
  ->propertyCondition('type', $node_type)
  ->execute();

if (!empty($result['node'])) {
  $nodes = entity_load('node', array_keys($result['node']));

  foreach($nodes as $node) {

    $str=<<<END

 TITLE

Hello world.

END;
    // Replace field_foo with the machine name of the field to update.
    // - 0 refers to specific within the field array, for when the field contains
    //    multiple values. If the field only has one value, it should be 0.
    $node->field_author_box[$lang][0]['value'] = $str;
    node_save($node);
  }
}

The output I get is this HTML code like this.

 TITLE

    Hello world.

The input format is set to Full HTML, but the HTML tags are shown escaped, even if in the database they appear normal.

I tried to re-save the node; then, it is normal. I tried also to use html_entity_decode() without luck, if I do the same with body field then it works fine, but with a new field its showing escaped characters.

What could the problem be?


texts: is it possible to declare an user group for the remote user in aliases.drushrc.php

texts:
I have a different user group for apache on my remote server clould i specify a group for drush sync like remote-user user adds the user or in some similar way
?


texts: changing display depending on fields value

texts:
I want to change how a field value can be displayed to the front-end user,

For example I have an Article content type which have a priority fields,
this priority can be either low or high as a value...

so I want when the priorty is high, my displayed view show me an image icon instead of the high value.


texts: How to set one content type to only one language in a multilingual site?

texts: I have a multi language website, it's for both English and Arabic, the site's default language is English, but for specific content type which is blog section of the website. I need to set it's default language to Arabic and to never translate it's content. Is it possible?


texts: Editable field in view to display editable form only

texts:
I'm using the Editable Views module to create a view in which the user can edit the values of numerous fields.

Currently picking an editable table formatter and adding an editable field results in showing the current value of the field above and an editable form below it.

I would like to show only the form with the current value editable, is it possible?

If its possible with another module, please feel free to suggest.


texts: How to calculate difference between two dates using Global PHP field?

texts:
I have a global PHP field provided by views php module. I tried two functions to calculate the date difference, date_diff() and $fieldDate->difference() but it always gives me an ajax error.
I think it causes by date format of the date field but I don't know how to fix it. What is right here?

$today=date("m/d/Y");
$load = $data->field_field_date_loading[0]['raw']['value'];
$diff=date_diff($load,$today);
echo $diff->format("%R%a days");

or

$today=date("m/d/Y");
$load = $data->field_field_date_loading[0]['raw']['value'];
$diff = $load->difference($today, 'days');
echo $diff;


texts: Structuring a user rating/rebuttal system

texts:
I am looking to create a really basic rating system (user reference and fivestar content type). But I would like to be able to have users rebut ratings if need be. I am just trying to figure out, structurally, how to do it. Would I have to create another content type called rebuttal and reference the rating? What about adding a field to the rating content type with the ability for the referenced user to fill in a text field? Limit comment access to just the rating author and the referenced user?

This may be the wrong forum to ask this, since its an open ended and subjective question. But I guess my question would be "How would you allow users to make selective edits to a node or limit comments to only the node author or referenced user?"


texts: How do you bold the output of the value within the email text? When an email is sent to the submitter I would like to bold a value that is input from the webform.


texts: How to use settings.local.php with Drupal 7?

texts:
I couldn't find answer from previous questions nor drupal.org/pantheon.io.

I don't know that how to get local Drupal to use settings.local.php?

There isn't a settings.php if I clone the repo from pantheon.io nor a settings.local.php.

If i create settings.local.php file it still thinks that it as a fresh install and redirects to install.php. So it doesn't recognize that file.

Naturally, all works if I create a settings.php. Can't I just create settings.php for local development and add it into gitignore so  it won't get pushed to remote repo?


texts:
I am uploading files to s3 bucket. Using exif_orientation to read exif data.
It works fine for local image. But when we are uploading to Amazon s3, it is unable to read EXIF data.
Reason I found is drupal_realpath function, that cant read from remote servers.
What should be the alternative to this?
How can we read EXIF data of a remote image then?

The other thin I am trying is reading EXIF from tmp image..

$source = $_FILES['files']['tmp_name']['field_image_und_9'];
$file_exif = exif_read_data($source);

But that shows this warning...

Warning: exif_read_data(): Unable to open file in _exif_orientation_rotate() (line 53 of /var/www/sitename.com/docroot/sites/all/modules/contrib/exif_orientation/exif_orientation.module).


texts: Drupal 8: Prevent webform from saving IP

texts:
About the webform module: It always stores the IP with a submission unless it's set as confidential. Is there a way to not store the IP while leaving it as not confidential?

In webform/src/WebformSubmissionForm.php is the function save where it sets the remote_addr. Is there any way to hook this? I don't think it works with a custom webform handler...

Thanks! Looking forward for your answers!


texts: How to make all images in Views display at same dimensions

texts:
My preview (thumbnail) images won't seem to display on my Views 3*16 grid page and my edits in the image Filed don't seem to make a different.  How do I ensure and force the Field image (cell) in the said Views page to show all the image content consistent in size? The image is a link to the actual page Node content. I'm probably missing something trivial, but you help would much appreciated.

(I'm using Bootstrap 3, Views 3.7 on Drupal 7.28).

Thanks.


texts: Add bootstrap.inc to file to programatically save nodes

texts:
In Drupal 6 I would add these two lines to my code so that I could programatically import fields without having to create a module for it

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

However, trying to do this in D7, I am getting all types of errors from defined constants not being defined.  What is the proper way to do this in d7?

I have my script ready, and I do not want to spend another several hours writing code just so this can fit nicely into drupal as a module.  Thoughts? thanks!


texts: How do I attach a single-use block through a field?

texts:
I am working on a project that has a lot of custom block types (about 35). They are complex and have a lot of fields. They are being used with Layout Builder so all the blocks that get created are mostly single-use and hidden. The block plugin that is applicable here is the InlineBlock class provided by Layout Builder.
I want to re-use some of these block types in a node field. This usage is identical to how paragraphs are used on a field. The main module I would turn to in this sort of situation is block_field. Unfortunately it does not work with InlineBlocks, I've created an issue about this.
Is there a solution for this problem? Are there other patterns or techniques I'm missing? At this stage my only obvious solution is to convert these types to paragraphs which I know how to use in Layout Builder.


texts:
I have a content type A. In this content type, i have paragraph (between 0 to n) with 2 fields.
First field is content type select (A, B and C).
Second field is based on the first field, only need to show off if the content type selected is B or C (more than that, i need to entityQuery to see if B or C is a child of A).
Can i use form states API to alter the form and only display the second field based on the type selected on the first field ? And also Ajax to reload the content of it ? Do you see an other way ?


texts: Apply text filter (not text format) in Twig

texts:
Is it possible to apply a specific text filter (not a whole text format) to a string in Twig?
(Or at least in template preprocess, if not possible in Twig)

Use case:

I've a special block for hand-picked, trusted editors that allows them to inject unfiltered HTML (for social widgets like Facebook posts, TripAdvisor reviews, etc) into the homepage. Basically it is just a custom content block with a text field, and printed using |raw to avoid style and script tags being from filtered:

{{ content.body.0['#text']|raw }}

This does already work as expected.

Now I've got the additional requirement to apply the text filter from the LinkIt module on this field. The editors want to provide a link to a node, and the link to the node should be printed using the correct language prefix and the SEO-friendly URL alias. E.g. I've got a text field containing something like

Link with correct language prefix and SEO-friendly URL-alias

and I want to run the LinkIt replacement on that field and then output it, but without filtering or escaping any of the JS or CSS.


texts: Display terms, username and user picture in a view block

texts:
I created a new view block and it appears in Article - Content type; In these block I want to display the author's user picture, author's username, post date, category, tags, and comment count.

I succeeded to display user picture, username, but the post date, category, tags, and comment count are from the other article (the first or the last article written by the same author).

I used a few relationships and contextual filters, without success.

Example

I have an article with title "One two three", category numerals, tags "one, two, three, numeral". When someone reads these article, I want that block to show these values:

Category: numerals
Tags: one, two, three, numeral
username
user picture

Is it possible to display all these things in one view?


texts: Drupal commerce: product field based in calculation of other fields

texts:
The commerce product has the field: Price

Then I added two more field: Quantity and Price per Unit

I need the field Price per Unit to take the calculated value from this:

Price per Unit = Price/Quantity

How I get this?


texts: Drupal 7 Remove field suffix from search index

texts:
On my Drupal 7 installation I have many different custom fields with different suffixes. Drupal inserts the suffixes into the search_index table which I need to avoid. I could change the output, so that the suffixes are hardcoded on the template side and only shown if the specific fields are printed, but I don't like this solution.

Is there any other way to tell Drupal which fields to add to search_index and which fields to skip? Any hook I could use?

I'm not sure if I really want to use the Search API Module...


texts: How to convert an HTML website to Drupal 7 nodes?

texts: I have a website that I want to move to Drupal 7. It is in HTML. I want the content to be in nodes. I don't know much about Drupal and so I need help doing this. I don't want to create a new theme because I want the design to change. I just want the content in nodes. How can I do this in Drupal? Is there a module that can help?


texts: Views boolean column if user has a specific role

texts:
I have a standard Drupal installation with Views and Administration Views modules installed.

By default, the Users view has a column Roles with ALL the users roles.

How to include a custom column (to replace the default Roles column) to show if the user has or hasn't a specific role (like a yes/no column)?


texts: Views: Table rows containing multiple nodes by taxonomy tag

texts:
How do I build a staff directory table that displays everyone assigned to a particular assignment? I'm using taxonomy for staff titles and staff assignments.

So in a simple example:

Staff1
- Title1
- Assignment1,Assignment2

Staff2
- Title2
- Assignment1

Staff3
- Title3
- Assignment1,Assignment2

Staff4
- Title2
- Assignment2

Table should be:

| Assignment  | Title1 | Title2 | Title3 |
------------------------------------------
| Assignment1 | Staff1 | Staff2 | Staff3 |
| Assignment2 | Staff1 | Staff4 | Staff3 |


texts: How to prevent certain bundled CKEditor plugins from loading

texts:
There is hook_ckeditor_settings_alter() to change/alter CKEditor settings. But I can't find a way to prevent certain CKEditor plugins from loading.

I am trying to achieve similar behaviors as here: https://www.drupal.org/node/2546048#comment-10188390 but that is for wysiwyg module, we don't use wysiwyg module.